public static Map<String, NormalizedResourceRequest> getBoltsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, NormalizedResourceRequest> boltResources = new HashMap<>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { NormalizedResourceRequest topologyResources = new NormalizedResourceRequest(bolt.getValue().get_common(), topologyConf, bolt.getKey()); if (LOG.isTraceEnabled()) { LOG.trace("Turned {} into {}", bolt.getValue().get_common().get_json_conf(), topologyResources); } boltResources.put(bolt.getKey(), topologyResources); } } return boltResources; }
public Bolt deepCopy() { return new Bolt(this); }
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(); }
public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case BOLT_OBJECT: if (value == null) { unset_bolt_object(); } else { set_bolt_object((ComponentObject)value); } break; case COMMON: if (value == null) { unset_common(); } else { set_common((ComponentCommon)value); } break; } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case BOLT_OBJECT: return is_set_bolt_object(); case COMMON: return is_set_common(); } throw new java.lang.IllegalStateException(); }
for (Entry<String, StreamInfo> streamEntry : boltEntry.getValue().get_common().get_streams().entrySet()) { String stream = streamEntry.getKey(); StreamInfo info = streamEntry.getValue(); topology.put_to_bolts(Utils.uuid(), new Bolt(Thrift.serializeComponentObject(capturer), Thrift.prepareComponentCommon(captureBoltInputs, new HashMap<>(), null))); return new CapturedTopology<>(topology, capturer);
static Map<String, Map<String, Double>> getBoltsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, Map<String, Double>> boltResources = new HashMap<>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { Map<String, Double> topologyResources = parseResources(bolt.getValue().get_common().get_json_conf()); checkInitialization(topologyResources, bolt.getValue().toString(), topologyConf); boltResources.put(bolt.getKey(), topologyResources); } } return boltResources; }
public void validate() throws org.apache.storm.thrift.TException { // check for required fields if (!is_set_bolt_object()) { throw new org.apache.storm.thrift.protocol.TProtocolException("Required field 'bolt_object' is unset! Struct:" + toString()); } if (!is_set_common()) { throw new org.apache.storm.thrift.protocol.TProtocolException("Required field 'common' is unset! Struct:" + toString()); } // check for sub-struct validity if (common != null) { common.validate(); } }
/** * 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))); } }
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; }
@Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof Bolt) return this.equals((Bolt)that); return false; }
@Test public void testGetComponentCommonWithWorkerHook() { StormTopology stormTopology = genereateStormTopology(true); ComponentCommon componentCommon = ThriftTopologyUtils.getComponentCommon(stormTopology, "bolt-1"); Assert.assertEquals( "We expect to get bolt-1's common", new Bolt().get_common(), componentCommon); }
public static Map<String, Map<String, Double>> getBoltsResources(StormTopology topology, Map topologyConf) { Map<String, Map<String, Double>> boltResources = new HashMap<String, Map<String, Double>>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { Map<String, Double> topology_resources = parseResources(bolt.getValue().get_common().get_json_conf()); checkIntialization(topology_resources, bolt.getValue().toString(), topologyConf); boltResources.put(bolt.getKey(), topology_resources); } } return boltResources; }
public void setFieldValue(_Fields field, Object value) { switch (field) { case BOLT_OBJECT: if (value == null) { unset_bolt_object(); } else { set_bolt_object((ComponentObject)value); } break; case COMMON: if (value == null) { unset_common(); } else { set_common((ComponentCommon)value); } break; } }
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((is_set_bolt_object()) ? 131071 : 524287); if (is_set_bolt_object()) hashCode = hashCode * 8191 + bolt_object.hashCode(); hashCode = hashCode * 8191 + ((is_set_common()) ? 131071 : 524287); if (is_set_common()) hashCode = hashCode * 8191 + common.hashCode(); return hashCode; }
public void validate() throws org.apache.thrift.TException { // check for required fields if (!is_set_bolt_object()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'bolt_object' is unset! Struct:" + toString()); } if (!is_set_common()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'common' is unset! Struct:" + toString()); } // check for sub-struct validity if (common != null) { common.validate(); } }
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)); }