public static void main(String[] args) { // o o o o o o o o o o // 0 1 2 3 4 5 6 7 8 9 TumblingCountWindows<Tuple> slideCountAssigner = TumblingCountWindows.create(3); for (int i = 0; i < 10; i++) { System.out.println("i=" + i); Collection<TimeWindow> windows = slideCountAssigner.assignWindows(new TupleImpl(), 0); for (TimeWindow window : windows) { System.out.println(window); } System.out.println(); } } }
public static void main(String[] args) { // o o o o o o o o o o // 0 1 2 3 4 5 6 7 8 9 SlidingCountWindows<Tuple> slideCountAssigner = SlidingCountWindows.create(3, 1); for (int i = 0; i < 10; i++) { System.out.println("i=" + i); Collection<TimeWindow> windows = slideCountAssigner.assignWindows(new TupleImpl(), 0); for (TimeWindow window : windows) { System.out.println(window); } System.out.println(); } } }
@Override public void execute(com.twitter.heron.api.tuple.Tuple tuple) { TupleImpl impl = new TupleImpl(tuple); delegate.execute(impl); }
public BoltAckInfo(com.twitter.heron.api.hooks.info.BoltAckInfo info) { this.tuple = new backtype.storm.tuple.TupleImpl(info.getTuple()); this.ackingTaskId = info.getAckingTaskId(); this.processLatencyMs = info.getProcessLatency().toMillis(); } }
public BoltFailInfo(com.twitter.heron.api.hooks.info.BoltFailInfo info) { this.tuple = new backtype.storm.tuple.TupleImpl(info.getTuple()); this.failingTaskId = info.getFailingTaskId(); this.failLatencyMs = info.getFailLatency().toMillis(); } }
public BoltExecuteInfo(com.twitter.heron.api.hooks.info.BoltExecuteInfo info) { this.tuple = new backtype.storm.tuple.TupleImpl(info.getTuple()); this.executingTaskId = info.getExecutingTaskId(); this.executeLatencyMs = info.getExecuteLatency().toMillis(); } }
public Tuple deserialize(byte[] ser) { try { _kryoInput.setBuffer(ser); int taskId = _kryoInput.readInt(true); int streamId = _kryoInput.readInt(true); String componentName = _context.getComponentId(taskId); String streamName = _ids.getStreamName(componentName, streamId); MessageId id = MessageId.deserialize(_kryoInput); List<Object> values = _kryo.deserializeFrom(_kryoInput); return new TupleImpl(_context, values, taskId, streamName, id); } catch(IOException e) { throw new RuntimeException(e); } } }
private void sendData(AlertBolt alertBolt, Map<String, StreamDefinition> definitionMap, PolicyDefinition policyDefinition) { StreamDefinition definition = definitionMap.get("perfmon_latency_stream"); long base = System.currentTimeMillis(); for (int i = 0; i < 2; i++) { long time = base + i * 1000; Map<String, Object> mapdata = new HashMap<>(); mapdata.put("host", "host-1"); mapdata.put("timestamp", time); mapdata.put("metric", "perfmon_latency"); mapdata.put("pool", "raptor"); mapdata.put("value", 1000.0 + i * 1000.0); mapdata.put("colo", "phx"); StreamEvent event = StreamEvent.builder().timestamep(time).attributes(mapdata, definition).build(); PartitionedEvent pEvent = new PartitionedEvent(event, policyDefinition.getPartitionSpec().get(0), 1); GeneralTopologyContext mock = Mockito.mock(GeneralTopologyContext.class); Mockito.when(mock.getComponentId(1)).thenReturn("taskId"); Mockito.when(mock.getComponentOutputFields("taskId", "test-stream-id")).thenReturn(new Fields(AlertConstants.FIELD_0)); TupleImpl ti = new TupleImpl(mock, Collections.singletonList(pEvent), 1, "test-stream-id"); alertBolt.execute(ti); } }
private Tuple createTuple(AlertBolt bolt, String version) throws IOException { GeneralTopologyContext context = mock(GeneralTopologyContext.class); int taskId = 1; when(context.getComponentId(taskId)).thenReturn("comp1"); when(context.getComponentOutputFields("comp1", TEST_STREAM)).thenReturn(new Fields("f0")); // case 1: bolt prepared but metadata not initialized (no bolt.onAlertBoltSpecChange) PartitionedEvent pe = new PartitionedEvent(); pe.setPartitionKey(1); pe.setPartition(createPartition()); StreamEvent streamEvent = new StreamEvent(); streamEvent.setStreamId(TEST_STREAM); streamEvent.setTimestamp(System.currentTimeMillis()); streamEvent.setMetaVersion(version); pe.setEvent(streamEvent); PartitionedEventSerializerImpl peSer = new PartitionedEventSerializerImpl(bolt); byte[] serializedEvent = peSer.serialize(pe); return new TupleImpl(context, Collections.singletonList(serializedEvent), taskId, TEST_STREAM); }
Tuple input = new TupleImpl(context, Collections.singletonList(serializedEvent), taskId, "default"); bolt.execute(input);
PartitionedEvent partitionedEvent2 = new PartitionedEvent(event2, sp, 1001); Tuple input = new TupleImpl(context, Collections.singletonList(partitionedEvent1), taskId, "default"); Tuple input2 = new TupleImpl(context, Collections.singletonList(partitionedEvent2), taskId, "default"); bolt.execute(input); bolt.execute(input2);
pEvent.setEvent(event); pEvent.setPartition(sp); Tuple input = new TupleImpl(context, Collections.singletonList(pEvent), taskId, "default"); routerBolt.execute(input); pEvent.setPartition(sp); pEvent.setEvent(event); input = new TupleImpl(context, Collections.singletonList(pEvent), taskId, "default"); routerBolt.execute(input); pEvent.setPartition(sp); pEvent.setEvent(event); input = new TupleImpl(context, Collections.singletonList(pEvent), taskId, "default"); routerBolt.execute(input); pEvent.setPartition(sp); pEvent.setEvent(event); input = new TupleImpl(context, Collections.singletonList(pEvent), taskId, "default"); routerBolt.execute(input); pEvent.setPartition(sp); pEvent.setEvent(event); input = new TupleImpl(context, Collections.singletonList(pEvent), taskId, "default"); routerBolt.execute(input);