org.apache.storm.utils.Utils.getSetComponentObject()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.storm.utils.Utils.getSetComponentObject()方法的一些代码示例,展示了Utils.getSetComponentObject()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getSetComponentObject()方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称:Utils
方法名:getSetComponentObject

Utils.getSetComponentObject介绍

暂无

代码示例

代码示例来源:origin: apache/storm

private Object mkTaskObject() {
  StormTopology topology = systemTopologyContext.getRawTopology();
  Map<String, SpoutSpec> spouts = topology.get_spouts();
  Map<String, Bolt> bolts = topology.get_bolts();
  Map<String, StateSpoutSpec> stateSpouts = topology.get_state_spouts();
  Object result;
  ComponentObject componentObject;
  if (spouts.containsKey(componentId)) {
    componentObject = spouts.get(componentId).get_spout_object();
  } else if (bolts.containsKey(componentId)) {
    componentObject = bolts.get(componentId).get_bolt_object();
  } else if (stateSpouts.containsKey(componentId)) {
    componentObject = stateSpouts.get(componentId).get_state_spout_object();
  } else {
    throw new RuntimeException("Could not find " + componentId + " in " + topology);
  }
  result = Utils.getSetComponentObject(componentObject);
  if (result instanceof ShellComponent) {
    if (spouts.containsKey(componentId)) {
      result = new ShellSpout((ShellComponent) result);
    } else {
      result = new ShellBolt((ShellComponent) result);
    }
  }
  if (result instanceof JavaObject) {
    result = Thrift.instantiateJavaObject((JavaObject) result);
  }
  return result;
}

代码示例来源:origin: org.apache.storm/storm-core

private static String getClassNameFromComponentObject(ComponentObject componentObject) {
  try {
    Object object = Utils.getSetComponentObject(componentObject);
    return object.getClass().getCanonicalName();
  } catch (RuntimeException e) {
    if (e.getCause() instanceof ClassNotFoundException) {
      return e.getCause().getMessage().trim();
    }
    throw e;
  }
}

相关文章

Utils类方法