public static TADWrapperObject FindAdObjectWithQueryStatic(IADToplogyConfigurationSession adSession, QueryFilter queryFilter)
        {
            TADWrapperObject answer = default(TADWrapperObject);
            Exception ex = ADUtils.RunADOperation(delegate()
            {
                TADWrapperObject[] array = adSession.Find <TADWrapperObject>(null, QueryScope.SubTree, queryFilter, null, 2);
                if (array.Length > 1)
                {
                    SimpleAdObjectLookup <TADWrapperObject> .Tracer.TraceError <QueryFilter, TADWrapperObject, TADWrapperObject>(0L, "FindAdObjectWithQueryStatic found multiple objects with query '{0}'! The first two are '{1}' and '{2}'.", queryFilter, array[0], array[1]);
                    answer = array[(Environment.TickCount & int.MaxValue) % 2];
                    return;
                }
                if (array.Length == 0)
                {
                    SimpleAdObjectLookup <TADWrapperObject> .Tracer.TraceError <QueryFilter>(0L, "FindAdObjectWithQueryStatic found no objects with query '{0}'!", queryFilter);
                    return;
                }
                answer = array[0];
            }, 2);

            if (ex != null)
            {
                SimpleAdObjectLookup <TADWrapperObject> .Tracer.TraceError <Exception>(0L, "FindAdObjectWithQueryStatic got an exception: {0}", ex);
            }
            return(answer);
        }
Example #2
0
        private ActiveManager(bool enableRpcCaching, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADServer> serverLookup, IFindMiniServer miniServerLookup, IFindAdObject <IADClientAccessArray> casLookup, IFindMiniClientAccessServerOrArray miniCasArrayLookup, IFindAdObject <IADDatabase> databaseLookup, ITopologyConfigurationSession adSession, bool isService)
        {
            ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <bool>((long)this.GetHashCode(), "Active Manager is instantiated (cacheEnabled={0})", enableRpcCaching);
            if (adSession == null)
            {
                throw new ArgumentNullException("adSession");
            }
            IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession);

            this.m_isCacheEnabled = enableRpcCaching;
            this.m_adSession      = adSession;
            this.m_disposeTracker = this.GetDisposeTracker();
            if (this.m_isCacheEnabled)
            {
                this.m_dagLookup          = (dagLookup ?? new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession2, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .TimeToLive, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .AdOperationTimeout));
                this.m_casLookup          = (casLookup ?? new AdObjectLookupCache <IADClientAccessArray>(adSession2, AdObjectLookupCache <IADClientAccessArray> .TimeToLive, AdObjectLookupCache <IADClientAccessArray> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADClientAccessArray> .AdOperationTimeout));
                this.m_miniServerLookup   = (miniServerLookup ?? new MiniServerLookupCache(adSession2, MiniServerLookupCache.TimeToLive, MiniServerLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniServerLookupCache.AdOperationTimeout));
                this.m_miniCasArrayLookup = (miniCasArrayLookup ?? new MiniClientAccessServerOrArrayLookupCache(this.m_adSession, MiniClientAccessServerOrArrayLookupCache.TimeToLive, MiniClientAccessServerOrArrayLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniClientAccessServerOrArrayLookupCache.AdOperationTimeout));
                this.m_databaseLookup     = (databaseLookup ?? new AdObjectLookupCache <IADDatabase>(adSession2, AdObjectLookupCache <IADDatabase> .TimeToLive, AdObjectLookupCache <IADDatabase> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabase> .AdOperationTimeout));
                if (!isService)
                {
                    this.EnableMinimization();
                }
            }
            else
            {
                this.m_dagLookup          = (dagLookup ?? new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession2));
                this.m_casLookup          = (casLookup ?? new SimpleAdObjectLookup <IADClientAccessArray>(adSession2));
                this.m_miniServerLookup   = (miniServerLookup ?? new SimpleMiniServerLookup(adSession2));
                this.m_miniCasArrayLookup = (miniCasArrayLookup ?? new SimpleMiniClientAccessServerOrArrayLookup(this.m_adSession));
                this.m_databaseLookup     = (databaseLookup ?? new SimpleAdObjectLookup <IADDatabase>(adSession2));
            }
            this.CacheUpdateInterval  = new TimeSpan(0, 0, 60);
            this.m_isRunningInService = isService;
        }
        public static IADDatabase[] GetAllDatabases(IADToplogyConfigurationSession adSession, IFindAdObject <IADDatabase> databaseLookup, MiniServer miniServer, out Exception exception)
        {
            IADDatabaseCopy[] copies       = null;
            QueryFilter       serverFilter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, miniServer.Name);

            exception = ADUtils.RunADOperation(delegate()
            {
                copies = adSession.Find <IADDatabaseCopy>(null, QueryScope.SubTree, serverFilter, null, 0);
            }, 2);
            if (exception != null)
            {
                return(null);
            }
            List <IADDatabase> list = new List <IADDatabase>(20);

            foreach (IADDatabaseCopy iaddatabaseCopy in copies)
            {
                ADObjectId  parent      = iaddatabaseCopy.Id.Parent;
                IADDatabase iaddatabase = databaseLookup.ReadAdObjectByObjectIdEx(parent, out exception);
                if (exception != null)
                {
                    return(null);
                }
                if (iaddatabase != null)
                {
                    list.Add(iaddatabase);
                }
            }
            return((list.Count > 0) ? list.ToArray() : null);
        }
        public static List <string> GetServersWithServerRoleInSite(string serverName, ServerRole serverRole)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IADServer iadserver = null;

            if (!string.IsNullOrEmpty(serverName))
            {
                if (!SharedHelper.StringIEquals(serverName, "localhost"))
                {
                    goto IL_2F;
                }
            }
            try
            {
                iadserver = iadtoplogyConfigurationSession.FindServerByName(Environment.MachineName);
                goto IL_5A;
            }
            catch (LocalServerNotFoundException)
            {
                goto IL_5A;
            }
