use of io.cdap.cdap.api.ProgramSpecification in project cdap by cdapio.
the class DeletedProgramHandlerStage method process.
@Override
public void process(ApplicationDeployable appSpec) throws Exception {
List<ProgramSpecification> deletedSpecs = store.getDeletedProgramSpecifications(appSpec.getApplicationId(), appSpec.getSpecification());
// TODO: this should also delete logs and run records (or not?), and do it for all program types [CDAP-2187]
Set<ProgramId> deletedPrograms = new HashSet<>();
for (ProgramSpecification spec : deletedSpecs) {
// call the deleted spec
ProgramType type = ProgramTypes.fromSpecification(spec);
ProgramId programId = appSpec.getApplicationId().program(type, spec.getName());
programTerminator.stop(programId);
programScheduler.deleteSchedules(programId);
programScheduler.modifySchedulesTriggeredByDeletedProgram(programId);
// Remove metadata for the deleted program
metadataServiceClient.drop(new MetadataMutation.Drop(programId.toMetadataEntity()));
deletedPrograms.add(programId);
}
deleteMetrics(deletedPrograms);
emit(appSpec);
}
use of io.cdap.cdap.api.ProgramSpecification in project cdap by cdapio.
the class MetadataWriterStage method collectProgramSystemMetadata.
private void collectProgramSystemMetadata(ApplicationId appId, ProgramType programType, Iterable<? extends ProgramSpecification> specs, List<MetadataMutation> mutations) {
for (ProgramSpecification spec : specs) {
ProgramId programId = appId.program(programType, spec.getName());
mutations.add(new ProgramSystemMetadataWriter(metadataServiceClient, programId, spec, creationTime).getMetadataMutation());
}
}
use of io.cdap.cdap.api.ProgramSpecification in project cdap by cdapio.
the class ProgramGenerationStage method process.
@Override
public void process(final ApplicationDeployable input) throws Exception {
List<ProgramDescriptor> programDescriptors = new ArrayList<>();
final ApplicationSpecification appSpec = input.getSpecification();
// Now, we iterate through all ProgramSpecification and generate programs
Iterable<ProgramSpecification> specifications = Iterables.concat(appSpec.getMapReduce().values(), appSpec.getWorkflows().values(), appSpec.getServices().values(), appSpec.getSpark().values(), appSpec.getWorkers().values());
for (ProgramSpecification spec : specifications) {
ProgramType type = ProgramTypes.fromSpecification(spec);
ProgramId programId = input.getApplicationId().program(type, spec.getName());
programDescriptors.add(new ProgramDescriptor(programId, appSpec));
}
emit(new ApplicationWithPrograms(input, programDescriptors));
}
use of io.cdap.cdap.api.ProgramSpecification in project cdap by cdapio.
the class ApplicationVerificationStage method verifyPrograms.
protected void verifyPrograms(ApplicationId appId, ApplicationSpecification specification) {
Iterable<ProgramSpecification> programSpecs = Iterables.concat(specification.getMapReduce().values(), specification.getWorkflows().values());
VerifyResult result;
for (ProgramSpecification programSpec : programSpecs) {
Verifier<ProgramSpecification> verifier = getVerifier(programSpec.getClass());
result = verifier.verify(appId, programSpec);
if (!result.isSuccess()) {
throw new RuntimeException(result.getMessage());
}
}
for (Map.Entry<String, WorkflowSpecification> entry : specification.getWorkflows().entrySet()) {
verifyWorkflowSpecifications(specification, entry.getValue());
}
for (Map.Entry<String, ScheduleCreationSpec> entry : specification.getProgramSchedules().entrySet()) {
String programName = entry.getValue().getProgramName();
if (!specification.getWorkflows().containsKey(programName)) {
throw new RuntimeException(String.format("Schedule '%s' is invalid: Workflow '%s' is not configured " + "in application '%s'", entry.getValue().getName(), programName, specification.getName()));
}
}
}
use of io.cdap.cdap.api.ProgramSpecification in project cdap by cdapio.
the class ProgramLifecycleHttpHandler method programSpecification.
@GET
@Path("/apps/{app-name}/versions/{app-version}/{program-type}/{program-name}")
public void programSpecification(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-name") String appName, @PathParam("app-version") String appVersion, @PathParam("program-type") String type, @PathParam("program-name") String programName) throws Exception {
ProgramType programType = getProgramType(type);
ApplicationId application = new ApplicationId(namespaceId, appName, appVersion);
ProgramId programId = application.program(programType, programName);
ProgramSpecification specification = lifecycleService.getProgramSpecification(programId);
if (specification == null) {
throw new NotFoundException(programId);
}
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(specification));
}
Aggregations