@Override public Map<String, ScheduleCreationSpec> getProgramSchedules() { return delegate.getProgramSchedules(); }
@Override public Map<String, ScheduleCreationSpec> getProgramSchedules() { return delegate.getProgramSchedules(); }
private Set<ProgramSchedule> getProgramScheduleSet(ApplicationId appId, ApplicationSpecification appSpec) { Set<ProgramSchedule> schedules = new HashSet<>(); for (ScheduleCreationSpec scheduleCreationSpec : appSpec.getProgramSchedules().values()) { schedules.add(toProgramSchedule(appId, scheduleCreationSpec)); } return schedules; }
private Set<ProgramSchedule> getProgramScheduleSet(ApplicationId appId, ApplicationSpecification appSpec) { Set<ProgramSchedule> schedules = new HashSet<>(); for (ScheduleCreationSpec scheduleCreationSpec : appSpec.getProgramSchedules().values()) { schedules.add(toProgramSchedule(appId, scheduleCreationSpec)); } return schedules; }
private void addSchedules(ImmutableMap.Builder<String, String> properties) { for (ScheduleCreationSpec creationSpec : appSpec.getProgramSchedules().values()) { properties.put("schedule" + MetadataConstants.KEYVALUE_SEPARATOR + creationSpec.getName(), creationSpec.getName() + MetadataConstants.KEYVALUE_SEPARATOR + creationSpec.getDescription()); } } }
private void addSchedules(ImmutableMap.Builder<String, String> properties) { for (ScheduleCreationSpec creationSpec : appSpec.getProgramSchedules().values()) { properties.put("schedule" + MetadataDataset.KEYVALUE_SEPARATOR + creationSpec.getName(), creationSpec.getName() + MetadataDataset.KEYVALUE_SEPARATOR + creationSpec.getDescription()); } } }
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())); } } }
protected void verifyPrograms(ApplicationId appId, ApplicationSpecification specification) { Iterable<ProgramSpecification> programSpecs = Iterables.concat(specification.getFlows().values(), specification.getMapReduce().values(), specification.getWorkflows().values()); VerifyResult result; for (ProgramSpecification programSpec : programSpecs) { result = getVerifier(programSpec.getClass()).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())); } } }
@Override public JsonElement serialize(ApplicationSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", new JsonPrimitive(src.getName())); jsonObj.add("appVersion", new JsonPrimitive(src.getAppVersion())); if (src.getConfiguration() != null) { jsonObj.add("configuration", new JsonPrimitive(src.getConfiguration())); } jsonObj.add("artifactId", context.serialize(src.getArtifactId())); jsonObj.add("description", new JsonPrimitive(src.getDescription())); jsonObj.add("datasetModules", serializeMap(src.getDatasetModules(), context, String.class)); jsonObj.add("datasetInstances", serializeMap(src.getDatasets(), context, DatasetCreationSpec.class)); jsonObj.add("mapReduces", serializeMap(src.getMapReduce(), context, MapReduceSpecification.class)); jsonObj.add("sparks", serializeMap(src.getSpark(), context, SparkSpecification.class)); jsonObj.add("workflows", serializeMap(src.getWorkflows(), context, WorkflowSpecification.class)); jsonObj.add("services", serializeMap(src.getServices(), context, ServiceSpecification.class)); jsonObj.add("programSchedules", serializeMap(src.getProgramSchedules(), context, ScheduleCreationSpec.class)); jsonObj.add("workers", serializeMap(src.getWorkers(), context, WorkerSpecification.class)); jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class)); return jsonObj; }
@Override public JsonElement serialize(ApplicationSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", new JsonPrimitive(src.getName())); jsonObj.add("appVersion", new JsonPrimitive(src.getAppVersion())); if (src.getConfiguration() != null) { jsonObj.add("configuration", new JsonPrimitive(src.getConfiguration())); } jsonObj.add("artifactId", context.serialize(src.getArtifactId())); jsonObj.add("description", new JsonPrimitive(src.getDescription())); jsonObj.add("streams", serializeMap(src.getStreams(), context, StreamSpecification.class)); jsonObj.add("datasetModules", serializeMap(src.getDatasetModules(), context, String.class)); jsonObj.add("datasetInstances", serializeMap(src.getDatasets(), context, DatasetCreationSpec.class)); jsonObj.add("flows", serializeMap(src.getFlows(), context, FlowSpecification.class)); jsonObj.add("mapReduces", serializeMap(src.getMapReduce(), context, MapReduceSpecification.class)); jsonObj.add("sparks", serializeMap(src.getSpark(), context, SparkSpecification.class)); jsonObj.add("workflows", serializeMap(src.getWorkflows(), context, WorkflowSpecification.class)); jsonObj.add("services", serializeMap(src.getServices(), context, ServiceSpecification.class)); jsonObj.add("programSchedules", serializeMap(src.getProgramSchedules(), context, ScheduleCreationSpec.class)); jsonObj.add("workers", serializeMap(src.getWorkers(), context, WorkerSpecification.class)); jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class)); return jsonObj; }
/** * Remove the profile metadata according to the message, currently only meant for application and schedule. */ private void removeProfileMetadata(MetadataMessage message) { EntityId entity = message.getEntityId(); Map<MetadataEntity, Set<String>> toRemove = new HashMap<>(); // We only care about application and schedules. if (entity.getEntityType().equals(EntityType.APPLICATION)) { ApplicationId appId = (ApplicationId) message.getEntityId(); ApplicationSpecification appSpec = message.getPayload(GSON, ApplicationSpecification.class); for (ProgramId programId : getAllProfileAllowedPrograms(appSpec, appId)) { toRemove.put(programId.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } for (ScheduleId scheduleId : getSchedulesInApp(appId, appSpec.getProgramSchedules())) { toRemove.put(scheduleId.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } } else if (entity.getEntityType().equals(EntityType.SCHEDULE)) { toRemove.put(entity.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } if (!toRemove.isEmpty()) { metadataStore.removeProperties(MetadataScope.SYSTEM, toRemove); } }
/** * Remove the profile metadata according to the message, currently only meant for application and schedule. */ private void removeProfileMetadata(MetadataMessage message) { EntityId entity = message.getEntityId(); // We only care about application and schedules. if (entity.getEntityType().equals(EntityType.APPLICATION)) { ApplicationId appId = (ApplicationId) message.getEntityId(); ApplicationSpecification appSpec = message.getPayload(GSON, ApplicationSpecification.class); for (ProgramId programId : getProgramsWithType(appId, ProgramType.WORKFLOW, appSpec.getWorkflows())) { metadataDataset.removeProperties(programId.toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } for (ScheduleId scheduleId : getSchedulesInApp(appId, appSpec.getProgramSchedules())) { metadataDataset.removeProperties(scheduleId.toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } } if (entity.getEntityType().equals(EntityType.SCHEDULE)) { metadataDataset.removeProperties(message.getEntityId().toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } }
for (String schedule: spec.getProgramSchedules().keySet()) { expectedMetadataChangeEntities.add(appId.schedule(schedule));
Assert.assertEquals(1, specification.getDatasets().size()); Assert.assertTrue(specification.getDatasets().containsKey(ConfigTestApp.DEFAULT_TABLE)); Assert.assertNotNull(specification.getProgramSchedules().get(ConfigTestApp.SCHEDULE_NAME)); ProgramStatusTrigger trigger = (ProgramStatusTrigger) specification.getProgramSchedules() .get(ConfigTestApp.SCHEDULE_NAME).getTrigger(); Assert.assertEquals(trigger.getProgramId().getProgram(), ConfigTestApp.WORKFLOW_NAME);