Search in sources :

Example 1 with KillOptions

use of backtype.storm.generated.KillOptions 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("Please 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 2 with KillOptions

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

the class JStormHelper method cleanCluster.

public static void cleanCluster() {
    try {
        NimbusClient client = getNimbusClient(null);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        List<TopologySummary> topologySummaries = clusterSummary.get_topologies();
        KillOptions killOption = new KillOptions();
        killOption.set_wait_secs(1);
        for (TopologySummary topologySummary : topologySummaries) {
            client.getClient().killTopologyWithOpts(topologySummary.get_name(), killOption);
            LOG.info("Successfully kill " + topologySummary.get_name());
        }
    } catch (Exception e) {
        if (client != null) {
            client.close();
            client = null;
        }
        LOG.error("Failed to kill all topology ", e);
    }
}
Also used : ClusterSummary(backtype.storm.generated.ClusterSummary) NimbusClient(backtype.storm.utils.NimbusClient) TopologySummary(backtype.storm.generated.TopologySummary) KillOptions(backtype.storm.generated.KillOptions)

Example 3 with KillOptions

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

the class JStormHelper method killTopology.

public static void killTopology(Map conf, String topologyName) throws Exception {
    NimbusClientWrapper client = new NimbusClientWrapper();
    try {
        Map clusterConf = Utils.readStormConfig();
        clusterConf.putAll(conf);
        client.init(clusterConf);
        KillOptions killOption = new KillOptions();
        killOption.set_wait_secs(1);
        client.getClient().killTopologyWithOpts(topologyName, killOption);
    } finally {
        client.cleanup();
    }
}
Also used : NimbusClientWrapper(backtype.storm.utils.NimbusClientWrapper) KillOptions(backtype.storm.generated.KillOptions) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with KillOptions

use of backtype.storm.generated.KillOptions in project storm-hbase by ypf412.

the class StormTestUtil method killToplogy.

/**
 * Kill Storm test topology
 *
 * @throws Exception
 */
private void killToplogy() {
    KillOptions opt = new KillOptions();
    opt.set_wait_secs(2);
    cluster.killTopologyWithOpts(TEST_TOPO_NAME, opt);
    Utils.sleep(3000);
}
Also used : KillOptions(backtype.storm.generated.KillOptions)

Aggregations

KillOptions (backtype.storm.generated.KillOptions)4 NimbusClient (backtype.storm.utils.NimbusClient)2 Map (java.util.Map)2 ClusterSummary (backtype.storm.generated.ClusterSummary)1 TopologySummary (backtype.storm.generated.TopologySummary)1 NimbusClientWrapper (backtype.storm.utils.NimbusClientWrapper)1 InvalidParameterException (java.security.InvalidParameterException)1 HashMap (java.util.HashMap)1