IL_2F:
            string nodeNameFromFqdn = MachineName.GetNodeNameFromFqdn(serverName);

            iadserver = iadtoplogyConfigurationSession.FindServerByName(nodeNameFromFqdn);
            string arg = "FindServerByName";

            if (iadserver == null)
            {
                ExTraceGlobals.ReplayConfigurationTracer.TraceDebug <string, string>(0L, "GetServersWithServerRoleInSite: {0} didn't find any server for {1}", arg, serverName);
            }
IL_5A:
            return(ReplayConfiguration.GetServersWithServerRoleInSiteByServer(iadserver, serverRole));
        }
Example #5
0
        // Token: 0x060000AB RID: 171 RVA: 0x00004F20 File Offset: 0x00003120
        protected override void RunInternal()
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IADServer iadserver = iadtoplogyConfigurationSession.FindServerByName(this.m_nodeName.NetbiosName);

            if (iadserver == null)
            {
                throw new ServerNotFoundException(this.m_nodeName.NetbiosName);
            }
            IADDatabase[] array = iadtoplogyConfigurationSession.GetAllDatabases(iadserver).ToArray <IADDatabase>();
            if (array.Length <= 0)
            {
                AmTrace.Info("Server '{0}' does not have any databases that needs to be marked as dismounted", new object[]
                {
                    this.m_nodeName
                });
                return;
            }
            AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.SyncState);

            foreach (IADDatabase db in array)
            {
                AmDbClusterDatabaseSyncOperation operation = new AmDbClusterDatabaseSyncOperation(db, actionCode);
                this.m_clusDbSyncRequests++;
                base.EnqueueDatabaseOperation(operation);
            }
            base.StartDatabaseOperations();
        }
        private bool CleanupDatabases(IADToplogyConfigurationSession adSession, IClusterDB clusdb, HashSet <Guid> dbGuidsToDelete, HashSet <Guid> validDatabaseGuids)
        {
            if (validDatabaseGuids.Count == 0)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupSkipped.Log <string, string>("Database", "Could not find a single valid database in cached list");
                return(false);
            }
            if (adSession.FindDatabaseByGuid(validDatabaseGuids.First <Guid>()) == null)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupSkipped.Log <string, string>("Database", "Could not find a single valid database in AD");
                return(false);
            }
            bool result = false;

            try
            {
                this.RemoveStaleDatabaseGuids(clusdb, dbGuidsToDelete);
                dbGuidsToDelete.ExceptWith(this.staleDatabases);
                result = true;
            }
            catch (Exception ex)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupFailed.Log <string, string>("Database", ex.ToString());
            }
            this.staleDatabases = dbGuidsToDelete;
            return(result);
        }
        private bool CleanupServers(IADToplogyConfigurationSession adSession, IClusterDB clusdb, HashSet <Guid> serverGuids, Dictionary <Guid, IADServer> validServers)
        {
            if (validServers.Count == 0)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupSkipped.Log <string, string>("Server", "Could not find a single valid server in the cached list");
                return(false);
            }
            IADServer value = validServers.First <KeyValuePair <Guid, IADServer> >().Value;

            if (adSession.FindServerByName(value.Name) == null)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupSkipped.Log <string, string>("Server", "Could not find a single valid server in AD");
                return(false);
            }
            bool result = false;

            try
            {
                this.RemoveStaleServerGuids(clusdb, serverGuids);
                serverGuids.ExceptWith(this.staleServers);
                result = true;
            }
            catch (Exception ex)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupFailed.Log <string, string>("Server", ex.ToString());
            }
            this.staleServers = serverGuids;
            return(result);
        }
