Search in sources :

Example 1 with StandaloneSupervisor

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);
    }
}
Also used : Supervisor(org.apache.storm.daemon.supervisor.Supervisor) StandaloneSupervisor(org.apache.storm.daemon.supervisor.StandaloneSupervisor) StandaloneSupervisor(org.apache.storm.daemon.supervisor.StandaloneSupervisor) File(java.io.File)

Example 2 with StandaloneSupervisor

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;
}
Also used : Supervisor(org.apache.storm.daemon.supervisor.Supervisor) ISupervisor(org.apache.storm.scheduler.ISupervisor) StandaloneSupervisor(org.apache.storm.daemon.supervisor.StandaloneSupervisor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TmpPath(org.apache.storm.testing.TmpPath) ArrayList(java.util.ArrayList) StandaloneSupervisor(org.apache.storm.daemon.supervisor.StandaloneSupervisor) ISupervisor(org.apache.storm.scheduler.ISupervisor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

StandaloneSupervisor (org.apache.storm.daemon.supervisor.StandaloneSupervisor)2 Supervisor (org.apache.storm.daemon.supervisor.Supervisor)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ISupervisor (org.apache.storm.scheduler.ISupervisor)1 TmpPath (org.apache.storm.testing.TmpPath)1