Ejemplo n.º 1
0
  /** @throws java.lang.Exception */
  @After
  public void tearDown() throws Exception {
    client.shutdown();
    client.waitForShutdown();

    dispatcher.shutdown();
    dispatcher.waitForShutdown();
  }
Ejemplo n.º 2
0
  /** @throws java.lang.Exception */
  @Before
  public void setUp() throws Exception {
    config =
        new ReplicationConfig(
            RequestHandlerTest.class.getResource("/config/replication_server0.test").getPath(),
            conf0);
    dispatcher = new RequestDispatcher(config);
    dispatcher.setLifeCycleListener(this);

    Map<Integer, Operation> testOps = new HashMap<Integer, Operation>();
    testOps.put(operationId, operation);
    RequestHandler handler = new RequestHandlerMock(MAX_Q, interfaceId, testOps);
    dispatcher.addHandler(handler);

    // control = handler;
    dispatcher.start();
    dispatcher.waitForStartup();

    client =
        new RPCNIOSocketClient(
            config.getSSLOptions(), RQ_TIMEOUT, CON_TIMEOUT, "BabuDB Replication Unittest");
    client.start();
    client.waitForStartup();
  }
Ejemplo n.º 3
0
  /**
   * Sends a message to the dispatcher.
   *
   * @param message
   * @return future for the response.
   */
  private RPCResponse<ErrorCodeResponse> send(Message message) {

    RPCResponse<ErrorCodeResponse> result =
        new RPCResponse<ErrorCodeResponse>(ErrorCodeResponse.getDefaultInstance());
    client.sendRequest(
        config.getInetSocketAddress(),
        AUTHENTICATION,
        USER_CREDENTIALS,
        interfaceId,
        operationId,
        message,
        null,
        result,
        false);

    return result;
  }