use of org.apache.crail.CrailMultiFile in project incubator-crail by apache.
the class CrailFsck method blockStatistics.
public void blockStatistics(String filename) throws Exception {
HashMap<String, AtomicInteger> stats = new HashMap<String, AtomicInteger>();
CrailConfiguration conf = new CrailConfiguration();
CrailStore fs = CrailStore.newInstance(conf);
CrailNode node = fs.lookup(filename).get();
if (node.getType() == CrailNodeType.DIRECTORY) {
CrailDirectory directory = node.asDirectory();
Iterator<String> iter = directory.listEntries();
while (iter.hasNext()) {
String path = iter.next();
CrailFile child = fs.lookup(path).get().asFile();
walkBlocks(stats, fs, child.getPath(), 0, child.getCapacity());
}
} else if (node.getType() == CrailNodeType.DATAFILE) {
CrailFile file = node.asFile();
walkBlocks(stats, fs, file.getPath(), 0, file.getCapacity());
} else if (node.getType() == CrailNodeType.MULTIFILE) {
CrailMultiFile directory = node.asMultiFile();
Iterator<String> iter = directory.listEntries();
while (iter.hasNext()) {
String path = iter.next();
CrailFile child = fs.lookup(path).get().asFile();
walkBlocks(stats, fs, child.getPath(), 0, child.getCapacity());
}
}
printStats(stats);
fs.close();
}
Aggregations