All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nstream.persist.store.snapshot.SnapshotContext Maven / Gradle / Ivy

// Copyright 2015-2024 Nstream, inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package nstream.persist.store.snapshot;

import java.util.Iterator;
import java.util.Optional;

/**
 * Interface for a snapshot repository which allows new snapshots to be produced and the most
 * recent snapshot to be restored. Implementations of this interface may assume that they will
 * only be used in a single threaded manner.
 */
public interface SnapshotContext extends SnapshotResource {

  /**
   * Crate a writer that can produce a new snapshot. The snapshot will only be added to the
   * repository after the writer has been successfully closed.
   * @return The snapshot writer.
   * @throws SnapshotException Failed to create a new writer.
   */
  SnapshotWriter writeSnapshot() throws SnapshotException;

  /**
   * Restore the most recent snapshot in the repository.
   * @return An iterator over the files of the snapshot or undefined if there are no snapshots.
   * @throws SnapshotException Failed to read the latest snapshot.
   */
  Optional> restoreLatest() throws SnapshotException;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy