Examples of DependencySet


Examples of org.voltdb.DependencySet

                else {
                    String msg = String.format("Unexpected execution of SysProc #%d on partition %d",
                                               fragmentId, this.partitionId);
                    throw new ServerFaultException(msg, txn_id);
                }
                return new DependencySet(fragmentId, result);
            }
            // ----------------------------------------------------------------------------
            // PROFILER DATA AGGREGATION
            // ----------------------------------------------------------------------------
            case SysProcFragmentId.PF_nodeMemoryAggregator:
            case SysProcFragmentId.PF_txnCounterAggregator:
            case SysProcFragmentId.PF_txnProfilerAggregator:
            case SysProcFragmentId.PF_execProfilerAggregator:
            case SysProcFragmentId.PF_queueProfilerAggregator:
            case SysProcFragmentId.PF_markovProfilerAggregator:
            case SysProcFragmentId.PF_specexecProfilerAggregator:
            case SysProcFragmentId.PF_siteProfilerAggregator:
            case SysProcFragmentId.PF_plannerProfilerAggregator:
            case SysProcFragmentId.PF_anticacheProfilerAggregator: {
                // Do a reverse look up to find the input dependency id
                int dataFragmentId = -1;
                for (Integer id : STATS_DATA.keySet()) {
                    Pair<SysProcSelector, Integer> pair = STATS_DATA.get(id);
                    if (pair.getSecond().equals(fragmentId)) {
                        dataFragmentId = id.intValue();
                        break;
                    }
                } // FOR
                if (dataFragmentId == -1) {
                    String msg = "Failed to find input data dependency for SysProc #" + fragmentId;
                    throw new ServerFaultException(msg, txn_id);
                }
                VoltTable result = VoltTableUtil.union(dependencies.get(dataFragmentId));
                return new DependencySet(fragmentId, result);
            }
           
            // ----------------------------------------------------------------------------
            //  TABLE statistics
            // ----------------------------------------------------------------------------
            case SysProcFragmentId.PF_tableData: {
                assert(params.toArray().length == 2);
                final boolean interval =
                    ((Byte)params.toArray()[0]).byteValue() == 0 ? false : true;
                final Long now = (Long)params.toArray()[1];
                // create an array of the table ids for which statistics are required.
                // pass this to EE owned by the execution site running this plan fragment.
                CatalogMap<Table> tables = context.getDatabase().getTables();
                int[] tableGuids = new int[tables.size()];
                int ii = 0;
                for (Table table : tables) {
                    tableGuids[ii++] = table.getRelativeIndex();
                    //System.err.println("TABLE ID: " + table.getRelativeIndex());
                }
                VoltTable result = executor.getExecutionEngine().getStats(
                            SysProcSelector.TABLE,
                            tableGuids,
                            interval,
                            now)[0];
                return new DependencySet(DEP_tableData, result);
            }
            case SysProcFragmentId.PF_tableAggregator: {
                VoltTable result = VoltTableUtil.union(dependencies.get(DEP_tableData));
                return new DependencySet(DEP_tableAggregator, result);
            }
           
            // ----------------------------------------------------------------------------
            //  INDEX statistics
            // ----------------------------------------------------------------------------
            case SysProcFragmentId.PF_indexData: {
                assert(params.toArray().length == 2);
                final boolean interval =
                    ((Byte)params.toArray()[0]).byteValue() == 0 ? false : true;
                final Long now = (Long)params.toArray()[1];

                // create an array of the table ids for which statistics are required.
                // pass this to EE owned by the execution site running this plan fragment.
                CatalogMap<Table> tables = context.getDatabase().getTables();
                int[] tableGuids = new int[tables.size()];
                int ii = 0;
                for (Table table : tables) {
                    tableGuids[ii++] = table.getRelativeIndex();
                    System.err.println("TABLE ID: " + table.getRelativeIndex());
                }

                /* This part is a test version for add every index's m_relativeIndex to ids.
                // create an array of the tables for which statistics are required.
                // pass this to EE owned by the execution site running this plan fragment.
                CatalogMap<Table> tables = context.getDatabase().getTables();
                CatalogMap<Index> indexes;
                ArrayList<Integer> catalogIds = new ArrayList<Integer>();

                //HashSet<Integer> tableIds = new HashSet<Integer>();
                //Integer tableId;

                for (Table table : tables) {
                    indexes = table.getIndexes();
                    //tableId = table.getRelativeIndex();
                    //if (tableIds.contains(tableId)) continue;
                    //tableIds.add(tableId);
                    for (Index index: indexes) {
                        catalogIds.add(index.getRelativeIndex());
                        //System.err.println("INDEX ID: " + index.getRelativeIndex());
                    }
                }

                int[] indexIds = new int[catalogIds.size()];
                int ii = 0;
                for (Integer n : catalogIds) {
                    //indexIds[ii] = ii + 1;
                    //ii++;
                    //System.err.println("INDEX ID: " + ii);
                    indexIds[ii++] = n;
                }
                VoltTable result = executor.getExecutionEngine().getStats(
                            SysProcSelector.INDEX,
                            indexIds,
                            interval,
                            now)[0];
                }*/

                VoltTable result = executor.getExecutionEngine().getStats(
                            SysProcSelector.INDEX,
                            tableGuids,
                            interval,
                            now)[0];
                return new DependencySet(DEP_indexData, result);
            }
            case SysProcFragmentId.PF_indexAggregator: {
                VoltTable result = VoltTableUtil.union(dependencies.get(DEP_indexData));
                return new DependencySet(DEP_indexAggregator, result);
            }
   
            // ----------------------------------------------------------------------------
            //  PROCEDURE statistics
            // ----------------------------------------------------------------------------
            case SysProcFragmentId.PF_procedureData: {
                // procedure stats are registered to VoltDB's statsagent with the site's catalog id.
                // piece this information together and the stats agent returns a table. pretty sweet.
                assert(params.toArray().length == 2);
                final boolean interval =
                    ((Byte)params.toArray()[0]).byteValue() == 0 ? false : true;
                final Long now = (Long)params.toArray()[1];
                ArrayList<Integer> catalogIds = new ArrayList<Integer>();
                catalogIds.add(context.getSite().getId());
                VoltTable result = executor.getHStoreSite().getStatsAgent().getStats(
                                SysProcSelector.PROCEDURE,
                                catalogIds,
                                interval,
                                now);
                return new DependencySet(DEP_procedureData, result);
            }
            case SysProcFragmentId.PF_procedureAggregator: {
                VoltTable result = VoltTableUtil.union(dependencies.get(DEP_procedureData));
                return new DependencySet(DEP_procedureAggregator, result);
            }
           
            // ----------------------------------------------------------------------------
            // IO statistics
            // ----------------------------------------------------------------------------
            case SysProcFragmentId.PF_ioData: {
                ColumnInfo ioColumnInfo[] = new ColumnInfo[] {
                        new ColumnInfo( "TIMESTAMP", VoltType.BIGINT),
                        new ColumnInfo( VoltSystemProcedure.CNAME_HOST_ID, VoltSystemProcedure.CTYPE_ID),
                        new ColumnInfo( "HOSTNAME", VoltType.STRING),
                        new ColumnInfo( "CONNECTION_ID", VoltType.BIGINT),
                        new ColumnInfo( "CONNECTION_HOSTNAME", VoltType.STRING),
                        new ColumnInfo( "BYTES_READ", VoltType.BIGINT),
                        new ColumnInfo( "MESSAGES_READ", VoltType.BIGINT),
                        new ColumnInfo( "BYTES_WRITTEN", VoltType.BIGINT),
                        new ColumnInfo( "MESSAGES_WRITTEN", VoltType.BIGINT)
                };
                final VoltTable result = new VoltTable(ioColumnInfo);
                // Choose the lowest site ID on this host to do the scan
                // All other sites should just return empty results tables.
                if (isFirstLocalPartition()) {
                    assert(params.toArray() != null);
                    assert(params.toArray().length == 2);
                    final boolean interval =
                        ((Byte)params.toArray()[0]).byteValue() == 0 ? false : true;
                    final Long now = (Long)params.toArray()[1];
                    try {
                        final Map<Long, Pair<String,long[]>> stats = executor.getHStoreSite().getVoltNetwork().getIOStats(interval);
   
                        final Integer hostId = executor.getHStoreSite().getSiteId();
                        final String hostname = executor.getHStoreSite().getSiteName();
                        for (Map.Entry<Long, Pair<String, long[]>> e : stats.entrySet()) {
                            final Long connectionId = e.getKey();
                            final String remoteHostname = e.getValue().getFirst();
                            final long counters[] = e.getValue().getSecond();
                            result.addRow(
                                          now,
                                          hostId,
                                          hostname,
                                          connectionId,
                                          remoteHostname,
                                          counters[0],
                                          counters[1],
                                          counters[2],
                                          counters[3]);
                        }
                    } catch (Exception e) {
                        HOST_LOG.warn("Error retrieving stats", e);
                    }
                }
                return new DependencySet(DEP_ioData, result);
            }
            case SysProcFragmentId.PF_ioDataAggregator: {
                VoltTable result = null;
                List<VoltTable> dep = dependencies.get(DEP_ioData);
                for (VoltTable t : dep) {
                    if (result == null) {
                        result = new VoltTable(t);
                    }
                    while (t.advanceRow()) {
                        result.add(t);
                    }
                }
                return new DependencySet(DEP_ioDataAggregator, result);
            }
            case SysProcFragmentId.PF_partitionCount: {
                VoltTable result = new VoltTable(new VoltTable.ColumnInfo("PARTITION_COUNT", VoltType.INTEGER));
                result.addRow(executor.getHStoreSite().getLocalPartitionIds().size());
                return new DependencySet(DEP_partitionCount, result);
            }
        } // SWITCH

        assert (false);
        return null;
