Java Code Examples for io.siddhi.query.api.annotation.Annotation#getElement()

The following examples show how to use io.siddhi.query.api.annotation.Annotation#getElement() . 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: DefinitionParserHelper.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private static Annotation updateAnnotationRef(Annotation annotation, String type,
                                              SiddhiAppContext siddhiAppContext) {
    String ref = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_REF);
    if (ref != null) {
        Map<String, String> systemConfigs = siddhiAppContext.getSiddhiContext().getConfigManager()
                .extractSystemConfigs(ref);

        if (systemConfigs.size() == 0) {
            throw new SiddhiAppCreationException("The " + type + " element of the name '" + ref +
                    "' is not defined in the configurations file.",
                    annotation.getQueryContextStartIndex(),
                    annotation.getQueryContextEndIndex());
        } else {
            HashMap<String, String> newSystemConfig = new HashMap<>(systemConfigs);

            Map<String, String> collection = annotation.getElements().stream()
                    .collect(Collectors.toMap(Element::getKey, Element::getValue));
            collection.remove(SiddhiConstants.ANNOTATION_ELEMENT_REF);
            newSystemConfig.putAll(collection);

            List<Element> annotationElements = newSystemConfig.entrySet().stream()
                    .map((property) -> new Element(
                            property.getKey(),
                            property.getValue()))
                    .collect(Collectors.toList());

            annotation.setElements(annotationElements);
        }
    }
    return annotation;
}
 
Example 2
Source File: StreamJunction.java    From siddhi with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example 3
Source File: IncrementalDataPurger.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public void init(AggregationDefinition aggregationDefinition, StreamEventFactory streamEventFactory,
                 Map<TimePeriod.Duration, Table> aggregationTables, Boolean isProcessingOnExternalTime,
                 SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    this.aggregationDefinition = aggregationDefinition;
    List<Annotation> annotations = aggregationDefinition.getAnnotations();
    this.streamEventFactory = streamEventFactory;
    this.aggregationTables = aggregationTables;
    if (isProcessingOnExternalTime) {
        purgingTimestampField = AGG_EXTERNAL_TIMESTAMP_COL;
    } else {
        purgingTimestampField = AGG_START_TIMESTAMP_COL;
    }
    aggregatedTimestampAttribute = new Attribute(purgingTimestampField, Attribute.Type.LONG);

    VariableExpressionExecutor variableExpressionExecutor = new VariableExpressionExecutor(
            aggregatedTimestampAttribute, 0, 1);
    variableExpressionExecutorList.add(variableExpressionExecutor);
    for (Map.Entry<TimePeriod.Duration, Table> entry : aggregationTables.entrySet()) {
        this.tableMap.put(entry.getValue().getTableDefinition().getId(), entry.getValue());
        switch (entry.getKey()) {
            case SECONDS:
                retentionPeriods.put(entry.getKey(), Expression.Time.sec(120).value());
                minimumDurationMap.put(entry.getKey(), Expression.Time.sec(120).value());
                break;
            case MINUTES:
                retentionPeriods.put(entry.getKey(), Expression.Time.hour(24).value());
                minimumDurationMap.put(entry.getKey(), Expression.Time.minute(120).value());
                break;
            case HOURS:
                retentionPeriods.put(entry.getKey(), Expression.Time.day(30).value());
                minimumDurationMap.put(entry.getKey(), Expression.Time.hour(25).value());
                break;
            case DAYS:
                retentionPeriods.put(entry.getKey(), Expression.Time.year(1).value());
                minimumDurationMap.put(entry.getKey(), Expression.Time.day(32).value());
                break;
            case MONTHS:
                retentionPeriods.put(entry.getKey(), RETAIN_ALL);
                minimumDurationMap.put(entry.getKey(), Expression.Time.month(13).value());
                break;
            case YEARS:
                retentionPeriods.put(entry.getKey(), RETAIN_ALL);
                minimumDurationMap.put(entry.getKey(), 0L);
        }
    }

    Map<String, Annotation> annotationTypes = new HashMap<>();
    for (Annotation annotation : annotations) {
        annotationTypes.put(annotation.getName().toLowerCase(), annotation);
    }
    Annotation purge = annotationTypes.get(SiddhiConstants.NAMESPACE_PURGE);
    if (purge != null) {
        if (purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_ENABLE) != null) {
            String purgeEnable = purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_ENABLE);
            if (!("true".equalsIgnoreCase(purgeEnable) || "false".equalsIgnoreCase(purgeEnable))) {
                throw new SiddhiAppCreationException("Invalid value for enable: " + purgeEnable + "." +
                        " Please use true or false");
            } else {
                purgingEnabled = Boolean.parseBoolean(purgeEnable);
            }
        }
        if (purgingEnabled) {
            // If interval is defined, default value of 15 min will be replaced by user input value
            if (purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_INTERVAL) != null) {
                String interval = purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_INTERVAL);
                purgeExecutionInterval = timeToLong(interval);
            }
            List<Annotation> retentions = purge.getAnnotations(SiddhiConstants.NAMESPACE_RETENTION_PERIOD);
            if (retentions != null && !retentions.isEmpty()) {
                Annotation retention = retentions.get(0);
                List<Element> elements = retention.getElements();
                for (Element element : elements) {
                    TimePeriod.Duration duration = normalizeDuration(element.getKey());
                    if (!aggregationTables.keySet().contains(duration)) {
                        throw new SiddhiAppCreationException(duration + " granularity cannot be purged since " +
                                "aggregation has not performed in " + duration + " granularity");
                    }
                    if (element.getValue().equalsIgnoreCase(RETAIN_ALL_VALUES)) {
                        retentionPeriods.put(duration, RETAIN_ALL);
                    } else {
                        if (timeToLong(element.getValue()) >= minimumDurationMap.get(duration)) {
                            retentionPeriods.put(duration, timeToLong(element.getValue()));
                        } else {
                            throw new SiddhiAppCreationException(duration + " granularity cannot be purge" +
                                    " with a retention of '" + element.getValue() + "', minimum retention" +
                                    " should be greater  than " + TimeUnit.MILLISECONDS.toMinutes
                                    (minimumDurationMap.get(duration)) + " minutes");
                        }
                    }
                }
            }
        }
    }
    compiledConditionsHolder = createCompileConditions(aggregationTables, tableMap);
}
 
