Search in sources :

Example 6 with EnvironmentMetadata

use of org.batfish.datamodel.EnvironmentMetadata in project batfish by batfish.

the class WorkQueueMgr method getBlockerForDataplaningWork.

private QueuedWork getBlockerForDataplaningWork(QueuedWork work) throws IOException {
    WorkItem wItem = work.getWorkItem();
    WorkDetails wDetails = work.getDetails();
    QueuedWork currentParsingWork = getIncompleteWork(wItem.getContainerName(), wDetails.baseTestrig, wDetails.baseEnv, WorkType.PARSING);
    EnvironmentMetadata envMetadata = TestrigMetadataMgr.getEnvironmentMetadata(wItem.getContainerName(), wDetails.baseTestrig, wDetails.baseEnv);
    switch(envMetadata.getProcessingStatus()) {
        case UNINITIALIZED:
        case PARSING_FAIL:
        case PARSING:
            if (currentParsingWork == null) {
                throw new BatfishException(String.format("Cannot queue dataplane work for %s / %s: " + "Status is %s but no incomplete parsing work exists", wDetails.baseTestrig, wDetails.baseEnv, envMetadata.getProcessingStatus()));
            }
            return currentParsingWork;
        case PARSED:
            return currentParsingWork;
        case DATAPLANING:
            // we get here only when currentDataplaningWork is null; by virtue of the calling context
            throw new BatfishException(String.format("Cannot queue dataplane work for %s / %s: " + "Status is %s but no incomplete dataplaning work exists", wDetails.baseTestrig, wDetails.baseEnv, envMetadata.getProcessingStatus()));
        case DATAPLANED:
        case DATAPLANING_FAIL:
            return null;
        default:
            throw new BatfishException("Unknown testrig processingStatus: " + envMetadata.getProcessingStatus());
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) WorkItem(org.batfish.common.WorkItem) EnvironmentMetadata(org.batfish.datamodel.EnvironmentMetadata)

Example 7 with EnvironmentMetadata

use of org.batfish.datamodel.EnvironmentMetadata in project batfish by batfish.

the class TestrigMetadataMgr method updateEnvironmentStatus.

public static synchronized void updateEnvironmentStatus(String container, String testrig, String envName, ProcessingStatus status, String errMessage) throws IOException {
    Path metadataPath = WorkMgr.getpathTestrigMetadata(container, testrig);
    TestrigMetadata trMetadata = readMetadata(metadataPath);
    EnvironmentMetadata environmentMetadata = trMetadata.getEnvironments().get(envName);
    environmentMetadata.updateStatus(status, errMessage);
    writeMetadata(trMetadata, metadataPath);
}
Also used : Path(java.nio.file.Path) TestrigMetadata(org.batfish.datamodel.TestrigMetadata) EnvironmentMetadata(org.batfish.datamodel.EnvironmentMetadata)

Aggregations

EnvironmentMetadata (org.batfish.datamodel.EnvironmentMetadata)7 BatfishException (org.batfish.common.BatfishException)5 WorkItem (org.batfish.common.WorkItem)5 Path (java.nio.file.Path)2 TestrigMetadata (org.batfish.datamodel.TestrigMetadata)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Task (org.batfish.common.Task)1 ProcessingStatus (org.batfish.datamodel.EnvironmentMetadata.ProcessingStatus)1 JSONException (org.codehaus.jettison.json.JSONException)1