+/*
+ * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.openflowjava.protocol.impl.core;
/**
*/
public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter {
- private static final Logger LOGGER = LoggerFactory.getLogger(DelegatingInboundHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DelegatingInboundHandler.class);
private final MessageConsumer consumer;
private boolean inactiveMessageSent = false;
* @param connectionAdapter reference for adapter communicating with upper layers outside library
*/
public DelegatingInboundHandler(final MessageConsumer connectionAdapter) {
- LOGGER.trace("Creating DelegatingInboundHandler");
+ LOG.trace("Creating DelegatingInboundHandler");
consumer = Preconditions.checkNotNull(connectionAdapter);
}
@Override
public void channelInactive(final ChannelHandlerContext ctx) {
- LOGGER.debug("Channel inactive");
+ LOG.debug("Channel inactive");
if (!inactiveMessageSent) {
DisconnectEventBuilder builder = new DisconnectEventBuilder();
builder.setInfo("Channel inactive");
@Override
public void channelUnregistered(final ChannelHandlerContext ctx) {
- LOGGER.debug("Channel unregistered");
+ LOG.debug("Channel unregistered");
if (!inactiveMessageSent) {
DisconnectEventBuilder builder = new DisconnectEventBuilder();
builder.setInfo("Channel unregistered");
*/
public class IdleHandler extends ReadTimeoutHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(IdleHandler.class);
private boolean first = true;
/**
@Override
protected void readTimedOut(final ChannelHandlerContext ctx) throws Exception {
if (first) {
- LOGGER.debug("Switch idle");
+ LOG.debug("Switch idle");
SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder();
builder.setInfo("Switch idle");
ctx.fireChannelRead(builder.build());
*/
public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<VersionMessageUdpWrapper>{
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketDecoder.class);
private DeserializationFactory deserializationFactory;
@Override
public void channelRead0(final ChannelHandlerContext ctx, final VersionMessageUdpWrapper msg)
throws Exception {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("UdpVersionMessageWrapper received");
- LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("UdpVersionMessageWrapper received");
+ LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
}
try {
final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
if (dataObject == null) {
- LOGGER.warn("Translated POJO is null");
+ LOG.warn("Translated POJO is null");
} else {
MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress());
consumer.consume(dataObject);
}
} catch(Exception e) {
- LOGGER.warn("Message deserialization failed", e);
+ LOG.warn("Message deserialization failed", e);
// TODO: delegate exception to allow easier deserialization
// debugging / deserialization problem awareness
} finally {
*/
public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageListenerWrapper> {
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketEncoder.class);
private SerializationFactory serializationFactory;
@Override
protected void encode(ChannelHandlerContext ctx,
UdpMessageListenerWrapper wrapper, List<Object> out) throws Exception {
- LOGGER.trace("Encoding");
+ LOG.trace("Encoding");
try {
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg());
out.add(new DatagramPacket(buffer, wrapper.getAddress()));
} catch(Exception e) {
- LOGGER.warn("Message serialization failed: {}", e.getMessage());
+ LOG.warn("Message serialization failed: {}", e.getMessage());
Future<Void> newFailedFuture = ctx.newFailedFuture(e);
wrapper.getListener().operationComplete(newFailedFuture);
return;
*/
public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPacket> {
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketHandler.class);
/** Length of OpenFlow 1.3 header */
public static final byte LENGTH_OF_HEADER = 8;
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- LOGGER.warn("Unexpected exception from downstream.", cause);
- LOGGER.warn("Closing connection.");
+ LOG.warn("Unexpected exception from downstream.", cause);
+ LOG.warn("Closing connection.");
ctx.close();
}
@Override
protected void decode(ChannelHandlerContext ctx, DatagramPacket msg,
List<Object> out) throws Exception {
- LOGGER.debug("OFDatagramPacketFramer");
+ LOG.debug("OFDatagramPacketFramer");
MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender());
if (consumer == null) {
ConnectionFacade connectionFacade =
ByteBuf bb = msg.content();
int readableBytes = bb.readableBytes();
if (readableBytes < LENGTH_OF_HEADER) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
- LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+ LOG.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
- LOGGER.debug("length of actual message: {}", length);
+ LOG.debug("length of actual message: {}", length);
if (readableBytes < length) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
- LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+ LOG.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
- LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
+ LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
byte version = bb.readByte();
if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) {
- LOGGER.debug("detected version: {}", version);
+ LOG.debug("detected version: {}", version);
ByteBuf messageBuffer = bb.slice();
out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender()));
messageBuffer.retain();
} else {
- LOGGER.warn("detected version: {} - currently not supported", version);
+ LOG.warn("detected version: {} - currently not supported", version);
}
bb.skipBytes(bb.readableBytes());
}
*/
public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFDecoder.class);
private final StatisticsCounters statisticsCounter;
// TODO: make this final?
* Constructor of class
*/
public OFDecoder() {
- LOGGER.trace("Creating OF 1.3 Decoder");
+ LOG.trace("Creating OF 1.3 Decoder");
// TODO: pass as argument
statisticsCounter = StatisticsCounters.getInstance();
}
protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg,
List<Object> out) throws Exception {
statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("VersionMessageWrapper received");
- LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VersionMessageWrapper received");
+ LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
}
try {
final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
msg.getVersion());
if (dataObject == null) {
- LOGGER.warn("Translated POJO is null");
+ LOG.warn("Translated POJO is null");
statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
} else {
out.add(dataObject);
statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
}
} catch (Exception e) {
- LOGGER.warn("Message deserialization failed", e);
+ LOG.warn("Message deserialization failed", e);
statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
} finally {
msg.getMessageBuffer().release();
/** Length of OpenFlow 1.3 header */
public static final byte LENGTH_OF_HEADER = 8;
private static final byte LENGTH_INDEX_IN_HEADER = 2;
- private static final Logger LOGGER = LoggerFactory.getLogger(OFFrameDecoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFFrameDecoder.class);
private ConnectionFacade connectionFacade;
private boolean firstTlsPass = false;
* @param tlsPresent true is TLS is required, false otherwise
*/
public OFFrameDecoder(ConnectionFacade connectionFacade, boolean tlsPresent) {
- LOGGER.trace("Creating OFFrameDecoder");
+ LOG.trace("Creating OFFrameDecoder");
if (tlsPresent) {
firstTlsPass = true;
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof io.netty.handler.ssl.NotSslRecordException) {
- LOGGER.warn("Not an TLS record exception - please verify TLS configuration.");
+ LOG.warn("Not an TLS record exception - please verify TLS configuration.");
} else {
- LOGGER.warn("Unexpected exception from downstream.", cause);
+ LOG.warn("Unexpected exception from downstream.", cause);
}
- LOGGER.warn("Closing connection.");
+ LOG.warn("Closing connection.");
ctx.close();
}
}
int readableBytes = bb.readableBytes();
if (readableBytes < LENGTH_OF_HEADER) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
- LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+ LOG.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
- LOGGER.debug("length of actual message: {}", length);
+ LOG.debug("length of actual message: {}", length);
if (readableBytes < length) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
- LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+ LOG.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
- LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
+ LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
list.add(messageBuffer);
/** Version number of OpenFlow 1.3 protocol */
private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID;
private static final short OF_PACKETIN = 10;
- private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OFVersionDetector.class);
private final StatisticsCounters statisticsCounters;
private volatile boolean filterPacketIns;
* Constructor of class.
*/
public OFVersionDetector() {
- LOGGER.trace("Creating OFVersionDetector");
+ LOG.trace("Creating OFVersionDetector");
statisticsCounters = StatisticsCounters.getInstance();
}
@Override
protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) {
if (!in.isReadable()) {
- LOGGER.debug("not enough data");
+ LOG.debug("not enough data");
in.release();
return;
}
final byte version = in.readByte();
if (version == OF13_VERSION_ID || version == OF10_VERSION_ID) {
- LOGGER.debug("detected version: {}", version);
+ LOG.debug("detected version: {}", version);
if (!filterPacketIns || OF_PACKETIN != in.getUnsignedByte(in.readerIndex())) {
ByteBuf messageBuffer = in.slice();
out.add(new VersionMessageWrapper(version, messageBuffer));
messageBuffer.retain();
} else {
- LOGGER.debug("dropped packetin");
+ LOG.debug("dropped packetin");
statisticsCounters.incrementCounter(CounterEventTypes.US_DROPPED_PACKET_IN);
}
} else {
- LOGGER.warn("detected version: {} - currently not supported", version);
+ LOG.warn("detected version: {} - currently not supported", version);
}
in.skipBytes(in.readableBytes());
}
private static final String PROTOCOL = "TLS";
private TlsConfiguration tlsConfig;
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(SslContextFactory.class);
/**
serverContext = SSLContext.getInstance(PROTOCOL);
serverContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
} catch (IOException e) {
- LOGGER.warn("IOException - Failed to load keystore / truststore."
+ LOG.warn("IOException - Failed to load keystore / truststore."
+ " Failed to initialize the server-side SSLContext", e);
} catch (NoSuchAlgorithmException e) {
- LOGGER.warn("NoSuchAlgorithmException - Unsupported algorithm."
+ LOG.warn("NoSuchAlgorithmException - Unsupported algorithm."
+ " Failed to initialize the server-side SSLContext", e);
} catch (CertificateException e) {
- LOGGER.warn("CertificateException - Unable to access certificate (check password)."
+ LOG.warn("CertificateException - Unable to access certificate (check password)."
+ " Failed to initialize the server-side SSLContext", e);
} catch (Exception e) {
- LOGGER.warn("Exception - Failed to initialize the server-side SSLContext", e);
+ LOG.warn("Exception - Failed to initialize the server-side SSLContext", e);
}
return serverContext;
}
*/
public final class SslKeyStore {
- private static final Logger LOGGER = LoggerFactory.getLogger(SslKeyStore.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SslKeyStore.class);
private SslKeyStore() {
throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
}
break;
case PATH:
- LOGGER.debug("Current dir using System:"
+ LOG.debug("Current dir using System:"
+ System.getProperty("user.dir"));
File keystorefile = new File(filename);
try {
*/
public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, ConnectionInitializer {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(SwitchConnectionProviderImpl.class);
private SwitchConnectionHandler switchConnectionHandler;
private ServerFacade serverFacade;
@Override
public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) {
- LOGGER.debug("setSwitchConnectionHandler");
+ LOG.debug("setSwitchConnectionHandler");
this.switchConnectionHandler = switchConnectionHandler;
}
@Override
public ListenableFuture<Boolean> shutdown() {
- LOGGER.debug("Shutdown summoned");
+ LOG.debug("Shutdown summoned");
if(serverFacade == null){
- LOGGER.warn("Can not shutdown - not configured or started");
+ LOG.warn("Can not shutdown - not configured or started");
throw new IllegalStateException("SwitchConnectionProvider is not started or not configured.");
}
return serverFacade.shutdown();
@Override
public ListenableFuture<Boolean> startup() {
- LOGGER.debug("Startup summoned");
+ LOG.debug("Startup summoned");
ListenableFuture<Boolean> result = null;
try {
serverFacade = createAndConfigureServer();
* @return
*/
private ServerFacade createAndConfigureServer() {
- LOGGER.debug("Configuring ..");
+ LOG.debug("Configuring ..");
ServerFacade server = null;
final ChannelInitializerFactory factory = new ChannelInitializerFactory();
factory.setSwitchConnectionHandler(switchConnectionHandler);
*/
public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChannel> {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(TcpChannelInitializer.class);
private final DefaultChannelGroup allChannels;
private final ConnectionAdapterFactory connectionAdapterFactory;
final InetAddress switchAddress = ch.remoteAddress().getAddress();
final int port = ch.localAddress().getPort();
final int remotePort = ch.remoteAddress().getPort();
- LOGGER.debug("Incoming connection from (remote address): {}:{} --> :{}",
+ LOG.debug("Incoming connection from (remote address): {}:{} --> :{}",
switchAddress.toString(), remotePort, port);
if (!getSwitchConnectionHandler().accept(switchAddress)) {
ch.disconnect();
- LOGGER.debug("Incoming connection rejected");
+ LOG.debug("Incoming connection rejected");
return;
}
}
- LOGGER.debug("Incoming connection accepted - building pipeline");
+ LOG.debug("Incoming connection accepted - building pipeline");
allChannels.add(ch);
ConnectionFacade connectionFacade = null;
connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null, useBarrier());
try {
- LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler());
+ LOG.debug("calling plugin: {}", getSwitchConnectionHandler());
getSwitchConnectionHandler().onSwitchConnected(connectionFacade);
connectionFacade.checkListeners();
ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS));
engine.setUseClientMode(false);
List<String> suitesList = getTlsConfiguration().getCipherSuites();
if (suitesList != null && !suitesList.isEmpty()) {
- LOGGER.debug("Requested Cipher Suites are: {}", suitesList);
+ LOG.debug("Requested Cipher Suites are: {}", suitesList);
String[] suites = suitesList.toArray(new String[suitesList.size()]);
engine.setEnabledCipherSuites(suites);
- LOGGER.debug("Cipher suites enabled in SSLEngine are: {}", engine.getEnabledCipherSuites().toString());
+ LOG.debug("Cipher suites enabled in SSLEngine are: {}", engine.getEnabledCipherSuites().toString());
}
final SslHandler ssl = new SslHandler(engine);
final Future<Channel> handshakeFuture = ssl.handshakeFuture();
connectionFacade.fireConnectionReadyNotification();
}
} catch (final Exception e) {
- LOGGER.warn("Failed to initialize channel", e);
+ LOG.warn("Failed to initialize channel", e);
ch.close();
}
}
+/*
+ * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.openflowjava.protocol.impl.core;
import io.netty.bootstrap.Bootstrap;
public class TcpConnectionInitializer implements ServerFacade,
ConnectionInitializer {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(TcpConnectionInitializer.class);
private EventLoopGroup workerGroup;
private ThreadConfiguration threadConfig;
try {
b.connect(host, port).sync();
} catch (InterruptedException e) {
- LOGGER.error("Unable to initiate connection", e);
+ LOG.error("Unable to initiate connection", e);
}
}
*/
private static final int DEFAULT_WRITE_SPIN_COUNT = 16;
- private static final Logger LOGGER = LoggerFactory.getLogger(TcpHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TcpHandler.class);
private int port;
private String address;
f = b.bind(port).sync();
}
} catch (InterruptedException e) {
- LOGGER.error("Interrupted while binding port {}", port, e);
+ LOG.error("Interrupted while binding port {}", port, e);
return;
}
// Update port, as it may have been specified as 0
this.port = isa.getPort();
- LOGGER.debug("address from tcphandler: {}", address);
+ LOG.debug("address from tcphandler: {}", address);
isOnlineFuture.set(true);
- LOGGER.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port);
+ LOG.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port);
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
- LOGGER.error("Interrupted while waiting for port {} shutdown", port, e);
+ LOG.error("Interrupted while waiting for port {} shutdown", port, e);
} finally {
shutdown();
}
((EpollEventLoopGroup)workerGroup).setIoRatio(100);
return;
} catch (Throwable ex) {
- LOGGER.debug("Epoll initiation failed");
+ LOG.debug("Epoll initiation failed");
}
//Fallback mechanism
*/
public final class UdpHandler implements ServerFacade {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(UdpHandler.class);
private int port;
private EventLoopGroup group;
f = b.bind(port).sync();
}
} catch (InterruptedException e) {
- LOGGER.error("Interrupted while binding port {}", port, e);
+ LOG.error("Interrupted while binding port {}", port, e);
return;
}
// Update port, as it may have been specified as 0
this.port = isa.getPort();
- LOGGER.debug("Address from udpHandler: {}", address);
+ LOG.debug("Address from udpHandler: {}", address);
isOnlineFuture.set(true);
- LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port);
+ LOG.info("Switch listener started and ready to accept incoming udp connections on port: {}", port);
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
- LOGGER.error("Interrupted while waiting for port {} shutdown", port, e);
+ LOG.error("Interrupted while waiting for port {} shutdown", port, e);
} finally {
shutdown();
}
}
return;
} catch (Throwable ex) {
- LOGGER.debug("Epoll initiation failed");
+ LOG.debug("Epoll initiation failed");
}
//Fallback mechanism
/* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */
private static final GenericFutureListener<Future<Void>> LOG_ENCODER_LISTENER = new GenericFutureListener<Future<Void>>() {
- private final Logger LOGGER = LoggerFactory.getLogger("LogEncoderListener");
+ private final Logger LOG = LoggerFactory.getLogger(GenericFutureListener.class);
@Override
public void operationComplete(final Future<Void> future) throws Exception {
if (future.cause() != null) {
- LOGGER.warn("Message encoding fail !", future.cause());
+ LOG.warn("Message encoding fail !", future.cause());
}
}
};
*/
public class DeserializerRegistryImpl implements DeserializerRegistry {
- private static final Logger LOGGER = LoggerFactory.getLogger(DeserializerRegistryImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DeserializerRegistryImpl.class);
private Map<MessageCodeKey, OFGeneralDeserializer> registry;
/**
}
OFGeneralDeserializer desInRegistry = registry.put(key, deserializer);
if (desInRegistry != null) {
- LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key,
+ LOG.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key,
desInRegistry.getClass().getName(), deserializer.getClass().getName());
}
if (deserializer instanceof DeserializerRegistryInjector) {
builder.setXid(rawMessage.readUnsignedInt());
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
- builder.setData(rawMessage.readBytes(remainingBytes).array());
+ byte[] data = new byte[remainingBytes];
+ rawMessage.readBytes(data);
+ builder.setData(data);
}
return builder.build();
}
EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
- builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ byte[] data = new byte[rawMessage.readableBytes()];
+ rawMessage.readBytes(data);
+ builder.setData(data);
return builder.build();
}
}
}
decodeType(builder, errorType, type);
decodeCode(rawMessage, builder, errorType);
- if (rawMessage.readableBytes() > 0) {
- builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ int remainingBytes = rawMessage.readableBytes();
+ if (remainingBytes > 0) {
+ byte[] data = new byte[remainingBytes];
+ rawMessage.readBytes(data);
+ builder.setData(data);
}
return builder.build();
}
builder.setXid(rawMessage.readUnsignedInt());
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
- builder.setData(rawMessage.readBytes(remainingBytes).array());
+ byte[] data = new byte[remainingBytes];
+ rawMessage.readBytes(data);
+ builder.setData(data);
}
return builder.build();
}
EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
- builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ byte[] data = new byte[rawMessage.readableBytes()];
+ rawMessage.readBytes(data);
+ builder.setData(data);
return builder.build();
}
}
ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
decodeType(builder, errorType, type);
decodeCode(rawMessage, builder, errorType);
- if (rawMessage.readableBytes() > 0) {
- builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ int remainingBytes = rawMessage.readableBytes();
+ if (remainingBytes > 0) {
+ byte[] data = new byte[remainingBytes];
+ rawMessage.readBytes(data);
+ builder.setData(data);
}
return builder.build();
}
rawMessage, keyMaker, registry);
builder.setAction(actions);
- byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array();
+ byte[] data = new byte[rawMessage.readableBytes()];
+ rawMessage.readBytes(data);
if (data != null) {
OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
builder.setMatch(matchDeserializer.deserialize(rawMessage));
rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
- builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ byte[] data = new byte[rawMessage.readableBytes()];
+ rawMessage.readBytes(data);
+ builder.setData(data);
return builder.build();
}
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len,
rawMessage, keyMaker, registry);
builder.setAction(actions);
- byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array();
+ byte[] data = new byte[rawMessage.readableBytes()];
+ rawMessage.readBytes(data);
if (data != null) {
builder.setData(data);
}
*/
public class SerializerRegistryImpl implements SerializerRegistry {
- private static final Logger LOGGER = LoggerFactory.getLogger(SerializerRegistryImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SerializerRegistryImpl.class);
private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
private Map<MessageTypeKey<?>, OFGeneralSerializer> registry;
}
OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer);
if (serInRegistry != null) {
- LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey,
+ LOG.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey,
serInRegistry.getClass().getName(), serializer.getClass().getName());
}
if (serializer instanceof SerializerRegistryInjector) {
* @author timotej.kubas
*/
public class OF13MatchSerializer implements OFSerializer<Match>, SerializerRegistryInjector {
- private static final Logger LOGGER = LoggerFactory.getLogger(OF13MatchSerializer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OF13MatchSerializer.class);
private static final byte STANDARD_MATCH_TYPE_CODE = 0;
private static final byte OXM_MATCH_TYPE_CODE = 1;
private SerializerRegistry registry;
@Override
public void serialize(Match match, ByteBuf outBuffer) {
if (match == null) {
- LOGGER.debug("Match is null");
+ LOG.debug("Match is null");
return;
}
int matchStartIndex = outBuffer.writerIndex();
*/
public void serializeMatchEntries(List<MatchEntry> matchEntries, ByteBuf out) {
if (matchEntries == null) {
- LOGGER.debug("Match entries are null");
+ LOG.debug("Match entries are null");
return;
}
for (MatchEntry entry : matchEntries) {
*/
public static final int MINIMAL_LOG_REPORT_PERIOD = 500;
private static StatisticsCounters instanceHolder;
- private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StatisticsCounters.class);
private Timer logReporter;
private int logReportPeriod;
runCounting = false;
this.logReportPeriod = 0;
this.runLogReport = false;
- LOGGER.debug("StaticsCounters has been created");
+ LOG.debug("StaticsCounters has been created");
}
/**
return;
}
resetCounters();
- LOGGER.debug("Counting started...");
+ LOG.debug("Counting started...");
if(reportToLogs){
startLogReport(logReportDelay);
}
*/
public void stopCounting(){
runCounting = false;
- LOGGER.debug("Stop counting...");
+ LOG.debug("Stop counting...");
stopLogReport();
}
logReporter = new Timer("SC_Timer");
logReporter.schedule(new LogReporterTask(this), this.logReportPeriod, this.logReportPeriod);
runLogReport = true;
- LOGGER.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod);
+ LOG.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod);
}
/**
if(runLogReport){
if(logReporter != null){
logReporter.cancel();
- LOGGER.debug("Statistics log reporter has been canceled");
+ LOG.debug("Statistics log reporter has been canceled");
}
runLogReport = false;
}
for(CounterEventTypes cet : enabledCounters){
countersMap.get(cet).reset();
}
- LOGGER.debug("StaticsCounters has been reset");
+ LOG.debug("StaticsCounters has been reset");
}
@Override
@Override
public void run() {
for(CounterEventTypes cet : sc.getEnabledCounters()){
- LOG.debug(cet.name() + ": " + sc.getCountersMap().get(cet).getStat());
+ LOG.debug("{}: {}", cet.name(), sc.getCountersMap().get(cet).getStat());
}
}
}
*/
public class StatisticsCollectionModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractStatisticsCollectionModule {
- private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCollectionModule.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StatisticsCollectionModule.class);
public StatisticsCollectionModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
if (statsConfig != null) {
statsCounter.startCounting(statsConfig.getStatisticsCollect(), statsConfig.getLogReportDelay());
} else {
- LOGGER.debug("Unable to start StatisticCounter - wrong configuration");
+ LOG.debug("Unable to start StatisticCounter - wrong configuration");
}
/* Internal MXBean implementation */
}
catch (Exception e) {
String errMsg = "Error by stoping StatisticsCollectionService.";
- LOGGER.error(errMsg, e);
+ LOG.error(errMsg, e);
throw new IllegalStateException(errMsg, e);
}
}
- LOGGER.info("StatisticsCollection Service consumer (instance {} turn down.)", this);
+ LOG.info("StatisticsCollection Service consumer (instance {} turn down.)", this);
}
@Override
}
AutoCloseable ret = new AutoClosableStatisticsCollection();
- LOGGER.info("StatisticsCollection service (instance {}) initialized.", ret);
+ LOG.info("StatisticsCollection service (instance {}) initialized.", ret);
return ret;
}
}
\ No newline at end of file
*/
public class DummyDecoder extends ByteToMessageDecoder {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(DummyDecoder.class);
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in,
List<Object> out) throws Exception {
- LOGGER.debug("decoding");
+ LOG.debug("decoding");
ctx.fireChannelReadComplete();
}
new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
}
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(MultipartReplyMessageFactoryTest.class);
/**
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
- LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
+ LOG.info(message.getMeterConfig().get(0).getFlags().toString());
Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
message.getMeterConfig().get(1).getFlags());
Assert.assertEquals("Wrong meterId01", 7,
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
- Assert.assertArrayEquals("Wrong data", message.getData(),
- serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+ byte[] readData = new byte[serializedBuffer.readableBytes()];
+ serializedBuffer.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
}
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
- Assert.assertArrayEquals("Wrong data", message.getData(),
- serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+ byte[] readData = new byte[serializedBuffer.readableBytes()];
+ serializedBuffer.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
}
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28);
Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort());
- Assert.assertArrayEquals("Wrong data", message.getData(),
- serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+ byte[] readData = new byte[serializedBuffer.readableBytes()];
+ serializedBuffer.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
}
*/
public class HelloInputMessageFactoryTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class);
private SerializerRegistry registry;
private OFSerializer<HelloInput> helloFactory;
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out));
}
BufferHelper.checkHeaderV13(out, (byte) 0, 16);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out));
}
BufferHelper.checkHeaderV13(out, (byte) 0, 24);
booleanList.add(false);
}
}
- LOGGER.debug("boolsize {}", booleanList.size());
+ LOG.debug("boolsize {}", booleanList.size());
elementsBuilder.setType(HelloElementType.forValue(1));
elementsBuilder.setVersionBitmap(booleanList);
elementsList.add(elementsBuilder.build());
Assert.assertEquals("Wrong port in", message.getInPort().intValue(), serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(1);
- Assert.assertArrayEquals("Wrong data", message.getData(),
- serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+ byte[] readData = new byte[serializedBuffer.readableBytes()];
+ serializedBuffer.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
}
Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
- Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());
+ byte[] readData = new byte[out.readableBytes()];
+ out.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(7);
serializedBuffer.skipBytes(PADDING);
- Assert.assertArrayEquals("Wrong data", message.getData(),
- serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+ byte[] readData = new byte[serializedBuffer.readableBytes()];
+ serializedBuffer.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
}
Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(PADDING_IN_ACTION_HEADER);
- Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());
+ byte[] readData = new byte[out.readableBytes()];
+ out.readBytes(readData);
+ Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
/**
*/
public class ActionsDeserializerTest {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(ActionsDeserializerTest.class);
private DeserializerRegistry registry;
+ "00 1B 00 08 00 00 00 00");
message.skipBytes(4); // skip XID
- LOGGER.info("bytes: {}", message.readableBytes());
+ LOG.info("bytes: {}", message.readableBytes());
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
byte[] label = new byte[4];
out.readBytes(label);
- LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label));
+ LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label));
Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
}
*/
public class StatisticsCountersTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCountersTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StatisticsCountersTest.class);
private StatisticsCounters statCounters;
/**
Assert.fail("No counter is enabled");
}
incrementCounter(firstEnabledCET,testCount);
- LOGGER.debug("Waiting to process event queue");
+ LOG.debug("Waiting to process event queue");
Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
Assert.assertEquals("Wrong - bad value", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue(false));
Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
*/
public class ListeningSimpleClient implements OFClient {
- private static final Logger LOGGER = LoggerFactory.getLogger(ListeningSimpleClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ListeningSimpleClient.class);
private int port;
private boolean securedClient = false;
private EventLoopGroup workerGroup;
isOnlineFuture.set(true);
synchronized (scenarioHandler) {
- LOGGER.debug("WAITING FOR SCENARIO");
+ LOG.debug("WAITING FOR SCENARIO");
while (! scenarioHandler.isScenarioFinished()) {
scenarioHandler.wait();
}
}
} catch (Exception ex) {
- LOGGER.error(ex.getMessage(), ex);
+ LOG.error(ex.getMessage(), ex);
} finally {
- LOGGER.debug("listening client shutting down");
+ LOG.debug("listening client shutting down");
try {
workerGroup.shutdownGracefully().get();
bossGroup.shutdownGracefully().get();
- LOGGER.debug("listening client shutdown succesful");
+ LOG.debug("listening client shutdown succesful");
} catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
}
scenarioDone.set(true);
* @return close future
*/
public Future<?> disconnect() {
- LOGGER.debug("disconnecting client");
+ LOG.debug("disconnecting client");
return workerGroup.shutdownGracefully();
}
*/
public class ScenarioHandler extends Thread {
- private static final Logger LOGGER = LoggerFactory.getLogger(ScenarioHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ScenarioHandler.class);
private Deque<ClientEvent> scenario;
private BlockingQueue<byte[]> ofMsg;
private ChannelHandlerContext ctx;
public void run() {
int freezeCounter = 0;
while (!scenario.isEmpty()) {
- LOGGER.debug("Running event #{}", eventNumber);
+ LOG.debug("Running event #{}", eventNumber);
ClientEvent peek = scenario.peekLast();
if (peek instanceof WaitForMessageEvent) {
- LOGGER.debug("WaitForMessageEvent");
+ LOG.debug("WaitForMessageEvent");
try {
WaitForMessageEvent event = (WaitForMessageEvent) peek;
event.setHeaderReceived(ofMsg.poll(2000, TimeUnit.MILLISECONDS));
} catch (InterruptedException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
break;
}
} else if (peek instanceof SendEvent) {
- LOGGER.debug("Proceed - sendevent");
+ LOG.debug("Proceed - sendevent");
SendEvent event = (SendEvent) peek;
event.setCtx(ctx);
}
freezeCounter++;
}
if (freezeCounter > 2) {
- LOGGER.warn("Scenario frozen: {}", freezeCounter);
+ LOG.warn("Scenario frozen: {}", freezeCounter);
break;
}
try {
sleep(100);
} catch (InterruptedException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
}
- LOGGER.debug("Scenario finished");
+ LOG.debug("Scenario finished");
synchronized (this) {
scenarioFinished = true;
this.notify();
*/
public class SendEvent implements ClientEvent {
- protected static final Logger LOGGER = LoggerFactory.getLogger(SendEvent.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SendEvent.class);
protected byte[] msgToSend;
protected ChannelHandlerContext ctx;
@Override
public boolean eventExecuted() {
- LOGGER.debug("sending message");
- LOGGER.debug("start of run");
+ LOG.debug("sending message");
+ LOG.debug("start of run");
ByteBuf buffer = ctx.alloc().buffer();
buffer.writeBytes(msgToSend);
ctx.writeAndFlush(buffer);
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend));
- LOGGER.debug("message sent");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend));
+ LOG.debug("message sent");
}
return true;
}
*/
public class SimpleClient implements OFClient {
- private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleClient.class);
private final String host;
private final int port;
private boolean securedClient = false;
b.connect(host, port).sync();
synchronized (scenarioHandler) {
- LOGGER.debug("WAITING FOR SCENARIO");
+ LOG.debug("WAITING FOR SCENARIO");
while (! scenarioHandler.isScenarioFinished()) {
scenarioHandler.wait();
}
}
} catch (Exception ex) {
- LOGGER.error(ex.getMessage(), ex);
+ LOG.error(ex.getMessage(), ex);
} finally {
- LOGGER.debug("shutting down");
+ LOG.debug("shutting down");
try {
group.shutdownGracefully().get();
- LOGGER.debug("shutdown succesful");
+ LOG.debug("shutdown succesful");
} catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
}
scenarioDone.set(true);
* @return close future
*/
public Future<?> disconnect() {
- LOGGER.debug("disconnecting client");
+ LOG.debug("disconnecting client");
return group.shutdownGracefully();
}
int port;
SimpleClient sc;
if (args.length != 3) {
- LOGGER.error("Usage: {} <host> <port> <secured>", SimpleClient.class.getSimpleName());
- LOGGER.error("Trying to use default setting.");
+ LOG.error("Usage: {} <host> <port> <secured>", SimpleClient.class.getSimpleName());
+ LOG.error("Trying to use default setting.");
InetAddress ia = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
host = all[0].getHostAddress();
/** Length of OpenFlow 1.3 header */
public static final byte LENGTH_OF_HEADER = 8;
private static final byte LENGTH_INDEX_IN_HEADER = 2;
- private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientFramer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleClientFramer.class);
/**
* Constructor of class.
*/
public SimpleClientFramer() {
- LOGGER.trace("Creating OFFrameDecoder");
+ LOG.trace("Creating OFFrameDecoder");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- LOGGER.warn("Unexpected exception from downstream.", cause);
+ LOG.warn("Unexpected exception from downstream.", cause);
ctx.close();
}
@Override
protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
if (bb.readableBytes() < LENGTH_OF_HEADER) {
- LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes());
+ LOG.debug("skipping bb - too few data for header: {}", bb.readableBytes());
return;
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
if (bb.readableBytes() < length) {
- LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
+ LOG.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
return;
}
- LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
+ LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
list.add(messageBuffer);
*/
public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
- protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleClientHandler.class);
private static final int LENGTH_INDEX_IN_HEADER = 2;
private SettableFuture<Boolean> isOnlineFuture;
protected ScenarioHandler scenarioHandler;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf bb = (ByteBuf) msg;
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(bb));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(bb));
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
- LOGGER.trace("SimpleClientHandler - start of read");
+ LOG.trace("SimpleClientHandler - start of read");
byte[] message = new byte[length];
bb.readBytes(message);
scenarioHandler.addOfMsg(message);
- LOGGER.trace("end of read");
+ LOG.trace("end of read");
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
- LOGGER.debug("Client is active");
+ LOG.debug("Client is active");
if (isOnlineFuture != null) {
isOnlineFuture.set(true);
isOnlineFuture = null;
*/
public class SleepEvent implements ClientEvent {
- private static final Logger LOGGER = LoggerFactory.getLogger(SleepEvent.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SleepEvent.class);
private long sleepTime;
/**
public boolean eventExecuted() {
try {
Thread.sleep(sleepTime);
- LOGGER.debug("Sleeping");
+ LOG.debug("Sleeping");
return true;
} catch (InterruptedException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
return false;
}
*/
public class UdpSimpleClient implements OFClient {
- private static final Logger LOGGER = LoggerFactory.getLogger(UdpSimpleClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UdpSimpleClient.class);
private final String host;
private final int port;
private EventLoopGroup group;
b.connect(host, port).sync();
synchronized (scenarioHandler) {
- LOGGER.debug("WAITING FOR SCENARIO");
+ LOG.debug("WAITING FOR SCENARIO");
while (! scenarioHandler.isScenarioFinished()) {
scenarioHandler.wait();
}
}
} catch (Exception ex) {
- LOGGER.error(ex.getMessage(), ex);
+ LOG.error(ex.getMessage(), ex);
} finally {
- LOGGER.debug("shutting down");
+ LOG.debug("shutting down");
try {
group.shutdownGracefully().get();
- LOGGER.debug("shutdown succesful");
+ LOG.debug("shutdown succesful");
} catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
}
scenarioDone.set(true);
* @return close future
*/
public Future<?> disconnect() {
- LOGGER.debug("disconnecting client");
+ LOG.debug("disconnecting client");
return group.shutdownGracefully();
}
int port;
UdpSimpleClient sc;
if (args.length != 2) {
- LOGGER.error("Usage: {} <host> <port>", UdpSimpleClient.class.getSimpleName());
- LOGGER.error("Trying to use default setting.");
+ LOG.error("Usage: {} <host> <port>", UdpSimpleClient.class.getSimpleName());
+ LOG.error("Trying to use default setting.");
InetAddress ia = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
host = all[0].getHostAddress();
/** Length of OpenFlow 1.3 header */
public static final byte LENGTH_OF_HEADER = 8;
private static final byte LENGTH_INDEX_IN_HEADER = 2;
- private static final Logger LOGGER = LoggerFactory.getLogger(UdpSimpleClientFramer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UdpSimpleClientFramer.class);
/**
* Constructor of class.
*/
public UdpSimpleClientFramer() {
- LOGGER.trace("Creating OFFrameDecoder");
+ LOG.trace("Creating OFFrameDecoder");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- LOGGER.warn("Unexpected exception from downstream.", cause);
+ LOG.warn("Unexpected exception from downstream.", cause);
ctx.close();
}
protected void decode(ChannelHandlerContext chc, DatagramPacket msg, List<Object> list) throws Exception {
ByteBuf bb = msg.content();
if (bb.readableBytes() < LENGTH_OF_HEADER) {
- LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes());
+ LOG.debug("skipping bb - too few data for header: {}", bb.readableBytes());
return;
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
if (bb.readableBytes() < length) {
- LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
+ LOG.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
return;
}
- LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
+ LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
list.add(messageBuffer);
*/
public class WaitForMessageEvent implements ClientEvent {
- private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class);
+ private static final Logger LOG = LoggerFactory.getLogger(WaitForMessageEvent.class);
private byte[] headerExpected;
private byte[] headerReceived;
return false;
}
if (!Arrays.equals(headerExpected, headerReceived)) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected));
- LOGGER.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected));
+ LOG.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived));
}
return false;
}
- LOGGER.debug("Headers OK");
+ LOG.debug("Headers OK");
return true;
}