// Set next partition as current partition in Autoscaler Context
networkPartitionContext.setCurrentPartitionIndex(currentPartitionIndex);
if (partitions.get(currentPartitionIndex) instanceof Partition) {
Partition currentPartition = (Partition) partitions.get(currentPartitionIndex);
String currentPartitionId = currentPartition.getId();
// has more than minimum instances.
int currentlyActiveMemberCount = networkPartitionContext.getActiveMemberCount(currentPartitionId);
if (currentlyActiveMemberCount > currentPartition.getPartitionMin()) {
// current partition is free
if (log.isDebugEnabled())
log.debug(String.format("A free space found for scale down in partition %s [current] %s [min] %s",
currentPartitionId, currentlyActiveMemberCount, currentPartition.getPartitionMin())) ;
return currentPartition;
}else {
if (currentPartitionIndex == 0) {
if (log.isDebugEnabled())
log.debug(String.format("Partition %s reached with no space to scale down," +
"[current] %s [min] %s", currentPartitionId, currentlyActiveMemberCount,
currentPartition.getPartitionMin()));
return null;
}
}
}
}