use of org.apache.storm.hooks.ITaskHook in project incubator-heron by apache.
the class TopologyContext method addTaskHook.
/*
public void setExecutorData(String name, Object data) {
_executorData.put(name, data);
}
public Object getExecutorData(String name) {
return _executorData.get(name);
}
*/
public void addTaskHook(ITaskHook newHook) {
Collection<com.twitter.heron.api.hooks.ITaskHook> hooks = delegate.getHooks();
if (hooks == null) {
ITaskHookDelegate delegateHook = new ITaskHookDelegate();
delegateHook.addHook(newHook);
delegate.addTaskHook(delegateHook);
} else {
for (com.twitter.heron.api.hooks.ITaskHook hook : hooks) {
if (hook instanceof ITaskHookDelegate) {
ITaskHookDelegate delegateHook = (ITaskHookDelegate) hook;
delegateHook.addHook(newHook);
return;
}
}
throw new RuntimeException("StormCompat taskHooks not setup properly");
}
}
use of org.apache.storm.hooks.ITaskHook in project heron by twitter.
the class TopologyContext method addTaskHook.
/*
public void setExecutorData(String name, Object data) {
_executorData.put(name, data);
}
public Object getExecutorData(String name) {
return _executorData.get(name);
}
*/
public void addTaskHook(ITaskHook newHook) {
Collection<org.apache.heron.api.hooks.ITaskHook> hooks = delegate.getHooks();
if (hooks == null) {
ITaskHookDelegate delegateHook = new ITaskHookDelegate();
delegateHook.addHook(newHook);
delegate.addTaskHook(delegateHook);
} else {
for (org.apache.heron.api.hooks.ITaskHook hook : hooks) {
if (hook instanceof ITaskHookDelegate) {
ITaskHookDelegate delegateHook = (ITaskHookDelegate) hook;
delegateHook.addHook(newHook);
return;
}
}
throw new RuntimeException("StormCompat taskHooks not setup properly");
}
}
use of org.apache.storm.hooks.ITaskHook in project storm by apache.
the class ExecutorShutdown method shutdown.
@Override
public void shutdown() {
try {
LOG.info("Shutting down executor " + executor.getComponentId() + ":" + executor.getExecutorId());
executor.getReceiveQueue().close();
for (Utils.SmartThread t : threads) {
t.interrupt();
}
for (Utils.SmartThread t : threads) {
LOG.debug("Executor " + executor.getComponentId() + ":" + executor.getExecutorId() + " joining thread " + t.getName());
// Don't wait forever.
// This is to avoid the deadlock between the executor thread (t) and the shutdown hook (which invokes Worker::shutdown)
// when it is the executor thread (t) who invokes the shutdown hook. See STORM-3658.
long waitMs = 100;
t.join(waitMs);
if (t.isAlive()) {
LOG.warn("Thread {} is still alive ({} ms after interruption). Stop waiting for it.", t.getName(), waitMs);
}
}
executor.getStats().cleanupStats();
for (Task task : taskDatas) {
if (task == null) {
continue;
}
TopologyContext userContext = task.getUserContext();
for (ITaskHook hook : userContext.getHooks()) {
hook.cleanup();
}
}
executor.getStormClusterState().disconnect();
if (executor.getOpenOrPrepareWasCalled().get()) {
for (Task task : taskDatas) {
if (task == null) {
continue;
}
Object object = task.getTaskObject();
if (object instanceof ISpout) {
((ISpout) object).close();
} else if (object instanceof IBolt) {
((IBolt) object).cleanup();
} else {
LOG.error("unknown component object");
}
}
}
LOG.info("Shut down executor " + executor.getComponentId() + ":" + executor.getExecutorId());
} catch (Exception e) {
throw Utils.wrapInRuntime(e);
}
}
Aggregations