• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ITaskHook类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:twitter,项目名称:heron,代码行数:12,代码来源:TopologyContext.java


示例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);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:8,代码来源:TopologyContext.java


示例3: addTaskHook

import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public void addTaskHook(ITaskHook hook) {
	hook.prepare(_stormConf, this);
	_hooks.add(hook);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:5,代码来源:TopologyContext.java


示例4: getHooks

import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public Collection<ITaskHook> getHooks() {
	return _hooks;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:4,代码来源:TopologyContext.java


示例5: addTaskHook

import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public void addTaskHook(ITaskHook hook) {
    hook.prepare(_stormConf, this);
    _hooks.add(hook);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:5,代码来源:TopologyContext.java


示例6: getHooks

import backtype.storm.hooks.ITaskHook; //导入依赖的package包/类
public Collection<ITaskHook> getHooks() {
    return _hooks;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:4,代码来源:TopologyContext.java


示例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);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:47,代码来源:TaskShutdownDameon.java


示例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);
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:59,代码来源:Task.java



注:本文中的backtype.storm.hooks.ITaskHook类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WalkingRouteResult类代码示例发布时间:2022-05-22
下一篇:
Java AppList类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap