コード例 #1
0
    /** Stores current DC/rack assignment for ep */
    protected void addEndpoint(InetAddress ep) {
      IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
      String dc = snitch.getDatacenter(ep);
      String rack = snitch.getRack(ep);
      Pair<String, String> current = currentLocations.get(ep);
      if (current != null) {
        if (current.left.equals(dc) && current.right.equals(rack)) return;
        dcRacks.get(current.left).remove(current.right, ep);
        dcEndpoints.remove(current.left, ep);
      }

      dcEndpoints.put(dc, ep);

      if (!dcRacks.containsKey(dc)) dcRacks.put(dc, HashMultimap.<String, InetAddress>create());
      dcRacks.get(dc).put(rack, ep);

      currentLocations.put(ep, Pair.create(dc, rack));
    }
コード例 #2
0
 /** Removes current DC/rack assignment for ep */
 protected void removeEndpoint(InetAddress ep) {
   if (!currentLocations.containsKey(ep)) return;
   Pair<String, String> current = currentLocations.remove(ep);
   dcEndpoints.remove(current.left, ep);
   dcRacks.get(current.left).remove(current.right, ep);
 }