use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project batfish by batfish.
the class NodJobTest method testNotNattedUnsat.
/**
* Test that traffic originating from 3.0.0.1 that is expected NOT to be NATed returns UNSAT when
* we constrain to only allow NATed results.
*/
@Test
public void testNotNattedUnsat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.1")));
NodJob nodJob = getNodJob(headerSpace, true);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.UNSATISFIABLE));
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project batfish by batfish.
the class NodJobTest method testNattedSat.
/**
* Test that traffic originating from 3.0.0.0 that is expected to be NATed returns SAT when we
* constrain to only allow NATed results.
*/
@Test
public void testNattedSat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.0")));
NodJob nodJob = getNodJob(headerSpace, true);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.SATISFIABLE));
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project batfish by batfish.
the class NodJob method computeNodSat.
protected Status computeNodSat(long startTime, Context ctx) {
NodProgram program = getNodProgram(ctx);
Fixedpoint fix = mkFixedpoint(program, true);
for (BoolExpr query : program.getQueries()) {
Status status = fix.query(query);
switch(status) {
case SATISFIABLE:
return status;
case UNKNOWN:
throw new BatfishException("Query satisfiability unknown");
case UNSATISFIABLE:
return status;
default:
throw new BatfishException("invalid status");
}
}
throw new BatfishException("No queries");
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project bmoth by hhu-stups.
the class ExplicitStateModelChecker method doModelCheck.
@Override
protected ModelCheckingResult doModelCheck() {
final int maxInitialStates = BMothPreferences.getIntPreference(BMothPreferences.IntPreference.MAX_INITIAL_STATE);
final int maxTransitions = BMothPreferences.getIntPreference(BMothPreferences.IntPreference.MAX_TRANSITIONS);
stateSpace = new StateSpace();
visited = new HashSet<>();
Queue<State> queue = new LinkedList<>();
// prepare initial states
BoolExpr initialValueConstraint = getMachineTranslator().getInitialValueConstraint();
Set<Model> models = finder.findSolutions(initialValueConstraint, maxInitialStates);
models.stream().map(this::getStateFromModel).filter(this::isUnknown).forEach(root -> {
stateSpace.addRootVertex(root);
queue.add(root);
});
final BoolExpr invariant = getMachineTranslator().getInvariantConstraint();
solver.add(invariant);
// create joint operations constraint and permanently add to separate
// solver
final BoolExpr operationsConstraint = getMachineTranslator().getCombinedOperationConstraint();
opSolver.add(operationsConstraint);
while (!isAborted() && !queue.isEmpty()) {
solver.push();
State current = queue.poll();
visited.add(current);
// apply current state - remains stored in solver for loop iteration
BoolExpr stateConstraint = current.getStateConstraint(getContext());
solver.add(stateConstraint);
// check invariant & state
Status check = solver.check();
switch(check) {
case UNKNOWN:
return createUnknown(visited.size(), solver.getReasonUnknown());
case UNSATISFIABLE:
return createCounterExampleFound(visited.size(), current, stateSpace);
case SATISFIABLE:
default:
}
// compute successors on separate finder
models = opFinder.findSolutions(stateConstraint, maxTransitions);
models.stream().map(this::getStateFromModel).forEach(successor -> {
if (isUnknown(successor)) {
stateSpace.addVertex(successor);
queue.add(successor);
}
stateSpace.addEdge(current, successor);
});
solver.pop();
}
if (isAborted()) {
return createAborted(visited.size());
} else {
ModelCheckingResult resultVerified = createVerified(visited.size(), stateSpace);
if (buechiAutomaton != null) {
// do ltl model check
labelStateSpace();
List<List<State>> cycles = new TarjanSimpleCycles<>(stateSpace).findSimpleCycles();
for (List<State> cycle : cycles) {
// if there is an accepting Buechi state in the cycle, a counterexample is found
for (State state : cycle) {
if (buechiAutomaton.isAcceptingSet(state.getBuechiNodes())) {
return createLTLCounterExampleFound(visited.size(), state);
}
}
}
}
return resultVerified;
}
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project UniversalMediaServer by UniversalMediaServer.
the class ChromecastPlayer method startPoll.
public void startPoll() {
Runnable r = new Runnable() {
@Override
public void run() {
for (; ; ) {
try {
Thread.sleep(1000);
Status s1 = api.getStatus();
if (s1 == null || !s1.isAppRunning(MediaPlayer)) {
continue;
}
MediaStatus status = api.getMediaStatus();
if (status == null) {
continue;
}
state.playback = translateState(status.playerState);
Media m = status.media;
if (m != null) {
if (m.url != null) {
state.uri = status.media.url;
}
if (m.duration != null) {
state.duration = StringUtil.convertTimeToString(status.media.duration, "%02d:%02d:%02.0f");
}
}
state.position = StringUtil.convertTimeToString(status.currentTime, "%02d:%02d:%02.0f");
if (status.volume != null) {
state.volume = status.volume.level.intValue();
state.mute = status.volume.muted;
}
alert();
} catch (InterruptedException | IOException e) {
LOGGER.debug("Bad chromecast mediastate " + e);
}
}
}
};
poller = new Thread(r);
poller.start();
}
Aggregations