Skip to content

MemcachedClient doesn't autodetect correct client mode when connection factory client mode is set to 'Unset' #42

Open
@barrycburton

Description

@barrycburton

I'm using the following code to set up a memcached client to connect to a multi-node elasticache cluster. The URL_PROPERTY is set to a configure url which contains ".cfg." I explicitly set the client mode to 'Unset' which based on MemcachedClient.java looks like it should trigger the determineClientMode logic. But for some reason it doesn't and the client always ends up set to Static mode and only uses a single node in the cluster. If I instead explicitly set the connection factory client mode to Dynamic it works as expected and correctly detects and uses all nodes in the cluster.

  ConnectionFactoryBuilder connectionFactoryBuilder = new ConnectionFactoryBuilder(new KetamaConnectionFactory());
  if (Boolean.parseBoolean(RuntimeProperties.getProperty(CACHE_PROVIDER_MEMCACHED_USE_SSL_PROPERTY))) {
    // Build SSLContext
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init((KeyStore)null);
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, tmf.getTrustManagers(), null);
    // Create the client in TLS mode
    connectionFactoryBuilder.setSSLContext(sslContext);
    connectionFactoryBuilder.setSkipTlsHostnameVerification(true);
  }
  connectionFactoryBuilder.setClientMode(ClientMode.Unset);
  cache = new MemcachedClient(connectionFactoryBuilder.build(), AddrUtil.getAddresses(
        RuntimeProperties.getProperty(CACHE_PROVIDER_MEMCACHED_URL_PROPERTY)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions