Search in sources :

Example 1 with MonitorOptions

use of backtype.storm.generated.MonitorOptions in project jstorm by alibaba.

the class metrics_monitor method main.

public static void main(String[] args) {
    if (args == null || args.length <= 1) {
        throw new InvalidParameterException("Should input topology name and enable flag");
    }
    String topologyName = args[0];
    NimbusClient client = null;
    try {
        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);
        boolean isEnable = Boolean.valueOf(args[1]);
        MonitorOptions options = new MonitorOptions();
        options.set_isEnable(isEnable);
        client.getClient().metricMonitor(topologyName, options);
        String str = (isEnable) ? "enable" : "disable";
        System.out.println("Successfully submit command to " + str + " the monitor of " + topologyName);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) MonitorOptions(backtype.storm.generated.MonitorOptions) NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) InvalidParameterException(java.security.InvalidParameterException)

Aggregations

MonitorOptions (backtype.storm.generated.MonitorOptions)1 NimbusClient (backtype.storm.utils.NimbusClient)1 InvalidParameterException (java.security.InvalidParameterException)1 Map (java.util.Map)1