Package edu.brown.hstore.txns

Examples of edu.brown.hstore.txns.LocalTransaction


        // NEW TXN INITIALIZATION
        // -------------------------------
        boolean predict_readOnly = orig_ts.getProcedure().getReadonly(); // FIXME
        boolean predict_abortable = true; // FIXME
       
        LocalTransaction new_ts = this.txnInitializer.createLocalTransaction(
                orig_ts,
                base_partition,
                predict_touchedPartitions,
                predict_readOnly,
                predict_abortable);
        assert(new_ts != null);

        // -------------------------------
        // ANTI-CACHING REQUEUE
        // -------------------------------
        if (status == Status.ABORT_EVICTEDACCESS && orig_error instanceof EvictedTupleAccessException) {
            if (this.anticacheManager == null) {
                String message = "Got eviction notice but anti-caching is not enabled";
                LOG.warn(message);
                throw new ServerFaultException(message, orig_error, orig_ts.getTransactionId());
            }
           
            EvictedTupleAccessException error = (EvictedTupleAccessException)orig_error;
            short block_ids[] = error.getBlockIds();
            int tuple_offsets[] = error.getTupleOffsets();

            Table evicted_table = error.getTable(this.catalogContext.database);
            new_ts.setPendingError(error, false);

            if (debug.val)
                LOG.debug(String.format("Added aborted txn to %s queue. Unevicting %d blocks from %s (%d).",
                          AntiCacheManager.class.getSimpleName(), block_ids.length, evicted_table.getName(), evicted_table.getRelativeIndex()));
           
            if (orig_ts.getBasePartition() != error.getPartitionId() && !this.isLocalPartition(error.getPartitionId())) {
                new_ts.setOldTransactionId(orig_ts.getTransactionId());
            }
            this.anticacheManager.queue(new_ts, error.getPartitionId(), evicted_table, block_ids, tuple_offsets);
           
           
        }
           
        // -------------------------------
        // REGULAR TXN REQUEUE
        // -------------------------------
        else {
            if (debug.val) {
                LOG.debug(String.format("Re-executing %s as new %s-partition %s on partition %d " +
                          "[restarts=%d, partitions=%s]%s",
                          orig_ts,
                          (predict_touchedPartitions.size() == 1 ? "single" : "multi"),
                          new_ts,
                          base_partition,
                          new_ts.getRestartCounter(),
                          predict_touchedPartitions,
                          (trace.val ? "\n"+orig_ts.debug() : "")));
                if (trace.val && status == Status.ABORT_MISPREDICT)
                    LOG.trace(String.format("%s Mispredicted partitions: %s",
                              new_ts, orig_ts.getTouchedPartitions().values()));
View Full Code Here


                      this.ts, this.getClass().getSimpleName(), status,
                      StringUtil.join("\n", ClassUtil.getStackTrace())));
       
        // Let everybody know that the party is over!
        if (this.ts instanceof LocalTransaction) {
            LocalTransaction local_ts = (LocalTransaction)this.ts;
            LocalFinishCallback callback = ((LocalTransaction)this.ts).getFinishCallback();
            callback.init(local_ts, status);
            this.hstore_site.getCoordinator().transactionFinish(local_ts, status, callback);
        }
    }
