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

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

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

Cluster.getLocalMember介绍

[英]Returns this Hazelcast instance member.

The returned value will never be null, but it may change when local lite member is promoted to a data member via #promoteLocalLiteMember()or when this member merges to a new cluster after split-brain detected. Returned value should not be cached but instead this method should be called each time when local member is needed.
[中]返回此Hazelcast实例成员。
返回的值永远不会为null,但当本地lite成员通过#PromoteLocallitemMember()升级为数据成员时,或当检测到拆分后该成员合并到新群集时,返回值可能会更改。不应缓存返回值,而是应在每次需要本地成员时调用此方法。

代码示例

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

  1. public Integer call() throws Exception {
  2. System.out.println("Running a computation heavy task on " + hz.getCluster().getLocalMember());
  3. return 0;
  4. }
  5. }

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dataservice.core

  1. @Override
  2. public Object getLocalMember() {
  3. return this.hz.getCluster().getLocalMember();
  4. }

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

  1. /**
  2. * Return the name of the current Hazelcast instance.
  3. */
  4. @Override
  5. public String call() throws Exception {
  6. String uuid = hazelcastInstance.getCluster().getLocalMember().getUuid();
  7. log.info("call() runs on {}", uuid);
  8. return uuid;
  9. }

代码示例来源:origin: stevensouza/jamonapi

  1. @Override
  2. public String getInstance() {
  3. intitialize();
  4. return hazelCast.getCluster().getLocalMember().toString();
  5. }

代码示例来源:origin: io.snamp/internal-services

  1. HazelcastCommunicator(final HazelcastInstance hazelcast,
  2. final String communicatorName){
  3. super(hazelcast, communicatorName, HazelcastInstance::getTopic);
  4. this.hazelcast = Objects.requireNonNull(hazelcast);
  5. localMember = hazelcast.getCluster().getLocalMember().getUuid();
  6. }

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

  1. public static void main(String[] args) {
  2. HazelcastInstance node1 = Hazelcast.newHazelcastInstance();
  3. HazelcastInstance node2 = Hazelcast.newHazelcastInstance();
  4. Member member2 = node2.getCluster().getLocalMember();
  5. boolean member2Safe = node1.getPartitionService().isMemberSafe(member2);
  6. System.out.printf("# Is member2 safe for shutdown\t: %s\n", member2Safe);
  7. }
  8. }

代码示例来源:origin: apache/karaf-cellar

  1. public void setNodeAlias(String alias) {
  2. Cluster cluster = instance.getCluster();
  3. if (cluster != null) {
  4. Member member = cluster.getLocalMember();
  5. member.setStringAttribute("alias", alias);
  6. }
  7. }

代码示例来源:origin: io.snamp/internal-services

  1. /**
  2. * Gets address of this node.
  3. *
  4. * @return Address of this node.
  5. */
  6. @Override
  7. public InetSocketAddress getAddress() {
  8. return hazelcast.getCluster().getLocalMember().getSocketAddress();
  9. }

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

  1. private void signalStartToAgent() {
  2. String address;
  3. if (serverInstance == null) {
  4. address = "client:" + getHostAddress();
  5. } else {
  6. InetSocketAddress socketAddress = serverInstance.getCluster().getLocalMember().getInetSocketAddress();
  7. address = socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort();
  8. }
  9. File file = new File("worker.address");
  10. writeObject(address, file);
  11. }

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

  1. private Address getThisAddress(HazelcastInstance hazelcastInstance) {
  2. try {
  3. return hazelcastInstance.getCluster().getLocalMember().getAddress();
  4. } catch (UnsupportedOperationException e) {
  5. return null;
  6. }
  7. }

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

  1. @Override
  2. public CompositeData call() throws Exception {
  3. int[] counters = hMgr.getCounters();
  4. Map<String, Object> result = new HashMap<>(3);
  5. result.put("Active docs", counters[0]);
  6. result.put("Inactive docs", counters[1]);
  7. Member m = hzInstance.getCluster().getLocalMember();
  8. result.put("Member", m.getSocketAddress().toString() + " [" + m.getUuid() + "]");
  9. return JMXUtils.mapToComposite("Counters", "Description", result);
  10. }

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

  1. @Override
  2. public String call() {
  3. hz.getCountDownLatch("latch").countDown();
  4. return hz.getCluster().getLocalMember().toString() + ":" + input;
  5. }

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

  1. public PartitionServiceBeanDTO(InternalPartitionService partitionService,
  2. HazelcastInstanceImpl hazelcastInstance) {
  3. Address address = hazelcastInstance.getCluster().getLocalMember().getAddress();
  4. this.partitionCount = partitionService.getPartitionCount();
  5. this.activePartitionCount = partitionService.getMemberPartitionsIfAssigned(address).size();
  6. }

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

  1. public PartitionServiceBeanDTO(InternalPartitionService partitionService,
  2. HazelcastInstanceImpl hazelcastInstance) {
  3. Address address = hazelcastInstance.getCluster().getLocalMember().getAddress();
  4. this.partitionCount = partitionService.getPartitionCount();
  5. this.activePartitionCount = partitionService.getMemberPartitionsIfAssigned(address).size();
  6. }

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

  1. public static void main(String[] args) throws Exception {
  2. HazelcastInstance instance = Hazelcast.newHazelcastInstance();
  3. IScheduledExecutorService scheduler = instance.getScheduledExecutorService("scheduler");
  4. IScheduledFuture<String> future = scheduler.scheduleOnMember(new EchoTask("My Task"),
  5. instance.getCluster().getLocalMember(), 5, TimeUnit.SECONDS);
  6. Object result = future.get();
  7. System.out.println("Result: " + result);
  8. future.dispose();
  9. Hazelcast.shutdownAll();
  10. }
  11. }

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

  1. @ManagedAnnotation("activePartitionCount")
  2. @ManagedDescription("Number of active partitions")
  3. public int getActivePartitionCount() {
  4. Address thisAddress = hazelcastInstance.getCluster().getLocalMember().getAddress();
  5. return managedObject.getMemberPartitionsIfAssigned(thisAddress).size();
  6. }

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

  1. @ManagedAnnotation("activePartitionCount")
  2. @ManagedDescription("Number of active partitions")
  3. public int getActivePartitionCount() {
  4. Address thisAddress = hazelcastInstance.getCluster().getLocalMember().getAddress();
  5. return managedObject.getMemberPartitionsIfAssigned(thisAddress).size();
  6. }

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

  1. private static InetSocketAddress getInetSocketAddress(HazelcastInstance hazelcastInstance) {
  2. try {
  3. return (InetSocketAddress) hazelcastInstance.getLocalEndpoint().getSocketAddress();
  4. } catch (NoSuchMethodError ignored) {
  5. try {
  6. return hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress();
  7. } catch (Exception e) {
  8. return null;
  9. }
  10. }
  11. }

代码示例来源:origin: net.kuujo/xync

  1. public HazelcastClusterManager(HazelcastInstance hazelcast) {
  2. this.hazelcast = hazelcast;
  3. this.nodeId = hazelcast.getCluster().getLocalMember().getUuid();
  4. hazelcast.getCluster().addMembershipListener(this);
  5. }

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

  1. @Test
  2. public void test_cluster() {
  3. // When
  4. run("cluster");
  5. // Then
  6. String actual = captureOut();
  7. assertContains(actual, jet.getCluster().getLocalMember().getUuid());
  8. assertContains(actual, "ACTIVE");
  9. }

相关文章