Search in sources :

Example 1 with ShellBoltMessageQueue

use of org.apache.storm.utils.ShellBoltMessageQueue 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)

Aggregations

ShellBoltMessageQueue (org.apache.storm.utils.ShellBoltMessageQueue)1 ShellProcess (org.apache.storm.utils.ShellProcess)1