use of org.apache.synapse.task.TaskScheduler in project wso2-synapse by wso2.
the class StartUpController method destroy.
/**
* Remove the scheduled task completely. So only un-deployment will remove the task. Server node shutdown will keep
* task intact in the registry.
* <p>
* This was introduced as a fix for product-ei#1206.
*
* @param removeTask whether keep the task or not.
*/
public void destroy(boolean removeTask) {
if (!destroyTask()) {
return;
}
// Need to re initialize startup controller to support updates from source view
if (!synapseTaskManager.isInitialized() && synapseEnvironment != null) {
init(synapseEnvironment);
}
if (synapseTaskManager.isInitialized()) {
TaskScheduler taskScheduler = synapseTaskManager.getTaskScheduler();
if (taskScheduler != null && taskScheduler.isInitialized() && removeTask) {
taskScheduler.deleteTask(taskDescription.getName(), taskDescription.getTaskGroup());
}
TaskDescriptionRepository repository = synapseTaskManager.getTaskDescriptionRepository();
if (repository != null) {
repository.removeTaskDescription(taskDescription.getName());
}
}
}
use of org.apache.synapse.task.TaskScheduler in project wso2-synapse by wso2.
the class StartUpController method init.
public void init(SynapseEnvironment synapseEnvironment) {
this.synapseEnvironment = synapseEnvironment;
if (taskDescription == null) {
handleException("Error while initializing the startup. TaskDescription is null.");
}
initSynapseTaskManager(synapseEnvironment);
TaskDescriptionRepository repository = synapseTaskManager.getTaskDescriptionRepository();
if (repository == null) {
handleException("Task Description Repository cannot be found");
return;
}
repository.addTaskDescription(taskDescription);
if (!processPinnedServers(taskDescription, synapseEnvironment)) {
return;
}
resolveTaskImpl(taskDescription, synapseEnvironment);
loadTaskProperties();
initializeTask(synapseEnvironment);
if (taskDescription.getResource(TaskDescription.INSTANCE) == null || taskDescription.getResource(TaskDescription.CLASSNAME) == null) {
taskDescription.addResource(TaskDescription.INSTANCE, task);
taskDescription.addResource(TaskDescription.CLASSNAME, task.getClass().getName());
}
try {
Map<String, Object> map = new HashMap<>();
map.put(TaskConstants.SYNAPSE_ENV, synapseEnvironment);
TaskScheduler taskScheduler = synapseTaskManager.getTaskScheduler();
TaskManager taskManager = synapseTaskManager.getTaskManagerImpl();
if (taskManager == null) {
logger.error("Could not initialize Start up controller. TaskManager not found.");
return;
}
taskManager.setProperties(map);
taskScheduler.init(synapseEnvironment.getSynapseConfiguration().getProperties(), taskManager);
submitTask(taskScheduler, taskDescription);
logger.debug("Submitted task [" + taskDescription.getName() + "] to Synapse task scheduler.");
} catch (Exception e) {
String msg = "Error starting up Scheduler : " + e.getLocalizedMessage();
logger.fatal(msg, e);
throw new SynapseException(msg, e);
}
}
Aggregations