View Full Code Here

            LOG.debug(String.format("Got %s for txn #%d [remotePartition=%d]",
                      request.getClass().getSimpleName(), txn_id, request.getSourcePartition()));
       
        // We should never a get a TransactionPrefetchResult for a transaction that
        // we don't know about.
        LocalTransaction ts = hstore_site.getTransaction(txn_id);
        if (ts == null) {
            String msg = String.format("Unexpected transaction id %d for incoming %s",
                                       txn_id, request.getClass().getSimpleName());
            throw new ServerFaultException(msg, txn_id);
        }
       
        // We want to store this before sending back the acknowledgment so that the transaction can get
        // access to it right away
        PartitionExecutor executor = hstore_site.getPartitionExecutor(ts.getBasePartition());
        WorkResult result = request.getResult();
       
        if (result.getStatus() != Status.OK) {
            // TODO: Process error!
        } else {
View Full Code Here

         * This is to avoid the double invoke for remote task.
         * */
        if(hstore_site.getHStoreConf().site.mr_reduce_blocking) {
            for (int partition : hstore_site.getLocalPartitionIds()) {
                if (partition != mr_ts.getBasePartition()) {
                    LocalTransaction ts = mr_ts.getLocalTransaction(partition);
                    hstore_site.transactionStart(ts);
                }
            } // FOR
        } else {
            // non-blocking way of execution for Reduce
View Full Code Here

   
    @Override
    public void sendLocal(Long txn_id, TransactionPrepareRequest request, PartitionSet partitions, RpcCallback<TransactionPrepareResponse> callback) {
        // We don't care whether we actually updated anybody locally, so we don't need to
        // pass in a set to get the partitions that were updated here.
        LocalTransaction ts = this.hstore_site.getTransaction(txn_id);
        assert(ts != null) : "Unexpected null transaction handle for txn #" + txn_id;
        this.hstore_site.transactionPrepare(ts, partitions, ts.getPrepareCallback());
    }
View Full Code Here

         * Here we would like to start MapReduce Transaction on the remote partition except the base partition of it.
         * This is to avoid the double invoke for remote task.
         * */
        for (int partition : hstore_site.getLocalPartitionIds()) {
            if (partition != mr_ts.getBasePartition()) {
                LocalTransaction ts = mr_ts.getLocalTransaction(partition);
                hstore_site.transactionStart(ts);
            }
        } // FOR
    }
View Full Code Here

        this.thresholds = hstore_site.getThresholds();
        this.queueManager = hstore_site.getTransactionQueueManager();
        this.lockQueue = this.queueManager.getLockQueue(this.partitionId);
       
        if (hstore_conf.site.exec_deferrable_queries) {
            tmp_def_txn = new LocalTransaction(hstore_site);
        }

        // ARIES       
        this.m_ariesLog = this.hstore_site.getAriesLogger();
View Full Code Here

                    // If we get something back here, then it should become our current transaction.
                    if (nextTxn != null) {
                        // If it's a single-partition txn, then we can return the StartTxnMessage
                        // so that we can fire it off right away.
                        if (nextTxn.isPredictSinglePartition()) {
                            LocalTransaction localTxn = (LocalTransaction)nextTxn;
                            nextWork = localTxn.getStartTxnMessage();
                            if (hstore_conf.site.txn_profiling && localTxn.profiler != null)
                                localTxn.profiler.startQueueExec();
                        }
                        // If it's as distribued txn, then we'll want to just set it as our
                        // current dtxn at this partition and then keep checking the queue
View Full Code Here

       
        // -------------------------------
        // Poll Lock Queue
        // -------------------------------

        LocalTransaction specTxn = null;
        InternalMessage work = null;
       
        // Check whether there is something we can speculatively execute right now
        if (this.specExecIgnoreCurrent == false && this.lockQueue.approximateIsEmpty() == false) {
//            if (trace.val)
//                LOG.trace(String.format("Checking %s for something to do at partition %d while %s",
//                          this.specExecScheduler.getClass().getSimpleName(),
//                          this.partitionId,
//                          (this.currentDtxn != null ? "blocked on " + this.currentDtxn : "idle")));
            assert(hstore_conf.site.specexec_enable) :
                "Trying to schedule speculative txn even though it is disabled";
            SpeculationType specType = this.calculateSpeculationType();
            if (hstore_conf.site.exec_profiling) this.profiler.conflicts_time.start();
            try {
                specTxn = this.specExecScheduler.next(this.currentDtxn, specType);
            } finally {
                if (hstore_conf.site.exec_profiling) this.profiler.conflicts_time.stopIfStarted();
            }
           
            // Because we don't have fine-grained undo support, we are just going
            // keep all of our speculative execution txn results around
            if (specTxn != null) {
                // TODO: What we really want to do is check to see whether we have anything
                // in our work queue before we go ahead and fire off this txn
                if (debug.val) {
                    if (this.work_queue.isEmpty() == false) {
                        LOG.warn(String.format("About to speculatively execute %s on partition %d but there " +
                                 "are %d messages in the work queue\n%s",
                                 specTxn, this.partitionId, this.work_queue.size(),
                                 CollectionUtil.first(this.work_queue)));
                    }
                    LOG.debug(String.format("Utility Work found speculative txn to execute on " +
                              "partition %d [%s, specType=%s]",
                              this.partitionId, specTxn, specType));
                    // IMPORTANT: We need to make sure that we remove this transaction for the lock queue
                    // before we execute it so that we don't try to run it again.
                    // We have to do this now because otherwise we may get the same transaction again
                    assert(this.lockQueue.contains(specTxn.getTransactionId()) == false) :
                        String.format("Failed to remove speculative %s before executing", specTxn);
                }
                assert(specTxn.getBasePartition() == this.partitionId) :
                    String.format("Trying to speculatively execute %s at partition %d but its base partition is %d\n%s",
                                  specTxn, this.partitionId, specTxn.getBasePartition(), specTxn.debug());
                assert(specTxn.isMarkedControlCodeExecuted() == false) :
                    String.format("Trying to speculatively execute %s at partition %d but was already executed\n%s",
                                  specTxn, this.partitionId, specTxn.getBasePartition(), specTxn.debug());
                assert(specTxn.isSpeculative() == false) :
                    String.format("Trying to speculatively execute %s at partition %d but was already speculative\n%s",
                                  specTxn, this.partitionId, specTxn.getBasePartition(), specTxn.debug());
               

                // It's also important that we cancel this txn's init queue callback, otherwise
                // it will never get cleaned up properly. This is necessary in order to support
                // sending out client results *before* the dtxn finishes
                specTxn.getInitCallback().cancel();
               
                // Ok now that that's out of the way, let's run this baby...
                specTxn.setSpeculative(specType);
                if (hstore_conf.site.exec_profiling) profiler.specexec_time.start();
                try {
                    this.executeTransaction(specTxn);
                } finally {
                    if (hstore_conf.site.exec_profiling) profiler.specexec_time.stopIfStarted();
View Full Code Here

        this.hstore_site = new MockHStoreSite(0, catalogContext, HStoreConf.singleton());
        this.executor = (MockPartitionExecutor)this.hstore_site.getPartitionExecutor(BASE_PARTITION);
        this.depTracker = this.executor.getDependencyTracker();
        assertNotNull(this.depTracker);
       
        this.ts = new LocalTransaction(this.hstore_site);
        this.ts.testInit(TXN_ID,
                         BASE_PARTITION,
                         null,
                         catalogContext.getAllPartitionIds(),
                         this.catalog_proc);
View Full Code Here

TOP

Related Classes of edu.brown.hstore.txns.LocalTransaction

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.