public String getName() { return scheduleId.getSchedule(); }
@Override public String getEntityName() { return getSchedule(); }
@Override public String getEntityName() { return getSchedule(); }
public String getName() { return scheduleId.getSchedule(); }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
@VisibleForTesting int getPartition(ScheduleId scheduleId) { // Similar to ScheduleId#hashCode, but that is not consistent across runtimes due to how Enum#hashCode works. // Ensure that the hash won't change across runtimes: int hash = Hashing.murmur3_32().newHasher() .putString(scheduleId.getNamespace()) .putString(scheduleId.getApplication()) .putString(scheduleId.getVersion()) .putString(scheduleId.getSchedule()) .hash().asInt(); return Math.abs(hash) % numPartitions; }
@VisibleForTesting int getPartition(ScheduleId scheduleId) { // Similar to ScheduleId#hashCode, but that is not consistent across runtimes due to how Enum#hashCode works. // Ensure that the hash won't change across runtimes: int hash = Hashing.murmur3_32().newHasher() .putString(scheduleId.getNamespace()) .putString(scheduleId.getApplication()) .putString(scheduleId.getVersion()) .putString(scheduleId.getSchedule()) .hash().asInt(); return Math.abs(hash) % numPartitions; }
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); } }
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); } }
/** * Delete an existing schedule. * * @param scheduleId the ID of the schedule to be deleted */ public void delete(ScheduleId scheduleId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/versions/%s/schedules/%s", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getNamespaceId(), path); HttpResponse response = restClient.execute(HttpMethod.DELETE, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } }
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"); }
private void doUpdate(ScheduleId scheduleId, String json) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException, AlreadyExistsException { String path = String.format("apps/%s/versions/%s/schedules/%s/update", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getNamespaceId(), path); HttpRequest request = HttpRequest.post(url).withBody(json).build(); HttpResponse response = restClient.execute(request, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } }
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 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 void enableSchedule(ScheduleId scheduleId) throws Exception { MockResponder responder = new MockResponder(); String uri = String.format("%s/apps/%s/versions/%s/program-type/schedules/program-id/%s/action/enable", getNamespacePath(scheduleId.getNamespace()), scheduleId.getVersion(), scheduleId.getApplication(), scheduleId.getSchedule()); FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri); HttpUtil.setContentLength(request, 0); programLifecycleHttpHandler.performAction(request, responder, scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), "schedules", scheduleId.getSchedule(), "enable"); verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Enable schedule failed"); }
public void deleteSchedule(ScheduleId scheduleId) throws Exception { MockResponder responder = new MockResponder(); ApplicationId application = scheduleId.getParent(); String uri = String.format("%s/apps/%s/versions/%s/schedules/%s", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, uri); programLifecycleHttpHandler.deleteSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Delete schedule failed"); } }
public void updateSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { MockResponder responder = new MockResponder(); ApplicationId application = scheduleId.getParent(); String uri = String.format("%s/apps/%s/versions/%s/schedules/%s/update", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri); request.content().writeCharSequence(GSON.toJson(scheduleDetail), StandardCharsets.UTF_8); HttpUtil.setContentLength(request, request.content().readableBytes()); programLifecycleHttpHandler.updateSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Update schedule failed"); }
public ScheduleDetail toScheduleDetail() { ScheduleProgramInfo programInfo = new ScheduleProgramInfo(schedule.getProgramId().getType().getSchedulableType(), schedule.getProgramId().getProgram()); ScheduleId scheduleId = schedule.getScheduleId(); return new ScheduleDetail(scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule(), schedule.getDescription(), programInfo, schedule.getProperties(), schedule.getTrigger(), schedule.getConstraints(), schedule.getTimeoutMillis(), meta.getStatus().name()); } }
public ScheduleDetail toScheduleDetail() { ScheduleProgramInfo programInfo = new ScheduleProgramInfo(schedule.getProgramId().getType().getSchedulableType(), schedule.getProgramId().getProgram()); ScheduleId scheduleId = schedule.getScheduleId(); return new ScheduleDetail(scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule(), schedule.getDescription(), programInfo, schedule.getProperties(), schedule.getTrigger(), schedule.getConstraints(), schedule.getTimeoutMillis(), meta.getStatus().name()); } }