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

io.zeebe.logstreams.spi.SnapshotStorage Maven / Gradle / Ivy

There is a newer version: 0.16.4
Show newest version
/*
 * Copyright © 2017 camunda services GmbH ([email protected])
 *
 * 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 io.zeebe.logstreams.spi;

import java.util.List;

/**
 * Storage for log snapshots.
 */
public interface SnapshotStorage
{

    /**
     * Returns the last snapshot for the given name.
     *
     * @param name
     *            the name of the snapshot
     * @return the snapshot or null if none exists
     * @throws Exception
     *             if fails to open the snapshot
     */
    ReadableSnapshot getLastSnapshot(String name) throws Exception;

    /**
     * Returns a writer to create a new snapshot.
     *
     * @param name
     *            the name of the snapshot
     * @param logPosition
     *            the log position at which the snapshot is taken
     * @return the writer to create the snapshot
     * @throws Exception
     *             if fails to create the snapshot
     */
    SnapshotWriter createSnapshot(String name, long logPosition) throws Exception;

    /**
     * Deletes all existing snapshot and checksum files.
     *
     * @param name the name of the snapshot
     * @return true if the purging was successful otherwise false
     */
    boolean purgeSnapshot(String name);

    /**
     * Returns a list of available snapshots; for each snapshot item, it returns the latest
     * file.
     * @return all available snapshots
     */
    List listSnapshots();

    /**
     * Returns whether or not there already exists a snapshot for the given
     * name + position.
     */
    boolean snapshotExists(String name, long logPosition);

    /**
     * Returns a writer to create a temporary snapshot.
     *
     * @param prefix a short prefix which indicates that the temporary snapshot is used for, e.g. "repl" for replication
     * @param name the snapshot name
     * @param logPosition the logPosition
     * @return pre-configured SnapshotWriter
     * @throws Exception if it fails to prepare the necessary resources for the temporary snapshot
     */
    SnapshotWriter createTemporarySnapshot(String prefix, String name, long logPosition) throws Exception;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy