本文整理了Java中com.hazelcast.core.Cluster.shutdown()
方法的一些代码示例,展示了Cluster.shutdown()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.shutdown()
方法的具体详情如下:
包路径:com.hazelcast.core.Cluster
类名称:Cluster
方法名:shutdown
[英]Changes state of the cluster to the ClusterState#PASSIVE transactionally, then triggers the shutdown process on each node. Transaction will be TWO_PHASEand will have 1 durability by default. If you want to override transaction options, use #shutdown(TransactionOptions).
If the cluster is already in ClusterState#PASSIVE, shutdown process begins immediately. All the node join / leave rules described in ClusterState#PASSIVE state also applies here.
Any node can start the shutdown process. A shutdown command is sent to other nodes periodically until either all other nodes leave the cluster or a configurable timeout occurs (see GroupProperty#CLUSTER_SHUTDOWN_TIMEOUT_SECONDS). If some of the nodes do not shutdown before the timeout duration, shutdown can be also invoked on them.
[中]以事务方式将集群的状态更改为ClusterState#被动,然后在每个节点上触发关闭进程。事务将是两个阶段,默认情况下将有1个持久性。如果要覆盖事务选项,请使用#shutdown(TransactionOptions)。
如果集群已经处于ClusterState#被动状态,则关闭过程立即开始。ClusterState#被动状态中描述的所有节点加入/离开规则也适用于此处。
任何节点都可以启动关闭过程。定期向其他节点发送关机命令,直到所有其他节点离开集群或出现可配置超时(请参阅GroupProperty#cluster _shutdown _timeout _SECONDS)。如果某些节点在超时持续时间之前未关闭,也可以对其调用shutdown。
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
System.out.println("Instance-1 members: " + instance1.getCluster().getMembers());
System.out.println("Instance-2 members: " + instance2.getCluster().getMembers());
// shutdown cluster
instance2.getCluster().shutdown();
System.out.println("Instance-1: Is running?: " + instance1.getLifecycleService().isRunning());
System.out.println("Instance-2: Is running?: " + instance2.getLifecycleService().isRunning());
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
String resultString = "SUCCESS";
try {
mcs.getHazelcastInstance().getCluster().shutdown();
} catch (Exception e) {
ILogger logger = mcs.getHazelcastInstance().node.nodeEngine.getLogger(getClass());
logger.warning("Cluster can not be shutdown: ", e);
resultString = e.getMessage();
}
JsonObject result = new JsonObject().add("result", resultString);
out.add("result", result);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
String resultString = "SUCCESS";
try {
mcs.getHazelcastInstance().getCluster().shutdown();
} catch (Exception e) {
ILogger logger = mcs.getHazelcastInstance().node.nodeEngine.getLogger(getClass());
logger.warning("Cluster can not be shutdown: ", e);
resultString = e.getMessage();
}
JsonObject result = new JsonObject().add("result", resultString);
out.add("result", result);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
IOUtil.delete(new File(HOT_RESTART_ROOT_DIR + "5701"));
IOUtil.delete(new File(HOT_RESTART_ROOT_DIR + "5702"));
HazelcastInstance instance1 = newHazelcastInstance(5701);
HazelcastInstance instance2 = newHazelcastInstance(5702);
Cache<Integer, String> cache = createCache(instance1);
for (int i = 0; i < 50; i++) {
cache.put(i, "value" + i);
}
instance2.getCluster().shutdown();
// Offloading to a thread.
// Because all instances should start in parallel
// to be able to do hot-restart cluster verification
new Thread() {
public void run() {
newHazelcastInstance(5701);
}
}.start();
instance2 = newHazelcastInstance(5702);
instance2.getCluster().changeClusterState(ClusterState.ACTIVE);
cache = createCache(instance2);
for (int i = 0; i < 50; i++) {
System.out.println("cache.get(" + i + ") = " + cache.get(i));
}
Hazelcast.shutdownAll();
}
内容来源于网络,如有侵权,请联系作者删除!