use of org.batfish.common.WorkItem in project batfish by batfish.
the class WorkQueueMgr method generateAndQueueDataplaneWork.
private QueuedWork generateAndQueueDataplaneWork(String container, String testrig, String environment) throws Exception {
WorkItem newWItem = WorkItemBuilder.getWorkItemGenerateDataPlane(container, testrig, environment);
WorkDetails details = new WorkDetails(testrig, environment, null, null, false, WorkType.DATAPLANING);
QueuedWork newWork = new QueuedWork(newWItem, details);
boolean queued = queueUnassignedWork(newWork);
if (!queued) {
throw new BatfishException("Failed to auto-queue dataplane work");
}
return newWork;
}
use of org.batfish.common.WorkItem 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());
}
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class Client method handleSigInt.
public void handleSigInt() {
_logger.info("Got SIGINT\n");
WorkItem wItem = _polledWorkItem;
if (wItem != null) {
_logger.outputf("Killing %s\n", wItem.getId());
boolean result = _workHelper.killWork(_polledWorkItem.getId());
_logger.outputf("Result of killing %s: %s\n", wItem.getId(), result);
} else {
_logger.output("No work being polled\n");
}
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class Client method reinitTestrig.
private boolean reinitTestrig(@Nullable FileWriter outWriter, List<String> options, List<String> parameters, boolean delta) {
Command command = delta ? Command.REINIT_DELTA_TESTRIG : Command.REINIT_TESTRIG;
if (!isValidArgument(options, parameters, 0, 0, 0, command)) {
return false;
}
String testrig;
if (!delta) {
_logger.output("Reinitializing testrig. Parsing now.\n");
testrig = _currTestrig;
} else {
_logger.output("Reinitializing delta testrig. Parsing now.\n");
testrig = _currDeltaTestrig;
}
WorkItem wItemParse = WorkItemBuilder.getWorkItemParse(_currContainerName, testrig);
if (!execute(wItemParse, outWriter)) {
return false;
}
return true;
}
use of org.batfish.common.WorkItem in project batfish by batfish.
the class Client method answerFile.
private boolean answerFile(Path questionFile, boolean isDifferential, boolean isDelta, FileWriter outWriter) {
if (!Files.exists(questionFile)) {
throw new BatfishException("Question file not found: " + questionFile);
}
String questionName = DEFAULT_QUESTION_PREFIX + "_" + UUID.randomUUID();
// upload the question
boolean resultUpload = _workHelper.uploadQuestion(_currContainerName, isDelta ? _currDeltaTestrig : _currTestrig, questionName, questionFile.toAbsolutePath().toString());
if (!resultUpload) {
return false;
}
_logger.debug("Uploaded question. Answering now.\n");
// answer the question
WorkItem wItemAs = WorkItemBuilder.getWorkItemAnswerQuestion(questionName, _currContainerName, _currTestrig, _currEnv, _currDeltaTestrig, _currDeltaEnv, isDifferential, isDelta);
return execute(wItemAs, outWriter);
}
Aggregations