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()); } }
@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); }
@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); }
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(); }