use of org.apache.curator.framework.recipes.nodes.PersistentNode in project pravega by pravega.
the class ClusterZKImpl method registerHost.
/**
* Register Host to cluster.
*
* @param host Host to be part of cluster.
*/
@Override
@Synchronized
public void registerHost(Host host) {
Preconditions.checkNotNull(host, "host");
Exceptions.checkArgument(!entryMap.containsKey(host), "host", "host is already registered to cluster.");
String hostPath = ZKPaths.makePath(getPathPrefix(), host.toString());
PersistentNode node = new PersistentNode(client, CreateMode.EPHEMERAL, false, hostPath, SerializationUtils.serialize(host));
// start creation of ephemeral node in background.
node.start();
entryMap.put(host, node);
}
use of org.apache.curator.framework.recipes.nodes.PersistentNode in project pravega by pravega.
the class ClusterZKImpl method deregisterHost.
/**
* Remove Host from cluster.
*
* @param host Host to be removed from cluster.
*/
@Override
@Synchronized
public void deregisterHost(Host host) {
Preconditions.checkNotNull(host, "host");
PersistentNode node = entryMap.get(host);
Preconditions.checkNotNull(node, "Host is not present in cluster.");
entryMap.remove(host);
close(node);
}
Aggregations