Search in sources :

Example 6 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class kill_topology method main.

public static void main(String[] args) {
    if (args == null || args.length == 0) {
        throw new InvalidParameterException("Should input topology name");
    }
    String topologyName = args[0];
    NimbusClient client = null;
    try {
        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);
        if (args.length == 1) {
            client.getClient().killTopology(topologyName);
        } else {
            int delaySeconds = Integer.parseInt(args[1]);
            KillOptions options = new KillOptions();
            options.set_wait_secs(delaySeconds);
            client.getClient().killTopologyWithOpts(topologyName, options);
        }
        System.out.println("Successfully submit command kill " + 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) NimbusClient(backtype.storm.utils.NimbusClient) KillOptions(backtype.storm.generated.KillOptions) Map(java.util.Map) InvalidParameterException(java.security.InvalidParameterException)

Example 7 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class list method main.

public static void main(String[] args) {
    NimbusClient client = null;
    try {
        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);
        if (args.length > 0 && !StringUtils.isBlank(args[0])) {
            String topologyName = args[0];
            TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);
            System.out.println("Successfully get topology info \n" + Utils.toPrettyJsonString(info));
        } else {
            ClusterSummary clusterSummary = client.getClient().getClusterInfo();
            System.out.println("Successfully get cluster info \n" + Utils.toPrettyJsonString(clusterSummary));
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
Also used : ClusterSummary(backtype.storm.generated.ClusterSummary) NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) TopologyInfo(backtype.storm.generated.TopologyInfo)

Example 8 with NimbusClient

use of backtype.storm.utils.NimbusClient 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)

Example 9 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class rebalance method submitRebalance.

public static void submitRebalance(String topologyName, RebalanceOptions options, Map conf) throws Exception {
    Map stormConf = Utils.readStormConfig();
    if (conf != null) {
        stormConf.putAll(conf);
    }
    NimbusClient client = null;
    try {
        client = NimbusClient.getConfiguredClient(stormConf);
        client.getClient().rebalance(topologyName, options);
    } catch (Exception e) {
        throw e;
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map)

Example 10 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class ClusterAPIController method topology.

@RequestMapping("/topology/summary")
public Map topology(@PathVariable String clusterName) {
    Map ret = new HashMap<>();
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        List<TopologyEntity> topologies = UIUtils.getTopologyEntities(clusterSummary);
        ret.put("topologies", topologies);
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        ret = UIUtils.exceptionJson(e);
        LOG.error(e.getMessage(), e);
    }
    return ret;
}
Also used : HashMap(java.util.HashMap) NimbusClient(backtype.storm.utils.NimbusClient) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NimbusClient (backtype.storm.utils.NimbusClient)38 Map (java.util.Map)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 HashMap (java.util.HashMap)9 InvalidParameterException (java.security.InvalidParameterException)6 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)4 ModelMap (org.springframework.ui.ModelMap)4 ClusterSummary (backtype.storm.generated.ClusterSummary)3 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)3 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)3 NimbusInfo (backtype.storm.nimbus.NimbusInfo)3 FileNotFoundException (java.io.FileNotFoundException)3 TTransportException (org.apache.thrift.transport.TTransportException)3 KillOptions (backtype.storm.generated.KillOptions)2 MetricInfo (backtype.storm.generated.MetricInfo)2 TopologyInfo (backtype.storm.generated.TopologyInfo)2 UITaskMetric (com.alibaba.jstorm.ui.model.UITaskMetric)2 UIWorkerMetric (com.alibaba.jstorm.ui.model.UIWorkerMetric)2 ChartSeries (com.alibaba.jstorm.ui.model.graph.ChartSeries)2