/** The local pod refers to the server itself. */
  private UpdatePod initLocalPod() {
    ServerBartender serverSelf = _bartender.serverSelf();

    ServicesAmp rampManager = AmpSystem.currentManager();

    UpdatePodBuilder podBuilder = new UpdatePodBuilder();

    podBuilder.name("local");
    podBuilder.cluster(_bartender.serverSelf().getCluster());

    // int count = Math.min(3, rack.getServerLength());

    ServerPod serverPod = new ServerPod(0, serverSelf);

    ServerPod[] servers = new ServerPod[] {serverPod};

    podBuilder.pod(servers);

    // int depth = Math.min(3, handles.length);
    podBuilder.primaryCount(1);
    podBuilder.depth(1);

    UpdatePod updatePod = podBuilder.build();

    return new UpdatePod(updatePod, new String[] {serverSelf.getId()}, 0);
  }
  @Override
  protected void build(BartenderSystem bartender) {
    if (_bartender != null) {
      throw new IllegalStateException();
    }

    _bartender = bartender;

    ServicesAmp manager = AmpSystem.currentManager();

    manager.service("local://").bind("public:///cluster_root.0");

    _heartbeatImpl = new HeartbeatImpl(_bartender, getServerSelf(), getRoot(), this);

    ServiceRef heartbeatRef =
        manager.newService(_heartbeatImpl).address("public://" + HeartbeatService.PATH).ref();

    HeartbeatLocalImpl heartbeatLocalImpl = new HeartbeatLocalImpl(_bartender, _heartbeatImpl);

    _heartbeat = heartbeatRef.as(HeartbeatService.class);

    _heartbeatLocal = heartbeatRef.pin(heartbeatLocalImpl).as(HeartbeatServiceLocal.class);

    _podHeartbeatImpl =
        new PodHeartbeatImpl(_bartender, getServerSelf(), _heartbeat, _heartbeatLocal);

    ServiceRefAmp podHeartbeatRef =
        manager.newService(_podHeartbeatImpl).address(PodHeartbeatService.PATH).ref();

    _podHeartbeat = podHeartbeatRef.as(PodHeartbeatService.class);

    /*
    PodManagerImpl podManagerImpl = _podHeartbeatImpl.getManager();

    _podManager = podHeartbeatRef.service(podManagerImpl)
                                 .bind("public://" + PodManagerService.PATH)
                                 .as(PodManagerService.class);
                                 */

    PodLocalImpl podServiceImpl;
    podServiceImpl = new PodLocalImpl(_bartender, _podHeartbeatImpl);

    _podService =
        podHeartbeatRef.pin(podServiceImpl).bind(PodLocalService.PATH).as(PodLocalService.class);
  }
  private UpdatePod initClusterPod(ClusterHeartbeat cluster) {
    ServicesAmp rampManager = AmpSystem.currentManager();

    RackHeartbeat rack = cluster.findRack("rack");

    if (rack == null) {
      return null;
    }

    String podName = "cluster." + cluster.id();

    PodBuilderConfig podConfig = _podMap.get(podName);

    if (podConfig != null) {
      return null;
    }

    UpdatePodBuilder podBuilder = new UpdatePodBuilder();

    podBuilder.name("cluster");
    podBuilder.cluster(cluster);

    List<ServerHeartbeat> seedServers = cluster.getServers();

    int count = Math.max(3, seedServers.size());

    ServerPod[] servers = buildClusterServers(cluster, count);

    int index = 0;

    /*
    for (ServerHeartbeat server : cluster.getSeedServers()) {
      // ServerPod server = servers[i];

      ServerBartender serverCluster = server; // serversHint.get(i);

      if (index < servers.length && ! serverCluster.getId().startsWith("127")) {
        //System.out.println("ZOHP: " + serverCluster.getAddress());
        //server.setHintServerId(serverCluster.getHintServerId());
        servers[index++].setHintServerId(serverCluster.getId());
      }
    }
    */
    /*
    for (int i = 0; i < servers.length; i++) {
      ServerPod server = servers[i];

      if (i < seedServers.size()) {
        String hintId = seedServers.get(i).getId();

        if (! hintId.startsWith("127")) {
          server.setHintServerId(hintId);
        }
      }
    }
    */

    podBuilder.pod(servers);

    podBuilder.depth(3);

    podBuilder.primaryCount(count);

    return podBuilder.build();
  }