Examples of BBContainer


Examples of org.voltcore.utils.DBBPool.BBContainer

        return false;
    }

    private BBContainer createNewBuffer(final BBContainer origin, final boolean noSchedule)
    {
        return new BBContainer(origin.b()) {
            @Override
            public void discard() {
                checkDoubleFree();
                origin.discard();
                m_availableSnapshotBuffers.incrementAndGet();
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

        }

        List<BBContainer> outputBuffers = new ArrayList<BBContainer>(tableTasks.size());

        for (int ii = 0; ii < tableTasks.size(); ii++) {
            final BBContainer origin = DBBPool.allocateDirectAndPool(m_snapshotBufferLength);
            outputBuffers.add(createNewBuffer(origin, noSchedule));
        }

        return outputBuffers;
    }
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

                    + m_totalAvailable + " bytes; call tryRead() first");
        }

        int bytesCopied = 0;
        while (bytesCopied < output.length) {
            BBContainer firstC = m_readBuffers.peekFirst();
            if (firstC == null) {
                // Steal the write buffer
                m_writeBuffer.b().flip();
                m_readBuffers.add(m_writeBuffer);
                firstC = m_writeBuffer;
                m_writeBuffer = null;
            }
            ByteBuffer first = firstC.b();
            assert first.remaining() > 0;

            // Copy bytes from first into output
            int bytesRemaining = first.remaining();
            int bytesToCopy = output.length - bytesCopied;
            if (bytesToCopy > bytesRemaining) bytesToCopy = bytesRemaining;
            first.get(output, bytesCopied, bytesToCopy);
            bytesCopied += bytesToCopy;
            m_totalAvailable -= bytesToCopy;

            if (first.remaining() == 0) {
                // read an entire block: move it to the empty buffers list
                m_readBuffers.poll();
                firstC.discard();
            }
        }
    }
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

        int bytesQueued = 0;
        while ((ds = oldlist.poll()) != null) {
            processedWrites++;
            final int serializedSize = ds.getSerializedSize();
            if (serializedSize == DeferredSerialization.EMPTY_MESSAGE_LENGTH) continue;
            BBContainer outCont = m_queuedBuffers.peekLast();
            ByteBuffer outbuf = null;
            if (outCont == null || !outCont.b().hasRemaining()) {
                outCont = pool.acquire();
                outCont.b().clear();
                m_queuedBuffers.offer(outCont);
            }

            outbuf = outCont.b();

            //Fastpath, serialize to direct buffer creating no garbage
            if (outbuf.remaining() >= serializedSize) {
                final int oldLimit = outbuf.limit();
                outbuf.limit(outbuf.position() + serializedSize);
                final ByteBuffer slice = outbuf.slice();
                ds.serialize(slice);
                checkSloppySerialization(slice, ds);
                slice.position(0);
                bytesQueued += slice.remaining();
                outbuf.position(outbuf.limit());
                outbuf.limit(oldLimit);
            } else {
                //Slow path serialize to heap, and then put in buffers
                ByteBuffer buf = ByteBuffer.allocate(serializedSize);
                ds.serialize(buf);
                checkSloppySerialization(buf, ds);
                buf.position(0);
                bytesQueued += buf.remaining();
                while (buf.hasRemaining()) {
                    if (!outbuf.hasRemaining()) {
                        outCont = pool.acquire();
                        outbuf = outCont.b();
                        outbuf.clear();
                        m_queuedBuffers.offer(outCont);
                    }
                    if (outbuf.remaining() >= buf.remaining()) {
                        outbuf.put(buf);
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

     * and will be freed when the thread terminates.
     */
    void shutdown() {
        int bytesReleased = 0;
        m_isShutdown = true;
        BBContainer c = null;
        if (m_currentWriteBuffer != null) {
            bytesReleased += m_currentWriteBuffer.b().remaining();
            m_currentWriteBuffer.discard();
        }
        while ((c = m_queuedBuffers.poll()) != null) {
            //Buffer is not flipped after being written to in swap and serialize, need to do it here
            c.b().flip();
            bytesReleased += c.b().remaining();
            c.discard();
        }
        updateQueued(-bytesReleased, false);
    }
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

    public NetworkDBBPool() {
        m_numBuffers = LIMIT;
    }
    BBContainer acquire() {
       final BBContainer cont = m_buffers.poll();
       if (cont == null) {
           final BBContainer originContainer = DBBPool.allocateDirect(1024 * 32);
           return new BBContainer(originContainer.b()) {
                @Override
                public void discard() {
                    checkDoubleFree();
                    //If we had to allocate over the desired limit, start discarding
                    if (m_buffers.size() > m_numBuffers) {
                        originContainer.discard();
                        return;
                    }
                    m_buffers.push(originContainer);
                }
           };
       }
       return new BBContainer(cont.b()) {
           @Override
           public void discard() {
               checkDoubleFree();
               m_buffers.push(cont);
           }
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

           }
       };
    }

    void clear() {
        BBContainer cont = null;
        while ((cont = m_buffers.poll()) != null) {
            cont.discard();
        }
    }
View Full Code Here

Examples of org.voltcore.utils.DBBPool.BBContainer

                        for (Integer partitionId : saveFile.getPartitionIds()) {
                            partitionIds.add(partitionId);
                        }
                        if (validate && saveFile.getCompleted()) {
                            while (saveFile.hasMoreChunks()) {
                                BBContainer cont = saveFile.getNextChunk();
                                if (cont != null) {
                                    cont.discard();
                                }
                            }
                        }
                        partitionIds.removeAll(saveFile.getCorruptedPartitionIds());
                        String nonce = parseNonceFromSnapshotFilename(f.getName());
View Full Code Here

Examples of org.voltdb.utils.DBBPool.BBContainer

        assertTrue(expected <= size);
        b.rewind();

        // Make sure we can still do this with a BufferPool
        DBBPool buffer_pool = new DBBPool(false, false);
        BBContainer bc = buffer_pool.acquire(size);
        error.serializeToBuffer(bc.b);
        bc.b.rewind();
        assertEquals(expected, bc.b.getInt());
        bc.b.rewind();
       
View Full Code Here

Examples of org.voltdb.utils.DBBPool.BBContainer

                int procId = catalog_proc.getId();
                this.singletonSerializer.writeInt(procId);
                this.singletonSerializer.writeString(catalog_proc.getName());
            } // FOR

            BBContainer b = this.singletonSerializer.getBBContainer();
            this.fstream.write(b.b.asReadOnlyBuffer());
            this.fstream.force(true);
        } catch (Exception e) {
            String message = "Failed to write log headers";
            throw new ServerFaultException(message, e);
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.