/** * @return {@code true} if good, exception otherwise */ @GetMapping("/k8s") public String k8s() { LOGGER.info("k8s()"); ClusterState clusterState = this.hazelcastInstance.getCluster().getClusterState(); if (clusterState == ClusterState.ACTIVE) { return Boolean.TRUE.toString(); } else { throw new RuntimeException("ClusterState==" + clusterState); } }
public static void main(String[] args) { System.setProperty("hazelcast.phone.home.enabled", "false"); HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); IMap<Object, Object> map = instance2.getMap("test-map"); // initialize partition assignments map.size(); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); instance2.getCluster().changeClusterState(ClusterState.NO_MIGRATION); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); // start a new instance HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(); System.out.println("Instance-3 Members: " + instance3.getCluster().getMembers()); System.out.println("Instance-3 Cluster State: " + instance3.getCluster().getClusterState()); Hazelcast.shutdownAll(); } }
@Override public boolean isAvailable() { return hazelcastInstance.getCluster().getClusterState().equals(ClusterState.ACTIVE); }
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
public ClusterMetadata(String name, Cluster cluster) { this.name = name; this.version = BuildInfoProvider.getBuildInfo().getJetBuildInfo().getVersion(); this.state = cluster.getClusterState(); this.clusterTime = cluster.getClusterTime(); }
logger.info("call.exit; cluster not finished migration yet, the state is {} now, skipping population", hz.getCluster().getClusterState());
@Override public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception { ClusterState clusterState = mcs.getHazelcastInstance().getCluster().getClusterState(); JsonObject result = new JsonObject(); result.add("result", clusterState.toString()); out.add("result", result); }
@Override public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception { ClusterState clusterState = mcs.getHazelcastInstance().getCluster().getClusterState(); JsonObject result = new JsonObject(); result.add("result", clusterState.toString()); out.add("result", result); }