Examples of ClientResponseImpl


Examples of org.voltdb.ClientResponseImpl

        LocalTransaction ts = new LocalTransaction(hstore_site);
        ts.init(1000l, EstTime.currentTimeMillis(), CLIENT_HANDLE, BASE_PARTITION,
                predict_touchedPartitions, predict_readOnly, predict_canAbort,
                catalog_proc, PARAMS, callback);
       
        ClientResponseImpl cresponse = new ClientResponseImpl(ts.getTransactionId(),
                                                              ts.getClientHandle(),
                                                              ts.getBasePartition(),
                                                              Status.OK,
                                                              HStoreConstants.EMPTY_RESULT,
                                                              "");
        hstore_site.responseSend(ts, cresponse);
       
        // Check to make sure our callback got the ClientResponse
        // And just make sure that they're the same
        assertEquals(callback, ts.getClientCallback());
        ClientResponseImpl clone = callback.getResponse();
        assertNotNull(clone);
        assertEquals(cresponse.getTransactionId(), clone.getTransactionId());
        assertEquals(cresponse.getClientHandle(), clone.getClientHandle());
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                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

Examples of org.voltdb.ClientResponseImpl

        // Client gets the final result, and  txn  is about to finish
       
        // STEP 1
        // Send the final result from all the partitions for this MR job
        // back to the client.
        ClientResponseImpl cresponse = new ClientResponseImpl();
        cresponse.init(ts, Status.OK, this.finalResults, "");
        hstore_site.responseSend(ts, cresponse);

        if (hstore_site.getHStoreConf().site.mr_map_blocking) {
            // STEP 2
            // Initialize the FinishCallback and tell every partition in the cluster
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        /**
         * Handle an incoming message
         */
        public void handleInput(ByteBuffer message, Connection connection) {
            ClientResponseImpl response = null;
            FastDeserializer fds = new FastDeserializer(message);
            try {
                response = fds.readObject(ClientResponseImpl.class);
            } catch (IOException e) {
                e.printStackTrace();
            }
            ProcedureCallback cb = null;
            cb = m_callbacks.remove(response.getClientHandle());
            if (cb != null) {
                cb.clientCallback(response);
            }
            else {
                // TODO: what's the right error path here?
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

              hstore_site.getHStoreConf().site.status_exec_info);
    }
   
    @Override
    protected void processingCallback(Object data[]) {
        ClientResponseImpl cresponse = (ClientResponseImpl)data[0];
        @SuppressWarnings("unchecked")
        RpcCallback<ClientResponseImpl> clientCallback = (RpcCallback<ClientResponseImpl>)data[1];
        long initiateTime = (Long)data[2];
        int restartCounter = (Integer)data[3];
       
        assert(cresponse != null);
        assert(clientCallback != null);
       
        if (debug.val)
            LOG.debug(String.format("Processing ClientResponse for txn #%d at partition %d [status=%s]",
                      cresponse.getTransactionId(), cresponse.getBasePartition(), cresponse.getStatus()));
        try {
            this.hstore_site.responseSend(cresponse, clientCallback, initiateTime, restartCounter);
        } catch (Throwable ex) {
            if (this.isShuttingDown() == false) throw new RuntimeException(ex);
            this.shutdown();
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                LOG.trace(String.format("Current Transaction at partition #%d\n%s",
                          this.partitionId, ts.debug()));
        }
       
        if (hstore_conf.site.txn_counters) TransactionCounter.EXECUTED.inc(ts.getProcedure());
        ClientResponseImpl cresponse = null;
        VoltProcedure previous = this.currentVoltProc;
        try {
            this.currentVoltProc = volt_proc;
            ts.markControlCodeExecuted();
            cresponse = volt_proc.call(ts, ts.getProcedureParameters().toArray()); // Blocking...
        // VoltProcedure.call() should handle any exceptions thrown by the transaction
        // If we get anything out here then that's bad news
        } catch (Throwable ex) {
            if (this.isShuttingDown() == false) {
                SQLStmt last[] = volt_proc.voltLastQueriesExecuted();
                LOG.fatal("Unexpected error while executing " + ts, ex);
                if (last.length > 0) {
                    LOG.fatal(String.format("Last Queries Executed [%d]: %s",
                              last.length, Arrays.toString(last)));
                }
                LOG.fatal("LocalTransactionState Dump:\n" + ts.debug());
                this.crash(ex);
            }
        } finally {
            this.currentVoltProc = previous;
            this.finishVoltProcedure(volt_proc);
            if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startPost();
           
//            if (cresponse.getStatus() == Status.ABORT_UNEXPECTED) {
//                cresponse.getException().printStackTrace();
//            }
        }
       
        // If this is a MapReduce job, then we can just ignore the ClientResponse
        // and return immediately. The VoltMapReduceProcedure is responsible for storing
        // the result at the proper location.
        if (ts.isMapReduce()) {
            return;
        } else if (cresponse == null) {
            assert(this.isShuttingDown()) : String.format("No ClientResponse for %s???", ts);
            return;
        }
       
        // -------------------------------
        // PROCESS RESPONSE AND FIGURE OUT NEXT STEP
        // -------------------------------
       
        Status status = cresponse.getStatus();
        if (debug.val) {
            LOG.debug(String.format("%s - Finished execution of transaction control code " +
                                    "[status=%s, beforeMode=%s, currentMode=%s]",
                                    ts, status, before_mode, this.currentExecMode));
            if (ts.hasPendingError()) {
                LOG.debug(String.format("%s - Txn finished with pending error: %s",
                          ts, ts.getPendingErrorMessage()));
            }
        }

        // We assume that most transactions are not speculatively executed and are successful
        // Therefore we don't want to grab the exec_mode lock here.
        if (predict_singlePartition == false || this.canProcessClientResponseNow(ts, status, before_mode)) {
            this.processClientResponse(ts, cresponse);
        }
        // Otherwise always queue our response, since we know that whatever thread is out there
        // is waiting for us to finish before it drains the queued responses
        else {
            // If the transaction aborted, then we can't execute any transaction that touch the tables
            // that this guy touches. But since we can't just undo this transaction without undoing
            // everything that came before it, we'll just disable executing all transactions until the
            // current distributed transaction commits
            if (status != Status.OK && ts.isExecReadOnly(this.partitionId) == false) {
                this.setExecutionMode(ts, ExecutionMode.DISABLED);
                int blocked = this.work_queue.drainTo(this.currentBlockedTxns);
                if (debug.val) {
                    if (trace.val && blocked > 0)
                        LOG.trace(String.format("Blocking %d transactions at partition %d because ExecutionMode is now %s",
                                  blocked, this.partitionId, this.currentExecMode));
                    LOG.debug(String.format("Disabling execution on partition %d because speculative %s aborted",
                              this.partitionId, ts));
                }
            }
            if (trace.val)
                LOG.trace(String.format("%s - Queuing ClientResponse [status=%s, origMode=%s, newMode=%s, dtxn=%s]",
                          ts, cresponse.getStatus(), before_mode, this.currentExecMode, this.currentDtxn));
            this.blockClientResponse(ts, cresponse);
        }
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                                LOG.debug(String.format("Speculative Txn %s does not conflict with dtxn %s at partition %d",
                                          spec_ts, ts, this.partitionId));
                            shouldCommit = true;
                        }
                        if (useAfterQueue == false || shouldCommit == false) {
                            ClientResponseImpl spec_cr = spec_ts.getClientResponse();
                            MispredictionException error = new MispredictionException(spec_ts.getTransactionId(),
                                                                                      spec_ts.getTouchedPartitions());
                            spec_ts.setPendingError(error, false);
                            spec_cr.setStatus(Status.ABORT_SPECULATIVE);
                            (useAfterQueue ? toAbortAfter : toAbortBefore).add(spec_ts);
                        } else {
                            toCommit.add(spec_ts);
                        }
                       
                    } // FOR
                   
                    // (1) Process all of the aborting txns that need to come *before*
                    //     we abort the dtxn
                    if (toAbortBefore.isEmpty() == false)
                        this.processClientResponseBatch(toAbortBefore, Status.ABORT_SPECULATIVE);
                   
                    // (2) Now abort the dtxn
                    this.finishTransaction(ts, status);
                   
                    // (3) Then abort all of the txn that need to come *after* we abort the dtxn
                    if (toAbortAfter.isEmpty() == false)
                        this.processClientResponseBatch(toAbortAfter, Status.ABORT_SPECULATIVE);
                   
                    // (4) Then blast out all of the txns that we want to commit
                    if (toCommit.isEmpty() == false)
                        this.processClientResponseBatch(toCommit, Status.OK);
                }
                // -------------------------------
                // DTXN READ-ONLY ABORT or DTXN COMMIT
                // -------------------------------
                else {
                    // **IMPORTANT**
                    // If the dtxn needs to commit, then all we need to do is get the
                    // last undoToken that we've generated (since we know that it had to
                    // have been used either by our distributed txn or for one of our
                    // speculative txns).
                    //
                    // If the read-only dtxn needs to abort, then there's nothing we need to
                    // do, because it didn't make any changes. That means we can just
                    // commit the last speculatively executed transaction
                    //
                    // Once we have this token, we can just make a direct call to the EE
                    // to commit any changes that came before it. Note that we are using our
                    // special 'finishWorkEE' method that does not require us to provide
                    // the transaction that we're committing.
                    long undoToken = this.lastUndoToken;
                    if (debug.val)
                        LOG.debug(String.format("%s - Last undoToken at partition %d => %d",
                                  ts, this.partitionId, undoToken));
                    // Bombs away!
                    if (undoToken != this.lastCommittedUndoToken) {
                        this.finishWorkEE(ts, undoToken, true);
                       
                        // IMPORTANT: Make sure that we remove the dtxn from the lock queue!
                        // This is normally done in finishTransaction() but because we're trying
                        // to be clever and invoke the EE directly, we have to make sure that
                        // we call it ourselves.
                        this.queueManager.lockQueueFinished(ts, status, this.partitionId);
                    }
                   
                    // Make sure that we mark the dtxn as finished so that we don't
                    // try to do anything with it later on.
                    if (hstore_conf.site.exec_readwrite_tracking)
                        this.markTransactionFinished(ts);
                    else
                        ts.markFinished(this.partitionId);
               
                    // Now make sure that all of the speculative txns are processed without
                    // committing (since we just committed any change that they could have made
                    // up above).
                    LocalTransaction spec_ts = null;
                    while ((spec_ts = this.specExecBlocked.pollFirst()) != null) {
                        ClientResponseImpl spec_cr = spec_ts.getClientResponse();
                        assert(spec_cr != null);
                        if (hstore_conf.site.exec_readwrite_tracking)
                            this.markTransactionFinished(spec_ts);
                        else
                            spec_ts.markFinished(this.partitionId);
                           
                        try {
                            if (trace.val)
                                LOG.trace(String.format("%s - Releasing blocked ClientResponse for %s [status=%s]",
                                          ts, spec_ts, spec_cr.getStatus()));
                            this.processClientResponse(spec_ts, spec_cr);
                        } catch (Throwable ex) {
                            String msg = "Failed to complete queued response for " + spec_ts;
                            throw new ServerFaultException(msg, ex, ts.getTransactionId());
                        }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        VoltTable results[] = new VoltTable[] {
            new VoltTable(new VoltTable.ColumnInfo("id", VoltType.BIGINT)),
            new VoltTable(new VoltTable.ColumnInfo("id", VoltType.BIGINT))
        };
        results[0].addRow(new Long(1));
        ClientResponseImpl cresponse = new ClientResponseImpl(TXN_ID, CLIENT_HANDLE,
                                                              0, Status.OK,
                                                              results, "");
       
        Reservation r = new Reservation(RESERVATION_ID, this.flight_id, customer_id, seatnum);
        assertNotNull(r);
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

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

Examples of org.voltdb.ClientResponseImpl

        }

        public void createWork(long now, long handle, String name, BBContainer c, ProcedureCallback callback) {
            synchronized (this) {
                if (!m_isConnected) {
                    final ClientResponse r = new ClientResponseImpl(-1, -1, -1, Status.ABORT_CONNECTION_LOST,
                            new VoltTable[0], "Connection to database host (" + m_hostname +
                            ") was lost before a response was received");
                    callback.clientCallback(r);
                    c.discard();
                    return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.