コード例 #1
0
ファイル: FASTER.cs プロジェクト: microsoft/FASTER
        /// <summary>
        /// Initiate log-only checkpoint
        /// </summary>
        /// <param name="token">Checkpoint token</param>
        /// <param name="checkpointType">Checkpoint type</param>
        /// <param name="tryIncremental">For snapshot, try to store as incremental delta over last snapshot</param>
        /// <param name="targetVersion">
        /// intended version number of the next version. Checkpoint will not execute if supplied version is not larger
        /// than current version. Actual new version may have version number greater than supplied number. If the supplied
        /// number is -1, checkpoint will unconditionally create a new version.
        /// </param>
        /// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
        public bool TakeHybridLogCheckpoint(out Guid token, CheckpointType checkpointType, bool tryIncremental = false,
                                            long targetVersion = -1)
        {
            ISynchronizationTask backend;

            if (checkpointType == CheckpointType.FoldOver)
            {
                backend = new FoldOverCheckpointTask();
            }
            else if (checkpointType == CheckpointType.Snapshot)
            {
                if (tryIncremental && _lastSnapshotCheckpoint.info.guid != default && _lastSnapshotCheckpoint.info.finalLogicalAddress > hlog.FlushedUntilAddress)
                {
                    backend = new IncrementalSnapshotCheckpointTask();
                }
                else
                {
                    backend = new SnapshotCheckpointTask();
                }
            }
            else
            {
                throw new FasterException("Unsupported checkpoint type");
            }

            var result = StartStateMachine(new HybridLogCheckpointStateMachine(backend, targetVersion));

            token = _hybridLogCheckpointToken;
            return(result);
        }
コード例 #2
0
ファイル: FASTER.cs プロジェクト: microsoft/FASTER
        /// <summary>
        /// Initiate full checkpoint
        /// </summary>
        /// <param name="token">Checkpoint token</param>
        /// <param name="checkpointType">Checkpoint type</param>
        /// <param name="targetVersion">
        /// intended version number of the next version. Checkpoint will not execute if supplied version is not larger
        /// than current version. Actual new version may have version number greater than supplied number. If the supplied
        /// number is -1, checkpoint will unconditionally create a new version.
        /// </param>
        /// <returns>
        /// Whether we successfully initiated the checkpoint (initiation may
        /// fail if we are already taking a checkpoint or performing some other
        /// operation such as growing the index). Use CompleteCheckpointAsync to wait completion.
        /// </returns>
        public bool TakeFullCheckpoint(out Guid token, CheckpointType checkpointType, long targetVersion = -1)
        {
            ISynchronizationTask backend;

            if (checkpointType == CheckpointType.FoldOver)
            {
                backend = new FoldOverCheckpointTask();
            }
            else if (checkpointType == CheckpointType.Snapshot)
            {
                backend = new SnapshotCheckpointTask();
            }
            else
            {
                throw new FasterException("Unsupported full checkpoint type");
            }

            var result = StartStateMachine(new FullCheckpointStateMachine(backend, targetVersion));

            if (result)
            {
                token = _hybridLogCheckpointToken;
            }
            else
            {
                token = default;
            }
            return(result);
        }
コード例 #3
0
ファイル: FASTER.cs プロジェクト: microsoft/FASTER
        /// <summary>
        /// Initiate log-only checkpoint
        /// </summary>
        /// <param name="token">Checkpoint token</param>
        /// <param name="targetVersion">
        /// intended version number of the next version. Checkpoint will not execute if supplied version is not larger
        /// than current version. Actual new version may have version number greater than supplied number. If the supplied
        /// number is -1, checkpoint will unconditionally create a new version.
        /// </param>
        /// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
        public bool TakeHybridLogCheckpoint(out Guid token, long targetVersion = -1)
        {
            ISynchronizationTask backend;

            if (FoldOverSnapshot)
            {
                backend = new FoldOverCheckpointTask();
            }
            else
            {
                backend = new SnapshotCheckpointTask();
            }

            var result = StartStateMachine(new HybridLogCheckpointStateMachine(backend, targetVersion));

            token = _hybridLogCheckpointToken;
            return(result);
        }
コード例 #4
0
ファイル: FASTER.cs プロジェクト: ryanrc/FASTER
        /// <summary>
        /// Initiate log-only checkpoint
        /// </summary>
        /// <param name="token">Checkpoint token</param>
        /// <param name="checkpointType">Checkpoint type</param>
        /// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
        public bool TakeHybridLogCheckpoint(out Guid token, CheckpointType checkpointType)
        {
            ISynchronizationTask backend;

            if (checkpointType == CheckpointType.FoldOver)
            {
                backend = new FoldOverCheckpointTask();
            }
            else if (checkpointType == CheckpointType.Snapshot)
            {
                backend = new SnapshotCheckpointTask();
            }
            else
            {
                throw new FasterException("Unsupported checkpoint type");
            }

            var result = StartStateMachine(new HybridLogCheckpointStateMachine(backend, -1));

            token = _hybridLogCheckpointToken;
            return(result);
        }