Exemple #1
0
        public bool Initialize()
        {
            if (this.m_witnessServer == null)
            {
                List <string> frontendTransportServersInLocalSite = ReplayConfiguration.GetFrontendTransportServersInLocalSite();
                if (frontendTransportServersInLocalSite != null && frontendTransportServersInLocalSite.Count > 0)
                {
                    foreach (string text in frontendTransportServersInLocalSite)
                    {
                        if (!this.ServerHasMailboxRole(text))
                        {
                            if (!FileShareWitnessServerName.TryParse(text, out this.m_witnessServer))
                            {
                                TaskLogger.Trace("Attempt to parse FrontendTransport server name {0} to its file share witness name failed.", new object[]
                                {
                                    text
                                });
                                break;
                            }
                            break;
                        }
                    }
                }
                if (this.m_witnessServer == null)
                {
                    this.m_initializationException = new DagFswUnableToDetermineFrontendTransportServerException();
                    throw this.m_initializationException;
                }
            }
            try
            {
                this.AssignWitnessServerFqdn();
            }
            catch (ArgumentException ex)
            {
                this.m_initializationException = new DagFswUnableToParseWitnessServerNameException(ex);
                throw this.m_initializationException;
            }
            catch (ErrorUnableToFindFqdnForHostADErrorException ex2)
            {
                this.m_initializationException = new DagFswUnableToParseWitnessServerNameException(ex2);
                throw this.m_initializationException;
            }
            string text2 = this.WitnessServer.DomainName;

            if (string.IsNullOrEmpty(text2))
            {
                int num = this.WitnessServerFqdn.IndexOf('.');
                if (num > -1)
                {
                    text2 = this.WitnessServerFqdn.Substring(num + 1);
                }
            }
            string arg = string.Format(FileShareWitness.s_dagShareNameFormat, this.m_dagName, text2);

            UncFileSharePath.TryParse(string.Format(FileShareWitness.s_uncPathFormat, this.WitnessServerFqdn, arg), out this.m_fileShareWitnessShare);
            if (this.m_witnessDirectory == null)
            {
                string text3 = WmiWrapper.TryGetSystemDrive(this.WitnessServerFqdn);
                if (text3 == null)
                {
                    this.m_initializationException = new DagFswUnableToBindWitnessDirectoryException(this.WitnessServerFqdn);
                    throw this.m_initializationException;
                }
                this.m_witnessDirectory = NonRootLocalLongFullPath.Parse(string.Format(FileShareWitness.s_defaultDirectoryFormat, text3, arg));
            }
            this.m_initialized = true;
            return(this.m_initialized);
        }