com.hazelcast.core.Cluster.getClusterState()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中com.hazelcast.core.Cluster.getClusterState()方法的一些代码示例,展示了Cluster.getClusterState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.getClusterState()方法的具体详情如下:
包路径:com.hazelcast.core.Cluster
类名称:Cluster
方法名:getClusterState

Cluster.getClusterState介绍

[英]Returns the state of the cluster.

If cluster state change is in process, ClusterState#IN_TRANSITION will be returned.

This is a local operation, state will be read directly from local member.
[中]返回群集的状态。
如果集群状态更改正在进行中,则将返回ClusterState#in_转换。
这是一个本地操作,状态将直接从本地成员读取。

代码示例

代码示例来源:origin: hazelcast/hazelcast-code-samples

  1. /**
  2. * @return {@code true} if good, exception otherwise
  3. */
  4. @GetMapping("/k8s")
  5. public String k8s() {
  6. LOGGER.info("k8s()");
  7. ClusterState clusterState = this.hazelcastInstance.getCluster().getClusterState();
  8. if (clusterState == ClusterState.ACTIVE) {
  9. return Boolean.TRUE.toString();
  10. } else {
  11. throw new RuntimeException("ClusterState==" + clusterState);
  12. }
  13. }

代码示例来源:origin: hazelcast/hazelcast-code-samples

  1. public static void main(String[] args) {
  2. System.setProperty("hazelcast.phone.home.enabled", "false");
  3. HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
  4. HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
  5. IMap<Object, Object> map = instance2.getMap("test-map");
  6. // initialize partition assignments
  7. map.size();
  8. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  9. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  10. instance2.getCluster().changeClusterState(ClusterState.NO_MIGRATION);
  11. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  12. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  13. // start a new instance
  14. HazelcastInstance instance3 = Hazelcast.newHazelcastInstance();
  15. System.out.println("Instance-3 Members: " + instance3.getCluster().getMembers());
  16. System.out.println("Instance-3 Cluster State: " + instance3.getCluster().getClusterState());
  17. Hazelcast.shutdownAll();
  18. }
  19. }

代码示例来源:origin: wu191287278/spring-boot-starter-dubbo

  1. @Override
  2. public boolean isAvailable() {
  3. return hazelcastInstance.getCluster().getClusterState().equals(ClusterState.ACTIVE);
  4. }

代码示例来源:origin: hazelcast/hazelcast-code-samples

  1. HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
  2. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  3. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  4. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  5. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  6. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  7. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());

代码示例来源:origin: hazelcast/hazelcast-code-samples

  1. HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
  2. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  3. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  4. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  5. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());
  6. System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState());
  7. System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState());

代码示例来源:origin: hazelcast/hazelcast-jet

  1. public ClusterMetadata(String name, Cluster cluster) {
  2. this.name = name;
  3. this.version = BuildInfoProvider.getBuildInfo().getJetBuildInfo().getVersion();
  4. this.state = cluster.getClusterState();
  5. this.clusterTime = cluster.getClusterTime();
  6. }

代码示例来源:origin: dsukhoroslov/bagri

  1. logger.info("call.exit; cluster not finished migration yet, the state is {} now, skipping population", hz.getCluster().getClusterState());

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. @Override
  2. public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
  3. ClusterState clusterState = mcs.getHazelcastInstance().getCluster().getClusterState();
  4. JsonObject result = new JsonObject();
  5. result.add("result", clusterState.toString());
  6. out.add("result", result);
  7. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. @Override
  2. public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
  3. ClusterState clusterState = mcs.getHazelcastInstance().getCluster().getClusterState();
  4. JsonObject result = new JsonObject();
  5. result.add("result", clusterState.toString());
  6. out.add("result", result);
  7. }

相关文章