@Override protected Map<String, String> addAdditionalSecurityHeaders() { Map<String, String> headers = new HashMap<>(super.addAdditionalSecurityHeaders()); headers.put(Constants.Security.Headers.PROGRAM_ID, programId.toString()); return headers; } }
@Override protected Map<String, String> addAdditionalSecurityHeaders() { Map<String, String> headers = new HashMap<>(super.addAdditionalSecurityHeaders()); headers.put(Constants.Security.Headers.PROGRAM_ID, programId.toString()); return headers; } }
public static String triggerKeyForProgramStatus(ProgramId programId, ProgramStatus programStatus) { return "programStatus:" + programId.toString() + "." + programStatus.toString().toLowerCase(); }
public static String triggerKeyForProgramStatus(ProgramId programId, ProgramStatus programStatus) { return "programStatus:" + programId.toString() + "." + programStatus.toString().toLowerCase(); }
/** * Get schedules that are triggered by the given program statuses. * * @param programId the program that is in the trigger * @param statusSet statuses that are involved in the trigger * @return schedules triggered by the given program statuses * @throws UnauthorizedException if the principal is not authorized to access the application * @throws Exception if any other errors occurred while performing the authorization enforcement check */ public Collection<ProgramScheduleRecord> findTriggeredBy(ProgramId programId, Set<ProgramStatus> statusSet) throws Exception { AuthorizationUtil.ensureAccess(programId, authorizationEnforcer, authenticationContext.getPrincipal()); Set<ProgramScheduleRecord> schedules = new HashSet<>(); scheduler.findSchedules(programId.toString()); for (String triggerKey : Schedulers.triggerKeysForProgramStatuses(programId, statusSet)) { schedules.addAll(scheduler.findSchedules(triggerKey)); } return schedules; }
/** * Get schedules that are triggered by the given program statuses. * * @param programId the program that is in the trigger * @param statusSet statuses that are involved in the trigger * @return schedules triggered by the given program statuses * @throws UnauthorizedException if the principal is not authorized to access the application * @throws Exception if any other errors occurred while performing the authorization enforcement check */ public Collection<ProgramScheduleRecord> findTriggeredBy(ProgramId programId, Set<ProgramStatus> statusSet) throws Exception { AuthorizationUtil.ensureAccess(programId, authorizationEnforcer, authenticationContext.getPrincipal()); Set<ProgramScheduleRecord> schedules = new HashSet<>(); scheduler.findSchedules(programId.toString()); for (String triggerKey : Schedulers.triggerKeysForProgramStatuses(programId, statusSet)) { schedules.addAll(scheduler.findSchedules(triggerKey)); } return schedules; }
ProgramStatus status = lifecycleService.getProgramStatus(programId); if (status == ProgramStatus.STOPPED) { throw new ServiceUnavailableException(programId.toString(), "Service is stopped. Please start it."); if (endpointStrategy.pick(300L, TimeUnit.MILLISECONDS) == null) { LOG.trace("Discoverable endpoint {} not found", discoverableName); throw new ServiceUnavailableException(programId.toString(), "Service is running but not accepting requests at this time.");
ProgramStatus status = lifecycleService.getProgramStatus(programId); if (status == ProgramStatus.STOPPED) { throw new ServiceUnavailableException(programId.toString(), "Service is stopped. Please start it."); if (strategy.pick(300L, TimeUnit.MILLISECONDS) == null) { LOG.trace("Discoverable endpoint {} not found", discoverableName); throw new ServiceUnavailableException(programId.toString(), "Service is running but not accepting requests at this time.");
"used to start the program %s", profileId.getProfile(), profileId.getNamespace(), programId.toString()), profileId);
"used to start the program %s", profileId.getProfile(), profileId.getNamespace(), programId.toString()), profileId);
/** * Checks if a user service is available by hitting the availability endpoint. */ private void checkAvailability() throws IOException, UnauthenticatedException, NotFoundException { URL url = clientConfig.resolveNamespacedURLV3(programId.getNamespaceId(), String.format("apps/%s/versions/%s/%s/%s/available", programId.getApplication(), programId.getVersion(), programId.getType().getCategoryName(), programId.getProgram())); HttpResponse response = restClient.execute(HttpMethod.GET, url, clientConfig.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_BAD_REQUEST, HttpURLConnection.HTTP_UNAVAILABLE); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NotFoundException(programId); } if (response.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) { throw new ServiceUnavailableException(programId.toString()); } } }
String.format("Must update the schedule '%s' with the same program as '%s'. " + "To change the program in a schedule, please delete the schedule and create a new one.", existing.getName(), existing.getProgramId().toString()));
String.format("Must update the schedule '%s' with the same program as '%s'. " + "To change the program in a schedule, please delete the schedule and create a new one.", existing.getName(), existing.getProgramId().toString()));