@Override public <Q, R> boolean addHandler(JobType<Q, R> jobType, Supplier<JobHandler<Q, R>> handlerSupplier) { checkNotNull(jobType, "jobType"); checkNotNull(handlerSupplier, "handlerSupplier"); RegistryEntry<?, ?> existing = _entries.put(jobType.getName(), new RegistryEntry<>(jobType, handlerSupplier)); return existing != null; }
@Override public <Q, R> boolean addHandler(JobType<Q, R> jobType, Supplier<JobHandler<Q, R>> handlerSupplier) { checkNotNull(jobType, "jobType"); checkNotNull(handlerSupplier, "handlerSupplier"); RegistryEntry<?, ?> existing = _entries.put(jobType.getName(), new RegistryEntry<>(jobType, handlerSupplier)); return existing != null; }
public static <Q, R> JobIdentifier<Q, R> fromString(String id, JobType<Q, R> jobType) { checkNotNull(id, "id"); checkNotNull(jobType, "jobType"); checkArgument(jobType.getName().equals(getJobTypeNameFromId(id)), "Inconsistent type"); return new JobIdentifier<>(id, jobType); }
public static <Q, R> JobIdentifier<Q, R> fromString(String id, JobType<Q, R> jobType) { checkNotNull(id, "id"); checkNotNull(jobType, "jobType"); checkArgument(jobType.getName().equals(getJobTypeNameFromId(id)), "Inconsistent type"); return new JobIdentifier<>(id, jobType); }
public static <Q, R> JobIdentifier<Q, R> createNew(JobType<Q, R> jobType) { checkNotNull(jobType, "jobType"); return new JobIdentifier<>(toId(jobType.getName(), UUID.randomUUID()), jobType); }
public static <Q, R> JobIdentifier<Q, R> createNew(JobType<Q, R> jobType) { checkNotNull(jobType, "jobType"); return new JobIdentifier<>(toId(jobType.getName(), UUID.randomUUID()), jobType); }
@Override public <Q, R> JobIdentifier<Q, R> submitJob(JobRequest<Q, R> jobRequest) { checkNotNull(jobRequest, "jobRequest"); JobType<Q, R> jobType = jobRequest.getType(); // Ensure there is a handler for this job type RegistryEntry<?, ?> entry = _jobHandlerRegistry.getRegistryEntry(jobType.getName()); if (entry == null) { throw new IllegalArgumentException("Cannot handle job of type " + jobType); } // Create a unique job identifier JobIdentifier<Q, R> jobId = createNew(jobType); // Store the job status as "submitted" JobStatus<Q, R> jobStatus = new JobStatus<>(JobStatus.Status.SUBMITTED, jobRequest.getRequest(), null, null); _jobStatusDAO.updateJobStatus(jobId, jobStatus); // Queue the job _queueService.send(_queueName, jobId.toString()); return jobId; }
@Override public <Q, R> JobIdentifier<Q, R> submitJob(JobRequest<Q, R> jobRequest) { checkNotNull(jobRequest, "jobRequest"); JobType<Q, R> jobType = jobRequest.getType(); // Ensure there is a handler for this job type RegistryEntry<?, ?> entry = _jobHandlerRegistry.getRegistryEntry(jobType.getName()); if (entry == null) { throw new IllegalArgumentException("Cannot handle job of type " + jobType); } // Create a unique job identifier JobIdentifier<Q, R> jobId = createNew(jobType); // Store the job status as "submitted" JobStatus<Q, R> jobStatus = new JobStatus<>(JobStatus.Status.SUBMITTED, jobRequest.getRequest(), null, null); _jobStatusDAO.updateJobStatus(jobId, jobStatus); // Queue the job _queueService.send(_queueName, jobId.toString()); return jobId; }