Package org.voltdb.messaging

Examples of org.voltdb.messaging.FastSerializer$BufferGrowCallback


    @Override
    public void run(ClientResponseImpl parameter) {
        if (debug.val)
            LOG.debug(String.format("Got ClientResponse callback for txn #%d! Sending back to %s",
                      parameter.getTransactionId(), HStoreThreadManager.formatSiteName(this.destSiteId)));
        FastSerializer fs = new FastSerializer();
        try {
            parameter.writeExternal(fs);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        ByteString bs = ByteString.copyFrom(fs.getBuffer());
        TransactionRedirectResponse response = TransactionRedirectResponse.newBuilder()
                                                              .setSenderSite(this.sourceSiteId)
                                                              .setOutput(bs)
                                                              .build();
        this.orig_callback.run(response);
View Full Code Here


                      ts.getPredictTouchedPartitions().size(), ts.getPredictTouchedPartitions()));
        assert(callback != null) :
            String.format("Trying to initialize %s with a null TransactionInitCallback", ts);
       
        ParameterSet procParams = ts.getProcedureParameters();
        FastSerializer fs = this.serializers.get();
       
        // Look at the Procedure to see whether it has prefetchable queries. If it does,
        // then embed them in the TransactionInitRequest. We will need to generate a separate
        // request for each site that we want to execute different queries on.
        // TODO: We probably don't want to bother prefetching for txns that only touch
View Full Code Here

        RpcCallback<ClientResponseImpl> wrapperCallback = new RpcCallback<ClientResponseImpl>() {
            @Override
            public void run(ClientResponseImpl parameter) {
                if (trace.val) LOG.trace("Serializing ClientResponse to byte array:\n" + parameter);
               
                FastSerializer fs = new FastSerializer();
                try {
                    parameter.writeExternal(fs);
                    clientCallback.run(fs.getBBContainer().b.array());
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                } finally {
                    fs.clear();
                }
            }
        };
       
        if (this.preProcessorQueue != null) {
View Full Code Here

                                                                              catalog_proc.getName(),
                                                                              orig_ts.getProcedureParameters().toArray());
                spi.setBasePartition(redirect_partition);
                spi.setRestartCounter(orig_ts.getRestartCounter()+1);
               
                FastSerializer out = this.outgoingSerializers.get();
                try {
                    out.writeObject(spi);
                } catch (IOException ex) {
                    String msg = "Failed to serialize StoredProcedureInvocation to redirect txn";
                    throw new ServerFaultException(msg, ex, orig_ts.getTransactionId());
                }
               
                RedirectCallback callback;
                try {
                    // callback = (RedirectCallback)objectPools.CALLBACKS_TXN_REDIRECT_REQUEST.borrowObject();
                    callback = new RedirectCallback(this);
                    callback.init(orig_ts.getClientCallback());
                } catch (Exception ex) {
                    String msg = "Failed to get TransactionRedirectCallback";
                    throw new ServerFaultException(msg, ex, orig_ts.getTransactionId());  
                }
                this.hstore_coordinator.transactionRedirect(out.getBytes(),
                                                            callback,
                                                            redirect_partition);
                out.clear();
                if (hstore_conf.site.txn_counters) TransactionCounter.REDIRECTED.inc(orig_ts.getProcedure());
                return (Status.ABORT_RESTART);
               
            // Allow local redirect
            } else if (orig_ts.getRestartCounter() <= 1) {
View Full Code Here

    public CommandLogWriter(HStoreSite hstore_site, File outputFile) {
        this.hstore_site = hstore_site;
        this.hstore_conf = hstore_site.getHStoreConf();
        this.catalogContext = hstore_site.getCatalogContext();
        this.outputFile = outputFile;
        this.singletonSerializer = new FastSerializer(true, true);
        // this.group_commit_size = Math.max(1,
        // hstore_conf.site.exec_command_logging_group_commit); //Group commit
        // threshold, or 1 if group commit is turned off

        // Number of local partitions
View Full Code Here

        // -------------------------------
        // NO GROUP COMMIT -- FINISH AND RETURN TRUE
        // -------------------------------
        else {
            try {
                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

    FastSerializer heapOut;
    FastSerializer directOut;
    FastSerializer poolOut;
    DBBPool pool;
    public void setUp() {
        heapOut = new FastSerializer();
        directOut = new FastSerializer(true, true);
        pool = new DBBPool();
        poolOut = new FastSerializer(pool);
    }
View Full Code Here

        testHMLE(directOut);
        testHMLE(poolOut);
    }

    private void testHMLE(FastSerializer out) throws IOException {
        out = new FastSerializer(false, false);

        // 1 MB message
        byte[] huge = new byte[1024*1024];
        huge[huge.length-1] = 42;
        out.write(huge);
View Full Code Here

        byte[] bytes = out.getBytes();
        assertEquals(4, bytes.length);
    }

    public void testDirect() throws IOException {
        directOut = new FastSerializer(false, true);
        assertTrue(directOut.getBBContainer().b.isDirect());
        testHugeMessage();
        // Should still be direct after resizing.
        assertTrue(directOut.getBBContainer().b.isDirect());
        directOut.getBBContainer().discard();
View Full Code Here

                Object... parameters) throws IOException {
            final long handle = m_handle.getAndIncrement();
            StoredProcedureInvocation invocation = new StoredProcedureInvocation(
                        handle, procName, -1, parameters);
            m_callbacks.put(handle, callback);
            FastSerializer fs = new FastSerializer();
            fs.writeObjectForMessaging(invocation);
            connection.writeStream().enqueue(fs.getBuffer());
        }
View Full Code Here

TOP

Related Classes of org.voltdb.messaging.FastSerializer$BufferGrowCallback

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.