Package org.voltdb

Examples of org.voltdb.DependencySet


        // Create a mocked up dependency pair. Required by some tests
        VoltTable vt;
        vt = new VoltTable(new ColumnInfo[] {
                           new ColumnInfo("foo", VoltType.INTEGER)});
        vt.addRow(Integer.valueOf(1));
        return new DependencySet(outputDepId, vt);
    }
View Full Code Here


    public DependencySet executePlanFragment(Long txn_id,
                                             Map<Integer, List<VoltTable>> dependencies,
                                             int fragmentId,
                                             ParameterSet params,
                                             PartitionExecutor.SystemProcedureExecutionContext context) {
        DependencySet result = null;
        switch (fragmentId) {
            case SysProcFragmentId.PF_quiesceDistribute: {
                LOG.debug("Clearing out work queue at partition " + executor.getPartitionId());
                executor.haltProcessing();
               
                // Clear out the QueueManager too if this is the first partition
                // at this site
                hstore_site.getTransactionQueueManager().clearQueues(executor.getPartitionId());
               
                VoltTable vt = new VoltTable(ResultsColumns);
                Object row[] = {
                    this.hstore_site.getSiteId(),
                    this.hstore_site.getSiteName(),
                    this.executor.getPartitionId(),
                    Status.OK.name(),
                    new TimestampType(),
                };
                vt.addRow(row);
                result = new DependencySet(SysProcFragmentId.PF_quiesceDistribute, vt);
                break;
            }
            // Aggregate Results
            case SysProcFragmentId.PF_quiesceAggregate:
                List<VoltTable> siteResults = dependencies.get(SysProcFragmentId.PF_quiesceDistribute);
                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_quiesceAggregate, vt);
                break;
            default:
                String msg = "Unexpected sysproc fragmentId '" + fragmentId + "'";
                throw new ServerFaultException(msg, txn_id);
        } // SWITCH
View Full Code Here

                      (lastExecuted != null  ? lastExecuted.longValue()  : VoltType.NULL_BIGINT),
                      (lastCommitted != null ? lastCommitted.longValue() : VoltType.NULL_BIGINT),
                      new TimestampType());
        } // FOR
       
        DependencySet result = new DependencySet(SysProcFragmentId.PF_execStatus, vt);
        return (result);
    }
View Full Code Here

            table = ee.executeCustomPlanFragment(plan, outputDepId, inputDepId, txn_id,
                                          context.getLastCommittedTxnId(),
                                          ts.getLastUndoToken(this.partitionId));
        }

        return new DependencySet(new int[]{ outputDepId }, new VoltTable[]{ table });
    }
View Full Code Here

                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

                        }
                    }
                }
            }

            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

            } 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

    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

                        (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

                // 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

TOP

Related Classes of org.voltdb.DependencySet

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.