本文整理了Java中com.hazelcast.core.Member
类的一些代码示例,展示了Member
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Member
类的具体详情如下:
包路径:com.hazelcast.core.Member
类名称:Member
[英]Cluster member interface. The default implementation com.hazelcast.instance.MemberImpl violates the Java Serialization contract. It should be serialized/deserialized by Hazelcast.
[中]集群成员接口。默认的实现是com。黑兹卡斯特。例子MemberImpl违反了Java序列化协议。Hazelcast应将其序列化/反序列化。
代码示例来源:origin: SonarSource/sonarqube
@Override
public Optional<String> getLeaderHostName() {
String leaderId = (String) hzMember.getAtomicReference(LEADER).get();
if (leaderId != null) {
Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderId)).findFirst();
if (leader.isPresent()) {
return Optional.of(leader.get().getAddress().getHost());
}
}
return Optional.empty();
}
代码示例来源:origin: apache/usergrid
@Test
public void doTest() {
logger.info( "do test" );
Hazelcast.addInstanceListener( this );
ITopic<Object> topic = Hazelcast.getTopic( "default" );
topic.addMessageListener( this );
topic.publish( "my-message-object" );
Collection<Instance> instances = Hazelcast.getInstances();
for ( Instance instance : instances ) {
logger.info( "ID: [" + instance.getId() + "] Type: [" + instance.getInstanceType() + "]" );
}
Set<Member> setMembers = Hazelcast.getCluster().getMembers();
for ( Member member : setMembers ) {
logger.info( "isLocalMember " + member.localMember() );
logger.info( "member.inetsocketaddress " + member.getInetSocketAddress() );
}
}
代码示例来源:origin: SonarSource/sonarqube
private static Member newMember(String uuid) {
Member member = mock(Member.class);
when(member.getUuid()).thenReturn(uuid);
when(member.getStringAttribute(NODE_NAME.getKey())).thenReturn(uuid);
return member;
}
}
代码示例来源:origin: SonarSource/sonarqube
private Member newMember(String name) {
Member member = mock(Member.class, Mockito.RETURNS_MOCKS);
when(member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME.getKey())).thenReturn(name);
when(member.getAddress()).thenReturn(new Address(AN_ADDRESS, 6789));
return member;
}
}
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
public void setHzaelCastInstance(HazelcastInstance hazelcastInstance){
this.hazelcastInstance = hazelcastInstance;
this.roleToMembershipMap = hazelcastInstance.getMap(STORM_ROLE_TO_MEMBERSHIP_HZ_MAP);
myHazelcastId = hazelcastInstance.getCluster().getLocalMember().getUuid();
}
代码示例来源:origin: com.hazelcast.simulator/tests-hz35
@Prepare
public void prepare() {
Set<Member> memberSet = targetInstance.getCluster().getMembers();
memberAddresses = new Address[memberSet.size()];
int i = 0;
for (Member member : memberSet) {
memberAddresses[i++] = new Address(member.getSocketAddress());
}
}
代码示例来源: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: hazelcast/hazelcast-jet
private Address getThisAddress(HazelcastInstance hazelcastInstance) {
try {
return hazelcastInstance.getCluster().getLocalMember().getAddress();
} catch (UnsupportedOperationException e) {
return null;
}
}
代码示例来源:origin: dsukhoroslov/bagri
private List<Member> getMembers(String name) {
List<Member> members = new ArrayList<Member>();
for (Member member: hzInstance.getCluster().getMembers()) {
if (name.equals(member.getStringAttribute(pn_cluster_node_name))) {
members.add(member);
}
}
return members;
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IExecutorService executorService = hz.getExecutorService("executor");
for (Member member : hz.getCluster().getMembers()) {
EchoTask task = new EchoTask(member.getSocketAddress().toString());
executorService.executeOnMember(task, member);
}
}
}
代码示例来源: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: net.kuujo/xync
public HazelcastClusterManager(HazelcastInstance hazelcast) {
this.hazelcast = hazelcast;
this.nodeId = hazelcast.getCluster().getLocalMember().getUuid();
hazelcast.getCluster().addMembershipListener(this);
}
代码示例来源: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: net.kuujo/xync
@Override
public Set<String> getNodes() {
Set<String> nodes = new HashSet<>();
for (Member member : hazelcast.getCluster().getMembers()) {
nodes.add(member.getUuid());
}
return nodes;
}
代码示例来源:origin: dsukhoroslov/bagri
private static void lookupManagedNodes(HazelcastInstance hzInstance) {
SchemaManagement sMgr = context.getBean("schemaService", SchemaManagement.class);
for (Member member: hzInstance.getCluster().getMembers()) {
if (!member.localMember()) {
sMgr.initMember(member);
}
}
}
代码示例来源:origin: org.neo4j/neo4j-causal-clustering
private static boolean canBeBootstrapped( HazelcastInstance hazelcastInstance, Config config )
{
Set<Member> members = hazelcastInstance.getCluster().getMembers();
String dbName = config.get( CausalClusteringSettings.database );
Predicate<Member> acceptsToBeLeader = m -> !m.getBooleanAttribute( REFUSE_TO_BE_LEADER_KEY );
Predicate<Member> hostsMyDb = m -> dbName.equals( m.getStringAttribute( MEMBER_DB_NAME ) );
Stream<Member> membersWhoCanLeadForMyDb = members.stream().filter( acceptsToBeLeader ).filter( hostsMyDb );
Optional<Member> firstAppropriateMember = membersWhoCanLeadForMyDb.findFirst();
return firstAppropriateMember.map( Member::localMember ).orElse( false );
}
代码示例来源: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: io.snamp/internal-services
/**
* Gets address of this node.
*
* @return Address of this node.
*/
@Override
public InetSocketAddress getAddress() {
return hazelcast.getCluster().getLocalMember().getSocketAddress();
}
代码示例来源:origin: org.sonatype.sisu/sisu-locks
for ( final Member m : instance.getCluster().getMembers() )
if ( addr.equals( m.getInetSocketAddress() ) )
for ( final Member m : instance.getCluster().getMembers() )
if ( addr.equals( m.getInetSocketAddress().getAddress() ) )
members.addAll( instance.getCluster().getMembers() );
代码示例来源:origin: hazelcast/hazelcast-jet
public void run() {
Address address = member.getAddress();
logger.warning(format("%s will ping %s", node.getThisAddress(), address));
for (int i = 0; i < MAX_PING_RETRY_COUNT; i++) {
if (doPing(address, Level.INFO)) {
return;
}
}
// host not reachable
String reason = format("%s could not ping %s", node.getThisAddress(), address);
logger.warning(reason);
clusterService.suspectMember(member, reason, true);
}
内容来源于网络,如有侵权,请联系作者删除!