public ScheduleDetail toScheduleDetail() { ScheduleProgramInfo programInfo = new ScheduleProgramInfo(programId.getType().getSchedulableType(), programId.getProgram()); return new ScheduleDetail(scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule(), description, programInfo, properties, trigger, constraints, timeoutMillis, null); } }
public String getStatus(ScheduleId scheduleId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/versions/%s/schedules/%s/status", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getParent().getParent(), path); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } Map<String, String> responseObject = ObjectResponse.<Map<String, String>>fromJsonBody(response, MAP_STRING_STRING_TYPE, GSON).getResponseObject(); return responseObject.get("status"); }
public ScheduleId schedule(String schedule) { return new ScheduleId(this, schedule); }
@SuppressWarnings("unused") public static ScheduleId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ScheduleId( next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version"), nextAndEnd(iterator, "schedule")); }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
public void resume(ScheduleId scheduleId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/versions/%s/schedules/%s/resume", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getNamespaceId(), path); HttpResponse response = restClient.execute(HttpMethod.POST, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } }
Assert.assertEquals(ProgramScheduleStatus.SUSPENDED.name(), scheduleManager.status(HttpURLConnection.HTTP_OK)); ScheduleId scheduleId = new ScheduleId(appId.getNamespace(), appId.getApplication(), appId.getVersion(), "testSchedule"); ScheduleDetail scheduleDetail = workflowManager.getSchedule(scheduleId.getSchedule()).status(HttpURLConnection.HTTP_OK)); workflowManager.getSchedule(scheduleId.getSchedule()).status(HttpURLConnection.HTTP_OK)); workflowManager.getSchedule(scheduleId.getSchedule()).status(HttpURLConnection.HTTP_NOT_FOUND);
@Override public String getEntityName() { return getSchedule(); }
@Override public void addSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { appFabricClient.addSchedule(scheduleId.getParent(), scheduleDetail); }
return false; return scheduleId2.equals(job.getJobKey().getScheduleId()) && job.getState() == Job.State.PENDING_TRIGGER; scheduler.deleteSchedule(scheduleId2); scheduler.addSchedule(updatedSchedule); enableSchedule(scheduleId2.getSchedule()); } else { Assert.fail("invalid howToUpdate: " + howToUpdate); return false; return scheduleId2.equals(job.getJobKey().getScheduleId()) && job.getState() == Job.State.PENDING_TRIGGER; }));
private void collectScheduleProfileMetadata(ProgramSchedule schedule, ProfileId programProfile, Map<MetadataEntity, Map<String, String>> updates) { ScheduleId scheduleId = schedule.getScheduleId(); LOG.trace("Updating profile metadata for {}", scheduleId); // if we are able to get profile from preferences or schedule properties, use it // otherwise default profile will be used Optional<ProfileId> scheduleProfileId = SystemArguments.getProfileIdFromArgs(scheduleId.getNamespaceId(), schedule.getProperties()); programProfile = scheduleProfileId.orElse(programProfile); addProfileMetadataUpdate(scheduleId, programProfile, updates); }
/** * Remove the profile metadata according to the message, currently only meant for application and schedule. */ private void removeProfileMetadata(MetadataMessage message) { EntityId entity = message.getEntityId(); Map<MetadataEntity, Set<String>> toRemove = new HashMap<>(); // We only care about application and schedules. if (entity.getEntityType().equals(EntityType.APPLICATION)) { ApplicationId appId = (ApplicationId) message.getEntityId(); ApplicationSpecification appSpec = message.getPayload(GSON, ApplicationSpecification.class); for (ProgramId programId : getAllProfileAllowedPrograms(appSpec, appId)) { toRemove.put(programId.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } for (ScheduleId scheduleId : getSchedulesInApp(appId, appSpec.getProgramSchedules())) { toRemove.put(scheduleId.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } } else if (entity.getEntityType().equals(EntityType.SCHEDULE)) { toRemove.put(entity.toMetadataEntity(), PROFILE_METADATA_KEY_SET); } if (!toRemove.isEmpty()) { metadataStore.removeProperties(MetadataScope.SYSTEM, toRemove); } }
public void suspend(ScheduleId scheduleId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/versions/%s/schedules/%s/suspend", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getNamespaceId(), path); HttpResponse response = restClient.execute(HttpMethod.POST, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
public String getName() { return scheduleId.getSchedule(); }
@Override public void addSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { appFabricClient.addSchedule(scheduleId.getParent(), scheduleDetail); }
@SuppressWarnings("unused") public static ScheduleId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ScheduleId( next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version"), nextAndEnd(iterator, "schedule")); }
private void updateScheduleProfileMetadata(ProgramSchedule schedule, ProfileId profileId) { ScheduleId scheduleId = schedule.getScheduleId(); Optional<ProfileId> scheduleProfileId = SystemArguments.getProfileIdFromArgs(scheduleId.getNamespaceId(), schedule.getProperties()); profileId = scheduleProfileId.orElse(profileId); setProfileMetadata(scheduleId, profileId); }
/** * Remove the profile metadata according to the message, currently only meant for application and schedule. */ private void removeProfileMetadata(MetadataMessage message) { EntityId entity = message.getEntityId(); // We only care about application and schedules. if (entity.getEntityType().equals(EntityType.APPLICATION)) { ApplicationId appId = (ApplicationId) message.getEntityId(); ApplicationSpecification appSpec = message.getPayload(GSON, ApplicationSpecification.class); for (ProgramId programId : getProgramsWithType(appId, ProgramType.WORKFLOW, appSpec.getWorkflows())) { metadataDataset.removeProperties(programId.toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } for (ScheduleId scheduleId : getSchedulesInApp(appId, appSpec.getProgramSchedules())) { metadataDataset.removeProperties(scheduleId.toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } } if (entity.getEntityType().equals(EntityType.SCHEDULE)) { metadataDataset.removeProperties(message.getEntityId().toMetadataEntity(), Collections.singleton(PROFILE_METADATA_KEY)); } }
public ScheduleDetail toScheduleDetail() { ScheduleProgramInfo programInfo = new ScheduleProgramInfo(programId.getType().getSchedulableType(), programId.getProgram()); return new ScheduleDetail(scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule(), description, programInfo, properties, trigger, constraints, timeoutMillis, null); } }