View Full Code Here

Examples of org.voltdb.DependencySet

                        }
                    }
                }
            }

            return new DependencySet( DEP_snapshotDelete, result);
        } else if (fragmentId == SysProcFragmentId.PF_snapshotDeleteResults) {
            final VoltTable results = constructFragmentResultsTable();
            LOG.trace("Aggregating Snapshot Delete  results");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_snapshotDelete);
            for (VoltTable table : dep)
            {
                while (table.advanceRow())
                {
                    // this will add the active row of table
                    results.add(table);
                }
            }
            return new DependencySet( DEP_snapshotDeleteResults, results);
        }
        assert (false);
        return null;
    }
View Full Code Here

Examples of org.voltdb.DependencySet

            } catch (VoltAbortException e) {
                // must continue and reply with dependency.
                e.printStackTrace();
            }
            if (debug.val) LOG.debug("Finished loading table. Things look good...");
            return new DependencySet(new int[] { (int)DEP_distribute }, result);

        } else if (fragmentId == SysProcFragmentId.PF_loadAggregate) {
            if (debug.val) LOG.debug("Aggregating results from loading fragments in txn #" + txn_id);
            return new DependencySet(new int[] { (int)DEP_aggregate }, result);
        }
        // must handle every dependency id.
        assert (false);
        return null;
    }
