2016-12-16 5 views
1

Я установил сервер riak на ubuntu.Riak java client, execute() никогда не возвращает

http://192.168.0.102:8098/ping возвращение «OK»

Я пытаюсь удаленно подключиться к нему с помощью Riak Java-клиент (2.1.1), используя следующий код. 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); 

добавить:

client.shutdown(); 

, чтобы освободить это соединение и продолжить выполнение.

Примечание, что вам нужно будет создать новое соединение для вашего следующего запроса с базой данных, так как вы закрыли client или использовать .executeAsync() вместо .execute().

+0

Но это не проходит мимо этой строки кода. Я также добавил столбец приостановленной нити в вопросе. – RakeshPrasad

+0

Если ваш код сейчас выглядит так: Response rv = client.execute (store); client.shutdown(); System.out.println ("write done"); Оператор печати должен выполняться. Я запускаю ваш код локально с изменениями, описанными выше, против одного узла. – Craig

+0

уверен, что он должен успешно работать, потому что его код ссылки в документации. Но почему-то это не работает для меня. Я надеялся, что кто-то сможет помочь мне найти причину из журнала и столбец приостановленной нити. – RakeshPrasad

0

Ожидается, что клиент Riak java будет подключаться с использованием HTTP API. Клиент Riak java подключается только через буфер протокола; используя HTTP-адрес, и порт замерзнет.

0

Yoy должны использовать это, его прекрасно работает ...

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"); 

} 

надеюсь, что вы также получите ... !!!

 Смежные вопросы

  • Нет связанных вопросов^_^