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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

相关文章