org.opencastproject.job.api.Job.getOperation()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.opencastproject.job.api.Job.getOperation()方法的一些代码示例,展示了Job.getOperation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.getOperation()方法的具体详情如下:
包路径:org.opencastproject.job.api.Job
类名称:Job
方法名:getOperation

Job.getOperation介绍

[英]The operation type, which can be used by the service responsible for the job to determine the service method to execute.
[中]操作类型,负责作业的服务可以使用它来确定要执行的服务方法。

代码示例

代码示例来源:origin: opencast/opencast

@Override
public List<String> getJobPayloads(String operation) throws ServiceRegistryException {
 List<String> result = new ArrayList<>();
 for (String serializedJob : jobs.values()) {
  try {
   Job job = JobParser.parseJob(serializedJob);
   if (operation.equals(job.getOperation())) {
    result.add(job.getPayload());
   }
  } catch (IOException e) {
   throw new IllegalStateException("Error unmarshaling job", e);
  }
 }
 return result;
}

代码示例来源:origin: opencast/opencast

if (START_OPERATION.equals(job.getOperation()) || START_WORKFLOW.equals(job.getOperation())
    || RESUME.equals(job.getOperation()))
 continue;

代码示例来源:origin: opencast/opencast

protected String process(Job job) throws Exception {
 logger.debug("Started processing job {}", job.getId());
 if (!OPERATION.equals(job.getOperation())) {
  throw new ServiceRegistryException(String.format("This service can't handle operations of type '%s'",
      job.getOperation()));

代码示例来源:origin: opencast/opencast

private void handleFailedProcessing(final Throwable t) throws Exception {
 if (t instanceof JobCanceledException) {
  logger.info(t.getMessage());
 } else {
  Job jobAfterProcessing = getServiceRegistry().getJob(jobId);
  jobAfterProcessing.setStatus(Status.FAILED);
  jobAfterProcessing = getServiceRegistry().updateJob(jobAfterProcessing);
  getServiceRegistry().incident().unhandledException(jobAfterProcessing, Severity.FAILURE, t);
  logger.error("Error handling operation '{}': {}", jobAfterProcessing.getOperation(), getStackTrace(t));
  if (t instanceof ServiceRegistryException)
   throw (ServiceRegistryException) t;
 }
}

代码示例来源:origin: opencast/opencast

/**
 * {@inheritDoc}
 *
 * @see org.opencastproject.serviceregistry.api.ServiceRegistry#count(java.lang.String, java.lang.String,
 *      java.lang.String, org.opencastproject.job.api.Job.Status)
 */
@Override
public long count(String serviceType, String host, String operation, Status status) throws ServiceRegistryException {
 int count = 0;
 synchronized (jobs) {
  for (String serializedJob : jobs.values()) {
   Job job = null;
   try {
    job = JobParser.parseJob(serializedJob);
   } catch (IOException e) {
    throw new IllegalStateException("Error unmarshaling job", e);
   }
   if (serviceType != null && !serviceType.equals(job.getJobType()))
    continue;
   if (host != null && !host.equals(job.getProcessingHost()))
    continue;
   if (operation != null && !operation.equals(job.getOperation()))
    continue;
   if (status != null && !status.equals(job.getStatus()))
    continue;
   count++;
  }
 }
 return count;
}

代码示例来源:origin: opencast/opencast

/**
 * {@inheritDoc}
 *
 * @see org.opencastproject.job.api.AbstractJobProducer#process(org.opencastproject.job.api.Job)
 */
@Override
protected String process(Job job) throws Exception {
 Operation op = null;
 String operation = job.getOperation();
 List<String> arguments = job.getArguments();
 try {
  op = Operation.valueOf(operation);
  switch (op) {
   case Waveform:
    Track track = (Track) MediaPackageElementParser.getFromXml(arguments.get(0));
    int pixelsPerMinute = Integer.parseInt(arguments.get(1));
    int minWidth = Integer.parseInt(arguments.get(2));
    int maxWidth = Integer.parseInt(arguments.get(3));
    int height = Integer.parseInt(arguments.get(4));
    Attachment waveformMpe = extractWaveform(track, pixelsPerMinute, minWidth, maxWidth, height);
    return MediaPackageElementParser.getAsXml(waveformMpe);
   default:
    throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'");
  }
 } catch (IndexOutOfBoundsException e) {
  throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e);
 } catch (MediaPackageException | WaveformServiceException e) {
  throw new ServiceRegistryException("Error handling operation '" + op + "'", e);
 }
}

代码示例来源:origin: opencast/opencast

/**
 * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by
 * the job system itself, e.g. the job dispatcher.
 */
private void unhandledException(Job job, String code, Severity severity, Throwable t) {
 if (!alreadyRecordedFailureIncident(job.getId())) {
  try {
   is.storeIncident(
       job,
       new Date(),
       code,
       severity,
       Collections.singletonMap("exception", ExceptionUtils.getMessage(t)),
       Arrays.asList(tuple("job-type", job.getJobType()), tuple("job-operation", job.getOperation()),
           tuple("stack-trace", ExceptionUtils.getStackTrace(t))));
  } catch (IncidentServiceException e) {
   logException(e);
  }
 }
}

代码示例来源:origin: opencast/opencast

protected String process(Job job) throws Exception {
 Operation op = null;
 String operation = job.getOperation();
 List<String> arguments = job.getArguments();
 try {

代码示例来源:origin: opencast/opencast

/**
 * {@inheritDoc}
 *
 * @see org.opencastproject.job.api.AbstractJobProducer#process(org.opencastproject.job.api.Job)
 */
@Override
protected String process(Job job) throws Exception {
 Operation op = null;
 String operation = job.getOperation();
 List<String> arguments = job.getArguments();
 try {
  op = Operation.valueOf(operation);
  switch (op) {
   case TimelinePreview:
    Track track = (Track) MediaPackageElementParser
     .getFromXml(arguments.get(0));
    int imageCount = Integer.parseInt(arguments.get(1));
    Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount);
    return MediaPackageElementParser.getAsXml(timelinePreviewsMpe);
   default:
    throw new IllegalStateException("Don't know how to handle operation '" + operation + "'");
  }
 } catch (IllegalArgumentException e) {
  throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e);
 } catch (IndexOutOfBoundsException e) {
  throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e);
 } catch (Exception e) {
  throw new ServiceRegistryException("Error handling operation '" + op + "'", e);
 }
}

