@Before
 public void setUp() throws Exception {
   HttpClientConnector connector =
       new HttpClientConnector(URI.create("http://localhost:" + port + "/thrift/"));
   final ThriftClientManager clientManager = new ThriftClientManager(codecManager);
   client = clientManager.createClient(connector, ThriftSampleService.class).get();
 }
Exemplo n.º 2
0
  public Fixed(HostAndPort... hostAndPorts) {
    ThriftClientManager clientManager = new ThriftClientManager();

    cacheClients = new ArrayList<ConiferCache>();

    for (HostAndPort hostAndPort : hostAndPorts) {
      FramedClientConnector connector =
          new FramedClientConnector(fromParts(hostAndPort.getHostText(), hostAndPort.getPort()));

      try {
        cacheClients.add(clientManager.createClient(connector, ConiferCache.class).get());
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 3
0
 @Override
 public void close() {
   try {
     if (!isLastThread()) {
       return;
     }
     if (clientManager != null) {
       clientManager.close();
     }
   } catch (Exception ioex) {
     logger.error("Error while closing client connection: " + ioex);
   }
 }
Exemplo n.º 4
0
 private RocksService getNodeClient() throws Exception {
   if (nodeClient.get() == null) {
     try {
       nodeClient.set(
           clientManager
               .createClient(
                   new FramedClientConnector(fromParts(hostNodes, portNodes)), RocksService.class)
               .get());
       logger.info("Opened node Rocksdb connection to " + hostNodes + ":" + portNodes);
     } catch (Exception e) {
       logger.error("Error in open node! Host " + hostNodes + " port ++" + portNodes + " " + e);
       throw e;
     }
   }
   return nodeClient.get();
 }