<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
<executions>
<execution>
<phase>prepare-package</phase>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.5</version>
<executions>
<execution>
<goals>
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
-
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.opendaylight.openflowjava.util.ByteBufUtils;
private DeserializationFactory deserializationFactory;
@Override
- public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg)
+ public void channelRead0(final ChannelHandlerContext ctx, final VersionMessageUdpWrapper msg)
throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("UdpVersionMessageWrapper received");
- LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+ LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
}
- DataObject dataObject = null;
+
try {
- dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
+ final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
if (dataObject == null) {
LOGGER.warn("Translated POJO is null");
} else {
consumer.consume(dataObject);
}
} catch(Exception e) {
- LOGGER.warn("Message deserialization failed");
- LOGGER.warn(e.getMessage(), e);
+ LOGGER.warn("Message deserialization failed", e);
// TODO: delegate exception to allow easier deserialization
// debugging / deserialization problem awareness
} finally {
/**
* @param deserializationFactory
*/
- public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+ public void setDeserializationFactory(final DeserializationFactory deserializationFactory) {
this.deserializationFactory = deserializationFactory;
}
-}
\ No newline at end of file
+}
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));
+ LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+ LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
if (readableBytes < length) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
- readableBytes + " < " + length);
- LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb));
+ LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+ LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
byte version = bb.readByte();
if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) {
- LOGGER.debug("detected version: " + version);
+ LOGGER.debug("detected version: {}", version);
ByteBuf messageBuffer = bb.slice();
out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender()));
messageBuffer.retain();
} else {
- LOGGER.warn("detected version: " + version + " - currently not supported");
+ LOGGER.warn("detected version: {} - currently not supported", version);
}
bb.skipBytes(bb.readableBytes());
}
-}
\ No newline at end of file
+}
public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+ private final StatisticsCounters statisticsCounter;
+
+ // TODO: make this final?
private DeserializationFactory deserializationFactory;
- private StatisticsCounters statisticsCounter;
+
/**
* Constructor of class
*/
public OFDecoder() {
LOGGER.trace("Creating OF 1.3 Decoder");
+ // TODO: pass as argument
statisticsCounter = StatisticsCounters.getInstance();
}
statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("VersionMessageWrapper received");
- LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+ LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
}
- DataObject dataObject = null;
try {
- dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
+ final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
msg.getVersion());
if (dataObject == null) {
LOGGER.warn("Translated POJO is null");
out.add(dataObject);
statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
}
- } catch(Exception e) {
- LOGGER.warn("Message deserialization failed");
- LOGGER.warn(e.getMessage(), e);
+ } catch (Exception e) {
+ LOGGER.warn("Message deserialization failed", e);
statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
} finally {
msg.getMessageBuffer().release();
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));
+ LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+ LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
if (readableBytes < length) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
- readableBytes + " < " + length);
- LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb));
+ LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+ LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
}
return;
}
InetAddress switchAddress = ch.remoteAddress().getAddress();
int port = ch.localAddress().getPort();
int remotePort = ch.remoteAddress().getPort();
- LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString()
- + ":" + remotePort + " --> :" + port);
+ LOGGER.debug("Incoming connection from (remote address): {}:{} --> :{}",
+ switchAddress.toString(), remotePort, port);
if (!getSwitchConnectionHandler().accept(switchAddress)) {
ch.disconnect();
ConnectionFacade connectionFacade = null;
connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null);
try {
- LOGGER.debug("calling plugin: " + getSwitchConnectionHandler());
+ LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler());
getSwitchConnectionHandler().onSwitchConnected(connectionFacade);
connectionFacade.checkListeners();
ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS));
public int size() {
return allChannels.size();
}
-}
\ No newline at end of file
+}
}
OFGeneralDeserializer desInRegistry = registry.put(key, deserializer);
if (desInRegistry != null) {
- LOGGER.debug("Deserializer for key " + key + " overwritten. Old deserializer: "
- + desInRegistry.getClass().getName() + ", new deserializer: "
- + deserializer.getClass().getName() );
+ LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}",
+ key, desInRegistry.getClass().getName(), deserializer.getClass().getName());
}
if (deserializer instanceof DeserializerRegistryInjector) {
((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this);
}
OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer);
if (serInRegistry != null) {
- LOGGER.debug("Serializer for key " + msgTypeKey + " overwritten. Old serializer: "
- + serInRegistry.getClass().getName() + ", new serializer: "
- + serializer.getClass().getName() );
+ LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}",
+ msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName());
}
if (serializer instanceof SerializerRegistryInjector) {
((SerializerRegistryInjector) serializer).injectSerializerRegistry(this);
*/
package org.opendaylight.openflowjava.protocol.impl.serialization.match;
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.util.ByteBufUtils;
-
import com.google.common.net.InetAddresses;
+import io.netty.buffer.ByteBuf;
/**
* Parent for Ipv6 address based match entry serializers
*/
public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer {
- protected void writeIpv6Address(String textAddress, final ByteBuf outBuffer) {
+ protected void writeIpv6Address(final String textAddress, final ByteBuf outBuffer) {
if (InetAddresses.isInetAddress(textAddress)) {
byte[] binaryAddress = InetAddresses.forString(textAddress).getAddress();
outBuffer.writeBytes(binaryAddress);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
- LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out));
+ }
BufferHelper.checkHeaderV13(out, (byte) 0, 16);
Elements element = readElement(out).get(0);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
- LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out));
+ }
BufferHelper.checkHeaderV13(out, (byte) 0, 24);
Elements element = readElement(out).get(0);
booleanList.add(false);
}
}
- LOGGER.debug("boolsize " + booleanList.size());
+ LOGGER.debug("boolsize {}", booleanList.size());
elementsBuilder.setType(HelloElementType.forValue(1));
elementsBuilder.setVersionBitmap(booleanList);
elementsList.add(elementsBuilder.build());
+ "00 1B 00 08 00 00 00 00");
message.skipBytes(4); // skip XID
- LOGGER.info("bytes: " + message.readableBytes());
+ LOGGER.info("bytes: {}", message.readableBytes());
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
LOGGER.debug("\n starting test -------------------------------");
String currentDir = System.getProperty("user.dir");
- LOGGER.debug("Current dir using System:" +currentDir);
+ LOGGER.debug("Current dir using System: {}", currentDir);
startupAddress = InetAddress.getLocalHost();
tlsConfiguration = null;
if (protocol.equals(TransportProtocol.TLS)) {
TransportProtocol protocol, ClientType clientType) throws ExecutionException {
List<OFClient> clientsHorde = new ArrayList<>();
for (int i = 0; i < amountOfCLients; i++) {
- LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());
+ LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress());
OFClient sc = null;
if (clientType == ClientType.SIMPLE) {
if (protocol.equals(TransportProtocol.TCP)) {
public MockPlugin() {
LOGGER.trace("Creating MockPlugin");
finishedFuture = SettableFuture.create();
- LOGGER.debug("mockPlugin: "+System.identityHashCode(this));
+ LOGGER.debug("mockPlugin: {}", System.identityHashCode(this));
}
@Override
public void onSwitchConnected(ConnectionAdapter connection) {
- LOGGER.debug("onSwitchConnected: " + connection);
+ LOGGER.debug("onSwitchConnected: {}", connection);
this.adapter = connection;
connection.setMessageListener(this);
connection.setSystemListener(this);
@Override
public boolean accept(InetAddress switchAddress) {
- LOGGER.debug("MockPlugin.accept(): " + switchAddress.toString());
+ LOGGER.debug("MockPlugin.accept(): {}", switchAddress.toString());
return true;
}
@Override
public void onEchoRequestMessage(final EchoRequestMessage notification) {
- LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: "+adapter);
+ LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter);
new Thread(new Runnable() {
@Override
public void run() {
- LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: "+adapter);
+ LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
replyBuilder.setVersion((short) 4);
replyBuilder.setXid(notification.getXid());
EchoReplyInput echoReplyInput = replyBuilder.build();
adapter.echoReply(echoReplyInput);
LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
- LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: "+adapter);
+ LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
}
}).start();
}
if (rpcResult.isSuccessful()) {
byte[] byteArray = rpcResult.getResult().getDatapathId()
.toByteArray();
- LOGGER.debug("DatapathId: " + Arrays.toString(byteArray));
+ LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray));
} else {
RpcError rpcError = rpcResult.getErrors().iterator().next();
- LOGGER.warn("rpcResult failed: "
- + rpcError.getCause().getMessage(), rpcError.getCause());
+ LOGGER.warn("rpcResult failed", rpcError.getCause());
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e);
protected void shutdown() {
try {
- LOGGER.debug("MockPlugin.shutdown() sleeping 5... : "+System.identityHashCode(this));
+ LOGGER.debug("MockPlugin.shutdown() sleeping 5... : {}", System.identityHashCode(this));
Thread.sleep(500);
if (adapter != null) {
Future<Boolean> disconnect = adapter.disconnect();
@Override
public void onPacketInMessage(PacketInMessage notification) {
LOGGER.debug("PacketIn message received");
- LOGGER.debug("BufferId: " + notification.getBufferId());
- LOGGER.debug("TotalLength: " + notification.getTotalLen());
- LOGGER.debug("Reason: " + notification.getReason());
- LOGGER.debug("TableId: " + notification.getTableId());
- LOGGER.debug("Cookie: " + notification.getCookie());
- LOGGER.debug("Class: " + notification.getMatch().getMatchEntry().get(0).getOxmClass());
- LOGGER.debug("Field: " + notification.getMatch().getMatchEntry().get(0).getOxmMatchField());
- LOGGER.debug("Datasize: " + notification.getData().length);
+ LOGGER.debug("BufferId: {}", notification.getBufferId());
+ LOGGER.debug("TotalLength: {}", notification.getTotalLen());
+ LOGGER.debug("Reason: {}", notification.getReason());
+ LOGGER.debug("TableId: {}", notification.getTableId());
+ LOGGER.debug("Cookie: {}", notification.getCookie());
+ LOGGER.debug("Class: {}", notification.getMatch().getMatchEntry().get(0).getOxmClass());
+ LOGGER.debug("Field: {}", notification.getMatch().getMatchEntry().get(0).getOxmMatchField());
+ LOGGER.debug("Datasize: {}", notification.getData().length);
}
@Override
@Override
public void onDisconnectEvent(DisconnectEvent notification) {
- LOGGER.debug("disconnection occured: "+notification.getInfo());
+ LOGGER.debug("disconnection occured: {}", notification.getInfo());
}
/**
@Override
public void onSwitchIdleEvent(SwitchIdleEvent notification) {
- LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: "+notification.getInfo());
+ LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: {}", notification.getInfo());
idleCounter ++;
}
public void run() {
int freezeCounter = 0;
while (!scenario.isEmpty()) {
- LOGGER.debug("Running event #" + eventNumber);
+ LOGGER.debug("Running event #{}", eventNumber);
ClientEvent peek = scenario.peekLast();
if (peek instanceof WaitForMessageEvent) {
LOGGER.debug("WaitForMessageEvent");
freezeCounter++;
}
if (freezeCounter > 2) {
- LOGGER.warn("Scenario freezed: " + freezeCounter);
+ LOGGER.warn("Scenario frozen: {}", freezeCounter);
break;
}
try {
ByteBuf buffer = ctx.alloc().buffer();
buffer.writeBytes(msgToSend);
ctx.writeAndFlush(buffer);
- LOGGER.debug(">> " + ByteBufUtils.bytesToHexString(msgToSend));
- LOGGER.debug("message sent");
+
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend));
+ LOGGER.debug("message sent");
+ }
return true;
}
int port;
SimpleClient sc;
if (args.length != 3) {
- LOGGER.error("Usage: " + SimpleClient.class.getSimpleName()
- + " <host> <port> <secured>");
+ LOGGER.error("Usage: {} <host> <port> <secured>", SimpleClient.class.getSimpleName());
LOGGER.error("Trying to use default setting.");
InetAddress ia = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
public void setScenarioHandler(ScenarioHandler scenario) {
this.scenarioHandler = scenario;
}
-}
\ No newline at end of file
+}
@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());
+ LOGGER.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);
+ LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
return;
}
LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf bb = (ByteBuf) msg;
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));
+ LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(bb));
}
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
LOGGER.trace("SimpleClientHandler - start of read");
int port;
UdpSimpleClient sc;
if (args.length != 2) {
- LOGGER.error("Usage: " + UdpSimpleClient.class.getSimpleName()
- + " <host> <port>");
+ LOGGER.error("Usage: {} <host> <port>", UdpSimpleClient.class.getSimpleName());
LOGGER.error("Trying to use default setting.");
InetAddress ia = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
public void setSecuredClient(boolean securedClient) {
// TODO: Finish implementation when DTLS is supported
}
-}
\ No newline at end of file
+}
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());
+ LOGGER.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);
+ LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
return;
}
LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
messageBuffer.retain();
bb.skipBytes(length);
}
-}
\ No newline at end of file
+}
return false;
}
if (!Arrays.equals(headerExpected, headerReceived)) {
- LOGGER.debug("expected msg: " + ByteBufUtils.bytesToHexString(headerExpected));
- LOGGER.debug("received msg: " + ByteBufUtils.bytesToHexString(headerReceived));
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected));
+ LOGGER.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived));
+ }
return false;
}
LOGGER.debug("Headers OK");