use of com.hazelcast.spi.partitiongroup.PartitionGroupStrategy in project hazelcast by hazelcast.
the class SPIAwareMemberGroupFactory method createInternalMemberGroups.
@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
Set<MemberGroup> memberGroups = createHashSet(allMembers.size());
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()) {
PartitionGroupStrategy groupStrategy = discoveryStrategy.getPartitionGroupStrategy(allMembers);
if (groupStrategy == null) {
groupStrategy = discoveryStrategy.getPartitionGroupStrategy();
}
checkNotNull(groupStrategy);
for (MemberGroup group : groupStrategy.getMemberGroups()) {
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;
}
Aggregations