When a ClientCache is created, a default pool is also created if one
doesn't exist, so by using code like below, a default pool is created that
attempts to connect to host:port localhost:40404.

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

If you try to create the pool before creating the cache, you'll get an
exception like:

java.lang.IllegalStateException: Distributed System must be created before
creating pool

So, I think the way to do this with java API is to create one of the pools
as the default and the other after creating the cache like:

ClientCacheFactory ccf = new ClientCacheFactory();

// Add default pool
ConnectionInfo[] gemfireLocators = gemfireProps.getLocators();
for(ConnectionInfo e : gemfireLocators) {
   ccf.addPoolLocator(e.host, e.port);
}
ccf.setPoolServerGroup(GroupNames.GROUP1);
ccf.setPoolSubscriptionEnabled(true);
ccf.setPoolSubscriptionRedundancy(SUBSCRIPTION_REDUNDANCY);
Integer retryAttempts = gemfireProps.getClientRetryAttempts();
if (retryAttempts != null) {
    ccf.setPoolRetryAttempts(retryAttempts);
}
Integer readTimeout = gemfireProps.getClientReadTimeout();
if (readTimeout != null) {
    ccf.setPoolReadTimeout(readTimeout);
}
Integer idleTimeout = gemfireProps.getClientIdleTimeout();
if (idleTimeout != null) {
   ccf.setPoolIdleTimeout(idleTimeout);
}
Integer pingInterval = gemfireProps.getClientPingInterval();
if (pingInterval != null) {
    ccf.setPoolPingInterval(pingInterval);
}

ClientCache cache = ccf.create();

// Add another pool

String groupName = GroupNames.GROUP2;
poolName = "Group2Pool";
PoolFactory pf = PoolManager.createFactory();
ConnectionInfo[] gemfireLocators = gemfireProps.getLocators();
for(ConnectionInfo e : gemfireLocators) {
   pf.addLocator(e.host, e.port);
}
pf.setServerGroup(groupName);
pf.setSubscriptionEnabled(true);
pf.setSubscriptionRedundancy(SUBSCRIPTION_REDUNDANCY);
Integer retryAttempts = gemfireProps.getClientRetryAttempts();
if (retryAttempts != null) {
    pf.setRetryAttempts(retryAttempts);
}
Integer readTimeout = gemfireProps.getClientReadTimeout();
if (readTimeout != null) {
    pf.setReadTimeout(readTimeout);
}
Integer idleTimeout = gemfireProps.getClientIdleTimeout();
if (idleTimeout != null) {
   pf.setIdleTimeout(idleTimeout);
}
Integer pingInterval = gemfireProps.getClientPingInterval();
if (pingInterval != null) {
    pf.setPingInterval(pingInterval);
}
pf.create(poolName);

You'll get a pool called DEFAULT and another called Group2Pool,


Thanks,
Barry Oglesby


On Tue, Dec 5, 2017 at 3:45 AM, Vahram Aharonyan <[email protected]>
wrote:

