@Test public void getCompletedWork() throws Exception { String snapshot = "snapshot"; WorkMgrTestUtils.initSnapshotWithTopology(NETWORK, snapshot, ImmutableSet.of()); SnapshotId snapshot1Id = _idManager.getSnapshotId(snapshot, _networkId).get(); WorkDetails.Builder builder = WorkDetails.builder() .setNetworkId(_networkId) .setSnapshotId(snapshot1Id) .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); List<QueuedWork> works0 = _workQueueMgr.getCompletedWork(_networkId, snapshot1Id); _workQueueMgr.markAssignmentError(work1); List<QueuedWork> works1 = _workQueueMgr.getCompletedWork(_networkId, snapshot1Id); _workQueueMgr.markAssignmentError(work2); List<QueuedWork> works2 = _workQueueMgr.getCompletedWork(_networkId, snapshot1Id); assertThat(works0, iterableWithSize(0)); assertThat(works1, contains(hasWorkItem(equalTo(work1.getWorkItem())))); assertThat( works2, containsInAnyOrder( ImmutableList.of( hasWorkItem(equalTo(work1.getWorkItem())), hasWorkItem(equalTo(work2.getWorkItem()))))); }
public synchronized List<QueuedWork> getCompletedWork( NetworkId networkId, SnapshotId snapshotId) { ImmutableList.Builder<QueuedWork> b = ImmutableList.builder(); for (QueuedWork work : _queueCompletedWork) { if (work.getDetails().getNetworkId().equals(networkId) && work.getDetails().getSnapshotId().equals(snapshotId)) { b.add(work); } } return b.build(); }
WorkQueueMgr { public synchronized List<QueuedWork> getCompletedWork( NetworkId networkId, SnapshotId snapshotId) { ImmutableList.Builder<QueuedWork> b = ImmutableList.builder(); for (QueuedWork work : _queueCompletedWork) { if (work.getDetails().getNetworkId().equals(networkId) && work.getDetails().getSnapshotId().equals(snapshotId)) { b.add(work); } } return b.build(); } }
WorkQueueMgr { public synchronized List<QueuedWork> getCompletedWork( NetworkId networkId, SnapshotId snapshotId) { ImmutableList.Builder<QueuedWork> b = ImmutableList.builder(); for (QueuedWork work : _queueCompletedWork) { if (work.getDetails().getNetworkId().equals(networkId) && work.getDetails().getSnapshotId().equals(snapshotId)) { b.add(work); } } return b.build(); } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); }
WorkQueueMgr { public synchronized List<QueuedWork> getCompletedWork( NetworkId networkId, SnapshotId snapshotId) { ImmutableList.Builder<QueuedWork> b = ImmutableList.builder(); for (QueuedWork work : _queueCompletedWork) { if (work.getDetails().getNetworkId().equals(networkId) && work.getDetails().getSnapshotId().equals(snapshotId)) { b.add(work); } } return b.build(); } 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> getCompletedWork( NetworkId networkId, SnapshotId snapshotId) { ImmutableList.Builder<QueuedWork> b = ImmutableList.builder(); for (QueuedWork work : _queueCompletedWork) { if (work.getDetails().getNetworkId().equals(networkId) && work.getDetails().getSnapshotId().equals(snapshotId)) { b.add(work); } } return b.build(); } 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);  }