Java Code Examples for org.graylog2.plugin.inputs.codecs.CodecAggregator#Result
The following examples show how to use
org.graylog2.plugin.inputs.codecs.CodecAggregator#Result .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetflowMessageAggregationHandler.java From graylog-plugin-netflow with Apache License 2.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { final SocketAddress remoteAddress = msg.sender(); final CodecAggregator.Result result; try (Timer.Context ignored = aggregationTimer.time()) { result = aggregator.addChunk(msg.content(), remoteAddress); } final ByteBuf completeMessage = result.getMessage(); if (completeMessage != null) { LOG.debug("Message aggregation completion, forwarding {}", completeMessage); ctx.fireChannelRead(completeMessage); } else if (result.isValid()) { LOG.debug("More chunks necessary to complete this message"); } else { invalidChunksMeter.mark(); LOG.debug("Message chunk was not valid and discarded."); } }
Example 2
Source File: NetflowV9CodecAggregatorTest.java From graylog-plugin-netflow with Apache License 2.0 | 5 votes |
private RawMessage convertToRawMessage(CodecAggregator.Result result, SocketAddress remoteAddress) { final ByteBuf buffer = result.getMessage(); assertThat(buffer).isNotNull(); final byte[] payload = ByteBufUtil.getBytes(buffer); return new RawMessage(payload, (InetSocketAddress) remoteAddress); }
Example 3
Source File: NetflowV9CodecAggregatorTest.java From graylog-plugin-netflow with Apache License 2.0 | 4 votes |
private CodecAggregator.Result aggregateRawPacket(String resourceName) throws IOException { final byte[] bytes = Resources.toByteArray(Resources.getResource(resourceName)); final ByteBuf channelBuffer = Unpooled.wrappedBuffer(bytes); return codecAggregator.addChunk(channelBuffer, source); }
Example 4
Source File: NetflowV9CodecAggregatorTest.java From graylog-plugin-netflow with Apache License 2.0 | 4 votes |
private Collection<Message> decodeResult(CodecAggregator.Result result) { if (result.getMessage() == null) { return Collections.emptyList(); } return codec.decodeMessages(convertToRawMessage(result, source)); }