2016-12-16 1 views
1

우분투에 riak 서버를 설치했습니다.Riak 자바 클라이언트, execute() never

http://192.168.0.102:8098/ping 반환 "OK"

내가 원격으로 다음 코드를 사용하여 자바 클라이언트 (2.1.1) riak 사용하여 연결을 시도하고있다. client.execute()는 결코 반환하지 않습니다. 나는 또한 로그를 첨부하고있다. 콘솔에

public class Testing { 

    public static void main(String[] args) throws ExecutionException, 
      InterruptedException, UnknownHostException { 

     RiakClient client = RiakClient.newClient(8098, "192.168.0.102"); 

     // put some stuff 

     Namespace ns = new Namespace("TestBucket"); 
     Location location = new Location(ns, "TestKey"); 

     String myData = "TestValue"; 

     StoreValue store = new StoreValue.Builder(myData) 
     .withLocation(location).build(); 
     Response rv = client.execute(store);   // << NEVER GETS PAST THIS 

     System.out.println("write done"); 

     // get some stuff 
     FetchValue fv = new FetchValue.Builder(location).build(); 
     FetchValue.Response response = client.execute(fv); 
     String obj = response.getValue(String.class); 

     System.out.println(obj); 
     System.out.println("fetch done"); 

    } 

} 

로그인이 일시 중단 된 스레드의

17:19:40.841 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework 
17:19:40.865 [main] DEBUG i.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 16 
17:19:40.891 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available 
17:19:40.892 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available 
17:19:40.893 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available 
17:19:40.894 [main] DEBUG i.n.util.internal.PlatformDependent0 - direct buffer constructor: available 
17:19:40.894 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true 
17:19:40.894 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available 
17:19:40.896 [main] DEBUG io.netty.util.internal.Cleaner0 - java.nio.ByteBuffer.cleaner(): available 
17:19:40.896 [main] DEBUG i.n.util.internal.PlatformDependent - Platform: Windows 
17:19:40.897 [main] DEBUG i.n.util.internal.PlatformDependent - Java version: 8 
17:19:40.897 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false 
17:19:40.897 [main] DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available 
17:19:40.898 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false 
17:19:40.899 [main] DEBUG i.n.util.internal.PlatformDependent - Javassist: unavailable 
17:19:40.899 [main] DEBUG i.n.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes. Please check the configuration for better performance. 
17:19:40.899 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\Rakesh\AppData\Local\Temp (java.io.tmpdir) 
17:19:40.900 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.bitMode: 32 (sun.arch.data.model) 
17:19:40.900 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false 
17:19:40.900 [main] DEBUG i.n.util.internal.PlatformDependent - io.netty.maxDirectMemory: 259522560 bytes 
17:19:40.921 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false 
17:19:40.921 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512 
17:19:40.922 [main] DEBUG i.n.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available 
17:19:41.039 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 2924 (auto-detected) 
17:19:41.041 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false 
17:19:41.041 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false 
17:19:41.162 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1) 
17:19:41.163 [main] DEBUG io.netty.util.NetUtil - \proc\sys\net\core\somaxconn: 200 (non-existent) 
17:19:41.321 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: e4:b3:18:ff:fe:6c:52:eb (auto-detected) 
17:19:41.321 [main] DEBUG i.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier: 0xb620b93d4006e503 
17:19:41.333 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple 
17:19:41.333 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.maxRecords: 4 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 2 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 2 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768 
17:19:41.355 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192 
17:19:41.364 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled 
17:19:41.365 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536 
17:19:41.365 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384 
17:19:41.406 [main] INFO com.basho.riak.client.core.RiakNode - RiakNode started; 192.168.0.102:8098 
17:19:41.407 [main] INFO c.basho.riak.client.core.RiakCluster - RiakCluster is starting. 
17:19:41.408 [main] INFO c.b.r.c.core.util.DefaultCharset - No desired charset found in system properties, the default charset 'windows-1252' will be used 
17:19:41.408 [main] INFO c.b.r.c.core.util.DefaultCharset - Initializing client charset to: windows-1252 
17:19:41.443 [main] DEBUG com.basho.riak.client.core.RiakNode - Attempting to acquire channel permit 
17:19:41.445 [main] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 32768 
17:19:41.445 [main] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2 
17:19:41.445 [main] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16 
17:19:41.445 [main] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8 
17:19:41.447 [main] DEBUG com.basho.riak.client.core.RiakNode - Operation 28144878 being executed on RiakNode 192.168.0.102:8098 
17:19:41.461 [nioEventLoopGroup-2-10] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.bytebuf.checkAccessible: true 
17:19:41.463 [nioEventLoopGroup-2-10] DEBUG i.n.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: [email protected] 

