protected RawMemcacheClient connectRaw()

in folsom/src/main/java/com/spotify/folsom/MemcacheClientBuilder.java [674:707]


  protected RawMemcacheClient connectRaw(boolean binary, Authenticator authenticator) {
    List<HostAndPort> addresses = this.addresses;
    RawMemcacheClient client;
    if (resolver != null) {
      if (!addresses.isEmpty()) {
        throw new IllegalStateException("You may not specify both a resolver and addresses");
      }
      client = createResolvingClient(binary, authenticator);
    } else {
      if (addresses.isEmpty()) {
        addresses = ImmutableList.of(HostAndPort.fromParts(DEFAULT_HOSTNAME, DEFAULT_PORT));
      }

      final List<RawMemcacheClient> clients = createClients(addresses, binary, authenticator);
      if (addresses.size() > 1) {
        checkState(clients.size() == addresses.size());

        final List<AddressAndClient> aac = new ArrayList<>(clients.size());
        for (int i = 0; i < clients.size(); i++) {
          final HostAndPort address = addresses.get(i);
          aac.add(new AddressAndClient(address, clients.get(i)));
        }

        client = new KetamaMemcacheClient(aac, nodeLocator.apply(aac));
      } else {
        client = clients.get(0);
      }
    }

    if (retry) {
      return new RetryingClient(client);
    }
    return client;
  }