Improve dynamic and random task execution

appm_improvement
Charitha Goonetilleke 9 months ago
parent 4045e39a76
commit 5d69d08100

@ -59,4 +59,5 @@ public class ScheduledAppSubscriptionCleanupTask extends RandomlyAssignedSchedul
public String getTaskName() { public String getTaskName() {
return TASK_NAME; return TASK_NAME;
} }
} }

@ -145,4 +145,5 @@ public class ScheduledAppSubscriptionTask extends RandomlyAssignedScheduleTask {
public String getTaskName() { public String getTaskName() {
return TASK_NAME; return TASK_NAME;
} }
} }

@ -365,13 +365,6 @@
<dependency> <dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId> <groupId>org.wso2.orbit.javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId> <artifactId>jaxb-api</artifactId>
<version>2.3.1.wso2v1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1.wso2v1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

@ -28,8 +28,6 @@ import org.wso2.carbon.ntask.core.Task;
public abstract class RandomlyAssignedScheduleTask implements Task { public abstract class RandomlyAssignedScheduleTask implements Task {
private static final Log log = LogFactory.getLog(RandomlyAssignedScheduleTask.class); private static final Log log = LogFactory.getLog(RandomlyAssignedScheduleTask.class);
private static String taskName = "UNSPECIFIED";
private static boolean qualifiedToExecuteTask = false; private static boolean qualifiedToExecuteTask = false;
private static boolean dynamicTaskEnabled = false; private static boolean dynamicTaskEnabled = false;
@ -40,8 +38,6 @@ public abstract class RandomlyAssignedScheduleTask implements Task {
} catch (HeartBeatManagementException e) { } catch (HeartBeatManagementException e) {
log.error("Error Instantiating Variables necessary for Randomly Assigned Task Scheduling.", e); log.error("Error Instantiating Variables necessary for Randomly Assigned Task Scheduling.", e);
} }
//This is done so that sub class extending this abstract class is forced to specify a task name.
taskName = getTaskName();
setup(); setup();
} }
@ -57,15 +53,15 @@ public abstract class RandomlyAssignedScheduleTask implements Task {
if (dynamicTaskEnabled) { if (dynamicTaskEnabled) {
try { try {
qualifiedToExecuteTask = DeviceManagementDataHolder.getInstance().getHeartBeatService().isQualifiedToExecuteTask(); qualifiedToExecuteTask = DeviceManagementDataHolder.getInstance().getHeartBeatService().isQualifiedToExecuteTask();
log.info("## NODE Qualified to execute Randomly Assigned Task : " + taskName);
DeviceManagementDataHolder.getInstance().getHeartBeatService().updateTaskExecutionAcknowledgement(taskName);
} catch (HeartBeatManagementException e) { } catch (HeartBeatManagementException e) {
log.error("Error refreshing Variables necessary for Randomly Assigned Scheduled Task. " + log.error("Error refreshing variables necessary for " +
"Dynamic Tasks will not function.", e); "Randomly Assigned Scheduled Task: " + getTaskName(), e);
} }
} else { } else {
qualifiedToExecuteTask = true; qualifiedToExecuteTask = true;
} }
log.info("Node is " + (qualifiedToExecuteTask ? "" : "not")
+ " qualified to execute Randomly Assigned Task : " + getTaskName());
} }
protected abstract void setup(); protected abstract void setup();

@ -147,7 +147,7 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating task list of elected server : '" + String msg = "Error occurred while updating task list of elected server : '" +
uuid + "' and task list " + taskList; uuid + "' and task list " + taskList;
log.error(msg, e); log.error(msg, e);
throw new HeartBeatDAOException(msg, e); throw new HeartBeatDAOException(msg, e);
} }

@ -151,7 +151,7 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
if (candidate != null && candidate.getServerUUID().equalsIgnoreCase(localServerUUID)) { if (candidate != null && candidate.getServerUUID().equalsIgnoreCase(localServerUUID)) {
isQualified = true; isQualified = true;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Node : " + localServerUUID + " Qualified to execute randomly assigned task."); log.debug("Node : " + localServerUUID + " is qualified to execute randomly assigned task.");
} }
} }
} catch (HeartBeatDAOException e) { } catch (HeartBeatDAOException e) {

@ -385,7 +385,6 @@ public class TaskManagementServiceImpl implements TaskManagementService {
dynamicTask.setProperties(dynamicTaskPropDAO.getDynamicTaskProps(dynamicTask.getDynamicTaskId(), dynamicTask.setProperties(dynamicTaskPropDAO.getDynamicTaskProps(dynamicTask.getDynamicTaskId(),
tenantId)); tenantId));
} }
TaskManagementDAOFactory.commitTransaction();
} catch (TaskManagementDAOException e) { } catch (TaskManagementDAOException e) {
String msg = "Error occurred while fetching dynamic task '" + dynamicTaskId + "'"; String msg = "Error occurred while fetching dynamic task '" + dynamicTaskId + "'";
log.error(msg, e); log.error(msg, e);

@ -894,6 +894,12 @@
<version>${jaxb.api.version}</version> <version>${jaxb.api.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1.wso2v1</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.axis2.transport</groupId> <groupId>org.apache.axis2.transport</groupId>

Loading…
Cancel
Save