MetadataTable.addBulkLoadInProgressFlag("/" + bulkDir.getParent().getName() + "/" + bulkDir.getName());
Path dirPath = new Path(dir);
FileStatus[] mapFiles = fs.listStatus(dirPath);
UniqueNameAllocator namer = UniqueNameAllocator.getInstance();
for (FileStatus fileStatus : mapFiles) {
String sa[] = fileStatus.getPath().getName().split("\\.");
String extension = "";
if (sa.length > 1) {
extension = sa[sa.length - 1];
if (!FileOperations.getValidExtensions().contains(extension)) {
log.warn(fileStatus.getPath() + " does not have a valid extension, ignoring");
continue;
}
} else {
// assume it is a map file
extension = Constants.MAPFILE_EXTENSION;
}
if (extension.equals(Constants.MAPFILE_EXTENSION)) {
if (!fileStatus.isDir()) {
log.warn(fileStatus.getPath() + " is not a map file, ignoring");
continue;
}
if (fileStatus.getPath().getName().equals("_logs")) {
log.info(fileStatus.getPath() + " is probably a log directory from a map/reduce task, skipping");
continue;
}
try {
FileStatus dataStatus = fs.getFileStatus(new Path(fileStatus.getPath(), MapFile.DATA_FILE_NAME));
if (dataStatus.isDir()) {
log.warn(fileStatus.getPath() + " is not a map file, ignoring");
continue;
}
} catch (FileNotFoundException fnfe) {
log.warn(fileStatus.getPath() + " is not a map file, ignoring");
continue;
}
}
String newName = "I" + namer.getNextName() + "." + extension;
Path newPath = new Path(bulkDir, newName);
try {
fs.rename(fileStatus.getPath(), newPath);
log.debug("Moved " + fileStatus.getPath() + " to " + newPath);
} catch (IOException E1) {