Package com.youtube.vitess.gorpc

Examples of com.youtube.vitess.gorpc.Response


    this.client = client;
  }

  @Override
  public Object begin() throws ConnectionException {
    Response response = call("VTGate.Begin", new BasicBSONObject());
    return response.getReply();
  }
View Full Code Here


  }

  @Override
  public QueryResponse execute(Query query) throws ConnectionException {
    String callMethod = null;
    Response response;
    if (query.isStreaming()) {
      if (query.getKeyspaceIds() != null) {
        callMethod = "VTGate.StreamExecuteKeyspaceIds";
      } else {
        callMethod = "VTGate.StreamExecuteKeyRanges";
      }
      response = streamCall(callMethod, Bsonify.queryToBson(query));
    } else {
      if (query.getKeyspaceIds() != null) {
        callMethod = "VTGate.ExecuteKeyspaceIds";
      } else {
        callMethod = "VTGate.ExecuteKeyRanges";
      }
      response = call(callMethod, Bsonify.queryToBson(query));
    }
    return Bsonify.bsonToQueryResponse((BSONObject) response.getReply());
  }
View Full Code Here

    return Bsonify.bsonToQueryResponse((BSONObject) response.getReply());
  }

  @Override
  public QueryResult streamNext(List<Field> fields) throws ConnectionException {
    Response response;
    try {
      response = client.streamNext();
    } catch (GoRpcException | ApplicationException e) {
      LOGGER.error("vtgate exception", e);
      throw new ConnectionException("vtgate exception: " + e.getMessage());
    }

    if (response == null) {
      return null;
    }
    BSONObject reply = (BSONObject) response.getReply();
    if (reply.containsField("Result")) {
      BSONObject result = (BSONObject) reply.get("Result");
      return Bsonify.bsonToQueryResult(result, fields);
    }
    return null;
View Full Code Here

  }

  @Override
  public BatchQueryResponse batchExecute(BatchQuery batchQuery) throws ConnectionException {
    String callMethod = "VTGate.ExecuteBatchKeyspaceIds";
    Response response = call(callMethod, Bsonify.batchQueryToBson(batchQuery));
    return Bsonify.bsonToBatchQueryResponse((BSONObject) response.getReply());
  }
View Full Code Here

  }

  @Override
  public SplitQueryResponse splitQuery(SplitQueryRequest request) throws ConnectionException {
    String callMethod = "VTGate.GetMRSplits";
    Response response = call(callMethod, Bsonify.splitQueryRequestToBson(request));
    return Bsonify.bsonToSplitQueryResponse((BSONObject) response.getReply());
  }
View Full Code Here

    return Bsonify.bsonToSplitQueryResponse((BSONObject) response.getReply());
  }

  private Response call(String methodName, Object args) throws ConnectionException {
    try {
      Response response = client.call(methodName, args);
      return response;
    } catch (GoRpcException | ApplicationException e) {
      LOGGER.error("vtgate exception", e);
      throw new ConnectionException("vtgate exception: " + e.getMessage());
    }
View Full Code Here

TOP

Related Classes of com.youtube.vitess.gorpc.Response

Copyright © 2018 www.massapicom. 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.