Example 4
Source File: PartitionRuntimeImpl.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public PartitionRuntimeImpl(ConcurrentMap<String, AbstractDefinition> streamDefinitionMap,
                            ConcurrentMap<String, AbstractDefinition> windowDefinitionMap,
                            ConcurrentMap<String, StreamJunction> streamJunctionMap,
                            Partition partition, int partitionIndex, SiddhiAppContext siddhiAppContext) {
    this.siddhiAppContext = siddhiAppContext;
    if (partition.getPartitionTypeMap().isEmpty()) {
        throw new SiddhiAppCreationException("Partition must have at least one partition executor. " +
                "But found none.");
    }
    try {
        Element element = AnnotationHelper.getAnnotationElement("info", "name",
                partition.getAnnotations());
        if (element != null) {
            this.partitionName = element.getValue();
        }
    } catch (DuplicateAnnotationException e) {
        throw new DuplicateAnnotationException(e.getMessageWithOutContext() + " for the same Query " +
                partition.toString(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex(),
                siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString());
    }
    if (partitionName == null) {
        this.partitionName = "partition_" + partitionIndex;
    }

    Annotation purge = AnnotationHelper.getAnnotation(SiddhiConstants.NAMESPACE_PURGE, partition.getAnnotations());
    if (purge != null) {
        if (purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_ENABLE) != null) {
            String purgeEnable = purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_ENABLE);
            if (!("true".equalsIgnoreCase(purgeEnable) || "false".equalsIgnoreCase(purgeEnable))) {
                throw new SiddhiAppCreationException("Invalid value for enable: " + purgeEnable + "." +
                        " Please use 'true' or 'false'");
            } else {
                purgingEnabled = Boolean.parseBoolean(purgeEnable);
            }
        } else {
            throw new SiddhiAppCreationException("Annotation @" + SiddhiConstants.NAMESPACE_PURGE +
                    " is missing element '" + SiddhiConstants.ANNOTATION_ELEMENT_ENABLE + "'");
        }
        if (purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_IDLE_PERIOD) != null) {
            String purgeIdle = purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_IDLE_PERIOD);
            purgeIdlePeriod = Expression.Time.timeToLong(purgeIdle);

        } else {
            throw new SiddhiAppCreationException("Annotation @" + SiddhiConstants.NAMESPACE_PURGE +
                    " is missing element '" + SiddhiConstants.ANNOTATION_ELEMENT_IDLE_PERIOD + "'");
        }

        if (purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_INTERVAL) != null) {
            String interval = purge.getElement(SiddhiConstants.ANNOTATION_ELEMENT_INTERVAL);
            purgeExecutionInterval = Expression.Time.timeToLong(interval);
        }
    }
    this.partition = partition;
    this.streamDefinitionMap = streamDefinitionMap;
    this.windowDefinitionMap = windowDefinitionMap;
    this.streamJunctionMap = streamJunctionMap;

    this.stateHolder = siddhiAppContext.generateStateHolder(partitionName, () -> new PartitionState());
}
 
