use of org.apache.pulsar.client.admin.PulsarAdminWithFunctions in project incubator-pulsar by apache.
the class PulsarAdminTool method main.
public static void main(String[] args) throws Exception {
String configFile = args[0];
Properties properties = new Properties();
if (configFile != null) {
FileInputStream fis = null;
try {
fis = new FileInputStream(configFile);
properties.load(fis);
} finally {
if (fis != null)
fis.close();
}
}
PulsarAdminTool tool = new PulsarAdminTool(properties);
int cmdPos;
for (cmdPos = 1; cmdPos < args.length; cmdPos++) {
if (tool.commandMap.containsKey(args[cmdPos])) {
break;
}
}
++cmdPos;
boolean isLocalRun = false;
if (cmdPos < args.length) {
isLocalRun = "localrun" == args[cmdPos].toLowerCase();
}
BiFunction<URL, ClientConfigurationData, ? extends PulsarAdmin> adminFactory;
if (isLocalRun) {
// bypass constructing admin client
adminFactory = (url, config) -> null;
} else {
adminFactory = (url, config) -> {
try {
return new PulsarAdminWithFunctions(url, config);
} catch (Exception ex) {
System.err.println(ex.getClass() + ": " + ex.getMessage());
System.exit(1);
return null;
}
};
}
if (tool.run(Arrays.copyOfRange(args, 1, args.length), adminFactory)) {
System.exit(0);
} else {
System.exit(1);
}
}
Aggregations