Examples of TableSaveFile


Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

    }

    private static synchronized boolean hasMoreChunks() throws IOException {
        boolean hasMoreChunks = false;
        while (!hasMoreChunks && m_saveFiles.peek() != null) {
            TableSaveFile f = m_saveFiles.peek();
            hasMoreChunks = f.hasMoreChunks();
            if (!hasMoreChunks) {
                try {
                    f.close();
                } catch (IOException e) {
                }
                m_saveFiles.poll();
            }
        }
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

    }

    private static synchronized BBContainer getNextChunk() throws IOException {
        BBContainer c = null;
        while (c == null && m_saveFiles.peek() != null) {
            TableSaveFile f = m_saveFiles.peek();
            LOG.trace("File Channel Size :" + f.getFileChannel().size());
            LOG.trace("File Channel Position :" + f.getFileChannel().position());
            c = f.getNextChunk();
            if (c == null) {
                LOG.trace("getNextChunk null");
                f.close();
                m_saveFiles.poll();
            }
        }
        return c;
    }
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

                m_fileNonce = (String) params.toArray()[1];
                LOG.trace("Checking saved table state for restore of: " + m_filePath + ", " + m_fileNonce);
                File[] savefiles = retrieveRelevantFiles(m_filePath, m_fileNonce);
                for (File file : savefiles) {
                    LOG.trace("Retrieving File :" + file);
                    TableSaveFile savefile = null;
                    try {
                        savefile = getTableSaveFile(file, 1, null);
                        try {

                            if (!savefile.getCompleted()) {
                                continue;
                            }

                            String is_replicated = "FALSE";
                            if (savefile.isReplicated()) {
                                is_replicated = "TRUE";
                            }
                            int partitionIds[] = savefile.getPartitionIds();
                            for (int pid : partitionIds) {
                                result.addRow(m_hostId, hostname, savefile.getHostId(), savefile.getHostname(), savefile.getClusterName(), savefile.getDatabaseName(), savefile.getTableName(),
                                        is_replicated, pid, savefile.getTotalPartitions());
                            }
                        } finally {
                            savefile.close();
                        }
                    } catch (FileNotFoundException e) {
                        // retrieveRelevantFiles should always generate a list
                        // of valid present files in m_filePath, so if we end up
                        // getting here, something has gone very weird.
                        e.printStackTrace();
                    } catch (IOException e) {
                        // For the time being I'm content to treat this as a
                        // missing file and let the coordinator complain if
                        // it discovers that it can't build a consistent
                        // database out of the files it sees available.
                        //
                        // Maybe just a log message? Later.
                        e.printStackTrace();
                    }
                }
            } else {
                // 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);
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

        return new File(filePath, new String(filename_builder));
    }

    private static TableSaveFile getTableSaveFile(File saveFile, int readAheadChunks, int relevantPartitionIds[]) throws IOException {
        FileInputStream savefile_input = new FileInputStream(saveFile);
        TableSaveFile savefile = new TableSaveFile(savefile_input.getChannel(), readAheadChunks, relevantPartitionIds);
        savefile.setFilePath(saveFile.getAbsolutePath());
        return savefile;
    }
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

    // I believe that it will work for at least one new node, but
    // there's not a good way to add a unit test for this at the moment,
    // so the emma coverage is weak.
    private VoltTable performDistributeReplicatedTable(String tableName, int siteId, SystemProcedureExecutionContext context, int allowExport) {
        String hostname = ConnectionUtil.getHostnameOrAddress();
        TableSaveFile savefile = null;
        try {
            savefile = getTableSaveFile(getSaveFileForReplicatedTable(tableName), 3, null);
            assert (savefile.getCompleted());
        } catch (IOException e) {
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, tableName, -1, "FAILURE", "Unable to load table: " + tableName + " error: " + e.getMessage());
            return result;
        }

        LOG.trace("Starting performDistributeReplicatedTable" + tableName);

        VoltTable[] results = null;
        results[0].addRow(m_hostId, hostname, m_siteId, tableName, -1, "SUCCESS", "NO DATA TO DISTRIBUTE");
        final Table new_catalog_table = getCatalogTable(tableName);
        Boolean needsConversion = null;
        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
                }

                if (needsConversion == null) {
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

        int partition_id = context.getPartitionExecutor().getPartitionId();
        LOG.trace("Starting performLoadPartitionedTable " + tableName + " at partition - " + partition_id);

        String result_str = "SUCCESS";
        String error_msg = "";
        TableSaveFile savefile = null;

        /**
         * For partitioned tables
         */
        try {
            savefile = getTableSaveFile(getSaveFileForPartitionedTable(m_filePath, m_fileNonce, tableName,
                    catalog_host.getId(),
                    catalog_site.getId(),
                    catalog_partition.getId()),                            
                    3, null);
            assert (savefile.getCompleted());
        } catch (IOException e) {
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, tableName, -1, "FAILURE", "Unable to load table: " + tableName + " error: " + e.getMessage());
            return 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(tableName);
                table = SavedTableConverter.convertTable(old_table, new_catalog_table);
                c.discard();
                try {
                    LOG.trace("LoadTable " + tableName);

                    this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), tableName, table, allowExport);
                } catch (VoltAbortException e) {
                    result_str = "FAILURE";
                    error_msg = e.getMessage();
                    break;
                }
            }

        } catch (Exception e) {
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, tableName, -1, "FAILURE", "Unable to load table: " + tableName + " error: " + e.getMessage());
            return result;
        }

        VoltTable result = constructResultsTable();
        result.addRow(m_hostId, hostname, m_siteId, tableName, -1, result_str, error_msg);
        try {
            savefile.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

                        }
                        if (f.canRead()) {
                            try {
                                FileInputStream savefile_input = new FileInputStream(f);
                                try {
                                    TableSaveFile savefile = new TableSaveFile(savefile_input.getChannel(), 1, null);
                                    String partitions = "";

                                    for (int partition : savefile.getPartitionIds()) {
                                        partitions = partitions + "," + partition;
                                    }

                                    if (partitions.startsWith(",")) {
                                        partitions = partitions.substring(1);
                                    }

                                    results.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), hostname, f.getParent(), f.getName(), savefile.getCreateTime(),
                                            savefile.getTableName(), savefile.getCompleted() ? "TRUE" : "FALSE", f.length(), savefile.isReplicated() ? "TRUE" : "FALSE", partitions,
                                            savefile.getTotalPartitions(), f.canRead() ? "TRUE" : "FALSE", "SUCCESS", "");
                                } catch (IOException e) {
                                    LOG.warn(e);
                                } finally {
                                    savefile_input.close();
                                }
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

                }
                if (f.canRead()) {
                    try {
                        FileInputStream savefile_input = new FileInputStream(f);
                        try {
                            TableSaveFile savefile =
                                new TableSaveFile(
                                        savefile_input,
                                        1,
                                        null);
                            String partitions = "";

                            for (int partition : savefile.getPartitionIds()) {
                                partitions = partitions + "," + partition;
                            }

                            if (partitions.startsWith(",")) {
                                partitions = partitions.substring(1);
                            }

                            results.addRow(
                                    m_messenger.getHostId(),
                                    m_hostname,
                                    f.getParent(),
                                    f.getName(),
                                    savefile.getTxnId(),
                                    org.voltdb.TransactionIdManager.getTimestampFromTransactionId(
                                        savefile.getTxnId()),
                                    savefile.getTableName(),
                                    savefile.getCompleted() ? "TRUE" : "FALSE",
                                    f.length(),
                                    savefile.isReplicated() ? "TRUE" : "FALSE",
                                    partitions,
                                    savefile.getTotalPartitions(),
                                    f.canRead() ? "TRUE" : "FALSE",
                                    "SUCCESS",
                                    ""
                                    );
                        } catch (IOException e) {
View Full Code Here

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile

    public CSVTableSaveFile(File saveFile, char delimiter, Integer partitions[])
            throws IOException {
        m_delimiter = delimiter;
        final FileInputStream fis = new FileInputStream(saveFile);
        m_saveFile = new TableSaveFile(fis, 10, partitions);
        for (int ii = 0; ii < m_converterThreads.length; ii++) {
            m_converterThreads[ii] = new Thread(new ConverterThread());
            m_converterThreads[ii].start();
        }
    }
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.