Package co.cask.cdap.internal.app.deploy

Examples of co.cask.cdap.internal.app.deploy.SessionInfo


    if (archiveName == null || archiveName.isEmpty()) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST, ARCHIVE_NAME_HEADER + " header not present");
    }

    final SessionInfo sessionInfo = new SessionInfo(accountId, appId, archiveName, archive, DeployStatus.UPLOADING);
    sessions.put(accountId, sessionInfo);

    return new BodyConsumer() {
      @Override
      public void chunk(ChannelBuffer request, HttpResponder responder) {
        try {
          request.readBytes(os, request.readableBytes());
        } catch (IOException e) {
          sessionInfo.setStatus(DeployStatus.FAILED);
          LOG.error("Failed to write deploy jar", e);
          responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, e.getMessage());
        }
      }
      @Override
      public void finished(HttpResponder responder) {
        try {
          os.close();
          sessionInfo.setStatus(DeployStatus.VERIFYING);
          deploy(accountId, appId, archive);
          sessionInfo.setStatus(DeployStatus.DEPLOYED);
          responder.sendString(HttpResponseStatus.OK, "Deploy Complete");
        } catch (Exception e) {
          sessionInfo.setStatus(DeployStatus.FAILED);
          LOG.error("Deploy failure", e);
          responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
        } finally {
          save(sessionInfo.setStatus(sessionInfo.getStatus()), accountId);
          sessions.remove(accountId);
        }
      }
      @Override
      public void handleError(Throwable t) {
        try {
          os.close();
          sessionInfo.setStatus(DeployStatus.FAILED);
          responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, t.getCause().getMessage());
        } catch (IOException e) {
          LOG.error("Error while saving deploy jar.", e);
        } finally {
          save(sessionInfo.setStatus(sessionInfo.getStatus()), accountId);
          sessions.remove(accountId);
        }
      }
    };
View Full Code Here


  /*
   * Returns DeploymentStatus
   */
  private DeployStatus dstatus(String accountId) {
    if (!sessions.containsKey(accountId)) {
      SessionInfo info = retrieve(accountId);
      if (info == null) {
        return DeployStatus.NOT_FOUND;
      }
      return info.getStatus();
    } else {
      SessionInfo info = sessions.get(accountId);
      return info.getStatus();
    }
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.internal.app.deploy.SessionInfo

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.