2

我创建了一个测试 gemfire 服务器。

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

我的Java代码是:

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

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

但我尝试运行,它没有连接 gemfire 定位器。我不知道怎么办?

 [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 正在退出 - 关闭分布式系统

[信息 2017/07/02 06:53:51.422 HKT tid=0xc] GemFireCache[id = 915500720; isClosing = true; isShutDownAll = 假;关闭GatewayHubsByShutdownAll = false; 创建 = Sun Jul 02 06:53:51 HKT 2017;服务器=假;复制阅读 = 假;锁定租赁 = 120; lockTimeout = 60]:现在关闭。

[info 2017/07/02 06:53:51.436 HKT tid=0xc] 在池 PS Old Gen 上重置原始 MemoryPoolMXBean 堆阈值字节 0

[info 2017/07/02 06:53:51.467 HKT tid=0xc] 销毁连接池默认

4

2 回答 2

0

看起来您可能没有创建任何服务器(服务器保存数据,定位器帮助客户端和其他集群成员查找服务器)。如果没有,那么您还需要启动至少一台服务器。检查文档,但它会是这样的:“gfsh start server --name=server1 --dir=workdir --locators=localhost[40404] --server-port=1234”

于 2017-07-02T01:04:32.630 回答
0

我使用 java config bean 连接定位器,它仍然连接失败。但是当我使用 cache.xml 创建 CacheFactory 时。例子。

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

它可以连接

<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>

但是当我使用clientCacheFactory.addLocators()时,不要设置cache.xml。它无法连接成功

于 2017-07-03T02:22:39.213 回答