gpt4 book ai didi

java - Apache Ignite - Java 瘦客户端终止

转载 作者:行者123 更新时间:2023-12-01 18:03:11 26 4
gpt4 key购买 nike

i am using apache ignite 2.8.0. this is my code for connecting the Java thin client to server,

ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
try (IgniteClient igniteClient = Ignition.startClient(cfg)) {

System.out.println("Thin client started.");
final String CACHE_NAME = "sample";
ClientCache<Integer, Object > cache = igniteClient.getOrCreateCache(CACHE_NAME);
cache.put(1,"JP");
System.out.println(cache.get(1));

} //main method



} //class

it prints JP successfully, but after that my thin client is terminated. is there any way to keep alive my thin client? this is my exception..

    [21:48:34,942][SEVERE][grid-nio-worker-client-listener-0-#30][ClientListenerProcessor] Failed to process selector key [ses=GridSelectorNioSessionImpl [worker=ByteBufferNioClientWorker [readBuf=java.nio.HeapByteBuffer[pos=0 lim=8192 cap=8192], super=AbstractNioClientWorker [idx=0, bytesRcvd=0, bytesSent=0, bytesRcvd0=0, bytesSent0=0, select=true, super=GridWorker [name=grid-nio-worker-client-listener-0, igniteInstanceName=null, finished=false, heartbeatTs=1583770713875, hashCode=1387062740, interrupted=false, runner=grid-nio-worker-client-listener-0-#30]]], writeBuf=null, readBuf=null, inRecovery=null, outRecovery=null, closeSocket=true, outboundMessagesQueueSizeMetric=null, super=GridNioSessionImpl [locAddr=/127.0.0.1:10800, rmtAddr=/127.0.0.1:51279, createTime=1583770713811, closeTime=0, bytesSent=83, bytesRcvd=92, bytesSent0=83, bytesRcvd0=92, sndSchedTime=1583770713875, lastSndTime=1583770713875, lastRcvTime=1583770713875, readsPaused=false, filterChain=FilterChain[filters=[GridNioAsyncNotifyFilter, GridNioCodecFilter [parser=ClientListenerBufferedParser, directMode=false]], accepted=true, markedForClose=false]]]
java.io.IOException: An existing connection was forcibly closed by the remote host
at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method)
at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358)
at org.apache.ignite.internal.util.nio.GridNioServer$ByteBufferNioClientWorker.processRead(GridNioServer.java:1162)
at org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.processSelectedKeysOptimized(GridNioServer.java:2449)
at org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.bodyInternal(GridNioServer.java:2216)
at org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.body(GridNioServer.java:1857)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
at java.base/java.lang.Thread.run(Thread.java:834)

最佳答案

您是否尝试过以下代码:

ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");

IgniteClient igniteClient = Ignition.startClient(cfg);

System.out.println("Thin client started.");
final String CACHE_NAME = "sample";
ClientCache<Integer, Object > cache = igniteClient.getOrCreateCache(CACHE_NAME);
cache.put(1,"JP");
System.out.println(cache.get(1));

//here your client will be alive

关于java - Apache Ignite - Java 瘦客户端终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60598588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com