private void validatePorts(ArrayList<Port> portList) {
    HashSet<PortType> portTypeSet = new HashSet<PortType>();
    for (Port port : portList) {
      if (portTypeSet.contains(port.getPortType())) {
        throw new IllegalArgumentException("Not more than one port of same type is allowed : " + port.getPortType());
      } else {
        portTypeSet.add(port.getPortType());
        this.ports.put(port.getPortType(), port);
      }
    }
  }
A NIO socket server. The threading model is
  1 Acceptor thread that handles new connections
  N Processor threads that each have their own selector and read requests from sockets
  M Handler threads that handle requests and produce responses back to the processor threads for writing.
ambry-network/src/main/java/com/github/ambry/network/SocketServer.java