@Parameters(commandDescription = "List the existing FATE transactions")
static class PrintOpts {}
public static void main(String[] args) throws Exception {
Help opts = new Help();
JCommander jc = new JCommander(opts);
jc.setProgramName(Admin.class.getName());
jc.addCommand("fail", new FailOpts());
jc.addCommand("delete", new DeleteOpts());
jc.addCommand("print", new PrintOpts());
jc.parse(args);
if (opts.help || jc.getParsedCommand() == null) {
jc.usage();
System.exit(-1);
}
AdminUtil<Master> admin = new AdminUtil<Master>();
Instance instance = HdfsZooInstance.getInstance();
String path = ZooUtil.getRoot(instance) + Constants.ZFATE;
String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK;
IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
ZooStore<Master> zs = new ZooStore<Master>(path, zk);
if (jc.getParsedCommand().equals("fail")) {
if (!admin.prepFail(zs, zk, masterPath, args[1])) {
System.exit(1);
}
} else if (jc.getParsedCommand().equals("delete")) {
if (!admin.prepDelete(zs, zk, masterPath, args[1])) {
System.exit(1);
}
admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, args[1]);
} else if (jc.getParsedCommand().equals("print")) {
admin.print(new ReadOnlyStore<Master>(zs), zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS);
}
}