private boolean normalizedNodeStateSimilarToIgnoringInitProgress( final NodeType nodeType, final NodeState lhs, final NodeState rhs) { final NodeState lhsNormalized = (lhs != null ? lhs : defaultUpNodeState(nodeType)); final NodeState rhsNormalized = (rhs != null ? rhs : defaultUpNodeState(nodeType)); return lhsNormalized.similarToIgnoringInitProgress(rhsNormalized); }
private boolean normalizedNodeStateSimilarTo(final NodeType nodeType, final NodeState lhs, final NodeState rhs) { final NodeState lhsNormalized = (lhs != null ? lhs : defaultUpNodeState(nodeType)); final NodeState rhsNormalized = (rhs != null ? rhs : defaultUpNodeState(nodeType)); return lhsNormalized.similarTo(rhsNormalized); }
public void updateValidTargets(ClusterState state) { List<Integer> validRandomTargets = new ArrayList<>(); for (int i=0; i<state.getNodeCount(NodeType.DISTRIBUTOR); ++i) { if (state.getNodeState(new Node(NodeType.DISTRIBUTOR, i)).getState().oneOf(upStates)) validRandomTargets.add(i); } this.validRandomTargets = validRandomTargets; this.totalTargets = state.getNodeCount(NodeType.DISTRIBUTOR); } public abstract String getTargetSpec(Integer distributor, RoutingContext context);
@Override public boolean clusterUp() { return clusterState != null && clusterState.getClusterState().oneOf("u"); }
public DiskState(State s, String description, double capacity) { setState(s); // Set via set methods, so we can have illegal argument checks only one place setCapacity(capacity); setDescription(description); } public DiskState clone() {
public static Node ofDistributor(int index) { return new Node(NodeType.DISTRIBUTOR, index); }
public String toString() { return "Context(Distributor " + calculatedDistributor + ", state version " + usedState.getVersion() + ")"; } }
/** Returns the serialized form of this cluster state */ // TODO: Don't rely on toString for that @Override public String toString() { return toString(false); }
public String toString() { StringBuilder sb = new StringBuilder(); PrintProperties pp = new PrintProperties(); print(sb, "", pp, false); return sb.toString(); } public String toHtml() {
@Override public int hashCode() { // NOTE: capacity cannot be part of the hashCode return state.hashCode(); } }
@Override public int compareTo(Node n) { return getOrdering() - n.getOrdering(); }
public DiskState(State s) { setState(s); } public DiskState(State s, String description, double capacity) {
@Override public boolean equals(Object o) { if (!(o instanceof Node)) return false; Node n = (Node) o; return (type.equals(n.type) && index == n.index); }
@Override public boolean nodeUp() { return !clusterUp() && clusterState.getNodeState(new Node(NodeType.STORAGE, clusterIndex)).getState().oneOf("uir"); } }
private void resetCachedStateIfClusterStateVersionLikelyRolledBack(ClusterState newState) { if (cachedClusterState != null && cachedClusterState.getVersion() > newState.getVersion()) { if (++oldClusterVersionGottenCount >= maxOldClusterVersionBeforeSendingRandom) { oldClusterVersionGottenCount = 0; cachedClusterState = null; } } }