public void execute(Tuple input) { if (_exception != null) { throw new RuntimeException(_exception); } //just need an id String genId = Long.toString(_rand.nextLong()); _inputs.put(genId, input); try { BoltMsg boltMsg = createBoltMessage(input, genId); _pendingWrites.putBoltMsg(boltMsg); } catch (InterruptedException e) { // It's likely that Bolt is shutting down so no need to throw RuntimeException // just ignore } }
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { super.prepare(topoConf, context, collector); CountShellMetric cMetric = new CountShellMetric(); context.registerMetric("my-custom-shell-metric", cMetric, 5); }
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; }
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); CountShellMetric cMetric = new CountShellMetric(); context.registerMetric("my-custom-shell-metric", cMetric, 5); }
public void execute(Tuple input) { if (_exception != null) { throw new RuntimeException(_exception); } //just need an id String genId = Long.toString(_rand.nextLong()); _inputs.put(genId, input); try { BoltMsg boltMsg = createBoltMessage(input, genId); _pendingWrites.putBoltMsg(boltMsg); } catch(InterruptedException e) { // It's likely that Bolt is shutting down so no need to throw RuntimeException // just ignore } }