Package org.apache.synapse.task

Examples of org.apache.synapse.task.TaskScheduler


            * Carbon Scheduled Tasks Component is used.
            * Since the Scheduled Tasks Component itself does not initialize a
            * TaskScheduler instance,this code snippet is used to initialize a
            * the required instance manually.
            */
            TaskScheduler taskScheduler = (TaskScheduler) configurationContext.getProperty(
                    TaskManager.CARBON_TASK_SCHEDULER);
            if (taskScheduler == null) {
                taskScheduler = new TaskScheduler(TaskManager.CARBON_TASK_SCHEDULER);
                taskScheduler.init(null);
                configurationContext.setProperty(
                        TaskManager.CARBON_TASK_SCHEDULER, taskScheduler);
            } else if (taskScheduler.isInitialized()) {
                taskScheduler.init(null);
            }
        } catch (Throwable e) {
            log.error("An error occurred while executing the bundle activator method!", e);
        }
    }
View Full Code Here


        }

        /**
         * Initializing the Task Scheduler
         */
        TaskScheduler taskScheduler = (TaskScheduler) configurationContext.getProperty(
                TaskSchedulerConstants.CARBON_TASK_SCHEDULER);
        if (taskScheduler == null) {
            taskScheduler = new TaskScheduler(TaskManager.CARBON_TASK_SCHEDULER);
            taskScheduler.init(null);
            configurationContext.setProperty(
                    TaskSchedulerConstants.CARBON_TASK_SCHEDULER, taskScheduler);
        } else if (taskScheduler.isInitialized()) {
            taskScheduler.init(null);
        }

        /**
         * Initializing the Task Description Repository
         */
 
View Full Code Here

    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(SystemHostObjectInitializer.CARBON_TASK_SCHEDULER);
        if (scheduler == null) {
            scheduler = new TaskScheduler(TaskConstants.TASK_SCHEDULER);
            scheduler.init(null);
            configContext.setProperty(SystemHostObjectInitializer.CARBON_TASK_SCHEDULER, scheduler);
        } else if(!scheduler.isInitialized()) {
            scheduler.init(null);
        }

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

        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

        //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

        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

            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

                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

            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

                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

TOP

Related Classes of org.apache.synapse.task.TaskScheduler

Copyright © 2018 www.massapicom. 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.