Example #8
0
        private static IADSite RetrieveLocalSite(IADToplogyConfigurationSession session)
        {
            if (ActiveManagerImplementation.cachedLocalSite != null)
            {
                if (!(DateTime.UtcNow > ActiveManagerImplementation.localSiteExpiration))
                {
                    goto IL_77;
                }
            }
            try
            {
                ActiveManagerImplementation.Tracer.TraceDebug(0L, "RetrieveLocalSite: either the local site is null, or it's time to refresh the value.");
                ActiveManagerImplementation.cachedLocalSite     = session.GetLocalSite();
                ActiveManagerImplementation.localSiteExpiration = DateTime.UtcNow.Add(ActiveManagerImplementation.c_timeSpanSiteExpiration);
            }
            catch (ADTransientException arg)
            {
                ActiveManagerImplementation.Tracer.TraceError <ADTransientException>(0L, "GetLocalSite() threw an ADTransientException: {0}", arg);
            }
            catch (CannotGetSiteInfoException arg2)
            {
                ActiveManagerImplementation.Tracer.TraceError <CannotGetSiteInfoException>(0L, "GetLocalSite() threw a CannotGetSiteInfoException: {0}", arg2);
            }
IL_77:
            return(ActiveManagerImplementation.cachedLocalSite);
        }
        internal static void UpdateServerLegdnForDatabaseSite(Task.TaskErrorLoggingDelegate writeErrorDelegate, Task.TaskVerboseLoggingDelegate writeVerboseDelegate, ITopologyConfigurationSession adSession, DatabaseCopy dbCopy)
        {
            ADObjectId hostServer = dbCopy.HostServer;

            PropertyDefinition[] properties = new PropertyDefinition[]
            {
                ServerSchema.ServerSite
            };
            MiniServer miniServer = adSession.ReadMiniServer(hostServer, properties);

            if (miniServer == null)
            {
                writeErrorDelegate(new ADServerNotFoundException(hostServer.ToString()), ErrorCategory.InvalidArgument, null);
            }
            IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession);
            SimpleAdObjectLookup <IADClientAccessArray> findClientAccessArray      = new SimpleAdObjectLookup <IADClientAccessArray>(adSession2);
            SimpleMiniClientAccessServerOrArrayLookup   findMiniClientAccessServer = new SimpleMiniClientAccessServerOrArrayLookup(adSession);
            ADObjectId serverSite = miniServer.ServerSite;
            LegacyDN   legacyDN   = ActiveManagerImplementation.FindClientAccessArrayOrServerFromSite(serverSite, miniServer.Id, findClientAccessArray, findMiniClientAccessServer, AdObjectLookupFlags.ReadThrough);
            ADObjectId parent     = dbCopy.Id.Parent;
            Database   database   = adSession.Read <Database>(parent);

            if (legacyDN != null)
            {
                LegacyDN databaseLegacyDNFromRcaLegacyDN = Database.GetDatabaseLegacyDNFromRcaLegacyDN(legacyDN, database.IsPublicFolderDatabase);
                database.ExchangeLegacyDN = databaseLegacyDNFromRcaLegacyDN.ToString();
                writeVerboseDelegate(Strings.UpdatingLegDnForDatabaseToServer(database.Name, legacyDN.ToString(), legacyDN.ToString()));
                adSession.Save(database);
                return;
            }
            ExTraceGlobals.CmdletsTracer.TraceDebug <ADObjectId>(0L, "Could not find a new CAS machines for site '{0}'. Leaving the database's legdn unchanged.", serverSite);
        }
