Ejemplo n.º 1
0
        /// <summary>
        /// Serialize the <see cref="BackupMetadataFileProperties"/> into the given stream.
        /// </summary>
        /// <param name="writer">Stream to write to.</param>
        public override void Write(BinaryWriter writer)
        {
            // Allow the base class to write first.
            base.Write(writer);

            // 'option' - uint32
            writer.Write(BackupOptionPropertyName);
            VarInt.Write(writer, (int)sizeof(uint));
            writer.Write((uint)this.BackupOption);

            // 'parentbackupid' - Guid
            writer.Write(ParentBackupIdPropertyName);
            var parentBackupIdBytes = this.ParentBackupId.ToByteArray();

            VarInt.Write(writer, (int)parentBackupIdBytes.Length);
            writer.Write(parentBackupIdBytes);

            // 'backupid' - Guid
            writer.Write(BackupIdPropertyName);
            var backupIdBytes = this.BackupId.ToByteArray();

            VarInt.Write(writer, (int)backupIdBytes.Length);
            writer.Write(backupIdBytes);

            // 'partitionid' - Guid
            writer.Write(PartitionIdPropertyName);
            var partitionIdBytes = this.PartitionId.ToByteArray();

            VarInt.Write(writer, (int)partitionIdBytes.Length);
            writer.Write(partitionIdBytes);

            // 'replicaid' - long
            writer.Write(ReplicaIdPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.ReplicaId);

            // 'epoch' - Epoch
            writer.Write(StartingEpochPropertyName);
            VarInt.Write(writer, (int)(sizeof(long) * 2));
            writer.Write(this.StartingEpoch.DataLossNumber);
            writer.Write(this.StartingEpoch.ConfigurationNumber);

            // 'lsn' - long
            writer.Write(StartLsnPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.StartingLsn);

            // 'epoch' - Epoch
            writer.Write(BackupEpochPropertyName);
            VarInt.Write(writer, (int)(sizeof(long) * 2));
            writer.Write(this.BackupEpoch.DataLossNumber);
            writer.Write(this.BackupEpoch.ConfigurationNumber);

            // 'lsn' - long
            writer.Write(BackupLsnPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.BackupLsn);
        }
        /// <summary>
        /// Serialize the <see cref="StateManagerFileProperties"/> into the given stream.
        /// </summary>
        /// <param name="writer">Stream to write to.</param>
        public override void Write(BinaryWriter writer)
        {
            // Allow the base class to write first.
            base.Write(writer);

            // 'metadata' - BlockHandle
            writer.Write(MetadataHandlePropertyName);
            VarInt.Write(writer, (int)BlockHandle.SerializedSize);
            this.MetadataHandle.Write(writer);

            // 'blocks' - BlockHandle
            writer.Write(BlocksHandlePropertyName);
            VarInt.Write(writer, (int)BlockHandle.SerializedSize);
            this.BlocksHandle.Write(writer);

            // 'count' - uint
            writer.Write(StateProviderCountPropertyName);
            VarInt.Write(writer, (int)sizeof(uint));
            writer.Write(this.StateProviderCount);

            // 'roots' - uint
            writer.Write(RootStateProviderCountPropertyName);
            VarInt.Write(writer, (int)sizeof(uint));
            writer.Write(this.RootStateProviderCount);

            // 'partitionid' - Guid
            writer.Write(PartitionIdPropertyName);
            var partitionIdBytes = this.PartitionId.ToByteArray();

            VarInt.Write(writer, (int)partitionIdBytes.Length);
            writer.Write(partitionIdBytes);

            // 'replicaid' - long
            writer.Write(ReplicaIdPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.ReplicaId);

            // #12249219: Without the "allowPrepareCheckpointLSNToBeInvalid" being set to true in the backup code path,
            // It is possible for all backups before the first checkpoint after the upgrade to fail.
            if (this.doNotWritePrepareCheckpointLSN == false && this.test_Ignore == false)
            {
                // 'checkpointlsn' - long
                writer.Write(PrepareCheckpointLSNPropertyName);
                VarInt.Write(writer, (int)sizeof(long));
                writer.Write(this.PrepareCheckpointLSN);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Serialize the <see cref="BackupLogFileProperties"/> into the given stream.
        /// </summary>
        /// <param name="writer">Stream to write to.</param>
        public override void Write(BinaryWriter writer)
        {
            // Allow the base class to write first.
            base.Write(writer);

            // 'records' - BlockHandle
            writer.Write(RecordsHandlePropertyName);
            VarInt.Write(writer, (int)BlockHandle.SerializedSize);
            this.RecordsHandle.Write(writer);

            // 'count' - uint
            writer.Write(CountPropertyName);
            VarInt.Write(writer, (int)sizeof(uint));
            writer.Write(this.Count);

            // 'indexepoch' - Epoch
            writer.Write(IndexingRecordEpochPropertyName);
            VarInt.Write(writer, (int)(sizeof(long) * 2));
            writer.Write(this.IndexingRecordEpoch.DataLossNumber);
            writer.Write(this.IndexingRecordEpoch.ConfigurationNumber);

            // 'indexlsn' - long
            writer.Write(IndexingRecordLsnPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.IndexingRecordLsn.LSN);

            // 'backupepoch' - Epoch
            writer.Write(LastBackedUpEpochPropertyName);
            VarInt.Write(writer, (int)(sizeof(long) * 2));
            writer.Write(this.LastBackedUpEpoch.DataLossNumber);
            writer.Write(this.LastBackedUpEpoch.ConfigurationNumber);

            // 'backuplsn' - long
            writer.Write(LastBackedUpLsnPropertyName);
            VarInt.Write(writer, (int)sizeof(long));
            writer.Write(this.LastBackedUpLsn.LSN);
        }