}
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
if (commandLine.hasOption("i")) {
String ip = commandLine.getOptionValue('i').trim();
defaultMQAdminExt.start();
String project = defaultMQAdminExt.getProjectGroupByIp(ip);
System.out.printf("ip=%s, projectGroup=%s\n", ip, project);
}
else if (commandLine.hasOption("p")) {
String project = commandLine.getOptionValue('p').trim();
defaultMQAdminExt.start();
String ips = defaultMQAdminExt.getIpsByProjectGroup(project);
if (UtilAll.isBlank(ips)) {
System.out.printf("No ip in project group[%s]\n", project);
}
else {
System.out.printf("projectGroup=%s, ips=%s\n", project, ips);
}
}
else {
ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options);
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}