Search in sources :

Example 1 with PersistentNode

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);
}
Also used : PersistentNode(org.apache.curator.framework.recipes.nodes.PersistentNode) Synchronized(lombok.Synchronized)

Example 2 with PersistentNode

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);
}
Also used : PersistentNode(org.apache.curator.framework.recipes.nodes.PersistentNode) Synchronized(lombok.Synchronized)

Aggregations

Synchronized (lombok.Synchronized)2 PersistentNode (org.apache.curator.framework.recipes.nodes.PersistentNode)2