- if (null == nodeId){
- SessionStatistics.countEvent(connectionAdapter.getRemoteAddress().toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
- } else {
- SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
- }
- final BigInteger datapathId = featuresReply != null ? featuresReply.getDatapathId() : BigInteger.ZERO;
- LOG.debug("Actively closing connection: {}, datapathId: {}",
- connectionAdapter.getRemoteAddress(), datapathId);
- connectionState = ConnectionContext.CONNECTION_STATE.RIP;
-
- Future<Void> future = Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- unregisterOutboundQueue();
- return null;
- }
- });
- try {
- future.get(1, TimeUnit.SECONDS);
- LOG.info("Unregister outbound queue successful.");
- } catch (InterruptedException | TimeoutException | ExecutionException e) {
- LOG.warn("Unregister outbound queue throws exception for node {} ", nodeId);
- LOG.trace("Unregister outbound queue throws exception for node {} ", nodeId, e);
- }
-
- closeHandshakeContext();
-
- if (getConnectionAdapter().isAlive()) {
- getConnectionAdapter().disconnect();
- }
-
- if (propagate) {
- LOG.debug("Propagating device disconnect for node {}", nodeId);
- propagateDeviceDisconnectedEvent();
- } else {
- LOG.debug("Close connection without propagating for node {}", nodeId);
- }