Esempio n. 1
0
 protected void TestGeneralSyncHealth()
 {
     try
     {
         EdgeSyncRecord edgeSyncRecord = this.TestSyncHealth(this.DomainController);
         if (this.MonitoringContext)
         {
             this.ReportMomStatus(edgeSyncRecord);
         }
         base.WriteObject(edgeSyncRecord);
     }
     catch (TransientException exception)
     {
         this.WriteErrorAndMonitoringEvent(exception, ExchangeErrorCategory.ServerOperation, null, 1003, this.CmdletMonitoringEventSource);
     }
     catch (ADOperationException exception2)
     {
         this.WriteErrorAndMonitoringEvent(exception2, ExchangeErrorCategory.ServerOperation, null, 1003, this.CmdletMonitoringEventSource);
     }
     catch (IOException exception3)
     {
         this.WriteErrorAndMonitoringEvent(exception3, ExchangeErrorCategory.ServerOperation, null, 1003, this.CmdletMonitoringEventSource);
     }
     finally
     {
         if (this.MonitoringContext)
         {
             base.WriteObject(this.monitoringData);
         }
     }
 }
Esempio n. 2
0
        private void ReportMomStatus(EdgeSyncRecord record)
        {
            int eventIdentifier            = 1000;
            EventTypeEnumeration eventType = EventTypeEnumeration.Success;

            switch (record.Status)
            {
            case ValidationStatus.NoSyncConfigured:
                eventIdentifier = 1005;
                eventType       = EventTypeEnumeration.Warning;
                break;

            case ValidationStatus.Warning:
                eventIdentifier = 1001;
                eventType       = EventTypeEnumeration.Warning;
                break;

            case ValidationStatus.Failed:
                eventIdentifier = 1002;
                eventType       = EventTypeEnumeration.Error;
                break;

            case ValidationStatus.Inconclusive:
                eventIdentifier = 1004;
                eventType       = EventTypeEnumeration.Information;
                break;

            case ValidationStatus.FailedUrgent:
                eventIdentifier = 1006;
                eventType       = EventTypeEnumeration.Error;
                break;
            }
            MonitoringEvent item = new MonitoringEvent(this.CmdletMonitoringEventSource, eventIdentifier, eventType, record.ToString());

            this.monitoringData.Events.Add(item);
        }
Esempio n. 3
0
        private EdgeSyncRecord TestSyncHealth(string domainController)
        {
            ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 383, "TestSyncHealth", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\EdgeSync\\TestEdgeSyncBase.cs");
            ADSite localSite             = null;
            EdgeSyncServiceConfig config = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                localSite = session.GetLocalSite();
                if (localSite == null)
                {
                    throw new TransientException(Strings.CannotGetLocalSite);
                }
                config = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService"));
            }, 3);
            if (config == null)
            {
                return(EdgeSyncRecord.GetEdgeSyncServiceNotConfiguredForCurrentSiteRecord(this.Service, localSite.Name));
            }
            bool   flag = false;
            string primaryLeaseFilePath;
            string backupLeaseFilePath;

            if (!this.ReadConnectorLeasePath(session, config.Id, out primaryLeaseFilePath, out backupLeaseFilePath, out flag))
            {
                if (!flag)
                {
                    return(EdgeSyncRecord.GetEdgeSyncConnectorNotConfiguredForEntireForestRecord(this.Service));
                }
                return(EdgeSyncRecord.GetEdgeSyncConnectorNotConfiguredForCurrentSiteRecord(this.Service, localSite.Name));
            }
            else
            {
                string     additionalInfo = null;
                LeaseToken lease          = TestEdgeSyncBase.GetLease(primaryLeaseFilePath, backupLeaseFilePath, out additionalInfo);
                if (lease.NotHeld)
                {
                    return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "There is no lease file detected. It suggests synchronization has not started at all.", lease, null, additionalInfo));
                }
                Cookie cookie = null;
                string text   = null;
                if (!this.TryGetNewestCookieFromAllDomainControllers(out cookie, out text))
                {
                    throw new InvalidOperationException("Failed accessing all DCs: " + text);
                }
                if (cookie == null)
                {
                    return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "There is no cookie detected. It suggests we haven't had a single successful synchronization.", lease, null, text));
                }
                EnhancedTimeSpan syncInterval = this.GetSyncInterval(config);
                switch (lease.Type)
                {
                case LeaseTokenType.Lock:
                    if (DateTime.UtcNow > lease.AlertTime)
                    {
                        return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization has completely stopped because lock has expired. It suggests the EdgeSync service died in the middle of the synchronization and no other service instance has taken over.", lease, cookie, text, true));
                    }
                    if (DateTime.UtcNow > cookie.LastUpdated + config.OptionDuration + 3L * syncInterval + TimeSpan.FromHours(1.0))
                    {
                        return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Cookie has not been updated as expected. It might be caused by failure to synchronize some items which means that the sychronization might still be running but not efficiently. It might also be caused by a long full sync. Check EdgeSync log for further troubleshooting.", lease, cookie, text));
                    }
                    return(EdgeSyncRecord.GetInconclusiveRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization status is inconclusive because EdgeSync is in the middle of synchronizing data. Try running this cmdlet again later.", lease, cookie, text));

                case LeaseTokenType.Option:
                    if (DateTime.UtcNow > lease.AlertTime)
                    {
                        return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization has completely stopped. We have failed to failover to another instance within the same AD site or to another AD site.", lease, cookie, text, true));
                    }
                    if (DateTime.UtcNow > cookie.LastUpdated + config.FailoverDCInterval + TimeSpan.FromMinutes(30.0))
                    {
                        return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Cookie has not been updated as expected. It might be caused by failure to synchronize some items which means that the sychronization might still be running but not efficiently. It might also be caused by a long full sync. Check EdgeSync log for further troubleshooting.", lease, cookie, text));
                    }
                    return(EdgeSyncRecord.GetNormalRecord(this.Service, "The synchronization is operating normally.", lease, cookie, text));

                default:
                    throw new ArgumentException("Unknown lease type: " + lease.Type);
                }
            }
        }