This is an optional context that can be acquired by using the CONSISTENT_REGION string defined in. More...

Classes |
|
| class | DrainResult |
Public Member Functions |
|
| def | isStartOfRegion (self) |
| Checks if the operator is a start of a consistent region. More... |
|
| def | isEndOfRegion (self) |
| Checks if the operator is an end of a consistent region. More... |
|
| def | isTriggerOperator (self) |
| Checks if the operator is the trigger operator of a consistent region. More... |
|
| def | isConsistentInputPort |
| def | getInputPorts (self) |
| Gets the input ports that participate in the consistent region. More... |
|
| def | getIndex (self) |
| Get the region index. More... |
|
| def | getConsistentRegionMXBeanName (self) |
Get the canonical form of the ObjectName of the ConsistentRegionMXBean associated with the current consistent region. More... |
|
| def | getSequenceId (self) |
| This method returns the current sequence identifier of a consistent region. More... |
|
| def | getResetAttempt (self) |
| Returns the current number of attempts of resetting a consistent region. More... |
|
| def | resetRegion (self) |
Requests the ConsistentRegionMXBean to reset the consistent region to the point of the last successful drain. More... |
|
| def | acquirePermit (self) |
| Acquires the permit required to do operator state modification and tuple or punctuation submission in a consistent region. More... |
|
| def | releasePermit (self) |
| Releases a previously acquired permit. More... |
|
| def | makeConsistent (self) |
| Called by start operators of a region to initiate the establishment of a consistent state. More... |
|
| def | getDrainTimeout (self) |
| Gets the drain timeout of the consistent region. More... |
|
| def | getResetTimeout (self) |
| Gets the reset timeout of the consistent region. More... |
|
| def | enableNonBlockingCheckpoint (self) |
| Enables non-blocking checkpointing. More... |
|
| def | makeConsistentNonBlocking (self) |
| Called by start operators of a region to initiate the establishment of a consistent state. More... |
|
Public Member Functions inherited from streams.OptionalContext |
|
| def | getName (self) |
| Get the optional context name. More... |
|
This is an optional context that can be acquired by using the CONSISTENT_REGION string defined in.
| def streams.ConsistentRegionContext.isStartOfRegion | ( | self, | |
| bool | |||
| ) |
Checks if the operator is a start of a consistent region.
| def streams.ConsistentRegionContext.isEndOfRegion | ( | self, | |
| bool | |||
| ) |
Checks if the operator is an end of a consistent region.
| def streams.ConsistentRegionContext.isTriggerOperator | ( | self, | |
| bool | |||
| ) |
Checks if the operator is the trigger operator of a consistent region.
An operator is the trigger operator if it is the start operator of an operator-driven region.
| def streams.ConsistentRegionContext.isConsistentInputPort | ( | self, | |
| port | |||
| ) |
| def streams.ConsistentRegionContext.getInputPorts | ( | self, | |
| Any | |||
| ) |
Gets the input ports that participate in the consistent region.
| def streams.ConsistentRegionContext.getIndex | ( | self, | |
| int | |||
| ) |
Get the region index.
| def streams.ConsistentRegionContext.getConsistentRegionMXBeanName | ( | self, | |
| str | |||
| ) |
Get the canonical form of the ObjectName of the ConsistentRegionMXBean associated with the current consistent region.
The name can be used to identify the source of notifications to subscribe to.
| def streams.ConsistentRegionContext.getSequenceId | ( | self, | |
| int | |||
| ) |
This method returns the current sequence identifier of a consistent region.
It indicates the id that a drain or a reset should be associated to. After operator startup, this method returns 1. On operator restart, the method returns -1 until it has reset.
When establishing a consistent state, the sequence ID is strictly increasing. When resetting, the sequence ID refers to a sequence ID of a prior successfully established consistent state.
| def streams.ConsistentRegionContext.getResetAttempt | ( | self, | |
| int | |||
| ) |
Returns the current number of attempts of resetting a consistent region.
If a drain is completed after a reset, this method returns -1.
| def streams.ConsistentRegionContext.resetRegion | ( | self, | |
| None | |||
| ) |
Requests the ConsistentRegionMXBean to reset the consistent region to the point of the last successful drain.
If the region is already being reset, a new reset attempt is triggered. This method can be used by operators when detecting an operator-specific transient failure (e.g., handling an exception that prevents the successful establishment of a consistent state). If the exception happens while holding consistent region permits, this method must be invoked while holding the permit.
| def streams.ConsistentRegionContext.acquirePermit | ( | self, | |
| None | |||
| ) |
Acquires the permit required to do operator state modification and tuple or punctuation submission in a consistent region.
Once the permit is acquired, no consistent state is established or reset until the permit is released. If a consistent state is being established or reset, this method blocks until the process completes successfuly.
Multiple threads are allowed to acquire permits at the same time. Operator backgrounds threads (e.g., threads running Operator::process(uint32_t)) that perform tuple or punctuation submission must always acquire permits prior to submission. Permits are automatically acquired by the SPL runtime when processing tuples (e.g., Operator::process(Tuple &, uint32_t)), punctuations (Operator::process(Punctuation const &, uint32_t)), and window library events.
| def streams.ConsistentRegionContext.releasePermit | ( | self, | |
| None | |||
| ) |
Releases a previously acquired permit.
Releasing a permit indicates the successful completion of operator state modification and tuple or punctuation submission, unless the resetRegion() method has been invoked prior to the release of the permit.
| def streams.ConsistentRegionContext.makeConsistent | ( | self, | |
| bool | |||
| ) |
Called by start operators of a region to initiate the establishment of a consistent state.
If the region is operator driven, and the operator is the trigger operator of the region, draining of the region starts immediately. If the region is periodic, the calling thread blocks until the SPL runtime finishes the next periodic consistent state. If the operator needs to submit more tuples prior to the start of a consistent state, such tuples can be submitted in the StateHandler::drain() method.
To successfully execute makeConsistent(), the calling thread must currently hold a permit. If multiple threads call this method at the same time, only a single consistent state will be established.
The method blocks the calling thread and returns when the region has successfully established or reset a consistent state or when there is a shutdown request.
Note that calling makeConsistent() in the start operator would block the tuple flow until all operators in the consistent region have finished checkpointing, including those operator which enable non-blocking checkpointing. In order to achieve non-blocking checkpointing, please use makeConsistentNonBlocking() in the start operator.
Since Streams® Version 4.2.0, before makeConsistent() returns true, the SPL Runtime invokes start operator's StateHandler::regionCheckpointed() callback.
@return true if the region become consistent without any reset, false otherwise. @throws SPLRuntimeOperatorException: if the operator is not a start operator of the region.
| def streams.ConsistentRegionContext.getDrainTimeout | ( | self, | |
| float | |||
| ) |
Gets the drain timeout of the consistent region.
| def streams.ConsistentRegionContext.getResetTimeout | ( | self, | |
| float | |||
| ) |
Gets the reset timeout of the consistent region.
| def streams.ConsistentRegionContext.enableNonBlockingCheckpoint | ( | self, | |
| None | |||
| ) |
Enables non-blocking checkpointing.
This method must be invoked from the operator constructor. Non-blocking checkpointing enables an operator to checkpoint its state while new tuples are processed. This should be used only when the operator implements techniques that guarantee that the operator state saved on the checkpoint() call is consistent with processing all tuples prior to the drain() call even after tuple processing is resumed. One such technique
is user-level copy-on-write of operator state.
| def streams.ConsistentRegionContext.makeConsistentNonBlocking | ( | self, | |
| DrainResult | |||
| ) |
Called by start operators of a region to initiate the establishment of a consistent state.
If the region is operator driven, and the operator is the trigger operator of the region, draining of the region starts immediately. If the region is periodic, the calling thread blocks until the SPL runtime starts the next periodic consistent state. If the operator needs to submit more tuples prior to the start of a consistent state, such tuples can be submitted in the StateHandler::drain() method.
To successfully execute makeConsistentNonBlocking(), the thread must currently hold a permit. If multiple threads call this method at the same time, only a single consistent state will be established.
The makeConsistentNonBlocking() function has similar functionality as makeConsistent(), but should be preferred when the consistent region contains operator(s) with non-blocking checkpoointing enabled.
If a consistent region has no operator which enables non-blocking checkpointing, then the makeConsistentNonBlocking() returns COMPLETED when a consistent state has successfully established, or FAILED when there is a shutdown request or there is a failure and the region has been resetted. So if the consistent region has no operator with non-blocking checkpointing enabled, makeConsistentNonBlocking() returning COMPLETED is equivalent to makeConsistent() returning true, and makeConsistentNonBlocking() returning FAILED is the same as makeConsistent() returning false.
If a consistent region has any operator which enabls non-blocking checkpointing, then the makeConsistentNonBlocking() may also return CHECKPOINT_PENDING, indicating that all blocking operators have finished checkpointing and all non-blocking operators have finished preparation but there is still non-blocking checkpointing ongoing. The start operator can resume tuple processing upon the return of CHECKPOINT_PENDING. In comparison, if makeConsistent() is used when the consistent region has any operator with non-blocking checkpointing enabled, the makeConsistent() call would not return until all operator have finished checkpointing (including those non-blocking ones).
If makeConsistentNonBlocking() returns COMPLETED (no matter whether there is non-blocking operator in the region), a consistent state has been successfully established, and it is safe to resume tuple processing and retire any tuples between this checkpoint and the previous checkpoint. The previous checkpoint has also been retired by the SPL Runtime via calling StateHandler::retireCheckpoint(). Before letting makeConsistentNonblocking() returning COMPLETED, the SPL Runtime also invokes start operator's StateHandler::regionCheckpointed() callback.
If makeConsistentNonBlocking() returns CHECKPOINT_PENDING, it is not safe to retire tuples between this checkpoint and the previous checkpoint, and the SPL Runtime has not yet retired the previous checkpoint; however, it is ok to resume tuple processing after CHECKPOINT_PENDING is returned. When all the pending checkpoints are complete, the SPL Runtime invokes start operator's StateHandler::regionCheckpointed() callback.
makeConsistentNonBlocking() and makeConsistent() cannot be used in mix.
@return COMPLETED if all operators have finished checkponting, return CHECKPOINT_PENDING if all operators that do blocking checkpointing have finished checkpointing, andall operators that do non-blocking checkpointing have finished preparation for non-blocking checkpointing, but at least one operator still has non-blocking checkpointing ongoing, return FAILED if there is failure & reset or shutdown request during the draining and checkpointing process @throws SPLRuntimeOperatorException: if the operator is not a start operator of the region. @since Streams® Version 4.2.0