@Override public Object createManagementObject() { return createJmxManagementObject(); }
@Override public Buffer wrap(final String s, final Charset charset) { return wrap(s.getBytes(charset)); }
/** * Allocates a buffer of at least the size requested. * <p/> * Keep in mind that the capacity of the buffer may be greater than the * allocation request. The limit however, will be set to the specified * size. The memory beyond the limit, is available for use. * * @param size the min {@link Buffer} size to be allocated. * @return a buffer with a limit of the specified <tt>size</tt>. */ @Override public Buffer allocateAtLeast(int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } if (size == 0) { return Buffers.EMPTY_BUFFER; } return size <= maxPooledBufferSize ? getPoolFor(size).allocate() : allocateToCompositeBuffer(newCompositeBuffer(), size); }
/** * For this implementation, this method simply calls through to * {@link #allocateAtLeast(int)}; */ @Override public Buffer allocate(final int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } return allocateAtLeast(size).limit(size); }
if (!isPowerOfTwo(baseBufferSize) || !isPowerOfTwo(growthFactor)) { throw new IllegalArgumentException("minBufferSize and growthFactor must be a power of two");
@Test public void testIllegalAllocationArgument() throws Exception { PooledMemoryManager mm = new PooledMemoryManager(DEFAULT_BASE_BUFFER_SIZE, 1, 0, 1, DEFAULT_HEAP_USAGE_PERCENTAGE, DEFAULT_PREALLOCATED_BUFFERS_PERCENTAGE, isDirect); // allocation request must be greater than zero try { mm.allocate(-1); fail(); } catch (IllegalArgumentException iae) { // expected } catch (Exception e) { fail(); } try { mm.allocateAtLeast(-1); fail(); } catch (IllegalArgumentException iae) { // expected } catch (Exception e) { fail(); } }
/** * Allocates a buffer of at least the size requested. * <p/> * Keep in mind that the capacity of the buffer may be greater than the * allocation request. The limit however, will be set to the specified * size. The memory beyond the limit, is available for use. * * @param size the min {@link Buffer} size to be allocated. * @return a buffer with a limit of the specified <tt>size</tt>. */ @Override public Buffer allocateAtLeast(int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } if (size == 0) { return Buffers.EMPTY_BUFFER; } return size <= maxPooledBufferSize ? getPoolFor(size).allocate() : allocateToCompositeBuffer(newCompositeBuffer(), size); }
/** * For this implementation, this method simply calls through to * {@link #allocateAtLeast(int)}; */ @Override public Buffer allocate(final int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } return allocateAtLeast(size).limit(size); }
if (!isPowerOfTwo(baseBufferSize) || !isPowerOfTwo(growthFactor)) { throw new IllegalArgumentException("minBufferSize and growthFactor must be a power of two");
/** * Allocates a buffer of at least the size requested. * <p/> * Keep in mind that the capacity of the buffer may be greater than the * allocation request. The limit however, will be set to the specified * size. The memory beyond the limit, is available for use. * * @param size the min {@link Buffer} size to be allocated. * @return a buffer with a limit of the specified <tt>size</tt>. */ @Override public Buffer allocateAtLeast(int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } if (size == 0) { return Buffers.EMPTY_BUFFER; } return size <= maxPooledBufferSize ? getPoolFor(size).allocate() : allocateToCompositeBuffer(newCompositeBuffer(), size); }
@Override public Buffer wrap(byte[] data, int offset, int length) { return wrap(ByteBuffer.wrap(data, offset, length)); }
/** * For this implementation, this method simply calls through to * {@link #allocateAtLeast(int)}; */ @Override public Buffer allocate(final int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } return allocateAtLeast(size).limit(size); }
@Override public Object createManagementObject() { return createJmxManagementObject(); }
if (!isPowerOfTwo(baseBufferSize) || !isPowerOfTwo(growthFactor)) { throw new IllegalArgumentException("minBufferSize and growthFactor must be a power of two");
/** * Allocates a buffer of at least the size requested. * <p/> * Keep in mind that the capacity of the buffer may be greater than the * allocation request. The limit however, will be set to the specified * size. The memory beyond the limit, is available for use. * * @param size the min {@link Buffer} size to be allocated. * @return a buffer with a limit of the specified <tt>size</tt>. */ @Override public Buffer allocateAtLeast(int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } if (size == 0) { return Buffers.EMPTY_BUFFER; } return size <= maxPooledBufferSize ? getPoolFor(size).allocate() : allocateToCompositeBuffer(newCompositeBuffer(), size); }
@Override public Buffer wrap(final String s, final Charset charset) { return wrap(s.getBytes(charset)); }
/** * For this implementation, this method simply calls through to * {@link #allocateAtLeast(int)}; */ @Override public Buffer allocate(final int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } return allocateAtLeast(size).limit(size); }
@Override public Object createManagementObject() { return createJmxManagementObject(); }
if (!isPowerOfTwo(baseBufferSize) || !isPowerOfTwo(growthFactor)) { throw new IllegalArgumentException("minBufferSize and growthFactor must be a power of two");
/** * Allocates a buffer of at least the size requested. * <p/> * Keep in mind that the capacity of the buffer may be greater than the * allocation request. The limit however, will be set to the specified * size. The memory beyond the limit, is available for use. * * @param size the min {@link Buffer} size to be allocated. * @return a buffer with a limit of the specified <tt>size</tt>. */ @Override public Buffer allocateAtLeast(int size) { if (size < 0) { throw new IllegalArgumentException("Requested allocation size must be greater than or equal to zero."); } if (size == 0) { return Buffers.EMPTY_BUFFER; } return size <= maxPooledBufferSize ? getPoolFor(size).allocate() : allocateToCompositeBuffer(newCompositeBuffer(), size); }