Java Code Examples for io.siddhi.query.api.definition.StreamDefinition#getId()
The following examples show how to use
io.siddhi.query.api.definition.StreamDefinition#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonSinkMapper.java From siddhi-map-json with Apache License 2.0 | 6 votes |
/** * Initialize the mapper and the mapping configurations. * * @param streamDefinition The stream definition * @param optionHolder Option holder containing static and dynamic options * @param payloadTemplateBuilderMap Unmapped list of payloads for reference */ @Override public void init(StreamDefinition streamDefinition, OptionHolder optionHolder, Map<String, TemplateBuilder> payloadTemplateBuilderMap, ConfigReader mapperConfigReader, SiddhiAppContext siddhiAppContext) { this.attributeNameArray = streamDefinition.getAttributeNameArray(); this.enclosingElement = optionHolder.validateAndGetStaticValue(ENCLOSING_ELEMENT_IDENTIFIER, null); this.isJsonValidationEnabled = Boolean.parseBoolean(optionHolder .validateAndGetStaticValue(JSON_VALIDATION_IDENTIFIER, "false")); //if @payload() is added there must be at least 1 element in it, otherwise a SiddhiParserException raised if (payloadTemplateBuilderMap != null && payloadTemplateBuilderMap.size() != 1) { throw new SiddhiAppCreationException("Json sink-mapper does not support multiple @payload mappings, " + "error at the mapper of '" + streamDefinition.getId() + "'"); } if (payloadTemplateBuilderMap != null && payloadTemplateBuilderMap.get(payloadTemplateBuilderMap.keySet().iterator().next()).isObjectMessage()) { throw new SiddhiAppCreationException("Json sink-mapper does not support object @payload mappings, " + "error at the mapper of '" + streamDefinition.getId() + "'"); } }
Example 2
Source File: SiddhiApp.java From siddhi with Apache License 2.0 | 5 votes |
public SiddhiApp defineStream(StreamDefinition streamDefinition) { if (streamDefinition == null) { throw new SiddhiAppValidationException("Stream Definition should not be null"); } else if (streamDefinition.getId() == null) { throw new SiddhiAppValidationException("Stream Id should not be null for Stream Definition", streamDefinition.getQueryContextStartIndex(), streamDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(streamDefinition); this.streamDefinitionMap.put(streamDefinition.getId(), streamDefinition); return this; }
Example 3
Source File: SinkHandler.java From siddhi with Apache License 2.0 | 5 votes |
final void initSinkHandler(String siddhiAppName, StreamDefinition streamDefinition, SinkHandlerCallback sinkHandlerCallback, SiddhiAppContext siddhiAppContext) { this.sinkHandlerCallback = sinkHandlerCallback; StateFactory<S> stateFactory = init(streamDefinition, sinkHandlerCallback); id = siddhiAppName + "-" + streamDefinition.getId() + "-" + this.getClass().getName(); stateHolder = siddhiAppContext.generateStateHolder( streamDefinition.getId() + "-" + this.getClass().getName(), stateFactory); }
Example 4
Source File: LogSink.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<State> init(StreamDefinition outputStreamDefinition, OptionHolder optionHolder, ConfigReader sinkConfigReader, SiddhiAppContext siddhiAppContext) { String defaultPrefix = siddhiAppContext.getName() + " : " + outputStreamDefinition.getId(); logPrefix = optionHolder.validateAndGetStaticValue(PREFIX, defaultPrefix); logPriority = LogPriority.valueOf(optionHolder.validateAndGetStaticValue(PRIORITY, "INFO") .toUpperCase()); return null; }
Example 5
Source File: SourceHandler.java From siddhi with Apache License 2.0 | 5 votes |
final void initSourceHandler(String siddhiAppName, SourceSyncCallback sourceSyncCallback, StreamDefinition streamDefinition, SiddhiAppContext siddhiAppContext) { StateFactory<S> stateFactory = init(siddhiAppName, sourceSyncCallback, streamDefinition, siddhiAppContext); id = siddhiAppName + "-" + streamDefinition.getId() + "-" + this.getClass().getName(); stateHolder = siddhiAppContext.generateStateHolder( streamDefinition.getId() + "-" + this.getClass().getName(), stateFactory); }
Example 6
Source File: PartitionStreamReceiver.java From siddhi with Apache License 2.0 | 5 votes |
public PartitionStreamReceiver(SiddhiAppContext siddhiAppContext, MetaStreamEvent metaStreamEvent, StreamDefinition streamDefinition, List<PartitionExecutor> partitionExecutors, PartitionRuntime partitionRuntime) { this.metaStreamEvent = metaStreamEvent; this.streamDefinition = streamDefinition; this.partitionRuntime = (PartitionRuntimeImpl) partitionRuntime; this.partitionExecutors = partitionExecutors; this.siddhiAppContext = siddhiAppContext; this.streamId = streamDefinition.getId(); this.streamEventFactory = new StreamEventFactory(metaStreamEvent); }
Example 7
Source File: DefinitionParserHelper.java From siddhi with Apache License 2.0 | 5 votes |
private static void validateSourceMapperCompatibility(StreamDefinition streamDefinition, String sourceType, String mapType, Source source, SourceMapper sourceMapper, Annotation sourceAnnotation) { Class[] inputEventClasses = sourceMapper.getSupportedInputEventClasses(); Class[] outputEventClasses = source.getOutputEventClasses(); //skipping validation for unknown output types if (outputEventClasses == null || outputEventClasses.length == 0) { return; } boolean matchingSinkAndMapperClasses = false; for (Class inputEventClass : inputEventClasses) { for (Class outputEventClass : outputEventClasses) { if (inputEventClass.isAssignableFrom(outputEventClass)) { matchingSinkAndMapperClasses = true; break; } } if (matchingSinkAndMapperClasses) { break; } } if (!matchingSinkAndMapperClasses) { throw new SiddhiAppCreationException("At stream '" + streamDefinition.getId() + "', source '" + sourceType + "' produces incompatible '" + Arrays.deepToString(outputEventClasses) + "' classes, while it's source mapper '" + mapType + "' can only consume '" + Arrays.deepToString(inputEventClasses) + "' classes.", sourceAnnotation.getQueryContextStartIndex(), sourceAnnotation.getQueryContextEndIndex()); } }
Example 8
Source File: DefinitionParserHelper.java From siddhi with Apache License 2.0 | 5 votes |
private static void validateSinkMapperCompatibility(StreamDefinition streamDefinition, String sinkType, String mapType, Sink sink, SinkMapper sinkMapper, Annotation sinkAnnotation) { Class[] inputEventClasses = sink.getSupportedInputEventClasses(); Class[] outputEventClasses = sinkMapper.getOutputEventClasses(); //skipping validation for unknown output types if (outputEventClasses == null || outputEventClasses.length == 0) { return; } boolean matchingSinkAndMapperClasses = false; for (Class inputEventClass : inputEventClasses) { for (Class outputEventClass : outputEventClasses) { if (inputEventClass.isAssignableFrom(outputEventClass)) { matchingSinkAndMapperClasses = true; break; } } if (matchingSinkAndMapperClasses) { break; } } if (!matchingSinkAndMapperClasses) { throw new SiddhiAppCreationException("At stream '" + streamDefinition.getId() + "', " + "sink mapper '" + mapType + "' processes '" + Arrays.deepToString(outputEventClasses) + "' classes but it's sink '" + sinkType + "' cannot not consume any of those class, where " + "sink can only consume '" + Arrays.deepToString(inputEventClasses) + "' classes.", sinkAnnotation.getQueryContextStartIndex(), sinkAnnotation.getQueryContextEndIndex()); } }
Example 9
Source File: DefinitionParserHelper.java From siddhi with Apache License 2.0 | 5 votes |
public static Extension constructExtension(StreamDefinition streamDefinition, String typeName, String typeValue, Annotation annotation, String defaultNamespace) { String[] namespaceAndName = typeValue.split(SiddhiConstants.EXTENSION_SEPARATOR); String namespace; String name; if (namespaceAndName.length == 1) { namespace = defaultNamespace; name = namespaceAndName[0]; } else if (namespaceAndName.length == 2) { namespace = namespaceAndName[0]; name = namespaceAndName[1]; } else { throw new SiddhiAppCreationException("Malformed '" + typeName + "' annotation type '" + typeValue + "' " + "provided, for annotation '" + annotation + "' on stream '" + streamDefinition.getId() + "', " + "it should be either '<namespace>:<name>' or '<name>'", annotation.getQueryContextStartIndex(), annotation.getQueryContextEndIndex()); } return new Extension() { @Override public String getNamespace() { return namespace; } @Override public String getName() { return name; } }; }
Example 10
Source File: StreamJunction.java From siddhi with Apache License 2.0 | 4 votes |
public StreamJunction(StreamDefinition streamDefinition, ExecutorService executorService, int bufferSize, StreamJunction faultStreamJunction, SiddhiAppContext siddhiAppContext) { this.streamDefinition = streamDefinition; this.bufferSize = bufferSize; this.batchSize = bufferSize; this.executorService = executorService; this.siddhiAppContext = siddhiAppContext; if (siddhiAppContext.getStatisticsManager() != null) { this.throughputTracker = QueryParserHelper.createThroughputTracker(siddhiAppContext, streamDefinition.getId(), SiddhiConstants.METRIC_INFIX_STREAMS, null); } this.faultStreamJunction = faultStreamJunction; if (faultStreamJunction != null) { StreamDefinition faultStreamDefinition = faultStreamJunction.getStreamDefinition(); StreamEventFactory faultStreamEventFactory = new StreamEventFactory(0, 0, faultStreamDefinition.getAttributeList().size()); faultStreamEventConverter = new FaultStreamEventConverter(faultStreamEventFactory); } try { Annotation asyncAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ASYNC, streamDefinition.getAnnotations()); if (asyncAnnotation != null) { async = true; String bufferSizeString = asyncAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_BUFFER_SIZE); if (bufferSizeString != null) { this.bufferSize = Integer.parseInt(bufferSizeString); } String workersString = asyncAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_WORKERS); if (workersString != null) { this.workers = Integer.parseInt(workersString); if (workers <= 0) { throw new SiddhiAppCreationException("Annotation element '" + SiddhiConstants.ANNOTATION_ELEMENT_WORKERS + "' cannot be negative or zero, " + "but found, '" + workers + "'.", asyncAnnotation.getQueryContextStartIndex(), asyncAnnotation.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString()); } } String batchSizeString = asyncAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_MAX_BATCH_SIZE); if (batchSizeString != null) { this.batchSize = Integer.parseInt(batchSizeString); if (batchSize <= 0) { throw new SiddhiAppCreationException("Annotation element '" + SiddhiConstants.ANNOTATION_ELEMENT_MAX_BATCH_SIZE + "' cannot be negative or zero, " + "but found, '" + batchSize + "'.", asyncAnnotation.getQueryContextStartIndex(), asyncAnnotation.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString()); } } } Annotation onErrorAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ON_ERROR, streamDefinition.getAnnotations()); if (onErrorAnnotation != null) { this.onErrorAction = OnErrorAction.valueOf(onErrorAnnotation .getElement(SiddhiConstants.ANNOTATION_ELEMENT_ACTION).toUpperCase()); } } catch (DuplicateAnnotationException e) { throw new DuplicateAnnotationException(e.getMessageWithOutContext() + " for the same Stream " + streamDefinition.getId(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString()); } isTraceEnabled = log.isTraceEnabled(); }