/** * Lists programs of a type belonging to an application. * * @param app the application * @return Map of {@link ProgramType} to list of {@link ProgramRecord}s * @throws ApplicationNotFoundException if the application with the given ID was not found * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public Map<ProgramType, List<ProgramRecord>> listProgramsByType(ApplicationId app) throws ApplicationNotFoundException, IOException, UnauthenticatedException, UnauthorizedException { Map<ProgramType, List<ProgramRecord>> result = Maps.newHashMap(); for (ProgramType type : ProgramType.values()) { result.put(type, Lists.<ProgramRecord>newArrayList()); } for (ProgramRecord program : listPrograms(app)) { result.get(program.getType()).add(program); } return result; }
@Override public EntityId apply(ProgramRecord input) { return appId.program(input.getType(), input.getName()); } }, null);
@Override public EntityId apply(ProgramRecord input) { return appId.program(input.getType(), input.getName()); } }, null);
@Override public List<?> makeRow(ProgramRecord object) { return Lists.newArrayList(object.getType().getPrettyName(), object.getName(), object.getDescription()); } }).build();
@Override public List<?> makeRow(ProgramRecord object) { return Lists.newArrayList(object.getType().getPrettyName(), object.getName(), object.getDescription()); } }).build();
@Override public List<?> makeRow(ProgramRecord object) { return Lists.newArrayList(object.getType().getCategoryName(), object.getApp(), object.getName(), object.getDescription()); } }).build();
@Override protected BatchProgram createProgram(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override public List<?> makeRow(ProgramRecord object) { return Lists.newArrayList(object.getType().getCategoryName(), object.getApp(), object.getName(), object.getDescription()); } }).build();
@Override protected BatchProgramStart createProgram(ProgramRecord programRecord) { return new BatchProgramStart(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgramStart createProgram(ProgramRecord programRecord) { return new BatchProgramStart(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgram createProgram(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgram createProgram(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgramStart createProgram(ProgramRecord programRecord) { return new BatchProgramStart(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgram createProgram(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override protected BatchProgramStart createProgram(ProgramRecord programRecord) { return new BatchProgramStart(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
public static BatchProgram from(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
public static BatchProgram from(ProgramRecord programRecord) { return new BatchProgram(programRecord.getApp(), programRecord.getType(), programRecord.getName()); }
@Override public void stopAll() { try { for (ProgramRecord programRecord : applicationClient.listPrograms(application)) { // have to do a check, since appFabricServer.stop will throw error when you stop something that is not running. ProgramId programId = application.program(programRecord.getType(), programRecord.getName()); if (!isStopped(programId)) { programClient.stop(programId); } waitForStopped(programId); } } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public ProgramId apply(ProgramRecord input) { return appId.program(input.getType(), input.getName()); }})));
private void verifyProgramList(String namespace, String appName, final ProgramType programType, int expected) throws Exception { HttpResponse response = requestAppDetail(namespace, appName); Assert.assertEquals(200, response.getResponseCode()); ApplicationDetail appDetail = GSON.fromJson(response.getResponseBodyAsString(), ApplicationDetail.class); Collection<ProgramRecord> programs = Collections2.filter( appDetail.getPrograms(), record -> programType.getCategoryName().equals(record.getType().getCategoryName())); Assert.assertEquals(expected, programs.size()); }