code: private boolean isPrimaryServer(ServerHeartbeat server, UpdatePod update)
    {
      int index = getServerIndex(server, update);
      
      if (index < 0) {
        return false;
      }
      
      for (int i = 0; i < update.getNodeCount(); i++) {
        UpdateNode node = update.getNode(i);
        
        int primary = node.getServers()[0];
        
        if (index == primary) {
          return true;
        }
      }
      
      return false;
    }
docs: /*
  private ArrayList<ServerHeartbeat>
  allocateServersForPod(PodConfig pod,
  Comparator<ServerPodsCost> cmp)
  {
  ArrayList<ServerPodsCost> serverCostList = new ArrayList<>();
  
  for (ServerHeartbeat server : getCluster().getServers()) {
  if (! isServerAlloc(server, pod)) {
  continue;
  }
  
  ServerPodsCost serverCost = new ServerPodsCost(server, pod);
  
  serverCost.setSeedIndex(calculateSeedIndex(server));
  serverCost.setPrimaryCount(calculatePodPrimaryCount(server));
  
  serverCostList.add(serverCost);
  }
  
  Collections.sort(serverCostList, cmp);
  
  ArrayList<ServerHeartbeat> serverList = new ArrayList<>();
  
  for (ServerPodsCost serverCost : serverCostList) {
  serverList.add(serverCost.getServer());
  }
  
  return serverList;
  }
  
  private boolean isServerAlloc(ServerHeartbeat server, PodConfig pod)
  {
  if (server.getPodSet().contains(pod.getName())) {
  return true;
  }
  else if (server.isPodAny()) {
  return true;
  }
  else if (pod.getName().equals("cluster_hub")) {
  return true;
  }
  else {
  return false;
  }
  }
  
  private int calculatePodPrimaryCount(ServerHeartbeat server)
  {
  int count = 0;
  
  for (UpdatePod updatePod : getPodsConfig().getUpdates()) {
  if (updatePod.getPodName().equals("cluster")
  || updatePod.getPodName().equals("cluster_hub")) {
  continue;
  }
  
  if (isPrimaryServer(server, updatePod)) {
  count++;
  }
  }
  
  return count;
  }