/// <summary> /// Opens a TStore checkpoint from the given file name. /// </summary> /// <param name="filename">The file to open that contains an existing checkpoint.</param> /// <param name="traceType">Tracing information.</param> /// <param name="isValueReferenceType"></param> public static async Task <CheckpointFile> OpenAsync(string filename, string traceType, bool isValueReferenceType) { KeyCheckpointFile keyFile = null; ValueCheckpointFile valueFile = null; try { keyFile = await KeyCheckpointFile.OpenAsync(filename + KeyCheckpointFile.FileExtension, traceType, isValueReferenceType).ConfigureAwait(false); valueFile = await ValueCheckpointFile.OpenAsync(filename + ValueCheckpointFile.FileExtension, traceType).ConfigureAwait(false); return(new CheckpointFile(filename, keyFile, valueFile, traceType)); } catch (Exception) { // Ensure the key and value files get disposed quickly if we get an exception. // Normally the CheckpointFile would dispose them, but it may not get constructed. if (keyFile != null) { keyFile.Dispose(); } if (valueFile != null) { valueFile.Dispose(); } throw; } }
/// <summary> /// Opens a <see cref="KeyCheckpointFile"/> from the given file. /// </summary> /// <param name="filename">The file to open that contains an existing checkpoint file.</param> /// <param name="traceType">Tracing information.</param> /// <param name="isValueReferenceType"></param> public static async Task <KeyCheckpointFile> OpenAsync(string filename, string traceType, bool isValueReferenceType) { FabricEvents.Events.OpenKeyCheckpointFile(traceType, filename, DiskConstants.state_opening); Diagnostics.Assert(FabricFile.Exists(filename), traceType, "File name {0} does not exist", filename); KeyCheckpointFile checkpointFile = null; try { checkpointFile = new KeyCheckpointFile(filename, isValueReferenceType); await checkpointFile.ReadMetadataAsync().ConfigureAwait(false); } catch (Exception) { // Ensure the checkpoint file get disposed quickly if we get an exception. if (checkpointFile != null) { checkpointFile.Dispose(); } throw; } FabricEvents.Events.OpenKeyCheckpointFile(traceType, filename, DiskConstants.state_complete); return(checkpointFile); }