Package org.apache.flink.runtime.state
Class StateUtil
- java.lang.Object
-
- org.apache.flink.runtime.state.StateUtil
-
public class StateUtil extends Object
Helpers forStateObjectrelated code.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbestEffortDiscardAllStateObjects(Iterable<? extends StateObject> handlesToDiscard)Iterates through the passed state handles and calls discardState() on each handle that is not null.static org.apache.flink.api.java.tuple.Tuple2<Long,Long>discardStateFuture(Future<? extends StateObject> stateFuture)Discards the given state future by first trying to cancel it.static voiddiscardStateObjectQuietly(StateObject stateObject)static longgetStateSize(StateObject handle)Returns the size of a state object.static RuntimeExceptionunexpectedStateHandleException(Class<? extends StateObject>[] expectedStateHandleClasses, Class<? extends StateObject> actualStateHandleClass)Creates aRuntimeExceptionthat signals that an operation did not get the type ofStateObjectthat was expected.static RuntimeExceptionunexpectedStateHandleException(Class<? extends StateObject> expectedStateHandleClass, Class<? extends StateObject> actualStateHandleClass)Creates anRuntimeExceptionthat signals that an operation did not get the type ofStateObjectthat was expected.
-
-
-
Method Detail
-
getStateSize
public static long getStateSize(StateObject handle)
Returns the size of a state object.- Parameters:
handle- The handle to the retrieved state
-
bestEffortDiscardAllStateObjects
public static void bestEffortDiscardAllStateObjects(Iterable<? extends StateObject> handlesToDiscard) throws Exception
Iterates through the passed state handles and calls discardState() on each handle that is not null. All occurring exceptions are suppressed and collected until the iteration is over and emitted as a single exception.- Parameters:
handlesToDiscard- State handles to discard. Passed iterable is allowed to deliver null values.- Throws:
Exception- exception that is a collection of all suppressed exceptions that were caught during iteration
-
discardStateObjectQuietly
public static void discardStateObjectQuietly(StateObject stateObject)
-
discardStateFuture
public static org.apache.flink.api.java.tuple.Tuple2<Long,Long> discardStateFuture(Future<? extends StateObject> stateFuture) throws Exception
Discards the given state future by first trying to cancel it. If this is not possible, then the state object contained in the future is calculated and afterwards discarded.- Parameters:
stateFuture- to be discarded- Returns:
- the size of state before cancellation (if available)
- Throws:
Exception- if the discard operation failed
-
unexpectedStateHandleException
public static RuntimeException unexpectedStateHandleException(Class<? extends StateObject> expectedStateHandleClass, Class<? extends StateObject> actualStateHandleClass)
Creates anRuntimeExceptionthat signals that an operation did not get the type ofStateObjectthat was expected. This can mostly happen when a differentStateBackendfrom the one that was used for taking a checkpoint/savepoint is used when restoring.
-
unexpectedStateHandleException
public static RuntimeException unexpectedStateHandleException(Class<? extends StateObject>[] expectedStateHandleClasses, Class<? extends StateObject> actualStateHandleClass)
Creates aRuntimeExceptionthat signals that an operation did not get the type ofStateObjectthat was expected. This can mostly happen when a differentStateBackendfrom the one that was used for taking a checkpoint/savepoint is used when restoring.
-
-