private ProgramId getId() { ProgramType programType; try { programType = ProgramType.valueOf(type.toUpperCase()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Invalid program type '%s': %s", type, e.getMessage()), e); } NamespaceId namespaceId = new NamespaceId(namespace); return namespaceId.app(application).program(programType, name); }
@GET @Path("/previews/{preview-id}/tracers/{tracer-id}") public void getData(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId, @PathParam("tracer-id") String tracerId) throws Exception { NamespaceId namespace = new NamespaceId(namespaceId); ApplicationId application = namespace.app(previewId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(previewManager.getRunner(application).getData(tracerId))); }
@GET @Path("/previews/{preview-id}/status") public void getStatus(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId) throws Exception { NamespaceId namespace = new NamespaceId(namespaceId); ApplicationId application = namespace.app(previewId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(previewManager.getRunner(application).getStatus())); }
@GET @Path("/previews/{preview-id}/status") public void getStatus(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId) throws Exception { NamespaceId namespace = new NamespaceId(namespaceId); ApplicationId application = namespace.app(previewId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(previewManager.getRunner(application).getStatus())); }
@POST @Path("/previews/{preview-id}/stop") public void stop(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId) throws Exception { NamespaceId namespace = new NamespaceId(namespaceId); ApplicationId application = namespace.app(previewId); previewManager.getRunner(application).stopPreview(); responder.sendStatus(HttpResponseStatus.OK); }
@GET @Path("/routeconfig") public void getRouteConfig(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("service-id") String serviceId) throws Exception { ProgramId programId = Ids.namespace(namespaceId).app(appId).service(serviceId); RouteConfig routeConfig = routeStore.fetch(programId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(routeConfig.getRoutes())); }
public void serviceClient() throws Exception { // Construct the client used to interact with CDAP ServiceClient serviceClient = new ServiceClient(clientConfig); // Fetch service information using the service in the PurchaseApp example ServiceSpecification serviceSpec = serviceClient.get( NamespaceId.DEFAULT.app("PurchaseApp").service("CatalogLookup")); }
@Override public void perform(Arguments arguments, PrintStream printStream) throws Exception { String[] programIdParts = arguments.get(ElementType.SCHEDULE.getArgumentName().toString()).split("\\."); if (programIdParts.length < 2) { throw new CommandInputError(this); } String appId = programIdParts[0]; String scheduleName = programIdParts[1]; ScheduleId schedule = cliConfig.getCurrentNamespace().app(appId).schedule(scheduleName); scheduleClient.delete(schedule); printStream.printf("Successfully deleted schedule '%s' in app '%s'\n", scheduleName, appId); }
@Test public void testMultipleTags() { MetadataEntry entry = new MetadataEntry(NamespaceId.DEFAULT.app("a"), MetadataConstants.TAGS_KEY, "t1,t2,t3"); Set<String> expected = new HashSet<>(); expected.add("t1"); expected.add("t2"); expected.add("t3"); expected.add(MetadataConstants.TAGS_KEY + ":t1"); expected.add(MetadataConstants.TAGS_KEY + ":t2"); expected.add(MetadataConstants.TAGS_KEY + ":t3"); Assert.assertEquals(expected, indexer.getIndexes(entry)); }
@Test public void testSingleSplitTags() { MetadataEntry entry = new MetadataEntry(NamespaceId.DEFAULT.app("a"), MetadataConstants.TAGS_KEY, "foo bar"); Set<String> expected = new HashSet<>(); expected.add("foo"); expected.add("bar"); expected.add(MetadataConstants.TAGS_KEY + ":foo"); expected.add(MetadataConstants.TAGS_KEY + ":bar"); Assert.assertEquals(expected, indexer.getIndexes(entry)); }
@Test public void testSingleSimpleTags() { MetadataEntry entry = new MetadataEntry(NamespaceId.DEFAULT.app("a"), MetadataConstants.TAGS_KEY, "tag"); Set<String> expected = new HashSet<>(); expected.add("tag"); expected.add(MetadataConstants.TAGS_KEY + ":tag"); Assert.assertEquals(expected, indexer.getIndexes(entry)); }
private void testContainingTrigger(ProtoTrigger proto, Trigger trigger) { ProgramSchedule proto1 = new ProgramSchedule("sched1", "one partition schedule", new NamespaceId("test").app("a").worker("ww"), ImmutableMap.of("prop3", "abc"), proto, ImmutableList.of()); ProgramSchedule sched1 = new ProgramSchedule("sched1", "one partition schedule", new NamespaceId("test").app("a").worker("ww"), ImmutableMap.of("prop3", "abc"), trigger, ImmutableList.of()); Assert.assertEquals(sched1, GSON.fromJson(GSON.toJson(proto1), ProgramSchedule.class)); } }
protected ApplicationId parseApplicationId(Arguments arguments) { String appVersion = arguments.hasArgument(ArgumentName.APP_VERSION.toString()) ? arguments.get(ArgumentName.APP_VERSION.toString()) : ApplicationId.DEFAULT_VERSION; return cliConfig.getCurrentNamespace().app(arguments.get(ArgumentName.APP.toString()), appVersion); } }
@Override public void perform(Arguments arguments, PrintStream printStream) throws Exception { String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\."); if (programIdParts.length < 2) { throw new CommandInputError(this); } ProgramRunId programRunId = cliConfig.getCurrentNamespace().app(programIdParts[0]).workflow(programIdParts[1]) .run(arguments.get(ArgumentName.RUN_ID.toString())); Table table = getWorkflowNodeStates(programRunId); cliConfig.getTableRenderer().render(cliConfig, printStream, table); }
@Override public void perform(Arguments arguments, PrintStream printStream) throws Exception { String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\."); if (programIdParts.length < 2) { throw new CommandInputError(this); } ProgramRunId programRunId = cliConfig.getCurrentNamespace().app(programIdParts[0]).workflow(programIdParts[1]) .run(arguments.get(ArgumentName.RUN_ID.toString())); Table table = getWorkflowLocalDatasets(programRunId); cliConfig.getTableRenderer().render(cliConfig, printStream, table); }
@Before public void deploy() throws Exception { addAppArtifact(ADMIN_APP_ARTIFACT, AdminApp.class); AppRequest<Void> appRequest = new AppRequest<>(ADMIN_ARTIFACT_SUMMARY); appManager = deployApplication(NamespaceId.DEFAULT.app("AdminApp"), appRequest); }
private ApplicationManager deploy(NamespaceId namespaceId, Class<? extends Application> appClass) throws Exception { ArtifactId artifactId = new ArtifactId(namespaceId.getNamespace(), appClass.getSimpleName(), "1.0-SNAPSHOT"); addArtifact(artifactId, ARTIFACTS.get(appClass)); AppRequest<?> appRequest = new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), null); return deployApplication(namespaceId.app(appClass.getSimpleName()), appRequest); }
private LoggingContext createLoggingContext(ProgramId programId, RunId runId, @Nullable WorkflowProgramInfo workflowProgramInfo) { if (workflowProgramInfo == null) { return new SparkLoggingContext(programId.getNamespace(), programId.getApplication(), programId.getProgram(), runId.getId()); } ProgramId workflowProramId = Ids.namespace(programId.getNamespace()).app(programId.getApplication()) .workflow(workflowProgramInfo.getName()); return new WorkflowProgramLoggingContext(workflowProramId.getNamespace(), workflowProramId.getApplication(), workflowProramId.getProgram(), workflowProgramInfo.getRunId().getId(), ProgramType.SPARK, programId.getProgram(), runId.getId()); }
@Test public void testDoesNotExist() { assertDoesNotExist(new InstanceId(DOES_NOT_EXIST)); assertDoesNotExist(new NamespaceId(DOES_NOT_EXIST)); assertDoesNotExist(NamespaceId.DEFAULT.artifact(DOES_NOT_EXIST, "1.0")); ApplicationId app = NamespaceId.DEFAULT.app(AllProgramsApp.NAME); assertDoesNotExist(NamespaceId.DEFAULT.app(DOES_NOT_EXIST)); assertDoesNotExist(app.mr(DOES_NOT_EXIST)); assertDoesNotExist(NamespaceId.DEFAULT.dataset(DOES_NOT_EXIST)); }
@Test @SuppressWarnings("unchecked") public void testExists() throws NotFoundException { existenceVerifier.ensureExists(new InstanceId(EXISTS)); existenceVerifier.ensureExists(NAMESPACE); existenceVerifier.ensureExists(ARTIFACT); ApplicationId app = NAMESPACE.app(AllProgramsApp.NAME); existenceVerifier.ensureExists(app); existenceVerifier.ensureExists(app.mr(AllProgramsApp.NoOpMR.NAME)); existenceVerifier.ensureExists(NAMESPACE.dataset(AllProgramsApp.DATASET_NAME)); }