/** * A null config will throw IllegalArgumentException. */ @Test(expected = IllegalArgumentException.class) public void getLogHandler_nullConf() { ShellUtils.getLogHandler(null); }
public void open(Map<String, Object> topoConf, TopologyContext context, SpoutOutputCollector collector) { _collector = collector; _context = context; if (topoConf.containsKey(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)) { workerTimeoutMills = 1000 * ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)); } else { workerTimeoutMills = 1000 * ObjectReader.getInt(topoConf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS)); } _process = new ShellProcess(_command); if (!env.isEmpty()) { _process.setEnv(env); } Number subpid = _process.launch(topoConf, context, changeDirectory); LOG.info("Launched subprocess with pid " + subpid); _logHandler = ShellUtils.getLogHandler(topoConf); _logHandler.setUpContext(ShellSpout.class, _process, _context); heartBeatExecutorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1)); }
/** * If a log handler is not configured, {@link DefaultShellLogHandler} * will be returned. */ @Test public void getLogHandler_notConfigured() { ShellLogHandler logHandler = ShellUtils.getLogHandler(new HashMap<String, Object>()); assertTrue(logHandler.getClass() == DefaultShellLogHandler.class); }
LOG.info("Launched subprocess with pid " + subpid); _logHandler = ShellUtils.getLogHandler(topoConf); _logHandler.setUpContext(ShellBolt.class, _process, _context);
/** * If a log handler is correctly configured, it will be returned. */ @Test public void getLogHandler_customHandler() { Map<String, Object> conf = configureLogHandler("org.apache.storm.utils.ShellUtilsTest$CustomShellLogHandler"); ShellLogHandler logHandler = ShellUtils.getLogHandler(conf); assertTrue(logHandler.getClass() == CustomShellLogHandler.class); }
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); _logHandler = ShellUtils.getLogHandler(stormConf); _logHandler.setUpContext(ShellSpout.class, _process, _context); heartBeatExecutorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1)); }
LOG.info("Launched subprocess with pid " + subpid); _logHandler = ShellUtils.getLogHandler(stormConf); _logHandler.setUpContext(ShellBolt.class, _process, _context);