Class Source<S extends State>
- java.lang.Object
-
- io.siddhi.core.stream.input.source.Source<S>
-
- Type Parameters:
S- current state of the Source
- Direct Known Subclasses:
InMemorySource
public abstract class Source<S extends State> extends Object
Abstract class to represent Event Sources. Events Sources are the object entry point to Siddhi from external transports. Each source represent a transport type. Whenever Siddhi need to support a new transport, a new Event source should be implemented.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSource.ConnectionCallbackCallback class used to pass connection exception during message retrieval
-
Constructor Summary
Constructors Constructor Description Source()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidconnect(Source.ConnectionCallback connectionCallback, S state)Called to connect to the source backend for receiving eventsvoidconnectWithRetry()abstract voiddestroy()Called at the end to clean all the resources consumedabstract voiddisconnect()Called to disconnect from the source backend, or when ConnectionUnavailableException is thrownprotected abstract ServiceDeploymentInfoexposeServiceDeploymentInfo()Give information to the deployment about the service exposed by the sink.SourceMappergetMapper()abstract Class[]getOutputEventClasses()Get produced event class typesServiceDeploymentInfogetServiceDeploymentInfo()io.siddhi.query.api.definition.StreamDefinitiongetStreamDefinition()StringgetType()abstract StateFactory<S>init(SourceEventListener sourceEventListener, OptionHolder optionHolder, String[] requestedTransportPropertyNames, ConfigReader configReader, SiddhiAppContext siddhiAppContext)To initialize the source.voidinit(String sourceType, OptionHolder transportOptionHolder, SourceMapper sourceMapper, String[] transportPropertyNames, ConfigReader configReader, String mapType, OptionHolder mapOptionHolder, List<AttributeMapping> attributeMappings, List<AttributeMapping> transportMappings, ConfigReader mapperConfigReader, SourceHandler sourceHandler, io.siddhi.query.api.definition.StreamDefinition streamDefinition, Map<String,String> deploymentProperties, SiddhiAppContext siddhiAppContext)booleanisStateful()abstract voidpause()Called to pause event consumptionabstract voidresume()Called to resume event consumptionvoidshutdown()
-
-
-
Method Detail
-
init
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, io.siddhi.query.api.definition.StreamDefinition streamDefinition, Map<String,String> deploymentProperties, SiddhiAppContext siddhiAppContext)
-
exposeServiceDeploymentInfo
protected abstract ServiceDeploymentInfo exposeServiceDeploymentInfo()
Give information to the deployment about the service exposed by the sink.- Returns:
- ServiceDeploymentInfo Service related information to the deployment
-
init
public abstract StateFactory<S> init(SourceEventListener sourceEventListener, OptionHolder optionHolder, String[] requestedTransportPropertyNames, ConfigReader configReader, SiddhiAppContext siddhiAppContext)
To initialize the source. (This will be called only once, no connection to external systems should be made at this point).- Parameters:
sourceEventListener- The listener to pass the events for processing which are consumed by the sourceoptionHolder- Contains static options of the sourcerequestedTransportPropertyNames- Requested transport properties that should be passed to SourceEventListenerconfigReader- System configuration reader for sourcesiddhiAppContext- Siddhi application context
-
getOutputEventClasses
public abstract Class[] getOutputEventClasses()
Get produced event class types- Returns:
- Array of classes that will be produced by the source, null or empty array if it can produce any type of class.
-
connect
public abstract void connect(Source.ConnectionCallback connectionCallback, S state) throws ConnectionUnavailableException
Called to connect to the source backend for receiving events- Parameters:
connectionCallback- Callback to pass the ConnectionUnavailableException for connection failure after initial successful connectionstate- current state of the source- Throws:
ConnectionUnavailableException- if it cannot connect to the source backend
-
disconnect
public abstract void disconnect()
Called to disconnect from the source backend, or when ConnectionUnavailableException is thrown
-
destroy
public abstract void destroy()
Called at the end to clean all the resources consumed
-
pause
public abstract void pause()
Called to pause event consumption
-
resume
public abstract void resume()
Called to resume event consumption
-
connectWithRetry
public void connectWithRetry()
-
getMapper
public final SourceMapper getMapper()
-
shutdown
public void shutdown()
-
getType
public String getType()
-
getStreamDefinition
public io.siddhi.query.api.definition.StreamDefinition getStreamDefinition()
-
getServiceDeploymentInfo
public ServiceDeploymentInfo getServiceDeploymentInfo()
-
isStateful
public boolean isStateful()
-
-