Search in sources :

Example 1 with PulsarAdminWithFunctions

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);
    }
}
Also used : ClientConfigurationData(org.apache.pulsar.client.impl.conf.ClientConfigurationData) PulsarAdminWithFunctions(org.apache.pulsar.client.admin.PulsarAdminWithFunctions) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException)

Aggregations

FileInputStream (java.io.FileInputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Properties (java.util.Properties)1 PulsarAdminWithFunctions (org.apache.pulsar.client.admin.PulsarAdminWithFunctions)1 ClientConfigurationData (org.apache.pulsar.client.impl.conf.ClientConfigurationData)1