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

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

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

Job.getJobType介绍

[英]Gets the job type, which determines the type of service that runs the job.
[中]获取作业类型,该类型确定运行该作业的服务的类型。

代码示例

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

/**
 * Record an incident for a given job. This method is intended to record client incidents, i.e. incidents crafted by
 * the programmer.
 *
 * @param code
 *          A code number. This incident factory method enforces an incident code schema of <code>job_type.code</code>
 *          , e.g. <code>org.opencastproject.service.1511</code> . So instead of aligning
 *          <code>job.getJobType()</code> and the incident's code prefix manually this is done automatically for you
 *          by this method. See {@link org.opencastproject.job.api.Incident#getCode()}.
 * @see org.opencastproject.job.api.Incident
 */
public void record(Job job, Severity severity, int code, Map<String, String> params,
    List<Tuple<String, String>> details) {
 try {
  is.storeIncident(job, new Date(), job.getJobType() + "." + code, severity, params, details);
 } catch (IncidentServiceException e) {
  logException(e);
 }
}

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

/**
 * {@inheritDoc}
 *
 * @see org.opencastproject.serviceregistry.api.ServiceRegistry#getJobs(java.lang.String,
 *      org.opencastproject.job.api.Job.Status)
 */
@Override
public List<Job> getJobs(String serviceType, Status status) throws ServiceRegistryException {
 List<Job> result = new ArrayList<Job>();
 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.equals(job.getJobType()) && status.equals(job.getStatus()))
    result.add(job);
  }
 }
 return result;
}

代码示例来源: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

if (!jobType.equals(job.getJobType())) {
 logger.debug("Invalid job type submitted: {}", job.getJobType());
 return false;
 logger.warn(
     "{} Accepting job {} of type {} with load {} even though load of {} is above this node's limit of {}.",
     Thread.currentThread().getId(), job.getId(), job.getJobType(), df.format(job.getJobLoad()),
     df.format(currentLoad), df.format(maxload.getLoadFactor()));
 logger.warn("This is a configuration issue that you should resolve in a production system!");
 logger.debug(
     "{} Declining job {} of type {} with load {} because load of {} would exceed this node's limit of {}.",
     Thread.currentThread().getId(), job.getId(), job.getJobType(), df.format(job.getJobLoad()),
     df.format(currentLoad), df.format(maxload.getLoadFactor()));
 return false;
} else  {
 logger.debug("{} Accepting job {} of type {} with load {} because load of {} is within this node's limit of {}.",
     Thread.currentThread().getId(), job.getId(), job.getJobType(), df.format(job.getJobLoad()),
     df.format(currentLoad), df.format(maxload.getLoadFactor()));
 return true;

代码示例来源: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

List<ServiceRegistration> registrations = getServiceRegistrationsByLoad(job.getJobType());
if (registrations.size() == 0)
 throw new ServiceUnavailableException("No service is available to handle jobs of type '" + job.getJobType() + "'");
job.setStatus(Status.DISPATCHING);
try {

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

@Override
public Job updateJob(Job job) throws ServiceRegistryException {
 JpaJob jpaJob = JpaJob.from(job);
 jpaJob.setProcessorServiceRegistration(
     (ServiceRegistrationJpaImpl) getServiceRegistration(job.getJobType(), job.getProcessingHost()));
 return updateJob(jpaJob).toJob();
}

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

private static Incident toIncident(Job job, IncidentDto dto) {
 return new IncidentImpl(dto.getId(), job.getId(), job.getJobType(), job.getProcessingHost(), dto.getTimestamp(),
     dto.getSeverity(), dto.getCode(), dto.getTechnicalInformation(), dto.getParameters());
}

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

job.getJobType(), job.getProcessingHost());
fromDb.setProcessorServiceRegistration(processingService);

代码示例来源: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;
}

相关文章