Package edu.brown.utils

Examples of edu.brown.utils.PartitionSet$Itr


        long txnId = base_hstore_site.getTransactionIdManager(0).getNextUniqueTransactionId();
        long clientHandle = -1;
       
        CatalogContext catalogContext = base_hstore_site.getCatalogContext();
        int base_partition = CollectionUtil.random(base_hstore_site.getLocalPartitionIds());
        PartitionSet predict_touchedPartitions = catalogContext.getAllPartitionIds();
        int partition = CollectionUtil.random(remote_hstore_site.getLocalPartitionIds());
        predict_touchedPartitions.add(partition);
        boolean predict_readOnly = false;
        boolean predict_canAbort = true;
        Procedure catalog_proc = catalogContext.procedures.getIgnoreCase("@NoOp");
        ParameterSet params = new ParameterSet();
        RpcCallback<ClientResponseImpl> client_callback = null;
       
        LocalTransaction ts = new LocalTransaction(base_hstore_site);
        ts.init(txnId, EstTime.currentTimeMillis(), clientHandle, base_partition,
                predict_touchedPartitions, predict_readOnly, predict_canAbort,
                catalog_proc, params, client_callback);
       
        base_hstore_site.getTransactionInitializer().registerTransaction(ts, base_partition);
        PartitionSet partitions = remote_hstore_site.getLocalPartitionIds();
        RemoteTransaction remote_ts = remote_hstore_site.getTransactionInitializer().createRemoteTransaction(txnId, partitions, params, base_partition, catalog_proc.getId());
       
        EstTimeUpdater.update(System.currentTimeMillis());
        return (remote_ts);
    }
View Full Code Here


        this.partitionSiteXref = new int[this.numberOfPartitions];
        for (Partition part : CatalogUtil.getAllPartitions(catalog)) {
            int p = part.getId();
            this.partitions[p] = part;
            this.partitionIdArray[p] = Integer.valueOf(p);
            this.partitionSingletons[p] = new PartitionSet(p);
            this.partitionIdCollection.add(this.partitionIdArray[p]);
            this.partitionSiteXref[part.getId()] = ((Site)part.getParent()).getId();
        } // FOR
       
        // ------------------------------------------------------------
