@Test public void listIncompleteWork() throws Exception { String snapshot = "snapshot1"; String otherNetwork = "other"; initSnapshotMetadata(snapshot, ProcessingStatus.UNINITIALIZED); Main.getWorkMgr().initNetwork(otherNetwork, null); WorkMgrTestUtils.initSnapshotWithTopology(otherNetwork, snapshot, ImmutableSet.of()); initSnapshotMetadata(otherNetwork, snapshot, ProcessingStatus.UNINITIALIZED); NetworkId otherNetworkId = _idManager.getNetworkId(otherNetwork).get(); WorkDetails.Builder builder = WorkDetails.builder().setWorkType(WorkType.UNKNOWN); QueuedWork work1 = new QueuedWork( new WorkItem(NETWORK, snapshot), builder .setNetworkId(_networkId) .setSnapshotId(_idManager.getSnapshotId(snapshot, _networkId).get()) .build()); QueuedWork work2 = new QueuedWork( new WorkItem(otherNetwork, snapshot), builder .setNetworkId(otherNetworkId) .setSnapshotId(_idManager.getSnapshotId(snapshot, otherNetworkId).get()) .build()); _workQueueMgr.queueUnassignedWork(work1); _workQueueMgr.queueUnassignedWork(work2); List<QueuedWork> works = _workQueueMgr.listIncompleteWork(_networkId, null, null); assertThat(works, equalTo(Collections.singletonList(work1))); }
public synchronized List<QueuedWork> listIncompleteWork( NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType) { List<QueuedWork> retList = new LinkedList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getDetails().getNetworkId().equals(networkId) && (snapshotId == null || work.getDetails().getSnapshotId().equals(snapshotId)) && (workType == null || work.getDetails().getWorkType() == workType)) { retList.add(work); } } return retList; }
WorkQueueMgr { public synchronized List<QueuedWork> listIncompleteWork( NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType) { List<QueuedWork> retList = new LinkedList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getDetails().getNetworkId().equals(networkId) && (snapshotId == null || work.getDetails().getSnapshotId().equals(snapshotId)) && (workType == null || work.getDetails().getWorkType() == workType)) { retList.add(work); } } return retList; } }
WorkQueueMgr { public synchronized List<QueuedWork> listIncompleteWork( NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType) { List<QueuedWork> retList = new LinkedList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getDetails().getNetworkId().equals(networkId) && (snapshotId == null || work.getDetails().getSnapshotId().equals(snapshotId)) && (workType == null || work.getDetails().getWorkType() == workType)) { retList.add(work); } } return retList; } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); }
WorkQueueMgr { public synchronized List<QueuedWork> listIncompleteWork( NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType) { List<QueuedWork> retList = new LinkedList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getDetails().getNetworkId().equals(networkId) && (snapshotId == null || work.getDetails().getSnapshotId().equals(snapshotId)) && (workType == null || work.getDetails().getWorkType() == workType)) { retList.add(work); } } return retList; } 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 { public synchronized List<QueuedWork> listIncompleteWork( NetworkId networkId, @Nullable SnapshotId snapshotId, @Nullable WorkType workType) { List<QueuedWork> retList = new LinkedList<>(); for (QueuedWork work : _queueIncompleteWork) { if (work.getDetails().getNetworkId().equals(networkId) && (snapshotId == null || work.getDetails().getSnapshotId().equals(snapshotId)) && (workType == null || work.getDetails().getWorkType() == workType)) { retList.add(work); } } return retList; } 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);  }