> HI Jens,
>
>
>
> Please see the snippets of code we have for client:
>
>
>
> 1.       Creating the cache:
>
> ClientCacheFactory factory = *new *SecureClientCacheFactory();
>          factory.set(*"name"*, *memberName*);
>          factory.set(*"log-level"*, props.getLogLevel());
>          factory.set(*"log-file-size-limit"*, Integer.*toString*(props.
> getLogFileSizeLimit()));
>          factory.set(*"log-disk-space-limit"*, Integer.*toString*(props.
> getLogDiskSpaceLimit()));
>          factory.set(*"archive-file-size-limit"*, Integer.*toString*
> (props.getArchiveFileSizeLimit()));
>          factory.set(*"archive-disk-space-limit"*, Integer.*toString*
> (props.getArchiveDiskSpaceLimit()));
>          factory.set(*"log-file"*, logFile + *".log"*);
>          factory.set(*"statistic-archive-file"*, logFile + *".gfs"*);
>          *cache *= factory.create();
>
>
>
> 2.       Afterwards we are creating two Pools based on the server groups
> we have:
>
> a.       Group1
>
> String poolName = *"Group1Pool"*;
> PoolFactory factory = PoolManager.*createFactory*();
> ConnectionInfo[] gemfireLocators = gemfireProps.getLocators();
> *for*(ConnectionInfo e : gemfireLocators) {
>    factory.addLocator(e.*host*, e.*port*);
> }
> factory.setServerGroup(GroupNames.*GROUP1*);
> factory.setSubscriptionEnabled(*true*);
> factory.setSubscriptionRedundancy(*SUBSCRIPTION_REDUNDANCY*);
> Integer retryAttempts = gemfireProps.getClientRetryAttempts();
> *if *(retryAttempts != *null*) {
>     factory.setRetryAttempts(retryAttempts);
> }
> Integer readTimeout = gemfireProps.getClientReadTimeout();
> *if *(readTimeout != *null*) {
>     factory.setReadTimeout(readTimeout);
> }
> Integer idleTimeout = gemfireProps.getClientIdleTimeout();
> *if *(idleTimeout != *null*) {
>    factory.setIdleTimeout(idleTimeout);
> }
> Integer pingInterval = gemfireProps.getClientPingInterval();
> *if *(pingInterval != *null*) {
>     factory.setPingInterval(pingInterval);
> }
> *pool1 *= factory.create(poolName);
>
>
>
> b.       Group2
>
> String groupName = GroupNames.*GROUP2*;
> poolName = *"Group2Pool"*;
> PoolFactory factory = PoolManager.*createFactory*();
> ConnectionInfo[] gemfireLocators = gemfireProps.getLocators();
> *for *(ConnectionInfo e : gemfireLocators) {
>     factory.addLocator(e.*host*, e.*port*);
> }
> factory.setServerGroup(groupName);
> Integer retryAttempts = gemfireProps.getClientRetryAttempts();
> *if *(retryAttempts != *null*) {
>     factory.setRetryAttempts(retryAttempts);
> }
> Integer readTimeout = gemfireProps.getClientReadTimeout();
> *if *(readTimeout != *null*) {
>     factory.setReadTimeout(readTimeout);
> }
> Integer idleTimeout = gemfireProps.getClientIdleTimeout();
> *if *(idleTimeout != *null*) {
>     factory.setIdleTimeout(idleTimeout);
> }
> Integer pingInterval = gemfireProps.getClientPingInterval();
> *if *(pingInterval != *null*) {
>     factory.setPingInterval(pingInterval);
> }
> Integer socketBufferSize = gemfireProps.getSocketBufferSize();
> *if *(socketBufferSize != *null*) {
>     factory.setSocketBufferSize(socketBufferSize);
> }
> *pool2 *= factory.create(poolName);
>
>
>
> Please note that all the parameters that we get from gemfireProps are
> defined in gemfire.properties file we use during startup.
>
>
>
> Thank you in advance,
>
> Vahram.
>
>
>
> *From:* Jens Deppe [mailto:[email protected]]
> *Sent:* Monday, December 4, 2017 8:53 PM
> *To:* [email protected]
> *Subject:* Re: Geode client attempting to connect to 40404 port
>
>
>
> How are you configuring the client Pool? Could you post the code/config
> for how this is being done?
>
>
>
> Thanks
>
> --Jens
>
>
>
> On Mon, Dec 4, 2017 at 7:33 AM, Vahram Aharonyan <[email protected]>
> wrote:
>
> Hi All,
>
>
>
> Before starting cache servers (through 
> org.apache.geode.cache.server.CacheServer#start)
> in our distributed system we  are performing 
> org.apache.geode.cache.server.CacheServer#setPort
> to set custom port on which this cache server will listen for clients.
>
> Also we do have locator service started and  cluster server/clients are
> powered up with configured locators lists  - we are using locators for
> discovery.
>
>
>
> But even with these, we see that after connecting  to distributed system
> our clients are trying to connect to their 40404 port:
>
>
>
> [warning 2017/12/04 17:29:51.688 AMT d830cfd9-509b-4443-960e-5412c8f9b516
> <poolTimer-DEFAULT-30835> tid=0x24d09] Could not connect to: Data1:40404
>
> java.net.ConnectException: Connection refused (Connection refused)
>
>         at java.net.PlainSocketImpl.socketConnect(Native Method)
>
>         at java.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__java.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=WavPlWOE9LBXSiSiRdy5gSXZ_m58FXtI2carmAxobTA&e=>
> .AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
>
>         at java.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__java.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=WavPlWOE9LBXSiSiRdy5gSXZ_m58FXtI2carmAxobTA&e=>
> .AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:
> 206)
>
>         at java.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__java.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=WavPlWOE9LBXSiSiRdy5gSXZ_m58FXtI2carmAxobTA&e=>
> .AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
>
>         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
>
>         at java.net.Socket.connect(Socket.java:589)
>
>         at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:673)
>
>         at org.apache.geode.internal.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__org.apache.geode.internal.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=IMDlJBLEtNH_ZebOjoS3oD4o5zT2SIV_uInxdwtF63A&e=>
> .SocketCreator.connect(SocketCreator.java:971)
>
>         at org.apache.geode.internal.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__org.apache.geode.internal.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=IMDlJBLEtNH_ZebOjoS3oD4o5zT2SIV_uInxdwtF63A&e=>
> .SocketCreator.connect(SocketCreator.java:934)
>
>         at org.apache.geode.internal.net
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__org.apache.geode.internal.net&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=wpTWSXVvcGFCkFEMePbOecdHHTbyiIj9aWq7oqKb0J8&m=r3XQ4tkIO34moEemZgeFUtmA80trEolzaW_6JVKlQh4&s=IMDlJBLEtNH_ZebOjoS3oD4o5zT2SIV_uInxdwtF63A&e=>
> .SocketCreator.connectForClient(SocketCreator.java:898)
>
>         at org.apache.geode.cache.client.internal.ConnectionImpl.
> connect(ConnectionImpl.java:103)
>
>         at org.apache.geode.cache.client.internal.ConnectionFactoryImpl.
> createClientToServerConnection(ConnectionFactoryImpl.java:136)
>
>         at org.apache.geode.cache.client.internal.ConnectionFactoryImpl.
> createClientToServerConnection(ConnectionFactoryImpl.java:259)
>
>         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:1315)
>
>         at java.util.concurrent.Executors$RunnableAdapter.
> call(Executors.java:511)
>
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>
>         at org.apache.geode.internal.ScheduledThreadPoolExecutorWit
> hKeepAlive$DelegatingScheduledFuture.run(ScheduledThreadPoolExecutorWit
> hKeepAlive.java:259)
>
>         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)
>
>
>
> Actually this is getting blocked because we don’t have 40404 port open in
> firewall configuration,. This does not seem to have any functional impact
> as well, but logs of client are getting filled.
>
> Can someone advice how to keep out client from attempting to connect to
> default 40404 port? Is there some configuration parameter that needs to be
> set for clients?
>
>
>
> Thanks,
>
> Vahram.
>
>
>

Reply via email to