use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkQueueMgr method markAssignmentSuccess.
public synchronized void markAssignmentSuccess(QueuedWork work, String assignedWorker) throws IOException {
work.setAssignment(assignedWorker);
// update testrig metadata
WorkItem wItem = work.getWorkItem();
WorkDetails wDetails = work.getDetails();
if (wDetails.workType == WorkType.PARSING) {
TestrigMetadataMgr.updateEnvironmentStatus(wItem.getContainerName(), wDetails.baseTestrig, wDetails.baseEnv, ProcessingStatus.PARSING, null);
} else if (wDetails.workType == WorkType.DATAPLANING) {
TestrigMetadataMgr.updateEnvironmentStatus(wItem.getContainerName(), wDetails.baseTestrig, wDetails.baseEnv, ProcessingStatus.DATAPLANING, null);
}
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkMgrTest method testGetAutoWorkQueueUserAnalysis.
@Test
public void testGetAutoWorkQueueUserAnalysis() {
String containerName = "myContainer";
String testrigName = "myTestrig";
_manager.initContainer(containerName, null);
// user policy
_manager.configureAnalysis(containerName, true, "useranalysis", Maps.newHashMap(), Lists.newArrayList(), false);
WorkItem parseWorkItem = WorkItemBuilder.getWorkItemParse(containerName, testrigName);
WorkItem analysisWorkItem = WorkItemBuilder.getWorkItemRunAnalysis("useranalysis", containerName, testrigName, BfConsts.RELPATH_DEFAULT_ENVIRONMENT_NAME, null, null, false, false);
List<WorkItem> workQueue = _manager.getAutoWorkQueue(containerName, testrigName);
assertThat(workQueue, hasSize(2));
// checking that the first work item is for parse
assertThat(workQueue.get(0).matches(parseWorkItem), equalTo(true));
// checking run analysis workitem
assertThat("Work Queue not correct for user analyses", workQueue.get(1).matches(analysisWorkItem), equalTo(true));
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkQueueMgrTest method queueUnassignedWorkDuplicate.
@Test
public void queueUnassignedWorkDuplicate() throws Exception {
initTestrigMetadata("testrig", "env", ProcessingStatus.UNINITIALIZED);
QueuedWork work1 = new QueuedWork(new WorkItem(CONTAINER, "testrig"), new WorkDetails("testrig", "env", WorkType.UNKNOWN));
_workQueueMgr.queueUnassignedWork(work1);
_thrown.expect(BatfishException.class);
_thrown.expectMessage("Duplicate work item");
_workQueueMgr.queueUnassignedWork(work1);
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkQueueMgrTest method workIsQueued.
private void workIsQueued(ProcessingStatus baseTrStatus, ProcessingStatus deltaTrStatus, WorkType wType, WorkStatusCode qwStatus, long queueLength) throws Exception {
initTestrigMetadata(BASE_TESTRIG, BASE_ENV, baseTrStatus);
initTestrigMetadata(DELTA_TESTRIG, DELTA_ENV, deltaTrStatus);
QueuedWork work = new QueuedWork(new WorkItem(CONTAINER, BASE_TESTRIG), new WorkDetails(BASE_TESTRIG, BASE_ENV, DELTA_TESTRIG, DELTA_ENV, true, wType));
doAction(new Action(ActionType.QUEUE, work));
assertThat(work.getStatus(), equalTo(qwStatus));
assertThat(_workQueueMgr.getLength(QueueType.INCOMPLETE), equalTo(queueLength));
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkQueueMgrTest method workIsUnblocked1.
@Test
public void workIsUnblocked1() throws Exception {
initTestrigMetadata("testrig", "env_default", ProcessingStatus.UNINITIALIZED);
QueuedWork work1 = new QueuedWork(new WorkItem(CONTAINER, "testrig"), new WorkDetails("testrig", "env_default", WorkType.PARSING));
QueuedWork work2 = new QueuedWork(new WorkItem(CONTAINER, "testrig"), new WorkDetails("testrig", "env_default", WorkType.PARSING_DEPENDENT_ANSWERING));
QueuedWork work3 = new QueuedWork(new WorkItem(CONTAINER, "testrig"), new WorkDetails("testrig", "env_default", WorkType.DATAPLANE_DEPENDENT_ANSWERING));
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 = // should be parsing work
doAction(new Action(ActionType.ASSIGN_SUCCESS, null));
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));
}
Aggregations