Package edu.brown.hstore.txns

Examples of edu.brown.hstore.txns.LocalTransaction


                      this.restartQueue.size()));
       
        Pair<LocalTransaction, Status> pair = null;
        int limit = CHECK_RESTART_QUEUE_LIMIT;
        while ((pair = this.restartQueue.poll()) != null) {
            LocalTransaction ts = pair.getFirst();
            Status status = pair.getSecond();
           
            if (trace.val)
                LOG.trace(String.format("%s - Ready to restart transaction [status=%s]", ts, status));
            Status ret = this.hstore_site.transactionRestart(ts, status);
            if (trace.val)
                LOG.trace(String.format("%s - Got return result %s after restarting", ts, ret));
           
            ts.unmarkNeedsRestart();
            this.hstore_site.queueDeleteTransaction(ts.getTransactionId(), status);
            if (limit-- == 0) break;
        } // WHILE
    }
View Full Code Here


                try {
                    pair = restartQueue.take();
                } catch (InterruptedException ex) {
                    // IGNORE
                }
                LocalTransaction ts = pair.getFirst();
                Status status = pair.getSecond();
                   
                if (trace.val)
                    LOG.trace(String.format("%s - Ready to restart transaction [status=%s]", ts, status));
                Status ret = hstore_site.transactionRestart(ts, status);
                if (trace.val)
                    LOG.trace(String.format("%s - Got return result %s after restarting", ts, ret));
               
                ts.unmarkNeedsRestart();
                hstore_site.queueDeleteTransaction(ts.getTransactionId(), status);
            } // WHILE
        }
View Full Code Here

        // what the transaction was initialized with
        final Map<Long, LocalTransaction> copiedHandles = new HashMap<Long, LocalTransaction>();
        EventObserver<LocalTransaction> newTxnObserver = new EventObserver<LocalTransaction>() {
            @Override
            public void update(EventObservable<LocalTransaction> o, LocalTransaction ts) {
                LocalTransaction copy = new LocalTransaction(hstore_site);
                copy.init(ts.getTransactionId(),
                          ts.getInitiateTime(),
                          ts.getClientHandle(),
                          ts.getBasePartition(),
                          new PartitionSet(ts.getPredictTouchedPartitions()),
                          ts.isPredictReadOnly(),
                          ts.isPredictAbortable(),
                          ts.getProcedure(),
                          ts.getProcedureParameters(),
                          null);
                copiedHandles.put(ts.getTransactionId(), copy);
            }
        };
        hstore_site.getTransactionInitializer().getNewTxnObservable().addObserver(newTxnObserver);
       
        Procedure catalog_proc = this.getProcedure(UpdateLocation.class);
        Object params[] = { 1234l, "XXXX" };
        ClientResponse cr = this.client.callProcedure(catalog_proc.getName(), params);
        assertEquals(Status.OK, cr.getStatus());
        // System.err.println(cr);
        // System.err.println(StringUtil.formatMaps(copiedHandles));
       
        assertTrue(cr.hasDebug());
        ClientResponseDebug crDebug = cr.getDebug();
        assertNotNull(crDebug);
       
        LocalTransaction copy = copiedHandles.get(cr.getTransactionId());
        assertNotNull(copiedHandles.toString(), copy);
        assertEquals(copy.getTransactionId().longValue(), cr.getTransactionId());
        assertEquals(copy.getClientHandle(), cr.getClientHandle());
        assertEquals(copy.getBasePartition(), cr.getBasePartition());
        assertEquals(copy.isPredictAbortable(), crDebug.isPredictAbortable());
        assertEquals(copy.isPredictReadOnly(), crDebug.isPredictReadOnly());
        assertEquals(copy.isPredictSinglePartition(), crDebug.isPredictSinglePartition());
        assertEquals(copy.getPredictTouchedPartitions(), crDebug.getPredictTouchedPartitions());
    }