Example #10
0
        public static void TaskConstructAllDatabaseConfigurations(IADDatabaseAvailabilityGroup dag, IADServer server, out List <ReplayConfiguration> activeConfigurations, out List <ReplayConfiguration> passiveConfigurations)
        {
            activeConfigurations  = new List <ReplayConfiguration>(20);
            passiveConfigurations = new List <ReplayConfiguration>(48);
            ActiveManager noncachingActiveManagerInstance = ActiveManager.GetNoncachingActiveManagerInstance();
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IEnumerable <IADDatabase>      allDatabases = iadtoplogyConfigurationSession.GetAllDatabases(server);

            if (allDatabases != null)
            {
                foreach (IADDatabase mdb in allDatabases)
                {
                    bool                flag;
                    Exception           ex;
                    ReplayConfiguration replayConfiguration = ReplayConfiguration.GetReplayConfiguration(dag, mdb, server, noncachingActiveManagerInstance, out flag, out ex);
                    if (replayConfiguration != null)
                    {
                        if (flag)
                        {
                            activeConfigurations.Add(replayConfiguration);
                        }
                        else
                        {
                            passiveConfigurations.Add(replayConfiguration);
                        }
                    }
                }
            }
        }
 public MiniServerLookupCache(IADToplogyConfigurationSession adSession, TimeSpan timeToLive, TimeSpan timeToNegativeLive, TimeSpan cacheLockTimeout, TimeSpan adOperationTimeout, TimeSpan maximumCacheTimeout)
 {
     this.AdSession            = adSession;
     this.m_timeToLive         = timeToLive;
     this.m_timeToNegativeLive = timeToNegativeLive;
     this.m_cacheLockTimeout   = cacheLockTimeout;
     this.m_adOperationTimeout = adOperationTimeout;
     this.m_maximumTimeToLive  = maximumCacheTimeout;
 }
Example #12
0
        public static IADDatabaseAvailabilityGroup GetLocalServerDatabaseAvailabilityGroup(out string errorMessage)
        {
            IADDatabaseAvailabilityGroup iaddatabaseAvailabilityGroup = null;
            Exception ex = null;

            errorMessage = string.Empty;
            try
            {
                IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
                IADServer iadserver = iadtoplogyConfigurationSession.FindServerByName(Dependencies.ManagementClassHelper.LocalMachineName);
                if (iadserver != null)
                {
                    iaddatabaseAvailabilityGroup = iadtoplogyConfigurationSession.FindDagByServer(iadserver);
                    if (iaddatabaseAvailabilityGroup == null)
                    {
                        ex = new CouldNotFindDagObjectForServer(iadserver.Name);
                    }
                }
                else
                {
                    ex = new CouldNotFindServerObject(Environment.MachineName);
                }
            }
            catch (ADTransientException ex2)
            {
                AmTrace.Error("GetLocalServerDatabaseAvailabilityGroup got exception: {0}", new object[]
                {
                    ex2
                });
                ex = ex2;
            }
            catch (ADExternalException ex3)
            {
                AmTrace.Error("GetLocalServerDatabaseAvailabilityGroup got exception: {0}", new object[]
                {
                    ex3
                });
                ex = ex3;
            }
            catch (ADOperationException ex4)
            {
                AmTrace.Error("GetLocalServerDatabaseAvailabilityGroup got exception: {0}", new object[]
                {
                    ex4
                });
                ex = ex4;
            }
            if (iaddatabaseAvailabilityGroup == null)
            {
                errorMessage = ex.Message;
                if (string.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = ex.ToString();
                }
            }
            return(iaddatabaseAvailabilityGroup);
        }
Example #13
0
 // Token: 0x060014FF RID: 5375 RVA: 0x00052E79 File Offset: 0x00051079
 protected MonitoringADConfig(AmServerName serverName, IReplayAdObjectLookup adLookup, IReplayAdObjectLookup adLookupPartiallyConsistent, IADToplogyConfigurationSession adSession, IADToplogyConfigurationSession adSessionPartiallyConsistent, Func <bool> isServiceShuttingDownFunc)
 {
     this.m_targetServerName           = serverName;
     this.AdLookup                     = adLookup;
     this.AdLookupPartiallyConsistent  = adLookupPartiallyConsistent;
     this.AdSessionIgnoreInvalid       = adSession;
     this.AdSessionPartiallyConsistent = adSessionPartiallyConsistent;
     this.m_isServiceShuttingDownFunc  = isServiceShuttingDownFunc;
 }
