Package edu.brown.hstore.txns

Examples of edu.brown.hstore.txns.AbstractTransaction


                          ts, base_partition, partitions, ts.hashCode()));
        } catch (Throwable ex) {
            String msg = "Failed to instantiate new remote transaction handle for " + TransactionUtil.formatTxnName(catalog_proc, txn_id);
            throw new RuntimeException(msg, ex);
        }
        AbstractTransaction dupe = this.inflight_txns.put(txn_id, ts);
        assert(dupe == null) : "Trying to create multiple transaction handles for " + dupe;
       
        if (trace.val)
            LOG.trace(String.format("Stored new transaction state for %s", ts));
        return (ts);
View Full Code Here


            "The parameters object is null for new txn from client #" + client_handle;
       
        MapReduceTransaction ts = new MapReduceTransaction(hstore_site);
       
        // We should never already have a transaction handle for this txnId
        AbstractTransaction dupe = this.inflight_txns.put(txn_id, ts);
        assert(dupe == null) : "Trying to create multiple transaction handles for " + dupe;

        ts.init(txn_id, initiateTime, client_handle, base_partition, catalog_proc, procParams);
        if (debug.val)
            LOG.debug(String.format("Created new MapReduceTransaction state %s from remote partition %d",
View Full Code Here

     * @return
     */
    protected Long resetTransactionId(AbstractTransaction ts, int base_partition) {
        Long oldTxnId = ts.getTransactionId();
        assert(oldTxnId != null);
        AbstractTransaction removed = this.inflight_txns.remove(oldTxnId);
        assert(ts == removed);
       
        Long newTxnId = this.registerTransaction(ts, base_partition);
        ts.setTransactionId(newTxnId);
       
View Full Code Here

        TransactionIdManager idManager = this.txnIdManagers[base_partition];
        Long txn_id = idManager.getNextUniqueTransactionId();
       
        // For some odd reason we sometimes get duplicate transaction ids from the VoltDB id generator
        // So we'll just double check to make sure that it's unique, and if not, we'll just ask for a new one
        AbstractTransaction dupe = this.inflight_txns.put(txn_id, ts);
        if (dupe != null) {
            // HACK!
            this.inflight_txns.put(txn_id, dupe);
            Long new_txn_id = idManager.getNextUniqueTransactionId();
            if (new_txn_id.equals(txn_id)) {
View Full Code Here

     * @param oldTxnId
     * @param newTxnId
     * @return
     */
    protected void registerTransactionRestartWithId(AbstractTransaction ts, Long oldTxnId, Long newTxnId) {
      AbstractTransaction removed = this.inflight_txns.remove(oldTxnId);
        assert(ts == removed);
        ts.setTransactionId(newTxnId);
       
        this.inflight_txns.put(newTxnId, ts);  
       
View Full Code Here

    // UTILITY METHODS
    // --------------------------------------------------------------------------------------------
   
    private void checkCurrentDtxn() {
        // Make sure that this txn is the current dtxn at each of the partitions
        AbstractTransaction dtxn = null;
        for (PartitionExecutor executor : this.executors) {
            AbstractTransaction ts = null;
            int tries = 3;
            while (tries-- > 0) {
                ts = executor.getDebugContext().getCurrentDtxn();
                if (ts != null) break;
                ThreadUtil.sleep(NOTIFY_TIMEOUT);
View Full Code Here

            LOG.debug(String.format("2PC:FINISH Txn #%d [status=%s, partitions=%s]",
                      txn_id, status, partitions));
       
        // If we don't have a AbstractTransaction handle, then we know that we never did anything
        // for this transaction and we can just ignore this finish request.
        AbstractTransaction ts = this.inflight_txns.get(txn_id);
        if (ts == null) {
            if (debug.val)
                LOG.warn(String.format("No transaction information exists for #%d." +
                           "Ignoring finish request", txn_id));
            return;
        }
       
        // Set the status in case something goes awry and we just want
        // to check whether this transaction is suppose to be aborted.
        // XXX: Why is this needed?
        ts.setStatus(status);
       
        // We only need to do this for distributed transactions, because all single-partition
        // transactions will commit/abort immediately
        if (ts.isPredictSinglePartition() == false) {
//            PartitionCountingCallback<AbstractTransaction> callback = null;
            for (int partition : this.local_partitions.values()) {
                if (partitions.contains(partition) == false) continue;
               
                // 2013-01-11
                // We can check to see whether the txn was ever released at the partition.
                // If it wasn't then we know that we don't need to queue a finish message
                // This is to allow the PartitionExecutor to spend more time processing other
                // more useful stuff.
//                if (ts.isMarkedReleased(partition)) {
                    if (trace.val)
                        LOG.trace(String.format("%s - Queuing transaction to get finished on partition %d",
                                  ts, partition));
                    try {
                        this.executors[partition].queueFinish(ts, status);
                    } catch (Throwable ex) {
                        LOG.error(String.format("Unexpected error when trying to finish %s\nHashCode: %d / Status: %s / Partitions: %s",
                                  ts, ts.hashCode(), status, partitions));
                        throw new RuntimeException(ex);
                    }
//                }
//                else {
//                    if (callback == null) callback = ts.getFinishCallback();
View Full Code Here

     */
    protected void deleteRemoteTransaction(RemoteTransaction ts, Status status) {
        // Nothing else to do for RemoteTransactions other than to just
        // return the object back into the pool
        final Long txn_id = ts.getTransactionId();
        AbstractTransaction rm = this.inflight_txns.remove(txn_id);
        if (debug.val) LOG.debug(String.format("Deleted %s [%s / inflightRemoval:%s]", ts, status, (rm != null)));
       
        EstimatorState t_state = ts.getEstimatorState();
        if (t_state != null) {
            this.remoteTxnEstimator.destroyEstimatorState(t_state);
View Full Code Here

                assert(ts.equals(this.executors[p].getDebugContext().getCurrentDtxn()) == false) :
                    String.format("About to finish %s but it is still the current DTXN at partition %d", ts, p);
            } // FOR
        }

        AbstractTransaction rm = this.inflight_txns.remove(txn_id);
        assert(rm == null || rm == ts) : String.format("%s != %s", ts, rm);
        if (trace.val)
            LOG.trace(String.format("Deleted %s [%s / inflightRemoval:%s]", ts, status, (rm != null)));
       
        assert(ts.isInitialized()) : "Trying to return uninitialized txn #" + txn_id;
View Full Code Here

                int limit = LIMIT_PER_ROUND;
                while ((txn_id = queue.poll()) != null) {
                    // It's ok for us to not have a transaction handle, because it could be
                    // for a remote transaction that told us that they were going to need one
                    // of our partitions but then they never actually sent work to us
                    AbstractTransaction ts = this.inflight_txns.get(txn_id);
                    if (ts != null) {
                        assert(txn_id.equals(ts.getTransactionId())) :
                            String.format("Mismatched %s - Expected[%d] != Actual[%s]",
                                          ts, txn_id, ts.getTransactionId());
                        // We need to check whether a txn is ready to be deleted
                        if (ts.isDeletable()) {
                            if (ts instanceof RemoteTransaction) {
                                this.hstore_site.deleteRemoteTransaction((RemoteTransaction)ts, status);   
                            }
                            else {
                                this.hstore_site.deleteLocalTransaction((LocalTransaction)ts, status);
                            }
                            needsSleep = false;
                            limit--;
                        }
                        // We can't delete this yet, so we'll just stop checking
                        else {
                            if (trace.val)
                                LOG.trace(String.format("%s - Cannot delete %s at this point [status=%s]\n%s",
                                          ts, ts.getClass().getSimpleName(), status, ts.debug()));
                            requeue.add(txn_id);
                        }
                    } else if (debug.val) {
                        LOG.warn(String.format("Ignoring clean-up request for txn #%d because we do not have a handle " +
                                 "[status=%s]", txn_id, status));
View Full Code Here

TOP

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

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.