View Full Code Here

        // -------------------------------
       
        // Grab a new LocalTransactionState object from the target base partition's
        // PartitionExecutor object pool. This will be the handle that is used all
        // throughout this txn's lifespan to keep track of what it does
        LocalTransaction ts = null;
        try {
            if (this.isMapReduce[procId]) {
                ts = new MapReduceTransaction(this.hstore_site);
            } else {
                ts = new LocalTransaction(this.hstore_site);
            }
            assert(ts.isInitialized() == false);
        } catch (Throwable ex) {
            String msg = "Failed to instantiate new local transaction handle for " + catalog_proc.getName();
            throw new RuntimeException(msg, ex);
        }
       
        // Initialize our LocalTransaction handle
        Long txn_id = this.registerTransaction(ts, base_partition);
        this.populateProperties(ts,
                                txn_id,
                                initiateTime,
                                client_handle,
                                base_partition,
                                catalog_proc,
                                procParams,
                                clientCallback);
        // Check whether this guy has already been restarted before
        if (serializedRequest != null) {
            int restartCounter = StoredProcedureInvocation.getRestartCounter(serializedRequest);
            if (restartCounter > 0) {
                ts.setRestartCounter(restartCounter);
            }
        }
       
        // Notify anybody that cares about this new txn
        if (this.newTxnObservable != null) this.newTxnObservable.notifyObservers(ts);
       
        assert(ts.isSysProc() == this.isSysProc[procId]) :
            "Unexpected sysproc mismatch for " + ts;
        return (ts);
    }
View Full Code Here

                                                   int base_partition,
                                                   PartitionSet predict_touchedPartitions,
                                                   boolean predict_readOnly,
                                                   boolean predict_abortable) {
       
        LocalTransaction new_ts = new LocalTransaction(hstore_site);
       
        // Setup TransactionProfiler
        if (hstore_conf.site.txn_profiling) {
            if (this.setupTransactionProfiler(new_ts, orig_ts.isSysProc())) {
                // Since we're restarting the txn, we should probably include
                // the original profiler information the original txn.
                // new_ts.profiler.startTransaction(ProfileMeasurement.getTime());
                new_ts.profiler.setSingledPartitioned(predict_touchedPartitions.size() == 1);               
            }
        }
        else if (new_ts.profiler != null) {
            new_ts.profiler.disableProfiling();
        }
       
        Long new_txn_id = this.registerTransaction(new_ts, base_partition);
        new_ts.init(new_txn_id,
                    orig_ts.getInitiateTime(),
                    orig_ts.getClientHandle(),
                    base_partition,
                    predict_touchedPartitions,
                    predict_readOnly,
                    predict_abortable,
                    orig_ts.getProcedure(),
                    orig_ts.getProcedureParameters(),
                    orig_ts.getClientCallback()
        );
       
        // Make sure that we remove the ParameterSet from the original LocalTransaction
        // so that they don't get returned back to the object pool when it is deleted
        orig_ts.removeProcedureParameters();
       
        // Increase the restart counter in the new transaction
        new_ts.setRestartCounter(orig_ts.getRestartCounter() + 1);
       
        // Notify anybody that cares about this new txn
        if (this.newTxnObservable != null) this.newTxnObservable.notifyObservers(new_ts);
       
        if (debug.val)
View Full Code Here

        boolean predict_readOnly = true;
        boolean predict_canAbort = true;
       
        MockClientCallback callback = new MockClientCallback();
       
        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

            for (int partition : hstore_site.getLocalPartitionIds().values()) {
                if (debug.val)
                    LOG.debug(String.format("TXN: %s $$$3 non-blocking reduce, partition called on:%d",
                              mr_ts, partition));
                if (partition != basePartition) {
                    LocalTransaction ts = mr_ts.getLocalTransaction(partition);
                    if (debug.val)
                        LOG.debug(String.format("TXN: %s $$$4 non-blocking reduce, partition called on:%d",
                                  mr_ts, partition));
                    VoltMapReduceProcedure<?> volt_proc = this.getVoltMapReduceProcedure(catalog_proc, partition);
                    volt_proc.call(ts, ts.getProcedureParameters());
                }
            } // FOR
        }
    }
View Full Code Here

                    public void run(ClientResponseImpl parameter) {
                        // Do nothing!
                    }
                };

                LocalTransaction ts = this.txnInitializer.createLocalTransaction(
                        null,
                        EstTime.currentTimeMillis(),
                        99999999,
                        base_partition,
                        catalog_proc,
View Full Code Here

        }
       
        // 2012-12-24 - We always want the network threads to do the initialization
        if (trace.val)
            LOG.trace("Initializing transaction request using network processing thread");
        LocalTransaction ts = this.txnInitializer.createLocalTransaction(
                                        buffer,
                                        timestamp,
                                        client_handle,
                                        base_partition,
                                        catalog_proc,
View Full Code Here

            // the adhoc compiler. Since we don't know what this thing will do, we have
            // to assume that it needs to touch all partitions.
            int idx = (int)(Math.abs(client_handle) % this.local_partitions.size());
            int base_partition = this.local_partitions.values()[idx];
           
            LocalTransaction ts = this.txnInitializer.createLocalTransaction(null,
                                                                             EstTime.currentTimeMillis(),
                                                                             client_handle,
                                                                             base_partition,
                                                                             catalog_proc,
                                                                             params,
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.