Examples of TaskScheduler


Examples of org.apache.synapse.task.TaskScheduler

        SystemHostObjectInitializer listener = new SystemHostObjectInitializer();
        bundleContext.registerService(
                Axis2ConfigurationContextObserver.class.getName(), listener, null);
        if (configurationContext != null) {
            TaskScheduler scheduler = (TaskScheduler) configurationContext.getProperty(SystemHostObjectInitializer.CARBON_TASK_SCHEDULER);
            if (scheduler == null) {
                scheduler = new TaskScheduler(TaskConstants.TASK_SCHEDULER);
                scheduler.init(null);
                configurationContext.setProperty(SystemHostObjectInitializer.CARBON_TASK_SCHEDULER, scheduler);
            } else if (!scheduler.isInitialized()) {
                scheduler.init(null);
            }
        }

    }
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

        //taskDescription.setInterval(200);
        taskDescription.setInterval(JOB_INTERVAL * 60 * 1000L);

        Map<String, Object> resources = new HashMap<String, Object>();

        TaskScheduler taskScheduler =
                TaskSchedulerFactory.getTaskScheduler(TASK_ID);
        if (!taskScheduler.isInitialized()) {
            Properties properties = new Properties();
            taskScheduler.init(properties);
        }       
        taskScheduler.scheduleTask(taskDescription, resources, KeepAliveJob.class);
    }
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

        taskDescription.setStartTime(startTime.getTime());

        Map<String, Object> resources = new HashMap<String, Object>();
        resources.put(ThrottlingJob.THROTTLING_TASK_CONTEXT_KEY, throttlingTask);

        TaskScheduler taskScheduler = TaskSchedulerFactory.getTaskScheduler(THROTTLING_TASK_ID);
        if (!taskScheduler.isInitialized()) {
            Properties properties = new Properties();
            taskScheduler.init(properties);
        }
        taskScheduler.scheduleTask(taskDescription, resources, ThrottlingJob.class);
    }
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

            SynapseConfiguration oldSynapseConfiguration = getSynapseConfiguration();
            SynapseEnvironment oldSynapseEnvironment = getSynapseEnvironment();

            TaskDescriptionRepository repository = getSynapseEnvironment().getTaskManager().
                    getTaskDescriptionRepository();
            TaskScheduler taskScheduler = getSynapseEnvironment().getTaskManager().
                    getTaskScheduler();

            int loadLocation = 0;

            // if this configuration is not created before we are going to
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

                contextInfo.addProperty(DataSourceConstants.DATA_SOURCE_INFORMATION_REPOSITORY,
                        repository);
            }

            if (taskSchedulerService != null) {
                TaskScheduler scheduler = taskSchedulerService.getTaskScheduler();
                contextInfo.addProperty(TaskConstants.TASK_SCHEDULER, scheduler);
            }

            if (repositoryService != null) {
                TaskDescriptionRepository repository
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

            taskDescription.setStartTime(startTime.getTime());

            Map<String, Object> resources = new HashMap<String, Object>();
            resources.put(ThrottlingJob.THROTTLING_TASK_CONTEXT_KEY, throttlingTask);

            TaskScheduler taskScheduler = TaskSchedulerFactory.getTaskScheduler(THROTTLING_TASK_ID);
            if (!taskScheduler.isInitialized()) {
                Properties properties = new Properties();
                taskScheduler.init(properties);
            }
            taskScheduler.scheduleTask(taskDescription, resources, ThrottlingJob.class);
        }
    }
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

                bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(),
                        listener, null);
            }

            if (configurationContext != null) {
                TaskScheduler scheduler =
                        (TaskScheduler) configurationContext.getProperty(AutoscalerTaskInitializer.CARBON_TASK_SCHEDULER);
                if (scheduler == null) {
                    scheduler = new TaskScheduler(TaskConstants.TASK_SCHEDULER);
                    scheduler.init(null);
                    configurationContext.setProperty(AutoscalerTaskInitializer.CARBON_TASK_SCHEDULER,
                            scheduler);
                } else if (!scheduler.isInitialized()) {
                    scheduler.init(null);
                }
            }
           
            String autoscalerClass = lbConfig.getLoadBalancerConfig().getAutoscalerTaskClass();
            Task task;
            if (autoscalerClass != null) {
                try {
                    task = (Task) Class.forName(autoscalerClass).newInstance();
                } catch (Exception e) {
                    String msg = "Cannot instantiate Autoscaling Task. Class: " + autoscalerClass
                        +". It should implement 'org.apache.synapse.task.Task' and "
                        +"'org.apache.synapse.ManagedLifecycle' interfaces.";
                    log.error(msg, e);
                    throw new RuntimeException(msg, e);
                }
            } else {
                task = new ServiceRequestsInFlightAutoscaler();
            }

