@Override public boolean test(MDSKey input) { ProgramId programId = getProgramID(input); return programId.getVersion().equals(version); } }
@Override public boolean test(MDSKey input) { ProgramId programId = getProgramID(input); return programId.getVersion().equals(version); } }
@Override public Map<String, String> getSystemPropertiesToAdd() { ImmutableMap.Builder<String, String> properties = ImmutableMap.builder(); properties.put(ENTITY_NAME_KEY, programId.getEntityName()); properties.put(VERSION_KEY, programId.getVersion()); String description = programSpec.getDescription(); if (!Strings.isNullOrEmpty(description)) { properties.put(DESCRIPTION_KEY, description); } properties.put(CREATION_TIME_KEY, creationTime); return properties.build(); }
@Override public Iterable<String> toIdParts() { return Collections.unmodifiableList( Arrays.asList(getNamespace(), getApplication(), getVersion(), type.getPrettyName().toLowerCase(), program)); }
@Override public int hashCode() { Integer hashCode = this.hashCode; if (hashCode == null) { this.hashCode = hashCode = Objects.hash(super.hashCode(), getNamespace(), getApplication(), getVersion(), type, program); } return hashCode; }
public static String programIdFor(ProgramId program, SchedulableProgramType programType) { return String.format("%s:%s:%s:%s:%s", program.getNamespace(), program.getApplication(), program.getVersion(), programType.name(), program.getProgram()); } }
public static String programIdFor(ProgramId program, SchedulableProgramType programType) { return String.format("%s:%s:%s:%s:%s", program.getNamespace(), program.getApplication(), program.getVersion(), programType.name(), program.getProgram()); } }
private Map<ProgramRunId, RunRecordMeta> getHistoricalRuns(@Nullable ProgramId programId, ProgramRunStatus status, final long startTime, final long endTime, int limit, @Nullable Predicate<RunRecordMeta> filter) { if (programId == null || !programId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) { MDSKey key = getProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build(); return getHistoricalRuns(key, status, startTime, endTime, limit, null, filter); } Predicate<MDSKey> keyPredicate = new AppVersionPredicate(ApplicationId.DEFAULT_VERSION); MDSKey key = getProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build(); return getHistoricalRuns(key, status, startTime, endTime, limit, keyPredicate, filter); }
private Map<ProgramRunId, RunRecordMeta> getHistoricalRuns(@Nullable ProgramId programId, ProgramRunStatus status, final long startTime, final long endTime, int limit, @Nullable Predicate<RunRecordMeta> filter) { if (programId == null || !programId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) { MDSKey key = getProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build(); return getHistoricalRuns(key, status, startTime, endTime, limit, null, filter); } Predicate<MDSKey> keyPredicate = new AppVersionPredicate(ApplicationId.DEFAULT_VERSION); MDSKey key = getProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build(); return getHistoricalRuns(key, status, startTime, endTime, limit, keyPredicate, filter); }
private boolean isInState(ProgramId programId, ProgramStatus status) { try { String actual = appFabricClient.getStatus(application.getNamespace(), programId.getApplication(), programId.getVersion(), programId.getProgram(), programId.getType()); return status.name().equals(actual); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ProgramId programId = parseProgramId(arguments, elementType); String appName = programId.getApplication(); String appVersion = programId.getVersion(); String programName = programId.getProgram(); programClient.stop(programId); output.printf("Successfully stopped %s '%s' of application '%s.%s'\n", elementType.getName(), programName, appName, appVersion); }
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); }
/** * 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); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ProgramId programId = parseProgramId(arguments, elementType); String appName = programId.getApplication(); String appVersion = programId.getVersion(); String programName = programId.getProgram(); String runtimeArgsString = arguments.get(ArgumentName.RUNTIME_ARGS.toString()); Map<String, String> runtimeArgs = ArgumentParser.parseMap(runtimeArgsString, ArgumentName.RUNTIME_ARGS.toString()); programClient.setRuntimeArgs(programId, runtimeArgs); output.printf("Successfully set runtime args of %s '%s' of application '%s.%s' to '%s'\n", elementType.getName(), programName, appName, appVersion, runtimeArgsString); }
protected void stopProgram(ProgramId program, @Nullable String runId, int expectedStatusCode, String expectedMessage) throws Exception { String path; if (runId == null) { path = String.format("apps/%s/versions/%s/%s/%s/stop", program.getApplication(), program.getVersion(), program.getType().getCategoryName(), program.getProgram()); } else { // TODO: HTTP endpoint for stopping a program run of an app version not implemented path = null; } stopProgram(path, program.getNamespace(), expectedStatusCode, expectedMessage); }
protected MDSKey.Builder getProgramKeyBuilder(String recordType, @Nullable ProgramId programId) { MDSKey.Builder builder = new MDSKey.Builder().add(recordType); if (programId != null) { builder.add(programId.getNamespace()); builder.add(programId.getApplication()); builder.add(programId.getVersion()); builder.add(programId.getType().name()); builder.add(programId.getProgram()); } return builder; }
/** * Tries to start the given program with the given runtime arguments and expect the call completed with the status. */ protected void startProgram(ProgramId program, Map<String, String> args, int expectedStatusCode) throws Exception { String path = String.format("apps/%s/versions/%s/%s/%s/start", program.getApplication(), program.getVersion(), program.getType().getCategoryName(), program.getProgram()); startProgram(path, program.getNamespace(), args, expectedStatusCode); }
public List<RunRecord> getHistory(ProgramId programId, ProgramRunStatus status) throws Exception { String namespace = programId.getNamespace(); String application = programId.getApplication(); String applicationVersion = programId.getVersion(); String programName = programId.getProgram(); String categoryName = programId.getType().getCategoryName(); return doGetHistory(namespace, application, applicationVersion, programName, categoryName, status); }
protected List<RunRecord> getProgramRuns(ProgramId program, ProgramRunStatus status) throws Exception { String path = String.format("apps/%s/versions/%s/%s/%s/runs?status=%s", program.getApplication(), program.getVersion(), program.getType().getCategoryName(), program.getProgram(), status.toString()); HttpResponse response = doGet(getVersionedAPIPath(path, program.getNamespace())); Assert.assertEquals(200, response.getResponseCode()); return GSON.fromJson(response.getResponseBodyAsString(), LIST_RUNRECORD_TYPE); }
private void testVersionedProgramRuntimeArgs(ProgramId programId) throws Exception { String versionedRuntimeArgsUrl = getVersionedAPIPath("apps/" + programId.getApplication() + "/versions/" + programId.getVersion() + "/" + programId.getType().getCategoryName() + "/" + programId.getProgram() + "/runtimeargs", Constants.Gateway.API_VERSION_3_TOKEN, programId.getNamespace()); verifyRuntimeArgs(versionedRuntimeArgsUrl); }