@Test public void convertJobSchedulingInfoToWorkerMapInvalidInputTest() { String jobName = "convertJobSchedulingInfoToWorkerMapInvalidInputTest"; String jobId = jobName + "-1"; MantisJobDurationType durationType = MantisJobDurationType.Perpetual; WorkerAssignments workerAssignmentsStage1 = createWorkerAssignments(1, 2); WorkerAssignments workerAssignmentsStage2 = createWorkerAssignments(2, 4); Map<Integer, WorkerAssignments> workerAssignmentsMap = new HashMap<>(); workerAssignmentsMap.put(1, workerAssignmentsStage1); workerAssignmentsMap.put(2, workerAssignmentsStage2); JobSchedulingInfo jobSchedulingInfo = new JobSchedulingInfo(jobId, workerAssignmentsMap); WorkerMap workerMap = WorkerExecutionOperationsNetworkStage.convertJobSchedulingInfoToWorkerMap(null, jobId, durationType, jobSchedulingInfo); assertTrue(workerMap.isEmpty()); workerMap = WorkerExecutionOperationsNetworkStage.convertJobSchedulingInfoToWorkerMap(jobName, null, durationType, jobSchedulingInfo); assertTrue(workerMap.isEmpty()); workerMap = WorkerExecutionOperationsNetworkStage.convertJobSchedulingInfoToWorkerMap(jobName, jobId, durationType, null); assertTrue(workerMap.isEmpty()); jobSchedulingInfo = new JobSchedulingInfo(jobId, null); workerMap = WorkerExecutionOperationsNetworkStage.convertJobSchedulingInfoToWorkerMap(jobName, jobId, durationType, jobSchedulingInfo); assertTrue(workerMap.isEmpty()); workerAssignmentsMap = new HashMap<>(); workerAssignmentsMap.put(1, null); workerAssignmentsMap.put(2, workerAssignmentsStage2); jobSchedulingInfo = new JobSchedulingInfo(jobId, workerAssignmentsMap); workerMap = WorkerExecutionOperationsNetworkStage.convertJobSchedulingInfoToWorkerMap(jobName, jobId, durationType, jobSchedulingInfo); assertTrue(workerMap.isEmpty()); }
static WorkerMap convertJobSchedulingInfoToWorkerMap(String jobName, String jobId, MantisJobDurationType durationType, JobSchedulingInfo js) { Map<Integer, List<WorkerInfo>> stageToWorkerInfoMap = new HashMap<>(); WorkerMap workerMap = new WorkerMap(stageToWorkerInfoMap); if (jobName == null || jobName.isEmpty() || jobId == null || jobId.isEmpty()) { logger.warn("Job name/jobId cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } if (js == null || js.getWorkerAssignments() == null) { logger.warn("JobSchedulingInfo or workerAssignments cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } try { Map<Integer, WorkerAssignments> workerAssignments = js.getWorkerAssignments(); Iterator<Map.Entry<Integer, WorkerAssignments>> entryIterator = workerAssignments.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, WorkerAssignments> next = entryIterator.next(); int stageNo = next.getKey(); WorkerAssignments workerAssignmentsForStage = next.getValue(); Map<Integer, WorkerHost> hosts = workerAssignmentsForStage.getHosts(); if (hosts != null) { List<WorkerInfo> workerInfoList = hosts.values().stream().map((workerHost) -> { return generateWorkerInfo(jobName, jobId, stageNo, workerHost.getWorkerIndex(), workerHost.getWorkerNumber(), durationType, workerHost.getHost(), workerHost); }).collect(Collectors.toList()); stageToWorkerInfoMap.put(stageNo, workerInfoList); } } workerMap = new WorkerMap(stageToWorkerInfoMap); } catch (Exception e) { logger.warn("Exception converting JobSchedulingInfo " + js + " to worker Map " + e.getMessage()); return workerMap; } return workerMap; }
WorkerExecutionOperationsNetworkStage implements WorkerExecutionOperations { static WorkerMap convertJobSchedulingInfoToWorkerMap(String jobName, String jobId, MantisJobDurationType durationType, JobSchedulingInfo js) { Map<Integer, List<WorkerInfo>> stageToWorkerInfoMap = new HashMap<>(); WorkerMap workerMap = new WorkerMap(stageToWorkerInfoMap); if (jobName == null || jobName.isEmpty() || jobId == null || jobId.isEmpty()) { logger.warn("Job name/jobId cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } if (js == null || js.getWorkerAssignments() == null) { logger.warn("JobSchedulingInfo or workerAssignments cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } try { Map<Integer, WorkerAssignments> workerAssignments = js.getWorkerAssignments(); Iterator<Map.Entry<Integer, WorkerAssignments>> entryIterator = workerAssignments.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, WorkerAssignments> next = entryIterator.next(); int stageNo = next.getKey(); WorkerAssignments workerAssignmentsForStage = next.getValue(); Map<Integer, WorkerHost> hosts = workerAssignmentsForStage.getHosts(); if (hosts != null) { List<WorkerInfo> workerInfoList = hosts.values().stream().map((workerHost) -> { return generateWorkerInfo(jobName, jobId, stageNo, workerHost.getWorkerIndex(), workerHost.getWorkerNumber(), durationType, workerHost.getHost(), workerHost); }).collect(Collectors.toList()); stageToWorkerInfoMap.put(stageNo, workerInfoList); } } workerMap = new WorkerMap(stageToWorkerInfoMap); } catch (Exception e) { logger.warn("Exception converting JobSchedulingInfo " + js + " to worker Map " + e.getMessage()); return workerMap; } return workerMap; } }
WorkerExecutionOperationsNetworkStage implements WorkerExecutionOperations { static WorkerMap convertJobSchedulingInfoToWorkerMap(String jobName, String jobId, MantisJobDurationType durationType, JobSchedulingInfo js) { Map<Integer, List<WorkerInfo>> stageToWorkerInfoMap = new HashMap<>(); WorkerMap workerMap = new WorkerMap(stageToWorkerInfoMap); if (jobName == null || jobName.isEmpty() || jobId == null || jobId.isEmpty()) { logger.warn("Job name/jobId cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } if (js == null || js.getWorkerAssignments() == null) { logger.warn("JobSchedulingInfo or workerAssignments cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } try { Map<Integer, WorkerAssignments> workerAssignments = js.getWorkerAssignments(); Iterator<Map.Entry<Integer, WorkerAssignments>> entryIterator = workerAssignments.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, WorkerAssignments> next = entryIterator.next(); int stageNo = next.getKey(); WorkerAssignments workerAssignmentsForStage = next.getValue(); Map<Integer, WorkerHost> hosts = workerAssignmentsForStage.getHosts(); if (hosts != null) { List<WorkerInfo> workerInfoList = hosts.values().stream().map((workerHost) -> { return generateWorkerInfo(jobName, jobId, stageNo, workerHost.getWorkerIndex(), workerHost.getWorkerNumber(), durationType, workerHost.getHost(), workerHost); }).collect(Collectors.toList()); stageToWorkerInfoMap.put(stageNo, workerInfoList); } } workerMap = new WorkerMap(stageToWorkerInfoMap); } catch (Exception e) { logger.warn("Exception converting JobSchedulingInfo " + js + " to worker Map " + e.getMessage()); return workerMap; } return workerMap; } WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi, WorkerConfiguration config);  WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi,
                                                 WorkerConfiguration config,
                                                 WorkerMetricsClient workerMetricsClient); }
