本文整理汇总了Java中org.graylog2.plugin.inputs.codecs.CodecAggregator类的典型用法代码示例。如果您正苦于以下问题:Java CodecAggregator类的具体用法?Java CodecAggregator怎么用?Java CodecAggregator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodecAggregator类属于org.graylog2.plugin.inputs.codecs包,在下文中一共展示了CodecAggregator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: channelRead0
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@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.");
}
}
示例2: parseNetflowPcapStream
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
private Collection<NetFlowV9Packet> parseNetflowPcapStream(String resourceName) throws IOException {
final List<NetFlowV9Packet> allPackets = Lists.newArrayList();
try (InputStream inputStream = Resources.getResource(resourceName).openStream()) {
final Pcap pcap = Pcap.openStream(inputStream);
pcap.loop(packet -> {
if (packet.hasProtocol(Protocol.UDP)) {
final UDPPacket udp = (UDPPacket) packet.getPacket(Protocol.UDP);
final InetSocketAddress source = new InetSocketAddress(udp.getSourceIP(), udp.getSourcePort());
final CodecAggregator.Result result = codecAggregator.addChunk(Unpooled.copiedBuffer(udp.getPayload().getArray()), source);
if (result.isValid() && result.getMessage() != null) {
final ByteBuf buffer = result.getMessage();
// must read the marker byte off the buffer first.
buffer.readByte();
allPackets.addAll(codec.decodeV9Packets(buffer));
}
}
return true;
}
);
}
return allPackets;
}
示例3: decodePcapStream
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
private Collection<Message> decodePcapStream(String resourceName) throws IOException {
final List<Message> allMessages = Lists.newArrayList();
try (InputStream inputStream = Resources.getResource(resourceName).openStream()) {
final Pcap pcap = Pcap.openStream(inputStream);
pcap.loop(packet -> {
if (packet.hasProtocol(Protocol.UDP)) {
final UDPPacket udp = (UDPPacket) packet.getPacket(Protocol.UDP);
final InetSocketAddress source = new InetSocketAddress(udp.getSourceIP(), udp.getSourcePort());
final CodecAggregator.Result result = codecAggregator.addChunk(Unpooled.copiedBuffer(udp.getPayload().getArray()), source);
if (result.isValid() && result.getMessage() != null) {
final Collection<Message> c = codec.decodeMessages(convertToRawMessage(result, source));
if (c != null) {
allMessages.addAll(c);
}
}
}
return true;
}
);
}
return allMessages;
}
示例4: convertToRawMessage
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
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);
}
示例5: getAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Nullable
@Override
public CodecAggregator getAggregator() {
return null;
}
示例6: setMessageAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Override
public void setMessageAggregator(CodecAggregator aggregator) {
// Not supported.
}
示例7: setMessageAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Override
public void setMessageAggregator(CodecAggregator aggregator) {
}
示例8: setMessageAggregatorDoesNothing
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Test
public void setMessageAggregatorDoesNothing() throws Exception {
final CodecAggregator codecAggregator = mock(CodecAggregator.class);
transport.setMessageAggregator(codecAggregator);
verifyNoMoreInteractions(codecAggregator);
}
开发者ID:graylog-labs,项目名称:graylog-plugin-internal-logs,代码行数:7,代码来源:SerializedLogEventTransportTest.java
示例9: getAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Nullable
@Override
public CodecAggregator getAggregator() {
return netflowV9CodecAggregator;
}
示例10: aggregateRawPacket
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
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);
}
示例11: decodeResult
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
private Collection<Message> decodeResult(CodecAggregator.Result result) {
if (result.getMessage() == null) {
return Collections.emptyList();
}
return codec.decodeMessages(convertToRawMessage(result, source));
}
示例12: setMessageAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Override
public void setMessageAggregator(CodecAggregator codecAggregator) {
// nope
}
示例13: setMessageAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Override
public void setMessageAggregator(CodecAggregator codecAggregator) {
// Not supported.
}
示例14: setMessageAggregator
import org.graylog2.plugin.inputs.codecs.CodecAggregator; //导入依赖的package包/类
@Override
public void setMessageAggregator(CodecAggregator codecAggregator) {
}