use of tezc.core.cluster.Cluster in project tezcRaft by tezc.
the class Core method openCluster.
/**
* Open cluster, if does not exist, a new one will be created
* @param name cluster name
* @param states state map of the cluster
* @return cluster object
* @throws IOException on any IO error
*/
public RaftCluster openCluster(String name, List<State> states) throws IOException {
Cluster cluster;
synchronized (lock) {
cluster = clusters.get(name);
if (cluster == null) {
ClusterWorker worker = getClusterWorker();
ClusterWorker snapshotWorker = getSnapshotWorker();
cluster = new Cluster(this, name, workingDir, worker, snapshotWorker, states);
clusters.put(name, cluster);
}
}
return cluster;
}
use of tezc.core.cluster.Cluster in project tezcRaft by tezc.
the class Core method removeCluster.
/**
* Remove cluster, if running, will be stopped first, than will be deleted,
* this a non blocking call, it may take a while to stop working gracefully
* @param name cluster name
* @throws IOException on any IO error
*/
public void removeCluster(String name) throws IOException {
Cluster cluster = clusters.get(name);
if (cluster == null) {
throw new RaftException("Cannot find cluster with name : " + name);
}
cluster.remove();
}
use of tezc.core.cluster.Cluster in project tezcRaft by tezc.
the class IOWorker method handleConnectReqMsg.
/**
* Received connect request, pass it to related cluster worker
* @param conn connection
* @param req connect request
*/
public void handleConnectReqMsg(Connection conn, ConnectReq req) {
pendings.remove(conn);
conn.unregister();
Cluster cluster = core.getCluster(req.getClusterName());
if (cluster != null) {
core.getIOWorker().sendAddConnectionEvent(conn);
cluster.sendIncomingConnEvent(conn, req);
} else {
logInfo("Cannot find cluster for ", req.getClusterName());
conn.disconnect(false);
}
}
use of tezc.core.cluster.Cluster in project tezcRaft by tezc.
the class ClusterWorker method eventsDrained.
/**
* All events are processed
*/
@Override
public void eventsDrained() {
try {
for (PeerNode node : readyNodes) {
node.handleMsgs();
}
readyNodes.clear();
for (Cluster cluster : readyClusters) {
cluster.flush();
}
readyClusters.clear();
} catch (Exception e) {
logError(e);
}
}
Aggregations