Example 5
Source File: AbstractQueryableRecordTable.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Override
public void initCache(TableDefinition tableDefinition, SiddhiAppContext siddhiAppContext,
                      StreamEventCloner storeEventCloner, ConfigReader configReader) {
    String[] annotationNames = {ANNOTATION_STORE, ANNOTATION_CACHE};
    Annotation cacheTableAnnotation = getAnnotation(annotationNames, tableDefinition.getAnnotations());
    if (cacheTableAnnotation != null) {
        cacheEnabled = true;
        maxCacheSize = Integer.parseInt(cacheTableAnnotation.getElement(CACHE_TABLE_SIZE));
        TableDefinition cacheTableDefinition = TableDefinition.id(tableDefinition.getId());
        for (Attribute attribute : tableDefinition.getAttributeList()) {
            cacheTableDefinition.attribute(attribute.getName(), attribute.getType());
        }
        for (Annotation annotation : tableDefinition.getAnnotations()) {
            if (!annotation.getName().equalsIgnoreCase("Store")) {
                cacheTableDefinition.annotation(annotation);
            }
        }

        String cachePolicy = cacheTableAnnotation.getElement(ANNOTATION_CACHE_POLICY);

        if (cachePolicy == null || cachePolicy.equalsIgnoreCase("FIFO")) {
            cachePolicy = "FIFO";
            cacheTable = new CacheTableFIFO();
        } else if (cachePolicy.equalsIgnoreCase("LRU")) {
            cacheTable = new CacheTableLRU();
        } else if (cachePolicy.equalsIgnoreCase("LFU")) {
            cacheTable = new CacheTableLFU();
        } else {
            throw new SiddhiAppCreationException(siddhiAppContext.getName() + " : Cache policy can only be one " +
                    "of FIFO, LRU, and LFU but given as " + cachePolicy);
        }

        // check if cache expiry enabled and initialize relevant parameters
        if (cacheTableAnnotation.getElement(ANNOTATION_CACHE_RETENTION_PERIOD) != null) {
            cacheExpiryEnabled = true;
            retentionPeriod = Expression.Time.timeToLong(cacheTableAnnotation.
                    getElement(ANNOTATION_CACHE_RETENTION_PERIOD));
            if (cacheTableAnnotation.getElement(ANNOTATION_CACHE_PURGE_INTERVAL) == null) {
                purgeInterval = retentionPeriod;
            } else {
                purgeInterval = Expression.Time.timeToLong(cacheTableAnnotation.
                        getElement(ANNOTATION_CACHE_PURGE_INTERVAL));
            }
            storeSizeCheckInterval = purgeInterval * 5;
        } else {
            storeSizeCheckInterval = 10000;
        }

        ((CacheTable) cacheTable).initCacheTable(cacheTableDefinition, configReader, siddhiAppContext,
                recordTableHandler, cacheExpiryEnabled, maxCacheSize, cachePolicy);

        // creating objects needed to load cache
        SiddhiQueryContext siddhiQueryContext = new SiddhiQueryContext(siddhiAppContext,
                CACHE_QUERY_NAME + tableDefinition.getId());
        MatchingMetaInfoHolder matchingMetaInfoHolder =
                generateMatchingMetaInfoHolderForCacheTable(tableDefinition);
        OnDemandQuery onDemandQuery = OnDemandQuery.query().
                from(
                        InputStore.store(tableDefinition.getId())).
                select(
                        Selector.selector().
                                limit(Expression.value((maxCacheSize + 1)))
                );
        List<VariableExpressionExecutor> variableExpressionExecutors = new ArrayList<>();

        compiledConditionForCaching = compileCondition(Expression.value(true), matchingMetaInfoHolder,
                variableExpressionExecutors, tableMap, siddhiQueryContext);
        List<Attribute> expectedOutputAttributes = buildExpectedOutputAttributes(onDemandQuery,
                tableMap, SiddhiConstants.UNKNOWN_STATE, matchingMetaInfoHolder, siddhiQueryContext);

        compiledSelectionForCaching = compileSelection(onDemandQuery.getSelector(), expectedOutputAttributes,
                matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);

        outputAttributesForCaching = expectedOutputAttributes.toArray(new Attribute[0]);
        QueryParserHelper.reduceMetaComplexEvent(matchingMetaInfoHolder.getMetaStateEvent());
        QueryParserHelper.updateVariablePosition(matchingMetaInfoHolder.getMetaStateEvent(),
                variableExpressionExecutors);
        compiledSelectionForSelectAll = generateCSForSelectAll();
    }
}
 