WorkerExecutionOperationsNetworkStage implements WorkerExecutionOperations { static WorkerMap convertJobSchedulingInfoToWorkerMap(String jobName, String jobId, MantisJobDurationType durationType, JobSchedulingInfo js) { Map<Integer, List<WorkerInfo>> stageToWorkerInfoMap = new HashMap<>(); WorkerMap workerMap = new WorkerMap(stageToWorkerInfoMap); if (jobName == null || jobName.isEmpty() || jobId == null || jobId.isEmpty()) { logger.warn("Job name/jobId cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } if (js == null || js.getWorkerAssignments() == null) { logger.warn("JobSchedulingInfo or workerAssignments cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } try { Map<Integer, WorkerAssignments> workerAssignments = js.getWorkerAssignments(); Iterator<Map.Entry<Integer, WorkerAssignments>> entryIterator = workerAssignments.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, WorkerAssignments> next = entryIterator.next(); int stageNo = next.getKey(); WorkerAssignments workerAssignmentsForStage = next.getValue(); Map<Integer, WorkerHost> hosts = workerAssignmentsForStage.getHosts(); if (hosts != null) { List<WorkerInfo> workerInfoList = hosts.values().stream().map((workerHost) -> { return generateWorkerInfo(jobName, jobId, stageNo, workerHost.getWorkerIndex(), workerHost.getWorkerNumber(), durationType, workerHost.getHost(), workerHost); }).collect(Collectors.toList()); stageToWorkerInfoMap.put(stageNo, workerInfoList); } } workerMap = new WorkerMap(stageToWorkerInfoMap); } catch (Exception e) { logger.warn("Exception converting JobSchedulingInfo " + js + " to worker Map " + e.getMessage()); return workerMap; } return workerMap; } WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi, WorkerConfiguration config);  WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi,
                                                 WorkerConfiguration config,
                                                 WorkerMetricsClient workerMetricsClient); @SuppressWarnings( {"rawtypes", "unchecked"}) @Override void executeStage(final ExecutionDetails setup); @Override void shutdownStage(); }