View Full Code Here

Examples of org.voltdb.DependencySet

    public DependencySet executePlanFragment(Long txn_id,
                                             Map<Integer, List<VoltTable>> dependencies,
                                             int fragmentId,
                                             ParameterSet params,
                                             PartitionExecutor.SystemProcedureExecutionContext context) {
        DependencySet result = null;
        assert(params.size() == 2);
        String confNames[] = (String[])params.toArray()[0];
        String confValues[] = (String[])params.toArray()[1];
       
        switch (fragmentId) {
            case DISTRIBUTE_ID: {
                HStoreConf hstore_conf = executor.getHStoreConf();
                assert(hstore_conf != null);
               
                // Put the conf name+value pairs into a map and shove that to
                // the HStoreConf. It will know how to process them and convert
                // the string values into the proper types
                Map<String, String> m = new HashMap<String, String>();
                for (int i = 0; i < confNames.length; i++) {
                    m.put(confNames[i], confValues[i]);
                } // FOR
                hstore_conf.loadFromArgs(m);
                if (debug.val)
                    LOG.debug(String.format("Updating %d conf parameters on %s",
                              m.size(), executor.getHStoreSite().getSiteName()));
               
                // Update our local HStoreSite
                context.getHStoreSite().updateConf(hstore_conf, confNames);

                // Create the result table
                VoltTable vt = new VoltTable(nodeResultsColumns);
                for (int i = 0; i < confNames.length; i++) {
                    Object row[] = {
                        executor.getSiteId(),
                        confNames[i],
                        hstore_conf.get(confNames[i]).toString(),
                    };
                    vt.addRow(row);
                } // FOR
                result = new DependencySet(DISTRIBUTE_ID, vt);
                if (debug.val)
                    LOG.info(String.format("%s - Sending back result for partition %d",
                             hstore_site.getTransaction(txn_id), this.executor.getPartitionId()));
                break;
            }
            // Aggregate Results
            case AGGREGATE_ID:
                List<VoltTable> siteResults = dependencies.get(DISTRIBUTE_ID);
                if (siteResults == null || siteResults.isEmpty()) {
                    String msg = "Missing site results";
                    throw new ServerFaultException(msg, txn_id);
                }
                if (debug.val)
                    LOG.debug("# of Results: " + siteResults.size() + "\n" +
                              StringUtil.join("\n************\n", siteResults));
               
                // Make sure that everyone is the same value
                VoltTable vt = new VoltTable(aggregateResultsColumns);
                TimestampType timestamp = new TimestampType();
                Set<String> values = new HashSet<String>();
                for (int i = 0; i < confNames.length; i++) {
                    if (i > 0) values.clear();
                    for (VoltTable site_vt : siteResults) {
                        if (i > 0) site_vt.resetRowPosition();
                        while (site_vt.advanceRow()) {
                            if (site_vt.getString(1).equalsIgnoreCase(confNames[i])) {
                                values.add(site_vt.getString(2));
                                break;
                            }
                        } // WHILE
                    } // FOR (site results)
                    if (values.isEmpty()) {
                        String msg = "Failed to find updated configuration values for '" + confNames[i] + "'";
                        throw new VoltAbortException(msg);
                    }
                    else if (values.size() > 1) {
                        String msg = String.format("Unexpected multiple values for '%s': %s",
                                                   confNames[i], values);
                        throw new VoltAbortException(msg);
                    }
                    vt.addRow(confNames[i], CollectionUtil.first(values).toString(), timestamp);
                } // FOR
                result = new DependencySet(AGGREGATE_ID, vt);
                break;
            default:
                String msg = "Unexpected sysproc fragmentId '" + fragmentId + "'";
                throw new ServerFaultException(msg, txn_id);
        } // SWITCH
View Full Code Here

Examples of org.voltdb.DependencySet

                        (is_global ? 1 : 0),
                        new TimestampType()
                    );
                }
            }
            return new DependencySet(new int[] { (int)SysProcFragmentId.PF_recomputeMarkovsDistribute }, result);
           
        } else if (fragmentId == SysProcFragmentId.PF_recomputeMarkovsAggregate) {
            if (debug.val) LOG.debug("Aggregating results from recomputing models fragments in txn #" + txn_id);
            for (List<VoltTable> l : dependencies.values()) {
                for (VoltTable vt : l) {
                    while (vt != null && vt.advanceRow()) {
                        result[0].add(vt.getRow());
                    } // WHILE
                } // FOR
            } // FOR
            return new DependencySet(new int[] { (int)SysProcFragmentId.PF_recomputeMarkovsAggregate }, result);
        }
        assert(false) : "Unexpected FragmentId " + fragmentId;
        return null;
    }
