Search in sources :

Example 6 with SnapshotPathType

use of org.voltdb.sysprocs.saverestore.SnapshotPathType in project voltdb by VoltDB.

the class SnapshotScanAgent method getSnapshotScanResults.

private VoltTable getSnapshotScanResults(String path) {
    List<SnapshotResultRow> results = new ArrayList<SnapshotResultRow>();
    List<File> relevantFiles = retrieveRelevantFiles(path);
    if (relevantFiles == null) {
        results.add(new SnapshotResultRow(m_messenger.getHostId(), m_hostname, "", SnapshotPathType.SNAP_PATH.toString(), "", 0, 0, "", "FALSE", 0, "", "", 0, "", "FAILURE", m_errorString));
    } else {
        for (final File f : relevantFiles) {
            if (f.getName().endsWith(".digest")) {
                continue;
            }
            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);
                        }
                        SnapshotPathType stype = SnapshotPathType.SNAP_PATH;
                        if (f.getParent().equals(VoltDB.instance().getCommandLogSnapshotPath())) {
                            stype = SnapshotPathType.SNAP_CL;
                        } else if (f.getParent().equals(VoltDB.instance().getSnapshotPath())) {
                            stype = SnapshotPathType.SNAP_AUTO;
                        }
                        results.add(new SnapshotResultRow(m_messenger.getHostId(), m_hostname, f.getParent(), stype.toString(), f.getName(), savefile.getTxnId(), savefile.getTimestamp(), savefile.getTableName(), savefile.getCompleted() ? "TRUE" : "FALSE", f.length(), savefile.isReplicated() ? "TRUE" : "FALSE", partitions, savefile.getTotalPartitions(), f.canRead() ? "TRUE" : "FALSE", "SUCCESS", ""));
                    } catch (IOException e) {
                        SNAP_LOG.warn(e);
                    } finally {
                        savefile_input.close();
                    }
                } catch (IOException e) {
                    SNAP_LOG.warn(e);
                }
            } else {
                SnapshotPathType stype = SnapshotPathType.SNAP_PATH;
                if (f.getParent().equals(VoltDB.instance().getCommandLogSnapshotPath())) {
                    stype = SnapshotPathType.SNAP_CL;
                } else if (f.getParent().equals(VoltDB.instance().getSnapshotPath())) {
                    stype = SnapshotPathType.SNAP_AUTO;
                }
                results.add(new SnapshotResultRow(m_messenger.getHostId(), m_hostname, f.getParent(), stype.toString(), f.getName(), 0L, f.lastModified(), "", "FALSE", f.length(), "FALSE", "", -1, f.canRead() ? "TRUE" : "FALSE", "SUCCESS", ""));
            }
        }
    }
    Collections.sort(results, new Comparator<SnapshotResultRow>() {

        @Override
        public int compare(SnapshotResultRow r1, SnapshotResultRow r2) {
            return r1.compareTo(r2);
        }
    });
    VoltTable sortedResults = constructFragmentResultsTable();
    for (SnapshotResultRow row : results) {
        sortedResults.addRow(row.hostId, row.hostName, row.path, row.name, row.txnid, row.created, row.table, row.completed, row.size, row.isReplicated, row.partitions, row.totalPartitions, row.readable, row.result, row.errMsg, row.pathType);
    }
    return sortedResults;
}
Also used : TableSaveFile(org.voltdb.sysprocs.saverestore.TableSaveFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SnapshotPathType(org.voltdb.sysprocs.saverestore.SnapshotPathType) VoltFile(org.voltdb.utils.VoltFile) TableSaveFile(org.voltdb.sysprocs.saverestore.TableSaveFile) File(java.io.File)

Aggregations

SnapshotPathType (org.voltdb.sysprocs.saverestore.SnapshotPathType)6 File (java.io.File)4 VoltFile (org.voltdb.utils.VoltFile)3 HashMap (java.util.HashMap)2 JSONObject (org.json_voltpatches.JSONObject)2 ImmutableMap (com.google_voltpatches.common.collect.ImmutableMap)1 FileFilter (java.io.FileFilter)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 NoNodeException (org.apache.zookeeper_voltpatches.KeeperException.NoNodeException)1 JSONException (org.json_voltpatches.JSONException)1 VoltMessage (org.voltcore.messaging.VoltMessage)1 Pair (org.voltcore.utils.Pair)1 SnapshotCompletionEvent (org.voltdb.SnapshotCompletionInterest.SnapshotCompletionEvent)1 SnapshotCheckRequestMessage (org.voltdb.messaging.SnapshotCheckRequestMessage)1 SnapshotCheckResponseMessage (org.voltdb.messaging.SnapshotCheckResponseMessage)1 NodeSettings (org.voltdb.settings.NodeSettings)1