public synchronized void joinCluster(ZuCluster cluster, Set<Integer> shards) throws JoinException, InterruptedException { String clusterId = cluster.getClusterId(); List<EndpointStatus> endpoints = endpointMap.get(clusterId); if (endpoints == null) { endpoints = cluster.join(addr, shards); endpointMap.put(clusterId, endpoints); } else { throw new JoinException("cluster " + clusterId + " already joined, leave first", null); } }
public void leaveCluster(ZuCluster cluster) throws UpdateException { List<EndpointStatus> endpoints = endpointMap.remove(cluster.getClusterId()); if (endpoints != null) { cluster.leave(endpoints); } }