本文整理汇总了Java中backtype.storm.hooks.ITaskHook类的典型用法代码示例。如果您正苦于以下问题:Java ITaskHook类的具体用法?Java ITaskHook怎么用?Java ITaskHook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITaskHook类属于backtype.storm.hooks包,在下文中一共展示了ITaskHook类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHooks
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public Collection<ITaskHook> getHooks() {
Collection<com.twitter.heron.api.hooks.ITaskHook> hooks = delegate.getHooks();
if (hooks != null) {
for (com.twitter.heron.api.hooks.ITaskHook hook : hooks) {
if (hook instanceof ITaskHookDelegate) {
return ((ITaskHookDelegate) hook).getHooks();
}
}
}
return null;
}
示例2: applyHooks
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public void applyHooks(String methodName, Object object) throws Exception {
for (ITaskHook taskHook : _hooks) {
Class clazz = taskHook.getClass();
Method method = clazz.getDeclaredMethod(methodName, object.getClass());
method.invoke(taskHook, object);
}
}
示例3: addTaskHook
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public void addTaskHook(ITaskHook hook) {
hook.prepare(_stormConf, this);
_hooks.add(hook);
}
示例4: getHooks
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public Collection<ITaskHook> getHooks() {
return _hooks;
}
示例5: addTaskHook
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public void addTaskHook(ITaskHook hook) {
hook.prepare(_stormConf, this);
_hooks.add(hook);
}
示例6: getHooks
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public Collection<ITaskHook> getHooks() {
return _hooks;
}
示例7: shutdown
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
@Override
public void shutdown() {
if (isClosing.compareAndSet(false, true)) {
LOG.info("Begin to shut down task " + topologyId + ":" + taskId);
TopologyContext userContext = task.getUserContext();
for (ITaskHook iTaskHook : userContext.getHooks())
iTaskHook.cleanup();
closeComponent(taskObj);
taskHeartbeatTrigger.updateExecutorStatus(TaskStatus.SHUTDOWN);
// wait 1 sec for executor thread to shutdown to make sure to send shutdown info to TM
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
// all thread will check the taskStatus
// once it has been set to SHUTDOWN, it will quit
taskStatus.setStatus(TaskStatus.SHUTDOWN);
for (AsyncLoopThread thr : allThreads) {
LOG.info("Begin to shutdown " + thr.getThread().getName());
thr.cleanup();
JStormUtils.sleepMs(10);
thr.interrupt();
// try {
// //thr.join();
// thr.getThread().stop(new RuntimeException());
// } catch (Throwable e) {
// }
LOG.info("Successfully shutdown " + thr.getThread().getName());
}
taskHeartbeatTrigger.unregister();
LOG.info("Successfully shutdown task heartbeat trigger for task:{}", taskId);
try {
zkCluster.disconnect();
} catch (Exception e) {
LOG.error("Failed to disconnect zk for task-" + taskId);
}
LOG.info("Successfully shutdown task " + topologyId + ":" + taskId);
}
}
示例8: Task
import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Task(WorkerData workerData, int taskId) throws Exception {
openOrPrepareWasCalled = new Atom(false);
this.workerData = workerData;
this.topologyContext = workerData.getContextMaker().makeTopologyContext(
workerData.getSysTopology(), taskId, openOrPrepareWasCalled);
this.userContext = workerData.getContextMaker().makeTopologyContext(
workerData.getRawTopology(), taskId, openOrPrepareWasCalled);
this.taskId = taskId;
this.componentId = topologyContext.getThisComponentId();
topologyContext.getStormConf().putAll(Common.component_conf(topologyContext, componentId));
this.stormConf = topologyContext.getStormConf();
this.taskStatus = new TaskStatus();
this.innerTaskTransfer = workerData.getInnerTaskTransfer();
this.deserializeQueues = workerData.getDeserializeQueues();
this.controlQueues = workerData.getControlQueues();
this.topologyId = workerData.getTopologyId();
this.context = workerData.getContext();
this.workHalt = workerData.getWorkHalt();
this.zkCluster = workerData.getZkCluster();
this.nodePortToSocket = workerData.getNodePortToSocket();
this.taskToNodePort = workerData.getTaskToNodePort();
// create report error callback,
// in fact it is storm_cluster.report-task-error
ITaskReportErr reportError = new TaskReportError(zkCluster, topologyId, taskId);
// report error and halt worker
reportErrorDie = new TaskReportErrorAndDie(reportError, workHalt);
this.taskStats = new TaskBaseMetric(topologyId, componentId, taskId);
//register auto hook
List<String> listHooks = Config.getTopologyAutoTaskHooks(stormConf);
for (String hook : listHooks) {
ITaskHook iTaskHook = (ITaskHook) Utils.newInstance(hook);
userContext.addTaskHook(iTaskHook);
}
LOG.info("Begin to deserialize taskObj " + componentId + ":" + this.taskId);
try {
WorkerClassLoader.switchThreadContext();
this.taskObj = Common.get_task_object(
topologyContext.getRawTopology(), componentId, WorkerClassLoader.getInstance());
WorkerClassLoader.restoreThreadContext();
} catch (Exception e) {
if (reportErrorDie != null) {
reportErrorDie.report(e);
} else {
throw e;
}
}
isTaskBatchTuple = ConfigExtension.isTaskBatchTuple(stormConf);
LOG.info("Transfer/receive in batch mode :" + isTaskBatchTuple);
LOG.info("Loading task " + componentId + ":" + this.taskId);
}