Example #14
0
        public void DoDumpsterRedeliveryIfRequired(Guid dbGuid)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreatePartiallyConsistentRootOrgSession(true);
            IADDatabase db     = iadtoplogyConfigurationSession.FindDatabaseByGuid(dbGuid);
            IADServer   server = iadtoplogyConfigurationSession.FindServerByName(Environment.MachineName);
            IADDatabaseAvailabilityGroup dag          = iadtoplogyConfigurationSession.FindDagByServer(server);
            ReplayConfiguration          replayConfig = RemoteReplayConfiguration.TaskGetReplayConfig(dag, db, server);

            DumpsterRedeliveryWrapper.DoRedeliveryIfRequired(replayConfig);
        }
Example #15
0
        public void TriggerDumpster(Guid dbGuid, DateTime inspectorTime)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreatePartiallyConsistentRootOrgSession(true);
            IADDatabase db     = iadtoplogyConfigurationSession.FindDatabaseByGuid(dbGuid);
            IADServer   server = iadtoplogyConfigurationSession.FindServerByName(Environment.MachineName);
            IADDatabaseAvailabilityGroup dag           = iadtoplogyConfigurationSession.FindDagByServer(server);
            ReplayConfiguration          configuration = RemoteReplayConfiguration.TaskGetReplayConfig(dag, db, server);

            DumpsterRedeliveryWrapper.MarkRedeliveryRequired(configuration, inspectorTime, 0L, 0L);
        }
Example #16
0
        public void TriggerDumpsterEx(Guid dbGuid, bool fTriggerSafetyNet, DateTime failoverTimeUtc, DateTime startTimeUtc, DateTime endTimeUtc, long lastLogGenBeforeActivation, long numLogsLost)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreatePartiallyConsistentRootOrgSession(true);
            IADDatabase db     = iadtoplogyConfigurationSession.FindDatabaseByGuid(dbGuid);
            IADServer   server = iadtoplogyConfigurationSession.FindServerByName(Environment.MachineName);
            IADDatabaseAvailabilityGroup dag           = iadtoplogyConfigurationSession.FindDagByServer(server);
            ReplayConfiguration          configuration = RemoteReplayConfiguration.TaskGetReplayConfig(dag, db, server);

            DumpsterRedeliveryWrapper.MarkRedeliveryRequired(configuration, failoverTimeUtc, startTimeUtc, endTimeUtc, lastLogGenBeforeActivation, numLogsLost);
        }
        // Token: 0x06000087 RID: 135 RVA: 0x000045F4 File Offset: 0x000027F4
        protected IADDatabase[] GetDatabases()
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IADServer iadserver = iadtoplogyConfigurationSession.FindServerByName(this.m_nodeName.NetbiosName);

            if (iadserver == null)
            {
                throw new ServerNotFoundException(this.m_nodeName.NetbiosName);
            }
            return(iadtoplogyConfigurationSession.GetAllDatabases(iadserver).ToArray <IADDatabase>());
        }
        protected void Initialize(ConsistencyMode adConsistencyMode)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(adConsistencyMode, ADSessionSettings.FromRootOrgScopeSet(), 92, "Initialize", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Replay\\Service\\NoncachingReplayAdObjectLookup.cs");

            this.AdSession = topologyConfigurationSession;
            IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession);

            this.DagLookup        = new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession);
            this.DatabaseLookup   = new SimpleAdObjectLookup <IADDatabase>(adSession);
            this.ServerLookup     = new SimpleAdObjectLookup <IADServer>(adSession);
            this.MiniServerLookup = new SimpleMiniServerLookup(adSession);
        }
Example #19
0
        internal static void GetDatabaseNameAndPath(Guid databaseGuid, out string databaseName, out string databaseFilePath)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateFullyConsistentRootOrgSession(true);
            IADDatabase iaddatabase = iadtoplogyConfigurationSession.FindDatabaseByGuid(databaseGuid);

            databaseName = iaddatabase.Name;
            if (iaddatabase.EdbFilePath != null)
            {
                databaseFilePath = iaddatabase.EdbFilePath.ToString();
                return;
            }
            databaseFilePath = null;
        }
