CRC32 overallChecksum = new CRC32();
private void verifyDir(DFSClient client, String dir)
throws IOException {
DFSFileInfo[] fileArr = client.listPaths(new UTF8(dir));
TreeMap<String, Boolean> fileMap = new TreeMap<String, Boolean>();
for(DFSFileInfo file : fileArr) {
String path = file.getPath();
fileMap.put(path, Boolean.valueOf(file.isDir()));
}
for(Iterator<String> it = fileMap.keySet().iterator(); it.hasNext();) {
String path = it.next();
boolean isDir = fileMap.get(path);
overallChecksum.update(path.getBytes());
if ( isDir ) {
verifyDir(client, path);
} else {
// this is not a directory. Checksum the file data.
CRC32 fileCRC = new CRC32();
FSInputStream in = client.open(new UTF8(path));
byte[] buf = new byte[4096];
int nRead = 0;
while ( (nRead = in.read(buf, 0, buf.length)) > 0 ) {
fileCRC.update(buf, 0, nRead);
}