MCPcopy Create free account
hub / github.com/apache/storm / prepare

Method prepare

storm-client/src/jvm/org/apache/storm/task/ShellBolt.java:128–174  ·  view source on GitHub ↗
(Map<String, Object> topoConf, TopologyContext context,
                        final OutputCollector collector)

Source from the content-addressed store, hash-verified

126 }
127
128 @Override
129 public void prepare(Map<String, Object> topoConf, TopologyContext context,
130 final OutputCollector collector) {
131 if (ConfigUtils.isLocalMode(topoConf)) {
132 isLocalMode = true;
133 }
134 Object maxPending = topoConf.get(Config.TOPOLOGY_SHELLBOLT_MAX_PENDING);
135 if (maxPending != null) {
136 this.pendingWrites = new ShellBoltMessageQueue(((Number) maxPending).intValue());
137 }
138
139 rand = new Random();
140 this.collector = collector;
141
142 this.context = context;
143
144 if (topoConf.containsKey(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)) {
145 workerTimeoutMills = 1000 * ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS));
146 } else {
147 workerTimeoutMills = 1000 * ObjectReader.getInt(topoConf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS));
148 }
149
150 process = new ShellProcess(command);
151 if (!env.isEmpty()) {
152 process.setEnv(env);
153 }
154
155 //subprocesses must send their pid first thing
156 Number subpid = process.launch(topoConf, context, changeDirectory);
157 LOG.info("Launched subprocess with pid " + subpid);
158
159 logHandler = ShellUtils.getLogHandler(topoConf);
160 logHandler.setUpContext(ShellBolt.class, process, this.context);
161
162 // reader
163 readerThread = new Thread(new BoltReaderRunnable());
164 readerThread.start();
165
166 writerThread = new Thread(new BoltWriterRunnable());
167 writerThread.start();
168
169 LOG.info("Start checking heartbeat...");
170 setHeartbeat();
171
172 heartBeatExecutorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
173 heartBeatExecutorService.scheduleAtFixedRate(new BoltHeartbeatTimerTask(this), 1, 1, TimeUnit.SECONDS);
174 }
175
176 @Override
177 public void execute(Tuple input) {

Callers

nothing calls this directly

Calls 11

isLocalModeMethod · 0.95
getIntMethod · 0.95
getLogHandlerMethod · 0.95
setHeartbeatMethod · 0.95
getMethod · 0.65
setUpContextMethod · 0.65
startMethod · 0.65
containsKeyMethod · 0.45
isEmptyMethod · 0.45
setEnvMethod · 0.45
launchMethod · 0.45

Tested by

no test coverage detected