List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP10WireFormat.java
License:Apache License
/** * Write a ZMTP/1.0 greeting.//from w w w . jav a2s .co m * * @param out Target buffer. * @param identity Socket identity. */ static void writeGreeting(final ByteBuf out, final ByteBuffer identity) { writeLength(identity.remaining() + 1, out); out.writeByte(0x00); out.writeBytes(identity.duplicate()); }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a ZMTP/2.0 socket type./*from w ww .j a v a2s . c o m*/ * * @param out The buffer to write the socket type to. * @param socketType The socket type to write. */ static void writeSocketType(final ByteBuf out, final ZMTPSocketType socketType) { out.writeByte(socketType(socketType)); }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a ZMTP/2.0 greeting signature./*from w w w. j a v a2 s .co m*/ * * @param out The buffer to write the signature to. */ static void writeSignature(final ByteBuf out) { out.writeByte(0xff); out.writeLong(0x00); out.writeByte(0x7f); }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a ZMTP/2.0 greeting body.//from www . j a v a2s.c o m * * @param out The buffer to write the greeting body to. * @param socketType The socket type. * @param identity The socket identity. */ static void writeGreetingBody(final ByteBuf out, final ZMTPSocketType socketType, final ByteBuffer identity) { out.writeByte(0x01); // socket-type writeSocketType(out, socketType); // identity // the final-short flag octet out.writeByte(0x00); out.writeByte(identity.remaining()); out.writeBytes(identity.duplicate()); }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a backwards compatible ZMTP/2.0 greeting signature. * * @param out The buffer to write the signature to. * @param identity The socket identity.// w w w .jav a2s. co m */ static void writeCompatSignature(final ByteBuf out, final ByteBuffer identity) { out.writeByte(0xFF); out.writeLong(identity.remaining() + 1); out.writeByte(0x7f); }
From source file:com.srotya.sidewinder.core.ingress.binary.SeriesDataPointEncoder.java
License:Apache License
public static void encodeDPointToBuf(ByteBuf buf, DataPoint dataPoint) { byte[] dbNameBytes = dataPoint.getDbName().getBytes(); buf.writeInt(dbNameBytes.length);// ww w.j av a2s. co m buf.writeBytes(dbNameBytes); byte[] measurementNameBytes = dataPoint.getMeasurementName().getBytes(); buf.writeInt(measurementNameBytes.length); buf.writeBytes(measurementNameBytes); byte[] valueNameBytes = dataPoint.getValueFieldName().getBytes(); buf.writeInt(valueNameBytes.length); buf.writeBytes(valueNameBytes); buf.writeLong(dataPoint.getTimestamp()); if (dataPoint.isFp()) { buf.writeByte('0'); buf.writeDouble(dataPoint.getValue()); } else { buf.writeByte('1'); buf.writeLong(dataPoint.getLongValue()); } }
From source file:com.streamsets.pipeline.lib.parser.net.netflow.NetflowTestUtil.java
License:Apache License
public static void writeV5NetflowHeader(EmbeddedChannel channel, int count, long uptime, long seconds, long nanos, long flowSequence, int engineType, int engineId, int sampling) { final int version = 5; final ByteBuf buf = Unpooled.buffer(); buf.writeShort(version);/*w ww . j av a 2s.c o m*/ buf.writeShort(count); buf.writeInt((int) uptime); buf.writeInt((int) seconds); buf.writeInt((int) nanos); buf.writeInt((int) flowSequence); buf.writeByte(engineType); buf.writeByte(engineId); buf.writeShort(sampling); channel.writeInbound(buf); }
From source file:com.streamsets.pipeline.lib.parser.net.netflow.NetflowTestUtil.java
License:Apache License
public static void writeV5NetflowFlowRecord(EmbeddedChannel channel, long srcAddr, long destAddr, long nextHop, int snmpInput, int snmpOutput, long packets, long octets, long first, long last, int srcPort, int destPort, int tcpFlags, int proto, int tos, int srcAs, int destAs, int srcMask, int destMask ) {/* w w w.j av a 2 s . com*/ final ByteBuf buf = Unpooled.buffer(); buf.writeInt((int) srcAddr); buf.writeInt((int) destAddr); buf.writeInt((int) nextHop); buf.writeShort(snmpInput); buf.writeShort(snmpOutput); buf.writeInt((int) packets); buf.writeInt((int) octets); buf.writeInt((int) first); buf.writeInt((int) last); buf.writeShort(srcPort); buf.writeShort(destPort); // one empty pad byte buf.writeByte(0); buf.writeByte(tcpFlags); buf.writeByte(proto); buf.writeByte(tos); buf.writeShort(srcAs); buf.writeShort(destAs); buf.writeByte(srcMask); buf.writeByte(destMask); // two empty pad bytes buf.writeByte(0); buf.writeByte(0); channel.writeInbound(buf); }
From source file:com.tesora.dve.db.mysql.common.MysqlAPIUtils.java
License:Open Source License
public static void putLengthCodedString(ByteBuf cb, byte[] data, boolean codeNullasZero) { if (data != null) { // need to handle the case of empty string (NULL and empty string are different) // mysql puts (byte)0 in the buffer for empty string if (data.length > 0) { putLengthCodedLong(cb, data.length); cb.writeBytes(data);/*from ww w . j av a 2s. com*/ } else cb.writeZero(1); } else { if (!codeNullasZero) cb.writeByte(LEN_CODED_NULL); // this indicates the string is NULL else cb.writeZero(1); } }
From source file:com.tesora.dve.db.mysql.common.MysqlAPIUtils.java
License:Open Source License
public static void putLengthCodedString(ByteBuf cb, Object obj) { if (obj == null) { cb.writeByte(LEN_CODED_NULL); // this indicates the string is NULL } else if (obj instanceof byte[]) { putLengthCodedBinary(cb, (byte[]) obj); } else {//from www .j a v a 2 s . c o m putLengthCodedBinary(cb, obj.toString().getBytes()); } }