Search in sources :

Example 1 with ServerType

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);
}
Also used : ServerType(com.netflix.exhibitor.core.state.ServerType) ServerSpec(com.netflix.exhibitor.core.state.ServerSpec) ServerList(com.netflix.exhibitor.core.state.ServerList) InstanceStateTypes(com.netflix.exhibitor.core.state.InstanceStateTypes)

Aggregations

InstanceStateTypes (com.netflix.exhibitor.core.state.InstanceStateTypes)1 ServerList (com.netflix.exhibitor.core.state.ServerList)1 ServerSpec (com.netflix.exhibitor.core.state.ServerSpec)1 ServerType (com.netflix.exhibitor.core.state.ServerType)1