public class ZooKeeperConfig extends Object implements Serializable
Example of use:
final GrizzlyThriftClientManager.Builder managerBuilder = new GrizzlyThriftClientManager.Builder();
// setup zookeeper server
final ZooKeeperConfig zkConfig = ZooKeeperConfig.create("thrift-client-manager", DEFAULT_ZOOKEEPER_ADDRESS);
zkConfig.setRootPath(ROOT);
zkConfig.setConnectTimeoutInMillis(3000);
zkConfig.setSessionTimeoutInMillis(30000);
zkConfig.setCommitDelayTimeInSecs(2);
managerBuilder.zooKeeperConfig(zkConfig);
// create a thrift client manager
final GrizzlyThriftClientManager manager = managerBuilder.build();
final GrizzlyThriftClient.Builder<String, String> thriftClientBuilder = manager.createThriftClientBuilder("user");
// setup thrift servers
final Set<SocketAddress> thriftServers = new HashSet<SocketAddress>();
thriftServers.add(THRIFT_SERVER_ADDRESS1);
thriftServers.add(THRIFT_SERVER_ADDRESS2);
thriftClientBuilder.servers(thriftServers);
// create a user thrift client
final GrizzlyThriftClient thriftClient = thriftClientBuilder.build();
// ...
// clean
manager.removeThriftClient("user");
manager.shutdown();
| Modifier and Type | Method and Description |
|---|---|
static ZooKeeperConfig |
create(String name,
String zooKeeperServerList)
Create ZKClient's configuration with the specific name or Id
|
long |
getCommitDelayTimeInSecs() |
long |
getConnectTimeoutInMillis() |
String |
getName() |
String |
getRootPath() |
long |
getSessionTimeoutInMillis() |
String |
getZooKeeperServerList() |
void |
setCommitDelayTimeInSecs(long commitDelayTimeInSecs)
Delay time in seconds for committing
|
void |
setConnectTimeoutInMillis(long connectTimeoutInMillis)
Connect timeout in milli-seconds
|
void |
setRootPath(String rootPath)
Root path for ZKClient
|
void |
setSessionTimeoutInMillis(long sessionTimeoutInMillis)
Session timeout in milli-seconds
|
String |
toString() |
public static ZooKeeperConfig create(String name, String zooKeeperServerList)
name - name or idzooKeeperServerList - comma separated host:port pairs, each corresponding to a zookeeper server.
e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"public void setRootPath(String rootPath)
rootPath - root path of the zookeeper. default is "/".public void setConnectTimeoutInMillis(long connectTimeoutInMillis)
connectTimeoutInMillis - connect timeout. negative value means "never timed out". default is 5000(5 secs).public void setSessionTimeoutInMillis(long sessionTimeoutInMillis)
sessionTimeoutInMillis - Zookeeper connection's timeout. default is 30000(30 secs).public void setCommitDelayTimeInSecs(long commitDelayTimeInSecs)
commitDelayTimeInSecs - delay time before committing. default is 60(60secs).public String getName()
public String getZooKeeperServerList()
public String getRootPath()
public long getConnectTimeoutInMillis()
public long getSessionTimeoutInMillis()
public long getCommitDelayTimeInSecs()
Copyright © 2017-2019 Oracle Corporation. All Rights Reserved.