*/
public class JsonRpcDecoder extends ByteToMessageDecoder {
- protected static final Logger logger = LoggerFactory.getLogger(JsonRpcDecoder.class);
-
+ private static final Logger LOG = LoggerFactory.getLogger(JsonRpcDecoder.class);
private int maxFrameLength;
-
+ //Indicates if the frame limit warning was issued
+ private boolean maxFrameLimitWasReached = false;
private JsonFactory jacksonJsonFactory = new MappingJsonFactory();
private IOContext jacksonIOContext = new IOContext(new BufferRecycler(), null, false);
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception {
- logger.trace("readable bytes {}, records read {}, incomplete record bytes {}",
+ LOG.trace("readable bytes {}, records read {}, incomplete record bytes {}",
buf.readableBytes(), recordsRead, lastRecordBytes);
if (lastRecordBytes == 0) {
}
if (index - buf.readerIndex() >= maxFrameLength) {
- fail(ctx, index - buf.readerIndex());
+ /*
+ * Changing this limit to being a warning, we do not wish to "break" in scale environment
+ * and currently this limits the ovs of having only around 50 ports defined...
+ * I do acknowledge the fast that this might be risky in case of huge amount of strings
+ * in which the controller can crash with an OOM, however seems that we need a really huge
+ * ovs to reach that limit.
+ */
+
+ //We do not want to issue a log message on every extent of the buffer
+ //hence logging only once
+ if (!maxFrameLimitWasReached) {
+ maxFrameLimitWasReached = true;
+ LOG.warn("***** OVSDB Frame limit of {} bytes has been reached! *****", this.maxFrameLength);
+ }
}
}
message = "";
}
if (startPos > buf.writerIndex()) {
- logger.trace("startPos out of bounds");
+ LOG.trace("startPos out of bounds");
}
byte[] bytes = new byte[startPos + chars <= buf.writerIndex() ? chars : buf.writerIndex() - startPos];
buf.getBytes(startPos, bytes);
- logger.trace("{} ={}", message, new String(bytes));
+ LOG.trace("{} ={}", message, new String(bytes));
}
// copied from Netty decoder