@Test public void testGetWorkForChecking() throws Exception { String snapshot = "snapshot1"; initSnapshotMetadata(snapshot, ProcessingStatus.UNINITIALIZED); List<QueuedWork> workToCheck = _workQueueMgr.getWorkForChecking(); assertThat(workToCheck, empty()); WorkDetails.Builder builder = WorkDetails.builder() .setNetworkId(_networkId) .setSnapshotId(_idManager.getSnapshotId(snapshot, _networkId).get()) .setWorkType(WorkType.UNKNOWN); QueuedWork work1 = new QueuedWork(new WorkItem(NETWORK, snapshot), builder.build()); QueuedWork work2 = new QueuedWork(new WorkItem(NETWORK, snapshot), builder.build()); _workQueueMgr.queueUnassignedWork(work1); _workQueueMgr.queueUnassignedWork(work2); workToCheck = _workQueueMgr.getWorkForChecking(); assertThat(workToCheck, empty()); work2.setStatus(WorkStatusCode.ASSIGNED); workToCheck = _workQueueMgr.getWorkForChecking(); assertThat(workToCheck, iterableWithSize(1)); assertSame(workToCheck.get(0), work2); assertThat(work2.getStatus(), equalTo(WorkStatusCode.CHECKINGSTATUS)); workToCheck = _workQueueMgr.getWorkForChecking(); assertThat(workToCheck, empty()); work1.setStatus(WorkStatusCode.ASSIGNED); work2.setStatus(WorkStatusCode.ASSIGNED); workToCheck = _workQueueMgr.getWorkForChecking(); assertThat(workToCheck, iterableWithSize(2)); }
@Nonnull public synchronized List<QueuedWork> getWorkForChecking() { List<QueuedWork> workToCheck = new ArrayList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getStatus() == WorkStatusCode.ASSIGNED) { work.setStatus(WorkStatusCode.CHECKINGSTATUS); workToCheck.add(work); } } return workToCheck; }
WorkQueueMgr { @Nonnull public synchronized List<QueuedWork> getWorkForChecking() { List<QueuedWork> workToCheck = new ArrayList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getStatus() == WorkStatusCode.ASSIGNED) { work.setStatus(WorkStatusCode.CHECKINGSTATUS); workToCheck.add(work); } } return workToCheck; } }
WorkQueueMgr { @Nonnull public synchronized List<QueuedWork> getWorkForChecking() { List<QueuedWork> workToCheck = new ArrayList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getStatus() == WorkStatusCode.ASSIGNED) { work.setStatus(WorkStatusCode.CHECKINGSTATUS); workToCheck.add(work); } } return workToCheck; } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); }
WorkQueueMgr { @Nonnull public synchronized List<QueuedWork> getWorkForChecking() { List<QueuedWork> workToCheck = new ArrayList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getStatus() == WorkStatusCode.ASSIGNED) { work.setStatus(WorkStatusCode.CHECKINGSTATUS); workToCheck.add(work); } } return workToCheck; } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); synchronized List<QueuedWork> getCompletedWork(
      NetworkId networkId, SnapshotId snapshotId); synchronized long getLength(QueueType qType); synchronized JSONObject getStatusJson(); synchronized QueuedWork getMatchingWork(WorkItem workItem, QueueType qType); synchronized QueuedWork getWork(UUID workId); @Nullable synchronized QueuedWork getWorkForAssignment(); @Nonnull synchronized List<QueuedWork> getWorkForChecking(); synchronized List<QueuedWork> listIncompleteWork(
      NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType); synchronized void makeWorkUnassigned(QueuedWork work); synchronized void markAssignmentError(QueuedWork work); synchronized void markAssignmentFailure(QueuedWork work); synchronized void markAssignmentSuccess(QueuedWork work, String assignedWorker); synchronized void processTaskCheckResult(QueuedWork work, Task task); synchronized boolean queueUnassignedWork(QueuedWork work); }
WorkQueueMgr { @Nonnull public synchronized List<QueuedWork> getWorkForChecking() { List<QueuedWork> workToCheck = new ArrayList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getStatus() == WorkStatusCode.ASSIGNED) { work.setStatus(WorkStatusCode.CHECKINGSTATUS); workToCheck.add(work); } } return workToCheck; } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); synchronized List<QueuedWork> getCompletedWork(
      NetworkId networkId, SnapshotId snapshotId); synchronized long getLength(QueueType qType); synchronized JSONObject getStatusJson(); synchronized QueuedWork getMatchingWork(WorkItem workItem, QueueType qType); synchronized QueuedWork getWork(UUID workId); @Nullable synchronized QueuedWork getWorkForAssignment(); @Nonnull synchronized List<QueuedWork> getWorkForChecking(); synchronized List<QueuedWork> listIncompleteWork(
      NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType); synchronized void makeWorkUnassigned(QueuedWork work); synchronized void markAssignmentError(QueuedWork work); synchronized void markAssignmentFailure(QueuedWork work); synchronized void markAssignmentSuccess(QueuedWork work, String assignedWorker); synchronized void processTaskCheckResult(QueuedWork work, Task task); synchronized boolean queueUnassignedWork(QueuedWork work);  }