Search in sources :

Example 6 with TopologyInfo

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

the class gray_upgrade method upgradeTopology.

private static void upgradeTopology(String topologyName, String component, List<String> workers, int workerNum) throws Exception {
    Map conf = Utils.readStormConfig();
    NimbusClient client = NimbusClient.getConfiguredClient(conf);
    try {
        String topologyId = client.getClient().getTopologyId(topologyName);
        Map stormConf = (Map) Utils.from_json(client.getClient().getTopologyConf(topologyId));
        // check if TM is a separate worker
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topologyId);
        for (TaskSummary taskSummary : topologyInfo.get_tasks()) {
            if (!taskSummary.get_status().equalsIgnoreCase("active")) {
                CommandLineUtil.error("Some of the tasks are not in ACTIVE state, cannot perform the upgrade!");
                return;
            }
        }
        if (!ConfigExtension.isTmSingleWorker(stormConf, topologyInfo.get_topology().get_numWorkers())) {
            CommandLineUtil.error("Gray upgrade requires that topology master to be a single worker, " + "cannot perform the upgrade!");
            return;
        }
        client.getClient().grayUpgrade(topologyName, component, workers, workerNum);
        CommandLineUtil.success("Successfully submit command gray_upgrade " + topologyName);
    } catch (Exception ex) {
        CommandLineUtil.error("Failed to perform gray_upgrade: " + ex.getMessage());
        ex.printStackTrace();
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
Also used : TaskSummary(backtype.storm.generated.TaskSummary) NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) TopologyInfo(backtype.storm.generated.TopologyInfo)

Aggregations

TopologyInfo (backtype.storm.generated.TopologyInfo)6 NotAliveException (backtype.storm.generated.NotAliveException)3 NimbusClient (backtype.storm.utils.NimbusClient)3 IOException (java.io.IOException)3 Map (java.util.Map)3 AlreadyAliveException (backtype.storm.generated.AlreadyAliveException)2 InvalidTopologyException (backtype.storm.generated.InvalidTopologyException)2 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)2 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)2 TaskSummary (backtype.storm.generated.TaskSummary)2 TopologyAssignException (backtype.storm.generated.TopologyAssignException)2 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)2 FailedAssignTopologyException (com.alibaba.jstorm.utils.FailedAssignTopologyException)2 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 TException (org.apache.thrift.TException)2 ClusterSummary (backtype.storm.generated.ClusterSummary)1 ComponentSummary (backtype.storm.generated.ComponentSummary)1