private void execAggregatorAndStoreResult(int currentTriggerId, List<T> tupleEvents) { List<TridentTuple> resultTuples = getTridentTuples(tupleEvents); // run aggregator to compute the result AccumulatedTuplesCollector collector = new AccumulatedTuplesCollector(delegateCollector); Object state = aggregator.init(currentTriggerId, collector); for (TridentTuple resultTuple : resultTuples) { aggregator.aggregate(state, resultTuple, collector); } aggregator.complete(state, collector); List<List<Object>> resultantAggregatedValue = collector.values; ArrayList<WindowsStore.Entry> entries = Lists.newArrayList(new WindowsStore.Entry(windowTriggerCountId, currentTriggerId + 1), new WindowsStore.Entry(WindowTridentProcessor .generateWindowTriggerKey(windowTaskId, currentTriggerId), resultantAggregatedValue)); windowStore.putAll(entries); pendingTriggers.add(new TriggerResult(currentTriggerId, resultantAggregatedValue)); }
@Override public void prepare() { preInitialize(); initialize(); postInitialize(); }
public Entry(String key, Object value) { nonNullCheckForKey(key); nonNullCheckForValue(value); this.key = key; this.value = value; }
private void _remove(String key) { Object oldValue = store.remove(key); if (oldValue != null) { decrementSize(); if (backingStore != null) { backingStore.remove(key); } } }
private void _put(String key, Object value) { if (!canAdd()) { return; } store.put(key, value); incrementCurrentSize(); }
@Override public WindowsStore create(Map<String, Object> topoConf) { if (inMemoryWindowsStore == null) { inMemoryWindowsStore = new InMemoryWindowsStore(); } return inMemoryWindowsStore; } }
@Override public void cleanup() { windowsStore.shutdown(); } }
public String generateTriggerKey() { return generateWindowTriggerKey(windowTaskId, triggerId); }
@Override public State makeState(Map<String, Object> conf, IMetricsContext metrics, int partitionIndex, int numPartitions) { return new WindowsState(); } }
@Override public void prepare(Map<String, Object> conf, TridentOperationContext context) { windowsStore = windowStoreFactory.create(conf); }
public String keyOf(Object batchId) { return windowTupleTaskId + getBatchTxnId(batchId) + WindowsStore.KEY_SEPARATOR; }
@Override public Object get(String key) { Object value = store.get(key); if (value == null && backingStore != null) { value = backingStore.get(key); } return value; }
@Override public void cleanup() { LOG.info("shutting down window manager"); try { tridentWindowManager.shutdown(); } catch (Exception ex) { LOG.error("Error occurred while cleaning up window processor", ex); throw ex; } }
@Override protected WindowKryoSerializer initialValue() { return new WindowKryoSerializer(topoConf); } };
@Override public void shutdown() { store.clear(); if (backingStore != null) { backingStore.shutdown(); } }
public String triggerKey(int triggerId) { return generateWindowTriggerKey(windowTaskId, triggerId); }