@Override public void onFailure(Throwable t) { LOG.info("getting feature failed seriously [addr:{}]: {}", connectionAdapter.getRemoteAddress(), t.getMessage()); } });
@Override public void onFailure(Throwable t) { LOG.warn("getting feature failed seriously [{}, addr:{}]: {}", xid, connectionAdapter.getRemoteAddress(), t.getMessage()); LOG.trace("DETAIL of sending of hello failure:", t); } });
@Override public void onHighWaterMark() { connectionAdapter.setAutoRead(false); LOG.debug("AutoRead is set on false: {}", connectionAdapter.getRemoteAddress()); }
@Override public void onLowWaterMark() { connectionAdapter.setAutoRead(true); LOG.debug("AutoRead is set on true: {}", connectionAdapter.getRemoteAddress()); } }
private static IpAddress getIpAddressOf(final ConnectionAdapter connectionAdapter) { InetSocketAddress remoteAddress = connectionAdapter.getRemoteAddress(); if (remoteAddress == null) { LOG.warn("IP address of the node cannot be obtained. No connection with switch."); return null; } return resolveIpAddress(remoteAddress.getAddress()); }
/** * @param expectedState connection conductor state */ protected void checkState(CONDUCTOR_STATE expectedState) { if (!conductorState.equals(expectedState)) { LOG.warn("State of connection to switch {} is not correct, " + "terminating the connection", connectionAdapter.getRemoteAddress()); throw new IllegalStateException("Expected state: " + expectedState + ", actual state:" + conductorState); } }
private void shutdownPoolPolitely() { LOG.debug("Terminating handshake pool for node {}", connectionAdapter.getRemoteAddress()); hsPool.shutdown(); try { hsPool.awaitTermination(1, TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.debug("Error while awaiting termination of pool. Will force shutdown now."); } finally { hsPool.purge(); if (!hsPool.isTerminated()) { hsPool.shutdownNow(); } LOG.debug("is handshake pool for node {} is terminated : {}", connectionAdapter.getRemoteAddress(), hsPool.isTerminated()); } }
@Override public void onFailure(Throwable t) { LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), t.getMessage()); LOG.trace("DETAIL of sending of hello failure:", t); resultFtr.cancel(false); handshakeListener.onHandshakeFailure(); } });
@Override public void onSwitchConnected(ConnectionAdapter connectionAdapter) { LOG.info("CREATING NEW LISTENER FOR {}", connectionAdapter.getRemoteAddress()); ShimMessageListener listener = new ShimMessageListener(coreConnector, connectionAdapter, shimRelay, this, notificationProviderService); mapListeners.put(connectionAdapter.getRemoteAddress(), listener); listener.registerConnectionAdaptersRegistry(connectionRegistry); listener.registerHandshakeListener(this); connectionRegistry.registerConnectionAdapter(connectionAdapter, null); connectionAdapter.setMessageListener(listener); connectionAdapter.setSystemListener(listener); connectionAdapter.setConnectionReadyListener(listener); handshake(connectionAdapter); }
@Override public void onSuccess(RpcResult<Void> result) { if (result.isSuccessful()) { LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress()); resultFtr.set(null); } else { for (RpcError error : result.getErrors()) { LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress()); if (error.getCause() != null) { LOG.trace("DETAIL of sending hello failure", error.getCause()); } } resultFtr.cancel(false); handshakeListener.onHandshakeFailure(); } }
private static IpAddress getIpAddressOf(final ModelDrivenSwitch sw) { SessionContext sessionContext = sw.getSessionContext(); Preconditions.checkNotNull(sessionContext.getPrimaryConductor(), "primary conductor must not be NULL -> " + sw.getNodeId()); Preconditions.checkNotNull(sessionContext.getPrimaryConductor().getConnectionAdapter(), "connection adapter of primary conductor must not be NULL -> " + sw.getNodeId()); InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter() .getRemoteAddress(); if (remoteAddress == null) { LOG.warn("IP address of the node {} cannot be obtained. No connection with switch.", sw.getNodeId()); return null; } return resolveIpAddress(remoteAddress.getAddress()); }
private static PortNumber getPortNumberOf(ModelDrivenSwitch sw) { SessionContext sessionContext = sw.getSessionContext(); Preconditions.checkNotNull(sessionContext.getPrimaryConductor(), "primary conductor must not be NULL -> " + sw.getNodeId()); Preconditions.checkNotNull(sessionContext.getPrimaryConductor().getConnectionAdapter(), "connection adapter of primary conductor must not be NULL -> " + sw.getNodeId()); InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter() .getRemoteAddress(); if (remoteAddress == null) { LOG.warn("Port Number of the node {} cannot be obtained. No connection with switch.", sw.getNodeId()); return null; } return resolvePortNumber(remoteAddress.getPort()); }
@Override public void onSuccess(RpcResult<GetFeaturesOutput> rpcFeatures) { LOG.trace("features are back"); if (rpcFeatures.isSuccessful()) { GetFeaturesOutput featureOutput = rpcFeatures.getResult(); LOG.debug("obtained features: datapathId={}", featureOutput.getDatapathId()); LOG.debug("obtained features: auxiliaryId={}", featureOutput.getAuxiliaryId()); LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}", version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId()); handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion); } else { // handshake failed LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress()); for (RpcError rpcError : rpcFeatures.getErrors()) { LOG.debug("handshake - features failure [{}]: i:{} | m:{} | s:{}", xid, rpcError.getInfo(), rpcError.getMessage(), rpcError.getSeverity(), rpcError.getCause() ); } handshakeListener.onHandshakeFailure(); } LOG.debug("postHandshake DONE"); }