Examples of THsHaServer


Examples of org.apache.thrift.server.THsHaServer

  private THsHaServer server_;
  private Thread serverThread_;
  private TAsyncClientManager clientManager_;

  public void setUp() throws Exception {
    server_ = new THsHaServer(new Args(new TNonblockingServerSocket(
      new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(ServerTestBase.PORT))).
      processor(new Srv.Processor(new SrvHandler())));
    serverThread_ = new Thread(new Runnable() {
      public void run() {
        server_.serve();
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

      TServer serverEngine;

      if (hsha) {
        // HsHa Server
        serverEngine = new THsHaServer(new Args(tServerSocket).processor(testProcessor));
      } else {
        // Nonblocking Server
        serverEngine = new TNonblockingServer(new Args(tServerSocket).processor(testProcessor));
      }
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

        serverArgs.getWorkerThreads(), metrics);
    serverArgs.executorService(executorService);
    serverArgs.processor(processor);
    serverArgs.transportFactory(transportFactory);
    serverArgs.protocolFactory(protocolFactory);
    return new THsHaServer(serverArgs);
  }
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

            callQueue, serverArgs.getWorkerThreads());
        serverArgs.executorService(executorService)
                  .processor(processor)
                  .transportFactory(transportFactory)
                  .protocolFactory(protocolFactory);
        tserver = new THsHaServer(serverArgs);
      } else { // THREADED_SELECTOR
        TThreadedSelectorServer.Args serverArgs =
            new HThreadedSelectorServerArgs(serverTransport, conf);
        CallQueue callQueue =
            new CallQueue(new LinkedBlockingQueue<Call>(), metrics);
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

        serverArgs.getWorkerThreads(), metrics);
    serverArgs.executorService(executorService);
    serverArgs.processor(processor);
    serverArgs.transportFactory(transportFactory);
    serverArgs.protocolFactory(protocolFactory);
    return new THsHaServer(serverArgs);
  }
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

            callQueue, serverArgs.getWorkerThreads());
        serverArgs.executorService(executorService)
                  .processor(processor)
                  .transportFactory(transportFactory)
                  .protocolFactory(protocolFactory);
        tserver = new THsHaServer(serverArgs);
      } else { // THREADED_SELECTOR
        TThreadedSelectorServer.Args serverArgs =
            new HThreadedSelectorServerArgs(serverTransport, conf);
        CallQueue callQueue =
            new CallQueue(new LinkedBlockingQueue<Call>(), metrics);
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

      if (cmd.hasOption("nonblocking")) {
        LOG.info("starting HBase Nonblocking Thrift server on " + Integer.toString(listenPort));
        server = new TNonblockingServer(processor, serverTransport, transportFactory, protocolFactory);
      } else {
        LOG.info("starting HBase HsHA Thrift server on " + Integer.toString(listenPort));
        server = new THsHaServer(processor, serverTransport, transportFactory, protocolFactory);
      }
    } else {
      // Get IP address to bind to
      InetAddress listenAddress = null;
      if (cmd.hasOption("bind")) {
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

            callQueue, serverArgs.getWorkerThreads());
        serverArgs.executorService(executorService)
                  .processor(processor)
                  .transportFactory(transportFactory)
                  .protocolFactory(protocolFactory);
        tserver = new THsHaServer(serverArgs);
      } else { // THREADED_SELECTOR
        TThreadedSelectorServer.Args serverArgs =
            new HThreadedSelectorServerArgs(serverTransport, conf);
        CallQueue callQueue =
            new CallQueue(new LinkedBlockingQueue<Call>(), metrics);
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

    final long maxFrameSize = AccumuloConfiguration.getMemoryInBytes(properties.getProperty("maxFrameSize", "16M"));
    if (maxFrameSize > Integer.MAX_VALUE)
      throw new RuntimeException(maxFrameSize + " is larger than MAX_INT");
    args.transportFactory(new TFramedTransport.Factory((int)maxFrameSize));
    args.protocolFactory(protoClass.newInstance());
    return new THsHaServer(args);
  }
View Full Code Here

