本文整理了Java中com.hazelcast.core.Cluster.getLocalMember()
方法的一些代码示例,展示了Cluster.getLocalMember()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.getLocalMember()
方法的具体详情如下:
包路径:com.hazelcast.core.Cluster
类名称: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
public Integer call() throws Exception {
System.out.println("Running a computation heavy task on " + hz.getCluster().getLocalMember());
return 0;
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dataservice.core
@Override
public Object getLocalMember() {
return this.hz.getCluster().getLocalMember();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
/**
* Return the name of the current Hazelcast instance.
*/
@Override
public String call() throws Exception {
String uuid = hazelcastInstance.getCluster().getLocalMember().getUuid();
log.info("call() runs on {}", uuid);
return uuid;
}
代码示例来源:origin: stevensouza/jamonapi
@Override
public String getInstance() {
intitialize();
return hazelCast.getCluster().getLocalMember().toString();
}
代码示例来源:origin: io.snamp/internal-services
HazelcastCommunicator(final HazelcastInstance hazelcast,
final String communicatorName){
super(hazelcast, communicatorName, HazelcastInstance::getTopic);
this.hazelcast = Objects.requireNonNull(hazelcast);
localMember = hazelcast.getCluster().getLocalMember().getUuid();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance node1 = Hazelcast.newHazelcastInstance();
HazelcastInstance node2 = Hazelcast.newHazelcastInstance();
Member member2 = node2.getCluster().getLocalMember();
boolean member2Safe = node1.getPartitionService().isMemberSafe(member2);
System.out.printf("# Is member2 safe for shutdown\t: %s\n", member2Safe);
}
}
代码示例来源:origin: apache/karaf-cellar
public void setNodeAlias(String alias) {
Cluster cluster = instance.getCluster();
if (cluster != null) {
Member member = cluster.getLocalMember();
member.setStringAttribute("alias", alias);
}
}
代码示例来源:origin: io.snamp/internal-services
/**
* Gets address of this node.
*
* @return Address of this node.
*/
@Override
public InetSocketAddress getAddress() {
return hazelcast.getCluster().getLocalMember().getSocketAddress();
}
代码示例来源:origin: com.hazelcast.stabilizer/stabilizer
private void signalStartToAgent() {
String address;
if (serverInstance == null) {
address = "client:" + getHostAddress();
} else {
InetSocketAddress socketAddress = serverInstance.getCluster().getLocalMember().getInetSocketAddress();
address = socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort();
}
File file = new File("worker.address");
writeObject(address, file);
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Address getThisAddress(HazelcastInstance hazelcastInstance) {
try {
return hazelcastInstance.getCluster().getLocalMember().getAddress();
} catch (UnsupportedOperationException e) {
return null;
}
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public CompositeData call() throws Exception {
int[] counters = hMgr.getCounters();
Map<String, Object> result = new HashMap<>(3);
result.put("Active docs", counters[0]);
result.put("Inactive docs", counters[1]);
Member m = hzInstance.getCluster().getLocalMember();
result.put("Member", m.getSocketAddress().toString() + " [" + m.getUuid() + "]");
return JMXUtils.mapToComposite("Counters", "Description", result);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public String call() {
hz.getCountDownLatch("latch").countDown();
return hz.getCluster().getLocalMember().toString() + ":" + input;
}
代码示例来源:origin: hazelcast/hazelcast-jet
public PartitionServiceBeanDTO(InternalPartitionService partitionService,
HazelcastInstanceImpl hazelcastInstance) {
Address address = hazelcastInstance.getCluster().getLocalMember().getAddress();
this.partitionCount = partitionService.getPartitionCount();
this.activePartitionCount = partitionService.getMemberPartitionsIfAssigned(address).size();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
public PartitionServiceBeanDTO(InternalPartitionService partitionService,
HazelcastInstanceImpl hazelcastInstance) {
Address address = hazelcastInstance.getCluster().getLocalMember().getAddress();
this.partitionCount = partitionService.getPartitionCount();
this.activePartitionCount = partitionService.getMemberPartitionsIfAssigned(address).size();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) throws Exception {
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
IScheduledExecutorService scheduler = instance.getScheduledExecutorService("scheduler");
IScheduledFuture<String> future = scheduler.scheduleOnMember(new EchoTask("My Task"),
instance.getCluster().getLocalMember(), 5, TimeUnit.SECONDS);
Object result = future.get();
System.out.println("Result: " + result);
future.dispose();
Hazelcast.shutdownAll();
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@ManagedAnnotation("activePartitionCount")
@ManagedDescription("Number of active partitions")
public int getActivePartitionCount() {
Address thisAddress = hazelcastInstance.getCluster().getLocalMember().getAddress();
return managedObject.getMemberPartitionsIfAssigned(thisAddress).size();
}
代码示例来源:origin: hazelcast/hazelcast-jet
@ManagedAnnotation("activePartitionCount")
@ManagedDescription("Number of active partitions")
public int getActivePartitionCount() {
Address thisAddress = hazelcastInstance.getCluster().getLocalMember().getAddress();
return managedObject.getMemberPartitionsIfAssigned(thisAddress).size();
}
代码示例来源:origin: com.hazelcast.simulator/simulator
private static InetSocketAddress getInetSocketAddress(HazelcastInstance hazelcastInstance) {
try {
return (InetSocketAddress) hazelcastInstance.getLocalEndpoint().getSocketAddress();
} catch (NoSuchMethodError ignored) {
try {
return hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress();
} catch (Exception e) {
return null;
}
}
}
代码示例来源:origin: net.kuujo/xync
public HazelcastClusterManager(HazelcastInstance hazelcast) {
this.hazelcast = hazelcast;
this.nodeId = hazelcast.getCluster().getLocalMember().getUuid();
hazelcast.getCluster().addMembershipListener(this);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Test
public void test_cluster() {
// When
run("cluster");
// Then
String actual = captureOut();
assertContains(actual, jet.getCluster().getLocalMember().getUuid());
assertContains(actual, "ACTIVE");
}
内容来源于网络,如有侵权,请联系作者删除!