public FileShareWitness(ITopologyConfigurationSession adSession, string dagName, FileShareWitnessServerName witnessServer, NonRootLocalLongFullPath witnessDirectory, IAmCluster cluster) : this(adSession, dagName, witnessServer, witnessDirectory) { this.m_clusterReference.SetTarget(cluster); }
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); }
public FileShareWitness(ITopologyConfigurationSession adSession, string dagName, FileShareWitnessServerName witnessServer, NonRootLocalLongFullPath witnessDirectory) : this(adSession, dagName) { this.m_witnessServer = witnessServer; this.m_witnessDirectory = witnessDirectory; }
private void ProcessFileShareWitness() { FileShareWitnessServerName fileShareWitnessServerName = this.AlternateWitnessServer ?? this.m_dag.AlternateWitnessServer; NonRootLocalLongFullPath nonRootLocalLongFullPath = this.AlternateWitnessDirectory ?? this.m_dag.AlternateWitnessDirectory; if (this.UsePrimaryWitnessServer) { fileShareWitnessServerName = this.m_dag.WitnessServer; nonRootLocalLongFullPath = this.m_dag.WitnessDirectory; } string serverName = (fileShareWitnessServerName != null) ? fileShareWitnessServerName.ToString() : Strings.CreateAltFswWillAutomaticallyCalculateLater; string filePath = (nonRootLocalLongFullPath != null) ? nonRootLocalLongFullPath.ToString() : Strings.CreateAltFswWillAutomaticallyCalculateLater; this.m_output.WriteProgressIncrementalSimple(Strings.ProgressCreateAltFsw(serverName, filePath), 10); this.m_afsw = new FileShareWitness((ITopologyConfigurationSession)base.DataSession, this.m_dag.Name, fileShareWitnessServerName, nonRootLocalLongFullPath); try { this.m_afsw.Initialize(); } catch (LocalizedException error) { this.m_output.WriteErrorSimple(error); } this.CheckFsw(this.m_afsw.WitnessServerFqdn); if (SharedHelper.StringIEquals(this.m_afsw.WitnessServer.ToString(), this.m_dag.WitnessServer.ToString()) && this.m_dag.WitnessDirectory != this.m_afsw.WitnessDirectory) { this.m_output.WriteErrorSimple(new DagFswAndAlternateFswOnSameWitnessServerButPointToDifferentDirectoriesException(this.m_afsw.WitnessServer.ToString(), this.m_dag.WitnessDirectory.ToString(), this.m_afsw.WitnessDirectory.ToString())); } if (!this.UsePrimaryWitnessServer) { this.m_dag.SetAlternateWitnessServer(this.m_afsw.FileShareWitnessShare, this.m_afsw.WitnessDirectory); } else { this.m_dag.SetWitnessServer(this.m_afsw.FileShareWitnessShare, this.m_afsw.WitnessDirectory); } base.DataSession.Save(this.m_dag); try { this.m_output.AppendLogMessage("Creating the file share of the FSW...", new object[0]); this.m_afsw.Create(); if (this.m_dag.Servers.Count == 0 && this.m_afsw.IsJustCreated) { this.m_output.AppendLogMessage("Because there are no servers in the DAG, and the file share witness was just created, then the permissions may be incorrect (the CNO account might not yet exist). Deleting the FSW.", new object[0]); this.m_afsw.Delete(); } } catch (LocalizedException ex) { this.m_output.AppendLogMessage("There was an exception encountered during creation and/or deletion of the FSW ('{0}'). If it was an error during deletion, then we'll just ignore it.", new object[] { ex.Message }); if (this.m_afsw.GetExceptionType(ex) != FileShareWitnessExceptionType.FswDeleteError) { this.m_output.WriteWarning(ex.LocalizedString); } else { this.m_output.AppendLogMessage("Yes, it was a an error related to deleting the FSW. Continuing on.", new object[0]); } } }