
org.logstash.beats.BeatsParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of proxy Show documentation
Show all versions of proxy Show documentation
Service for batching and relaying metric traffic to Wavefront
package org.logstash.beats;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.Inflater;
import java.util.zip.InflaterOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class BeatsParser extends ByteToMessageDecoder {
private static final Logger logger = LogManager.getLogger(BeatsParser.class);
private Batch batch;
private enum States {
READ_HEADER(1),
READ_FRAME_TYPE(1),
READ_WINDOW_SIZE(4),
READ_JSON_HEADER(8),
READ_COMPRESSED_FRAME_HEADER(4),
READ_COMPRESSED_FRAME(
-1), // -1 means the length to read is variable and defined in the frame itself.
READ_JSON(-1),
READ_DATA_FIELDS(-1);
private int length;
States(int length) {
this.length = length;
}
}
private States currentState = States.READ_HEADER;
private int requiredBytes = 0;
private int sequence = 0;
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy