|
|
|
@ -22,6 +22,8 @@ package io.entgra.task.mgt.watcher;
|
|
|
|
|
import io.entgra.task.mgt.common.bean.DynamicTask;
|
|
|
|
|
import io.entgra.task.mgt.common.constant.TaskMgtConstant;
|
|
|
|
|
import io.entgra.task.mgt.common.exception.TaskManagementException;
|
|
|
|
|
import io.entgra.task.mgt.core.config.TaskConfigurationManager;
|
|
|
|
|
import io.entgra.task.mgt.core.config.TaskManagementConfig;
|
|
|
|
|
import io.entgra.task.mgt.core.util.TaskManagementUtil;
|
|
|
|
|
import io.entgra.task.mgt.watcher.internal.TaskWatcherDataHolder;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
@ -45,13 +47,25 @@ public class IoTSStartupHandler implements ServerStartupObserver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void completedServerStartup() {
|
|
|
|
|
Timer timer = new Timer();
|
|
|
|
|
timer.schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
compareTasks();
|
|
|
|
|
try {
|
|
|
|
|
TaskManagementConfig taskManagementConfig = TaskConfigurationManager.getInstance().getTaskManagementConfig();
|
|
|
|
|
if (taskManagementConfig.isTaskWatcherEnabled()) {
|
|
|
|
|
Timer timer = new Timer();
|
|
|
|
|
timer.schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
compareTasks();
|
|
|
|
|
}
|
|
|
|
|
}, 200000, 600000);
|
|
|
|
|
} else {
|
|
|
|
|
String msg = "Task watcher is not enabled in this environment hence wso2 carbon ntask will not " +
|
|
|
|
|
"update according to the task manager ";
|
|
|
|
|
log.error(msg);
|
|
|
|
|
}
|
|
|
|
|
}, 200000, 600000);
|
|
|
|
|
} catch (TaskManagementException e) {
|
|
|
|
|
String msg = "Unable to read task watcher configuration";
|
|
|
|
|
log.error(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void compareTasks() {
|
|
|
|
@ -97,7 +111,7 @@ public class IoTSStartupHandler implements ServerStartupObserver {
|
|
|
|
|
&& taskManager.getTaskState(generatedTaskId) != TaskManager.TaskState.PAUSED) {
|
|
|
|
|
taskManager.pauseTask(generatedTaskId);
|
|
|
|
|
}
|
|
|
|
|
log.info("Task - '" + generatedTaskId + "' updated according to the dynamic task table");
|
|
|
|
|
log.debug("Task - '" + generatedTaskId + "' updated according to the dynamic task table");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -108,7 +122,7 @@ public class IoTSStartupHandler implements ServerStartupObserver {
|
|
|
|
|
dt.getProperties(), triggerInfo);
|
|
|
|
|
taskManager.registerTask(taskInfo);
|
|
|
|
|
taskManager.scheduleTask(generatedTaskId);
|
|
|
|
|
log.info("New task -'" + generatedTaskId + "' created according to the dynamic task table");
|
|
|
|
|
log.debug("New task -'" + generatedTaskId + "' created according to the dynamic task table");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -122,7 +136,7 @@ public class IoTSStartupHandler implements ServerStartupObserver {
|
|
|
|
|
}
|
|
|
|
|
if (!isExist) {
|
|
|
|
|
taskManager.deleteTask(taskInfo.getName());
|
|
|
|
|
log.info("Task '" + taskInfo.getName() + "' deleted according to the dynamic task table");
|
|
|
|
|
log.debug("Task '" + taskInfo.getName() + "' deleted according to the dynamic task table");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("Task Comparison Completed and all tasks in current node are updated");
|
|
|
|
|