Example 6
Source File: DefinitionParserHelper.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public static void addTable(TableDefinition tableDefinition, ConcurrentMap<String, Table> tableMap,
                            SiddhiAppContext siddhiAppContext) {

    if (!tableMap.containsKey(tableDefinition.getId())) {

        MetaStreamEvent tableMetaStreamEvent = new MetaStreamEvent();
        tableMetaStreamEvent.addInputDefinition(tableDefinition);
        for (Attribute attribute : tableDefinition.getAttributeList()) {
            tableMetaStreamEvent.addOutputData(attribute);
        }

        StreamEventFactory tableStreamEventFactory = new StreamEventFactory(tableMetaStreamEvent);
        StreamEventCloner tableStreamEventCloner = new StreamEventCloner(tableMetaStreamEvent,
                tableStreamEventFactory);

        Annotation annotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_STORE,
                tableDefinition.getAnnotations());

        Table table;
        ConfigReader configReader = null;
        RecordTableHandlerManager recordTableHandlerManager = null;
        RecordTableHandler recordTableHandler = null;
        if (annotation != null) {
            annotation = updateAnnotationRef(annotation, SiddhiConstants.NAMESPACE_STORE, siddhiAppContext);
            String tableType = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
            if (tableType == null) {
                throw new SiddhiAppCreationException(
                        "Attribute 'type' does not exist for annotation '" + annotation + "'",
                        annotation, siddhiAppContext);
            }
            Extension extension = new Extension() {
                @Override
                public String getNamespace() {
                    return SiddhiConstants.NAMESPACE_STORE;
                }

                @Override
                public String getName() {
                    return tableType;
                }
            };
            recordTableHandlerManager = siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
            if (recordTableHandlerManager != null) {
                recordTableHandler = recordTableHandlerManager.generateRecordTableHandler();
            }
            table = (Table) SiddhiClassLoader.loadExtensionImplementation(extension,
                    TableExtensionHolder.getInstance(siddhiAppContext));
            configReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                    .generateConfigReader(extension.getNamespace(), extension.getName());
        } else {
            table = new InMemoryTable();
        }
        table.initTable(tableDefinition, tableStreamEventFactory, tableStreamEventCloner, configReader,
                siddhiAppContext, recordTableHandler);
        if (recordTableHandler != null) {
            recordTableHandlerManager.registerRecordTableHandler(recordTableHandler.getId(),
                    recordTableHandler);
        }
        tableMap.putIfAbsent(tableDefinition.getId(), table);
    }
}
 