Example #20
0
        // Token: 0x06001E72 RID: 7794 RVA: 0x0008A730 File Offset: 0x00088930
        protected void Initialize(ConsistencyMode adConsistencyMode)
        {
            ITopologyConfigurationSession  topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(adConsistencyMode, ADSessionSettings.FromRootOrgScopeSet(), 101, "Initialize", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Replay\\Service\\ReplayAdObjectLookup.cs");
            IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession);
            TimeSpan timeToLive         = TimeSpan.FromSeconds((double)RegistryParameters.AdObjectCacheHitTtlInSec);
            TimeSpan timeToNegativeLive = TimeSpan.FromSeconds((double)RegistryParameters.AdObjectCacheMissTtlInSec);

            this.AdSession        = topologyConfigurationSession;
            this.DagLookup        = new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession, timeToLive, timeToNegativeLive);
            this.DatabaseLookup   = new AdObjectLookupCache <IADDatabase>(adSession, timeToLive, timeToNegativeLive);
            this.ServerLookup     = new AdObjectLookupCache <IADServer>(adSession, timeToLive, timeToNegativeLive);
            this.MiniServerLookup = new MiniServerLookupCache(adSession, timeToLive, timeToNegativeLive);
        }
Example #21
0
        internal static IADMiniClientAccessServerOrArray FindMiniCasOrArrayByFqdn(IADToplogyConfigurationSession cdsAdSession, string serverFqdn)
        {
            IADMiniClientAccessServerOrArray returnObj = null;
            Exception ex = ADUtils.RunADOperation(delegate()
            {
                returnObj = cdsAdSession.FindMiniClientAccessServerOrArrayByFqdn(serverFqdn);
            }, 2);

            if (ex != null)
            {
                SimpleMiniClientAccessServerOrArrayLookup.Tracer.TraceDebug <Exception>(0L, "SimpleMiniClientAccessServerOrArrayLookup.FindMiniCasOrArrayByFqdn got an exception: {0}", ex);
            }
            return(returnObj);
        }
Example #22
0
        public static ActiveManager CreateCustomActiveManager(bool cacheRpcRequests, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADServer> serverLookup, IFindMiniServer miniServerLookup, IFindAdObject <IADClientAccessArray> casLookup, IFindMiniClientAccessServerOrArray miniCasArrayLookup, IFindAdObject <IADDatabase> databaseLookup, ITopologyConfigurationSession adSession, bool isService)
        {
            if (adSession == null)
            {
                adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 1200, "CreateCustomActiveManager", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ActiveManager\\ActiveManager.cs");
            }
            IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession);

            dagLookup          = (dagLookup ?? new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession2));
            serverLookup       = (serverLookup ?? new SimpleAdObjectLookup <IADServer>(adSession2));
            miniServerLookup   = (miniServerLookup ?? new SimpleMiniServerLookup(adSession2));
            casLookup          = (casLookup ?? new SimpleAdObjectLookup <IADClientAccessArray>(adSession2));
            miniCasArrayLookup = (miniCasArrayLookup ?? new SimpleMiniClientAccessServerOrArrayLookup(adSession));
            databaseLookup     = (databaseLookup ?? new SimpleAdObjectLookup <IADDatabase>(adSession2));
            return(new ActiveManager(cacheRpcRequests, dagLookup, serverLookup, miniServerLookup, casLookup, miniCasArrayLookup, databaseLookup, adSession, isService));
        }
Example #23
0
 public static ActiveManager GetNoncachingActiveManagerInstance()
 {
     if (ActiveManager.s_uncachedActiveManager == null)
     {
         lock (ActiveManager.s_singletonLock)
         {
             if (ActiveManager.s_uncachedActiveManager == null)
             {
                 ITopologyConfigurationSession  topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 1023, "GetNoncachingActiveManagerInstance", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ActiveManager\\ActiveManager.cs");
                 IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession);
                 ActiveManager.s_uncachedActiveManager = new ActiveManager(false, new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession), new SimpleAdObjectLookup <IADServer>(adSession), new SimpleMiniServerLookup(adSession), new SimpleAdObjectLookup <IADClientAccessArray>(adSession), new SimpleMiniClientAccessServerOrArrayLookup(topologyConfigurationSession), new SimpleAdObjectLookup <IADDatabase>(adSession), topologyConfigurationSession, false);
                 ActiveManager.s_uncachedActiveManager.SuppressDisposeTracker();
             }
         }
     }
     return(ActiveManager.s_uncachedActiveManager);
 }
