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 ProgramId(ApplicationId appId, ProgramType type, String program) { super(appId.getNamespace(), EntityType.PROGRAM); if (type == null) { throw new NullPointerException("Program type cannot be null."); } if (program == null) { throw new NullPointerException("Program ID cannot be null."); } this.application = appId.getApplication(); this.version = appId.getVersion(); this.type = type; this.program = program; }
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; }
private ScheduleId deserializeSchedule(JsonObject id) { ApplicationId app = deserializeApplicationId(id.getAsJsonObject("application")); String scheduleId = id.get("id").getAsString(); return new ScheduleId(app.getNamespace(), app.getApplication(), app.getVersion(), scheduleId); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ApplicationId appId = parseApplicationId(arguments); appClient.delete(appId); output.printf("Successfully deleted application '%s.%s'\n", appId.getEntityName(), appId.getVersion()); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ApplicationId appId = parseApplicationId(arguments); appClient.delete(appId); output.printf("Successfully deleted application '%s.%s'\n", appId.getEntityName(), appId.getVersion()); }
private ScheduleId deserializeSchedule(JsonObject id) { ApplicationId app = deserializeApplicationId(id); String scheduleId = id.get("schedule").getAsString(); return new ScheduleId(app.getNamespace(), app.getApplication(), app.getVersion(), scheduleId); }
@Override public void startProgram(ProgramId programId, Map<String, String> arguments) { try { appFabricClient.startProgram(application.getNamespace(), application.getApplication(), application.getVersion(), programId.getProgram(), programId.getType(), arguments); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void startProgram(ProgramId programId, Map<String, String> arguments) { try { appFabricClient.startProgram(application.getNamespace(), application.getApplication(), application.getVersion(), programId.getProgram(), programId.getType(), arguments); } catch (Exception e) { throw Throwables.propagate(e); } }
private ApplicationSpecification getApplicationSpec(AppMetadataStore mds, ApplicationId id) { ApplicationMeta meta = mds.getApplication(id.getNamespace(), id.getApplication(), id.getVersion()); return meta == null ? null : meta.getSpec(); }
@Override public void removeApplication(ApplicationId id) { LOG.trace("Removing application: namespace: {}, application: {}", id.getNamespace(), id.getApplication()); Transactionals.execute(transactional, context -> { AppMetadataStore metaStore = getAppMetadataStore(context); metaStore.deleteApplication(id.getNamespace(), id.getApplication(), id.getVersion()); metaStore.deleteProgramHistory(id.getNamespace(), id.getApplication(), id.getVersion()); }); }
@Override public void stopProgram(ProgramId programId) { String programName = programId.getProgram(); try { appFabricClient.stopProgram(application.getNamespace(), application.getApplication(), application.getVersion(), programName, programId.getType()); waitForStopped(programId); } catch (Exception e) { throw Throwables.propagate(e); } }
@Nullable public ApplicationMeta getApplication(ApplicationId appId) { return getFirst(new MDSKey.Builder().add(TYPE_APP_META, appId.getNamespace(), appId.getApplication(), appId.getVersion()).build(), ApplicationMeta.class); }
@Override public void stopProgram(ProgramId programId) { String programName = programId.getProgram(); try { appFabricClient.stopProgram(application.getNamespace(), application.getApplication(), application.getVersion(), programName, programId.getType()); waitForStopped(programId); } catch (Exception e) { throw Throwables.propagate(e); } }
protected MDSKey.Builder getApplicationKeyBuilder(String recordType, @Nullable ApplicationId applicationId) { MDSKey.Builder builder = new MDSKey.Builder().add(recordType); if (applicationId != null) { builder.add(applicationId.getNamespace()); builder.add(applicationId.getApplication()); builder.add(applicationId.getVersion()); } return builder; }
@Override public void addApplication(ApplicationId id, ApplicationSpecification spec) { Transactionals.execute(transactional, context -> { getAppMetadataStore(context).writeApplication(id.getNamespace(), id.getApplication(), id.getVersion(), spec); }); }
protected MDSKey.Builder getApplicationKeyBuilder(String recordType, @Nullable ApplicationId applicationId) { MDSKey.Builder builder = new MDSKey.Builder().add(recordType); if (applicationId != null) { builder.add(applicationId.getNamespace()); builder.add(applicationId.getApplication()); builder.add(applicationId.getVersion()); } return builder; }
protected HttpResponse deploy(ApplicationId appId, AppRequest<? extends Config> appRequest) throws Exception { String deployPath = getVersionedAPIPath(String.format("apps/%s/versions/%s/create", appId.getApplication(), appId.getVersion()), appId.getNamespace()); return executeDeploy(HttpRequest.post(getEndPoint(deployPath).toURL()), appRequest); }
protected void deleteApp(ApplicationId app, int expectedResponseCode) throws Exception { HttpResponse response = doDelete(getVersionedAPIPath( String.format("/apps/%s/versions/%s", app.getApplication(), app.getVersion()), app.getNamespace())); Assert.assertEquals(expectedResponseCode, response.getResponseCode()); }
public void deleteApplication(ApplicationId appId) throws Exception { HttpRequest request = new DefaultHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.DELETE, String.format("%s/apps/%s/versions/%s", getNamespacePath(appId.getNamespace()), appId.getApplication(), appId.getVersion())); request.headers().set(Constants.Gateway.API_KEY, "api-key-example"); MockResponder mockResponder = new MockResponder(); appLifecycleHttpHandler.deleteApp(request, mockResponder, appId.getNamespace(), appId.getApplication()); verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Deleting app failed"); }