@Override public String getNodeName() { return this.me == null ? null : this.me.getName(); }
protected int calculateReplicantsHash(List<ClusterNode> members) { int result = 0; for (ClusterNode member: members) { if (member != null) { result += member.getName().hashCode(); // no explicit overflow with int addition } } return result; }
public Vector<String> getCurrentView() { GroupView curView = this.groupView; Vector<String> result = new Vector<String>(curView.allMembers.size()); for (ClusterNode member: curView.allMembers) { result.add(member.getName()); } return result; }
@Override public int compareTo(ClusterNode o) { if (o == null) throw new ClassCastException("Comparison to null value"); if (!(o instanceof ClusterNodeImpl)) throw new ClassCastException("Comparison between different classes"); return this.id.compareTo(o.getName()); }
private ClusterNode find(List<ClusterNode> candidates, String host, int port) { String node = host + ":" + port; this.log.debug("Checking if " + node + " is in candidate list: " + candidates); for (ClusterNode candidate: candidates) { if (candidate.getName().equals(node)) { return candidate; } } return null; } }
public String getLocalNodeName() { ClusterNode localNode = this.partition == null ? null : this.partition.getClusterNode(); return localNode == null ? null : localNode.getName(); }
@Override public List<String> lookupReplicantsNodeNames(String key) { List<ClusterNode> nodes = this.lookupReplicantsNodes(key); if (nodes == null) return null; List<String> nodeNames = new ArrayList<String>(nodes.size()); for (ClusterNode node : nodes) { nodeNames.add(node.getName()); } return nodeNames; }
String name = node.getName();
deadNodes.add(member.getName());
/** * Takes a set of discrepancies provided by another node and adds any * missing entries to our discrepancy set, *after* adjusting the * TimestampDiscrepancy objects to incorporate our discrepancy with * the node that provided the set. */ private void convertRemoteDiscrepanciesToLocalTime(Map<Server, TimestampDiscrepancy> remoteDiscrepancies, TimestampDiscrepancy senderDiscrepancy) { for (Map.Entry<Server, TimestampDiscrepancy> entry : remoteDiscrepancies.entrySet()) { Server key = entry.getKey(); if (discrepancies.get(key) == null) { // A node we didn't know about discrepancies.put(new Server(key, senderDiscrepancy), new TimestampDiscrepancy(entry.getValue(), senderDiscrepancy)); ClusterNode node = key.getNode(); nodesByName.put(node.getName(), node); } } }
@Override public List<ClusterNode> lookupReplicantsNodes(String key) { boolean local = this.localReplicants.containsKey(key); Map<String, Serializable> replicant = this.replicants.get(key); if (replicant == null) { return local ? Collections.singletonList(this.partition.getClusterNode()) : null; } Set<String> keys = replicant.keySet(); ClusterNode[] nodes = this.partition.getClusterNodes(); List<ClusterNode> rtn = new ArrayList<ClusterNode>(nodes.length); for (ClusterNode node : nodes) { String name = node.getName(); if (local && this.partition.getNodeName().equals(name)) { rtn.add(this.partition.getClusterNode()); } else if (keys.contains(name)) { rtn.add(node); } } return rtn; }
private void updateTimestampDiscrepancy(Server server, TimestampDiscrepancy discrepancy, boolean live) { discrepancies.put(server, discrepancy); nodesByName.put(server.getNode().getName(), server.getNode()); if (live) { liveServers.add(server); } synchronized (unresolvedRemoteDependencies) { Map<Server, TimestampDiscrepancy> unresolved = unresolvedRemoteDependencies.remove(server.getNode()); if (unresolved != null) { convertRemoteDiscrepanciesToLocalTime(unresolved, discrepancy); } } for (TimestampDiscrepancyObserver observer : observers) { observer.timestampDiscrepancyChanged(server.getNode(), discrepancy); } }