2

I create a test gemfire server.

gfsh>start locator --name=test --bind-address=localhost --port=40404

my java code is:

    ClientCacheFactory cf =  new ClientCacheFactory().addPoolServer( "localhost", 40404);
    ClientCache cache = cf.setPdxReadSerialized( true).create();
    ClientRegionFactory rf = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);

    Region region = rf.create( "People");

but i try run,it not connect gemfire locator.i dont know way?

 [warn 2017/07/02 06:53:51.363 HKT <poolTimer-DEFAULT-2> tid=0x17] Could not connect to: localhost:40404
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at com.gemstone.gemfire.internal.cache.tier.sockets.HandShake.greet(HandShake.java:1291)
at com.gemstone.gemfire.cache.client.internal.ConnectionImpl.connect(ConnectionImpl.java:111)
at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:134)
at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:252)
at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefillConnection(ConnectionManagerImpl.java:794)
at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefill(ConnectionManagerImpl.java:737)
at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl$PrefillConnectionsTask.run2(ConnectionManagerImpl.java:888)
at com.gemstone.gemfire.cache.client.internal.PoolImpl$PoolTask.run(PoolImpl.java:1260)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)

[info 2017/07/02 06:53:51.421 HKT tid=0xc] VM is exiting - shutting down distributed system

[info 2017/07/02 06:53:51.422 HKT tid=0xc] GemFireCache[id = 915500720; isClosing = true; isShutDownAll = false; closingGatewayHubsByShutdownAll = false; created = Sun Jul 02 06:53:51 HKT 2017; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.

[info 2017/07/02 06:53:51.436 HKT tid=0xc] Resetting original MemoryPoolMXBean heap threshold bytes 0 on pool PS Old Gen

[info 2017/07/02 06:53:51.467 HKT tid=0xc] Destroying connection pool DEFAULT

Jackie Tian
  • 31
  • 1
  • 4

2 Answers2

0

It looks like you may not have created any servers (servers hold data and locators help clients and other cluster members find servers). If not then you will need to start at least one server as well. Check the documentation but it would be something like this: "gfsh start server --name=server1 --dir=workdir --locators=localhost[40404] --server-port=1234"

Randy May
  • 348
  • 1
  • 8
  • Yes, and be sure to create the "People" region on the server that you create after following Randy's instructions to start a server. Also, a locator is launched on port 10334 by default (not 40404). A servers default port is 40404. You apparently got your locator and server confused. – Wes Williams Jul 02 '17 at 03:55
  • I using java config bean to connect locator, it still connect fail,but when i create CacheFactory using cache.xml.is connect successful.i don't know way? exmaple ` clientCacheFactory.set("cache-xml-file", "gemfire-clientCache.xml");` it can connect –  Jackie Tian Jul 03 '17 at 02:16
0

I using java config bean to connect locator, it still connect fail. But when i create CacheFactory using cache.xml. Example.

clientCacheFactory.set("cache-xml-file", "gemfire-clientCache.xml");

it can connect

<pool name="client"
        subscription-enabled="true">
    <locator host="172.16.175.145" port="10334"/>
</pool>
<region name="test" refid="PROXY"/>
<region name="test1" refid="PROXY">
</region>

but when i using clientCacheFactory.addLocators(),don't set cache.xml.it can't connect success

Jackie Tian
  • 31
  • 1
  • 4