public java.lang.Object getFieldValue(_Fields field) { switch (field) { case BOLT_OBJECT: return get_bolt_object(); case COMMON: return get_common(); } throw new java.lang.IllegalStateException(); }
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; }
/** * Create a new topology to be tracked. * @param origTopo the original topology. * @param cluster a cluster that should have been launched with tracking enabled. */ public TrackedTopology(StormTopology origTopo, ILocalCluster cluster) { LOG.warn("CLUSTER {} - {}", cluster, cluster.getTrackedId()); this.cluster = cluster; lastSpoutCommit = new AtomicInteger(0); String id = cluster.getTrackedId(); topology = origTopo.deepCopy(); for (Bolt bolt : topology.get_bolts().values()) { IRichBolt obj = (IRichBolt) Thrift.deserializeComponentObject(bolt.get_bolt_object()); bolt.set_bolt_object(Thrift.serializeComponentObject(new BoltTracker(obj, id))); } for (SpoutSpec spout : topology.get_spouts().values()) { IRichSpout obj = (IRichSpout) Thrift.deserializeComponentObject(spout.get_spout_object()); spout.set_spout_object(Thrift.serializeComponentObject(new SpoutTracker(obj, id))); } }
public Object getFieldValue(_Fields field) { switch (field) { case BOLT_OBJECT: return get_bolt_object(); case COMMON: return get_common(); } throw new IllegalStateException(); }
private void addTopologyOutputs(StormTopology stormTopology, String topologyOwner, Map stormConf, AtlasEntity topology, AtlasEntityExtInfo entityExtInfo) { List<AtlasEntity> outputs = new ArrayList<>(); Map<String, Bolt> bolts = stormTopology.get_bolts(); Set<String> boltNames = StormTopologyUtil.getTerminalUserBoltNames(stormTopology); for (String boltName : boltNames) { Serializable instance = Utils.javaDeserialize(bolts.get(boltName).get_bolt_object().get_serialized_java(), Serializable.class); String dsType = instance.getClass().getSimpleName(); AtlasEntity dsEntity = addDataSet(dsType, topologyOwner, instance, stormConf, entityExtInfo); if (dsEntity != null) { outputs.add(dsEntity); } } topology.setAttribute("outputs", AtlasTypeUtil.getAtlasObjectIds(outputs)); }
private AtlasEntity createBoltInstance(String boltName, Bolt stormBolt) { AtlasEntity bolt = new AtlasEntity(StormDataTypes.STORM_BOLT.getName()); Serializable instance = Utils.javaDeserialize(stormBolt.get_bolt_object().get_serialized_java(), Serializable.class); Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null); bolt.setAttribute(AtlasClient.NAME, boltName); bolt.setAttribute("driverClass", instance.getClass().getName()); bolt.setAttribute("conf", flatConfigMap); return bolt; }