Package co.cask.cdap.api.procedure

Examples of co.cask.cdap.api.procedure.ProcedureResponse


      byte[] name = whom.read(NameSaver.NAME);
      String toGreet = name != null ? new String(name) : "World";
      if (toGreet.equals("Jane Doe")) {
        procedureMetrics.count("greetings.count.jane_doe", 1);
      }
      responder.sendJson(new ProcedureResponse(SUCCESS), "Hello " + toGreet + "!");
    }
View Full Code Here


    sendJson(ProcedureResponse.Code.SUCCESS, object);
  }

  @Override
  public final void sendJson(ProcedureResponse.Code code, Object object) throws IOException {
    sendJson(new ProcedureResponse(code), object);
  }
View Full Code Here

    HandlerMethod handlerMethod = handlers.get(request.getMethod());
    if (handlerMethod == null) {
      LOG.error("Unsupport procedure method " + request.getMethod() + " on procedure " + procedure.getClass());
      context.getProgramMetrics().increment("query.failures", 1);
      try {
        responder.stream(new ProcedureResponse(ProcedureResponse.Code.NOT_FOUND));
      } catch (IOException e) {
        throw Throwables.propagate(e);
      }
      return;
    }
View Full Code Here

      throw new IOException("A writer is already opened for streaming or the response was already sent.");
    }

    try {
      ChannelBuffer errorContent = ChannelBuffers.wrappedBuffer(Charsets.UTF_8.encode(errorMessage));
      HttpResponse httpResponse = createHttpResponse(new ProcedureResponse(errorCode));
      httpResponse.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
      httpResponse.setHeader(HttpHeaders.Names.CONTENT_LENGTH, errorContent.readableBytes());
      httpResponse.setContent(errorContent);
      channel.write(httpResponse).addListener(ChannelFutureListener.CLOSE);
    } finally {
View Full Code Here

TOP

Related Classes of co.cask.cdap.api.procedure.ProcedureResponse

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.