code: private static List<NodeInfo> buildPartitionHosts(List<NodeInfo> nodeInfos, CouchbasePartitionInfo partitionInfo) {
          List<NodeInfo> partitionHosts = new ArrayList<NodeInfo>();
          for (String rawHost : partitionInfo.partitionHosts()) {
              NetworkAddress convertedHost;
              int directPort;
              try {
                  String parts[] = rawHost.split(":");
                  String host = "";
                  String port = parts[parts.length - 1];
                  if (parts.length > 2) {
                      // Handle IPv6 syntax
                      for (int i = 0; i < parts.length - 1; i++) {
                          host += parts[i];
                          if (parts[i].endsWith("]")) {
                              break;
                          } else {
                              host += ":";
                          }
                      }
                  } else {
                      // Simple IPv4 Handling
                      host = parts[0];
                  }
  
                  convertedHost = NetworkAddress.create(host);
                  try {
                      directPort = Integer.parseInt(port);
                  } catch (NumberFormatException e) {
                      LOGGER.warn("Could not parse port from the node address: {}, fallback to 0", system(rawHost));
                      directPort = 0;
                  }
              } catch (Exception e) {
                  throw new ConfigurationException("Could not resolve " + rawHost + "on config building.", e);
              }
              for (NodeInfo nodeInfo : nodeInfos) {
                  // Make sure we only take into account nodes which contain KV
                  if (!nodeInfo.services().containsKey(ServiceType.BINARY)) {
                      continue;
                  }
  
                  if (nodeInfo.hostname().equals(convertedHost) &&
                          (nodeInfo.services().get(ServiceType.BINARY) == directPort || directPort == 0)) {
                      partitionHosts.add(nodeInfo);
                  }
              }
          }
          if (partitionHosts.size() != partitionInfo.partitionHosts().length) {
              throw new ConfigurationException("Partition size is not equal after conversion, this is a bug.");
          }
          return partitionHosts;
      }
docs: Helper method to reference the partition hosts from the raw node list.
  
  @param nodeInfos the node infos.
  @param partitionInfo the partition info.
  @return a ordered reference list for the partition hosts.