//            ServiceRequestsInFlightAutoscaler autoscalerTask =
//                    new ServiceRequestsInFlightAutoscaler();

            ((ManagedLifecycle) task).init(synapseEnv);

            // specify scheduler task details
            JobBuilder jobBuilder = JobBuilder.newJob(AutoscalingJob.class)
                .withIdentity("autoscalerJob");
            JobDetail job = jobBuilder.build();

            Map<String, Object> dataMap = job.getJobDataMap();
            dataMap.put(AutoscalingJob.AUTOSCALER_TASK, task);
            dataMap.put(AutoscalingJob.SYNAPSE_ENVI, synapseEnv);

            final TaskDescription taskDescription = new TaskDescription();
            taskDescription.setTaskClass(ServiceRequestsInFlightAutoscaler.class.getName());
            taskDescription.setName("autoscaler");
            //taskDescription.setCount(SimpleTrigger.REPEAT_INDEFINITELY);

            int interval = AutoscalerTaskDSHolder.getInstance().getLoadBalancerConfig().getAutoscalerTaskInterval();
            taskDescription.setInterval(interval);
            taskDescription.setStartTime(new Date(System.currentTimeMillis() + (interval*2)));

            TaskSchedulingManager scheduler = new TaskSchedulingManager();
            scheduler.scheduleTask(taskDescription, dataMap, configurationContext);


        } else {

            log.info("Autoscaling is disabled.");
View Full Code Here

Examples of org.apache.synapse.task.TaskScheduler

    public static final java.lang.String CARBON_TASK_SCHEDULER = "CARBON_TASK_SCHEDULER";
    public static final java.lang.String CARBON_TASK_REPOSITORY = "CARBON_TASK_REPOSITORY";

    public void createdConfigurationContext(ConfigurationContext configContext) {
        TaskScheduler scheduler = (TaskScheduler)configContext.getProperty(AutoscalerTaskInitializer.CARBON_TASK_SCHEDULER);
        if (scheduler == null) {
            scheduler = new TaskScheduler(TaskConstants.TASK_SCHEDULER);
            scheduler.init(null);
            configContext.setProperty(AutoscalerTaskInitializer.CARBON_TASK_SCHEDULER, scheduler);
        } else if(!scheduler.isInitialized()) {
            scheduler.init(null);
        }

        if (configContext.getProperty(AutoscalerTaskInitializer.CARBON_TASK_REPOSITORY) == null) {
            TaskDescriptionRepository repository = new TaskDescriptionRepository();
            configContext.setProperty(
View Full Code Here

Examples of org.springframework.scheduling.TaskScheduler

   * @param beanFactory BeanFactory for lookup, must not be null.
   * @return task scheduler
   * @throws IllegalStateException if no such bean is available
   */
  public static TaskScheduler getRequiredTaskScheduler(BeanFactory beanFactory) {
    TaskScheduler taskScheduler = getTaskScheduler(beanFactory);
    Assert.state(taskScheduler != null, "No such bean '" + TASK_SCHEDULER_BEAN_NAME + "'");
    return taskScheduler;
  }
View Full Code Here

Examples of org.springframework.scheduling.TaskScheduler

*/
public class PollingTaskSupportTests {

  @Test
  public void testPollingTask() throws InterruptedException {
    TaskScheduler taskScheduler = new ConcurrentTaskScheduler();
    TaskExecutor taskExecutor = new SyncTaskExecutor();
    TestPollingTaskSupport poller = new TestPollingTaskSupport(taskScheduler, taskExecutor,
        TimeUnit.SECONDS, 2);
    poller.init();
    poller.start();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.