// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
namespace FASTER.core
{
///
/// Interface for users to control creation and retrieval of checkpoint-related data
/// FASTER calls this interface during checkpoint/recovery in this sequence:
///
/// Checkpoint:
/// InitializeIndexCheckpoint (for index checkpoints) ->
/// GetIndexDevice (for index checkpoints) ->
/// InitializeLogCheckpoint (for log checkpoints) ->
/// GetSnapshotLogDevice (for log checkpoints in snapshot mode) ->
/// GetSnapshotObjectLogDevice (for log checkpoints in snapshot mode with objects) ->
/// CommitLogCheckpoint (for log checkpoints) ->
/// CommitIndexCheckpoint (for index checkpoints) ->
///
/// Recovery:
/// GetLatestCheckpoint (if request to recover to latest checkpoint) ->
/// GetIndexCommitMetadata ->
/// GetLogCommitMetadata ->
/// GetIndexDevice ->
/// GetSnapshotLogDevice (for recovery in snapshot mode) ->
/// GetSnapshotObjectLogDevice (for recovery in snapshot mode with objects)
///
/// Provided devices will be closed directly by FASTER when done.
///
public interface ICheckpointManager
{
///
/// Initialize index checkpoint
///
///
void InitializeIndexCheckpoint(Guid indexToken);
///
/// Initialize log checkpoint (snapshot and fold-over)
///
///
void InitializeLogCheckpoint(Guid logToken);
///
/// Commit index checkpoint
///
///
///
///
void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata);
///
/// Commit log checkpoint (snapshot and fold-over)
///
///
///
///
void CommitLogCheckpoint(Guid logToken, byte[] commitMetadata);
///
/// Retrieve commit metadata for specified index checkpoint
///
/// Token
/// Metadata, or null if invalid
byte[] GetIndexCommitMetadata(Guid indexToken);
///
/// Retrieve commit metadata for specified log checkpoint
///
/// Token
/// Metadata, or null if invalid
byte[] GetLogCommitMetadata(Guid logToken);
///
/// Provide device to store index checkpoint (including overflow buckets)
///
///
///
IDevice GetIndexDevice(Guid indexToken);
///
/// Provide device to store snapshot of log (required only for snapshot checkpoints)
///
///
///
IDevice GetSnapshotLogDevice(Guid token);
///
/// Provide device to store snapshot of object log (required only for snapshot checkpoints)
///
///
///
IDevice GetSnapshotObjectLogDevice(Guid token);
///
/// Get latest valid checkpoint for recovery
///
///
///
/// true if latest valid checkpoint found, false otherwise
bool GetLatestCheckpoint(out Guid indexToken, out Guid logToken);
}
}