View Full Code Here

Examples of org.voltdb.DependencySet

                // Initialize on other sites
                m_filePath = (String) params.toArray()[0];
                m_fileNonce = (String) params.toArray()[1];
            }

            return new DependencySet(DEP_restoreScan, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreScanResults) {
            LOG.trace("Aggregating saved table state");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_restoreScan);
            VoltTable result = ClusterSaveFileState.constructEmptySaveFileStateVoltTable();
            for (VoltTable table : dep) {
                while (table.advanceRow()) {
                    // the actually adds the active row... weird...
                    result.add(table);
                }
            }
            return new DependencySet(DEP_restoreScanResults, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreLoadReplicatedTable) {
            assert (params.toArray()[0] != null);
            assert (params.toArray()[1] != null);
            assert (params.toArray()[2] != null);
            String table_name = (String) params.toArray()[0];
            int dependency_id = (Integer) params.toArray()[1];
            int allowExport = (Integer) params.toArray()[2];
            LOG.trace("restoreLoadReplicatedTable :: Partition id :" + context.getPartitionExecutor().getPartitionId());
            //LOG.trace("Dependency_id :" + dependency_id + " - Loading replicated table: " + table_name);
            String result_str = "SUCCESS";
            String error_msg = "";
            TableSaveFile savefile = null;

            /**
             * For replicated tables this will do the slow thing and read the
             * file once for each ExecutionSite. This could use optimization
             * like is done with the partitioned tables.
             */
            try {
                savefile = getTableSaveFile(getSaveFileForReplicatedTable(table_name), 3, null);
                assert (savefile.getCompleted());
            } catch (IOException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            }

            try {

                while (savefile.hasMoreChunks()) {
                    VoltTable table = null;
                    final org.voltdb.utils.DBBPool.BBContainer c = savefile.getNextChunk();
                    if (c == null) {
                        continue;// Should be equivalent to break
                    }
                    VoltTable old_table = PrivateVoltTableFactory.createVoltTableFromBuffer(c.b, true);
                    Table new_catalog_table = getCatalogTable(table_name);
                    table = SavedTableConverter.convertTable(old_table, new_catalog_table);
                    c.discard();
                    try {
                        LOG.trace("LoadTable " + table_name);
                        this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
                    } catch (VoltAbortException e) {
                        result_str = "FAILURE";
                        error_msg = e.getMessage();
                        break;
                    }
                }

            } catch (IOException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            } catch (VoltTypeException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            }

            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, table_name, -1, result_str, error_msg);
            try {
                savefile.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreDistributeReplicatedTable) {
            // XXX I tested this with a hack that cannot be replicated
            // in a unit test since it requires hacks to this sysproc that
            // effectively break it
            assert (params.toArray()[0] != null);
            assert (params.toArray()[1] != null);
            assert (params.toArray()[2] != null);
            assert (params.toArray()[3] != null);
            String table_name = (String) params.toArray()[0];
            int site_id = (Integer) params.toArray()[1];
            int dependency_id = (Integer) params.toArray()[2];
            int allowExport = (Integer) params.toArray()[3];
            LOG.trace("Distributing replicated table: " + table_name + " to: " + site_id);
            VoltTable result = performDistributeReplicatedTable(table_name, site_id, context, allowExport);
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreSendReplicatedTable) {
            assert (params.toArray()[0] != null);
            assert (params.toArray()[1] != null);
            assert (params.toArray()[2] != null);
            assert (params.toArray()[3] != null);
            String table_name = (String) params.toArray()[0];
            int dependency_id = (Integer) params.toArray()[1];
            VoltTable table = (VoltTable) params.toArray()[2];
            int allowExport = (Integer) params.toArray()[3];
            LOG.trace("Received replicated table: " + table_name);
            String result_str = "SUCCESS";
            String error_msg = "";
            try {
                this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
            } catch (VoltAbortException e) {
                result_str = "FAILURE";
                error_msg = e.getMessage();
            }
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, table_name, -1, result_str, error_msg);
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreSendReplicatedTableResults) {
            assert (params.toArray()[0] != null);
            int dependency_id = (Integer) params.toArray()[0];
            LOG.trace("Received confirmmation of successful replicated table load");
            VoltTable result = constructResultsTable();
            for (int dep_id : dependencies.keySet()) {
                List<VoltTable> table_list = dependencies.get(dep_id);
                assert (table_list.size() == 1);
                VoltTable t = table_list.get(0);
                while (t.advanceRow()) {
                    // this will actually add the active row of t
                    result.add(t);
                }
            }
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreLoadReplicatedTableResults) {
            LOG.trace("Aggregating replicated table restore results");
            assert (params.toArray()[0] != null);
            int dependency_id = (Integer) params.toArray()[0];
            assert (dependencies.size() > 0);
            VoltTable result = constructResultsTable();
            for (int dep_id : dependencies.keySet()) {
                List<VoltTable> table_list = dependencies.get(dep_id);
                assert (table_list.size() == 1);
                VoltTable t = table_list.get(0);
                while (t.advanceRow()) {
                    // this will actually add the active row of t
                    result.add(t);
                }
            }
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreDistributePartitionedTable) {
            Object paramsA[] = params.toArray();
            assert (paramsA[0] != null);
            assert (paramsA[1] != null);
            assert (paramsA[2] != null);
            assert (paramsA[3] != null);

            String table_name = (String) paramsA[0];
            int originalHosts[] = (int[]) paramsA[1];
            int relevantPartitions[] = (int[]) paramsA[2];
            int dependency_id = (Integer) paramsA[3];
            int allowExport = (Integer) paramsA[4];

            // Using Localized Version
            VoltTable result = performLoadPartitionedTable(table_name, originalHosts, relevantPartitions, context, allowExport, ts);

            // Distributed Version - Invokes another round of plan fragments
            // which does not work
            // VoltTable result =
            // performDistributePartitionedTable(table_name, originalHosts,
            // relevantPartitions, context, allowExport);
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreDistributePartitionedTableResults) {
            LOG.trace("Aggregating partitioned table restore results");
            assert (params.toArray()[0] != null);
            int dependency_id = (Integer) params.toArray()[0];
            VoltTable result = constructResultsTable();
            for (int dep_id : dependencies.keySet()) {
                List<VoltTable> table_list = dependencies.get(dep_id);
                assert (table_list.size() == 1);
                VoltTable t = table_list.get(0);
                while (t.advanceRow()) {
                    // this will actually add the active row of t
                    result.add(t);
                }
            }
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreSendPartitionedTable) {
            assert (params.toArray()[0] != null);
            assert (params.toArray()[1] != null);
            assert (params.toArray()[2] != null);
            assert (params.toArray()[3] != null);
            assert (params.toArray()[4] != null);
            String table_name = (String) params.toArray()[0];
            int partition_id = (Integer) params.toArray()[1];
            int dependency_id = (Integer) params.toArray()[2];
            VoltTable table = (VoltTable) params.toArray()[3];
            int allowExport = (Integer) params.toArray()[4];
            LOG.trace("Received partitioned table: " + table_name);
            String result_str = "SUCCESS";
            String error_msg = "";
            try {
                this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
            } catch (VoltAbortException e) {
                result_str = "FAILURE";
                error_msg = e.getMessage();
            }
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, table_name, partition_id, result_str, error_msg);
            return new DependencySet(dependency_id, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreSendPartitionedTableResults) {
            assert (params.toArray()[0] != null);
            int dependency_id = (Integer) params.toArray()[0];
            LOG.trace("Received confirmation of successful partitioned table load");
            VoltTable result = constructResultsTable();
            for (int dep_id : dependencies.keySet()) {
                List<VoltTable> table_list = dependencies.get(dep_id);
                assert (table_list.size() == 1);
                VoltTable t = table_list.get(0);
                while (t.advanceRow()) {
                    // this will actually add the active row of t
                    result.add(t);
                }
            }
            return new DependencySet(dependency_id, result);
        }

        assert (false);
        return null;
    }
