Skip to content

Commit a3ed53c

Browse files
committed
[Refactor] Use Duration instead of long for duration-related Zoo Keeper config options
1 parent b24c87e commit a3ed53c

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

fluss-common/src/main/java/com/alibaba/fluss/config/ConfigOptions.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,27 +296,26 @@ public class ConfigOptions {
296296
// ZooKeeper Client Settings
297297
// ------------------------------------------------------------------------
298298

299-
public static final ConfigOption<Integer> ZOOKEEPER_SESSION_TIMEOUT =
299+
public static final ConfigOption<Duration> ZOOKEEPER_SESSION_TIMEOUT =
300300
key("zookeeper.client.session-timeout")
301-
.intType()
302-
.defaultValue(60000)
301+
.durationType()
302+
.defaultValue(Duration.ofMillis(60_000L))
303303
.withDeprecatedKeys("recovery.zookeeper.client.session-timeout")
304-
.withDescription(
305-
"Defines the session timeout for the ZooKeeper session in ms.");
304+
.withDescription("Defines the session timeout for the ZooKeeper session.");
306305

307-
public static final ConfigOption<Integer> ZOOKEEPER_CONNECTION_TIMEOUT =
306+
public static final ConfigOption<Duration> ZOOKEEPER_CONNECTION_TIMEOUT =
308307
key("zookeeper.client.connection-timeout")
309-
.intType()
310-
.defaultValue(15000)
308+
.durationType()
309+
.defaultValue(Duration.ofMillis(15_000L))
311310
.withDeprecatedKeys("recovery.zookeeper.client.connection-timeout")
312-
.withDescription("Defines the connection timeout for ZooKeeper in ms.");
311+
.withDescription("Defines the connection timeout for ZooKeeper.");
313312

314-
public static final ConfigOption<Integer> ZOOKEEPER_RETRY_WAIT =
313+
public static final ConfigOption<Duration> ZOOKEEPER_RETRY_WAIT =
315314
key("zookeeper.client.retry-wait")
316-
.intType()
317-
.defaultValue(5000)
315+
.durationType()
316+
.defaultValue(Duration.ofMillis(5_000L))
318317
.withDeprecatedKeys("recovery.zookeeper.client.retry-wait")
319-
.withDescription("Defines the pause between consecutive retries in ms.");
318+
.withDescription("Defines the pause between consecutive retries.");
320319

321320
public static final ConfigOption<Integer> ZOOKEEPER_MAX_RETRY_ATTEMPTS =
322321
key("zookeeper.client.max-retry-attempts")

fluss-server/src/main/java/com/alibaba/fluss/server/zk/ZooKeeperUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ public static ZooKeeperClient startZookeeperClient(
6161
+ "'.");
6262
}
6363

64-
int sessionTimeout = configuration.getInt(ConfigOptions.ZOOKEEPER_SESSION_TIMEOUT);
64+
int sessionTimeout =
65+
Math.toIntExact(
66+
configuration.get(ConfigOptions.ZOOKEEPER_SESSION_TIMEOUT).toMillis());
6567

66-
int connectionTimeout = configuration.getInt(ConfigOptions.ZOOKEEPER_CONNECTION_TIMEOUT);
68+
int connectionTimeout =
69+
Math.toIntExact(
70+
configuration.get(ConfigOptions.ZOOKEEPER_CONNECTION_TIMEOUT).toMillis());
6771

68-
int retryWait = configuration.getInt(ConfigOptions.ZOOKEEPER_RETRY_WAIT);
72+
int retryWait =
73+
Math.toIntExact(configuration.get(ConfigOptions.ZOOKEEPER_RETRY_WAIT).toMillis());
6974

7075
int maxRetryAttempts = configuration.getInt(ConfigOptions.ZOOKEEPER_MAX_RETRY_ATTEMPTS);
7176

website/docs/maintenance/configuration.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ during the Fluss cluster working.
6666
6767
### Zookeeper
6868
69-
| Option | Type | Default | Description |
70-
|-------------------------------------------------|---------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71-
| zookeeper.address | String | (None) | The ZooKeeper address to use, when running Fluss with ZooKeeper. |
72-
| zookeeper.path.root | String | /fluss | The root path under which Fluss stores its entries in ZooKeeper. |
73-
| zookeeper.client.session-timeout | Integer | 60000 | Defines the session timeout for the ZooKeeper session in ms. |
74-
| zookeeper.client.connection-timeout | Integer | 15000 | Defines the connection timeout for ZooKeeper in ms. |
75-
| zookeeper.client.retry-wait | Integer | 5000 | Defines the pause between consecutive retries in ms. |
76-
| zookeeper.client.max-retry-attempts | Integer | 3 | Defines the number of connection retries before the client gives up. |
77-
| zookeeper.client.tolerate-suspended-connections | Boolean | false | Defines whether a suspended ZooKeeper connection will be treated as an error that causes the leader information to be invalidated or not. In case you set this option to %s, Fluss will wait until a ZooKeeper connection is marked as lost before it revokes the leadership of components. This has the effect that Fluss is more resilient against temporary connection instabilities at the cost of running more likely into timing issues with ZooKeeper. |
78-
| zookeeper.client.ensemble-tracker | Boolean | true | Defines whether Curator should enable ensemble tracker. This can be useful in certain scenarios in which CuratorFramework is accessing to ZK clusters via load balancer or Virtual IPs. Default Curator EnsembleTracking logic watches CuratorEventType.GET_CONFIG events and changes ZooKeeper connection string. It is not desired behaviour when ZooKeeper is running under the Virtual IPs. Under certain configurations EnsembleTracking can lead to setting of ZooKeeper connection string with unresolvable hostnames. |
69+
| Option | Type | Default | Description |
70+
|-------------------------------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71+
| zookeeper.address | String | (None) | The ZooKeeper address to use, when running Fluss with ZooKeeper. |
72+
| zookeeper.path.root | String | /fluss | The root path under which Fluss stores its entries in ZooKeeper. |
73+
| zookeeper.client.session-timeout | Duration | 60s | Defines the session timeout for the ZooKeeper session in ms. |
74+
| zookeeper.client.connection-timeout | Duration | 15s | Defines the connection timeout for ZooKeeper in ms. |
75+
| zookeeper.client.retry-wait | Duration | 5s | Defines the pause between consecutive retries in ms. |
76+
| zookeeper.client.max-retry-attempts | Integer | 3 | Defines the number of connection retries before the client gives up. |
77+
| zookeeper.client.tolerate-suspended-connections | Boolean | false | Defines whether a suspended ZooKeeper connection will be treated as an error that causes the leader information to be invalidated or not. In case you set this option to %s, Fluss will wait until a ZooKeeper connection is marked as lost before it revokes the leadership of components. This has the effect that Fluss is more resilient against temporary connection instabilities at the cost of running more likely into timing issues with ZooKeeper. |
78+
| zookeeper.client.ensemble-tracker | Boolean | true | Defines whether Curator should enable ensemble tracker. This can be useful in certain scenarios in which CuratorFramework is accessing to ZK clusters via load balancer or Virtual IPs. Default Curator EnsembleTracking logic watches CuratorEventType.GET_CONFIG events and changes ZooKeeper connection string. It is not desired behaviour when ZooKeeper is running under the Virtual IPs. Under certain configurations EnsembleTracking can lead to setting of ZooKeeper connection string with unresolvable hostnames. |
7979
8080
### Netty
8181

0 commit comments

Comments
 (0)