private boolean createPipeline() throws IOException {

    JsonRpcClient client = createClient();

    boolean result = createPipeline(client);

    client.close();

    return result;
  }
  public boolean secuentialPipelinesOneConnection()
      throws IOException, InterruptedException, ExecutionException {

    JsonRpcClient client = createClient();

    for (int i = 0; i < SEQUENTIAL_PIPELINES; i++) {
      LOG.info("Starting pipeline OneConnection {}", i);
      if (!createPipeline(client)) {
        return false;
      }
      LOG.info("Finished pipeline OneConnection {}", i);
    }

    client.close();
    return true;
  }
  private JsonObject sendRequest(JsonRpcClient client, String request) throws IOException {

    JsonObject requestJson = createJsonObject(request);

    JsonElement paramsProp = requestJson.get("params");
    JsonObject params = null;
    if (paramsProp != null) {
      params = paramsProp.getAsJsonObject();
    }

    return client.sendRequest(requestJson.get("method").getAsString(), params, JsonObject.class);
  }
  public JsonRpcClient createClient() throws IOException {

    HttpHeaders headers = new HttpHeaders();
    headers.add(
        "X-Auth-Token",
        "jm1-vF_kcarImdhRh0v4axk0FcndHbZPaNRpiRMyddp2Qb1Kojllfm63Ikv3uN3KFx850CCYzUamjNl5GwApnQ");

    JsonRpcClient client =
        new JsonRpcClientWebSocket("ws://localhost:" + getPort() + "/thrift", headers);

    client.setServerRequestHandler(
        new DefaultJsonRpcHandler<JsonObject>() {
          @Override
          public void handleRequest(Transaction transaction, Request<JsonObject> request)
              throws Exception {

            LOG.info("Request received: " + request);
          }
        });

    LOG.info("Client started");

    return client;
  }
 public void teardown(JsonRpcClient client) throws IOException {
   client.close();
   LOG.info("Client finished");
 }