|
22 | 22 | import java.lang.reflect.Constructor; |
23 | 23 | import java.net.InetSocketAddress; |
24 | 24 | import java.net.SocketAddress; |
| 25 | +import java.time.Duration; |
25 | 26 | import java.util.ArrayList; |
26 | 27 | import java.util.Collection; |
27 | 28 | import java.util.Collections; |
@@ -462,7 +463,7 @@ public boolean isConnected() { |
462 | 463 | * if an invalid chroot path is specified |
463 | 464 | */ |
464 | 465 | public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher) throws IOException { |
465 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 466 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
466 | 467 | .withDefaultWatcher(watcher) |
467 | 468 | .toOptions()); |
468 | 469 | } |
@@ -517,7 +518,7 @@ public ZooKeeper( |
517 | 518 | int sessionTimeout, |
518 | 519 | Watcher watcher, |
519 | 520 | ZKClientConfig conf) throws IOException { |
520 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 521 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
521 | 522 | .withDefaultWatcher(watcher) |
522 | 523 | .withClientConfig(conf) |
523 | 524 | .toOptions()); |
@@ -586,7 +587,7 @@ public ZooKeeper( |
586 | 587 | Watcher watcher, |
587 | 588 | boolean canBeReadOnly, |
588 | 589 | HostProvider aHostProvider) throws IOException { |
589 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 590 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
590 | 591 | .withDefaultWatcher(watcher) |
591 | 592 | .withCanBeReadOnly(canBeReadOnly) |
592 | 593 | .withHostProvider(ignored -> aHostProvider) |
@@ -660,7 +661,7 @@ public ZooKeeper( |
660 | 661 | HostProvider hostProvider, |
661 | 662 | ZKClientConfig clientConfig |
662 | 663 | ) throws IOException { |
663 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 664 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
664 | 665 | .withDefaultWatcher(watcher) |
665 | 666 | .withCanBeReadOnly(canBeReadOnly) |
666 | 667 | .withHostProvider(ignored -> hostProvider) |
@@ -746,7 +747,7 @@ public ZooKeeper( |
746 | 747 | int sessionTimeout, |
747 | 748 | Watcher watcher, |
748 | 749 | boolean canBeReadOnly) throws IOException { |
749 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 750 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
750 | 751 | .withDefaultWatcher(watcher) |
751 | 752 | .withCanBeReadOnly(canBeReadOnly) |
752 | 753 | .toOptions()); |
@@ -812,7 +813,7 @@ public ZooKeeper( |
812 | 813 | Watcher watcher, |
813 | 814 | boolean canBeReadOnly, |
814 | 815 | ZKClientConfig conf) throws IOException { |
815 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 816 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
816 | 817 | .withDefaultWatcher(watcher) |
817 | 818 | .withCanBeReadOnly(canBeReadOnly) |
818 | 819 | .withClientConfig(conf) |
@@ -877,7 +878,7 @@ public ZooKeeper( |
877 | 878 | Watcher watcher, |
878 | 879 | long sessionId, |
879 | 880 | byte[] sessionPasswd) throws IOException { |
880 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 881 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
881 | 882 | .withDefaultWatcher(watcher) |
882 | 883 | .withSession(sessionId, sessionPasswd) |
883 | 884 | .toOptions()); |
@@ -955,7 +956,7 @@ public ZooKeeper( |
955 | 956 | byte[] sessionPasswd, |
956 | 957 | boolean canBeReadOnly, |
957 | 958 | HostProvider aHostProvider) throws IOException { |
958 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 959 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
959 | 960 | .withDefaultWatcher(watcher) |
960 | 961 | .withSession(sessionId, sessionPasswd) |
961 | 962 | .withCanBeReadOnly(canBeReadOnly) |
@@ -1041,7 +1042,7 @@ public ZooKeeper( |
1041 | 1042 | boolean canBeReadOnly, |
1042 | 1043 | HostProvider hostProvider, |
1043 | 1044 | ZKClientConfig clientConfig) throws IOException { |
1044 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 1045 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
1045 | 1046 | .withSession(sessionId, sessionPasswd) |
1046 | 1047 | .withDefaultWatcher(watcher) |
1047 | 1048 | .withCanBeReadOnly(canBeReadOnly) |
@@ -1072,7 +1073,7 @@ public ZooKeeper( |
1072 | 1073 | @InterfaceAudience.Private |
1073 | 1074 | public ZooKeeper(ZooKeeperOptions options) throws IOException { |
1074 | 1075 | String connectString = options.getConnectString(); |
1075 | | - int sessionTimeout = options.getSessionTimeout(); |
| 1076 | + int sessionTimeout = options.getSessionTimeoutMs(); |
1076 | 1077 | long sessionId = options.getSessionId(); |
1077 | 1078 | byte[] sessionPasswd = sessionId == 0 ? new byte[16] : options.getSessionPasswd(); |
1078 | 1079 | Watcher watcher = options.getDefaultWatcher(); |
@@ -1188,7 +1189,7 @@ public ZooKeeper( |
1188 | 1189 | long sessionId, |
1189 | 1190 | byte[] sessionPasswd, |
1190 | 1191 | boolean canBeReadOnly) throws IOException { |
1191 | | - this(new ZooKeeperBuilder(connectString, sessionTimeout) |
| 1192 | + this(new ZooKeeperBuilder(connectString, Duration.ofMillis(sessionTimeout)) |
1192 | 1193 | .withDefaultWatcher(watcher) |
1193 | 1194 | .withSession(sessionId, sessionPasswd) |
1194 | 1195 | .withCanBeReadOnly(canBeReadOnly) |
|
0 commit comments