Package co.cask.cdap.proto

Examples of co.cask.cdap.proto.ProgramType


  @Path("/apps/{app-id}/{runnable-type}/{runnable-id}/runtimeargs")
  public void saveRunnableRuntimeArgs(HttpRequest request, HttpResponder responder,
                                      @PathParam("app-id") final String appId,
                                      @PathParam("runnable-type") final String runnableType,
                                      @PathParam("runnable-id") final String runnableId) {
    ProgramType type = RUNNABLE_TYPE_MAP.get(runnableType);
    if (type == null || type == ProgramType.WEBAPP) {
      responder.sendStatus(HttpResponseStatus.NOT_FOUND);
      return;
    }
View Full Code Here


  }

  private synchronized void startStopProgram(HttpRequest request, HttpResponder responder,
                                             final String appId, final String runnableType,
                                             final String runnableId, final String action) {
    ProgramType type = RUNNABLE_TYPE_MAP.get(runnableType);

    if (type == null || (type == ProgramType.WORKFLOW && "stop".equals(action))) {
      responder.sendStatus(HttpResponseStatus.NOT_FOUND);
    } else {
      LOG.trace("{} call from AppFabricHttpHandler for app {}, flow type {} id {}",
View Full Code Here

                                     File hConfFile, File cConfFile, ApplicationLauncher launcher) {
    // Extract and verify parameters
    ApplicationSpecification appSpec = program.getSpecification();
    Preconditions.checkNotNull(appSpec, "Missing application specification.");

    ProgramType processorType = program.getType();
    Preconditions.checkNotNull(processorType, "Missing processor type.");
    Preconditions.checkArgument(processorType == ProgramType.MAPREDUCE, "Only MAPREDUCE process type is supported.");

    MapReduceSpecification spec = appSpec.getMapReduce().get(program.getName());
    Preconditions.checkNotNull(spec, "Missing MapReduceSpecification for %s", program.getName());
View Full Code Here

    if (!matcher.matches()) {
      LOG.warn("Unrecognized application name pattern {}", appName);
      return null;
    }

    ProgramType type = getType(matcher.group(1));
    if (type == null) {
      LOG.warn("Unrecognized program type {}", appName);
      return null;
    }
    Id.Program programId = Id.Program.from(matcher.group(2), matcher.group(3), matcher.group(4));
View Full Code Here

      String appName = liveInfo.getApplicationName();
      Matcher matcher = APP_NAME_PATTERN.matcher(appName);
      if (!matcher.matches()) {
        continue;
      }
      ProgramType appType = getType(matcher.group(1));
      if (appType != type) {
        continue;
      }

      for (TwillController controller : liveInfo.getControllers()) {
View Full Code Here

      Matcher matcher = APP_NAME_PATTERN.matcher(info.getApplicationName());
      if (!matcher.matches()) {
        return null;
      }

      ProgramType type = getType(matcher.group(1));
      if (type == null) {
        return null;
      }
      Id.Program programId = Id.Program.from(matcher.group(2), matcher.group(3), matcher.group(4));
      return Joiner.on(".").join(programId.getApplicationId(),
View Full Code Here

    }
  }

  private ProgramRuntimeService.RuntimeInfo findRuntimeInfo(String accountId, String appId,
                                                            String flowId, ProgramType typeId) {
    ProgramType type = ProgramType.valueOf(typeId.name());
    Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos = runtimeService.list(type).values();
    Preconditions.checkNotNull(runtimeInfos, UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),
                               accountId, flowId);

    Id.Program programId = Id.Program.from(accountId, appId, flowId);
View Full Code Here

                                     ApplicationLauncher launcher) {
    // Extract and verify parameters
    ApplicationSpecification appSpec = program.getSpecification();
    Preconditions.checkNotNull(appSpec, "Missing application specification.");

    ProgramType processorType = program.getType();
    Preconditions.checkNotNull(processorType, "Missing processor type.");
    Preconditions.checkArgument(processorType == ProgramType.SERVICE, "Only SERVICE process type is supported.");

    final ServiceSpecification serviceSpec = appSpec.getServices().get(program.getName());
    Preconditions.checkNotNull(serviceSpec, "Missing ServiceSpecification for %s", program.getName());
View Full Code Here

        ApplicationSpecification spec = store.getApplication(Id.Application.from(accountId, appId));
        if (spec == null) {
          addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(), "App: " + appId + " not found");
          continue;
        }
        ProgramType programType = ProgramType.valueOfPrettyName(programTypeStr);
        String runnableId;
        if (programType == ProgramType.PROCEDURE) {
          // the "runnable" for procedures has the same id as the procedure name
          runnableId = programId;
          if (spec.getProcedures().containsKey(programId)) {
            requested = store.getProcedureInstances(Id.Program.from(accountId, appId, programId));
          } else {
            addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(),
                         "Procedure: " + programId + " not found");
            continue;
          }
        } else {
          // cant get instances for things that are not flows, services, or procedures
          if (programType != ProgramType.FLOW && programType != ProgramType.SERVICE) {
            addCodeError(requestedObj, HttpResponseStatus.BAD_REQUEST.getCode(),
                         "Program type: " + programType + " is not a valid program type to get instances");
            continue;
          }
          // services and flows must have runnable id
          if (requestedObj.getRunnableId() == null) {
            responder.sendJson(HttpResponseStatus.BAD_REQUEST, "Must provide a string runnableId for flows/services");
            return;
          }
          runnableId = requestedObj.getRunnableId();
          if (programType == ProgramType.FLOW) {
            FlowSpecification flowSpec = spec.getFlows().get(programId);
            if (flowSpec != null) {
              Map<String, FlowletDefinition> flowletSpecs = flowSpec.getFlowlets();
              if (flowletSpecs != null && flowletSpecs.containsKey(runnableId)) {
                requested = flowletSpecs.get(runnableId).getInstances();
              } else {
                addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(),
                             "Flowlet: " + runnableId + " not found");
                continue;
              }
            } else {
              addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(), "Flow: " + programId + " not found");
              continue;
            }
          } else {
            // Services
            ServiceSpecification serviceSpec = spec.getServices().get(programId);
            if (serviceSpec != null) {
              Map<String, RuntimeSpecification> runtimeSpecs = serviceSpec.getRunnables();
              if (runtimeSpecs != null && runtimeSpecs.containsKey(runnableId)) {
                requested = runtimeSpecs.get(runnableId).getResourceSpecification().getInstances();
              } else {
                addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(),
                             "Runnable: " + runnableId + " not found");
                continue;
              }
            } else {
              addCodeError(requestedObj, HttpResponseStatus.NOT_FOUND.getCode(),
                           "Service: " + programId + " not found");
              continue;
            }
          }
        }
        // use the pretty name of program types to be consistent
        requestedObj.setProgramType(programType.getPrettyName());
        provisioned = getRunnableCount(accountId, appId, programType, programId, runnableId);
        requestedObj.setStatusCode(HttpResponseStatus.OK.getCode());
        requestedObj.setRequested(requested);
        requestedObj.setProvisioned(provisioned);
      }
View Full Code Here

        return;
      }
      for (int i = 0; i < args.size(); ++i) {
        BatchEndpointStatus requestedObj = args.get(i);
        Id.Program progId = Id.Program.from(accountId, requestedObj.getAppId(), requestedObj.getProgramId());
        ProgramType programType = ProgramType.valueOfPrettyName(requestedObj.getProgramType());
        // get th statuses
        StatusMap statusMap = getStatus(progId, programType);
        if (statusMap.getStatus() != null) {
          requestedObj.setStatusCode(HttpResponseStatus.OK.getCode());
          requestedObj.setStatus(statusMap.getStatus());
        } else {
          requestedObj.setStatusCode(statusMap.getStatusCode());
          requestedObj.setError(statusMap.getError());
        }
        // set the program type to the pretty name in case the request originally didn't have pretty name
        requestedObj.setProgramType(programType.getPrettyName());
      }
      responder.sendJson(HttpResponseStatus.OK, args);
    } catch (SecurityException e) {
      responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
    } catch (Throwable e) {
View Full Code Here

TOP

Related Classes of co.cask.cdap.proto.ProgramType

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.