apache-curator

How to programmatically detect which server in ensemble client is connected to?

喜你入骨 提交于 2019-12-07 14:41:03
问题 How to programmatically detect which server in a ZooKeeper ensemble a client is connected to? I'm using the Apache Curator API and I am listening for state changes in connection by registering ConnectionStateListener. I would like to know which server in the ensemble a client is connected to when the client reconnects if the server it was connected to goes down. 回答1: You can see this in the logs produced by Curator. In the example output below, the CuratorFramework client has been given 4

When and why does Curator throw ConnectionLossException?

情到浓时终转凉″ 提交于 2019-12-06 11:44:12
问题 I use Curator 1.2.4 and I keep getting ConnectionLossException when I want to monitor one znode for its children's changes. I then implemented a watcher like this public class CuratorChildWatcherImpl implements CuratorWatcher { private CuratorFramework client; public CuratorChildWatcherImpl(CuratorFramework client) { this.client = client; } @Override public void process(WatchedEvent event) throws Exception { List<String> children=client.getChildren().usingWatcher(this).forPath(event.getPath()

Apache Curator NPE in JsonInstanceSerializer

北城余情 提交于 2019-12-06 00:23:04
I am facing a strange NPE when starting Apache Curator's ServiceProvider . This happens intermittently on the servers, but I was not able to reproduce the error locally, that's why it's so difficult to know what's the problem. Here's the code: CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(zookeeperConnectString, new RetryNTimes(5, 1000)); curatorFramework.start(); ServiceDiscovery<Void> serviceDiscovery = ServiceDiscoveryBuilder.builder(Void.class).basePath(ZK_BASE_PATH).client(curatorFramework).build(); serviceDiscovery.start(); ServiceProvider<Void> serviceProvider =

How to programmatically detect which server in ensemble client is connected to?

你。 提交于 2019-12-05 20:59:14
How to programmatically detect which server in a ZooKeeper ensemble a client is connected to? I'm using the Apache Curator API and I am listening for state changes in connection by registering ConnectionStateListener . I would like to know which server in the ensemble a client is connected to when the client reconnects if the server it was connected to goes down. You can see this in the logs produced by Curator. In the example output below, the CuratorFramework client has been given 4 different ZooKeeper instances in the connectionString that it can connect to. As can be seen in the log, it

When and why does Curator throw ConnectionLossException?

牧云@^-^@ 提交于 2019-12-04 18:27:22
I use Curator 1.2.4 and I keep getting ConnectionLossException when I want to monitor one znode for its children's changes. I then implemented a watcher like this public class CuratorChildWatcherImpl implements CuratorWatcher { private CuratorFramework client; public CuratorChildWatcherImpl(CuratorFramework client) { this.client = client; } @Override public void process(WatchedEvent event) throws Exception { List<String> children=client.getChildren().usingWatcher(this).forPath(event.getPath()); // Do other stuff with the children znode. } } Every 11 seconds the code throws

How to use kazoo client for leader election?

丶灬走出姿态 提交于 2019-12-03 12:06:44
This is the code mentioned on kazoo readthedocs election=zk.Election("/electionpath", "my-identifier") what are the input arguments to be passed to make particular node as leader? (i.e what does /electionpath and my-identifier refers here?) In Short: "/electionpath" is your path of interest where you will be creating nodes, adding data and watching nodes using dataWatchers. "my-identifier" is identifier to the non re-entrant lock which will be used to verify who is the leader out of the contenders and allow writes only to leader. In Detail: To simplify it explaining first why there should be

Using ACL with Curator

て烟熏妆下的殇ゞ 提交于 2019-11-30 16:33:08
问题 Using CuratorFramework, could someone explain how I can: Create a new path Set data for this path Get this path Using username foo and password bar ? Those that don't know this user/pass would not be able to do anything. I don't care about SSL or passwords being sent via plaintext for the purpose of this question. 回答1: ACL in Apache Curator are for access control. Therefore, ZooKeeper do not provide any authentication mechanism like, clients who don't have correct password cannot connect to

How to implement distributed rate limiter?

筅森魡賤 提交于 2019-11-29 06:47:01
问题 Let's say, I have P processes running some business logic on N physical machines. These processes call some web service S, say. I want to ensure that not more than X calls are made to the service S per second by all the P processes combined. How can such a solution be implemented? Google Guava's Rate Limiter works well for processes running on single box, but not in distributed setup. Are there any standard, ready to use, solutions available for JAVA? [may be based on zookeeper] Thanks! 回答1: