Search in sources :

Example 1 with SingleMemberGroup

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;
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) SingleMemberGroup(com.hazelcast.internal.partition.membergroup.SingleMemberGroup) SingleMemberGroup(com.hazelcast.internal.partition.membergroup.SingleMemberGroup) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Aggregations

Member (com.hazelcast.cluster.Member)1 SingleMemberGroup (com.hazelcast.internal.partition.membergroup.SingleMemberGroup)1 MemberGroup (com.hazelcast.spi.partitiongroup.MemberGroup)1 LinkedList (java.util.LinkedList)1