Default Pool Is Always Created While Configuring A GemFire Client Cache Using Java APIs
search cancel

Default Pool Is Always Created While Configuring A GemFire Client Cache Using Java APIs

book

Article ID: 294096

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Symptoms:

While configuring a client cache using only the Java API, the "Default" pool is always created. This is shown below:

ClientCache cache = new ClientCacheFactory().create();

The default endpoint for this pool is "localhost:40404". Hence, depending on your log level, you may see the following unwanted messages in a client-side log:

[warn 2018/01/29 14:23:59.627 UTC <poolTimer-DEFAULT-2> tid=0x18] Could not connect to: localhost:40404 java.net.ConnectException: Connection refused (Connection refused) 
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.geode.internal.net.SocketCreator.connect(SocketCreator.java:988)
    at org.apache.geode.internal.net.SocketCreator.connect(SocketCreator.java:929)
    at org.apache.geode.internal.net.SocketCreator.connectForClient(SocketCreator.java:893)
    at org.apache.geode.cache.client.internal.ConnectionImpl.connect(ConnectionImpl.java:92)
    at org.apache.geode.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:135)
    at org.apache.geode.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:256)
    at org.apache.geode.cache.client.internal.pooling.ConnectionManagerImpl.prefillConnection(ConnectionManagerImpl.java:762)
    at org.apache.geode.cache.client.internal.pooling.ConnectionManagerImpl.prefill(ConnectionManagerImpl.java:706)
    at org.apache.geode.cache.client.internal.pooling.ConnectionManagerImpl$PrefillConnectionsTask.run2(ConnectionManagerImpl.java:854)
    at org.apache.geode.cache.client.internal.PoolImpl$PoolTask.run(PoolImpl.java:1291)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Moreover, this "Default" pool will continue to try to connect to establish a connection to the default endpoint periodically which is usually undesirable behavior. But, it will fail.

Environment


Resolution

There are several options to prevent the unwanted behavior of the DEFAULT pool or prevent it from being created:

  1. Configure the Java client cache via a cache.xml file, setting your own pools:
    In this case, the "Default" pool is not created.
  2. Use the "Default" pool as your first pool and configure it according to your cluster configuration:
    You can set endpoints and additional parameters for the "Default" pool via the ClientCacheFactory class before creating the "Default" pool. If you specify the actual endpoints of your cluster, you can use the "Default" pool to communicate with locators and cache servers. In the following examples code, two locators are configured:
    ClientCache ccache = new ClientCacheFactory().set("name","MyClient").set("log-level","config")
        .addPoolLocator("mylocator1.local",55221)
        .addPoolLocator("mylocator2.local", 55221)
        .create();
  3. Destroy the "Default" pool immediately after creating a client cache:
    Although you may see the above mentioned unwanted log message once, you can destroy the "Default" pool using the following method:
    ClientCache ccache = new ClientCacheFactory().set("name","MyClient").set("log-level","config")
        .create();
    Pool defaultPool = ccache.getDefaultPool();
    defaultPool.destroy();
    This, at least, will prevent the useless challenges to try to connect to the default endpoint.