WorkerExecutionOperationsNetworkStage implements WorkerExecutionOperations { static WorkerMap convertJobSchedulingInfoToWorkerMap(String jobName, String jobId, MantisJobDurationType durationType, JobSchedulingInfo js) { Map<Integer, List<WorkerInfo>> stageToWorkerInfoMap = new HashMap<>(); WorkerMap workerMap = new WorkerMap(stageToWorkerInfoMap); if (jobName == null || jobName.isEmpty() || jobId == null || jobId.isEmpty()) { logger.warn("Job name/jobId cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } if (js == null || js.getWorkerAssignments() == null) { logger.warn("JobSchedulingInfo or workerAssignments cannot be null in convertJobSchedulingInfoToWorkerMap"); return workerMap; } try { Map<Integer, WorkerAssignments> workerAssignments = js.getWorkerAssignments(); Iterator<Map.Entry<Integer, WorkerAssignments>> entryIterator = workerAssignments.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, WorkerAssignments> next = entryIterator.next(); int stageNo = next.getKey(); WorkerAssignments workerAssignmentsForStage = next.getValue(); Map<Integer, WorkerHost> hosts = workerAssignmentsForStage.getHosts(); if (hosts != null) { List<WorkerInfo> workerInfoList = hosts.values().stream().map((workerHost) -> { return generateWorkerInfo(jobName, jobId, stageNo, workerHost.getWorkerIndex(), workerHost.getWorkerNumber(), durationType, workerHost.getHost(), workerHost); }).collect(Collectors.toList()); stageToWorkerInfoMap.put(stageNo, workerInfoList); } } workerMap = new WorkerMap(stageToWorkerInfoMap); } catch (Exception e) { logger.warn("Exception converting JobSchedulingInfo " + js + " to worker Map " + e.getMessage()); return workerMap; } return workerMap; } WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi, WorkerConfiguration config);  WorkerExecutionOperationsNetworkStage(Observer<VirtualMachineTaskStatus> vmTaskStatusObserver,
                                                 MantisMasterClientApi mantisMasterApi,
                                                 WorkerConfiguration config,
                                                 WorkerMetricsClient workerMetricsClient); @SuppressWarnings( {"rawtypes", "unchecked"}) @Override void executeStage(final ExecutionDetails setup); @Override void shutdownStage();  }