public async Task RunAsync(int primaryEpoch, CancellationToken token) { if (primaryEpoch < 0) { throw new ArgumentOutOfRangeException("primaryEpoch"); } if (!this.TryStartRunAsync()) { throw new InvalidOperationException("Coordinator has already been started"); } try { if (primaryEpoch < this.primaryEpoch) { throw new ArgumentException("Primary epoch must be non-decreasing", "primaryEpoch"); } if (this.primaryEpoch < primaryEpoch) { this.nextSequenceNumber = 0; } coordinatorCommandProcessor.Reset(); coordinatorRunAsyncStartTime = DateTimeOffset.UtcNow; coordinatorCommandProcessor.CoordinatorDiagnosticInfo = new CoordinatorDiagnosticInfo { CoordinatorStartTime = "{0:o}".ToString(coordinatorRunAsyncStartTime), AzureTenantId = this.tenantId, AssemblyFileVersion = this.assemblyFileVersion, }; this.primaryEpoch = primaryEpoch; traceType.WriteInfo("RunAsync: primaryEpoch = 0x{0:X}, nextSequenceNumber = 0x{1:X}", this.primaryEpoch, this.nextSequenceNumber); traceType.WriteAggregatedEvent( InfrastructureService.Constants.CoordinatorModeKey, this.tenantId, "{0}", new CoordinatorStateData().Mode); this.isNotificationAvailable = false; this.lastHealthIncarnation = 0; this.lastHealthIncarnationUpdatedAt = null; this.repairActionProvider = new RepairActionProvider(configSection); ActionHelper.ResetActionPolicies(actionPolicies); // Clear old AzureSerial health property ClearLegacyNotificationApprovalHealthStatus(); await StartJobTaskAsync(token).ConfigureAwait(false); } finally { this.CompleteRunAsync(); } }