List of usage examples for io.netty.buffer ByteBufAllocator buffer
ByteBuf buffer(int initialCapacity);
From source file:com.addthis.meshy.SourceHandler.java
License:Apache License
private static ByteBuf allocateSendBuffer(ByteBufAllocator alloc, int type, int session, byte[] data) { ByteBuf sendBuffer = alloc.buffer(MESHY_BYTE_OVERHEAD + data.length); sendBuffer.writeInt(type);//from www. j av a 2s . co m sendBuffer.writeInt(session); sendBuffer.writeInt(data.length); sendBuffer.writeBytes(data); return sendBuffer; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getBulkStringResponse(ByteBufAllocator alloc, byte[] value) { ByteBuf response = alloc.buffer(value.length + 20); response.writeByte(BULK_STRING_ID);//w ww .java 2 s.co m response.writeBytes(intToBytes(value.length)); response.writeBytes(CRLFar); response.writeBytes(value); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getBulkStringResponse(ByteBufAllocator alloc, String value) { byte[] valueAr = stringToBytes(value); int length = valueAr == null ? 0 : valueAr.length; ByteBuf response = alloc.buffer(length + 20); response.writeByte(BULK_STRING_ID);/*from ww w . j a v a 2 s.c om*/ response.writeBytes(intToBytes(length)); response.writeBytes(CRLFar); response.writeBytes(valueAr); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getSimpleStringResponse(ByteBufAllocator alloc, String string) { byte[] simpAr = stringToBytes(string); ByteBuf response = alloc.buffer(simpAr.length + 20); response.writeByte(SIMPLE_STRING_ID); response.writeBytes(simpAr);/*www. j ava2 s . c o m*/ response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getErrorResponse(ByteBufAllocator alloc, String error) { byte[] errorAr = stringToBytes(error); ByteBuf response = alloc.buffer(errorAr.length + 25); response.writeByte(ERROR_ID);/*from ww w. j ava 2s .c o m*/ response.writeBytes(err); response.writeBytes(errorAr); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getNoAuthResponse(ByteBufAllocator alloc, String error) { byte[] errorAr = stringToBytes(error); ByteBuf response = alloc.buffer(errorAr.length + 25); response.writeByte(ERROR_ID);//from w ww.j a va 2s . c o m response.writeBytes(noAuth); response.writeBytes(errorAr); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getWrongTypeResponse(ByteBufAllocator alloc, String error) { byte[] errorAr = stringToBytes(error); ByteBuf response = alloc.buffer(errorAr.length + 31); response.writeByte(ERROR_ID);/*from w w w . ja v a 2 s . co m*/ response.writeBytes(wrongType); response.writeBytes(errorAr); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getIntegerResponse(ByteBufAllocator alloc, int integer) { ByteBuf response = alloc.buffer(15); response.writeByte(INTEGER_ID);/* w ww .ja v a 2s .c om*/ response.writeBytes(intToBytes(integer)); response.writeBytes(CRLFar); return response; }
From source file:com.gemstone.gemfire.internal.redis.Coder.java
License:Apache License
public static final ByteBuf getIntegerResponse(ByteBufAllocator alloc, long l) { ByteBuf response = alloc.buffer(25); response.writeByte(INTEGER_ID);//from ww w .ja v a 2 s.c o m response.writeBytes(longToBytes(l)); response.writeBytes(CRLFar); return response; }
From source file:com.github.milenkovicm.kafka.AbstractTest.java
License:Apache License
/** * Creates and references buffer to be dereferenced when test finishes. * * @param allocator/*from w w w .j a va 2 s . com*/ * allocator to use * @param initialCapacity * buffer capacity * @return allocated buffer */ public static ByteBuf freeLaterBuffer(final ByteBufAllocator allocator, final int initialCapacity) { final ByteBuf buffer = allocator.buffer(initialCapacity); freeLaterQueue.add(buffer); return buffer; }