Exemplo n.º 1
0
        protected override void Read(BinaryReader br, bool isPhysicalRead)
        {
            // IF THIS METHOD CHANGES, READLOGICAL MUST CHANGE ACCORDINGLY AS WE ARE ADDING MULTIPLE ARRAYSEGMENTS HERE
            // THIS IS TRUE FOR ANY REDO+UNDO TYPE RECORDS
            base.Read(br, isPhysicalRead);

            // Metadata section.
            var startingPosition = br.BaseStream.Position;
            var sizeOfSection    = br.ReadInt32();
            var endPosition      = startingPosition + sizeOfSection;

            // Read Metadata fields
            this.isRedoOnly = br.ReadBoolean();

            // Jump to the end of the section ignoring fields that are not understood.
            Utility.Assert(endPosition >= br.BaseStream.Position, "Could not have read more than section size.");
            br.BaseStream.Position = endPosition;

            if (this.isRedoOnly)
            {
                this.Transaction = AtomicRedoOperation.CreateAtomicRedoOperation(this.Transaction.Id, true);
            }

            this.metaData = ReadOperationData(br);
            this.redo     = ReadOperationData(br);

            if (!this.isRedoOnly)
            {
                this.undo = ReadOperationData(br);
            }

            this.UpdateApproximateDiskSize();
            return;
        }
Exemplo n.º 2
0
        protected override void ReadLogical(OperationData operationData, ref int index)
        {
            base.ReadLogical(operationData, ref index);

            using (var br = new BinaryReader(IncrementIndexAndGetMemoryStreamAt(operationData, ref index)))
            {
                // Metadata section.
                var startingPosition = br.BaseStream.Position;
                var sizeOfSection    = br.ReadInt32();
                var endPosition      = startingPosition + sizeOfSection;

                // Read Metadata fields
                this.isRedoOnly = br.ReadBoolean();

                // Jump to the end of the section ignoring fields that are not understood.
                Utility.Assert(endPosition >= br.BaseStream.Position, "Could not have read more than section size.");
                br.BaseStream.Position = endPosition;
            }

            if (this.isRedoOnly)
            {
                this.Transaction = AtomicRedoOperation.CreateAtomicRedoOperation(this.Transaction.Id, true);
            }

            this.metaData = ReadOperationData(operationData, ref index);
            this.redo     = ReadOperationData(operationData, ref index);

            if (!this.isRedoOnly)
            {
                this.undo = ReadOperationData(operationData, ref index);
            }

            this.UpdateApproximateDiskSize();
        }
Exemplo n.º 3
0
        public async Task <long> AddOperationAsync(
            AtomicRedoOperation atomicRedoOperation,
            OperationData metaData,
            OperationData redo,
            object operationContext)
        {
            var record = new OperationLogRecord(atomicRedoOperation, metaData, redo, operationContext);

            await this.ProcessLogicalRecordOnPrimaryAsync(record).ConfigureAwait(false);

            return(record.Lsn.LSN);
        }
 /// <summary>
 /// Called when state providers need to replicate their redo only operation and when local state needs to be replicated.
 /// </summary>
 Task <long> ITransactionalReplicator.AddOperationAsync(
     AtomicRedoOperation atomicRedoOperation,
     OperationData metaData,
     OperationData redo,
     object operationContext,
     long stateProviderId)
 {
     return(this.stateManager.AddOperationAsync(
                atomicRedoOperation,
                metaData,
                redo,
                operationContext,
                stateProviderId));
 }