Example #24
0
 public static ActiveManager GetCachingActiveManagerInstance()
 {
     if (ActiveManager.s_cachedActiveManager == null)
     {
         lock (ActiveManager.s_singletonLock)
         {
             if (ActiveManager.s_cachedActiveManager == null)
             {
                 ITopologyConfigurationSession  topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 1240, "GetCachingActiveManagerInstance", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ActiveManager\\ActiveManager.cs");
                 IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession);
                 TimeSpan timeSpan = new TimeSpan(0, 0, 45);
                 ActiveManager.s_cachedActiveManager = new ActiveManager(true, new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession, timeSpan, timeSpan, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .AdOperationTimeout), new AdObjectLookupCache <IADServer>(adSession, AdObjectLookupCache <IADServer> .TimeToLive, AdObjectLookupCache <IADServer> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADServer> .AdOperationTimeout), new MiniServerLookupCache(adSession, MiniServerLookupCache.TimeToLive, MiniServerLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniServerLookupCache.AdOperationTimeout), new AdObjectLookupCache <IADClientAccessArray>(adSession, AdObjectLookupCache <IADClientAccessArray> .TimeToLive, AdObjectLookupCache <IADClientAccessArray> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADClientAccessArray> .AdOperationTimeout), new MiniClientAccessServerOrArrayLookupCache(topologyConfigurationSession, MiniClientAccessServerOrArrayLookupCache.TimeToLive, MiniClientAccessServerOrArrayLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniClientAccessServerOrArrayLookupCache.AdOperationTimeout), new AdObjectLookupCache <IADDatabase>(adSession, AdObjectLookupCache <IADDatabase> .TimeToLive, AdObjectLookupCache <IADDatabase> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabase> .AdOperationTimeout), topologyConfigurationSession, false);
                 ActiveManager.s_cachedActiveManager.SuppressDisposeTracker();
             }
         }
     }
     return(ActiveManager.s_cachedActiveManager);
 }
        private void CleanupStaleEntries(IClusterDB clusdb)
        {
            IMonitoringADConfig          config = Dependencies.MonitoringADConfigProvider.GetConfig(true);
            HashSet <Guid>               validDatabaseGuids;
            HashSet <Guid>               databasesToBeDeleted = this.GetDatabasesToBeDeleted(config, clusdb, out validDatabaseGuids);
            Dictionary <Guid, IADServer> validServers;
            HashSet <Guid>               serversToBeDeleted = this.GetServersToBeDeleted(config, clusdb, out validServers);

            if (databasesToBeDeleted.Count == 0 && serversToBeDeleted.Count == 0)
            {
                this.staleDatabases.Clear();
                this.staleServers.Clear();
                return;
            }
            IADToplogyConfigurationSession adSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);

            this.CleanupDatabases(adSession, clusdb, databasesToBeDeleted, validDatabaseGuids);
            this.CleanupServers(adSession, clusdb, serversToBeDeleted, validServers);
        }
Example #26
0
        internal static IADMiniClientAccessServerOrArray FindMiniCasOrArrayByLegdn(IADToplogyConfigurationSession cdsAdSession, string serverLegdn)
        {
            IADMiniClientAccessServerOrArray result = null;
            Exception ex = ADUtils.RunADOperation(delegate()
            {
                bool flag = cdsAdSession.TryFindByExchangeLegacyDN(serverLegdn, out result);
                SimpleMiniClientAccessServerOrArrayLookup.Tracer.TraceDebug <string, bool>(0L, "TryFindByExchangeLegacyDN({0}) returned {1}.", serverLegdn, flag);
                if (!flag)
                {
                    SimpleMiniClientAccessServerOrArrayLookup.Tracer.TraceDebug <string>(0L, "FindMiniCasOrArrayByLegdn: Could not find a MiniServer for the legdn extracted server '{0}'.", serverLegdn);
                }
            }, 2);

            if (ex != null)
            {
                SimpleMiniClientAccessServerOrArrayLookup.Tracer.TraceDebug <Exception>(0L, "SimpleMiniClientAccessServerOrArrayLookup.FindMiniCasOrArrayByLegdn got an exception: {0}", ex);
            }
            return(result);
        }
        public static TADWrapperObject FindAdObjectTypeByGuidStatic(IADToplogyConfigurationSession adSession, Guid objectGuid, IPerformanceDataLogger perfLogger)
        {
            if (objectGuid == Guid.Empty)
            {
                throw new ArgumentException("objectGuid cannot be Empty.");
            }
            TADWrapperObject adObject = default(TADWrapperObject);
            Exception ex = ADUtils.RunADOperation(delegate()
            {
                QueryFilter filter       = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Guid, objectGuid);
                TADWrapperObject[] array = adSession.Find <TADWrapperObject>(null, QueryScope.SubTree, filter, null, 1);
                adObject = ((array != null && array.Length > 0) ? array[0] : default(TADWrapperObject));
            }, perfLogger, 2);

            if (ex != null)
            {
                SimpleAdObjectLookup <TADWrapperObject> .Tracer.TraceError <Exception>(0L, "FindAdObjectTypeByGuidStatic got an exception: {0}", ex);
            }
            return(adObject);
        }
        // Token: 0x0600241D RID: 9245 RVA: 0x000A8E60 File Offset: 0x000A7060
        private IADDatabase LookupDatabase(Guid databaseId)
        {
            IADDatabase db = null;
            Exception   ex = this.DoADAction(delegate(object param0, EventArgs param1)
            {
                IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
                db = iadtoplogyConfigurationSession.FindDatabaseByGuid(databaseId);
            });

            if (db != null)
            {
                return(db);
            }
            ExTraceGlobals.ThirdPartyManagerTracer.TraceDebug <Guid, Exception>(0L, "LookupDatabase({0}) failed. Ex={1}", databaseId, ex);
            if (ex == null)
            {
                throw new NoSuchDatabaseException(databaseId);
            }
            throw ex;
        }
