Package org.voltdb

Examples of org.voltdb.StoredProcedureInvocation


                if (debug.val)
                    LOG.debug(String.format("%s - Redirecting to partition %d because of misprediction",
                              orig_ts, redirect_partition));
               
                Procedure catalog_proc = orig_ts.getProcedure();
                StoredProcedureInvocation spi = new StoredProcedureInvocation(orig_ts.getClientHandle(),
                                                                              catalog_proc.getId(),
                                                                              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) {
View Full Code Here


            }
           
           
            Object params[] = new Object[] { partition, tableNames, children, evictBlockSizes, evictBlocks};

            StoredProcedureInvocation invocation = new StoredProcedureInvocation(1, procName, params);

            if (hstore_conf.site.anticache_profiling)
                this.profilers[partition].eviction_time.start();

            ByteBuffer b = null;
View Full Code Here

            assertTrue(volt1.handler != null);
            assertTrue(volt0.handler != null);
            assertTrue(volt2.handler != null);

            StoredProcedureInvocation pi1 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));
            StoredProcedureInvocation pi2 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));
            StoredProcedureInvocation pi3 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));
            StoredProcedureInvocation pi4 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));
            StoredProcedureInvocation pi5 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));
            StoredProcedureInvocation pi6 = new StoredProcedureInvocation(++handle, "i1", new Integer(1));

            dist.queue(pi1, new ProcCallback(), 128, true);
            dist.queue(pi2, new ProcCallback(), 128, true);
            dist.queue(pi3, new ProcCallback(), 128, true);
            dist.queue(pi4, new ProcCallback(), 128, true);
View Full Code Here

        @Override
        public void handleMessage(ByteBuffer message, Connection c) {
            try {
                FastDeserializer fds = new FastDeserializer(message);
                StoredProcedureInvocation spi = fds.readObject(StoredProcedureInvocation.class);

                VoltTable vt[] = new VoltTable[1];
                vt[0] = new VoltTable(new VoltTable.ColumnInfo("Foo", VoltType.BIGINT));
                vt[0].addRow(1);
                ClientResponseImpl response =
                    new ClientResponseImpl(-1, spi.getClientHandle(), -1, Status.OK, vt, "Extra String");
                c.writeStream().enqueue(response);
                roundTrips.incrementAndGet();
                System.err.println("Sending response.");
            }
            catch (Exception ex) {
View Full Code Here

         * @throws IOException
         */
        protected void invokeProcedure(Connection connection, ProcedureCallback callback, String procName,
                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

        assert(rows > 0);
    }
   
    public void testStoreData() throws Exception {
       MapReduceTransaction ts = new MapReduceTransaction(this.sites[0]);
       StoredProcedureInvocation request = new StoredProcedureInvocation(-1, TARGET_PROCEDURE.getSimpleName());
       Procedure catalog_proc = this.getProcedure(TARGET_PROCEDURE);
      
//       Collection<Integer> local_partitions = this.sites[0].getLocalPartitionIds();
//       System.err.println(local_partitions);
//       ts.init(123456789l, 0, 0, local_partitions, false, true, catalog_proc, request, null);
View Full Code Here

    public static Future<Long> sendInvocation(final ExecutorService executor, final SocketChannel channel, final String procName,final Object ...parameters) {
        return executor.submit(new Callable<Long>() {
            @Override
            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);
View Full Code Here

        if (m_isShutdown) {
            throw new NoConnectionsException("Client instance is shutdown");
        }
        final SyncCallback cb = new SyncCallback();
        cb.setArgs(parameters);
        final StoredProcedureInvocation invocation =
              new StoredProcedureInvocation(m_handle.getAndIncrement(), procName, parameters);

        Integer site_id = null;
        if (hints != null && hints.basePartition != HStoreConstants.NULL_PARTITION_ID) {
            invocation.setBasePartition(hints.basePartition);
            if (m_partitionSiteXref != null) {
                site_id = m_partitionSiteXref[hints.basePartition];
            }
        }
        else if (m_catalog != null && procName.startsWith("@") == false) {
            try {
                int partition = m_pEstimator.getBasePartition(invocation);
                if (partition != HStoreConstants.NULL_PARTITION_ID) {
                    site_id = m_partitionSiteXref[partition];
                    invocation.setBasePartition(partition);
                }
            } catch (Exception ex) {
                throw new RuntimeException("Failed to estimate base partition for new invocation of '" + procName + "'", ex);
            }
        }

        long start = ProfileMeasurement.getTime();
        m_distributer.queue(
                invocation,
                cb,
                m_expectedOutgoingMessageSize,
                true,
                site_id);
        m_queueTime.appendTime(start, ProfileMeasurement.getTime());

        try {
            if (trace.val)
                LOG.trace(String.format("Waiting for response for %s txn [clientHandle=%d]",
                                        procName, invocation.getClientHandle()));
            cb.waitForResponse();
        } catch (final InterruptedException e) {
            throw new java.io.InterruptedIOException("Interrupted while waiting for response");
        }
        if (cb.getResponse().getStatus() != Status.OK) {
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();
View Full Code Here

        if (callback == null) {
            callback = new NullCallback();
        } else if (callback instanceof ProcedureArgumentCacher) {
            ((ProcedureArgumentCacher)callback).setArgs(parameters);
        }
        StoredProcedureInvocation invocation =
            new StoredProcedureInvocation(m_handle.getAndIncrement(), procName, parameters);

        Integer site_id = null;
        if (m_catalog != null) {
            Procedure catalog_proc = m_catalogContext.procedures.getIgnoreCase(procName);
            if (catalog_proc != null) {
                // OPTIMIZATION: If we have the the catalog, then we'll send just
                // the procId. This reduces the number of strings that we need to
                // allocate on the server side.
                invocation.setProcedureId(catalog_proc.getId());
               
                // OPTIMIZATION: If this isn't a sysproc, then we can tell them
                // what the base partition for this request will be
                if ((hints == null || hints.basePartition == HStoreConstants.NULL_PARTITION_ID) &&
                    catalog_proc.getSystemproc() == false) {
                    try {
                        int partition = m_pEstimator.getBasePartition(invocation);
                        if (partition != HStoreConstants.NULL_PARTITION_ID) {
                            site_id = m_partitionSiteXref[partition];
                            invocation.setBasePartition(partition);
                        }
                    } catch (Exception ex) {
                        throw new RuntimeException("Failed to estimate base partition for new invocation of '" + procName + "'", ex);
                    }
                }
            }
        }
        if (hints != null && hints.basePartition != HStoreConstants.NULL_PARTITION_ID) {
            invocation.setBasePartition(hints.basePartition);
        }

        if (m_blockingQueue) {
            long start = ProfileMeasurement.getTime();
            while (!m_distributer.queue(invocation, callback, expectedSerializedSize, true, site_id)) {
View Full Code Here

TOP

Related Classes of org.voltdb.StoredProcedureInvocation

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.