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);
int distributorNodeCount = getNodeCount(NodeType.DISTRIBUTOR); int storageNodeCount = getNodeCount(NodeType.STORAGE);
public Diff getDiff(ClusterState other) { Diff diff = new Diff(); if (version != other.version) { diff.add(new Diff.Entry("version", version, other.version)); } if (!state.equals(other.state)) { diff.add(new Diff.Entry("cluster", state, other.state)); } if (distributionBits != other.distributionBits) { diff.add(new Diff.Entry("bits", distributionBits, other.distributionBits)); } if (official != other.official) { diff.add(new Diff.Entry("official", official, other.official)); } for (NodeType type : NodeType.getTypes()) { Diff typeDiff = new Diff(); int maxCount = Math.max(getNodeCount(type), other.getNodeCount(type)); for (int i = 0; i < maxCount; i++) { Node n = new Node(type, i); Diff d = getNodeState(n).getDiff(other.getNodeState(n)); if (d.differs()) { typeDiff.add(new Diff.Entry(i, d)); } } if (typeDiff.differs()) { diff.add(new Diff.Entry(type, typeDiff).splitLine()); } } return diff; }