Java Code Examples for io.siddhi.core.config.SiddhiAppContext#getScheduledExecutorService()

The following examples show how to use io.siddhi.core.config.SiddhiAppContext#getScheduledExecutorService() . 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: Sink.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public final void initOnlyTransport(StreamDefinition streamDefinition, OptionHolder transportOptionHolder,
                                    ConfigReader sinkConfigReader, String type,
                                    DistributedTransport.ConnectionCallback connectionCallback,
                                    Map<String, String> deploymentProperties, SiddhiAppContext siddhiAppContext) {
    this.type = type;
    this.streamDefinition = streamDefinition;
    this.connectionCallback = connectionCallback;
    this.siddhiAppContext = siddhiAppContext;
    init(streamDefinition, transportOptionHolder, sinkConfigReader, siddhiAppContext);
    scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
    serviceDeploymentInfo = exposeServiceDeploymentInfo();
    if (serviceDeploymentInfo != null) {
        serviceDeploymentInfo.addDeploymentProperties(deploymentProperties);
    } else if (!deploymentProperties.isEmpty()) {
        throw new SiddhiAppCreationException("Deployment properties '" + deploymentProperties +
                "' are defined for sink '" + type + "' which does not expose a service");
    }
}
 
Example 2
Source File: Source.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public final void init(String sourceType, OptionHolder transportOptionHolder, SourceMapper sourceMapper,
                       String[] transportPropertyNames, ConfigReader configReader, String mapType,
                       OptionHolder mapOptionHolder, List<AttributeMapping> attributeMappings,
                       List<AttributeMapping> transportMappings, ConfigReader mapperConfigReader,
                       SourceHandler sourceHandler, StreamDefinition streamDefinition,
                       Map<String, String> deploymentProperties, SiddhiAppContext siddhiAppContext) {
    this.type = sourceType;

    sourceMapper.init(streamDefinition, mapType, mapOptionHolder, attributeMappings, sourceType,
            (this instanceof SourceSyncCallback) ? (SourceSyncCallback) this : null, transportMappings,
            sourceHandler, transportOptionHolder, mapperConfigReader, siddhiAppContext);
    this.mapper = sourceMapper;
    this.streamDefinition = streamDefinition;
    this.siddhiAppContext = siddhiAppContext;
    StateFactory<S> stateFactory = init(sourceMapper, transportOptionHolder, transportPropertyNames,
            configReader, siddhiAppContext);
    stateHolder = siddhiAppContext.generateStateHolder(streamDefinition.getId() + "-" +
            this.getClass().getName(), stateFactory);
    scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
    serviceDeploymentInfo = exposeServiceDeploymentInfo();
    if (serviceDeploymentInfo != null) {
        serviceDeploymentInfo.addDeploymentProperties(deploymentProperties);
    } else if (!deploymentProperties.isEmpty()) {
        throw new SiddhiAppCreationException("Deployment properties '" + deploymentProperties +
                "' are defined for source '" + sourceType + "' which does not expose a service");
    }
}
 
Example 3
Source File: Table.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void initTable(TableDefinition tableDefinition, StreamEventFactory storeEventPool,
                      StreamEventCloner storeEventCloner,
                      ConfigReader configReader, SiddhiAppContext siddhiAppContext,
                      RecordTableHandler recordTableHandler) {
    this.tableDefinition = tableDefinition;
    this.scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
    this.siddhiAppContext = siddhiAppContext;
    this.recordTableHandler = recordTableHandler;
    if (siddhiAppContext.getStatisticsManager() != null) {
        latencyTrackerFind = QueryParserHelper.createLatencyTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_FIND);
        latencyTrackerInsert = QueryParserHelper.createLatencyTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_INSERT);
        latencyTrackerUpdate = QueryParserHelper.createLatencyTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_UPDATE);
        latencyTrackerDelete = QueryParserHelper.createLatencyTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_DELETE);
        latencyTrackerUpdateOrInsert = QueryParserHelper.createLatencyTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES,
                SiddhiConstants.METRIC_TYPE_UPDATE_OR_INSERT);
        latencyTrackerContains = QueryParserHelper.createLatencyTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_CONTAINS);

        throughputTrackerFind = QueryParserHelper.createThroughputTracker(siddhiAppContext, tableDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_FIND);
        throughputTrackerInsert = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_INSERT);
        throughputTrackerUpdate = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_UPDATE);
        throughputTrackerDelete = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_DELETE);
        throughputTrackerUpdateOrInsert = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES,
                SiddhiConstants.METRIC_TYPE_UPDATE_OR_INSERT);
        throughputTrackerContains = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                tableDefinition.getId(), SiddhiConstants.METRIC_INFIX_TABLES, SiddhiConstants.METRIC_TYPE_CONTAINS);

    }
    init(tableDefinition, storeEventPool, storeEventCloner, configReader, siddhiAppContext, recordTableHandler);
}
 
Example 4
Source File: Sink.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public final void init(StreamDefinition streamDefinition, String type, OptionHolder transportOptionHolder,
                       ConfigReader sinkConfigReader, SinkMapper sinkMapper, String mapType,
                       OptionHolder mapOptionHolder, SinkHandler sinkHandler, List<Element> payloadElementList,
                       ConfigReader mapperConfigReader, Map<String, String> deploymentProperties,
                       StreamJunction streamJunction, SiddhiAppContext siddhiAppContext) {
    this.streamDefinition = streamDefinition;
    this.type = type;
    this.streamJunction = streamJunction;
    this.siddhiAppContext = siddhiAppContext;
    this.onErrorAction = OnErrorAction.valueOf(transportOptionHolder
            .getOrCreateOption(SiddhiConstants.ANNOTATION_ELEMENT_ON_ERROR, "LOG")
            .getValue().toUpperCase());
    if (siddhiAppContext.getStatisticsManager() != null) {
        this.throughputTracker = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                streamDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_SINKS, type);
        this.mapperLatencyTracker = QueryParserHelper.createLatencyTracker(siddhiAppContext,
                streamDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_SINK_MAPPERS,
                type + SiddhiConstants.METRIC_DELIMITER + mapType);
    }
    StateFactory<S> stateFactory = init(streamDefinition, transportOptionHolder, sinkConfigReader,
            siddhiAppContext);
    stateHolder = siddhiAppContext.generateStateHolder(streamDefinition.getId() + "-" +
            this.getClass().getName(), stateFactory);
    if (sinkMapper != null) {
        sinkMapper.init(streamDefinition, mapType, mapOptionHolder, payloadElementList, this,
                mapperConfigReader, mapperLatencyTracker, transportOptionHolder, siddhiAppContext);
        this.mapper = sinkMapper;
    }
    if (sinkHandler != null) {
        sinkHandler.initSinkHandler(siddhiAppContext.getName(), streamDefinition,
                new SinkHandlerCallback(sinkMapper), siddhiAppContext);
        this.handler = sinkHandler;
    }
    scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
    serviceDeploymentInfo = exposeServiceDeploymentInfo();
    if (serviceDeploymentInfo != null) {
        serviceDeploymentInfo.addDeploymentProperties(deploymentProperties);
    } else if (!deploymentProperties.isEmpty()) {
        throw new SiddhiAppCreationException("Deployment properties '" + deploymentProperties +
                "' are defined for sink '" + type + "' which does not expose a service");
    }
}
 
Example 5
Source File: TimestampGeneratorImpl.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public TimestampGeneratorImpl(SiddhiAppContext siddhiAppContext) {
    this.siddhiAppContext = siddhiAppContext;
    this.scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
}