/** * Whether this state model allows at most a single replica in the top-state? * * @return */ public boolean isSingleTopStateModel() { int topStateCount = 0; try { topStateCount = Integer.valueOf(_statesCountMap.get(getTopState())); } catch (NumberFormatException ex) { } return topStateCount == 1; }
/** * Whether this state model allows at most a single replica in the top-state? * * @return */ public boolean isSingleTopStateModel() { int topStateCount = 0; try { topStateCount = Integer.valueOf(_statesCountMap.get(getTopState())); } catch (NumberFormatException ex) { } return topStateCount == 1; }
/** * From current state output, find out the location of the top state of given resource * and partition * * @param currentStateOutput current state output * @param resourceName resource name * @param partition partition of the resource * @param stateModelDef state model def object * @return name of the node that contains top state, null if there is not top state recorded */ private String findCurrentTopStateLocation(CurrentStateOutput currentStateOutput, String resourceName, Partition partition, StateModelDefinition stateModelDef) { Map<String, String> stateMap = currentStateOutput.getCurrentStateMap(resourceName, partition); for (String instance : stateMap.keySet()) { if (stateMap.get(instance).equals(stateModelDef.getTopState())) { return instance; } } return null; }
if (stateMap.get(instance).equals(stateModelDef.getTopState())) { if (!lastTopStateMap.containsKey(resourceName)) { lastTopStateMap.put(resourceName, new HashMap<String, String>()); if (stateMap.values().contains(stateModelDef.getTopState())) { clusterStatusMonitor, durationThreshold, stateModelDef.getTopState()); } else { partition, stateModelDef.getTopState(), currentStateOutput);
if (fromState.equals(stateModelDef.getTopState())) { fromTopStateMessages.add(message); int newCnt = (stateCnts.containsKey(toState) ? stateCnts.get(toState) + 1 : 1); if (newCnt > stateConstraints.get(toState).getUpperBound()) { if (p2pMessageEnabled && toState.equals(stateModelDef.getTopState()) && stateModelDef.isSingleTopStateModel()) {
stateModelDef.getTopState()); } else if (lastTopStateInstance != null && !lastTopStateInstance .equals(currentTopStateInstance)) {
if (fromState.equals(stateModelDef.getTopState())) { fromTopStateMessages.add(message); String fromState = message.getFromState(); if (toState.equals(stateModelDef.getTopState())) { int newCnt = (stateCnts.containsKey(toState) ? stateCnts.get(toState) + 1 : 1); if (newCnt > stateConstraints.get(toState).getUpperBound()) { if (p2pMessageEnabled && toState.equals(stateModelDef.getTopState()) && stateModelDef.isSingleTopStateModel()) {
} else { reportTopStateMissing(cache, resourceName, partition, stateModelDef.getTopState(), currentStateOutput); reportTopStateHandoffFailIfNecessary(cache, resourceName, partition, durationThreshold, clusterStatusMonitor);
recoveryRebalance(resource, bestPossiblePartitionStateMap, throttleController, intermediatePartitionStateMap, partitionsNeedRecovery, currentStateOutput, cache.getStateModelDef(resource.getStateModelDefRef()).getTopState());
recoveryRebalance(resource, bestPossiblePartitionStateMap, throttleController, intermediatePartitionStateMap, partitionsNeedRecovery, currentStateOutput, cache.getStateModelDef(resource.getStateModelDefRef()).getTopState());