콜 스택입니다 ...

Thread [main] (Suspended) 
    Unsafe.park(boolean, long) line: not available [native method] 
    LockSupport.park(Object) line: not available  
    CountDownLatch$Sync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: not available 
    CountDownLatch$Sync(AbstractQueuedSynchronizer).doAcquireSharedInterruptibly(int) line: not available 
    CountDownLatch$Sync(AbstractQueuedSynchronizer).acquireSharedInterruptibly(int) line: not available 
    CountDownLatch.await() line: not available 
    StoreOperation(FutureOperation<T,U,S>).await() line: 387  
    GenericRiakCommand$1(CoreFutureAdapter<T2,S2,T,S>).await() line: 90 
    StoreValue(RiakCommand<T,S>).execute(RiakCluster) line: 92 
    RiakClient.execute(RiakCommand<T,S>) line: 355 
    Testing.main(String[]) line: 29 

답변

0

당신을 위해 일을 수정해야 코드의 다음 줄 후 간단한 코드 추가 :

response rv = client.execute(store); 

add :

client.shutdown(); 

해당 연결을 해제하고 실행을 계속합니다.

주 당신이 client 폐쇄 이후 데이터베이스에 대해 다음 요청에 대한 새 연결을 만들거나 .execute() 대신 .executeAsync()를 사용해야합니다.

+0

하지만 코드 줄을 지키지 않아야합니다. 또한 질문에 중단 된 스레드의 호출 스택을 추가했습니다. – RakeshPrasad

+0

코드가 다음과 같이 표시되면 응답 rv = client.execute (store); client.shutdown(); System.out.println ("write done"); print 문을 실행해야합니다. 단일 노드에 대해 위에서 설명한 변경 사항을 사용하여 로컬에서 코드를 성공적으로 실행했습니다. – Craig

+0

확실히, 이상적으로는 문서의 참조 코드 때문에 성공적으로 실행되어야합니다. 그러나 어떤 이유로 그것은 나를 위해 작동하지 않습니다. 누군가가 로그와 중단 된 스레드의 콜 스택 (callstack)에서 이유를 찾는 것을 도울 수 있기를 바랬습니다. – RakeshPrasad

0

Riak 자바 클라이언트가 HTTP API를 사용하여 연결할 것으로 예상됩니다. Riak Java 클라이언트는 프로토콜 버퍼를 사용하여 연결합니다. HTTP 주소와 포트를 사용하면 고정됩니다.

0

전년 동기 대비는

public static void main(String[] args) throws ExecutionException, 
     InterruptedException, UnknownHostException { 

    RiakClient client = RiakClient.newClient(8087,"192.168.0.65"); 

    // put some stuff 

    Namespace ns = new Namespace("TestBucket"); 
    Location location = new Location(ns, "TestKey"); 

    String myData = "TestValue"; 

    StoreValue store = new StoreValue.Builder(myData) 
    .withLocation(location).build(); 
    client.execute(store);   // << NEVER GETS PAST THIS 

    System.out.println("write done"); 

// get some stuff 
    FetchValue fv = new FetchValue.Builder(location).build(); 
    FetchValue.Response response = client.execute(fv); 
    String obj = response.getValue(String.class); 

    System.out.println(obj); 
    System.out.println("fetch done"); 

} 

당신은 또한 얻을 것이다 희망 ...이, 미세의 작품을 사용해야합니다 ...!