OffHeapByteBuffer implements OffHeapStore { protected byte[] header(int length) { final byte[] header = new byte[5]; header[0] = USED; header[1] = (byte) ((length >>> 24) & 0xFF); header[2] = (byte) ((length >>> 16) & 0xFF); header[3] = (byte) ((length >>> 8) & 0xFF); header[4] = (byte) ((length >>> 0) & 0xFF); return header; } OffHeapByteBuffer(int index, int capacity);  OffHeapByteBuffer(int index, int capacity, int concurrencyLevel); byte[] retrieve(final Pointer pointer); byte[] remove(Pointer pointer); Pointer store(final byte[] payload, final long expiry); Pointer store(final Allocation allocation, byte[] payload, final long expiry); Pointer update(final Pointer pointer, final byte[] payload, final long expiry); void free(); long dirtyMemory(); long usedMemory(); long freeMemory(); int getIndex(); final static int DEFAULT_CONCURRENCY_LEVEL; }
@Test(expected = OffHeapByteBufferException.class) public void headerDirty() { int size = 5; byte[] bytes = new byte[size]; bytes[0] = -1; random.nextBytes(bytes); buffer.header(bytes); }
@Test(expected = OffHeapByteBufferException.class) public void headerFree() { int size = 5; byte[] bytes = new byte[size]; bytes[0] = 0; random.nextBytes(bytes); buffer.header(bytes); }
@Test(expected = OffHeapByteBufferException.class) public void headerUsed() { int size = 5; byte[] bytes = new byte[size]; bytes[0] = 1; random.nextBytes(bytes); buffer.header(bytes); }