}
@Override
public Repo<Master> call(long tid, Master master) throws Exception {
try {
VolumeManager fs = master.getFileSystem();
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
for (String oldFileName : fileNameMappings.keySet()) {
if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
throw new ThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
"File referenced by exported table does not exists " + oldFileName);
}
}
FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
for (FileStatus fileStatus : files) {
String newName = fileNameMappings.get(fileStatus.getPath().getName());
if (newName != null)
fs.rename(fileStatus.getPath(), new Path(tableInfo.importDir, newName));
}
return new FinishImportTable(tableInfo);
} catch (IOException ioe) {
log.warn(ioe.getMessage(), ioe);