Improve dynamic and random task execution

issue-10462/secure-pending-operation-6.2
Charitha Goonetilleke 9 months ago
parent 4045e39a76
commit 5d69d08100

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

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

@ -365,13 +365,6 @@
<dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
<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>
</dependency>
<dependency>

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

@ -147,7 +147,7 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
}
} catch (SQLException e) {
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);
throw new HeartBeatDAOException(msg, e);
}

@ -151,7 +151,7 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
if (candidate != null && candidate.getServerUUID().equalsIgnoreCase(localServerUUID)) {
isQualified = true;
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) {

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

@ -894,6 +894,12 @@
<version>${jaxb.api.version}</version>
<scope>test</scope>
</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>
<groupId>org.apache.axis2.transport</groupId>

Loading…
Cancel
Save