use of com.netflix.exhibitor.core.state.ServerType in project exhibitor by soabase.
the class FixedEnsembleBuilder method createPotentialServerList.
@Override
public ServerList createPotentialServerList() {
ServerList configuredServerList = clusterState.getConfiguredServerList();
Map<ServerSpec, InstanceStateTypes> statusMap = clusterState.buildStatusMap();
List<ServerSpec> newList = Lists.newArrayList();
for (ServerSpec spec : configuredServerList.getSpecs()) {
if (statusMap.get(spec) != InstanceStateTypes.DOWN) {
newList.add(spec);
}
}
if (newList.size() >= fixedEnsembleSize) {
// no room for us
return configuredServerList;
}
int standardTypeCount = 0;
for (ServerSpec spec : newList) {
if (spec.getServerType() == ServerType.STANDARD) {
++standardTypeCount;
}
}
int observerThreshold = exhibitor.getConfigManager().getConfig().getInt(IntConfigs.OBSERVER_THRESHOLD);
ServerType serverType = ((observerThreshold > 0) && (standardTypeCount >= observerThreshold)) ? ServerType.OBSERVER : ServerType.STANDARD;
int existingMaxId = FlexibleEnsembleBuilder.getExistingMaxId(configuredServerList);
ServerSpec us = new ServerSpec(exhibitor.getThisJVMHostname(), existingMaxId + 1, serverType);
newList.add(us);
return new ServerList(newList);
}
Aggregations