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();
}
}
}
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 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();
}
}
}
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 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;
}
Aggregations