Esempio n. 1
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);
        }
Esempio n. 2
0
        // Token: 0x060006D6 RID: 1750 RVA: 0x00020B4C File Offset: 0x0001ED4C
        private bool IsServerStartedForDACMode(ref LocalizedString error)
        {
            string adError = null;
            IADDatabaseAvailabilityGroup iaddatabaseAvailabilityGroup;

            if (this.DagConfig != null)
            {
                iaddatabaseAvailabilityGroup = this.DagConfig.Dag;
                if (iaddatabaseAvailabilityGroup == null)
                {
                    CouldNotFindDagObjectForServer couldNotFindDagObjectForServer = new CouldNotFindDagObjectForServer(this.ServerToCheck.NetbiosName);
                    adError = couldNotFindDagObjectForServer.Message;
                }
            }
            else
            {
                iaddatabaseAvailabilityGroup = AmBestCopySelectionHelper.GetLocalServerDatabaseAvailabilityGroup(out adError);
            }
            if (iaddatabaseAvailabilityGroup == null)
            {
                error = ReplayStrings.AmBcsDagNotFoundInAd(this.ServerToCheck.Fqdn, adError);
                this.ReportServerBlocked(AmBcsServerChecks.DatacenterActivationModeStarted, error);
                return(false);
            }
            if (AmBestCopySelectionHelper.IsServerInDacAndStopped(iaddatabaseAvailabilityGroup, this.ServerToCheck))
            {
                AmTrace.Error("AmBcsServerValidation: Rejecting server '{0}' for DB '{1}' since it is stopped in the DAC mode.", new object[]
                {
                    this.ServerToCheck,
                    this.Database.Name
                });
                error = ReplayStrings.AmBcsTargetServerIsStoppedOnDAC(this.ServerToCheck.Fqdn);
                this.ReportServerBlocked(AmBcsServerChecks.DatacenterActivationModeStarted, error);
                return(false);
            }
            return(true);
        }