Package org.apache.directmemory.memory.buffer

Examples of org.apache.directmemory.memory.buffer.MemoryBuffer.writeBytes()


            }

            p = instanciatePointer( buffer, allocator.getNumber(), expiresIn, NEVER_EXPIRES );

            buffer.writerIndex( 0 );
            buffer.writeBytes( payload );

            used.addAndGet( payload.length );

        }
        while ( p == null );
View Full Code Here


        final MemoryBuffer buffer1 = allocatedPointer1.getMemoryBuffer();
        Assert.assertNotNull( buffer1 );
        Assert.assertEquals( 0, buffer1.writerIndex() );
        Assert.assertEquals( size1, buffer1.capacity() );
        Assert.assertEquals( size1, buffer1.capacity() );
        buffer1.writeBytes( allocatedPayload1 );
        Assert.assertEquals( new String( allocatedPayload1 ), new String( mms.retrieve( allocatedPointer1 ) ) );

        final int size2 = 2 * SMALL_PAYLOAD_LENGTH;
        final byte[] allocatedPayload2 = MemoryTestUtils.generateRandomPayload( size2 );
        final Pointer<Object> allocatedPointer2 = mms.allocate( Object.class, allocatedPayload2.length, -1, -1 );
View Full Code Here

        final Pointer<Object> allocatedPointer2 = mms.allocate( Object.class, allocatedPayload2.length, -1, -1 );
        Assert.assertNotNull( allocatedPointer2 );
        final MemoryBuffer buffer2 = allocatedPointer2.getMemoryBuffer();
        Assert.assertNotNull( buffer2 );
        Assert.assertEquals( size2, buffer2.capacity() );
        buffer2.writeBytes( allocatedPayload2 );
        Assert.assertEquals( new String( allocatedPayload2 ), new String( mms.retrieve( allocatedPointer2 ) ) );

        // Ensure the new allocation has not overwritten other data
        Assert.assertEquals( new String( payload2 ), new String( mms.retrieve( pointer2 ) ) );
        Assert.assertEquals( new String( payload3 ), new String( mms.retrieve( pointer3 ) ) );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.