Ejemplo n.º 1
0
  private <T> void mergePartitionGroup(
      Map<T, SegmentIdSet> instanceToSegmentMap, T instances, SegmentIdSet pg) {

    SegmentIdSet pg2 = instanceToSegmentMap.get(instances);
    if (null != pg2) {
      pg2.addSegments(pg.getSegments());
    } else {
      instanceToSegmentMap.put(instances, pg);
    }
  }
Ejemplo n.º 2
0
 private <T> void mergePartitionGroup(
     Map<T, SegmentIdSet> instanceToSegmentMap, T instances, SegmentId p) {
   SegmentIdSet pg2 = instanceToSegmentMap.get(instances);
   if (null != pg2) {
     pg2.addSegment(p);
   } else {
     SegmentIdSet pg1 = new SegmentIdSet();
     pg1.addSegment(p);
     instanceToSegmentMap.put(instances, pg1);
   }
 }
Ejemplo n.º 3
0
  public ServerToSegmentSetMap(Map<String, Set<String>> serverToSegmentSetMap) {
    _serverToSegmentSetMap = serverToSegmentSetMap;
    _routingTable = new HashMap<ServerInstance, SegmentIdSet>();
    for (Entry<String, Set<String>> entry : _serverToSegmentSetMap.entrySet()) {
      String namePortStr = entry.getKey().split(CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE)[1];
      String hostName = namePortStr.split(NAME_PORT_DELIMITER)[0];
      int port;
      try {
        port = Integer.parseInt(namePortStr.split(NAME_PORT_DELIMITER)[1]);
      } catch (Exception e) {
        port = CommonConstants.Helix.DEFAULT_SERVER_NETTY_PORT;
      }

      ServerInstance serverInstance = new ServerInstance(hostName, port);
      SegmentIdSet segmentIdSet = new SegmentIdSet();
      for (String segmentId : entry.getValue()) {
        segmentIdSet.addSegment(new SegmentId(segmentId));
      }
      _routingTable.put(serverInstance, segmentIdSet);
    }
  }