Class DistributionStrategy
- java.lang.Object
-
- io.siddhi.core.stream.output.sink.distributed.DistributionStrategy
-
- Direct Known Subclasses:
BroadcastDistributionStrategy,PartitionedDistributionStrategy,RoundRobinDistributionStrategy
public abstract class DistributionStrategy extends Object
Parent class for the Distributed publishing strategy extensions. Note that destinationId of the each destination is implied by the order which @destination annotations appear in @sink annotation. Therefore, when implementing a strategy, if the implementation wants refer to a certain @destination the ID can be derived by looking at the listing order of @destination
-
-
Constructor Summary
Constructors Constructor Description DistributionStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddestinationAvailable(Integer destinationId)Remove a destination to available set of destination IDs.voiddestinationFailed(Integer destinationId)Remove a given destination from available set of destination IDs.intgetActiveDestinationCount()Get the active number of destinationsabstract List<Integer>getDestinationsToPublish(Object payload, DynamicOptions transportOptions)This method tells the ID(s) of the destination(s) to which a given messages should be sent.abstract voidinit(io.siddhi.query.api.definition.StreamDefinition streamDefinition, OptionHolder transportOptionHolder, OptionHolder distributionOptionHolder, List<OptionHolder> destinationOptionHolders, ConfigReader configReader)Initialize the Distribution strategy with the information it will require to make decisions.
-
-
-
Method Detail
-
init
public abstract void init(io.siddhi.query.api.definition.StreamDefinition streamDefinition, OptionHolder transportOptionHolder, OptionHolder distributionOptionHolder, List<OptionHolder> destinationOptionHolders, ConfigReader configReader)Initialize the Distribution strategy with the information it will require to make decisions.- Parameters:
streamDefinition- The stream attached to the sink this DistributionStrategy is used intransportOptionHolder- Sink options of the sink which uses this DistributionStrategydistributionOptionHolder- The option under @destination of the relevant sink.destinationOptionHolders- The list of options under @destination of the relevant sink.configReader- This hold theDistributionStrategyextensions configuration reader.
-
getDestinationsToPublish
public abstract List<Integer> getDestinationsToPublish(Object payload, DynamicOptions transportOptions)
This method tells the ID(s) of the destination(s) to which a given messages should be sent. There can be cases where a given message is only sent to a specific destination(e.g., partition based) and message is sent to multiple endpoints(e.g., broadcast)- Parameters:
payload- payload of the messagetransportOptions- Dynamic transport options of the sink- Returns:
- Set of IDs of the destination to which the event should be sent
-
destinationFailed
public void destinationFailed(Integer destinationId)
Remove a given destination from available set of destination IDs. Once this method is called for a given destination ID, that particular destination ID will not included in the return value of subsequent getDestinationsToPublish() is calls- Parameters:
destinationId- the ID of the destination to be removed
-
destinationAvailable
public void destinationAvailable(Integer destinationId)
Remove a destination to available set of destination IDs. Once this method is called for a given destination ID, that particular destination ID will be considered when getDestinationsToPublish() is called- Parameters:
destinationId- the ID of the destination to be check for availability.
-
getActiveDestinationCount
public int getActiveDestinationCount()
Get the active number of destinations- Returns:
- The active number of destinations
-
-