Package org.voltdb.messaging

Examples of org.voltdb.messaging.FastDeserializer


    public int size() {
        return m_params.length;
    }

    static Object getParameterAtIndex(int partitionIndex, ByteBuffer unserializedParams) throws IOException {
        FastDeserializer in = new FastDeserializer(unserializedParams);
        int paramLen = in.readShort();
        if (partitionIndex >= paramLen) {
            // error if caller desires out of bounds parameter
            throw new RuntimeException("Invalid partition parameter requested.");
        }
        for (int i = 0; i < partitionIndex; ++i) {
View Full Code Here


//            this.throttle.set(val);
//        } // SYNCH
//    }

    public static StoredProcedureInvocation decodeRequest(byte[] bytes) {
        final FastDeserializer fds = new FastDeserializer(ByteBuffer.wrap(bytes));
        StoredProcedureInvocation task;
        try {
            task = fds.readObject(StoredProcedureInvocation.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        task.buildParameterSet();
View Full Code Here

                    uniqueId,
                    undoToken);

        try {
            checkErrorCode(errorCode);
            FastDeserializer fds = fallbackBuffer == null ? deserializer : new FastDeserializer(fallbackBuffer);
            // get a copy of the result buffers and make the tables
            // use the copy
            try {
                // read the complete size of the buffer used
                final int totalSize = fds.readInt();
                // check if anything was changed
                final boolean dirty = fds.readBoolean();
                if (dirty)
                    m_dirty = true;
                // get a copy of the buffer
                final ByteBuffer fullBacking = fds.readBuffer(totalSize);
                final VoltTable[] results = new VoltTable[batchSize];
                for (int i = 0; i < batchSize; ++i) {
                    final int numdeps = fullBacking.getInt(); // number of dependencies for this frag
                    assert(numdeps == 1);
                    @SuppressWarnings("unused")
View Full Code Here

            if (!timeoutFuture.cancel(false)) {
                return null;
            }

            message.flip().position(1);//skip version
            FastDeserializer fds = new FastDeserializer(message);
            final String service = fds.readString();
            final String username = fds.readString();
            final byte password[] = new byte[20];
            //We should be left with SHA-1 bytes only.
            if (message.remaining() != 20) {
                authLog.warn("Failure to authenticate connection(" + socket.socket().getRemoteSocketAddress()
                        + "): user " + username + " failed authentication.");
View Full Code Here

        }
    }

    public void initFromBuffer(ByteBuffer buf) throws IOException
    {
        FastDeserializer in = new FastDeserializer(buf);
        byte version = in.readByte();// version number also embeds the type
        type = ProcedureInvocationType.typeFromByte(version);

        /*
         * If it's a replicated invocation, there should be two txn IDs
         * following the version byte. The first txn ID is the new txn ID, the
         * second one is the original txn ID.
         */
        if (type == ProcedureInvocationType.REPLICATED) {
            originalTxnId = in.readLong();
            originalUniqueId = in.readLong();
        }

        procName = in.readString().intern();
        clientHandle = in.readLong();
        // do not deserialize parameters in ClientInterface context
        serializedParams = in.remainder();
        final ByteBuffer duplicate = serializedParams.duplicate();
        params = new FutureTask<ParameterSet>(new Callable<ParameterSet>() {
            @Override
            public ParameterSet call() throws Exception {
                return ParameterSet.fromByteBuffer(duplicate);
View Full Code Here

                } else {
                    throw new IOException("Checksum mismatch");
                }
            }

            FastDeserializer fd = new FastDeserializer(saveRestoreHeader);
            byte completedByte = fd.readByte();
            m_completed = failedCRCDueToNotCompleted ? false : (completedByte == 1 ? true : false);
            for (int ii = 0; ii < 4; ii++) {
                m_versionNum[ii] = fd.readInt();
            }

            /*
             * Support the original pre 1.3 header format as well as a new JSON format.
             * JSON will make it possible to add info to a snapshot header without
             * breaking backwards compatibility.
             */
            if (m_versionNum[3] == 0) {
                m_txnId = fd.readLong();
                m_timestamp = TransactionIdManager.getTimestampFromTransactionId(m_txnId);
                m_hostId = fd.readInt();
                m_hostname = fd.readString();
                m_clusterName = fd.readString();
                m_databaseName = fd.readString();
                m_tableName = fd.readString();
                m_isReplicated = fd.readBoolean();
                m_isCompressed = false;
                m_checksumType = ChecksumType.CRC32;
                if (!m_isReplicated) {
                    m_partitionIds = (int[])fd.readArray(int.class);
                    if (!m_completed) {
                        for (Integer partitionId : m_partitionIds) {
                            m_corruptedPartitions.add(partitionId);
                        }
                    }
                    m_totalPartitions = fd.readInt();
                } else {
                    m_partitionIds = new int[] {0};
                    m_totalPartitions = 1;
                    if (!m_completed) {
                        m_corruptedPartitions.add(0);
                    }
                }
                m_hasVersion2FormatChunks = false;
            } else {
                assert(m_versionNum[3] == 1 || m_versionNum[3] == 2);
                if (m_versionNum[3] >= 2) {
                    m_hasVersion2FormatChunks = true;
                } else {
                    m_hasVersion2FormatChunks = false;
                }
                int numJSONBytes = fd.readInt();
                byte jsonBytes[] = new byte[numJSONBytes];
                fd.readFully(jsonBytes);
                String jsonString = new String(jsonBytes, "UTF-8");
                JSONObject obj = new JSONObject(jsonString);

                m_txnId = obj.getLong("txnId");
                //Timestamp field added for 3.0, might not be there
View Full Code Here

TOP

Related Classes of org.voltdb.messaging.FastDeserializer

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.