use of kafka.tools.TerseFailure in project kafka by apache.
the class MetadataShell method main.
public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers.newArgumentParser("metadata-tool").defaultHelp(true).description("The Apache Kafka metadata tool");
parser.addArgument("--snapshot", "-s").type(String.class).help("The snapshot file to read.");
parser.addArgument("command").nargs("*").help("The command to run.");
Namespace res = parser.parseArgsOrFail(args);
try {
Builder builder = new Builder();
builder.setSnapshotPath(res.getString("snapshot"));
Path tempDir = Files.createTempDirectory("MetadataShell");
Exit.addShutdownHook("agent-shutdown-hook", () -> {
log.debug("Removing temporary directory " + tempDir.toAbsolutePath().toString());
try {
Utils.delete(tempDir.toFile());
} catch (Exception e) {
log.error("Got exception while removing temporary directory " + tempDir.toAbsolutePath().toString());
}
});
MetadataShell shell = builder.build();
try {
shell.run(res.getList("command"));
} finally {
shell.close();
}
Exit.exit(0);
} catch (TerseFailure e) {
System.err.println("Error: " + e.getMessage());
Exit.exit(1);
} catch (Throwable e) {
System.err.println("Unexpected error: " + (e.getMessage() == null ? "" : e.getMessage()));
e.printStackTrace(System.err);
Exit.exit(1);
}
}
Aggregations