use of org.openkilda.floodlight.error.SessionCloseException in project open-kilda by telstra.
the class SessionServiceTest method sessionBarrierWriteError.
@Test
public void sessionBarrierWriteError() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
setupSwitchMock(sw, dpId);
swWriteSecondFail(sw);
doneWithSetUp(sw);
CompletableFuture<Optional<OFMessage>> future = null;
try (Session session = subject.open(context, sw)) {
future = session.write(makePacketOut(sw.getOFFactory(), 1));
}
try {
future.get(1, TimeUnit.SECONDS);
Assert.fail();
} catch (ExecutionException e) {
Assert.assertNotNull(e.getCause());
Assert.assertTrue(e.getCause() instanceof SessionCloseException);
}
}
use of org.openkilda.floodlight.error.SessionCloseException in project open-kilda by telstra.
the class Session method close.
@Override
public void close() {
if (error) {
SessionRevertException e = new SessionRevertException(sw.getId());
incompleteRequestsStream().forEach(entry -> entry.completeExceptionally(e));
return;
}
if (closingBarrier != null) {
throw new IllegalStateException("Session already closed");
}
OFBarrierRequest barrier = sw.getOFFactory().barrierRequest();
closingBarrier = prepareRequest(barrier);
try {
actualWrite(barrier);
} catch (SwitchWriteException e) {
closingBarrier.completeExceptionally(e);
SessionCloseException closeError = new SessionCloseException(sw.getId());
incompleteRequestsStream().forEach(entry -> entry.completeExceptionally(closeError));
}
}
Aggregations