Package com.youtube.vitess.gorpc.Exceptions

Examples of com.youtube.vitess.gorpc.Exceptions.GoRpcException


   * Fetches streaming results. Should be invoked only after streamCall(). Returns Response until
   * the stream has ended, which is marked by a null.
   */
  public Response streamNext() throws GoRpcException, ApplicationException {
    if (!isStreaming) {
      throw new GoRpcException("no streaming requests pending");
    }
    try {
      return readResponse();
    } catch (ApplicationException e) {
      if (e.getMessage().equals(LAST_STREAM_RESPONSE_ERROR)) {
View Full Code Here


    }
  }

  public void close() throws GoRpcException {
    if (closed) {
      throw new GoRpcException("closing a closed connection");
    }
    try {
      codec.close();
    } catch (IOException e) {
      logger.error("connection exception", e);
      throw new GoRpcException("connection exception" + e.getMessage());
    }
    closed = true;
  }
View Full Code Here

    closed = true;
  }

  private void writeRequest(String serviceMethod, Object args) throws GoRpcException {
    if (closed) {
      throw new GoRpcException("client is closed");
    }
    if (isStreaming) {
      throw new GoRpcException("request not allowed as client is in the middle of streaming");
    }
    seq = seq.add(UnsignedLong.ONE);
    Request request = new Request(serviceMethod, seq);
    try {
      codec.WriteRequest(request, args);
    } catch (IOException e) {
      logger.error("connection exception", e);
      throw new GoRpcException("connection exception" + e.getMessage());
    }
  }
View Full Code Here

    try {
      codec.ReadResponseHeader(response);
      codec.ReadResponseBody(response);
    } catch (IOException e) {
      logger.error("connection exception", e);
      throw new GoRpcException("connection exception " + e.getMessage());
    }
    if (response.getSeq().compareTo(seq) != 0) {
      throw new GoRpcException("sequence number mismatch");
    }
    if (response.getError() != null) {
      throw new ApplicationException(response.getError());
    }
    return response;
View Full Code Here

      out.write(("CONNECT " + path + " HTTP/1.0\n\n").getBytes(CharEncoding.UTF_8));
      BufferedReader reader = new BufferedReader(new InputStreamReader(in));
      String response = reader.readLine();
      if (!CONNECTED.equals(response)) {
        s.close();
        throw new GoRpcException("unexpected response for handshake " + response);
      }
      return new Client(cFactory.createCodec(s));
    } catch (IOException e) {
      if (s != null) {
        try {
          s.close();
        } catch (IOException e1) {
          logger.error("unable to close socket", e1);
          throw new GoRpcException("unable to close socket" + e1.getMessage());
        }
      }
      logger.error("connection exception", e);
      throw new GoRpcException("connection exception " + e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of com.youtube.vitess.gorpc.Exceptions.GoRpcException

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.