コード例 #1
0
 /// <summary>
 /// Create a new value checkpoint file with the given filename.
 /// </summary>
 /// <param name="filename">Path to the checkpoint file.</param>
 /// <param name="fileId">File Id of the checkpoint file.</param>
 /// <param name="traceType">trace id</param>
 /// <param name="priorityHint">The priority hint.</param>
 public ValueCheckpointFile(string filename, uint fileId, string traceType, Kernel32Types.PRIORITY_HINT priorityHint = Kernel32Types.PRIORITY_HINT.IoPriorityHintNormal)
     : this(filename, priorityHint)
 {
     this.traceType  = traceType;
     this.Properties = new ValueCheckpointFileProperties()
     {
         FileId = fileId,
     };
 }
コード例 #2
0
        /// <summary>
        /// Deserializes the metadata (footer, properties, etc.) for this checkpoint file.
        /// </summary>
        private async Task ReadMetadataAsync()
        {
            Stream filestream = null;

            try
            {
                filestream = this.ReaderPool.AcquireStream();

                var snapFileStream = filestream as FileStream;
                Diagnostics.Assert(snapFileStream != null, this.traceType, "fileStream must be a FileStream");
                Microsoft.ServiceFabric.Replicator.Utility.SetIoPriorityHint(snapFileStream.SafeFileHandle, this.priorityHint);

                // Read and validate the Footer section.  The footer is always at the end of the stream, minus space for the checksum.
                var footerHandle = new BlockHandle(filestream.Length - FileFooter.SerializedSize - sizeof(ulong), FileFooter.SerializedSize);
                this.Footer =
                    await FileBlock.ReadBlockAsync(filestream, footerHandle, (sectionReader, sectionHandle) => FileFooter.Read(sectionReader, sectionHandle)).ConfigureAwait(false);

                // Verify we know how to deserialize this version of the checkpoint file.
                if (this.Footer.Version != FileVersion)
                {
                    throw new InvalidDataException(SR.Error_ValueCheckpoint_Deserialized);
                }

                // Read and validate the Properties section.
                var propertiesHandle = this.Footer.PropertiesHandle;
                this.Properties =
                    await
                    FileBlock.ReadBlockAsync(
                        filestream,
                        propertiesHandle,
                        (sectionReader, sectionHandle) => FilePropertySection.Read <ValueCheckpointFileProperties>(sectionReader, sectionHandle)).ConfigureAwait(false);
            }
            finally
            {
                this.ReaderPool.ReleaseStream(filestream, true);
            }
        }