private ApplicationId deserializeApplicationId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String applicationId = id.get("application").getAsString(); String version = id.get("version").getAsString(); return new ApplicationId(namespace.getNamespace(), applicationId, version); }
public Collection<String> getAppVersions(String namespace, String application) throws Exception { Collection<ApplicationId> appIds = store.getAllAppVersionsAppIds(new ApplicationId(namespace, application)); List<String> versions = new ArrayList<>(); for (ApplicationId appId : appIds) { versions.add(appId.getVersion()); } return versions; }
public FlowletId flowlet(String flowlet) { if (type != ProgramType.FLOW) { throw new IllegalArgumentException("Expected program type for flowlet to be " + ProgramType.FLOW); } return new FlowletId(new ApplicationId(getNamespace(), getApplication(), getVersion()), program, flowlet); }
@Override public Trigger onProgramStatus(String programNamespace, String application, ProgramType programType, String program, ProgramStatus... programStatuses) { return new ProgramStatusTrigger(new ApplicationId(programNamespace, application) .program(co.cask.cdap.proto.ProgramType.valueOf(programType.name()), program), programStatuses); }
@Override public ProgramStatusTrigger build(String namespace, String applicationName, String applicationVersion) { // Inherit environment attributes from the deployed application ProgramId programId = new ApplicationId(namespace, applicationName, applicationVersion).program(programType, programName); return new ProgramStatusTrigger(programId, programStatuses); } }
/** * Creates a {@link ProgramRunId} of this program id with the given run id. */ public ProgramRunId run(String run) { return new ProgramRunId(new ApplicationId(getNamespace(), getApplication(), getVersion()), type, program, run); }
/** * Creates a {@link ProgramRunId} of this program id with the given run id. */ public ProgramRunId run(String run) { return new ProgramRunId(new ApplicationId(getNamespace(), getApplication(), getVersion()), type, program, run); }
@SuppressWarnings("unused") public static ApplicationId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), nextAndEnd(iterator, "version")); }
@Override public ProgramId getParent() { return new ProgramId(new ApplicationId(getNamespace(), getApplication(), getVersion()), ProgramType.FLOW, getFlow()); }
private void doGetSchedule(HttpResponder responder, String namespace, String app, String version, String scheduleName) throws Exception { ScheduleId scheduleId = new ApplicationId(namespace, app, version).schedule(scheduleName); ProgramSchedule schedule = programScheduleService.get(scheduleId); ScheduleDetail detail = schedule.toScheduleDetail(); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(detail, ScheduleDetail.class)); }
private void doDeleteSchedule(HttpResponder responder, String namespaceId, String appName, String appVersion, String scheduleName) throws Exception { ScheduleId scheduleId = new ApplicationId(namespaceId, appName, appVersion).schedule(scheduleName); programScheduleService.delete(scheduleId); responder.sendStatus(HttpResponseStatus.OK); }
@SuppressWarnings("unused") public static ProgramId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ProgramId( new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version")), ProgramType.valueOfPrettyName(next(iterator, "type")), nextAndEnd(iterator, "program")); }
@SuppressWarnings("unused") public static ProgramId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ProgramId( new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version")), ProgramType.valueOfPrettyName(next(iterator, "type")), nextAndEnd(iterator, "program")); }
@SuppressWarnings("unused") public static ProgramRunId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ProgramRunId( new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version")), ProgramType.valueOfPrettyName(next(iterator, "type")), next(iterator, "program"), nextAndEnd(iterator, "run")); }
private void doUpdateSchedule(FullHttpRequest request, HttpResponder responder, String namespaceId, String appId, String appVersion, String scheduleName) throws Exception { ScheduleId scheduleId = new ApplicationId(namespaceId, appId, appVersion).schedule(scheduleName); ScheduleDetail scheduleDetail = readScheduleDetailBody(request, scheduleName); programScheduleService.update(scheduleId, scheduleDetail); responder.sendStatus(HttpResponseStatus.OK); }
private void doUpdateSchedule(FullHttpRequest request, HttpResponder responder, String namespaceId, String appId, String appVersion, String scheduleName) throws Exception { ScheduleId scheduleId = new ApplicationId(namespaceId, appId, appVersion).schedule(scheduleName); ScheduleDetail scheduleDetail = readScheduleDetailBody(request, scheduleName); programScheduleService.update(scheduleId, scheduleDetail); responder.sendStatus(HttpResponseStatus.OK); }
/** * Parses the {@link ProgramRunId} from the {@link MDSKey}. */ private ProgramRunId getProgramRunId(MDSKey key) { MDSKey.Splitter st = key.split(); st.skipString(); // Skip prefix return new ProgramRunId(new ApplicationId(st.getString(), st.getString(), st.getString()), ProgramType.valueOf(st.getString()), st.getString(), st.getString()); } }
@Test public void testUpdateChangedApplication() { ApplicationId id = new ApplicationId("account1", "application1"); store.addApplication(id, Specifications.from(new FooApp())); // update store.addApplication(id, Specifications.from(new ChangedFooApp())); ApplicationSpecification spec = store.getApplication(id); Assert.assertNotNull(spec); Assert.assertEquals(FooMapReduceJob.class.getName(), spec.getMapReduce().get("mrJob3").getClassName()); }
/** * Good test */ @Test public void testGoodApplication() { ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp()); ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(); ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec)); ApplicationVerification app = new ApplicationVerification(); VerifyResult result = app.verify(new ApplicationId("test", newSpec.getName()), newSpec); Assert.assertSame(result.getMessage(), result.getStatus(), VerifyResult.Status.SUCCESS); }
@Test public void testGetMetadataEntityFromKey() { ApplicationId expectedAppId = new ApplicationId("ns1", "app1"); MDSKey mdsValueKey = MetadataKey.createValueRowKey(expectedAppId.toMetadataEntity(), "key1"); MDSKey mdsIndexKey = MetadataKey.createIndexRowKey(expectedAppId.toMetadataEntity(), "key1", "value1"); // check that we can get MetadataEntity from value and index key MetadataEntity actualAppId = MetadataKey.extractMetadataEntityFromKey(mdsValueKey.getKey()); Assert.assertEquals(expectedAppId.toMetadataEntity(), actualAppId); actualAppId = MetadataKey.extractMetadataEntityFromKey(mdsIndexKey.getKey()); Assert.assertEquals(expectedAppId.toMetadataEntity(), actualAppId); }