View Full Code Here

Examples of org.voltdb.DependencySet

    public DependencySet executePlanFragment(Long txn_id,
                                             Map<Integer, List<VoltTable>> dependencies,
                                             int fragmentId,
                                             ParameterSet params,
                                             PartitionExecutor.SystemProcedureExecutionContext context) {
        DependencySet result = null;
        switch (fragmentId) {
            // Reset Stats
            case SysProcFragmentId.PF_resetProfilingDistribute: {
                LOG.debug("Resetting internal profiling counters");
                HStoreConf hstore_conf = hstore_site.getHStoreConf();
               
                PartitionExecutor.Debug executorDebug = this.executor.getDebugContext();
                Collection<AbstractProfiler> profilers = new HashSet<AbstractProfiler>();
               
                // EXECUTOR
                if (hstore_conf.site.exec_profiling) {
                    executorDebug.getProfiler().reset();
                }
               
                // SPEC EXEC
                if (hstore_conf.site.specexec_profiling) {
                    for (AbstractProfiler p : executorDebug.getSpecExecScheduler().getDebugContext().getProfilers()) {
                        profilers.add(p);
                    } // FOR
                }
                               
                // MARKOV
                if (hstore_conf.site.markov_profiling) {
                    TransactionEstimator est = executor.getTransactionEstimator();
                    if (est instanceof MarkovEstimator) {
                        profilers.add(((MarkovEstimator)est).getDebugContext().getProfiler());
                    }
                }
               
                // ANTI-CACHE
                if (hstore_conf.site.anticache_enable) {
                    profilers.add(hstore_site.getAntiCacheManager().getDebugContext().getProfiler(this.partitionId));
                }

                // QUEUE
                if (hstore_conf.site.queue_profiling) {
                    profilers.add(hstore_site.getTransactionQueueManager().getDebugContext().getProfiler(this.partitionId));
                }
               
                // The first partition at this HStoreSite will have to reset
                // any global profiling parameters
                if (this.isFirstLocalPartition()) {
                    // COMMAND LOGGER
                    CommandLogWriter commandLog = hstore_site.getCommandLogWriter();
                    if (hstore_conf.site.commandlog_profiling && commandLog.getProfiler() != null) {
                        profilers.add(commandLog.getProfiler());
                    }
                   
                    // Reset the StartWorkload flag in the HStoreSite
                    hstore_site.getDebugContext().resetStartWorkload();
                }
               
                for (AbstractProfiler profiler : profilers) {
                    profiler.reset();
                } // FOR
               
                VoltTable vt = new VoltTable(nodeResultsColumns);
                vt.addRow(this.executor.getHStoreSite().getSiteName(),
                          this.gcTime.getTotalThinkTimeMS() + " ms",
                          new TimestampType());
                result = new DependencySet(SysProcFragmentId.PF_resetProfilingDistribute, vt);
                break;
            }
            // Aggregate Results
            case SysProcFragmentId.PF_resetProfilingAggregate:
                LOG.debug("Combining results");
                List<VoltTable> siteResults = dependencies.get(SysProcFragmentId.PF_resetProfilingDistribute);
                if (siteResults == null || siteResults.isEmpty()) {
                    String msg = "Missing site results";
                    throw new ServerFaultException(msg, txn_id);
                }
               
                VoltTable vt = VoltTableUtil.union(siteResults);
                result = new DependencySet(SysProcFragmentId.PF_resetProfilingAggregate, vt);
                break;
            default:
                String msg = "Unexpected sysproc fragmentId '" + fragmentId + "'";
                throw new ServerFaultException(msg, txn_id);
        } // SWITCH
View Full Code Here

Examples of org.voltdb.DependencySet

                dependencies[ii] = fds.readObject(VoltTable.class);
            }
            assert(depIds.length == 1);

            // and finally return the constructed dependency set
            return new DependencySet(depIds, dependencies);
        }
