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;
}
Aggregations