代码示例来源:origin: opencast/opencast

@Override
public IncidentTree getIncidentsOfJob(long jobId, boolean cascade) throws NotFoundException, IncidentServiceException {
 List<Incident> incidents = getIncidentsOfJob(jobId);
 List<IncidentTree> childIncidents = new ArrayList<IncidentTree>();
 try {
  Job job = getServiceRegistry().getJob(jobId);
  if (cascade && !"START_WORKFLOW".equals(job.getOperation())) {
   childIncidents = getChildIncidents(jobId);
  } else if (cascade && "START_WORKFLOW".equals(job.getOperation())) {
   for (WorkflowOperationInstance operation : getWorkflowService().getWorkflowById(jobId).getOperations()) {
    if (operation.getState().equals(OperationState.INSTANTIATED))
     continue;
    IncidentTree operationResult = getIncidentsOfJob(operation.getId(), true);
    if (hasIncidents(Collections.list(operationResult)))
     childIncidents.add(operationResult);
   }
  }
  return new IncidentTreeImpl(incidents, childIncidents);
 } catch (NotFoundException ignore) {
  // Workflow deleted
  return new IncidentTreeImpl(incidents, childIncidents);
 } catch (Exception e) {
  logger.error("Error loading child jobs of {}: {}", jobId);
  throw new IncidentServiceException(e);
 }
}

代码示例来源:origin: opencast/opencast

jobHosts.put(inMemoryRegistration, jobs);
if (!service.isReadyToAcceptJobs(job.getOperation())) {
 jobs.remove(job);
 jobHosts.put(inMemoryRegistration, jobs);

代码示例来源:origin: opencast/opencast

protected String process(Job job) throws Exception {
 Operation op = null;
 String operation = job.getOperation();
 List<String> arguments = job.getArguments();
 try {

代码示例来源:origin: opencast/opencast

fromDb.setDispatchable(job.isDispatchable());
fromDb.setVersion(job.getVersion());
fromDb.setOperation(job.getOperation());
fromDb.setArguments(job.getArguments());
fromDb.setBlockedJobIds(job.getBlockedJobIds());

代码示例来源:origin: opencast/opencast

public JaxbJob(Job job) {
 this();
 this.id = job.getId();
 this.dateCompleted = job.getDateCompleted();
 this.dateCreated = job.getDateCreated();
 this.dateStarted = job.getDateStarted();
 this.queueTime = job.getQueueTime();
 this.runTime = job.getRunTime();
 this.version = job.getVersion();
 this.payload = job.getPayload();
 this.processingHost = job.getProcessingHost();
 this.createdHost = job.getCreatedHost();
 this.id = job.getId();
 this.jobType = job.getJobType();
 this.operation = job.getOperation();
 if (job.getArguments() != null)
  this.arguments = unmodifiableList(job.getArguments());
 this.status = job.getStatus();
 this.parentJobId = job.getParentJobId();
 this.rootJobId = job.getRootJobId();
 this.dispatchable = job.isDispatchable();
 this.uri = job.getUri();
 this.creator = job.getCreator();
 this.organization = job.getOrganization();
 this.jobLoad = job.getJobLoad();
 if (job.getBlockedJobIds() != null)
  this.blockedJobIds = unmodifiableList(job.getBlockedJobIds());
 this.blockingJobId = job.getBlockingJobId();
}

代码示例来源:origin: opencast/opencast

public static JpaJob from(Job job) {
 JpaJob newJob = new JpaJob();
 newJob.id = job.getId();
 newJob.dateCompleted = job.getDateCompleted();
 newJob.dateCreated = job.getDateCreated();
 newJob.dateStarted = job.getDateStarted();
 newJob.queueTime = job.getQueueTime();
 newJob.runTime = job.getRunTime();
 newJob.version = job.getVersion();
 newJob.payload = job.getPayload();
 newJob.jobType = job.getJobType();
 newJob.operation = job.getOperation();
 newJob.arguments = job.getArguments();
 newJob.status = job.getStatus().ordinal();
 newJob.parentJobId = job.getParentJobId();
 newJob.rootJobId = job.getRootJobId();
 newJob.dispatchable = job.isDispatchable();
 newJob.uri = job.getUri();
 newJob.creator = job.getCreator();
 newJob.organization = job.getOrganization();
 newJob.jobLoad = job.getJobLoad();
 newJob.blockedJobIds = job.getBlockedJobIds();
 newJob.blockingJobId = job.getBlockingJobId();
 return newJob;
}

相关文章