Example #1
0
        internal static void Assert(bool condition, string format, RecordProcessingMode param1)
        {
            if (condition == false)
            {
                var failFastMessage = string.Format(System.Globalization.CultureInfo.InvariantCulture, format, param1);
                FailFast(failFastMessage);

                // AMW - Force break into debugger for ease of debugging
                Debugger.Break();
            }
        }
Example #2
0
        private void PrepareToProcessRecord(LogRecord record, RecordProcessingMode processingMode)
        {
            Utility.Assert(
                processingMode < RecordProcessingMode.ProcessImmediately,
                "processingMode < RecordProcessingMode.ProcessImmediately");

            var logicalRecord = record as LogicalLogRecord;

            if (logicalRecord != null)
            {
                this.processor.PrepareToProcessLogicalRecord();
            }
            else
            {
                this.processor.PrepareToProcessPhysicalRecord();
            }
        }
Example #3
0
        public async Task ImmediatelyProcessRecord(
            LogRecord record,
            Exception flushException,
            RecordProcessingMode processingMode)
        {
            Utility.Assert(
                processingMode > RecordProcessingMode.Normal,
                "processingMode ({0}) > RecordProcessingMode.Normal",
                processingMode);

            // TODO: Temporary double check.
            Utility.Assert(record.RecordType != LogRecordType.Backup, "record.RecordType != LogRecordType.Backup");

            Exception exception = null;

            if (flushException != null)
            {
                Utility.Assert(
                    this.logException != null,
                    "FlushException is {0} and this.logException is null",
                    flushException);
                exception = flushException;
            }

            // In case there was an apply failure, we should fault any further applies of any records.
            // Without this, we could end up assuming that all applies have succeeded and as a result, issue a checkpoint call
            if (exception == null)
            {
                exception = this.serviceException;
            }

            FabricEvents.Events.RecordProcessedImmediatelyNoise(
                this.tracer.Type,
                (int)this.roleContextDrainState.DrainingStream,
                record.Psn.PSN);

            var information = string.Empty;

            switch (record.RecordType)
            {
            case LogRecordType.TruncateHead:
                this.checkpointManager.ApplyLogHeadTruncationIfPermitted(exception, record);
                break;

            case LogRecordType.BeginCheckpoint:
                if (processingMode == RecordProcessingMode.ProcessImmediately)
                {
                    goto default;
                }

                await this.checkpointManager.ApplyCheckpointIfPermitted(exception, record).ConfigureAwait(false);

                break;

            case LogRecordType.Information:
                information = '-' + ((InformationLogRecord)record).InformationEvent.ToString();
                goto case LogRecordType.EndCheckpoint;

            case LogRecordType.EndCheckpoint:
            case LogRecordType.TruncateTail:
            case LogRecordType.Indexing:
            case LogRecordType.UpdateEpoch:
                goto default;

            default:
                record.CompletedApply(exception);
                break;
            }

            if (processingMode == RecordProcessingMode.ProcessImmediately)
            {
                FabricEvents.Events.RecordProcessedImmediately(
                    this.tracer.Type,
                    (int)this.roleContextDrainState.DrainingStream,
                    information,
                    record.Psn.PSN);

                record.CompletedProcessing(null);
            }

            return;
        }