View Full Code Here

        // If our transaction was originally designated as a single-partitioned, then we need to make
        // sure that we don't touch any partition other than our local one. If we do, then we need abort
        // it and restart it as multi-partitioned
        boolean need_restart = false;
        boolean predict_singlepartition = ts.isPredictSinglePartition();
        PartitionSet done_partitions = ts.getDonePartitions();
        Estimate t_estimate = ts.getLastEstimate();
       
        // Now we can go back through and start running all of the WorkFragments that were not blocked
        // waiting for an input dependency. Note that we pack all the fragments into a single
        // CoordinatorFragment rather than sending each WorkFragment in its own message
        for (WorkFragment.Builder fragmentBuilder : fragmentBuilders) {
            assert(this.depTracker.isBlocked(ts, fragmentBuilder) == false);
            final int target_partition = fragmentBuilder.getPartitionId();
            final int target_site = catalogContext.getSiteIdForPartitionId(target_partition);
            final PartitionSet doneNotifications = (notify != null ? notify.getNotifications(target_site) : null);
           
            // Make sure that this isn't a single-partition txn trying to access a remote partition
            if (predict_singlepartition && target_partition != this.partitionId) {
                if (debug.val)
                    LOG.debug(String.format("%s - Txn on partition %d is suppose to be " +
View Full Code Here

     */
    private DonePartitionsNotification computeDonePartitions(final LocalTransaction ts,
                                                             final Estimate estimate,
                                                             final FastIntHistogram fragmentsPerPartition,
                                                             final boolean finalTask) {
        final PartitionSet touchedPartitions = ts.getPredictTouchedPartitions();
        final PartitionSet donePartitions = ts.getDonePartitions();
       
        // Compute the partitions that the txn will be finished with after this batch
        PartitionSet estDonePartitions = null;
       
        // If the finalTask flag is set to true, then the new done partitions
        // is every partition that this txn has locked
        if (finalTask) {
            estDonePartitions = new PartitionSet(touchedPartitions);
        }
        // Otherwise, we'll rely on the transaction's current estimate to figure it out.
        else {
            if (estimate == null || estimate.isValid() == false) {
                if (debug.val && estimate != null)
                    LOG.debug(String.format("%s - Unable to compute new done partitions because there " +
                         "is no valid estimate for the txn",
                              ts, estimate.getClass().getSimpleName()));
                return (null);
            }
           
            estDonePartitions = estimate.getDonePartitions(this.thresholds);
            if (estDonePartitions == null || estDonePartitions.isEmpty()) {
                if (debug.val)
                    LOG.debug(String.format("%s - There are no new done partitions identified by %s",
                              ts, estimate.getClass().getSimpleName()));
                return (null);
            }
        }
        assert(estDonePartitions != null) : "Null done partitions for " + ts;
        assert(estDonePartitions.isEmpty() == false) : "Empty done partitions for " + ts;
       
        if (debug.val)
            LOG.debug(String.format("%s - New estimated done partitions %s%s",
                      ts, estDonePartitions,
                      (trace.val ? "\n"+estimate : "")));

        // Note that we can actually be done with ourself, if this txn is only going to execute queries
        // at remote partitions. But we can't actually execute anything because this partition's only
        // execution thread is going to be blocked. So we always do this so that we're not sending a
        // useless message
        estDonePartitions.remove(this.partitionId);
       
        // Make sure that we only tell partitions that we actually touched, otherwise they will
        // be stuck waiting for a finish request that will never come!
        DonePartitionsNotification notify = new DonePartitionsNotification();
        LocalPrepareCallback callback = null;
        for (int partition : estDonePartitions.values()) {
            // Only mark the txn done at this partition if the Estimate says we were done
            // with it after executing this batch and it's a partition that we've locked.
            if (donePartitions.contains(partition) || touchedPartitions.contains(partition) == false)
                continue;
               
View Full Code Here

        for (int i = 0; i < num_txns; i++) {
            LocalTransaction ts = new LocalTransaction(hstore_site);
            txnId[i] = TXN_ID.incrementAndGet();
            ts.testInit(txnId[i],
                        BASE_PARTITION,
                        new PartitionSet(BASE_PARTITION),
                        catalog_procs[i % 2],
                        TARGET_PARAMS[i % 2]);
           
            ClientResponseImpl cresponse = new ClientResponseImpl(txnId[i],
                                                                  0l,
View Full Code Here

           
            // We will send a prepare message to all of our remote HStoreSites
            // The coordinator needs to be smart enough to know whether a txn
            // has already been marked as prepared at a partition (i.e., it's gotten
            // responses).
            PartitionSet partitions = ts.getPredictTouchedPartitions();
            LocalPrepareCallback callback = ts.getPrepareCallback();
            this.hstore_coordinator.transactionPrepare(ts, callback, partitions);
            if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();
            ts.getDonePartitions().addAll(partitions);
        }
View Full Code Here

            int remoteSiteId = remoteSite.getId();
            if (this.notificationsPerSite == null) {
                this.notificationsPerSite = new PartitionSet[catalogContext.numberOfSites];
            }
            if (this.notificationsPerSite[remoteSiteId] == null) {
                this.notificationsPerSite[remoteSiteId] = new PartitionSet();
            }
            this.notificationsPerSite[remoteSiteId].add(partitionId);
            if (noQueriesInBatch) {
                if (this._sitesToNotify == null) {
                    this._sitesToNotify = new HashSet<Integer>();
View Full Code Here

       
        this.ts0 = new LocalTransaction(this.hstore_site);
        this.ts0.testInit(NEXT_TXN_ID++, BASE_PARTITION, null, catalogContext.getAllPartitionIds(), catalog_proc);
       
        this.ts1 = new LocalTransaction(this.hstore_site);
        this.ts1.testInit(NEXT_TXN_ID++, BASE_PARTITION, null, new PartitionSet(BASE_PARTITION), catalog_proc);
       
        // Initialize some messages that we can use
        this.utilMsg = new UtilityWorkMessage();
        this.startMsg = new StartTxnMessage(ts1);
        this.workMsg = new WorkFragmentMessage(ts1, mockFragment);
View Full Code Here

        } // FOR
        return (ret);
    }
   
    private PartitionSet findTxnInQueues(LocalTransaction txn) {
        PartitionSet partitions = new PartitionSet();
        for (int partition : catalogContext.getAllPartitionIds().values()) {
            if (this.queueManager.getLockQueue(partition).contains(txn)) {
                partitions.add(partition);
            }
        } // FOR
        return (partitions);
    }
View Full Code Here

        // Mark first as done, second comes out
       
        final Long txn_id0 = this.idManager.getNextUniqueTransactionId();
        final Long txn_id1 = this.idManager.getNextUniqueTransactionId();
        final Long txn_id2 = this.idManager.getNextUniqueTransactionId();
        final PartitionSet partitions0 = catalogContext.getAllPartitionIds();
        final PartitionSet partitions1 = catalogContext.getAllPartitionIds();
        final PartitionSet partitions2 = catalogContext.getAllPartitionIds();
        final MockCallback inner_callback0 = new MockCallback();
        final MockCallback inner_callback1 = new MockCallback();
        final MockCallback inner_callback2 = new MockCallback();
        final LocalTransaction txn0 = this.createTransaction(txn_id0, partitions0, inner_callback0);
        final LocalTransaction txn1 = this.createTransaction(txn_id1, partitions1, inner_callback1);
View Full Code Here

TOP

Related Classes of edu.brown.utils.PartitionSet$Itr

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.