Example 7
Source File: DefinitionParserHelper.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public static void addEventSource(StreamDefinition streamDefinition,
                                  ConcurrentMap<String, List<Source>> eventSourceMap,
                                  SiddhiAppContext siddhiAppContext) {
    for (Annotation sourceAnnotation : streamDefinition.getAnnotations()) {
        if (SiddhiConstants.ANNOTATION_SOURCE.equalsIgnoreCase(sourceAnnotation.getName())) {
            try {
                sourceAnnotation = updateAnnotationRef(sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE,
                        siddhiAppContext);
                Annotation mapAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_MAP,
                        sourceAnnotation.getAnnotations());
                if (mapAnnotation == null) {
                    mapAnnotation = Annotation.annotation(SiddhiConstants.ANNOTATION_MAP).element(SiddhiConstants
                            .ANNOTATION_ELEMENT_TYPE, "passThrough");
                }
                final String sourceType = sourceAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
                if (sourceType == null) {
                    throw new SiddhiAppCreationException(
                            "Attribute 'type' does not exist for annotation '" + sourceAnnotation + "'",
                            sourceAnnotation, siddhiAppContext);
                }
                final String mapType = mapAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
                if (mapType == null) {
                    throw new SiddhiAppCreationException(
                            "Attribute 'type' does not exist for annotation '" + mapAnnotation + "'",
                            mapAnnotation, siddhiAppContext);
                }

                SourceHandlerManager sourceHandlerManager = siddhiAppContext.getSiddhiContext().
                        getSourceHandlerManager();
                SourceHandler sourceHandler = null;
                if (sourceHandlerManager != null) {
                    sourceHandler = sourceHandlerManager.generateSourceHandler(sourceType);
                }
                // load input transport extension
                Extension sourceExtension = constructExtension(streamDefinition, SiddhiConstants.ANNOTATION_SOURCE,
                        sourceType, sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE);
                Source source = (Source) SiddhiClassLoader.loadExtensionImplementation(sourceExtension,
                        SourceExecutorExtensionHolder.getInstance(siddhiAppContext));
                ConfigReader configReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                        .generateConfigReader(sourceExtension.getNamespace(), sourceExtension.getName());

                // load input mapper extension
                Extension mapperExtension = constructExtension(streamDefinition, SiddhiConstants.ANNOTATION_MAP,
                        mapType, sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE_MAPPER);
                SourceMapper sourceMapper = (SourceMapper) SiddhiClassLoader.loadExtensionImplementation(
                        mapperExtension, SourceMapperExecutorExtensionHolder.getInstance(siddhiAppContext));
                ConfigReader mapperConfigReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                        .generateConfigReader(mapperExtension.getNamespace(), mapperExtension.getName());
                validateSourceMapperCompatibility(streamDefinition, sourceType, mapType, source, sourceMapper,
                        sourceAnnotation);

                io.siddhi.annotation.Extension sourceExt =
                        source.getClass().getAnnotation(io.siddhi.annotation.Extension.class);
                OptionHolder sourceOptionHolder = constructOptionHolder(streamDefinition, sourceAnnotation,
                        sourceExt, null, true);
                Map<String, String> deploymentProperties = createDeploymentProperties(sourceAnnotation, sourceExt);
                OptionHolder mapOptionHolder = constructOptionHolder(streamDefinition, mapAnnotation,
                        sourceMapper.getClass().getAnnotation(io.siddhi.annotation.Extension.class),
                        null, false);

                AttributesHolder attributesHolder = getAttributeMappings(mapAnnotation, mapType, streamDefinition);
                String[] transportPropertyNames = getTransportPropertyNames(attributesHolder);
                source.init(sourceType, sourceOptionHolder, sourceMapper, transportPropertyNames,
                        configReader, mapType, mapOptionHolder, attributesHolder.payloadMappings,
                        attributesHolder.transportMappings, mapperConfigReader, sourceHandler, streamDefinition,
                        deploymentProperties, siddhiAppContext);
                if (sourceHandlerManager != null) {
                    sourceHandlerManager.registerSourceHandler(sourceHandler.getId(), sourceHandler);
                }
                List<Source> eventSources = eventSourceMap.get(streamDefinition.getId());
                if (eventSources == null) {
                    eventSources = new ArrayList<>();
                    eventSources.add(source);
                    eventSourceMap.put(streamDefinition.getId(), eventSources);
                } else {
                    eventSources.add(source);
                }
            } catch (Throwable t) {
                ExceptionUtil.populateQueryContext(t, sourceAnnotation, siddhiAppContext);
                throw t;
            }
        }
    }
}