List<Participant> containersToStart = Lists.newArrayList();
List<Participant> containersToStop = Lists.newArrayList();
List<Participant> containersToRelease = Lists.newArrayList();
int stopCount = 0;
for (Participant participant : participants) {
ContainerConfig containerConfig = participant.getContainerConfig();
if (containerConfig != null && containerConfig.getState() != null) {
ContainerState state = containerConfig.getState();
switch (state) {
case ACQUIRED:
// acquired containers are ready to start
containersToStart.add(participant);
break;
case CONNECTED:
// stop at most one active at a time, wait for everything to be up first
if (stopCount < 1 && _askCount >= MAX_PARTICIPANTS) {
containersToStop.add(participant);
stopCount++;
}
break;
case HALTED:
// halted containers can be released
containersToRelease.add(participant);
break;
default:
break;
}
ContainerId containerId = containerConfig.getId();
if (containerId != null) {
_containerParticipants.put(containerId, participant.getId());
_states.put(containerId, state);
}
}