Example #29
0
        // Token: 0x06001511 RID: 5393 RVA: 0x00053854 File Offset: 0x00051A54
        protected virtual IEnumerable <IADDatabaseCopy> LookupDatabaseCopies(IADServer miniServer)
        {
            MonitoringADConfig.Tracer.TraceDebug <string>((long)this.GetHashCode(), "LookupDatabases ( {0} ): Searching for all valid/invalid database copies...", miniServer.Name);
            IEnumerable <IADDatabaseCopy>  dbCopies  = null;
            IADToplogyConfigurationSession adSession = this.AdSessionPartiallyConsistent;
            Exception ex = ADUtils.RunADOperation(delegate()
            {
                dbCopies = adSession.GetAllDatabaseCopies(miniServer);
            }, 2);

            if (ex != null)
            {
                MonitoringADConfig.Tracer.TraceError <string, string>((long)this.GetHashCode(), "LookupDatabases ( {0} ): Got exception: {1}", miniServer.Name, AmExceptionHelper.GetExceptionToStringOrNoneString(ex));
                throw new MonitoringCouldNotFindDatabasesException(miniServer.Name, ex.Message, ex);
            }
            if (dbCopies == null)
            {
                dbCopies = new IADDatabaseCopy[0];
            }
            return(dbCopies);
        }
Example #30
0
        // Token: 0x0600002B RID: 43 RVA: 0x000024F0 File Offset: 0x000006F0
        public static string ResolveFqdn(string shortNodeName, bool throwException)
        {
            string    fqdn = null;
            Exception ex   = SharedHelper.RunADOperationEx(delegate(object param0, EventArgs param1)
            {
                IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
                iadtoplogyConfigurationSession.UseConfigNC      = false;
                iadtoplogyConfigurationSession.UseGlobalCatalog = true;
                IADComputer iadcomputer = iadtoplogyConfigurationSession.FindComputerByHostName(shortNodeName);
                if (iadcomputer != null && !string.IsNullOrEmpty(iadcomputer.DnsHostName))
                {
                    fqdn = iadcomputer.DnsHostName;
                    return;
                }
                if (throwException)
                {
                    throw new AmGetFqdnFailedNotFoundException(shortNodeName);
                }
                AmTrace.Error("FQDN resolution of the short name {0} failed. Could not find valid DNS hostname from ADComputer query.", new object[]
                {
                    shortNodeName
                });
                fqdn = AmServerNameCache.GetFqdnWithLocalDomainSuffix(shortNodeName);
            });

            if (ex != null)
            {
                if (throwException)
                {
                    throw new AmGetFqdnFailedADErrorException(shortNodeName, ex.Message, ex);
                }
                AmTrace.Error("FQDN resolution of the short name {0} failed. Error: {1}", new object[]
                {
                    shortNodeName,
                    ex.Message
                });
                fqdn = AmServerNameCache.GetFqdnWithLocalDomainSuffix(shortNodeName);
            }
            return(fqdn);
        }