/** * Receives events from the CEP Receiver through Thrift using data bridge and pass through the events * to a downstream component as tupels. * * @param stormDeploymentConfig * @param incomingStreamDefinitions - Incoming Siddhi stream definitions * @param executionPlanName * @param tenantId */ public EventReceiverSpout(DistributedConfiguration stormDeploymentConfig, List<String> incomingStreamDefinitions, String executionPlanName, int tenantId, int heartbeatInterval) { this.incomingStreamDefinitions = new ArrayList<StreamDefinition>(incomingStreamDefinitions.size()); this.stormDeploymentConfig = stormDeploymentConfig; this.executionPlanName = executionPlanName; this.tenantId = tenantId; this.heartbeatInterval = heartbeatInterval; for (String definition : incomingStreamDefinitions) { this.incomingStreamDefinitions.add(SiddhiCompiler.parseStreamDefinition(definition)); } this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + "EventReceiverSpout] "; }
public void addInputStream(String streamDefinition) { StreamDefinition siddhiStreamDefinition = SiddhiCompiler.parseStreamDefinition(streamDefinition); inputStreams.put(siddhiStreamDefinition.getId(), siddhiStreamDefinition); }
public void addOutputStream(String streamDefinition) { StreamDefinition siddhiStreamDefinition = SiddhiCompiler.parseStreamDefinition(streamDefinition); outputStreams.put(siddhiStreamDefinition.getId(), siddhiStreamDefinition); }
/** * Adding stream partitioned fields */ private static void addPartitionFields(OMElement streamsElement, ComponentInfoHolder componentInfoHolder) throws StormQueryConstructionException { Iterator<OMElement> streamIterator = streamsElement.getChildrenWithName(new QName(EventProcessorConstants.STREAM)); while (streamIterator.hasNext()) { OMElement streamElement = streamIterator.next(); OMAttribute partitionAttribute = streamElement.getAttribute(new QName("partition")); if (partitionAttribute != null) { StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition(streamElement.getText()); if (!Arrays.asList(streamDefinition.getAttributeNameArray()).contains(partitionAttribute .getAttributeValue())) { throw new StormQueryConstructionException("All input streams of the partition should have the " + "partitioning attribute."); } componentInfoHolder.addStreamPartitioningField(streamDefinition.getId(), partitionAttribute.getAttributeValue()); } } } }
@Override public void declareOutputFields(OutputFieldsDeclarer declarer) { if (siddhiManager == null) { init(); } // Declaring output fields for each exported stream ID for (String outputStreamDefinition : outputStreamDefinitions) { StreamDefinition siddhiOutputDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); if (outputStreamDefinition == null) { throw new RuntimeException(logPrefix + "Cannot find exported stream : " + siddhiOutputDefinition.getId()); } List<String> list = new ArrayList<String>(); list.add(0,"_timestamp"); for (Attribute attribute : siddhiOutputDefinition.getAttributeList()) { list.add(attribute.getName()); } Fields fields = new Fields(list); declarer.declareStream(siddhiOutputDefinition.getId(), fields); log.info(logPrefix + "Declaring output field for stream :" + siddhiOutputDefinition.getId()); } } }
final StreamDefinition outputSiddhiDefinition = SiddhiCompiler.parseStreamDefinition (outputStreamDefinition); log.info(logPrefix + "Adding callback for stream:" + outputSiddhiDefinition.getId()); StreamDefinition siddhiDefinition; for (String outputStreamDefinition : outputStreamDefinitions) { siddhiDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); streamIdToDefinitionMap.put(siddhiDefinition.getId(), siddhiDefinition);
List<String> exportedStreamIds = new ArrayList<String>(exportedStreams.size()); for (String definitionString : exportedStreams) { StreamDefinition definition = SiddhiCompiler.parseStreamDefinition(definitionString); exportedStreamIds.add(definition.getId());
final StreamDefinition outputSiddhiDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); if (log.isDebugEnabled()) { log.debug(logPrefix + " Adding callback for stream: " + outputSiddhiDefinition.getId());