本文整理了Java中com.hazelcast.core.Member.getAddress()
方法的一些代码示例,展示了Member.getAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Member.getAddress()
方法的具体详情如下:
包路径:com.hazelcast.core.Member
类名称:Member
方法名:getAddress
[英]Returns the Address of this Member.
[中]返回此成员的地址。
代码示例来源: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: 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: SonarSource/sonarqube
public Collection<NodeInfo> load() throws InterruptedException {
Map<String, NodeInfo> nodesByName = new HashMap<>();
MemberSelector memberSelector = HazelcastMemberSelectors.selectorForProcessIds(ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE);
DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer = hzMember.call(ProcessInfoProvider::provide, memberSelector, DISTRIBUTED_TIMEOUT_MS);
for (Member member : distributedAnswer.getMembers()) {
String nodeName = member.getStringAttribute(NODE_NAME.getKey());
NodeInfo nodeInfo = nodesByName.computeIfAbsent(nodeName, name -> {
NodeInfo info = new NodeInfo(name);
info.setHost(member.getAddress().getHost());
return info;
});
completeNodeInfo(distributedAnswer, member, nodeInfo);
}
return nodesByName.values();
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void ensureMemberExist(Member member) {
if (!addressToMemberMap.containsKey(member.getAddress())) {
throw new IllegalArgumentException(member + " not found!");
}
if (!uuidToMemberMap.containsKey(member.getUuid())) {
throw new IllegalArgumentException(member + " not found!");
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Address getRandomAddress() {
Member member = loadBalancer.next();
if (member != null) {
return member.getAddress();
}
return null;
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Address getRandomAddress() {
Member member = loadBalancer.next();
if (member == null) {
return null;
}
return member.getAddress();
}
代码示例来源:origin: hazelcast/hazelcast-jet
private static Address masterAddress(Cluster cluster) {
return cluster.getMembers().stream().findFirst()
.orElseThrow(() -> new IllegalStateException("No members found in cluster"))
.getAddress();
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
void handleInitialMembershipEvent(InitialMembershipEvent event) {
synchronized (initialMembershipListenerMutex) {
Set<Member> initialMembers = event.getMembers();
LinkedHashMap<Address, Member> newMap = new LinkedHashMap<Address, Member>();
for (Member initialMember : initialMembers) {
newMap.put(initialMember.getAddress(), initialMember);
}
members.set(Collections.unmodifiableMap(newMap));
fireInitialMembershipEvent(event);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void initLocal(Set<Partition> partitions) {
addrToPartitions = partitions.stream()
.collect(groupingBy(p -> p.getOwner().getAddress(),
mapping(Partition::getPartitionId, toList())));
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
protected Address masterAddress() {
Optional<Member> first = container().getCluster().getMembers().stream().findFirst();
return first.orElseThrow(() -> new IllegalStateException("No members found in cluster")).getAddress();
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void onResponse(Boolean response) {
if (!Boolean.TRUE.equals(response)) {
logger.fine(member + " rejected completed migrations with response " + response);
partitionService.sendPartitionRuntimeState(member.getAddress());
return;
}
if (latch.decrementAndGet() == 0) {
logger.fine("Evicting " + migrations.size() + " completed migrations.");
evictCompletedMigrations(migrations);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
Address address = member.getAddress();
String host = address.getHost();
int port = address.getPort();
out.writeUTF(member.getUuid());
out.writeUTF(host);
out.writeInt(port);
out.writeBoolean(member.isLiteMember());
out.writeObject(member.getVersion());
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public <T> Map<Member, Future<T>> submitToAllMembers(Callable<T> task) {
final Collection<Member> memberList = getContext().getClusterService().getMemberList();
Map<Member, Future<T>> futureMap = new HashMap<Member, Future<T>>(memberList.size());
for (Member m : memberList) {
Future<T> f = submitToTargetInternal(task, m.getAddress(), null, true);
futureMap.put(m, f);
}
return futureMap;
}
代码示例来源: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: hazelcast/hazelcast-jet
private void sendReplicationOperation(boolean isRemove, String name, Data key, Data value, long ttl,
VersionResponsePair response) {
Collection<Member> members = nodeEngine.getClusterService().getMembers(MemberSelectors.DATA_MEMBER_SELECTOR);
for (Member member : members) {
invoke(isRemove, member.getAddress(), name, key, value, ttl, response);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
public byte[] clusterWideUpdateManagementCenterUrl(String newUrl) {
try {
final Collection<Member> memberList = instance.node.clusterService.getMembers();
for (Member member : memberList) {
send(member.getAddress(), new UpdateManagementCenterUrlOperation(newUrl));
}
return HttpCommand.RES_204;
} catch (Throwable throwable) {
logger.warning("New Management Center url cannot be assigned.", throwable);
return HttpCommand.RES_500;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void memberRemoved(Member member) {
members.remove(member);
logger.info(membersString());
final Connection connection = connectionManager.getActiveConnection(member.getAddress());
if (connection != null) {
connection.close(null, newTargetDisconnectedExceptionCausedByMemberLeftEvent(connection));
}
MembershipEvent event = new MembershipEvent(client.getCluster(), member, MembershipEvent.MEMBER_REMOVED,
unmodifiableSet(members));
clusterService.handleMembershipEvent(event);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void init(@Nonnull Context context) {
if (context.localParallelism() != 1) {
throw new IllegalArgumentException(
"Non-distributed vertex had parallelism of " + context.localParallelism()
+ ", should be 1");
}
String key = StringPartitioningStrategy.getPartitionKey(partitionKey);
ownerAddress = context.jetInstance().getHazelcastInstance().getPartitionService()
.getPartition(key).getOwner().getAddress();
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void destroyCacheOnAllMembers(String name, String callerUuid) {
NodeEngine nodeEngine = getNodeEngine();
OperationService operationService = nodeEngine.getOperationService();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
for (Member member : members) {
if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
CacheDestroyOperation op = new CacheDestroyOperation(name, true);
operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
}
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void updateCacheListenerConfigOnOtherNodes(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration,
boolean isRegister) {
OperationService operationService = getNodeEngine().getOperationService();
Collection<Member> members = getNodeEngine().getClusterService().getMembers();
for (Member member : members) {
if (!member.localMember()) {
Operation op = new CacheListenerRegistrationOperation(getDistributedObjectName(), cacheEntryListenerConfiguration,
isRegister);
operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, member.getAddress());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!