use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class JStormHelper method getSupervisorHosts.
public static List<String> getSupervisorHosts() throws Exception {
try {
List<String> hosts = new ArrayList<>();
NimbusClient client = getNimbusClient(null);
ClusterSummary clusterSummary = client.getClient().getClusterInfo();
List<SupervisorSummary> supervisorSummaries = clusterSummary.get_supervisors();
Collections.sort(supervisorSummaries, new Comparator<SupervisorSummary>() {
@Override
public int compare(SupervisorSummary o1, SupervisorSummary o2) {
int o1Left = o1.get_numWorkers() - o1.get_numUsedWorkers();
int o2Left = o2.get_numWorkers() - o2.get_numUsedWorkers();
return o1Left - o2Left;
}
});
for (SupervisorSummary supervisorSummary : supervisorSummaries) {
hosts.add(supervisorSummary.get_host());
}
return hosts;
} catch (Exception e) {
if (client != null) {
client.close();
client = null;
}
LOG.error("Failed to kill all topologies ", e);
throw new RuntimeException(e);
}
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class blacklist method main.
public static void main(String[] args) {
if (args == null || args.length < 2) {
throw new InvalidParameterException("Please input action and hostname");
}
String action = args[0];
String hostname = args[1];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
if (action.equals("add"))
client.getClient().setHostInBlackList(hostname);
else {
client.getClient().removeHostOutBlackList(hostname);
}
System.out.println("Successfully submit command blacklist with action:" + action + " and hostname :" + hostname);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
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();
}
}
}
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();
}
}
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class activate 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);
client.getClient().activate(topologyName);
System.out.println("Successfully submit command activate " + topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
Aggregations