| @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; | |||
| import javax.annotation.Resource; | |||
| import java.util.ArrayList; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| @@ -31,7 +32,7 @@ public class ActiveLearnInsStatusTask { | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| private List<Long> activeLearnIds = new ArrayList<>(); | |||
| private HashSet<Long> activeLearnIds = new HashSet<>(); | |||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||
| public void executeActiveLearnInsStatus() { | |||
| @@ -76,14 +77,16 @@ public class ActiveLearnInsStatusTask { | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||
| public void executeActiveLearnStatus() { | |||
| if (activeLearnIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<ActiveLearn> updateActiveLearns = new ArrayList<>(); | |||
| for (Long activeLearnId : activeLearnIds) { | |||
| Iterator<Long> iterator1 = activeLearnIds.iterator(); | |||
| while (iterator1.hasNext()) { | |||
| Long activeLearnId = iterator1.next(); | |||
| // 获取当前实验的所有实例列表 | |||
| List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| @@ -93,10 +96,14 @@ public class ActiveLearnInsStatusTask { | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); | |||
| if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { | |||
| activeLearn.setStatusList(subStatus); | |||
| updateActiveLearns.add(activeLearn); | |||
| activeLearnDao.edit(activeLearn); | |||
| if (activeLearn == null) { | |||
| iterator1.remove(); | |||
| } else { | |||
| if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { | |||
| activeLearn.setStatusList(subStatus); | |||
| updateActiveLearns.add(activeLearn); | |||
| activeLearnDao.edit(activeLearn); | |||
| } | |||
| } | |||
| } | |||
| @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; | |||
| import javax.annotation.Resource; | |||
| import java.util.ArrayList; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| @@ -27,7 +28,7 @@ public class AutoMlInsStatusTask { | |||
| @Resource | |||
| private AutoMlDao autoMlDao; | |||
| private List<Long> autoMlIds = new ArrayList<>(); | |||
| private HashSet<Long> autoMlIds = new HashSet<>(); | |||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||
| public void executeAutoMlInsStatus() { | |||
| @@ -58,14 +59,17 @@ public class AutoMlInsStatusTask { | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||
| public void executeAutoMlStatus() { | |||
| if (autoMlIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<AutoMl> updateAutoMls = new ArrayList<>(); | |||
| for (Long autoMlId : autoMlIds) { | |||
| Iterator<Long> iterator1 = autoMlIds.iterator(); | |||
| while (iterator1.hasNext()) { | |||
| Long autoMlId = iterator1.next(); | |||
| // 获取当前实验的所有实例列表 | |||
| List<AutoMlIns> insList = autoMlInsDao.getByAutoMlId(autoMlId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| @@ -75,10 +79,14 @@ public class AutoMlInsStatusTask { | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); | |||
| if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { | |||
| autoMl.setStatusList(subStatus); | |||
| updateAutoMls.add(autoMl); | |||
| autoMlDao.edit(autoMl); | |||
| if (autoMl == null) { | |||
| iterator1.remove(); | |||
| } else { | |||
| if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { | |||
| autoMl.setStatusList(subStatus); | |||
| updateAutoMls.add(autoMl); | |||
| autoMlDao.edit(autoMl); | |||
| } | |||
| } | |||
| } | |||
| @@ -34,7 +34,7 @@ public class ExperimentInstanceStatusTask { | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| private List<Integer> experimentIds = new ArrayList<>(); | |||
| private HashSet<Integer> experimentIds = new HashSet<>(); | |||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||
| public void executeExperimentInsStatus() throws Exception { | |||
| @@ -141,14 +141,17 @@ public class ExperimentInstanceStatusTask { | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||
| public void executeExperimentStatus() throws IOException { | |||
| if (experimentIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<Experiment> updateExperiments = new ArrayList<>(); | |||
| for (Integer experimentId : experimentIds) { | |||
| Iterator<Integer> iterator1 = experimentIds.iterator(); | |||
| while (iterator1.hasNext()) { | |||
| Integer experimentId = iterator1.next(); | |||
| // 获取当前实验的所有实例列表 | |||
| List<ExperimentIns> insList = experimentInsService.getByExperimentId(experimentId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| @@ -158,10 +161,14 @@ public class ExperimentInstanceStatusTask { | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| Experiment experiment = experimentDao.queryById(experimentId); | |||
| // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 | |||
| if (!StringUtils.equals(subStatus, experiment.getStatusList())) { | |||
| experiment.setStatusList(subStatus); | |||
| updateExperiments.add(experiment); | |||
| if (experiment == null) { | |||
| iterator1.remove(); | |||
| } else { | |||
| // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 | |||
| if (!StringUtils.equals(subStatus, experiment.getStatusList())) { | |||
| experiment.setStatusList(subStatus); | |||
| updateExperiments.add(experiment); | |||
| } | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; | |||
| import javax.annotation.Resource; | |||
| import java.util.ArrayList; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| @@ -29,7 +30,7 @@ public class MLStatusTask { | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| private List<Long> machineLearnIds = new ArrayList<>(); | |||
| private HashSet<Long> machineLearnIds = new HashSet<>(); | |||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||
| public void executeMachineLearnInsStatus() { | |||
| @@ -80,14 +81,17 @@ public class MLStatusTask { | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||
| public void executeMachineLearn() { | |||
| if (machineLearnIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<MachineLearn> updateMLs = new ArrayList<>(); | |||
| for (Long machineLearnId : machineLearnIds) { | |||
| Iterator<Long> iterator1 = machineLearnIds.iterator(); | |||
| while (iterator1.hasNext()) { | |||
| Long machineLearnId = iterator1.next(); | |||
| // 获取当前实验的所有实例列表 | |||
| List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearnId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| @@ -97,10 +101,14 @@ public class MLStatusTask { | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId); | |||
| if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { | |||
| machineLearn.setStatusList(subStatus); | |||
| updateMLs.add(machineLearn); | |||
| machineLearnDao.edit(machineLearn); | |||
| if (machineLearn == null) { | |||
| iterator1.remove(); | |||
| } else { | |||
| if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { | |||
| machineLearn.setStatusList(subStatus); | |||
| updateMLs.add(machineLearn); | |||
| machineLearnDao.edit(machineLearn); | |||
| } | |||
| } | |||
| } | |||
| @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; | |||
| import javax.annotation.Resource; | |||
| import java.util.ArrayList; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| @@ -31,7 +32,7 @@ public class RayInsStatusTask { | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| private List<Long> rayIds = new ArrayList<>(); | |||
| private HashSet<Long> rayIds = new HashSet<>(); | |||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||
| public void executeRayInsStatus() { | |||
| @@ -76,14 +77,17 @@ public class RayInsStatusTask { | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||
| public void executeRayStatus() { | |||
| if (rayIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<Ray> updateRays = new ArrayList<>(); | |||
| for (Long rayId : rayIds) { | |||
| Iterator<Long> iterator1 = rayIds.iterator(); | |||
| while (iterator1.hasNext()) { | |||
| Long rayId = iterator1.next(); | |||
| // 获取当前实验的所有实例列表 | |||
| List<RayIns> insList = rayInsDao.getByRayId(rayId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| @@ -93,10 +97,14 @@ public class RayInsStatusTask { | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| Ray ray = rayDao.getRayById(rayId); | |||
| if (!StringUtils.equals(ray.getStatusList(), subStatus)) { | |||
| ray.setStatusList(subStatus); | |||
| updateRays.add(ray); | |||
| rayDao.edit(ray); | |||
| if (ray == null) { | |||
| iterator1.remove(); | |||
| } else { | |||
| if (!StringUtils.equals(ray.getStatusList(), subStatus)) { | |||
| ray.setStatusList(subStatus); | |||
| updateRays.add(ray); | |||
| rayDao.edit(ray); | |||
| } | |||
| } | |||
| } | |||