Example #1
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);
                        }
                    }
                }
            }
        }
Example #2
0
        public static ReplayConfiguration GetLocalReplayConfiguration(Guid dbGuid, IADConfig adConfig, ActiveManager activeManager, out Exception ex)
        {
            ex = null;
            if (activeManager == null)
            {
                activeManager = ActiveManager.GetNoncachingActiveManagerInstance();
            }
            IADServer localServer = adConfig.GetLocalServer();

            if (localServer == null)
            {
                ex = new FailedToFindServerException("localmachine");
                ExTraceGlobals.ReplayManagerTracer.TraceError <Guid, Exception>(0L, "GetReplayConfiguration ({0}): didn't find any server object for the local machine: {1}", dbGuid, ex);
                return(null);
            }
            IADDatabase database = adConfig.GetDatabase(dbGuid);

            if (database == null)
            {
                ex = new FailedToFindDatabaseException(dbGuid.ToString());
                ExTraceGlobals.ReplayManagerTracer.TraceError <Guid>(0L, "GetReplayConfiguration ({0}): Didn't find any mailbox database object from AD.", dbGuid);
                return(null);
            }
            bool flag;
            ReplayConfiguration replayConfiguration = ReplayConfiguration.GetReplayConfiguration(adConfig.GetLocalDag(), database, localServer, activeManager, out flag, out ex);

            if (ex != null)
            {
                ExTraceGlobals.ReplayManagerTracer.TraceError <Guid, Exception>(0L, "GetReplayConfiguration ({0}): Error occurred constructing the ReplayConfiguration. Error: {1}", dbGuid, ex);
                return(null);
            }
            return(replayConfiguration);
        }
        public static void ConstructAllLocalConfigurations(IADConfig adConfig, ActiveManager activeManager, out List <ReplayConfiguration> currentSourceConfigurations, out List <ReplayConfiguration> currentRemoteTargetConfigurations, out List <KeyValuePair <IADDatabase, Exception> > failedConfigurations)
        {
            currentSourceConfigurations       = new List <ReplayConfiguration>(20);
            currentRemoteTargetConfigurations = new List <ReplayConfiguration>(48);
            failedConfigurations = new List <KeyValuePair <IADDatabase, Exception> >();
            if (activeManager == null)
            {
                activeManager = ActiveManager.GetNoncachingActiveManagerInstance();
            }
            IADServer localServer = adConfig.GetLocalServer();

            if (localServer == null)
            {
                ReplayConfiguration.Tracer.TraceError(0L, "ConstructAllLocalConfigurations: didn't find local server");
                return;
            }
            IEnumerable <IADDatabase> databasesOnLocalServer = adConfig.GetDatabasesOnLocalServer();

            if (databasesOnLocalServer == null)
            {
                ReplayConfiguration.Tracer.TraceError(0L, "There are no mailbox dbs on this server");
                return;
            }
            IADDatabaseAvailabilityGroup localDag = adConfig.GetLocalDag();

            foreach (IADDatabase iaddatabase in databasesOnLocalServer)
            {
                Exception           ex = null;
                bool                flag;
                ReplayConfiguration replayConfiguration = ReplayConfiguration.GetReplayConfiguration(localDag, iaddatabase, localServer, activeManager, out flag, out ex);
                if (replayConfiguration != null)
                {
                    if (flag)
                    {
                        currentSourceConfigurations.Add(replayConfiguration);
                    }
                    else
                    {
                        currentRemoteTargetConfigurations.Add(replayConfiguration);
                    }
                }
                else if (ex != null)
                {
                    ReplayConfiguration.Tracer.TraceError <Guid, string>(0L, "ReplayConfiguration for database '{0}' was not created due to an Exception. The configuration will not be added to the list of possible instances to run. Exception: {1}", iaddatabase.Guid, ex.ToString());
                    failedConfigurations.Add(new KeyValuePair <IADDatabase, Exception>(iaddatabase, ex));
                }
                else
                {
                    ReplayConfiguration.Tracer.TraceError <string>(0L, "ConstructAllLocalConfigurations() did not find a ReplayConfiguration for database '{0}' and no error occurred.", iaddatabase.Name);
                }
            }
        }