/** * Returns the job status for the given job id. The job status includes things like where it's * deployed, and the status of the jobs where it's deployed, etc. * * @param id The job ID. * * @return The job status. */ @Path("{id}/status") @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<JobStatus> statusGet(@PathParam("id") @Valid final JobId id) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } return Optional.fromNullable(model.getJobStatus(id)); }
/** * Returns the current {@link Deployment} of {@code job} on {@code host} if it is deployed. * * @param host The host where the job is deployed. * @param jobId The ID of the job. * * @return The response. */ @GET @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<Deployment> jobGet(@PathParam("host") final String host, @PathParam("job") final JobId jobId) { if (!jobId.isFullyQualified()) { throw badRequest(); } return Optional.fromNullable(model.getDeployment(host, jobId)); }
@Path("/statuses") @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Map<JobId, JobStatus> jobStatuses(@Valid final Set<JobId> ids) { for (final JobId id : ids) { if (!id.isFullyQualified()) { throw badRequest("Invalid id " + id); } } final Map<JobId, JobStatus> results = Maps.newHashMap(); for (final JobId id : ids) { final JobStatus status = model.getJobStatus(id); if (status != null) { results.put(id, status); } } return results; } }
/** * Returns the {@link Job} with the given id. * * @param id The job ID. * * @return The job. */ @Path("{id}") @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<Job> get(@InjectParam @PathParam("id") @Valid final JobId id) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } return Optional.fromNullable(model.getJob(id)); }
/** * Returns the {@link TaskStatusEvents} for the specified job. * * @param jobId The ID of the job. * * @return The history of the jobs. * * @throws HeliosException If an unexpected error occurs. */ @GET @Produces(APPLICATION_JSON) @Path("jobs/{id}") @Timed @ExceptionMetered public TaskStatusEvents jobHistory(@PathParam("id") @Valid final JobId jobId) throws HeliosException { if (!jobId.isFullyQualified()) { throw badRequest("Invalid id"); } try { final List<TaskStatusEvent> events = model.getJobHistory(jobId); metrics.jobsHistoryEventSize(events.size()); final TaskStatusEvents result = new TaskStatusEvents(events, OK); return result; } catch (JobDoesNotExistException e) { return new TaskStatusEvents(ImmutableList.<TaskStatusEvent>of(), JOB_ID_NOT_FOUND); } } }
/** * Deletes the job specified by the given id. * * @param id The id of the job to delete. * @param token The optional authorization token. * * @return The response. */ @Path("{id}") @DELETE @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public JobDeleteResponse delete(@PathParam("id") @Valid final JobId id, @QueryParam("token") @DefaultValue("") final String token) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } try { model.removeJob(id, token); return new JobDeleteResponse(JobDeleteResponse.Status.OK); } catch (JobDoesNotExistException e) { throw notFound(new JobDeleteResponse(JobDeleteResponse.Status.JOB_NOT_FOUND)); } catch (JobStillDeployedException e) { throw badRequest(new JobDeleteResponse(JobDeleteResponse.Status.STILL_IN_USE)); } catch (TokenVerificationException e) { throw forbidden(new JobDeleteResponse(JobDeleteResponse.Status.FORBIDDEN)); } }
@PathParam("job") final JobId jobId, @QueryParam("token") @DefaultValue("") final String token) { if (!jobId.isFullyQualified()) { throw badRequest(new JobUndeployResponse(INVALID_ID, host, jobId));
@RequestUser final String username, @QueryParam("token") @DefaultValue(EMPTY_TOKEN) final String token) { if (!jobId.isFullyQualified()) { throw badRequest(new JobDeployResponse(JobDeployResponse.Status.INVALID_ID, host, jobId));
/** * Returns the job status for the given job id. The job status includes things like where it's * deployed, and the status of the jobs where it's deployed, etc. * * @param id The job ID. * @return The job status. */ @Path("{id}/status") @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<JobStatus> statusGet(@PathParam("id") @Valid final JobId id) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } return Optional.fromNullable(model.getJobStatus(id)); }
/** * Returns the current {@link Deployment} of {@code job} on {@code host} if it is deployed. * @param host The host where the job is deployed. * @param jobId The ID of the job. * @return The response. */ @GET @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<Deployment> jobGet(@PathParam("host") final String host, @PathParam("job") final JobId jobId) { if (!jobId.isFullyQualified()) { throw badRequest(); } return Optional.fromNullable(model.getDeployment(host, jobId)); } }
/** * Returns the {@link Job} with the given id. * * @param id The job ID. * @return The job. */ @Path("{id}") @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Optional<Job> get(@InjectParam @PathParam("id") @Valid final JobId id) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } return Optional.fromNullable(model.getJob(id)); }
@Path("/statuses") @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Map<JobId, JobStatus> jobStatuses(@Valid final Set<JobId> ids) { for (final JobId id : ids) { if (!id.isFullyQualified()) { throw badRequest("Invalid id " + id); } } final Map<JobId, JobStatus> results = Maps.newHashMap(); for (final JobId id : ids) { final JobStatus status = model.getJobStatus(id); if (status != null) { results.put(id, status); } } return results; } }
/** * Returns the {@link TaskStatusEvents} for the specified job. * @param jobId The ID of the job. * @return The history of the jobs. * @throws HeliosException If an unexpected error occurs. */ @GET @Produces(APPLICATION_JSON) @Path("jobs/{id}") @Timed @ExceptionMetered public TaskStatusEvents jobHistory(@PathParam("id") @Valid final JobId jobId) throws HeliosException { if (!jobId.isFullyQualified()) { throw badRequest("Invalid id"); } try { final List<TaskStatusEvent> events = model.getJobHistory(jobId); metrics.jobsHistoryEventSize(events.size()); final TaskStatusEvents result = new TaskStatusEvents(events, OK); return result; } catch (JobDoesNotExistException e) { return new TaskStatusEvents(ImmutableList.<TaskStatusEvent>of(), JOB_ID_NOT_FOUND); } } }
/** * Deletes the job specified by the given id. * * @param id The id of the job to delete. * @param token The optional authorization token. * @return The response. */ @Path("{id}") @DELETE @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public JobDeleteResponse delete(@PathParam("id") @Valid final JobId id, @QueryParam("token") @DefaultValue("") final String token) { if (!id.isFullyQualified()) { throw badRequest("Invalid id"); } try { model.removeJob(id, token); return new JobDeleteResponse(JobDeleteResponse.Status.OK); } catch (JobDoesNotExistException e) { throw notFound(new JobDeleteResponse(JobDeleteResponse.Status.JOB_NOT_FOUND)); } catch (JobStillDeployedException e) { throw badRequest(new JobDeleteResponse(JobDeleteResponse.Status.STILL_IN_USE)); } catch (TokenVerificationException e) { throw forbidden(new JobDeleteResponse(JobDeleteResponse.Status.FORBIDDEN)); } }
/** * Causes the job identified by its {@link JobId} to be undeployed from the specified host. * This call will fail if the host is not found or the job is not deployed on the host. * @param host The host to undeploy from. * @param jobId The job to undeploy. * @param token The authorization token. * @return The response. */ @DELETE @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public JobUndeployResponse jobDelete(@PathParam("host") final String host, @PathParam("job") final JobId jobId, @QueryParam("token") @DefaultValue("") final String token) { if (!jobId.isFullyQualified()) { throw badRequest(new JobUndeployResponse(INVALID_ID, host, jobId)); } try { model.undeployJob(host, jobId, token); return new JobUndeployResponse(OK, host, jobId); } catch (HostNotFoundException e) { throw notFound(new JobUndeployResponse(HOST_NOT_FOUND, host, jobId)); } catch (JobNotDeployedException e) { throw notFound(new JobUndeployResponse(JOB_NOT_FOUND, host, jobId)); } catch (TokenVerificationException e) { throw forbidden(new JobUndeployResponse(FORBIDDEN, host, jobId)); } }
@RequestUser final String username, @QueryParam("token") @DefaultValue("") final String token) { if (!jobId.isFullyQualified()) { throw badRequest(new JobDeployResponse(JobDeployResponse.Status.INVALID_ID, host, jobId));