EventT
- type of events to be processedKeyT
- type of keys which will be used to group the eventsStateT
- type of internal State which will be used for processingResultT
- type of the result of the processing which will be outputpublic abstract class OrderedProcessingHandler<EventT,KeyT,StateT extends MutableState<EventT,?>,ResultT>
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_ELEMENTS_TO_OUTPUT |
Constructor and Description |
---|
OrderedProcessingHandler(java.lang.Class<EventT> eventTClass,
java.lang.Class<KeyT> keyTClass,
java.lang.Class<StateT> stateTClass,
java.lang.Class<ResultT> resultTClass)
Provide concrete classes which will be used by the ordered processing transform.
|
Modifier and Type | Method and Description |
---|---|
@NonNull Coder<EventT> |
getEventCoder(Pipeline pipeline,
Coder<KV<KeyT,KV<java.lang.Long,EventT>>> inputCoder)
Provide the event coder.
|
abstract @NonNull EventExaminer<EventT,StateT> |
getEventExaminer() |
@NonNull Coder<KeyT> |
getKeyCoder(Pipeline pipeline,
Coder<KV<KeyT,KV<java.lang.Long,EventT>>> inputCoder)
Provide the key coder.
|
int |
getMaxOutputElementsPerBundle()
Returns the maximum number of elements which will be output per each bundle.
|
@NonNull Coder<ResultT> |
getResultCoder(Pipeline pipeline)
Provide the result coder.
|
@NonNull Coder<StateT> |
getStateCoder(Pipeline pipeline)
Provide the state coder.
|
@Nullable Duration |
getStatusUpdateFrequency()
Determines the frequency of emission of the
OrderedProcessingStatus elements. |
boolean |
isProduceStatusUpdateOnEveryEvent()
Indicates if the status update needs to be sent after each event's processing.
|
void |
setMaxOutputElementsPerBundle(int maxOutputElementsPerBundle)
Overrides the default value.
|
void |
setProduceStatusUpdateOnEveryEvent(boolean value)
Sets the indicator of whether the status notification needs to be produced on every event.
|
void |
setStatusUpdateFrequency(Duration statusUpdateFrequency)
Changes the default status update frequency.
|
public static final int DEFAULT_MAX_ELEMENTS_TO_OUTPUT
public OrderedProcessingHandler(java.lang.Class<EventT> eventTClass, java.lang.Class<KeyT> keyTClass, java.lang.Class<StateT> stateTClass, java.lang.Class<ResultT> resultTClass)
eventTClass
- class of the eventskeyTClass
- class of the keysstateTClass
- class of the stateresultTClass
- class of the resultspublic abstract @NonNull EventExaminer<EventT,StateT> getEventExaminer()
public @NonNull Coder<EventT> getEventCoder(Pipeline pipeline, Coder<KV<KeyT,KV<java.lang.Long,EventT>>> inputCoder) throws CannotProvideCoderException
The default implementation of the method will use the event coder from the input PCollection. If the input PCollection doesn't use KVCoder, it will attempt to get the coder from the pipeline's coder registry.
pipeline
- of the transforminputCoder
- input coder of the transformCannotProvideCoderException
- if the method can't determine the coder based on the above
algorithm.public @NonNull Coder<StateT> getStateCoder(Pipeline pipeline) throws CannotProvideCoderException
The default implementation will attempt to get the coder from the pipeline's code registry.
pipeline
- of the transformCannotProvideCoderException
public @NonNull Coder<KeyT> getKeyCoder(Pipeline pipeline, Coder<KV<KeyT,KV<java.lang.Long,EventT>>> inputCoder) throws CannotProvideCoderException
The default implementation of the method will use the event coder from the input PCollection. If the input PCollection doesn't use KVCoder, it will attempt to get the coder from the pipeline's coder registry.
pipeline
- inputCoder
- CannotProvideCoderException
- if the method can't determine the coder based on the above
algorithm.public @NonNull Coder<ResultT> getResultCoder(Pipeline pipeline) throws CannotProvideCoderException
The default implementation will attempt to get the coder from the pipeline's code registry.
pipeline
- CannotProvideCoderException
public @Nullable Duration getStatusUpdateFrequency()
OrderedProcessingStatus
elements.
Default is 5 seconds.
public void setStatusUpdateFrequency(Duration statusUpdateFrequency)
statusUpdateFrequency
- public boolean isProduceStatusUpdateOnEveryEvent()
Default is false.
getStatusUpdateFrequency
,
PCollection of processing statuses
public void setProduceStatusUpdateOnEveryEvent(boolean value)
value
- public int getMaxOutputElementsPerBundle()
This is used to limit the amount of data produced for each bundle - many runners have limitations on how much data can be output from a single bundle. If many events arrive out of sequence and are buffered then at some point a single event can cause processing of a large number of buffered events.
public void setMaxOutputElementsPerBundle(int maxOutputElementsPerBundle)
maxOutputElementsPerBundle
-