Package org.voltdb.utils.DBBPool

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


                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

                FastSerializer fs = this.singletonSerializer;
                assert (fs != null);
                fs.clear();
                this.singletonLogEntry.init(ts);
                fs.writeObject(this.singletonLogEntry);
                BBContainer b = fs.getBBContainer();
                this.fstream.write(b.b.asReadOnlyBuffer());
                this.fstream.force(true);
                this.singletonLogEntry.finish();
            } catch (Exception e) {
                String message = "Failed to write single log entry for " + ts.toString();
View Full Code Here

    }

    public void testDefaultPoolCtor() {
        DBBPool p1 = new DBBPool();
        assertEquals(0, p1.bytesLoanedLocally());
        BBContainer containers1[] = p1.acquire( NUM_BUFFERS, INITIAL_ALLOCATION);
        assertTrue((NUM_BUFFERS * INITIAL_ALLOCATION) <= p1.bytesAllocatedGlobally());
        for (BBContainer c : containers1) {
            c.discard();
        }

        // verify that globalbytes is really all pools
        DBBPool p2 = new DBBPool();
        BBContainer containers2[] = p2.acquire( 33, INITIAL_ALLOCATION);
        assertTrue(p1.bytesAllocatedGlobally() >=
                     (p1.bytesAllocatedLocally() + p2.bytesAllocatedLocally()));

        for (BBContainer c : containers2) {
            c.discard();
View Full Code Here

        loadTestTables(catalog);

        sourceEngine.activateTableStream( WAREHOUSE_TABLEID, TableStreamType.RECOVERY );
        sourceEngine.activateTableStream( STOCK_TABLEID, TableStreamType.RECOVERY );

        BBContainer origin = DBBPool.allocateDirect(1024 * 1024 * 2);
        try {
            origin.b.clear();
            long address = org.voltdb.utils.DBBPool.getBufferAddress(origin.b);
            BBContainer container = new BBContainer(origin.b, address){

                @Override
                public void discard() {
                }};

View Full Code Here

                        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());
                        Snapshot s = snapshots.get(saveFile.getCreateTime());
View Full Code Here

        builder.setStatus(status);
       
        // SerializableException
        if (error != null) {
            int size = error.getSerializedSize();
            BBContainer bc = this.buffer_pool.acquire(size);
            try {
                error.serializeToBuffer(bc.b);
            } catch (IOException ex) {
                String msg = "Failed to serialize error for " + ts;
                throw new ServerFaultException(msg, ex);
            }
            bc.b.rewind();
            builder.setError(ByteString.copyFrom(bc.b));
            bc.discard();
        }
       
        // Push dependencies back to the remote partition that needs it
        if (status == Status.OK) {
            for (int i = 0, cnt = result.size(); i < cnt; i++) {
View Full Code Here

                final long handle = m_handle.getAndIncrement();
                final StoredProcedureInvocation invocation =
                    new StoredProcedureInvocation(handle, procName, -1, parameters);

                final FastSerializer fs = new FastSerializer();
                final BBContainer c = fs.writeObjectForMessaging(invocation);
                do {
                    channel.write(c.b);
                    if (c.b.hasRemaining()) {
                        Thread.yield();
                    }
                }
                while(c.b.hasRemaining());
                c.discard();
                return handle;
            }
        });
    }
View Full Code Here

        return read;
    }

    private final void drainWriteStream(final DBBPool pool) throws IOException {
        //Safe to do this with a separate embedded synchronization because no interest ops are modded
        final BBContainer results[] = m_writeStream.swapAndSerializeQueuedWrites(pool);

        /*
         * All interactions with write stream must be protected
         * with a lock to ensure that interests ops are consistent with
         * the state of writes queued to the stream. This prevent
View Full Code Here

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

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

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

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

        if (bytesCopied > 0) {
            m_globalAvailable.addAndGet(0 - bytesCopied);
View Full Code Here

TOP

Related Classes of org.voltdb.utils.DBBPool.BBContainer

Copyright © 2018 www.massapicom. 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.