本文整理了Java中org.opencastproject.job.api.Job.getStatus()
方法的一些代码示例,展示了Job.getStatus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.getStatus()
方法的具体详情如下:
包路径:org.opencastproject.job.api.Job
类名称:Job
方法名:getStatus
[英]Gets the receipt's current Status
[中]获取收据的当前状态
代码示例来源:origin: opencast/opencast
/**
* Returns <code>true</code> if the job is ready to be dispatched.
*
* @param job
* the job
* @return <code>true</code> whether the job is ready to be dispatched
* @throws IllegalStateException
* if the job status is unknown
*/
public static boolean isReadyToDispatch(Job job) throws IllegalStateException {
switch (job.getStatus()) {
case CANCELED:
case DELETED:
case FAILED:
case FINISHED:
return false;
case DISPATCHING:
case INSTANTIATED:
case PAUSED:
case QUEUED:
case RESTART:
case RUNNING:
case WAITING:
return true;
default:
throw new IllegalStateException("Found job in unknown state '" + job.getStatus() + "'");
}
}
代码示例来源:origin: opencast/opencast
/** Shuts down this service registry, logging all jobs and their statuses. */
public void deactivate() {
dispatcher.shutdownNow();
Map<Status, AtomicInteger> counts = new HashMap<Job.Status, AtomicInteger>();
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 (counts.containsKey(job.getStatus())) {
counts.get(job.getStatus()).incrementAndGet();
} else {
counts.put(job.getStatus(), new AtomicInteger(1));
}
}
}
StringBuilder sb = new StringBuilder("Abandoned:");
for (Entry<Status, AtomicInteger> entry : counts.entrySet()) {
sb.append(" " + entry.getValue() + " " + entry.getKey() + " jobs");
}
logger.info(sb.toString());
}
代码示例来源:origin: opencast/opencast
/**
* {@inheritDoc}
*
* @see org.opencastproject.serviceregistry.api.ServiceRegistry#getActiveJobs()
*/
@Override
public List<Job> getActiveJobs() 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 (job.getStatus().isActive())
result.add(job);
}
}
return result;
}
代码示例来源: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
continue;
if (job.getStatus().isTerminated()) {
try {
removeJobs(Collections.singletonList(job.getId()));
代码示例来源:origin: opencast/opencast
/**
* Private utility to update and optionally fail job, called from a finally block.
*
* @param job
* to be updated, may be null
*/
protected void finallyUpdateJob(Job job) {
if (job == null) {
return;
}
if (!Job.Status.FINISHED.equals(job.getStatus())) {
job.setStatus(Job.Status.FAILED);
}
try {
getServiceRegistry().updateJob(job);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: opencast/opencast
@Override
public SystemLoad getCurrentHostLoads() {
SystemLoad systemLoad = new SystemLoad();
for (String host : hosts.keySet()) {
NodeLoad node = new NodeLoad();
node.setHost(host);
for (ServiceRegistration service : services.get(host)) {
if (service.isInMaintenanceMode() || !service.isOnline()) {
continue;
}
Set<Job> hostJobs = jobHosts.get(service);
float loadSum = 0.0f;
if (hostJobs != null) {
for (Job job : hostJobs) {
if (job.getStatus() != null && JOB_STATUSES_INFLUENCING_LOAD_BALANCING.contains(job.getStatus())) {
loadSum += job.getJobLoad();
}
}
}
node.setLoadFactor(node.getLoadFactor() + loadSum);
}
systemLoad.addNodeLoad(node);
}
return systemLoad;
}
代码示例来源:origin: opencast/opencast
final Job.Status jobStatus = processedJob.getStatus();
switch (jobStatus) {
case CANCELED:
代码示例来源:origin: opencast/opencast
Thread.currentThread().getId(), currentLoad, job.getJobLoad(), job.getStatus().name(),
maxload.getLoadFactor());
代码示例来源:origin: opencast/opencast
/** Check if <code>job</code> is not done yet and wait in case. */
public static JobBarrier.Result waitForJob(Job waiter, ServiceRegistry reg, Option<Long> timeout, Job job) {
final Job.Status status = job.getStatus();
// only create a barrier if the job is not done yet
switch (status) {
case CANCELED:
case DELETED:
case FAILED:
case FINISHED:
return new JobBarrier.Result(map(tuple(job, status)));
default:
for (Long t : timeout)
return waitForJobs(waiter, reg, t, job);
return waitForJobs(waiter, reg, job);
}
}
代码示例来源:origin: opencast/opencast
private Job updateInternal(Job job) {
Date now = new Date();
Status status = job.getStatus();
if (job.getDateCreated() == null) {
job.setDateCreated(now);
代码示例来源:origin: opencast/opencast
/**
* Sets j's blocking job ID (ie, the job which it is blocking) to waiter's ID
* @param j
* The job doing the blocking
* @param waiter
* The job blocking, waiting for its child to finish
* @return
* True if j is an active job and has been successfully updated, false if it is not an active job
* @throws ServiceRegistryException
* @throws NotFoundException
*/
private boolean setBlockerJob(Job j, Job waiter) throws ServiceRegistryException, NotFoundException {
Job blockerJob = this.serviceRegistry.getJob(j.getId());
if (j.getStatus().isActive()) {
blockerJob.setBlockingJobId(waiter.getId());
// FYI not updating local j in jobs collection
this.serviceRegistry.updateJob(blockerJob);
return true;
} else {
return false;
}
}
代码示例来源:origin: opencast/opencast
private JpaJob updateJob(JpaJob job) throws ServiceRegistryException {
EntityManager em = null;
try {
em = emf.createEntityManager();
Job oldJob = getJob(job.getId());
JpaJob jpaJob = updateInternal(em, job);
if (!TYPE_WORKFLOW.equals(job.getJobType()) && job.getJobLoad() > 0.0f
&& job.getProcessorServiceRegistration() != null
&& job.getProcessorServiceRegistration().getHost().equals(getRegistryHostname())) {
processCachedLoadChange(job);
}
// All WorkflowService Jobs will be ignored
if (oldJob.getStatus() != job.getStatus() && !TYPE_WORKFLOW.equals(job.getJobType())) {
updateServiceForFailover(em, job);
}
return jpaJob;
} catch (PersistenceException e) {
throw new ServiceRegistryException(e);
} catch (NotFoundException e) {
// Just in case, remove from cache if there
removeFromLoadCache(job.getId());
throw new ServiceRegistryException(e);
} finally {
if (em != null)
em.close();
}
}
代码示例来源:origin: opencast/opencast
securityService.setUser(creator);
securityService.setOrganization(organization);
if (Status.QUEUED.equals(job.getStatus())) {
job.setStatus(Status.DISPATCHING);
if (!dispatchJob(job)) {
代码示例来源:origin: opencast/opencast
if (parentJob != null) {
for (Job child : getChildJobs(parentJob.getId())) {
if (Status.RUNNING.equals(child.getStatus())) {
parentHasRunningChildren = true;
break;
代码示例来源:origin: opencast/opencast
final Job job = jpaJob.toJob();
final Date now = new Date();
final Status status = job.getStatus();
final Status fromDbStatus = fromDb.getStatus();
fromDb.setStatus(job.getStatus());
fromDb.setDispatchable(job.isDispatchable());
fromDb.setVersion(job.getVersion());
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!