Examples of ByteBufferAllocator


Examples of org.apache.directmemory.memory.allocator.ByteBufferAllocator

        allocators = new ArrayList<ByteBufferAllocator>( numberOfBuffers );

        for ( int i = 0; i < numberOfBuffers; i++ )
        {
            final ByteBufferAllocator allocator = instanciateByteBufferAllocator( i, size );
            allocators.add( allocator );
        }

        allocationPolicy.init( allocators );
View Full Code Here

Examples of org.apache.directmemory.memory.allocator.ByteBufferAllocator

    @Override
    public Pointer<V> store( byte[] payload, int expiresIn )
    {
        Pointer<V> p = null;
        ByteBufferAllocator allocator = null;
        int allocationNumber = 0;
        do
        {
            allocationNumber++;
            allocator = allocationPolicy.getActiveAllocator( allocator, allocationNumber );
            if ( allocator == null )
            {
                if ( returnsNullWhenFull() )
                {
                    return null;
                }
                else
                {
                    throw new BufferOverflowException();
                }
            }
            final ByteBuffer buffer = allocator.allocate( payload.length );

            if ( buffer == null )
            {
                continue;
            }

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

            buffer.rewind();
            buffer.put( payload );

            used.addAndGet( payload.length );
View Full Code Here

Examples of org.apache.directmemory.memory.allocator.ByteBufferAllocator

    public <T extends V> Pointer<V> allocate( final Class<T> type, final int size, final long expiresIn,
                                              final long expires )
    {

        Pointer<V> p = null;
        ByteBufferAllocator allocator = null;
        int allocationNumber = 0;
        do
        {
            allocationNumber++;
            allocator = allocationPolicy.getActiveAllocator( allocator, allocationNumber );
            if ( allocator == null )
            {
                if ( returnsNullWhenFull() )
                {
                    return null;
                }
                else
                {
                    throw new BufferOverflowException();
                }
            }

            final ByteBuffer buffer = allocator.allocate( size );

            if ( buffer == null )
            {
                continue;
            }

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

            used.addAndGet( size );
        }
        while ( p == null );
View Full Code Here

Examples of org.apache.directmemory.memory.allocator.ByteBufferAllocator

        }

        // Thread safely increment and get the next buffer's index
        int i = incrementAndGetBufferIndex();

        final ByteBufferAllocator allocator = allocators.get( i );

        return allocator;
    }
View Full Code Here

Examples of org.apache.http.nio.util.ByteBufferAllocator

        connectionManager = new PoolingClientAsyncConnectionManager(ioReactor, registry,
                                                                    connectionTTL, TimeUnit.MILLISECONDS) {
            @Override
            protected ClientAsyncConnectionFactory createClientAsyncConnectionFactory() {
                final HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
                final ByteBufferAllocator allocator = new HeapByteBufferAllocator();

                return new ClientAsyncConnectionFactory() {
                    @Override
                    public ClientAsyncConnection create(String id, IOSession iosession, HttpParams params) {
                        return new DefaultClientAsyncConnection(id, iosession,
View Full Code Here

Examples of org.apache.http.nio.util.ByteBufferAllocator

    @Override
    public ConsumingNHttpEntity entityRequest(HttpEntityEnclosingRequest request,
            HttpContext context) throws HttpException, IOException {
        final RESTfulCommand command = new RESTfulCommand(
                request.getRequestLine().getUri());
        final ByteBufferAllocator allocator;
        if (command.getMethodName().equalsIgnoreCase(REQ_CMD_UPLOAD)) {
            // file upload
            allocator = new BeeByteBufferAllocator();
            // should write header for content type or other parameter to pass to threaded handler
            request.addHeader(REQ_TEMPFILE,
View Full Code Here

Examples of org.apache.http.nio.util.ByteBufferAllocator

        connectionManager = new PoolingClientAsyncConnectionManager(ioReactor, registry,
                                                                    connectionTTL, TimeUnit.MILLISECONDS) {
            @Override
            protected ClientAsyncConnectionFactory createClientAsyncConnectionFactory() {
                final HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
                final ByteBufferAllocator allocator = new HeapByteBufferAllocator();

                return new ClientAsyncConnectionFactory() {
                    @Override
                    public ClientAsyncConnection create(String id, IOSession iosession, HttpParams params) {
                        return new DefaultClientAsyncConnection(id, iosession,
View Full Code Here

Examples of org.apache.http.nio.util.ByteBufferAllocator

        connectionManager = new PoolingClientAsyncConnectionManager(ioReactor, registry,
                                                                    connectionTTL, TimeUnit.MILLISECONDS) {
            @Override
            protected ClientAsyncConnectionFactory createClientAsyncConnectionFactory() {
                final HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
                final ByteBufferAllocator allocator = new HeapByteBufferAllocator();

                return new ClientAsyncConnectionFactory() {
                    @Override
                    public ClientAsyncConnection create(String id, IOSession iosession, HttpParams params) {
                        return new DefaultClientAsyncConnection(id, iosession,
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.