Package org.voltdb

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


                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

                                    -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

            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

                          Arrays.toString(planFragmentIds),
                          Arrays.toString(parameterSets));
       
        if (batchSize == 0) {
            LOG.warn("No fragments to execute. Returning empty DependencySet");
            return (new DependencySet(new int[0], HStoreConstants.EMPTY_RESULT));
        }
       
        if (this.trackingCache != null) {
            this.trackingResetCacheEntry(txnId);
        }

        // serialize the param sets
        fsForParameterSet.clear();
        try {
            for (int i = 0; i < batchSize; ++i) {
                assert(parameterSets[i] != null) :
                    String.format("Null ParameterSet at offset %d for txn #%d\n" +
                                  "PlanFragments:%s\nParameterSets:%s",
                                  i, txnId,
                                  Arrays.toString(planFragmentIds),
                                  Arrays.toString(parameterSets));
               
                parameterSets[i].writeExternal(fsForParameterSet);
                if (trace.val)
                    LOG.trace(String.format("Batch Executing planfragment:%d, params=%s",
                              planFragmentIds[i], parameterSets[i]));
            }
        } catch (final IOException exception) {
            throw new RuntimeException(exception); // can't happen
        }

        // Execute the plan, passing a raw pointer to the byte buffers for input and output
        deserializer.clear();
        final int errorCode = nativeExecuteQueryPlanFragmentsAndGetResults(this.pointer,
                planFragmentIds, batchSize,
                input_depIds,
                output_depIds,
                txnId, lastCommittedTxnId, undoToken);
        checkErrorCode(errorCode);

        // get a copy of the result buffers and make the tables use the copy
        ByteBuffer fullBacking = deserializer.buffer();
        try {
            // read the complete size of the buffer used
            fullBacking.getInt();
            // check if anything was changed
            m_dirty = (fullBacking.get() == 1 ? true : false);

            // get a copy of the buffer
            // Because this is a copy, that means we don't have to worry about the EE overwriting us
            // Not sure of the implications for performance.
             // deserializer.readBuffer(totalSize);
           
            // At this point we don't know how many dependencies we expect to get back from our fragments.
            // We're just going to assume that each PlanFragment generated one and only one output dependency
            VoltTable results[] = new VoltTable[batchSize];
            int dependencies[] = new int[batchSize];
            int dep_ctr = 0;
            for (int i = 0; i < batchSize; ++i) {
                int numDependencies = fullBacking.getInt(); // number of dependencies for this frag
                assert(numDependencies == 1) :
                    "Unexpected multiple output dependencies from PlanFragment #" + planFragmentIds[i];
               
                // PAVLO: Since we can't pass the dependency ids using nativeExecuteQueryPlanFragmentsAndGetResults(),
                // the results will come back without a dependency id. So we have to just assume
                // that the frags were executed in the order that we passed to the EE and that we
                // can just use the list of output_depIds that we have
                for (int ii = 0; ii < numDependencies; ++ii) {
                    assert(dep_ctr < output_depIds.length) :
                        "Trying to get depId #" + dep_ctr + ": " + Arrays.toString(output_depIds);
                    fullBacking.getInt(); // IGNORE
                    int depid = output_depIds[dep_ctr];
                    assert(depid >= 0);
                   
                    int tableSize = fullBacking.getInt();
                    assert(tableSize < 10000000);
                    byte tableBytes[] = new byte[tableSize];
                    fullBacking.get(tableBytes, 0, tableSize);
                    final ByteBuffer tableBacking = ByteBuffer.wrap(tableBytes);
//                    fullBacking.position(fullBacking.position() + tableSize);

                    results[dep_ctr] = PrivateVoltTableFactory.createVoltTableFromBuffer(tableBacking, true);
                    dependencies[dep_ctr] = depid;
                    if (debug.val) LOG.debug(String.format("%d - New output VoltTable for DependencyId %d [origTableSize=%d]\n%s",
                                                   txnId, depid, tableSize, results[dep_ctr].toString()));
                    dep_ctr++;
                } // FOR
            } // FOR
           
            return (new DependencySet(dependencies, results));
        } catch (Throwable ex) {
            LOG.error("Failed to deserialze result table" + ex);
            throw new EEException(ERRORCODE_WRONG_SERIALIZED_BYTES);
        }
    }
