Class SavepointWriter


  • @PublicEvolving
    public class SavepointWriter
    extends Object
    A SavepointWriter can create new savepoints from bounded data streams. This can allow for boostrapping state for new applications or modifying the savepoints of existing jobs.
    • Field Detail

      • metadata

        protected final SavepointMetadataV2 metadata
        The savepoint metadata, which maintains the current set of existing / newly added operator states.
      • stateBackend

        @Nullable
        protected final StateBackend stateBackend
        The state backend to use when writing this savepoint.
    • Method Detail

      • removeOperator

        public SavepointWriter removeOperator​(OperatorIdentifier identifier)
        Drop an existing operator from the savepoint.
        Parameters:
        identifier - The identifier of the operator.
        Returns:
        A modified savepoint.
      • withOperator

        public <T> SavepointWriter withOperator​(OperatorIdentifier identifier,
                                                StateBootstrapTransformation<T> transformation)
        Adds a new operator to the savepoint.
        Parameters:
        identifier - The identifier of the operator.
        transformation - The operator to be included.
        Returns:
        The modified savepoint.
      • withConfiguration

        public <T> SavepointWriter withConfiguration​(ConfigOption<T> option,
                                                     T value)
        Sets a configuration that will be applied to the stream operators used to bootstrap a new savepoint.
        Type Parameters:
        T - type of the value to be stored
        Parameters:
        option - metadata information
        value - value to be stored
        Returns:
        The modified savepoint.
      • changeOperatorIdentifier

        public SavepointWriter changeOperatorIdentifier​(OperatorIdentifier from,
                                                        OperatorIdentifier to)
        Changes the identifier of an operator.

        This method is comparatively cheap since it only modifies savepoint metadata without reading the entire savepoint data.

        Use-cases include, but are not limited to:

        • assigning a UID to an operator that did not have a UID assigned before
        • changing the UID of an operator
        • swapping the states of 2 operators

        Identifier changes are applied after all other operations; in the following example the savepoint will only contain UID_2.

             SavepointWriter savepoint = ...
             savepoint.withOperator(UID_1, ...)
             savepoint.changeOperatorIdentifier(UID_1, UID_2)
             savepoint.write(...)
         

        You cannot define a chain of changes; in the following example the savepoint will only contain UID_2.

             SavepointWriter savepoint = ...
             savepoint.withOperator(UID_1, ...)
             savepoint.changeOperatorIdentifier(UID_1, UID_2)
             savepoint.changeOperatorIdentifier(UID_2, UID_3)
             savepoint.write(...)
         
        Parameters:
        from - operator whose identifier should be changed
        to - desired identifier
        Returns:
        The modified savepoint.
      • write

        public final void write​(String path)
        Write out a new or updated savepoint.
        Parameters:
        path - The path to where the savepoint should be written.