View Full Code Here

Examples of org.voltdb.DependencySet

                                    -1, f.canRead() ? "TRUE" : "FALSE", "SUCCESS", "");
                        }
                    }
                }
            }
            return new DependencySet(DEP_snapshotScan, results);
        } else if (fragmentId == SysProcFragmentId.PF_snapshotScanResults) {
            final VoltTable results = constructFragmentResultsTable();
            LOG.trace("Aggregating Snapshot Scan  results");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_snapshotScan);
            for (VoltTable table : dep) {
                while (table.advanceRow()) {
                    // this will add the active row of table
                    results.add(table);
                }
            }
            return new DependencySet(DEP_snapshotScanResults, results);
        } else if (fragmentId == SysProcFragmentId.PF_snapshotDigestScan) {
            final VoltTable results = constructDigestResultsTable();
            // Choose the lowest site ID on this host to do the file scan
            // All other sites should just return empty results tables.
            int host_id = context.getHStoreSite().getHostId();
            Integer lowest_site_id = null; // FIXME
            // VoltDB.instance().getCatalogContext().siteTracker.
            // getLowestLiveExecSiteIdForHost(host_id);
            if (context.getPartitionExecutor().getSiteId() == lowest_site_id) {
                assert (params.toArray()[0] != null);
                assert (params.toArray()[0] instanceof String);
                final String path = (String) params.toArray()[0];
                List<File> relevantFiles = retrieveRelevantFiles(path);
                if (relevantFiles == null) {
                    results.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), "", "", "", "FAILURE", errorString);
                } else {
                    for (final File f : relevantFiles) {
                        if (f.getName().endsWith(".vpt")) {
                            continue;
                        }
                        if (f.canRead()) {
                            try {
                                List<String> tableNames = SnapshotUtil.retrieveRelevantTableNamesAndTime(f).getSecond();
                                final StringWriter sw = new StringWriter();
                                for (int ii = 0; ii < tableNames.size(); ii++) {
                                    sw.append(tableNames.get(ii));
                                    if (ii != tableNames.size() - 1) {
                                        sw.append(',');
                                    }
                                }
                                results.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), path, f.getName(), sw.toString(), "SUCCESS", "");
                            } catch (Exception e) {
                                LOG.warn(e);
                            }
                        }
                    }
                }
            }
            return new DependencySet(DEP_snapshotDigestScan, results);
        } else if (fragmentId == SysProcFragmentId.PF_snapshotDigestScanResults) {
            final VoltTable results = constructDigestResultsTable();
            LOG.trace("Aggregating Snapshot Digest Scan  results");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_snapshotDigestScan);
            for (VoltTable table : dep) {
                while (table.advanceRow()) {
                    // this will add the active row of table
                    results.add(table);
                }
            }
            return new DependencySet(DEP_snapshotDigestScanResults, results);
        } else if (fragmentId == SysProcFragmentId.PF_hostDiskFreeScan) {
            final VoltTable results = constructDiskFreeResultsTable();
            // Choose the lowest site ID on this host to do the file scan
            // All other sites should just return empty results tables.
            int host_id = context.getHStoreSite().getHostId();
            Integer lowest_site_id = null; // FIXME
            // VoltDB.instance().getCatalogContext().siteTracker.
            // getLowestLiveExecSiteIdForHost(host_id);
            if (context.getPartitionExecutor().getSiteId() == lowest_site_id) {
                assert (params.toArray()[0] != null);
                assert (params.toArray()[0] instanceof String);
                final String path = (String) params.toArray()[0];
                File dir = new File(path);

                if (dir.isDirectory()) {
                    final long free = dir.getUsableSpace();
                    final long total = dir.getTotalSpace();
                    final long used = total - free;
                    results.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), hostname, path, total, free, used, "SUCCESS", "");
                } else {
                    results.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), hostname, path, 0, 0, 0, "FAILURE", "Path is not a directory");
                }
            }
            return new DependencySet(DEP_hostDiskFreeScan, results);
        } else if (fragmentId == SysProcFragmentId.PF_hostDiskFreeScanResults) {
            final VoltTable results = constructDiskFreeResultsTable();
            LOG.trace("Aggregating disk free results");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_hostDiskFreeScan);
            for (VoltTable table : dep) {
                while (table.advanceRow()) {
                    // this will add the active row of table
                    results.add(table);
                }
            }
            return new DependencySet(DEP_hostDiskFreeScanResults, results);
        }
        assert (false);
        return null;
    }
View Full Code Here

Examples of org.voltdb.DependencySet

            for (int i = 0; i < numDependencies; ++i) {
                depIds[i] = deserializer.readInt();
                dependencies[i] = deserializer.readObject(VoltTable.class);
            } // FOR
            assert(depIds.length == 1);
            return new DependencySet(depIds, dependencies);
        } catch (final IOException ex) {
            LOG.error("Failed to deserialze result dependencies" + ex);
            throw new EEException(ERRORCODE_WRONG_SERIALIZED_BYTES);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.