Package org.voltdb.messaging

Examples of org.voltdb.messaging.FastSerializer$BufferGrowCallback


            stringer.key(id.toString()).object();
            for (Entry<Procedure, MarkovGraph> e : this.markovs.get(id).entrySet()) {
                // Optimization: Hex-encode all of the MarkovGraphs so that we don't get crushed
                // when trying to read them all back at once when we create the JSONObject
                try {
                    FastSerializer fs = new FastSerializer(false, false); // C++ needs little-endian
                    fs.write(e.getValue().toJSONString().getBytes());
                    String hexString = fs.getHexEncodedBytes();
                    stringer.key(CatalogKey.createKey(e.getKey())).value(hexString);
                } catch (Exception ex) {
                    String msg = String.format("Failed to serialize %s MarkovGraph for Id %d", e.getKey(), id);
                    LOG.fatal(msg);
                    throw new JSONException(ex);
View Full Code Here


        if (isSync()) retval += "SYNC|";
        return retval;
    }

    public ByteBuffer toBuffer() throws IOException {
        FastSerializer fs = new FastSerializer();
        writeToFastSerializer(fs);
        return fs.getBuffer();
    }
View Full Code Here

                                                        .setTransactionId(ts.getTransactionId().longValue())
                                                        .setProcedureId(ts.getProcedure().getId())
                                                        .setBasePartition(ts.getBasePartition())
                                                        .addAllPartitions(ts.getPredictTouchedPartitions());
        if (paramsSerializer != null) {
            FastSerializer fs = paramsSerializer;
            try {
                fs.clear();
                ts.getProcedureParameters().writeExternal(fs);
                builder.setProcParams(ByteString.copyFrom(fs.getBBContainer().b));
            } catch (Exception ex) {
                throw new RuntimeException("Failed to serialize ParameterSet for " + ts, ex);
            }
        }
       
View Full Code Here

                    siteId,
                    partitionId,
                    hostId,
                    hostname);
        checkErrorCode(errorCode);
        fsForParameterSet = new FastSerializer(false, new BufferGrowCallback() {
            public void onBufferGrow(final FastSerializer obj) {
                if (trace.val) LOG.trace("Parameter buffer has grown. re-setting to EE..");
                final int code = nativeSetBuffers(pointer,
                        fsForParameterSet.getContainerNoFlip().b,
                        fsForParameterSet.getContainerNoFlip().b.capacity(),
View Full Code Here

            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
                System.exit(-1);
            }
            byte passwordHash[] = md.digest(password.getBytes());
            FastSerializer fs = new FastSerializer();
            fs.writeInt(0);             // placeholder for length
            fs.writeByte(0);            // version
            fs.writeString(service);    // data service (export|database)
            fs.writeString(username);
            fs.write(passwordHash);
            final ByteBuffer fsBuffer = fs.getBuffer();
            final ByteBuffer b = ByteBuffer.allocate(fsBuffer.remaining());
            b.put(fsBuffer);
            final int size = fsBuffer.limit() - 4;
            b.flip();
            b.putInt(size);
View Full Code Here

            public Long call() throws Exception {
                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();
                    }
View Full Code Here

     * Write out the internal state information for this Exception
     * @throws IOException
     */
    @Override
    protected void p_serializeToBuffer(ByteBuffer b) throws IOException {
        FastSerializer fs = new FastSerializer();
        try {
            fs.writeShort(this.block_id);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        b.put(fs.getBuffer());
    }
View Full Code Here

            }
            updateLastPendingWriteTimeAndQueueBackpressure();
            m_queuedWrites.offer(new DeferredSerialization() {
                @Override
                public BBContainer serialize(final DBBPool pool) throws IOException {
                    final FastSerializer fs = new FastSerializer(pool, m_port.m_expectedOutgoingMessageSize);
                    return fs.writeObjectForMessaging(f);
                }

                @Override
                public void cancel() {}
            });
View Full Code Here

            }
            updateLastPendingWriteTimeAndQueueBackpressure();
            m_queuedWrites.offer(new DeferredSerialization() {
                @Override
                public BBContainer serialize(final DBBPool pool) throws IOException {
                    final FastSerializer fs = new FastSerializer(pool, expectedSize);
                    return fs.writeObjectForMessaging(f);
                }

                @Override
                public void cancel() {}
            });
View Full Code Here

    @Override
    public int calculateInvocationSerializedSize(String procName,
            Object... parameters) {
        final StoredProcedureInvocation invocation =
            new StoredProcedureInvocation(0, procName, parameters);
        final FastSerializer fds = new FastSerializer();
        int size = 0;
        try {
            final BBContainer c = fds.writeObjectForMessaging(invocation);
            size = c.b.remaining();
            c.discard();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
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.