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

io.zeebe.snapshots.raft.PersistedSnapshotStore Maven / Gradle / Ivy

There is a newer version: 1.0.0-alpha7
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Zeebe Community License 1.0. You may not use this file
 * except in compliance with the Zeebe Community License 1.0.
 */
package io.zeebe.snapshots.raft;

import io.zeebe.util.CloseableSilently;
import io.zeebe.util.sched.future.ActorFuture;
import java.util.Optional;

/**
 * Represents a store, which allows to persist snapshots on a storage, which is implementation
 * dependent. It can receive {@link SnapshotChunk}'s from an already {@link PersistedSnapshot} and
 * persist them in this current store.
 *
 * 

Only one {@link PersistedSnapshot} at a time is stored in the {@link PersistedSnapshotStore} * and can be received via {@link PersistedSnapshotStore#getLatestSnapshot()}. */ public interface PersistedSnapshotStore extends CloseableSilently { /** * Returns true if the given identifier is equal to the snapshot id of the current persisted * snapshot, false otherwise. * * @param id the snapshot Id to look for * @return true if the current snapshot has the equal Id, false otherwise * @see SnapshotId#getSnapshotIdAsString() */ boolean hasSnapshotId(String id); /** @return the latest {@link PersistedSnapshot} if exists */ Optional getLatestSnapshot(); /** * Purges all ongoing pending/transient/volatile snapshots. * * @return future which will be completed when all pending snapshots are deleted */ ActorFuture purgePendingSnapshots(); /** * Adds an {@link PersistedSnapshotListener} to the store, which is notified when a new {@link * PersistedSnapshot} is persisted at this store. * * @param listener the listener which should be added and notified later * @return */ ActorFuture addSnapshotListener(PersistedSnapshotListener listener); /** * Removes an registered {@link PersistedSnapshotListener} from the store. The listener will no * longer called when a new {@link PersistedSnapshot} is persisted at this store. * * @param listener the listener which should be removed * @return */ ActorFuture removeSnapshotListener(PersistedSnapshotListener listener); /** * @return the snapshot index of the latest {@link PersistedSnapshot} * @see PersistedSnapshotStore#getLatestSnapshot() */ long getCurrentSnapshotIndex(); /** * Deletes a {@link PersistedSnapshotStore} from disk. * *

The snapshot store will be deleted by simply reading {@code snapshot} file names from disk * and deleting snapshot files directly. Deleting the snapshot store does not involve reading any * snapshot files into memory. * * @return */ ActorFuture delete(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy