use of org.apache.storm.testing.TmpPath in project storm by apache.
the class LocalCluster method close.
@Override
public synchronized void close() throws Exception {
if (nimbus != null) {
nimbus.shutdown();
}
if (thriftServer != null) {
LOG.info("shutting down thrift server");
try {
thriftServer.stop();
} catch (Exception e) {
LOG.info("failed to stop thrift", e);
}
}
if (state != null) {
state.close();
}
if (getClusterState() != null) {
getClusterState().disconnect();
}
for (Supervisor s : supervisors) {
s.shutdownAllWorkers(null, ReadClusterState.THREAD_DUMP_ON_ERROR);
s.close();
}
ProcessSimulator.killAllProcesses();
if (zookeeper != null) {
LOG.info("Shutting down in process zookeeper");
zookeeper.close();
LOG.info("Done shutting down in process zookeeper");
}
for (TmpPath p : tmpDirs) {
p.close();
}
if (this.trackId != null) {
LOG.warn("Clearing tracked metrics for ID {}", this.trackId);
LocalExecutor.clearTrackId();
RegisteredGlobalState.clearState(this.trackId);
}
if (this.commonInstaller != null) {
this.commonInstaller.close();
}
if (time != null) {
time.close();
}
}
use of org.apache.storm.testing.TmpPath 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