Optimize based on review comments

Bug#10930
Charitha Goonetilleke 9 months ago
parent 5d69d08100
commit d2ad8ac579

@ -64,7 +64,7 @@ public class OperationTimeoutTask extends RandomlyAssignedScheduleTask {
@Override @Override
protected void executeRandomlyAssignedTask() { protected void executeRandomlyAssignedTask() {
// this task will run only in one node when the deployment has multiple nodes // this task will run only in one node when the deployment has multiple nodes
String operationTimeoutTaskConfigStr = getProperty( String operationTimeoutTaskConfigStr = getProperty(
OperationTimeoutTaskManagerServiceImpl.OPERATION_TIMEOUT_TASK_CONFIG); OperationTimeoutTaskManagerServiceImpl.OPERATION_TIMEOUT_TASK_CONFIG);
Gson gson = new Gson(); Gson gson = new Gson();
@ -89,22 +89,22 @@ public class OperationTimeoutTask extends RandomlyAssignedScheduleTask {
List<Activity> activities = DeviceManagementDataHolder.getInstance().getOperationManager() List<Activity> activities = DeviceManagementDataHolder.getInstance().getOperationManager()
.getActivities(deviceTypes, operationTimeoutConfig.getCode(), timeMillis, .getActivities(deviceTypes, operationTimeoutConfig.getCode(), timeMillis,
operationTimeoutConfig.getInitialStatus()); operationTimeoutConfig.getInitialStatus());
String operationId;
Operation operation;
for (Activity activity : activities) { for (Activity activity : activities) {
operationId = activity.getActivityId().replace("ACTIVITY_", "");
for (ActivityStatus activityStatus : activity.getActivityStatus()) { for (ActivityStatus activityStatus : activity.getActivityStatus()) {
String operationId = activity.getActivityId().replace("ACTIVITY_", ""); operation = DeviceManagementDataHolder.getInstance().getOperationManager()
Operation operation = DeviceManagementDataHolder.getInstance().getOperationManager()
.getOperation(Integer.parseInt(operationId)); .getOperation(Integer.parseInt(operationId));
operation.setStatus(Operation.Status.valueOf(operationTimeoutConfig.getNextStatus())); operation.setStatus(Operation.Status.valueOf(operationTimeoutConfig.getNextStatus()));
DeviceManagementDataHolder.getInstance().getOperationManager() DeviceManagementDataHolder.getInstance().getOperationManager()
.updateOperation(activityStatus.getDeviceIdentifier(), operation); .updateOperation(activityStatus.getDeviceIdentifier(), operation);
} }
} }
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String msg = "Error occurred while retrieving operations."; String msg = "Error occurred while retrieving operations.";
log.error(msg, e); log.error(msg, e);
} }
} }
} }

Loading…
Cancel
Save