當前位置: 首頁>>代碼示例>>Java>>正文


Java JobExecutionException類代碼示例

本文整理匯總了Java中org.quartz.JobExecutionException的典型用法代碼示例。如果您正苦於以下問題:Java JobExecutionException類的具體用法?Java JobExecutionException怎麽用?Java JobExecutionException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JobExecutionException類屬於org.quartz包,在下文中一共展示了JobExecutionException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jobWasExecuted

import org.quartz.JobExecutionException; //導入依賴的package包/類
/** 
 * @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException)
 */
public void jobWasExecuted(JobExecutionContext context,
        JobExecutionException jobException) {

    Trigger trigger = context.getTrigger();
    
    Object[] args = null;
    
    if (jobException != null) {
        if (!getLog().isWarnEnabled()) {
            return;
        } 
        
        String errMsg = jobException.getMessage();
        args = 
            new Object[] {
                context.getJobDetail().getKey().getName(),
                context.getJobDetail().getKey().getGroup(), new java.util.Date(),
                trigger.getKey().getName(), trigger.getKey().getGroup(),
                trigger.getPreviousFireTime(), trigger.getNextFireTime(),
                Integer.valueOf(context.getRefireCount()), errMsg
            };
        
        getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException); 
    } else {
        if (!getLog().isInfoEnabled()) {
            return;
        } 
        
        String result = String.valueOf(context.getResult());
        args =
            new Object[] {
                context.getJobDetail().getKey().getName(),
                context.getJobDetail().getKey().getGroup(), new java.util.Date(),
                trigger.getKey().getName(), trigger.getKey().getGroup(),
                trigger.getPreviousFireTime(), trigger.getNextFireTime(),
                Integer.valueOf(context.getRefireCount()), result
            };
        
        getLog().info(MessageFormat.format(getJobSuccessMessage(), args));
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:45,代碼來源:LoggingJobHistoryPlugin.java

示例2: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void execute(JobExecutionContext job) throws JobExecutionException {
	TriggerScheduleServiceCenterToProviderServiceCenterMessage msg = new TriggerScheduleServiceCenterToProviderServiceCenterMessage();
	String jobName = job.getJobDetail().getKey().getName();
	JobDataMap jobDataMap = job.getJobDetail().getJobDataMap();
	ConcurrentHashMap<Integer, ServiceXServerSession> rpcServers = (ConcurrentHashMap<Integer, ServiceXServerSession>) jobDataMap
			.get(RPCSERVERS);
	ConcurrentHashMap<String, ConcurrentHashSet<Integer>> schedules = (ConcurrentHashMap<String, ConcurrentHashSet<Integer>>) jobDataMap
			.get(SCHEDULES);
	ConcurrentHashSet<Integer> providerList = schedules.get(jobName);
	if (providerList == null) {
		log.error("Job:" + jobName + "找不到Provider");
		return;
	}
	msg.setJobName(jobName);
	// 查看是否是最有一次執行,並且移除此job
	if (!job.getTrigger().mayFireAgain()) {
		msg.setEnd(true);
		schedules.remove(jobName);
		log.info("任務生命終結,執行刪除:" + jobName);
	}
	// 選舉式觸發
	ArrayList<Integer> arrayList = new ArrayList<>(providerList);
	int providerId = arrayList.get(RandomUtil.randomInt(0, arrayList.size() - 1));
	ServiceXServerSession serviceXServerSession = rpcServers.get(providerId);
	if (serviceXServerSession != null) {
		serviceXServerSession.getSession().writeAndFlush(msg);
		log.info(jobName + "觸發!分配的ProviderId為:" + providerId + ",下次觸發時間:"
				+ TimeUtil.date2Str(job.getTrigger().getNextFireTime().getTime()));
	}
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:33,代碼來源:ScheduleTask.java

示例3: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
    ShardingContexts shardingContexts = jobFacade.getShardingContexts();
    int jobEventSamplingCount = shardingContexts.getJobEventSamplingCount();
    int currentJobEventSamplingCount = shardingContexts.getCurrentJobEventSamplingCount();
    if (jobEventSamplingCount > 0 && ++currentJobEventSamplingCount < jobEventSamplingCount) {
        shardingContexts.setCurrentJobEventSamplingCount(currentJobEventSamplingCount);
        jobFacade.getShardingContexts().setAllowSendJobEvent(false);
        JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
    } else {
        jobFacade.getShardingContexts().setAllowSendJobEvent(true);
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskId).setState(Protos.TaskState.TASK_RUNNING).setMessage("BEGIN").build());
        JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskId).setState(Protos.TaskState.TASK_RUNNING).setMessage("COMPLETE").build());
        shardingContexts.setCurrentJobEventSamplingCount(0);
    }
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:18,代碼來源:DaemonTaskScheduler.java

