use of tezc.core.cluster.RaftCluster 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.RaftCluster in project tezcRaft by tezc.
the class App method start.
public void start(List<State> states, String name) throws IOException {
TlsConfig tlsConfig = new TlsConfig(null, null, null, null, null, null, null, null, null, null);
Config config = new Config();
config.setLogLevel("DEBUG");
config.setTlsConfig(tlsConfig);
Tezc tezc = new Tezc("./cluster1/" + name, this, config);
RaftCluster cluster = tezc.openCluster("cluster1", states);
if (!cluster.isStarted()) {
NodeRecord nodeRecord1 = new NodeRecord("node0", "group0");
nodeRecord1.addTransport(new TransportRecord("tcp", "127.0.0.1", 9090));
/*NodeRecord nodeRecord2 = new NodeRecord("node1", "group0");
nodeRecord2.addTransport(new TransportRecord("tcp", "127.0.0.1", 9091));
NodeRecord nodeRecord3 = new NodeRecord("node2", "group1");
nodeRecord3.addTransport(new TransportRecord("tcp", "127.0.0.1", 9092));*/
cluster.setLocal(Integer.parseInt(name));
cluster.addNode(nodeRecord1);
// cluster.addNode(nodeRecord2);
// cluster.addNode(nodeRecord3);
}
cluster.run();
}
Aggregations