java_gen: add optional instrumentation
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ChannelUtils.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ChannelUtils.java
index 13cfdc7..f024fa3 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ChannelUtils.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ChannelUtils.java
@@ -4,8 +4,11 @@
import org.jboss.netty.buffer.ChannelBuffer;
import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.OFInstrumentationOptions;
import org.projectfloodlight.openflow.protocol.OFMessageReader;
import org.projectfloodlight.openflow.protocol.Writeable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -18,6 +21,7 @@
*/
public class ChannelUtils {
+ private static final Logger logger = LoggerFactory.getLogger(ChannelUtils.class);
public static String readFixedLengthString(ChannelBuffer bb, int length) {
byte[] dst = new byte[length];
bb.readBytes(dst, 0, length);
@@ -56,8 +60,15 @@
public static <T> List<T> readList(ChannelBuffer bb, int length, OFMessageReader<T> reader) throws OFParseError {
int end = bb.readerIndex() + length;
Builder<T> builder = ImmutableList.<T>builder();
+ if(OFInstrumentationOptions.TRACE_READS)
+ if(logger.isTraceEnabled())
+ logger.trace("readList(length={}, reader={})", length, reader.getClass());
while(bb.readerIndex() < end) {
- builder.add(reader.readFrom(bb));
+ T read = reader.readFrom(bb);
+ if(OFInstrumentationOptions.TRACE_READS)
+ if(logger.isTraceEnabled())
+ logger.trace("readList: read={}, left={}", read, end - bb.readerIndex());
+ builder.add(read);
}
if(bb.readerIndex() != end) {
throw new IllegalStateException("Overread length: length="+length + " overread by "+ (bb.readerIndex() - end) + " reader: "+reader);