use of org.apache.storm.daemon.supervisor.StandaloneSupervisor in project storm by apache.
the class KillWorkers method main.
public static void main(String[] args) throws Exception {
Map<String, Object> conf = ConfigUtils.readStormConfig();
conf.put(Config.STORM_LOCAL_DIR, new File((String) conf.get(Config.STORM_LOCAL_DIR)).getCanonicalPath());
try (Supervisor supervisor = new Supervisor(conf, null, new StandaloneSupervisor())) {
supervisor.shutdownAllWorkers(null, null);
}
}
use of org.apache.storm.daemon.supervisor.StandaloneSupervisor in project storm by apache.
the class LocalCluster method addSupervisor.
/**
* Add another supervisor to the topology. This is intended mostly for internal testing.
* @param ports the number of ports/slots the supervisor should have
* @param conf any config values that should be added/over written in the daemon conf of the cluster.
* @param id the id of the new supervisor, so you can find it later.
*/
public synchronized Supervisor addSupervisor(Number ports, Map<String, Object> conf, String id) throws Exception {
if (ports == null) {
ports = 2;
}
TmpPath tmpDir = new TmpPath();
tmpDirs.add(tmpDir);
List<Integer> portNumbers = new ArrayList<>(ports.intValue());
for (int i = 0; i < ports.intValue(); i++) {
portNumbers.add(portCounter.getAndIncrement());
}
Map<String, Object> superConf = new HashMap<>(daemonConf);
if (conf != null) {
superConf.putAll(conf);
}
superConf.put(Config.STORM_LOCAL_DIR, tmpDir.getPath());
superConf.put(Config.SUPERVISOR_SLOTS_PORTS, portNumbers);
final String superId = id == null ? Utils.uuid() : id;
ISupervisor isuper = new StandaloneSupervisor() {
@Override
public String generateSupervisorId() {
return superId;
}
};
if (!ConfigUtils.isLocalMode(superConf)) {
throw new IllegalArgumentException("Cannot start server in distrubuted mode!");
}
Supervisor s = new Supervisor(superConf, sharedContext, isuper);
s.launch();
supervisors.add(s);
return s;
}
Aggregations