Search in sources :

Example 1 with ShellProcess

use of org.apache.storm.utils.ShellProcess in project storm by apache.

the class ShellBolt method prepare.

public void prepare(Map stormConf, TopologyContext context, final OutputCollector collector) {
    if (ConfigUtils.isLocalMode(stormConf)) {
        _isLocalMode = true;
    }
    Object maxPending = stormConf.get(Config.TOPOLOGY_SHELLBOLT_MAX_PENDING);
    if (maxPending != null) {
        this._pendingWrites = new ShellBoltMessageQueue(((Number) maxPending).intValue());
    }
    _rand = new Random();
    _collector = collector;
    _context = context;
    if (stormConf.containsKey(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)) {
        workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS));
    } else {
        workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS));
    }
    _process = new ShellProcess(_command);
    if (!env.isEmpty()) {
        _process.setEnv(env);
    }
    //subprocesses must send their pid first thing
    Number subpid = _process.launch(stormConf, context, changeDirectory);
    LOG.info("Launched subprocess with pid " + subpid);
    // reader
    _readerThread = new Thread(new BoltReaderRunnable());
    _readerThread.start();
    _writerThread = new Thread(new BoltWriterRunnable());
    _writerThread.start();
    LOG.info("Start checking heartbeat...");
    setHeartbeat();
    heartBeatExecutorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
    heartBeatExecutorService.scheduleAtFixedRate(new BoltHeartbeatTimerTask(this), 1, 1, TimeUnit.SECONDS);
}
Also used : ShellProcess(org.apache.storm.utils.ShellProcess) ShellBoltMessageQueue(org.apache.storm.utils.ShellBoltMessageQueue)

Example 2 with ShellProcess

use of org.apache.storm.utils.ShellProcess in project storm by apache.

the class ShellSpout method open.

public void open(Map stormConf, TopologyContext context, SpoutOutputCollector collector) {
    _collector = collector;
    _context = context;
    if (stormConf.containsKey(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)) {
        workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS));
    } else {
        workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS));
    }
    _process = new ShellProcess(_command);
    if (!env.isEmpty()) {
        _process.setEnv(env);
    }
    Number subpid = _process.launch(stormConf, context, changeDirectory);
    LOG.info("Launched subprocess with pid " + subpid);
    heartBeatExecutorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
}
Also used : ShellProcess(org.apache.storm.utils.ShellProcess) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Aggregations

ShellProcess (org.apache.storm.utils.ShellProcess)2 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ShellBoltMessageQueue (org.apache.storm.utils.ShellBoltMessageQueue)1