use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class SPIAwareMemberGroupFactory method createInternalMemberGroups.
@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
Set<MemberGroup> memberGroups = new HashSet<MemberGroup>();
for (Member member : allMembers) {
try {
if (member.localMember()) {
DefaultDiscoveryService defaultDiscoveryService = (DefaultDiscoveryService) discoveryService;
// If no discovery strategy is found fail-fast
if (!defaultDiscoveryService.getDiscoveryStrategies().iterator().hasNext()) {
throw new RuntimeException("Could not load any Discovery Strategy, please " + "check service definitions under META_INF.services folder. ");
} else {
for (DiscoveryStrategy discoveryStrategy : defaultDiscoveryService.getDiscoveryStrategies()) {
checkNotNull(discoveryStrategy.getPartitionGroupStrategy());
Iterable<MemberGroup> spiGroupsIterator = discoveryStrategy.getPartitionGroupStrategy().getMemberGroups();
for (MemberGroup group : spiGroupsIterator) {
memberGroups.add(group);
}
return memberGroups;
}
}
}
} catch (Exception e) {
if (e instanceof ValidationException) {
throw new InvalidConfigurationException("Invalid configuration", e);
} else {
throw new RuntimeException("Failed to configure discovery strategies", e);
}
}
}
return memberGroups;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientExecutorServiceProxy method selectMembers.
private List<Member> selectMembers(MemberSelector memberSelector) {
if (memberSelector == null) {
throw new IllegalArgumentException("memberSelector must not be null");
}
List<Member> selected = new ArrayList<Member>();
Collection<Member> members = getContext().getClusterService().getMemberList();
for (Member member : members) {
if (memberSelector.select(member)) {
selected.add(member);
}
}
if (selected.isEmpty()) {
throw new RejectedExecutionException("No member selected with memberSelector[" + memberSelector + "]");
}
return selected;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientExecutorServiceProxy method submitToMembers.
@Override
public <T> Map<Member, Future<T>> submitToMembers(Callable<T> task, Collection<Member> members) {
Map<Member, Future<T>> futureMap = new HashMap<Member, Future<T>>(members.size());
for (Member member : members) {
final Address memberAddress = getMemberAddress(member);
Future<T> f = submitToTargetInternal(task, memberAddress, null, true);
futureMap.put(member, f);
}
return futureMap;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientExecutorServiceProxy method executeOnAllMembers.
@Override
public void executeOnAllMembers(Runnable command) {
Callable<?> callable = createRunnableAdapter(command);
final Collection<Member> memberList = getContext().getClusterService().getMemberList();
for (Member member : memberList) {
submitToMember(callable, member);
}
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientExecutorServiceProxy method submitToAllMembers.
@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;
}
Aggregations