// PartitionManager.getInstance()
// .getNetworkPartitionLbHolder(partitionGroup.getId());
// FIXME pick a random partition
Partition partition =
partitionGroup.getPartitions()[new Random().nextInt(partitionGroup.getPartitions().length)];
PartitionContext partitionContext = new PartitionContext(partition);
partitionContext.setServiceName(cluster.getServiceName());
partitionContext.setProperties(cluster.getProperties());
partitionContext.setNetworkPartitionId(partitionGroup.getId());
partitionContext.setMinimumMemberCount(1);//Here it hard codes the minimum value as one for LB cartridge partitions
NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(),
partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()) ;
for (Member member : cluster.getMembers()) {
String memberId = member.getMemberId();
if (member.getNetworkPartitionId().equalsIgnoreCase(networkPartitionContext.getId())) {
MemberContext memberContext = new MemberContext();
memberContext.setClusterId(member.getClusterId());
memberContext.setMemberId(memberId);
memberContext.setPartition(partition);
if (MemberStatus.Activated.equals(member.getStatus())) {
partitionContext.addActiveMember(memberContext);
// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1);
// partitionContext.incrementCurrentActiveMemberCount(1);
} else if (MemberStatus.Created.equals(member.getStatus()) ||
MemberStatus.Starting.equals(member.getStatus())) {
partitionContext.addPendingMember(memberContext);
// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1);
} else if (MemberStatus.Suspended.equals(member.getStatus())) {
// partitionContext.addFaultyMember(memberId);
}
partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
if(log.isInfoEnabled()){
log.info(String.format("Member stat context has been added: [member] %s", memberId));
}
}