Search in sources :

Example 1 with WorkType

use of org.batfish.coordinator.WorkDetails.WorkType in project batfish by batfish.

the class WorkMgr method computeWorkDetails.

private WorkDetails computeWorkDetails(WorkItem workItem) {
    WorkType workType = WorkType.UNKNOWN;
    if (WorkItemBuilder.isParsingWorkItem(workItem)) {
        workType = WorkType.PARSING;
    }
    if (WorkItemBuilder.isDataplaningWorkItem(workItem)) {
        if (workType != WorkType.UNKNOWN) {
            throw new BatfishException("Cannot do composite work. Separate PARSING and DATAPLANING.");
        }
        workType = WorkType.DATAPLANING;
    }
    if (WorkItemBuilder.isAnsweringWorkItem(workItem)) {
        if (workType != WorkType.UNKNOWN) {
            throw new BatfishException("Cannot do composite work. Separate ANSWER from other work.");
        }
        String qName = WorkItemBuilder.getQuestionName(workItem);
        if (qName == null) {
            throw new BatfishException("Question name not provided for ANSWER work");
        }
        Path qFile = getpathContainerQuestion(workItem.getContainerName(), qName);
        Question question = Question.parseQuestion(qFile);
        workType = question.getIndependent() ? WorkType.INDEPENDENT_ANSWERING : question.getDataPlane() ? WorkType.DATAPLANE_DEPENDENT_ANSWERING : WorkType.PARSING_DEPENDENT_ANSWERING;
    }
    if (WorkItemBuilder.isAnalyzingWorkItem(workItem)) {
        if (workType != WorkType.UNKNOWN) {
            throw new BatfishException("Cannot do composite work. Separate ANALYZE from other work.");
        }
        String aName = WorkItemBuilder.getAnalysisName(workItem);
        if (aName == null) {
            throw new BatfishException("Analysis name not provided for ANALYZE work");
        }
        Set<String> qNames = listAnalysisQuestions(workItem.getContainerName(), aName);
        // compute the strongest dependency among the embedded questions
        workType = WorkType.INDEPENDENT_ANSWERING;
        for (String qName : qNames) {
            Path qFile = getpathAnalysisQuestion(workItem.getContainerName(), aName, qName);
            Question question = Question.parseQuestion(qFile);
            if (question.getDataPlane()) {
                workType = WorkType.DATAPLANE_DEPENDENT_ANSWERING;
                break;
            }
            if (!question.getIndependent()) {
                workType = WorkType.PARSING_DEPENDENT_ANSWERING;
            }
        }
    }
    Pair<Pair<String, String>, Pair<String, String>> settings = WorkItemBuilder.getBaseAndDeltaSettings(workItem);
    WorkDetails details = new WorkDetails(WorkItemBuilder.getBaseTestrig(settings), WorkItemBuilder.getBaseEnvironment(settings), WorkItemBuilder.getDeltaTestrig(settings), WorkItemBuilder.getDeltaEnvironment(settings), WorkItemBuilder.isDifferential(workItem), workType);
    return details;
}
Also used : Path(java.nio.file.Path) BatfishException(org.batfish.common.BatfishException) WorkType(org.batfish.coordinator.WorkDetails.WorkType) Question(org.batfish.datamodel.questions.Question) Pair(org.batfish.common.Pair)

Aggregations

Path (java.nio.file.Path)1 BatfishException (org.batfish.common.BatfishException)1 Pair (org.batfish.common.Pair)1 WorkType (org.batfish.coordinator.WorkDetails.WorkType)1 Question (org.batfish.datamodel.questions.Question)1