use of com.hazelcast.internal.partition.membergroup.SingleMemberGroup in project hazelcast by hazelcast.
the class PartitionStateGeneratorImpl method createNodeGroups.
private Queue<NodeGroup> createNodeGroups(Collection<MemberGroup> memberGroups) {
Queue<NodeGroup> nodeGroups = new LinkedList<>();
if (memberGroups == null || memberGroups.isEmpty()) {
return nodeGroups;
}
for (MemberGroup memberGroup : memberGroups) {
NodeGroup nodeGroup;
if (memberGroup.size() == 0) {
continue;
}
if (memberGroup instanceof SingleMemberGroup || memberGroup.size() == 1) {
nodeGroup = new SingleNodeGroup();
Member next = memberGroup.iterator().next();
nodeGroup.addNode(PartitionReplica.from(next));
} else {
nodeGroup = new DefaultNodeGroup();
Iterator<Member> iter = memberGroup.iterator();
while (iter.hasNext()) {
Member next = iter.next();
nodeGroup.addNode(PartitionReplica.from(next));
}
}
nodeGroups.add(nodeGroup);
}
return nodeGroups;
}
Aggregations