示例4: jobWasExecuted

import org.quartz.JobExecutionException; //導入依賴的package包/類
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {

        Key sj = (Key) chainLinks.get(context.getJobDetail().getKey());

        if(sj == null) {
            return;
        }

        getLog().info("Job '" + context.getJobDetail().getFullName() + "' will now chain to Job '" + sj + "'");

        try {
            if(context.getJobDetail().isVolatile() || context.getTrigger().isVolatile()) {
                context.getScheduler().triggerJobWithVolatileTrigger(sj.getName(), sj.getGroup());
            } else {
                context.getScheduler().triggerJob(sj.getName(), sj.getGroup());
            }
        } catch(SchedulerException se) {
            getLog().error("Error encountered during chaining to Job '" + sj + "'", se);
        }
    }
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:21,代碼來源:JobChainingJobListener.java

示例5: throwAndFinish

import org.quartz.JobExecutionException; //導入依賴的package包/類
private void throwAndFinish(JobDataMap jobDataMap, JobExecutionContext context, Throwable t)
        throws JobExecutionException {
    context.put(Constants.JOB_EXCEPTION, t);
    //reset retry param, just in case
    jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, 0);
    JobExecutionException e = new JobExecutionException("This trigger has thrown a terminal exception. " +
            "Retries exceeded or job not retryable", t);
    throw e;
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:10,代碼來源:ErrorHandlingJob.java

示例6: triggerRefire

import org.quartz.JobExecutionException; //導入依賴的package包/類
private void triggerRefire(JobDataMap jobDataMap, int numberOfRetries, JobExecutionContext context, Throwable t)
        throws JobExecutionException {
    final long sleepTimeBetweenRetries = jobDataMap.containsKey(SLEEP_TIME_BETWEEN_RETRIES_PARAM) ?
            jobDataMap.getLongValue(SLEEP_TIME_BETWEEN_RETRIES_PARAM) : DEFAULT_SLEEP_TIME_BETWEEN_RETRIES;
    try {
        Thread.sleep(sleepTimeBetweenRetries);
    } catch (InterruptedException e) {}
    context.put(Constants.JOB_EXCEPTION, t);
    jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, --numberOfRetries);
    //set refire flag as true
    throw new JobExecutionException(t, true);
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:13,代碼來源:ErrorHandlingJob.java

