@Test public void workIsUnblocked1() throws Exception { String snapshot = "snapshot1"; initSnapshotMetadata(snapshot, ProcessingStatus.UNINITIALIZED); SnapshotId snapshotId = _idManager.getSnapshotId(snapshot, _networkId).get(); WorkDetails.Builder builder = WorkDetails.builder().setNetworkId(_networkId).setSnapshotId(snapshotId); QueuedWork work1 = new QueuedWork( new WorkItem(NETWORK, snapshot), builder.setWorkType(WorkType.PARSING).build()); QueuedWork work2 = new QueuedWork( new WorkItem(NETWORK, snapshot), builder.setWorkType(WorkType.PARSING_DEPENDENT_ANSWERING).build()); QueuedWork work3 = new QueuedWork( new WorkItem(NETWORK, snapshot), builder.setWorkType(WorkType.DATAPLANE_DEPENDENT_ANSWERING).build()); doAction(new Action(ActionType.QUEUE, work1)); doAction(new Action(ActionType.QUEUE, work2)); doAction(new Action(ActionType.QUEUE, work3)); assertThat(work2.getStatus(), equalTo(WorkStatusCode.BLOCKED)); assertThat(work3.getStatus(), equalTo(WorkStatusCode.BLOCKED)); QueuedWork aWork1 = doAction(new Action(ActionType.ASSIGN_SUCCESS, null)); Main.getWorkMgr() .getStorage() .storeNodeRoles( NodeRolesData.builder().build(), _idManager.getSnapshotNodeRolesId(_networkId, snapshotId)); doAction(new Action(ActionType.STATUS_TERMINATED_NORMALLY, aWork1)); QueuedWork aWork2 = doAction(new Action(ActionType.ASSIGN_SUCCESS, null)); doAction(new Action(ActionType.STATUS_TERMINATED_NORMALLY, aWork2)); QueuedWork aWork3 = doAction(new Action(ActionType.ASSIGN_SUCCESS, null)); doAction(new Action(ActionType.STATUS_TERMINATED_NORMALLY, aWork3)); QueuedWork aWork4 = doAction(new Action(ActionType.ASSIGN_SUCCESS, null)); doAction(new Action(ActionType.STATUS_TERMINATED_NORMALLY, aWork4)); assertThat(_workQueueMgr.getLength(QueueType.INCOMPLETE), equalTo(0L)); }
public synchronized long getLength(QueueType qType) { switch (qType) { case COMPLETED: return _queueCompletedWork.getLength(); case INCOMPLETE: return _queueIncompleteWork.getLength(); default: return -1; } }
WorkQueueMgr { public synchronized long getLength(QueueType qType) { switch (qType) { case COMPLETED: return _queueCompletedWork.getLength(); case INCOMPLETE: return _queueIncompleteWork.getLength(); default: return -1; } } }
WorkQueueMgr { public synchronized long getLength(QueueType qType) { switch (qType) { case COMPLETED: return _queueCompletedWork.getLength(); case INCOMPLETE: return _queueIncompleteWork.getLength(); default: return -1; } } WorkQueueMgr(BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager);   WorkQueueMgr(Type wqType, BatfishLogger logger, SnapshotMetadataMgr snapshotMetadataManager); }
WorkQueueMgr { public synchronized long getLength(QueueType qType) { switch (qType) { case COMPLETED: return _queueCompletedWork.getLength(); case INCOMPLETE: return _queueIncompleteWork.getLength(); default: return -1; } } 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 long getLength(QueueType qType) { switch (qType) { case COMPLETED: return _queueCompletedWork.getLength(); case INCOMPLETE: return _queueIncompleteWork.getLength(); default: return -1; } } 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);  }