use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientMapMetaDataFetcher method scanMembers.
@Override
protected List<InternalCompletableFuture> scanMembers(List<String> names) {
Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
List<InternalCompletableFuture> futures = new ArrayList<InternalCompletableFuture>(members.size());
for (Member member : members) {
Address address = member.getAddress();
ClientMessage message = encodeRequest(names, address);
ClientInvocation invocation = new ClientInvocation(clientImpl, message, address);
try {
futures.add(invocation.invoke());
} catch (Exception e) {
if (logger.isWarningEnabled()) {
logger.warning("Cant fetch invalidation meta-data from address + " + address + " + [" + e.getMessage() + "]");
}
}
}
return futures;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ExecuteScriptRequest method writeResponse.
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
JsonObject jsonResult = new JsonObject();
ArrayList results;
if (targetAllMembers) {
Set<Member> members = mcs.getHazelcastInstance().getCluster().getMembers();
ArrayList<Object> list = new ArrayList<Object>(members.size());
for (Member member : members) {
list.add(mcs.callOnMember(member, new ScriptExecutorOperation(engine, script, bindings)));
}
results = list;
} else {
ArrayList<Object> list = new ArrayList<Object>(targets.size());
for (String address : targets) {
AddressUtil.AddressHolder addressHolder = AddressUtil.getAddressHolder(address);
Address targetAddress = new Address(addressHolder.getAddress(), addressHolder.getPort());
list.add(mcs.callOnAddress(targetAddress, new ScriptExecutorOperation(engine, script, bindings)));
}
results = list;
}
StringBuilder sb = new StringBuilder();
for (Object result : results) {
if (result instanceof String) {
sb.append(result);
} else if (result instanceof List) {
List list = (List) result;
for (Object o : list) {
sb.append(o).append("\n");
}
} else if (result instanceof Map) {
Map map = (Map) result;
for (Object o : map.entrySet()) {
Map.Entry entry = (Map.Entry) o;
sb.append(entry.getKey()).append("->").append(entry.getValue()).append("\n");
}
} else if (result == null) {
sb.append("error");
}
sb.append("\n");
}
jsonResult.add("scriptResult", sb.toString());
root.add("result", jsonResult);
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class MapReduceService method checkAssignedMembersAvailable.
public boolean checkAssignedMembersAvailable(Collection<Address> assignedMembers) {
Collection<Member> members = clusterService.getMembers();
List<Address> addresses = new ArrayList<Address>(members.size());
for (Member member : members) {
addresses.add(member.getAddress());
}
for (Address address : assignedMembers) {
if (!addresses.contains(address)) {
return false;
}
}
return true;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class SingleNodeTest method alwaysFalseMemberSelector_expectRejection.
@Test(expected = RejectedExecutionException.class)
public void alwaysFalseMemberSelector_expectRejection() {
HazelcastInstanceAwareRunnable task = new HazelcastInstanceAwareRunnable();
executor.execute(task, new MemberSelector() {
@Override
public boolean select(Member member) {
return false;
}
});
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClusterListenerSupport method getSocketAddresses.
private Collection<InetSocketAddress> getSocketAddresses() {
final List<InetSocketAddress> socketAddresses = new LinkedList<InetSocketAddress>();
Collection<Member> memberList = getMemberList();
for (Member member : memberList) {
socketAddresses.add(member.getSocketAddress());
}
for (AddressProvider addressProvider : addressProviders) {
socketAddresses.addAll(addressProvider.loadAddresses());
}
if (shuffleMemberList) {
Collections.shuffle(socketAddresses);
}
return socketAddresses;
}
Aggregations