Package edu.brown.hstore.estimators

Examples of edu.brown.hstore.estimators.TransactionEstimator


            // Load in all the partition-specific TransactionEstimators and ExecutionSites in order to
            // stick them into the HStoreSite
            if (debug.val)
                LOG.debug(String.format("Creating %s for %s",
                          TransactionEstimator.class.getSimpleName(), singleton.getSiteName()));
            TransactionEstimator t_estimator = null;
            if (hstore_conf.site.markov_enable) {
                if (hstore_conf.site.markov_fixed == false && markovs != null) {
                    t_estimator = new MarkovEstimator(catalogContext, p_estimator, local_markovs);
                } else if (hstore_conf.site.markov_fixed) {
                    t_estimator = AbstractFixedEstimator.factory(p_estimator, singleton.getCatalogContext());
                }
            }
            if (first && t_estimator != null)
                LOG.info(String.format("All incoming txn requests will be processed with %s at this site",
                         t_estimator.getClass().getSimpleName()));

            // setup the EE
            if (debug.val)
                LOG.debug(String.format("Creating %s for Partition #%02d",
                          PartitionExecutor.class.getSimpleName(), local_partition));
View Full Code Here


        this.hstore_conf.site.markov_dtxn_updates = true;
        this.hstore_conf.site.markov_dtxn_updates = true;
        this.initHStore();
       
        for (PartitionExecutor executor : this.executors) {
            TransactionEstimator estimator = executor.getTransactionEstimator();
            assertNotNull(estimator);
            assertEquals(MarkovEstimator.class, estimator.getClass());
        } // FOR
       
        Object params[] = CollectionUtil.first(workload).getParams();
        for (int i = 0; i < params.length; i++) {
            if (ClassUtil.isArray(params[i])) {
View Full Code Here

        // -------------------------------
        else if (hstore_conf.site.markov_enable || hstore_conf.site.markov_fixed) {
            // Grab the TransactionEstimator for the destination partition and figure out whether
            // this mofo is likely to be single-partition or not. Anything that we can't estimate
            // will just have to be multi-partitioned. This includes sysprocs
            TransactionEstimator t_estimator = this.t_estimators[base_partition];
            if (t_estimator == null) {
                t_estimator = this.hstore_site.getPartitionExecutor(base_partition).getTransactionEstimator();
                this.t_estimators[base_partition] = t_estimator;
            }
           
            try {
                if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startInitEstimation();
                if (t_estimator != null) {
                    if (debug.val)
                        LOG.debug(String.format("%s - Using %s to populate txn properties [clientHandle=%d]",
                                  TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                  t_estimator.getClass().getSimpleName(), client_handle));
                    t_state = t_estimator.startTransaction(txn_id, base_partition, catalog_proc, params.toArray());
                }
               
                // If there is no EstimatorState, then there is nothing we can do
                // It has to be executed as multi-partitioned
                if (t_state == null) {
                    if (debug.val) {
                        LOG.debug(String.format("%s - No %s was returned. Using default estimate.",
                                  TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                  EstimatorState.class.getSimpleName()));
                    }
                }
                // We have a EstimatorState handle, so let's see what it says...
                else {
                    if (trace.val)
                        LOG.trace("\n" + StringBoxUtil.box(t_state.toString()));
                    Estimate t_estimate = t_state.getInitialEstimate();
                   
                    // Bah! We didn't get back a Estimation for some reason...
                    if (t_estimate == null) {
                        if (debug.val)
                            LOG.debug(String.format("%s - No %s handle was return. Using default estimate.",
                                      TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                      Estimate.class.getSimpleName()));
                    }
                    // Invalid Estimation. Stick with defaults
                    else if (t_estimate.isValid() == false) {
                        if (debug.val)
                            LOG.debug(String.format("%s - %s is marked as invalid. Using default estimate.\n%s",
                                      TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                      t_estimate.getClass().getSimpleName(), t_estimate));
                    }   
                    // Use Estimation to determine things
                    else {
                        if (debug.val) {
                            LOG.debug(String.format("%s - Using %s to determine if txn is single-partitioned",
                                      TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                      t_estimate.getClass().getSimpleName()));
                            LOG.trace(String.format("%s %s:\n%s",
                                      TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                      t_estimate.getClass().getSimpleName(), t_estimate));
                        }
                        predict_partitions = t_estimate.getTouchedPartitions(this.thresholds);
                        predict_readOnly = t_estimate.isReadOnlyAllPartitions(this.thresholds);
                        predict_abortable = (predict_partitions.size() == 1 ||
                                             predict_readOnly == false ||
                                             t_estimate.isAbortable(this.thresholds));
                       
                        // Check whether the TransactionEstimator *really* thinks that we should
                        // give it updates about this txn. If the flag is false, then we'll
                        // check whether the updates are enabled in the HStoreConf parameters
                        if (t_state.shouldAllowUpdates() == false) {
                            if (predict_partitions.size() == 1) {
                                if (hstore_conf.site.markov_singlep_updates == false) t_state.disableUpdates();
                            }
                            else if (hstore_conf.site.markov_dtxn_updates == false) {
                                t_state.disableUpdates();
                            }
                        }
                       
                        if (debug.val && predict_partitions.isEmpty()) {
                            LOG.warn(String.format("%s - Unexpected empty predicted %s from %s [updatesEnabled=%s]\n%s",
                                TransactionUtil.formatTxnName(catalog_proc, txn_id),
                                PartitionSet.class.getSimpleName(),
                                t_estimator.getClass().getSimpleName(),
                                t_state.isUpdatesEnabled(), t_estimate));
                            ts.setAllowEarlyPrepare(false);
//                            System.err.println("WROTE MARKOVGRAPH: " + ((MarkovEstimatorState)t_state).dumpMarkovGraph());
//                            System.err.flush();
//                            HStore.crashDB();
View Full Code Here

       
        assert(ts.checkDeletableFlag()) :
            String.format("Trying to delete %s before it was marked as ready!", ts);
       
        // Clean-up any extra information that we may have for the txn
        TransactionEstimator t_estimator = null;
        EstimatorState t_state = ts.getEstimatorState();
        if (t_state != null) {
            t_estimator = this.executors[base_partition].getTransactionEstimator();
            assert(t_estimator != null);
        }
        if (ts.hasDependencyTracker()) {
            // HACK: Check whether there were unnecessary prefetch queries
            if (hstore_conf.site.txn_profiling && ts.profiler != null) {
                Integer cnt = this.depTrackers[base_partition].getDebugContext().getUnusedPrefetchResultCount(ts);
                if (cnt != null) ts.profiler.addPrefetchUnusedQuery(cnt.intValue());
            }
            this.depTrackers[base_partition].removeTransaction(ts);
        }
       
        // Update Transaction profiler
        // XXX: Should we include totals for mispredicted txns?
        if (hstore_conf.site.txn_profiling &&
                ts.profiler != null &&
                ts.profiler.isDisabled() == false &&
                status != Status.ABORT_MISPREDICT) {
            ts.profiler.stopTransaction();
            if (this.txnProfilerStats != null) {
                this.txnProfilerStats.addTxnProfile(ts.getProcedure(), ts.profiler);
            }
            if (this.status_monitor != null) {
                this.status_monitor.addTxnProfile(ts.getProcedure(), ts.profiler);
            }
        }
       
        try {
            switch (status) {
                case OK:
                    if (t_estimator != null) {
                        if (trace.val)
                            LOG.trace(String.format("Telling the %s to COMMIT %s",
                                      t_estimator.getClass().getSimpleName(), ts));
                        t_estimator.commit(t_state);
                    }
                    // We always need to keep track of how many txns we process
                    // in order to check whether we are hung or not
                    if (hstore_conf.site.txn_counters || hstore_conf.site.status_kill_if_hung) {
                        TransactionCounter.COMPLETED.inc(catalog_proc);
                    }
                    break;
                case ABORT_USER:
                    if (t_estimator != null) {
                        if (trace.val) LOG.trace("Telling the TransactionEstimator to ABORT " + ts);
                        t_estimator.abort(t_state, status);
                    }
                    if (hstore_conf.site.txn_counters)
                        TransactionCounter.ABORTED.inc(catalog_proc);
                    break;
                case ABORT_MISPREDICT:
                case ABORT_RESTART:
                case ABORT_EVICTEDACCESS:
                case ABORT_SPECULATIVE:
                    if (t_estimator != null) {
                        if (trace.val) LOG.trace("Telling the TransactionEstimator to IGNORE " + ts);
                        t_estimator.abort(t_state, status);
                    }
                    if (hstore_conf.site.txn_counters) {
                        if (status == Status.ABORT_EVICTEDACCESS) {
                //if(ts.getRestartCounter()==0){
                                TransactionCounter.EVICTEDACCESS.inc(catalog_proc);
                //}
                        }
                        else if (status == Status.ABORT_SPECULATIVE) {
                            TransactionCounter.ABORT_SPECULATIVE.inc(catalog_proc);
                        }
                        else if (status == Status.ABORT_MISPREDICT) {
                            TransactionCounter.MISPREDICTED.inc(catalog_proc);
                        }
                        // Don't count restarted txns more than once
                        else if (ts.getRestartCounter() == 0) {
                            TransactionCounter.RESTARTED.inc(catalog_proc);
                        }
                    }
                    break;
                case ABORT_REJECT:
                    if (hstore_conf.site.txn_counters)
                        TransactionCounter.REJECTED.inc(catalog_proc);
                    break;
                case ABORT_UNEXPECTED:
                    if (hstore_conf.site.txn_counters)
                        TransactionCounter.ABORT_UNEXPECTED.inc(catalog_proc);
                    break;
                case ABORT_GRACEFUL:
                    if (hstore_conf.site.txn_counters)
                        TransactionCounter.ABORT_GRACEFUL.inc(catalog_proc);
                    break;
                default:
                    LOG.warn(String.format("Unexpected status %s for %s", status, ts));
            } // SWITCH
        } catch (Throwable ex) {
            LOG.error(String.format("Unexpected error when cleaning up %s transaction %s", status, ts), ex);
            // Pass...
        } finally {
            if (t_state != null && t_estimator != null) {
                assert(txn_id == t_state.getTransactionId()) :
                    String.format("Unexpected mismatch txnId in %s [%d != %d]",
                                  t_state.getClass().getSimpleName(),
                                  txn_id, t_state.getTransactionId());
                t_estimator.destroyEstimatorState(t_state);
            }
        }
       
        // Update additional transaction profiling counters
        if (hstore_conf.site.txn_counters) {
View Full Code Here

    }

    @Override
    protected synchronized void updateStatsRow(Object rowKey, Object[] rowValues) {
        Integer partition = (Integer)rowKey;
        TransactionEstimator est = hstore_site.getPartitionExecutor(partition).getTransactionEstimator();
        assert(est != null) : "Unexpected null TransactionEstimator for partition " + partition;
        MarkovEstimator.Debug dbg = ((MarkovEstimator)est).getDebugContext();
        assert(dbg != null);
        MarkovEstimatorProfiler profiler = dbg.getProfiler();
        assert(profiler != null);
View Full Code Here

                this.remoteExecutor
        };
        this.executorDbgs = new PartitionExecutor.Debug[this.executors.length];
        for (int i = 0; i < this.executors.length; i++) {
            this.executorDbgs[i] = this.executors[i].getDebugContext();
            TransactionEstimator t_estimator = this.executors[i].getTransactionEstimator();
            assertNotNull(t_estimator);
            assertEquals(MarkovEstimator.class, t_estimator.getClass());
        } // FOR
    }
View Full Code Here

                    } // FOR
                }
                               
                // MARKOV
                if (hstore_conf.site.markov_profiling) {
                    TransactionEstimator est = executor.getTransactionEstimator();
                    if (est instanceof MarkovEstimator) {
                        profilers.add(((MarkovEstimator)est).getDebugContext().getProfiler());
                    }
                }
               
View Full Code Here

TOP

Related Classes of edu.brown.hstore.estimators.TransactionEstimator

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.