当前位置: 首页>>代码示例>>Java>>正文


Java TriggerInfo类代码示例

本文整理汇总了Java中org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo的典型用法代码示例。如果您正苦于以下问题:Java TriggerInfo类的具体用法?Java TriggerInfo怎么用?Java TriggerInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TriggerInfo类属于org.wso2.carbon.ntask.core.TaskInfo包,在下文中一共展示了TriggerInfo类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleCronScheduleMisfirePolicy

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
private CronScheduleBuilder handleCronScheduleMisfirePolicy(TriggerInfo triggerInfo,
                                                            CronScheduleBuilder cb) throws TaskException {
    switch (triggerInfo.getMisfirePolicy()) {
        case DEFAULT:
            return cb;
        case IGNORE_MISFIRES:
            return cb.withMisfireHandlingInstructionIgnoreMisfires();
        case FIRE_AND_PROCEED:
            return cb.withMisfireHandlingInstructionFireAndProceed();
        case DO_NOTHING:
            return cb.withMisfireHandlingInstructionDoNothing();
        default:
            throw new TaskException("The task misfire policy '" + triggerInfo.getMisfirePolicy() +
                    "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:AbstractQuartzTaskManager.java

示例2: handleSimpleScheduleMisfirePolicy

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
private SimpleScheduleBuilder handleSimpleScheduleMisfirePolicy(TriggerInfo triggerInfo,
                                                                SimpleScheduleBuilder sb) throws TaskException {
    switch (triggerInfo.getMisfirePolicy()) {
        case DEFAULT:
            return sb;
        case FIRE_NOW:
            return sb.withMisfireHandlingInstructionFireNow();
        case IGNORE_MISFIRES:
            return sb.withMisfireHandlingInstructionIgnoreMisfires();
        case NEXT_WITH_EXISTING_COUNT:
            return sb.withMisfireHandlingInstructionNextWithExistingCount();
        case NEXT_WITH_REMAINING_COUNT:
            return sb.withMisfireHandlingInstructionNextWithRemainingCount();
        case NOW_WITH_EXISTING_COUNT:
            return sb.withMisfireHandlingInstructionNowWithExistingCount();
        case NOW_WITH_REMAINING_COUNT:
            return sb.withMisfireHandlingInstructionNowWithRemainingCount();
        default:
            throw new TaskException("The task misfire policy '" + triggerInfo.getMisfirePolicy() +
                    "' cannot be used in simple schedule tasks", Code.CONFIG_ERROR);
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:23,代码来源:AbstractQuartzTaskManager.java

示例3: convert

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
public static StaticTaskInformation convert(TaskInfo taskInfo, String taskType,
        String remoteTaskId, int tenantId) throws TaskException {
    StaticTaskInformation stTaskInfo = new StaticTaskInformation();
    stTaskInfo.setName(remoteTaskNameFromTaskInfo(taskType, taskInfo.getName()));
    stTaskInfo.setTargetURI(getTaskNodeBaseURL(tenantId) + "/" + remoteTaskId);
    TriggerInfo triggerInfo = taskInfo.getTriggerInfo();
    TriggerInformation stTriggerInfo = new TriggerInformation();
    stTriggerInfo.setCronExpression(triggerInfo.getCronExpression());
    stTriggerInfo.setStartTime(dateToCal(triggerInfo.getStartTime()));
    stTriggerInfo.setEndTime(dateToCal(triggerInfo.getEndTime()));
    stTriggerInfo.setTaskCount(triggerInfo.getRepeatCount());
    stTriggerInfo.setTaskInterval(triggerInfo.getIntervalMillis());
    stTaskInfo.setTriggerInformation(stTriggerInfo);
    stTaskInfo.setAllowConcurrentExecutions(!triggerInfo.isDisallowConcurrentExecution());
    return stTaskInfo;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:RemoteTaskUtils.java

示例4: convert

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
public static TaskInfo convert(DSTaskInfo dsTaskInfo) {
	TriggerInfo triggerInfo = new TriggerInfo();
	triggerInfo.setCronExpression(dsTaskInfo.getCronExpression());
	if (dsTaskInfo.getStartTime() != null) {
	    triggerInfo.setStartTime(dsTaskInfo.getStartTime().getTime());
	}
	if (dsTaskInfo.getEndTime() != null) {
	    triggerInfo.setEndTime(dsTaskInfo.getEndTime().getTime());
	}
	triggerInfo.setIntervalMillis(dsTaskInfo.getTaskInterval());
	triggerInfo.setRepeatCount(dsTaskInfo.getTaskCount());
	Map<String, String> props = new HashMap<String, String>();
	if (dsTaskInfo.getDataTaskClassName() != null) {
	    props.put(DSTaskConstants.DATA_TASK_CLASS_NAME, dsTaskInfo.getDataTaskClassName());
           props.put(DSTaskConstants.TASK_NAME, dsTaskInfo.getName());
	    triggerInfo.setDisallowConcurrentExecution(true);
	    return new TaskInfo(
				dsTaskInfo.getName(), DSTaskExt.class.getName(), props, triggerInfo);
	} else {
	    props.put(DSTaskConstants.DATA_SERVICE_NAME, dsTaskInfo.getServiceName());
	    props.put(DSTaskConstants.DATA_SERVICE_OPERATION_NAME, dsTaskInfo.getOperationName());
	    props.put(WebServiceCallTask.SERVICE_ACTION, "urn:" + dsTaskInfo.getOperationName());
        return new TaskInfo(dsTaskInfo.getName(), DSTask.class.getName(), props, triggerInfo);
	}
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:26,代码来源:DSTaskUtils.java

示例5: updateTask

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
@Override
public void updateTask(int monitoringFrequency) throws PolicyMonitoringTaskException {
    int tenantId = getTenantId();
    try {
        String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId);
        TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService();
        TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE);

        if (taskManager.isTaskScheduled(taskName)) {

            taskManager.deleteTask(taskName);
            TriggerInfo triggerInfo = new TriggerInfo();
            triggerInfo.setIntervalMillis(monitoringFrequency);
            triggerInfo.setRepeatCount(-1);

            Map<String, String> properties = new HashMap<>();
            properties.put("tenantId", String.valueOf(tenantId));

            TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.MONITORING_TASK_CLAZZ, properties,
                    triggerInfo);

            taskManager.registerTask(taskInfo);
            taskManager.rescheduleTask(taskInfo.getName());
        } else {
            throw new PolicyMonitoringTaskException("Monitoring task has not been started for this tenant " +
                    tenantId + ". Please start the task first.");
        }

    } catch (TaskException e) {
        throw new PolicyMonitoringTaskException("Error occurred while updating the task for tenant " + tenantId, e);
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:34,代码来源:TaskScheduleServiceImpl.java

示例6: getTriggerFromInfo

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
private Trigger getTriggerFromInfo(String taskName, String taskGroup,
                                   TriggerInfo triggerInfo) throws TaskException {
    TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger().withIdentity(
            taskName, taskGroup);
    if (triggerInfo.getStartTime() == null) {
        triggerBuilder = triggerBuilder.startNow();
    } else {
        triggerBuilder = triggerBuilder.startAt(triggerInfo.getStartTime());
    }
    if (triggerInfo.getEndTime() != null) {
        triggerBuilder.endAt(triggerInfo.getEndTime());
    }
    Trigger trigger;
    if (triggerInfo.getCronExpression() != null) {
        trigger = triggerBuilder.withSchedule(this.getCronScheduleBuilder(
                triggerInfo)).build();
    } else {
        if (triggerInfo.getRepeatCount() == 0) {
            /* only once executed */
            trigger = triggerBuilder.build();
        } else {
            trigger = triggerBuilder.withSchedule(this.getSimpleScheduleBuilder(
                    triggerInfo)).build();
        }
    }
    return trigger;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:28,代码来源:AbstractQuartzTaskManager.java

示例7: getSimpleScheduleBuilder

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
private SimpleScheduleBuilder getSimpleScheduleBuilder(TriggerInfo triggerInfo)
        throws TaskException {
    SimpleScheduleBuilder scheduleBuilder = null;
    if (triggerInfo.getRepeatCount() == -1) {
        scheduleBuilder = SimpleScheduleBuilder.simpleSchedule().repeatForever();
    } else if (triggerInfo.getRepeatCount() > 0) {
        scheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withRepeatCount(
                triggerInfo.getRepeatCount());
    }
    scheduleBuilder = scheduleBuilder.withIntervalInMilliseconds(
            triggerInfo.getIntervalMillis());
    scheduleBuilder = this.handleSimpleScheduleMisfirePolicy(triggerInfo, scheduleBuilder);
    return scheduleBuilder;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:15,代码来源:AbstractQuartzTaskManager.java

示例8: startTask

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
@Override
public void startTask(int monitoringFrequency) throws PolicyMonitoringTaskException {
    int tenantId = getTenantId();
    if (policyConfiguration.getMonitoringEnable()) {

        if (monitoringFrequency <= 0) {
            throw new PolicyMonitoringTaskException("Time interval cannot be 0 or less than 0.");
        }
        try {
            TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService();
            taskService.registerTaskType(PolicyManagementConstants.MONITORING_TASK_TYPE);

            if (log.isDebugEnabled()) {
                log.debug("Monitoring task is started for the tenant id " + tenantId);
            }

            TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE);

            TriggerInfo triggerInfo = new TriggerInfo();
            triggerInfo.setIntervalMillis(monitoringFrequency);
            triggerInfo.setRepeatCount(-1);

            Map<String, String> properties = new HashMap<>();
            properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId));

            String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId);

            if (!taskManager.isTaskScheduled(taskName)) {

                TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.MONITORING_TASK_CLAZZ,
                        properties, triggerInfo);

                taskManager.registerTask(taskInfo);
                taskManager.rescheduleTask(taskInfo.getName());
            } else {
                throw new PolicyMonitoringTaskException("Monitoring task is already started for this tenant " +
                        tenantId);
            }


        } catch (TaskException e) {
            throw new PolicyMonitoringTaskException("Error occurred while creating the task for tenant " +
                                                    tenantId, e);
        }
    } else {
        throw new PolicyMonitoringTaskException("Policy monitoring is not enabled in the cdm-config.xml.");
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:50,代码来源:TaskScheduleServiceImpl.java

示例9: getCronScheduleBuilder

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入依赖的package包/类
private CronScheduleBuilder getCronScheduleBuilder(TriggerInfo triggerInfo)
        throws TaskException {
    CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(triggerInfo.getCronExpression());
    cb = this.handleCronScheduleMisfirePolicy(triggerInfo, cb);
    return cb;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:7,代码来源:AbstractQuartzTaskManager.java


注:本文中的org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。