示例7: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    ApiFactoryService apiFactoryService =  (ApiFactoryService) context.get(ApiFactoryService.class.getName());

    try {
        EntityManager em = HibernateUtil.getTransactionalEntityManager();
        List<DistributedAppliance> das = HibernateUtil.getTransactionControl().required(() -> {
            OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(
                    DistributedAppliance.class, em, StaticRegistry.transactionalBroadcastUtil());

            return emgr.listAll();
        });

        for (DistributedAppliance da : das) {
            for (VirtualSystem vs : da.getVirtualSystems()) {

                ApplianceManagerConnector apmc = vs.getDistributedAppliance().getApplianceManagerConnector();
                ManagerDeviceMemberApi agentApi =  apiFactoryService.createManagerDeviceMemberApi(apmc, vs);

                if (apiFactoryService.providesDeviceStatus(vs)) {
                    List<ManagerDeviceMemberStatusElement> agentElems = agentApi.getFullStatus(
                            vs.getDistributedApplianceInstances().stream()
                            .map(DistributedApplianceInstanceElementImpl::new)
                            .collect(Collectors.toList()));
                    for (DistributedApplianceInstance dai : vs.getDistributedApplianceInstances()) {
                        getAgentFullStatus(dai, agentElems);
                    }
                }
            }
        }

    } catch (Exception ex) {
        log.error("Fail to sync DAs", ex);
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:36,代碼來源:ApplianceAgentsJob.java

示例8: save

import org.quartz.JobExecutionException; //導入依賴的package包/類
/**
 * @param context      {@link JobExecutionContext}
 * @param jobException {@link JobExecutionException}
 */
@Trace(metricName = "JobListener{save}", async = true, dispatcher = true)
private void save(JobExecutionContext context, JobExecutionException jobException) throws IOException {
    JobResult jobResult = (JobResult) context.getResult();
    ExecutionStatusEntity.ExecutionStatusEntityBuilder builder = ExecutionStatusEntity.builder();
    builder.created(new Date());
    builder.nextFireTime(context.getNextFireTime());
    builder.fireTime(context.getFireTime());
    builder.jobRunTime(context.getJobRunTime());
    builder.prevFireTime(context.getPreviousFireTime());
    builder.scheduledFireTime(context.getScheduledFireTime());
    if (jobResult != null && jobResult.getTmpFile() != null) {
        builder.output(FileUtils.readFileToString(jobResult.getTmpFile().toFile()));
        builder.exitCode(jobResult.getExitValue());
        if (jobResult.getExitValue() != 0)
            builder.errors(true);
        if (jobResult.getTmpFile().toFile().delete())
            logger.debug(String.format("%s file deleted", jobResult.getTmpFile().toAbsolutePath()));
    } else {
        builder.output("No output");
        builder.exitCode(-1);
        builder.errors(true);
    }
    if (jobException != null) {
        builder.errors(true);
        builder.errorMessage(jobException.getMessage());
    }
    builder.job(getJob());
    executionStatusRepository.save(builder.build());
}
 
開發者ID:farchanjo,項目名稱:webcron,代碼行數:34,代碼來源:JobListenerImpl.java

示例9: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
public void execute(JobExecutionContext context) throws JobExecutionException
{
    JobDataMap jobData = context.getJobDetail().getJobDataMap();
    // extract the content Cleanup to use
    Object nodeCleanupWorkerObj = jobData.get("nodeCleanupWorker");
    if (nodeCleanupWorkerObj == null || !(nodeCleanupWorkerObj instanceof NodeCleanupWorker))
    {
        throw new AlfrescoRuntimeException(
                "NodeCleanupJob data must contain valid 'nodeCleanupWorker' reference");
    }
    NodeCleanupWorker nodeCleanupWorker = (NodeCleanupWorker) nodeCleanupWorkerObj;
    List<String> cleanupLog = nodeCleanupWorker.doClean();
    // Done
    if (logger.isDebugEnabled())
    {
        logger.debug("Node cleanup log:");
        for (String log : cleanupLog)
        {
            logger.debug(log);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:NodeCleanupJob.java

示例10: executeInternal

import org.quartz.JobExecutionException; //導入依賴的package包/類
@Override
protected synchronized final void executeInternal(final JobExecutionContext jobContext)
        throws JobExecutionException
{
    if (locker == null)
    {
        JobLockService jobLockServiceBean = (JobLockService) jobContext.getJobDetail()
                .getJobDataMap().get("jobLockService");
        if (jobLockServiceBean == null)
            throw new JobExecutionException("Missing setting for bean jobLockService");
        String name = (String) jobContext.getJobDetail().getJobDataMap().get("name");
        String jobName = name == null ? this.getClass().getSimpleName() : name;
        locker = new ScheduledJobLockExecuter(jobLockServiceBean, jobName, this);
    }
    locker.execute(jobContext);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:17,代碼來源:AbstractScheduledLockedJob.java

示例11: executeInternal

import org.quartz.JobExecutionException; //導入依賴的package包/類
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	JobKey key = jobExecutionContext.getJobDetail().getKey();
	System.out.println("Cron Job started with key :" + key.getName() + ", Group :"+key.getGroup() + " , Thread Name :"+Thread.currentThread().getName() + " ,Time now :"+new Date());
	
	System.out.println("======================================");
	System.out.println("Accessing annotation example: "+jobService.getAllJobs());
	List<Map<String, Object>> list = jobService.getAllJobs();
	System.out.println("Job list :"+list);
	System.out.println("======================================");
	
	//*********** For retrieving stored key-value pairs ***********/
	JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();
	String myValue = dataMap.getString("myKey");
	System.out.println("Value:" + myValue);

	System.out.println("Thread: "+ Thread.currentThread().getName() +" stopped.");
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:19,代碼來源:CronJob.java

示例12: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
/** 
 * Called when the job is executed by quartz. This method delegates to the <tt>validateSessions()</tt> method on the 
 * associated session manager. 
 *  
 * @param context 
 *            the Quartz job execution context for this execution. 
 */  
public void execute(JobExecutionContext context) throws JobExecutionException {  
  
    JobDataMap jobDataMap = context.getMergedJobDataMap();  
    ValidatingSessionManager sessionManager = (ValidatingSessionManager) jobDataMap.get(SESSION_MANAGER_KEY);  
  
    if (log.isDebugEnabled()) {  
        log.debug("Executing session validation Quartz job...");  
    }  
  
    sessionManager.validateSessions();  
  
    if (log.isDebugEnabled()) {  
        log.debug("Session validation Quartz job complete.");  
    }  
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:23,代碼來源:QuartzSessionValidationJob.java

示例13: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    HistorianEntry entry = getInitialHistorianEntry(context);

    try {
        job.execute(context);
        entry.setOutput(context.getResult());
        entry.setRunStatus(ExecutionStatus.COMPLETED_SUCCESSFULLY);
    } catch (Throwable t) {
        entry.setException(t);
        entry.setRunStatus(ExecutionStatus.COMPLETED_WITH_EXCEPTION);
        throw t;
    } finally {
        entry.setEndTime(Instant.now(clock));
        historianDAO.writeEntry(entry);
    }
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:18,代碼來源:HistorianJob.java

示例14: executeInternal

import org.quartz.JobExecutionException; //導入依賴的package包/類
/**
    * @see org.springframework.scheduling.quartz.QuartzJobBean#executeInternal(org.quartz.JobExecutionContext)
    */
   @Override
   protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
IMonitoringService monitoringService = getMonitoringService(context);

//getting gate id set from scheduler
Map properties = context.getJobDetail().getJobDataMap();
Long gateId = (Long) properties.get("gateId");

if (log.isDebugEnabled()) {
    log.debug("Closing gate......[" + gateId.longValue() + "]");
}

monitoringService.closeGate(gateId);

if (log.isDebugEnabled()) {
    log.debug("Gate......[" + gateId.longValue() + "] Closed");
}
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:CloseScheduleGateJob.java

示例15: execute

import org.quartz.JobExecutionException; //導入依賴的package包/類
public void execute(JobExecutionContext context) throws JobExecutionException {
	long start = System.currentTimeMillis();
	JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
	String taskType = jobDataMap.getString("taskType");
	String targetObject = jobDataMap.getString("targetObject");
	String targetMethod = jobDataMap.getString("targetMethod");
	logger.info("定時任務開始執行: [{}.{}]", targetObject, targetMethod);
	try {
		ApplicationContext applicationContext = (ApplicationContext) context.getScheduler().getContext()
				.get("applicationContext");
		if (TaskType.local.equals(taskType)) {
			Object refer = applicationContext.getBean(targetObject);
			refer.getClass().getDeclaredMethod(targetMethod).invoke(refer);
		} else if (TaskType.dubbo.equals(taskType)) {
			String system = jobDataMap.getString("targetSystem");
			BaseProvider provider = (BaseProvider) DubboUtil.refer(applicationContext, system);
			provider.execute(new Parameter(targetObject, targetMethod));
		}
		double time = (System.currentTimeMillis() - start) / 1000.0;
		logger.info("定時任務[{}.{}]用時:{}s", targetObject, targetMethod, time);
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:25,代碼來源:BaseJob.java


注:本文中的org.quartz.JobExecutionException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。