Examples of org.apache.thrift.server.THsHaServer

    assertTrue(jankyReturned.get());
  }

  public void testIt() throws Exception {
    // put up a server
    final THsHaServer s = new THsHaServer(new Srv.Processor(new SrvHandler()),
      new TNonblockingServerSocket(ServerTestBase.PORT));
    new Thread(new Runnable() {
      @Override
      public void run() {
        s.serve();
      }
    }).start();
    Thread.sleep(1000);

    // set up async client manager
    TAsyncClientManager acm = new TAsyncClientManager();

    // connect an async client
    TNonblockingSocket clientSock = new TNonblockingSocket(
      ServerTestBase.HOST, ServerTestBase.PORT);
    Srv.AsyncClient client = new Srv.AsyncClient(new TBinaryProtocol.Factory(), acm, clientSock);

    // make a standard method call
    standardCallTest(client);

    // make a standard method call that succeeds within timeout
    assertFalse(s.isStopped());
    client.setTimeout(5000);
    standardCallTest(client);

    // make a void method call
    assertFalse(s.isStopped());
    final CountDownLatch voidLatch = new CountDownLatch(1);
    final AtomicBoolean voidMethodReturned = new AtomicBoolean(false);
    client.voidMethod(new FailureLessCallback<Srv.AsyncClient.voidMethod_call>() {
      @Override
      public void onComplete(voidMethod_call response) {
        try {
          response.getResult();
          voidMethodReturned.set(true);
        } catch (TException e) {
          fail(e);
        } finally {
          voidLatch.countDown();
        }
      }
    });
    voidLatch.await(1, TimeUnit.SECONDS);
    assertTrue(voidMethodReturned.get());

    // make a oneway method call
    assertFalse(s.isStopped());
    final CountDownLatch onewayLatch = new CountDownLatch(1);
    final AtomicBoolean onewayReturned = new AtomicBoolean(false);
    client.onewayMethod(new FailureLessCallback<onewayMethod_call>() {
      @Override
      public void onComplete(onewayMethod_call response) {
        try {
          response.getResult();
          onewayReturned.set(true);
        } catch (TException e) {
          fail(e);
        } finally {
          onewayLatch.countDown();
        }
      }
    });
    onewayLatch.await(1, TimeUnit.SECONDS);
    assertTrue(onewayReturned.get());

    // make another standard method call
    assertFalse(s.isStopped());
    final CountDownLatch voidAfterOnewayLatch = new CountDownLatch(1);
    final AtomicBoolean voidAfterOnewayReturned = new AtomicBoolean(false);
    client.voidMethod(new FailureLessCallback<voidMethod_call>() {
      @Override
      public void onComplete(voidMethod_call response) {
        try {
          response.getResult();
          voidAfterOnewayReturned.set(true);
        } catch (TException e) {
          fail(e);
        } finally {
          voidAfterOnewayLatch.countDown();
        }
      }
    });
    voidAfterOnewayLatch.await(1, TimeUnit.SECONDS);
    assertTrue(voidAfterOnewayReturned.get());

    // make multiple calls with deserialization in the selector thread (repro Eric's issue)
    assertFalse(s.isStopped());
    int numThreads = 50;
    int numCallsPerThread = 100;
    List<JankyRunnable> runnables = new ArrayList<JankyRunnable>();
    List<Thread> threads = new ArrayList<Thread>();
    for (int i = 0; i < numThreads; i++) {
      JankyRunnable runnable = new JankyRunnable(acm, numCallsPerThread);
      Thread thread = new Thread(runnable);
      thread.start();
      threads.add(thread);
      runnables.add(runnable);
    }
    for (Thread thread : threads) {
      thread.join();
    }
    int numSuccesses = 0;
    for (JankyRunnable runnable : runnables) {
      numSuccesses += runnable.getNumSuccesses();
    }
    assertEquals(numThreads * numCallsPerThread, numSuccesses);

    // check that timeouts work
    assertFalse(s.isStopped());
    assertTrue(clientSock.isOpen());
    final CountDownLatch timeoutLatch = new CountDownLatch(1);
    client.setTimeout(100);
    client.primitiveMethod(new AsyncMethodCallback<primitiveMethod_call>() {

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.