public static void main(final String[] args) throws ParseException, IOException {
final CommandLineParser parser = new GnuParser();
final Options options = getCLIOptions();
final CommandLine cmd;
try {
cmd = parser.parse(options, args);
} catch (final ParseException e) {
final String cmdLineSyntax = "java -cp [jar_name] com.uber.marmaray.tools.HDFSMetadataPrinter "
+ "-m [METADATA_FILE]";
final String header = "This tools prints out all the metadata contents of a HDFS metadata file.";
final String footer = "For help, please contact the Hadoop Data Platform team";
CommandLineUtil.printHelp(options, cmdLineSyntax, header, footer);
throw e;
}
final String metadataFilePath = cmd.getOptionValue(METADATA_FILE_OPTION);
Preconditions.checkState(!Strings.isNullOrEmpty(metadataFilePath));
log.info("Printing contents of metadata file: " + metadataFilePath);
final Configuration conf = new Configuration();
final FileSystem fs = FSUtils.getFs(conf);
try (final InputStream is = new BufferedInputStream(fs.open(new Path(metadataFilePath)))) {
try (final ObjectInputStream input = new ObjectInputStream(is)) {
final Map<String, StringValue> metadataMap = HDFSMetadataManager.deserialize(input);
metadataMap.entrySet()
.stream()
.forEach(entry ->
log.info("Key: " + entry.getKey() + " Value: " + entry.getValue().getValue()));
}
}
}