Exemplo n.º 1
0
        private void SaveEdgeConnection(EdgeConnectionInfo subscription)
        {
            this.currentEdgeConnection = subscription;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 751, "SaveEdgeConnection", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ConfigValidator.cs");
            EdgeSyncServiceConfig         edgeSyncServiceConfig        = topologyConfigurationSession.Read <EdgeSyncServiceConfig>(topologyConfigurationSession.GetLocalSite().Id.GetChildId("EdgeSyncService"));

            this.syncInScheduleWindow = (edgeSyncServiceConfig.ConfigurationSyncInterval > DateTime.UtcNow.Subtract(subscription.LastSynchronizedDate));
        }
Exemplo n.º 2
0
        public static bool TryLoadLocalSiteTopology(string domainController, out ReplicationTopology topology, out Exception exception)
        {
            topology  = null;
            exception = null;
            ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 154, "TryLoadLocalSiteTopology", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ReplicationTopology.cs");
            ADSite localSite = null;
            EdgeSyncServiceConfig edgeSyncServiceConfig = null;
            ADOperationResult     adoperationResult     = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                localSite = session.GetLocalSite();
                if (localSite == null)
                {
                    throw new ADTransientException(Strings.CannotGetLocalSite);
                }
                edgeSyncServiceConfig = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService"));
            }, 3);

            if (!adoperationResult.Succeeded)
            {
                exception = adoperationResult.Exception;
                return(false);
            }
            if (edgeSyncServiceConfig == null)
            {
                topology = new ReplicationTopology(session, null, localSite, null);
                return(true);
            }
            ReplicationTopology resultTopology = null;

            adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                Server server      = session.FindLocalServer();
                resultTopology     = new ReplicationTopology(session, server, localSite, edgeSyncServiceConfig);
                QueryFilter filter = Util.BuildServerFilterForSite(localSite.Id);
                ADPagedReader <Server> adpagedReader = session.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0);
                resultTopology.siteEdgeServers.Clear();
                resultTopology.siteHubServers.Clear();
                foreach (Server server2 in adpagedReader)
                {
                    if (server2.IsEdgeServer)
                    {
                        resultTopology.siteEdgeServers.Add(server2);
                    }
                    if (server2.IsHubTransportServer)
                    {
                        resultTopology.siteHubServers.Add(server2);
                    }
                }
            }, 3);
            if (!adoperationResult.Succeeded)
            {
                exception = adoperationResult.Exception;
                return(false);
            }
            topology = resultTopology;
            return(true);
        }
Exemplo n.º 3
0
 protected abstract EnhancedTimeSpan GetSyncInterval(EdgeSyncServiceConfig config);
Exemplo n.º 4
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);
                }
            }
        }
Exemplo n.º 5
0
 protected override EnhancedTimeSpan GetSyncInterval(EdgeSyncServiceConfig config)
 {
     return(config.RecipientSyncInterval);
 }
Exemplo n.º 6
0
 private ReplicationTopology(IConfigurationSession configSession, Server localHub, ADSite localSite, EdgeSyncServiceConfig edgeSyncServiceConfig)
 {
     this.configSession         = configSession;
     this.localHub              = localHub;
     this.localSite             = localSite;
     this.edgeSyncServiceConfig = edgeSyncServiceConfig;
 }
 // Token: 0x0600098F RID: 2447 RVA: 0x00020DF0 File Offset: 0x0001EFF0
 public EdgeSyncServiceConfigIdParameter(EdgeSyncServiceConfig edgeSyncServiceConfig) : base(edgeSyncServiceConfig.Id)
 {
 }
Exemplo n.º 8
0
 protected override EnhancedTimeSpan GetSyncInterval(EdgeSyncServiceConfig config)
 {
     return(config.ConfigurationSyncInterval);
 }