Package edu.brown.workload

Examples of edu.brown.workload.TransactionTrace


    /**
     * testExecuteQueries
     */
    @Test
    public void testExecuteQueries() throws Exception {
        TransactionTrace txn_trace = multip_trace;
        long txn_id = XACT_ID.getAndIncrement();
        MarkovEstimatorState state = t_estimator.startTransaction(txn_id, this.catalog_proc, txn_trace.getParams());
        assertNotNull(state);
        assertNotNull(state.getLastEstimate());
       
        MarkovEstimate initialEst = state.getInitialEstimate();
        assertNotNull(initialEst);
        assertTrue(initialEst.toString(), initialEst.isInitialized());
//        assertTrue(initialEst.toString(), initialEst.isSinglePartitionProbabilitySet());
        assertTrue(initialEst.toString(), initialEst.isAbortProbabilitySet());
//        assertTrue(initialEst.toString(), initialEst.getSinglePartitionProbability() < 1.0f);
        assertTrue(initialEst.toString(), initialEst.isConfidenceCoefficientSet());
        assertTrue(initialEst.toString(), initialEst.getConfidenceCoefficient() >= 0f);
        assertTrue(initialEst.toString(), initialEst.getConfidenceCoefficient() <= 1f);

        // Get the list of partitions that we're going to touch in the beginning
        // We should never mark these as finished in subsequent estimates
        PartitionSet touched = initialEst.getTouchedPartitions(thresholds);
        assertFalse(touched.isEmpty());
        assertFalse(touched.contains(HStoreConstants.NULL_PARTITION_ID));
        System.err.println("TOUCHED: " + touched);
        assertFalse(touched.toString(), touched.size() == 1);
       
        // Execute a bunch of batches
        // All should say that the txn is not finished with the partitions until we
        // get to the one that contains the updateStock queries, which should be the last.
        Statement lastBatchStmt = this.getStatement(this.catalog_proc, "updateStock");
        for (int i = 0, cnt = txn_trace.getBatchCount(); i < cnt; i++) {
            List<QueryTrace> queries = txn_trace.getBatchQueries(i);
            assertFalse(queries.isEmpty());
            boolean is_last = (i+1 == cnt);
            Statement stmts[] = new Statement[queries.size()];
            PartitionSet partitions[] = new PartitionSet[queries.size()];
           
View Full Code Here


        Object txn_params[] = new Object[] { 1l, 4l, 0l, 5l };
       
        Statement catalog_stmt = this.getStatement(catalog_proc, "GetData");
        Object query_params[] = new Object[] { 1l, 1l, 4l, 0l, 5l };
       
        TransactionTrace txn_trace = new TransactionTrace(1001l, catalog_proc, txn_params);
        QueryTrace query_trace = new QueryTrace(catalog_stmt, query_params, 0);
        txn_trace.addQuery(query_trace);
        txn_trace.stop();
       
        p_estimator.getAllPartitions(partitions, txn_trace);
        assertNotNull(partitions);
        assertEquals(partitions.toString(), 1, partitions.size());
    }
View Full Code Here

        Set<TransactionTrace> multisite_xacts = new HashSet<TransactionTrace>();
        int xact_ctr = 0;
        for (AbstractTraceElement<?> element : this.info.workload) {
            if (!(element instanceof TransactionTrace))
                continue;
            TransactionTrace xact = (TransactionTrace) element;
            SingleSitedCostModel.TransactionCacheEntry xact_cost = null; // FIXME
                                                                         // cost_model.getTransactionCacheEntry(xact);
            if (xact_cost.isSinglePartitioned())
                continue;
            multisite_xacts.add(xact);
View Full Code Here

   
    @Override
    protected FilterResult filter(AbstractTraceElement<? extends CatalogType> element) {
        FilterResult result = FilterResult.ALLOW;
        if (element instanceof TransactionTrace) {
            TransactionTrace xact = (TransactionTrace)element;
            Procedure catalog_proc = xact.getCatalogItem(this.catalog_db);
           
            PartitionSet partitions = new PartitionSet();
            try {
                int base_partition = this.p_estimator.getBasePartition(catalog_proc, xact.getParams(), true);
                partitions.add(base_partition);
                for (QueryTrace query : xact.getQueries()) {
                    this.p_estimator.getAllPartitions(partitions, query, base_partition);
                } // FOR
               
            } catch (Exception ex) {
                throw new RuntimeException(ex);
View Full Code Here

   
    @Override
    protected FilterResult filter(AbstractTraceElement<? extends CatalogType> element) {
        FilterResult result = FilterResult.ALLOW;
        if (element instanceof TransactionTrace) {
            TransactionTrace xact = (TransactionTrace)element;
            int basePartition = HStoreConstants.NULL_PARTITION_ID;
            try {
                basePartition = this.p_estimator.getBasePartition(xact);
            } catch (Exception ex) {
                ex.printStackTrace();
View Full Code Here

    }
   
    @Override
    protected FilterResult filter(AbstractTraceElement<? extends CatalogType> element) {
        if (element instanceof TransactionTrace) {
            TransactionTrace xact = (TransactionTrace)element;
            boolean allow = true;
            for (Entry<Integer, Set<Object>> e : this.values.entrySet()) {
                Object param_val = xact.getParam(e.getKey());
               
                // The parameter must equal at least one of these values
                for (Object val : e.getValue()) {
                    allow = val.equals(param_val);
                    if (d) LOG.debug(String.format("%s #%02d => [%s (%s) <-> %s (%s)] = %s",
View Full Code Here

    }
   
    @Override
    protected FilterResult filter(AbstractTraceElement<? extends CatalogType> element) {
        if (element instanceof TransactionTrace) {
            TransactionTrace xact = (TransactionTrace)element;
            // Procedure catalog_proc = xact.getCatalogItem(this.catalog_db);
           
            assert(xact.getParamCount() > this.param_idx) :
                xact + " only has " + xact.getParamCount() + " parameters but we need #" + this.param_idx;
            Object param = xact.getParam(this.param_idx);
            assert(ClassUtil.isArray(param)) :
                "Parameter #" + this.param_idx + " for " + xact + " is not an array";
            Object params_arr[] = (Object[])param;
           
            boolean allow = false;
View Full Code Here

        }

        @Override
        public void process(Pair<TransactionTrace, Integer> p) {
            assert (p != null);
            final TransactionTrace txn_trace = p.getFirst();
            final int i = p.getSecond(); // Interval
            final int txn_weight = (use_txn_weights ? txn_trace.getWeight() : 1);
            final String proc_key = CatalogKey.createKey(CatalogUtil.DEFAULT_DATABASE_NAME, txn_trace.getCatalogItemName());

            // Terrible Hack: Assume that we are using the SingleSitedCostModel
            // and that
            // it will return fixed values based on whether the txn is
            // single-partitioned or not
            SingleSitedCostModel singlesited_cost_model = (SingleSitedCostModel) cost_models[i];

            total_interval_txns[i] += txn_weight;
            total_interval_queries[i] += (txn_trace.getQueryCount() * txn_weight);
            histogram_procs.put(proc_key, txn_weight);

            try {
                singlesited_cost_model.estimateTransactionCost(catalogContext, workload, filter, txn_trace);
                TransactionCacheEntry txn_entry = singlesited_cost_model.getTransactionCacheEntry(txn_trace);
                assert (txn_entry != null) : "No txn entry for " + txn_trace;
                Collection<Integer> partitions = txn_entry.getTouchedPartitions();

                // If the txn runs on only one partition, then the cost is
                // nothing
                if (txn_entry.isSinglePartitioned()) {
                    singlepartition_ctrs[i] += txn_weight;
                    if (!partitions.isEmpty()) {
                        assert (txn_entry.getAllTouchedPartitionsHistogram().getValueCount() == 1) : txn_entry + " says it was single-partitioned but the partition count says otherwise:\n"
                                + txn_entry.debug();
                        singlepartition_with_partitions_ctrs[i] += txn_weight;
                    }
                    histogram_sp_procs.put(proc_key, txn_weight);

                    // If the txn runs on multiple partitions, then the cost
                    // is...
                    // XXX 2010-06-28: The number of partitions that the txn
                    // touches divided by the total number of partitions
                    // XXX 2010-07-02: The histogram for the total number of
                    // partitions touched by all of the queries
                    // in the transaction. This ensures that txns with just one
                    // multi-partition query
                    // isn't weighted the same as a txn with many
                    // multi-partition queries
                } else {
                    assert (!partitions.isEmpty()) : "No touched partitions for " + txn_trace;
                    if (partitions.size() == 1 && txn_entry.getExecutionPartition() != HStoreConstants.NULL_PARTITION_ID) {
                        assert (CollectionUtil.first(partitions) != txn_entry.getExecutionPartition()) : txn_entry.debug();
                        exec_mismatch_ctrs[i] += txn_weight;
                        partitions_touched[i] += txn_weight;
                    } else {
                        assert (partitions.size() > 1) : String.format("%s is not marked as single-partition but it only touches one partition\n%s", txn_trace, txn_entry.debug());
                    }
                    partitions_touched[i] += (partitions.size() * txn_weight); // Txns
                    multipartition_ctrs[i] += txn_weight;
                    histogram_mp_procs.put(proc_key, txn_weight);
                }
                Integer base_partition = txn_entry.getExecutionPartition();
                if (base_partition != null) {
                    exec_histogram[i].put(base_partition, txn_weight);
                } else {
                    exec_histogram[i].put(all_partitions, txn_weight);
                }
                if (debug.val) { // &&
                                   // txn_trace.getCatalogItemName().equalsIgnoreCase("DeleteCallForwarding"))
                                   // {
                    Procedure catalog_proc = txn_trace.getCatalogItem(catalogContext.database);
                    Map<String, Object> inner = new LinkedHashMap<String, Object>();
                    for (Statement catalog_stmt : catalog_proc.getStatements()) {
                        inner.put(catalog_stmt.fullName(), CatalogUtil.getReferencedTables(catalog_stmt));
                    }

                    Map<String, Object> m = new LinkedHashMap<String, Object>();
                    m.put(txn_trace.toString(), null);
                    m.put("Interval", i);
                    m.put("Single-Partition", txn_entry.isSinglePartitioned());
                    m.put("Base Partition", base_partition);
                    m.put("Touched Partitions", partitions);
                    m.put(catalog_proc.fullName(), inner);
                    LOG.debug(StringUtil.formatMaps(m));
                }

                // We need to keep a count of the number txns that didn't have
                // all of its queries estimated
                // completely so that we can update the access histograms down
                // below for entropy calculations
                // Note that this is at the txn level, not the query level.
                if (!txn_entry.isComplete()) {
                    incomplete_txn_ctrs[i] += txn_weight;
                    tmp_missingPartitions.clear();
                    tmp_missingPartitions.addAll(all_partitions);
                    tmp_missingPartitions.removeAll(txn_entry.getTouchedPartitions());
                    // Update the histogram for this interval to keep track of
                    // how many times we need to
                    // increase the partition access histogram
                    incomplete_txn_histogram[i].put(tmp_missingPartitions, txn_weight);
                    if (trace.val) {
                        Map<String, Object> m = new LinkedHashMap<String, Object>();
                        m.put(String.format("Marking %s as incomplete in interval #%d", txn_trace, i), null);
                        m.put("Examined Queries", txn_entry.getExaminedQueryCount());
                        m.put("Total Queries", txn_entry.getTotalQueryCount());
                        m.put("Touched Partitions", txn_entry.getTouchedPartitions());
                        m.put("Missing Partitions", tmp_missingPartitions);
                        LOG.trace(StringUtil.formatMaps(m));
                    }
                }
            } catch (Exception ex) {
                CatalogUtil.saveCatalog(catalogContext.catalog, CatalogUtil.CATALOG_FILENAME);
                throw new RuntimeException("Failed to estimate cost for " + txn_trace.getCatalogItemName() + " at interval " + i, ex);
            }
        }
View Full Code Here

            // Grab the Instance and throw it at the the clusterer to get the target cluster
            // The original data set is going to have the txn id that we need to grab
            // the proper TransactionTrace record from the workload
            Instance inst = trainingData.instance(i);
            long txn_id = FeatureUtil.getTransactionId(inst);
            TransactionTrace txn_trace = this.workload.getTransaction(txn_id);
            assert(txn_trace != null) : "Invalid TxnId #" + txn_id + "\n" + inst;

            // Figure out which base partition this txn would execute on
            // because we want divide the MarkovGraphContainers by the base partition
            int base_partition = this.getBasePartition(txn_trace);
           
            // Update Global MarkovGraph
            MarkovGraph markov = this.global_markov.get(base_partition, this.catalog_proc);
            assert(markov != null) : "Failed to get Global MarkovGraph for partition #" + base_partition;
            markov.processTransaction(txn_trace, this.p_estimator);
        } // FOR

        // ----------------------------------------------------------------------------
        // BUILD GLOBAL COST MODELS
        // ----------------------------------------------------------------------------
        for (Integer partition : FeatureClusterer.this.all_partitions) {
            MarkovGraph m = this.global_markov.get(partition, this.catalog_proc);
            assert(m != null);
            m.calculateProbabilities(catalogContext.getAllPartitionIds());
            assert(m.isValid()) : "The MarkovGraph at Partition #" + partition + " is not valid!";
        } // FOR
        if (debug.val) LOG.debug(String.format("Finished initializing GLOBAL MarkovCostModel"));

        // ----------------------------------------------------------------------------
        // ESTIMATE GLOBAL COST
        // ----------------------------------------------------------------------------
        int validationCnt = validationData.numInstances();
        int recalculate_ctr = 0;
        for (int i = 0; i < validationCnt; i++) {
            if (trace.val && i > 0 && i % 1000 == 0) LOG.trace(String.format("TransactionTrace %d/%d", i, validationCnt));
            Instance inst = validationData.instance(i);
            long txn_id = FeatureUtil.getTransactionId(inst);
            TransactionTrace txn_trace = this.workload.getTransaction(txn_id);
            assert(txn_trace != null);
            int base_partition = this.getBasePartition(txn_trace);

            // Skip any txn that executes on a partition that we're not evaluating
            if (this.all_partitions.contains(base_partition) == false) continue;
View Full Code Here

        for (int i = 0; i < validationCnt; i++) {
            if (i > 0 && i % 1000 == 0) LOG.trace(String.format("TransactionTrace %d/%d", i, validationCnt));
           
            Instance inst = validationData.instance(i);
            long txn_id = FeatureUtil.getTransactionId(inst);
            TransactionTrace txn_trace = this.workload.getTransaction(txn_id);
            assert(txn_trace != null);
            Integer base_partition = this.getBasePartition(txn_trace);
            // Skip any txn that executes on a partition that we're not evaluating
            if (this.all_partitions.contains(base_partition) == false) continue;
           
View Full Code Here

TOP

Related Classes of edu.brown.workload.TransactionTrace

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.