import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class HandshakeListenerImpl implements HandshakeListener {
private static final Logger LOG = LoggerFactory.getLogger(HandshakeListenerImpl.class);
private HandshakeContext handshakeContext;
/**
- * @param connectionContext
- * @param deviceConnectedHandler
+ * Constructor.
+ *
+ * @param connectionContext - connection context
+ * @param deviceConnectedHandler - device connected handler
*/
- public HandshakeListenerImpl(final ConnectionContext connectionContext, final DeviceConnectedHandler deviceConnectedHandler) {
+ public HandshakeListenerImpl(final ConnectionContext connectionContext,
+ final DeviceConnectedHandler deviceConnectedHandler) {
this.connectionContext = connectionContext;
this.deviceConnectedHandler = deviceConnectedHandler;
}
private FutureCallback<RpcResult<BarrierOutput>> addBarrierCallback() {
return new FutureCallback<RpcResult<BarrierOutput>>() {
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void onSuccess(@Nullable final RpcResult<BarrierOutput> result) {
if (LOG.isDebugEnabled()) {
- LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}", connectionContext.getDeviceInfo().getLOGValue());
+ LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}",
+ connectionContext.getDeviceInfo());
}
try {
ConnectionStatus connectionStatusResult = deviceConnectedHandler.deviceConnected(connectionContext);
- if (!ConnectionStatus.MAY_CONTINUE.equals(connectionStatusResult)) {
- connectionContext.closeConnection(true);
+ if (connectionStatusResult != ConnectionStatus.MAY_CONTINUE) {
+ connectionContext.closeConnection(false);
}
- SessionStatistics.countEvent(connectionContext.getDeviceInfo().getLOGValue(),
+ SessionStatistics.countEvent(connectionContext.getDeviceInfo().toString(),
SessionStatistics.ConnectionStatus.CONNECTION_CREATED);
} catch (final Exception e) {
- LOG.warn("initial processing failed for device {}", connectionContext.getDeviceInfo().getLOGValue(), e);
- SessionStatistics.countEvent(connectionContext.getDeviceInfo().getLOGValue(),
+ LOG.warn("initial processing failed for device {}", connectionContext.getDeviceInfo(), e);
+ SessionStatistics.countEvent(connectionContext.getDeviceInfo().toString(),
SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
connectionContext.closeConnection(true);
}
}
@Override
- public void onFailure(final Throwable t) {
- LOG.warn("failed to get sweep barrier after post-handshake for device {}", connectionContext.getDeviceInfo().getLOGValue(), t);
+ public void onFailure(final Throwable throwable) {
+ LOG.warn("failed to get sweep barrier after post-handshake for device {}",
+ connectionContext.getDeviceInfo(), throwable);
connectionContext.closeConnection(false);
}
};