Class StateObjectCollection<T extends StateObject>
- java.lang.Object
-
- org.apache.flink.runtime.checkpoint.StateObjectCollection<T>
-
- Type Parameters:
T- type of the contained state objects.
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,StateObject
public class StateObjectCollection<T extends StateObject> extends Object implements Collection<T>, StateObject
This class represents a generic collection forStateObjects. Being a state object itself, it delegatesdiscardState()to all contained state objects and computesgetStateSize()as sum of the state sizes of all contained objects.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.StateObject
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector
-
-
Constructor Summary
Constructors Constructor Description StateObjectCollection()Creates a new StateObjectCollection that is backed by anArrayList.StateObjectCollection(Collection<T> stateObjects)Creates a new StateObjectCollection wraps the given collection and delegates to it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T t)booleanaddAll(Collection<? extends T> c)List<T>asList()voidclear()voidcollectSizeStats(StateObject.StateObjectSizeStatsCollector collector)Collects statistics about state size and location from the state object.booleancontains(Object o)booleancontainsAll(Collection<?> c)voiddiscardState()Discards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage.static <T extends StateObject>
StateObjectCollection<T>empty()static <T extends StateObject>
StateObjectCollection<T>emptyIfNull(StateObjectCollection<T> collection)booleanequals(Object o)longgetCheckpointedSize()longgetStateSize()Returns the size of the state in bytes.inthashCode()booleanhasState()Returns true if this contains at least oneStateObject.booleanisEmpty()Iterator<T>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanremoveIf(Predicate<? super T> filter)booleanretainAll(Collection<?> c)static <T extends StateObject>
StateObjectCollection<T>singleton(T stateObject)static <T extends StateObject>
StateObjectCollection<T>singletonOrEmpty(T stateObject)intsize()Object[]toArray()<T1> T1[]toArray(T1[] a)StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
StateObjectCollection
public StateObjectCollection()
Creates a new StateObjectCollection that is backed by anArrayList.
-
StateObjectCollection
public StateObjectCollection(Collection<T> stateObjects)
Creates a new StateObjectCollection wraps the given collection and delegates to it.- Parameters:
stateObjects- collection of state objects to wrap.
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<T extends StateObject>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T extends StateObject>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<T extends StateObject>
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceCollection<T extends StateObject>- Specified by:
iteratorin interfaceIterable<T extends StateObject>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T extends StateObject>
-
toArray
public <T1> T1[] toArray(T1[] a)
- Specified by:
toArrayin interfaceCollection<T extends StateObject>
-
add
public boolean add(T t)
- Specified by:
addin interfaceCollection<T extends StateObject>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T extends StateObject>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T extends StateObject>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAllin interfaceCollection<T extends StateObject>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<T extends StateObject>
-
removeIf
public boolean removeIf(Predicate<? super T> filter)
- Specified by:
removeIfin interfaceCollection<T extends StateObject>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T extends StateObject>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T extends StateObject>
-
discardState
public void discardState() throws ExceptionDescription copied from interface:StateObjectDiscards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage. This method is called when the state represented by this object will not be used anymore.- Specified by:
discardStatein interfaceStateObject- Throws:
Exception
-
getStateSize
public long getStateSize()
Description copied from interface:StateObjectReturns the size of the state in bytes. If the size is not known, this method should return0.The values produced by this method are only used for informational purposes and for metrics/monitoring. If this method returns wrong values, the checkpoints and recovery will still behave correctly. However, efficiency may be impacted (wrong space pre-allocation) and functionality that depends on metrics (like monitoring) will be impacted.
Note for implementors: This method should not perform any I/O operations while obtaining the state size (hence it does not declare throwing an
IOException). Instead, the state size should be stored in the state object, or should be computable from the state stored in this object. The reason is that this method is called frequently by several parts of the checkpointing and issuing I/O requests from this method accumulates a heavy I/O load on the storage system at higher scale.- Specified by:
getStateSizein interfaceStateObject- Returns:
- Size of the state in bytes.
-
collectSizeStats
public void collectSizeStats(StateObject.StateObjectSizeStatsCollector collector)
Description copied from interface:StateObjectCollects statistics about state size and location from the state object.- Specified by:
collectSizeStatsin interfaceStateObject- Parameters:
collector- the statistics collector.
-
getCheckpointedSize
public long getCheckpointedSize()
-
hasState
public boolean hasState()
Returns true if this contains at least oneStateObject.
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<T extends StateObject>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<T extends StateObject>- Overrides:
hashCodein classObject
-
empty
public static <T extends StateObject> StateObjectCollection<T> empty()
-
emptyIfNull
public static <T extends StateObject> StateObjectCollection<T> emptyIfNull(@Nullable StateObjectCollection<T> collection)
-
singleton
public static <T extends StateObject> StateObjectCollection<T> singleton(T stateObject)
-
singletonOrEmpty
public static <T extends StateObject> StateObjectCollection<T> singletonOrEmpty(@Nullable T stateObject)
-
-