private static SchedulerServiceException checked(String message, Throwable e) { return new SchedulerServiceException(message, e); }
@Override synchronized public final void start() throws SchedulerServiceException { LOG.debug("{} -> STARTED", state); switch (state) { case STARTED: return; case SHUTDOWN: throw new SchedulerServiceException("The scheduler service has been shut down; it cannot be restarted."); } startImpl(); state = State.STARTED; }
private JobId generateUniqueJobId() throws SchedulerServiceException { for (int i = 0; i < MAX_ATTEMPTS; ++i) { final JobId jobId = JobId.of(UUID.randomUUID().toString()); if (getJobDetails(jobId) == null) { return jobId; } } throw new SchedulerServiceException("Unable to generate a unique job ID"); }
/** * Converts the unchecked {@code SchedulerRuntimeException} to the checked * {@code SchedulerServiceException}. It makes sense to do this in many cases * where the checked exception is declared, as the caller is already having to * handle it. * <p> * The message and cause of the {@code SchedulerServiceException} are taken from * the {@link Throwable#getCause() cause} of the runtime exception. If no cause * was set, then the runtime exception itself is used. * </p> * * @param sre the scheduler runtime exception to convert * @return the converted exception */ protected static SchedulerServiceException checked(SchedulerRuntimeException sre) { Throwable cause = sre.getCause(); if (cause == null) { cause = sre; } return new SchedulerServiceException(cause.toString(), cause); }
throw new SchedulerServiceException("Serialization failed", ioe);
@Override synchronized public final void standby() throws SchedulerServiceException { LOG.debug("{} -> STANDBY", state); switch (state) { case STANDBY: return; case SHUTDOWN: throw new SchedulerServiceException("The scheduler service has been shut down; it cannot be restarted."); } cancelJobs(); standbyImpl(); state = State.STANDBY; }