private void refreshEndpointMap() {
   String keyspace = ConfigHelper.getOutputKeyspace(conf);
   try (Session session =
       CqlConfigHelper.getOutputCluster(ConfigHelper.getOutputInitialAddress(conf), conf)
           .connect(keyspace)) {
     rangeMap = new HashMap<>();
     metadata = session.getCluster().getMetadata();
     Set<TokenRange> ranges = metadata.getTokenRanges();
     for (TokenRange range : ranges) {
       rangeMap.put(range, metadata.getReplicas(keyspace, range));
     }
   }
 }
    public TokenRange getRange(ByteBuffer key) {
      Token t = partitioner.getToken(key);
      com.datastax.driver.core.Token driverToken =
          metadata.newToken(partitioner.getTokenFactory().toString(t));
      for (TokenRange range : rangeMap.keySet()) {
        if (range.contains(driverToken)) {
          return range;
        }
      }

      throw new RuntimeException(
          "Invalid token information returned by describe_ring: " + rangeMap);
    }