E
- type of the buffer elements.public final class PersistedAppendingBuffer<E>
extends java.lang.Object
PersistedAppendingBuffer
is an append-only buffer registered within StatefulFunction
s and is persisted and maintained by the system for fault-tolerance. Persisted
elements in the buffer may only be updated with bulk replacements.
Created persisted buffers must be registered by using the Persisted
annotation. Please
see the class-level Javadoc of StatefulFunction
for an example on how to do that.
StatefulFunction
Modifier and Type | Method and Description |
---|---|
void |
append(E element)
Appends an element to the persisted buffer.
|
void |
appendAll(java.util.List<E> elements)
Adds all elements of a list to the persisted buffer.
|
void |
clear()
Clears all elements in the persisted buffer.
|
java.lang.Class<E> |
elementType()
Returns the type of the persisted buffer elements.
|
Expiration |
expiration() |
java.lang.String |
name()
Returns the unique name of the persisted buffer.
|
static <E> PersistedAppendingBuffer<E> |
of(java.lang.String name,
java.lang.Class<E> elementType)
Creates a
PersistedAppendingBuffer instance that may be used to access persisted state
managed by the system. |
static <E> PersistedAppendingBuffer<E> |
of(java.lang.String name,
java.lang.Class<E> elementType,
Expiration expiration)
Creates a
PersistedAppendingBuffer instance that may be used to access persisted state
managed by the system. |
void |
replaceWith(java.util.List<E> elements)
Replace the elements in the persisted buffer with the provided list of elements.
|
java.lang.String |
toString() |
java.lang.Iterable<E> |
view()
Gets an unmodifiable view of the elements of the persisted buffer, as an
Iterable . |
public static <E> PersistedAppendingBuffer<E> of(java.lang.String name, java.lang.Class<E> elementType)
PersistedAppendingBuffer
instance that may be used to access persisted state
managed by the system. Access to the persisted buffer is identified by an unique name and type
of the elements. These may not change across multiple executions of the application.E
- the type of the elements.name
- the unique name of the persisted buffer stateelementType
- the type of the elements of this PersistedAppendingBuffer
.PersistedAppendingBuffer
instance.public static <E> PersistedAppendingBuffer<E> of(java.lang.String name, java.lang.Class<E> elementType, Expiration expiration)
PersistedAppendingBuffer
instance that may be used to access persisted state
managed by the system. Access to the persisted buffer is identified by an unique name and type
of the elements. These may not change across multiple executions of the application.E
- the type of the elements.name
- the unique name of the persisted buffer stateelementType
- the type of the elements of this PersistedAppendingBuffer
.expiration
- state expiration configuration.PersistedAppendingBuffer
instance.public java.lang.String name()
public java.lang.Class<E> elementType()
public Expiration expiration()
public void append(@Nonnull E element)
element
- the element to add to the persisted buffer.public void appendAll(@Nonnull java.util.List<E> elements)
If an empty list is passed in, then this method has no effect and the persisted buffer remains the same.
elements
- a list of elements to add to the persisted buffer.public void replaceWith(@Nonnull java.util.List<E> elements)
If an empty list is passed in, this method will have the same effect as clear()
.
elements
- list of elements to replace the elements in the persisted buffer with.@Nonnull public java.lang.Iterable<E> view()
Iterable
.Iterable
, of the elements of the persisted buffer.public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.