Package edu.brown.hstore.txns

Examples of edu.brown.hstore.txns.LocalTransaction


    }
   
    private Collection<AbstractTransaction> loadQueue(int num_txns) throws InterruptedException {
        Collection<AbstractTransaction> added = new TreeSet<AbstractTransaction>();
        for (long i = 0; i < num_txns; i++) {
            LocalTransaction txn = new LocalTransaction(this.hstore_site);
            Long txnId = this.idManager.getNextUniqueTransactionId();
            txn.testInit(txnId, 0, new PartitionSet(1), this.catalog_proc);
           
            // I think that we need to do this...
            this.queue.noteTransactionRecievedAndReturnLastSafeTxnId(txn.getTransactionId());
           
            boolean ret = this.queue.offer(txn, false);
            assert(ret);
            added.add(txn);
        } // FOR
View Full Code Here


    public void testOutOfOrderInsertion() throws Exception {
        // Create a bunch of txns and then insert them in the wrong order
        // We should be able to get them back in the right order
        Collection<AbstractTransaction> added = new TreeSet<AbstractTransaction>();
        for (long i = 0; i < NUM_TXNS; i++) {
            LocalTransaction txn = new LocalTransaction(this.hstore_site);
            Long txnId = this.idManager.getNextUniqueTransactionId();
            txn.testInit(txnId, 0, new PartitionSet(1), this.catalog_proc);
            added.add(txn);
        } // FOR
        List<AbstractTransaction> shuffled = new ArrayList<AbstractTransaction>(added);
        Collections.shuffle(shuffled, random);
       
        System.err.println(StringUtil.columns(
                "Expected Order:\n" + StringUtil.join("\n", added),
                "Insertion Order:\n" + StringUtil.join("\n", shuffled)
        ));
        System.err.flush();
       
        for (AbstractTransaction txn : shuffled) {
            this.queue.noteTransactionRecievedAndReturnLastSafeTxnId(txn.getTransactionId());
            boolean ret = this.queue.offer(txn, false);
            assert(ret);
            // assertNull(this.queue.poll());
        } // FOR
        assertEquals(added.size(), this.queue.size());
View Full Code Here

    @Test
    public void testConcurrentOfferIterator() throws Exception {
        Collection<AbstractTransaction> added = this.loadQueue(10);
        assertEquals(added.size(), this.queue.size());
       
        LocalTransaction toOffer = new LocalTransaction(this.hstore_site);
        Long txnId = this.idManager.getNextUniqueTransactionId();
        toOffer.testInit(txnId, 0, new PartitionSet(1), this.catalog_proc);
        assertFalse(this.queue.contains(toOffer));
       
        Set<AbstractTransaction> found = new HashSet<AbstractTransaction>();
        for (AbstractTransaction txn : this.queue) {
            if (found.isEmpty()) this.queue.offer(toOffer, false);
View Full Code Here

        TestSmallBankSuite.initializeSmallBankDatabase(catalogContext, this.client);
       
        BlockingSendPayment voltProc = this.startTxn();
        Long txnId = voltProc.getTransactionId();
        assertNotNull(txnId);
        LocalTransaction ts = hstore_site.getTransaction(txnId);
        assertNotNull(ts);
       
        Set<String> expectedTables = new HashSet<String>();
        for (Table tbl : catalogContext.database.getTables()) {
            if (ts.isTableRead(BASE_PARTITION, tbl)) {
                expectedTables.add(tbl.getName());
            }
        } // FOR
       
        // We should always get back the same handle each time.
View Full Code Here

        if (debug.val) LOG.debug(String.format("%s - Invoking TransactionFinish protocol from %s [status=%s]",
                                   this.ts, this.getClass().getSimpleName(), status));
       
        // 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

        }
    }

    @Override
    protected void removeCallback(QueueEntry next) {
      LocalTransaction ts = (LocalTransaction) next.ts;
        this.hstore_site.transactionReject(ts, Status.ABORT_GRACEFUL);
    }
View Full Code Here

      for (short block : allBlockIds) {
          block_ids[i++] = block;
      }
     
      if (txn instanceof LocalTransaction) {
        LocalTransaction ts = (LocalTransaction)txn;
        // Different partition generated the exception
        if (ts.getBasePartition() != partition  && !hstore_site.isLocalPartition(partition)){
          int site_id = hstore_site.getCatalogContext().getSiteIdForPartitionId(partition);
          hstore_site.getCoordinator().sendUnevictDataMessage(site_id, ts, partition, catalog_tbl, block_ids, tuple_offsets);
          return true;
          // should we enqueue the transaction on our side?
          // if yes then we need to prevent the queue item from being picked up
          // and prevent it from bombing the partition error
          // if no then simply return?
         
          // how to take care of LRU?
         
        }
       
        if (hstore_conf.site.anticache_profiling) {
            assert(ts.getPendingError() != null) :
                String.format("Missing original %s for %s", EvictedTupleAccessException.class.getSimpleName(), ts);
            assert(ts.getPendingError() instanceof EvictedTupleAccessException) :
                String.format("Unexpected error for %s: %s", ts, ts.getPendingError().getClass().getSimpleName());
            this.profilers[partition].restarted_txns++;
            this.profilers[partition].addEvictedAccess(ts, (EvictedTupleAccessException)ts.getPendingError());
          LOG.debug("Restarting transaction " + String.format("%s",ts) + ", " + ts.getRestartCounter() + " total restarts.");
          LOG.debug("Total Restarted Txns: " + this.profilers[partition].restarted_txns);
        }
      }

      if (debug.val)
View Full Code Here

    private AbstractTransaction createTransaction(TransactionTrace txn_trace) throws Exception {
        PartitionSet partitions = new PartitionSet();
        int base_partition = p_estimator.getBasePartition(txn_trace);
        p_estimator.getAllPartitions(partitions, txn_trace);
        LocalTransaction ts = new LocalTransaction(this.hstore_site);
        ts.testInit(txn_trace.getTransactionId(),
                    base_partition,
                    partitions,
                    txn_trace.getCatalogItem(catalogContext.database),
                    txn_trace.getParams());
        return (ts);
View Full Code Here

        // even without a txn estimate
        Procedure proc = this.getProcedure(slev.class);
        int basePartition = 0;
        PartitionSet partitions = catalogContext.getAllPartitionIds();
       
        LocalTransaction ts0 = new LocalTransaction(this.hstore_site);
        Object params0[] = new Object[]{ 0, 1, 2 };
        ts0.testInit(10000l, basePartition, partitions, proc, params0);
       
        LocalTransaction ts1 = new LocalTransaction(this.hstore_site);
        Object params1[] = new Object[]{ 0, 1, 2 };
        ts1.testInit(10001l, basePartition, partitions, proc, params1);
       
        boolean ret = this.checker.hasConflictBefore(ts0, ts1, basePartition);
        assertFalse(ret);
    }
View Full Code Here

        // even without a txn estimate
        int basePartition = 0;
        PartitionSet partitions = catalogContext.getAllPartitionIds();

        Procedure proc0 = this.getProcedure(paymentByCustomerId.class);
        LocalTransaction ts0 = new LocalTransaction(this.hstore_site);
        Object params0[] = new Object[]{ 0, 1, 2 };
        ts0.testInit(10000l, basePartition, partitions, proc0, params0);
       
        Procedure proc1 = this.getProcedure(UpdateNewOrder.class);
        LocalTransaction ts1 = new LocalTransaction(this.hstore_site);
        Object params1[] = new Object[]{ 0, 0 };
        ts1.testInit(10001l, basePartition, partitions, proc1, params1);
       
        boolean ret = this.checker.hasConflictBefore(ts0, ts1, basePartition);
        assertFalse(ret);
    }
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.