Package org.voltdb.messaging

Examples of org.voltdb.messaging.FastDeserializer


        // to do it for local work
        ParameterSet parameterSets[] = new ParameterSet[request.getParamsCount()]; // TODO: Cache!
        for (int i = 0; i < parameterSets.length; i++) {
            ByteString paramData = request.getParams(i);
            if (paramData != null && paramData.isEmpty() == false) {
                final FastDeserializer fds = new FastDeserializer(paramData.asReadOnlyByteBuffer());
                if (trace.val)
                    LOG.trace(String.format("Txn #%d paramData[%d] => %s",
                              txn_id, i, fds.buffer()));
                try {
                    parameterSets[i] = fds.readObject(ParameterSet.class);
                } catch (Exception ex) {
                    String msg = String.format("Failed to deserialize ParameterSet[%d] for txn #%d TransactionRequest", i, txn_id);
                    throw new ServerFaultException(msg, ex, txn_id);
                }
                // LOG.info("PARAMETER[" + i + "]: " + parameterSets[i]);
            } else {
                parameterSets[i] = ParameterSet.EMPTY;
            }
        } // FOR
        ts.attachParameterSets(parameterSets);
       
        // Deserialize attached VoltTable input dependencies
        FastDeserializer fds = null;
        VoltTable vt = null;
        for (int i = 0, cnt = request.getAttachedDataCount(); i < cnt; i++) {
            int input_dep_id = request.getAttachedDepId(i);
            ByteString data = request.getAttachedData(i);
            if (data.isEmpty()) {
                String msg = String.format("%s input dependency %d is empty", ts, input_dep_id);
                LOG.warn(msg + "\n" + request);
                throw new ServerFaultException(msg, txn_id);
            }
           
            if (fds == null) fds = new FastDeserializer(data.asReadOnlyByteBuffer());
            else fds.setBuffer(data.asReadOnlyByteBuffer());

            vt = null;
            try {
                vt = fds.readObject(VoltTable.class);
            } catch (Exception ex) {
                String msg = String.format("Failed to deserialize VoltTable[%d] for txn #%d", input_dep_id, txn_id);
                throw new ServerFaultException(msg, ex, txn_id);
            }
            assert(vt != null);
View Full Code Here


                          result.getPartitionId(), ts));
            int depId = result.getDepId(i);
            ByteString bs = result.getDepData(i);
            VoltTable vt = null;
            if (bs.isEmpty() == false) {
                FastDeserializer fd = new FastDeserializer(bs.asReadOnlyByteBuffer());
                try {
                    vt = fd.readObject(VoltTable.class);
                    if (trace.val)
                        LOG.trace(String.format("Displaying results from partition %d for %s :: \n %s",
                                  result.getPartitionId(), ts, vt.toString()));                   
                } catch (Exception ex) {
                    throw new ServerFaultException("Failed to deserialize VoltTable from partition " + result.getPartitionId() + " for " + ts, ex);
View Full Code Here

                       Thread.yield();
                   }
               }
               while (message.hasRemaining());
               message.flip();
               FastDeserializer fds = new FastDeserializer(message);
               ClientResponseImpl response = fds.readObject(ClientResponseImpl.class);
               return response;
           }
        });
    }
View Full Code Here

            return table;
        }

        table = PrivateVoltTableFactory.createUninitializedVoltTable();
        try {
            table.readExternal(new FastDeserializer(buffer));
        } catch (IOException e) {
            LOG.severe(e.toString());
            return null;
        }
View Full Code Here

     * @param buffer ByteBuffer containing a serialized representation of the exception.
     */
    public UnknownBlockAccessException(ByteBuffer buffer) {
        super(buffer);
       
        FastDeserializer fds = new FastDeserializer(buffer);
        short _block_id;
        try {
            _block_id = fds.readShort();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        this.block_id = _block_id;
    }
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();
            }
            m_createTime = fd.readLong();
            m_hostId = fd.readInt();
            m_hostname = fd.readString();
            m_clusterName = fd.readString();
            m_databaseName = fd.readString();
            m_tableName = fd.readString();
            m_isReplicated = fd.readBoolean();
            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);
View Full Code Here

                        throw new EOFException();
                    }
                }
                messageBuffer.rewind();

                final FastDeserializer fds = new FastDeserializer(messageBuffer);
                final VoltTable results[] = new VoltTable[1];
                final VoltTable resultTable = PrivateVoltTableFactory.createUninitializedVoltTable();
                results[0] = (VoltTable)fds.readObject(resultTable, this);
                return results;
            }
        } catch (final IOException e) {
            System.out.println("Exception: " + e.getMessage());
            throw new RuntimeException(e);
View Full Code Here

        }

        @Override
        public void handleMessage(ByteBuffer buf, Connection c) {
            ClientResponseImpl response = null;
            FastDeserializer fds = new FastDeserializer(buf);
            try {
                response = fds.readObject(ClientResponseImpl.class);
            } catch (IOException e) {
                LOG.error("Invalid ClientResponse object returned by " + this, e);
                return;
            }
            if (response == null) {
View Full Code Here

                    throw new EOFException();
                }
            }
            resultTablesBuffer.flip();

            final FastDeserializer ds = new FastDeserializer(resultTablesBuffer);
            // check if anything was changed
            final boolean dirty = ds.readBoolean();
            if (dirty)
                m_dirty = true;

            for (int ii = 0; ii < tables.length; ii++) {
                final int dependencyCount = ds.readInt(); // ignore the table count
                assert(dependencyCount == 1); //Expect one dependency generated per plan fragment
                ds.readInt(); // ignore the dependency ID
                tables[ii] = (VoltTable) ds.readObject(tables[ii], null);
            }
        }
View Full Code Here

                m_dirty = true;
            }
            final int numDependencies = depsBuff.getInt();
            final int[] depIds = new int[numDependencies];
            final VoltTable[] dependencies = new VoltTable[numDependencies];
            final FastDeserializer fds = new FastDeserializer(depsBuff);
            for (int ii = 0; ii < numDependencies; ++ii) {
                depIds[ii] = fds.readInt();
                dependencies[ii] = fds.readObject(VoltTable.class);
            }
            assert(depIds.length == 1);

            // and finally return the constructed dependency set
            return new DependencySet(depIds, dependencies);
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.