View Full Code Here

            byte block = (Byte) params.toArray()[3];
            SnapshotSaveAPI saveAPI = new SnapshotSaveAPI();
            VoltTable result = saveAPI.startSnapshotting(file_path, file_nonce, block, startTime, context, hostname);

            LOG.trace("createSnapshotTargets :: Ends at partition : " + context.getPartitionExecutor().getPartitionId() + "\n" + result);
            return new DependencySet(SnapshotSave.DEP_createSnapshotTargets, result);
        } else if (fragmentId == SysProcFragmentId.PF_createSnapshotTargetsResults) {
            return createSnapshotTargetsResults(dependencies);
        }
        assert (false);
        return null;
View Full Code Here

                    result.add(table);
                }
            }

            LOG.trace("createSnapshotTargetsResults : " + "\n" + result);
            return new DependencySet(DEP_createSnapshotTargetsResults, result);
        }
    }
View Full Code Here

               LOG.trace("ExecutionSitesCurrentlySnapshotting check : " + SnapshotSiteProcessor.ExecutionSitesCurrentlySnapshotting.get());

                // CHANGE : Only 1 Site doing this
                if (SnapshotSiteProcessor.ExecutionSitesCurrentlySnapshotting.get() != -1) {
                    result.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), hostname, "", "FAILURE", "SNAPSHOT IN PROGRESS");
                    return new DependencySet(DEP_saveTest, result);
                }

                for (Table table : SnapshotUtil.getTablesToSave(context.getDatabase())) {
                    File saveFilePath = SnapshotUtil.constructFileForTable(table, file_path, file_nonce,
                            String.valueOf(context.getHost().getId()),                                
                            String.valueOf(context.getHStoreSite().getSiteId()),
                            String.valueOf(context.getPartitionExecutor().getPartitionId())
                            );
                    LOG.trace("Host ID " + context.getSite().getHost().getTypeName() + " table: " + table.getTypeName() + " to path: " + saveFilePath);
                    String file_valid = "SUCCESS";
                    String err_msg = "";
                    if (saveFilePath.exists()) {
                        file_valid = "FAILURE";
                        err_msg = "SAVE FILE ALREADY EXISTS: " + saveFilePath;
                    } else if (!saveFilePath.getParentFile().canWrite()) {
                        file_valid = "FAILURE";
                        err_msg = "FILE LOCATION UNWRITABLE: " + saveFilePath;
                    } else {
                        try {
                            saveFilePath.createNewFile();
                        } catch (IOException ex) {
                            file_valid = "FAILURE";
                            err_msg = "FILE CREATION OF " + saveFilePath + "RESULTED IN IOException: " + ex.getMessage();
                        }
                    }
                    result.addRow(catalog_host.getId(), hostname, context.getHStoreSite().getSiteId(), context.getPartitionExecutor().getPartitionId(),  table.getTypeName(), file_valid, err_msg);
                }
            }
            //LOG.trace("Host ID " + context.getSite().getHost().getTypeName() + "\n" + new DependencySet(DEP_saveTest, result));
            return new DependencySet(DEP_saveTest, result);
        }
    }
View Full Code Here

                while (table.advanceRow()) {
                    // this will add the active row of table
                    result.add(table);
                }
            }
            return new DependencySet(DEP_saveTestResults, result);
        }
    }
View Full Code Here

        assert(fragmentId == SysProcFragmentId.PF_getCatalog);
       
        // Serialize the catalog and throw it back to the client
        VoltTable vt = new VoltTable(nodeResultsColumns);
        vt.addRow(catalogContext.catalog.serialize(), new TimestampType());
        DependencySet result = new DependencySet(SysProcFragmentId.PF_getCatalog, vt);
        return (result);
    }
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.