Search in sources :

Example 11 with WorkItem

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);
    }
}
Also used : WorkItem(org.batfish.common.WorkItem)

Example 12 with WorkItem

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));
}
Also used : WorkItem(org.batfish.common.WorkItem) Test(org.junit.Test)

Example 13 with WorkItem

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);
}
Also used : WorkItem(org.batfish.common.WorkItem) Test(org.junit.Test)

Example 14 with WorkItem

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));
}
Also used : WorkItem(org.batfish.common.WorkItem)

Example 15 with WorkItem

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));
}
Also used : WorkItem(org.batfish.common.WorkItem) Test(org.junit.Test)

Aggregations

WorkItem (org.batfish.common.WorkItem)44 Test (org.junit.Test)15 BatfishException (org.batfish.common.BatfishException)14 IOException (java.io.IOException)6 EnvironmentMetadata (org.batfish.datamodel.EnvironmentMetadata)5 JSONObject (org.codehaus.jettison.json.JSONObject)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 FileNotFoundException (java.io.FileNotFoundException)3 Path (java.nio.file.Path)3 AccessControlException (java.security.AccessControlException)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 FileExistsException (org.apache.commons.io.FileExistsException)3 JSONException (org.codehaus.jettison.json.JSONException)3 LinkedList (java.util.LinkedList)2 Task (org.batfish.common.Task)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayList (java.util.ArrayList)1