private void PerformTargetServerValidation() { DatabaseTasksHelper.CheckServerObjectForCopyTask(this.ActivateOnServer, new Task.TaskErrorLoggingDelegate(base.WriteError), this.m_targetServer); if (this.CommandType == MoveActiveMailboxDatabase.CommandTypes.MoveSingleDatabase) { DatabaseCopy databaseCopy; DatabaseCopy[] array; DatabaseTasksHelper.CheckDatabaseCopyForCopyTask(this.m_database, new Task.TaskErrorLoggingDelegate(this.m_output.WriteError), this.m_targetServer, out databaseCopy, out array); } if (this.m_dag == null) { this.m_dag = ((IConfigurationSession)base.DataSession).Read <DatabaseAvailabilityGroup>(this.m_targetServer.DatabaseAvailabilityGroup); } IADDatabaseAvailabilityGroup dag = ADObjectWrapperFactory.CreateWrapper(this.m_dag); if (AmBestCopySelectionHelper.IsServerInDacAndStopped(dag, new AmServerName(this.m_targetServer.Name))) { base.WriteError(new InvalidOperationException(Strings.ErrorServerDacedAndNotStarted(this.m_dag.Name, this.m_targetServer.Name)), ErrorCategory.InvalidOperation, null); } DatabaseTasksHelper.CheckReplayServiceRunningOnNode(this.m_targetAmServer, new Task.TaskErrorLoggingDelegate(base.WriteError)); DagTaskHelper.CheckStoreIsRunning(new Task.TaskErrorLoggingDelegate(base.WriteError), this.m_targetAmServer); if (this.MountDialOverride != DatabaseMountDialOverride.Lossless) { base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.m_targetServer, true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope)); } }
private void BuildReplayConfigurations(DatabaseAvailabilityGroup dag, IADServer server) { IADDatabaseAvailabilityGroup dag2 = null; if (dag != null) { dag2 = ADObjectWrapperFactory.CreateWrapper(dag); } List <ReplayConfiguration> list; List <ReplayConfiguration> list2; ReplayConfigurationHelper.TaskConstructAllDatabaseConfigurations(dag2, server, out list, out list2); if (list != null && list.Count > 0) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "BuildReplayConfigurations(): Found RCR Source Configurations."); this.m_serverConfigBitfield |= ServerConfig.RcrSource; this.m_replayConfigs.AddRange(list); } if (list2 != null && list2.Count > 0) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "BuildReplayConfigurations(): Found RCR Target Configurations."); this.m_serverConfigBitfield |= ServerConfig.RcrTarget; this.m_replayConfigs.AddRange(list2); } if (this.AreConfigBitsSet(ServerConfig.DagMember) && !this.AreConfigBitsSet(ServerConfig.RcrSource) && !this.AreConfigBitsSet(ServerConfig.RcrTarget)) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "BuildReplayConfigurations(): Server is a DAG member but has no Database copies."); this.m_serverConfigBitfield |= ServerConfig.DagMemberNoDatabases; } ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "BuildReplayConfigurations(): The following bits are set on localConfigBitfield: {0}", this.m_serverConfigBitfield.ToString()); }
protected void PerformSeedIfNecessary() { TDataObject dataObject = this.DataObject; IIdentityParameter id = new DatabaseIdParameter(dataObject.Id); IConfigDataProvider dataSession = base.DataSession; ObjectId rootId = this.RootId; TDataObject dataObject2 = this.DataObject; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorDatabaseNotFound(dataObject2.Name)); TDataObject dataObject3 = this.DataObject; Database database = (Database)base.GetDataObject <Database>(id, dataSession, rootId, notFoundError, new LocalizedString?(Strings.ErrorDatabaseNotUnique(dataObject3.Name))); IADDatabaseAvailabilityGroup dag = null; if (this.m_server.DatabaseAvailabilityGroup != null) { DatabaseAvailabilityGroup dag2 = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.m_server.DatabaseAvailabilityGroup); dag = ADObjectWrapperFactory.CreateWrapper(dag2); } ReplayConfiguration config = RemoteReplayConfiguration.TaskGetReplayConfig(dag, ADObjectWrapperFactory.CreateWrapper(database), ADObjectWrapperFactory.CreateWrapper(this.m_server)); if (this.m_fSeeding) { this.SeedDatabase(config); } this.SuspendDatabaseCopyIfNecessary(config); }
protected override void InternalValidate() { TaskLogger.LogEnter(); if (this.Identity != null) { this.Identity.AllowInvalid = true; } base.InternalValidate(); if (base.HasErrors) { TaskLogger.LogExit(); return; } this.ValidateDatabaseCopy(); if (RemoteReplayConfiguration.IsServerRcrSource(ADObjectWrapperFactory.CreateWrapper(this.m_database), this.m_serverName, (ITopologyConfigurationSession)this.ConfigurationSession, out this.m_dbLocationInfo)) { base.WriteError(new InvalidOperationException(Strings.ErrorDbMountedOnServer(this.m_database.Identity.ToString(), this.m_serverName)), ErrorCategory.InvalidOperation, this.m_database.Identity); } if (this.m_server != null) { base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.m_server, true, new DataAccessTask <DatabaseCopy> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope)); } if (this.m_database != null) { MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, this.m_database, new Task.ErrorLoggerDelegate(base.WriteError)); if (this.m_database.Servers != null && this.m_database.Servers.Length > 0) { MapiTaskHelper.VerifyServerIsWithinScope(this.m_database, new Task.ErrorLoggerDelegate(base.WriteError), (ITopologyConfigurationSession)this.ConfigurationSession); } } TaskLogger.LogExit(); }
internal static AmDatabaseMoveResult PerformDatabaseFailover(string componentName, string comment, Database database) { AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, AmDbActionReason.FailureItem, AmDbActionCategory.Move); AmDatabaseMoveResult result = null; string text; AmRpcClientHelper.MoveDatabaseEx(ADObjectWrapperFactory.CreateWrapper(database), 0, 16, -1, AmServerName.LocalComputerName.Fqdn, null, true, 0, actionCode, comment, out text, ref result); return(result); }
private void RequestMount(MountFlags storeMountFlags) { AmMountFlags amMountFlags = AmMountFlags.None; if (this.Force) { amMountFlags |= AmMountFlags.MountWithForce; } AmRpcClientHelper.MountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), (int)storeMountFlags, (int)amMountFlags, 0); }
// Token: 0x06000823 RID: 2083 RVA: 0x000277FC File Offset: 0x000259FC internal static IADDatabase FindDatabaseByName(string databaseName, bool throwOnError) { Database database = null; Exception innerException = null; try { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 347, "FindDatabaseByName", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Replay\\ActiveManager\\Util\\AmHelperMethods.cs"); QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseSchema.Name, databaseName); Database[] array = tenantOrTopologyConfigurationSession.Find <Database>(null, QueryScope.SubTree, filter, null, 1); if (array != null && array.Length > 0) { database = array[0]; } } catch (ADTransientException ex) { AmTrace.Error("FindDatabaseByName(): ADTransientException occurred for {0} (error={1})", new object[] { databaseName, ex }); innerException = ex; } catch (ADExternalException ex2) { AmTrace.Error("FindDatabaseByName(): ADExternalException occurred for {0} (error={1})", new object[] { databaseName, ex2 }); innerException = ex2; } catch (ADOperationException ex3) { AmTrace.Error("FindDatabaseByName(): ADOperationException occurred for {0} (error={1})", new object[] { databaseName, ex3 }); innerException = ex3; } if (database == null) { AmTrace.Error("Database object not found in AD {0}", new object[] { databaseName }); if (throwOnError) { throw new AmDatabaseNameNotFoundException(databaseName, innerException); } } return(ADObjectWrapperFactory.CreateWrapper(database)); }
internal ReplayConfiguration ConstructReplayConfiguration(Database database) { IADDatabaseAvailabilityGroup dag = null; if (this.m_server.DatabaseAvailabilityGroup != null) { DatabaseAvailabilityGroup dag2 = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.m_server.DatabaseAvailabilityGroup); dag = ADObjectWrapperFactory.CreateWrapper(dag2); } return(RemoteReplayConfiguration.TaskGetReplayConfig(dag, ADObjectWrapperFactory.CreateWrapper(database), ADObjectWrapperFactory.CreateWrapper(this.m_server))); }
private void RcrValidation() { int num = 0; try { Server server = this.DataObject.GetServer(); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } else { RemoteReplayConfiguration.IsServerValidRcrTarget(ADObjectWrapperFactory.CreateWrapper(this.DataObject), ADObjectWrapperFactory.CreateWrapper(this.m_server), out num, server.Domain, true); } } catch (TransientException exception) { base.WriteError(exception, ErrorCategory.InvalidOperation, this.DataObject.Identity); } this.CheckDagMembership(); base.InitializeLagTimes(this.m_invalidDbCopy); Database[] databases = this.m_server.GetDatabases(); if (databases != null && databases.Length >= num) { base.WriteError(new RcrExceedDbLimitException(this.m_server.Name, num), ErrorCategory.InvalidOperation, this.DataObject.Identity); } string[] checkValue = new string[] { this.DataObject.LogFolderPath.PathName, this.DataObject.SystemFolderPath.PathName, this.DataObject.EdbFilePath.PathName }; try { this.PathUniquenessValidationForRcr(databases, checkValue); if (!this.IsThirdPartyReplicationEnabled) { this.PathExistenceValidationForRcr(this.m_server.Fqdn, checkValue); } } catch (ArgumentException exception2) { base.WriteError(exception2, ErrorCategory.InvalidArgument, this.DataObject.Identity); } }
private void MoveSingleDatabase() { AmDatabaseMoveResult result = null; try { int mountDialOverride = (int)this.MountDialOverride; bool tryOtherHealthyServers = !this.TargetServerSpecified; AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Admin, AmDbActionReason.Cmdlet, AmDbActionCategory.Move); AmRpcClientHelper.MoveDatabaseEx(ADObjectWrapperFactory.CreateWrapper(this.m_database), 0, 16, mountDialOverride, null, this.TargetServerSpecified ? this.m_targetServer.Fqdn : null, tryOtherHealthyServers, (int)this.GetSkipFlags(), actionCode, this.MoveComment, out this.m_lastServerContacted, ref result); this.m_output.WriteProgress(Strings.ProgressStatusCompleted, this.GetRpcDoneProgressString(), 100); this.WriteMoveResult(this.DataObject, this.m_startingServer, result, null); } catch (AmReplayServiceDownException ex) { TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[] { ex }); this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex); this.m_output.WriteError(new InvalidOperationException(Strings.ErrorActiveManagerIsNotReachable(ex.ServerName, ex.RpcErrorMessage)), ErrorCategory.InvalidOperation, this.m_database.Identity); } catch (AmServerException ex2) { TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[] { ex2 }); this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex2); this.m_output.WriteError(ex2, ErrorCategory.InvalidOperation, this.m_database.Identity); } catch (AmServerTransientException ex3) { TaskLogger.Trace("MoveMdbMaster.MoveSingleDatabase raised exception while moving database: {0}", new object[] { ex3 }); this.WriteMoveResult(this.DataObject, this.m_startingServer, result, ex3); this.m_output.WriteError(ex3, ErrorCategory.InvalidOperation, this.m_database.Identity); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { this.ConfigurationSession.ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout)); ((IDirectorySession)base.DataSession).ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout)); if (this.Identity == null) { this.m_serverName = Environment.MachineName; this.Identity = ServerIdParameter.Parse(this.m_serverName); } base.InternalValidate(); if (base.HasErrors) { TaskLogger.LogExit(); } else { ADServerWrapper server = ADObjectWrapperFactory.CreateWrapper(this.DataObject); ReplicationCheckGlobals.Server = server; this.m_serverName = this.DataObject.Name; ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "serverName is '{0}'.", this.m_serverName ?? "null"); this.m_isLocal = SharedHelper.StringIEquals(this.m_serverName, Environment.MachineName); if (!this.m_isLocal && this.MonitoringContext) { this.WriteErrorAndMonitoringEvent(new CannotRunMonitoringTaskRemotelyException(this.m_serverName), ErrorCategory.InvalidOperation, this.Identity, 10011, "MSExchange Monitoring ReplicationHealth"); } ReplicationCheckGlobals.RunningInMonitoringContext = this.MonitoringContext; if (this.m_isLocal && !this.CheckLocalServerRegistryRoles()) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "Local server does not have Exchange 2009 Mailbox Role in the registry."); } else { this.CheckServerObject(); if (this.DataObject.DatabaseAvailabilityGroup != null) { this.m_serverConfigBitfield |= ServerConfig.DagMember; this.m_dag = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.DataObject.DatabaseAvailabilityGroup); if (this.m_dag.StoppedMailboxServers.Contains(new AmServerName(this.m_serverName).Fqdn)) { this.m_serverConfigBitfield |= ServerConfig.Stopped; } } else { ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "{0} is a Standalone non-DAG Mailbox server.", this.DataObject.Name); } try { this.BuildReplayConfigurations(this.m_dag, server); } catch (ClusterException exception) { this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (TransientException exception2) { this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (DataSourceOperationException exception3) { this.WriteErrorAndMonitoringEvent(exception3, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (DataValidationException exception4) { this.WriteErrorAndMonitoringEvent(exception4, ErrorCategory.InvalidData, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } ReplicationCheckGlobals.ServerConfiguration = this.m_serverConfigBitfield; if (this.DataObject != null) { this.m_useReplayRpc = ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(this.DataObject.AdminDisplayVersion); } this.CheckIfTaskCanRun(); } } } finally { if (base.HasErrors) { if (this.MonitoringContext) { this.WriteMonitoringData(); } ReplicationCheckGlobals.ResetState(); } TaskLogger.LogExit(); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); try { Server server = this.DataObject.GetServer(); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(server.Fqdn)); base.WriteVerbose(Strings.VerboseUnmountDatabase(this.DataObject.Identity.ToString())); AmRpcClientHelper.DismountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), 0); } catch (AmServerException ex) { Exception ex2; if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("DismountDatabase.InternalProcessRecord ignoring exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("DismountDatabase.InternalProcessRecord ignoring exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("DismountDatabase.InternalProcessRecord ignoring exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex is AmDatabaseNeverMountedException) { TaskLogger.Trace("DismountDatabase.InternalProcessRecord ignoring exception while unmounting database: {0}", new object[] { ex.Message }); } else { TaskLogger.Trace("DismountDatabase.InternalProcessRecord raises exception while dismounting database: {0}", new object[] { ex.Message }); base.WriteError(new InvalidOperationException(Strings.ErrorFailedToUnmountDatabase(this.Identity.ToString(), ex.Message), ex), ErrorCategory.InvalidOperation, this.DataObject.Identity); } } catch (AmServerTransientException ex3) { TaskLogger.Trace("DismountDatabase.InternalProcessRecord raises exception while dismounting database: {0}", new object[] { ex3.Message }); base.WriteError(new InvalidOperationException(Strings.ErrorFailedToUnmountDatabase(this.Identity.ToString(), ex3.Message), ex3), ErrorCategory.InvalidOperation, this.DataObject.Identity); } TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { ExTraceGlobals.CmdletsTracer.TraceDebug <string, DatabaseCopyIdParameter>((long)this.GetHashCode(), "DatabaseCopyStateAction: enter InternalValidate(DB,ident): {0}, {1}", base.DatabaseName, this.Identity); base.InternalValidate(); if (base.HasErrors) { TaskLogger.LogExit(); } else { Database database = this.DataObject.GetDatabase <Database>(); DatabaseAvailabilityGroup dagForDatabase = DagTaskHelper.GetDagForDatabase(database, base.DataSession, new Task.TaskErrorLoggingDelegate(base.WriteError)); DagTaskHelper.PreventTaskWhenTPREnabled(dagForDatabase, this); this.m_UseRpc = ReplayRpcVersionControl.IsSuspendRpcSupported(this.Server.AdminDisplayVersion); ServerVersion serverVersion = this.IsReplayLagManagementOperation ? ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion : ReplayRpcVersionControl.SuspendRpcSupportVersion; if (this.m_UseRpc) { if (this.IsSuspendOperation) { base.WriteVerbose(Strings.SuspendSgcUseRpc(this.Server.AdminDisplayVersion.ToString(), serverVersion.ToString())); } else { base.WriteVerbose(Strings.ResumeSgcUseRpc(this.Server.AdminDisplayVersion.ToString(), serverVersion.ToString())); } } else if (this.IsReplayLagManagementOperation) { base.WriteError(new ReplayLagRpcUnsupportedException(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx4RpcSupportVersion.ToString()), ExchangeErrorCategory.ServerOperation, this.Server); } else if (this.IsSuspendOperation) { base.WriteVerbose(Strings.SuspendSgcUseState(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.SuspendRpcSupportVersion.ToString())); } else { base.WriteVerbose(Strings.ResumeSgcUseState(this.Server.Name, this.Server.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.SuspendRpcSupportVersion.ToString())); } this.IsActivationRpcSupported = ReplayRpcVersionControl.IsActivationRpcSupported(this.Server.AdminDisplayVersion); this.IsRequestSuspend3RpcSupported = ReplayRpcVersionControl.IsRequestSuspend3RpcSupported(this.Server.AdminDisplayVersion); this.IsOperationRunOnSource = false; DatabaseLocationInfo databaseLocationInfo; if (database.ReplicationType == ReplicationType.Remote && RemoteReplayConfiguration.IsServerRcrSource(ADObjectWrapperFactory.CreateWrapper(database), ADObjectWrapperFactory.CreateWrapper(this.Server), out databaseLocationInfo)) { this.IsOperationRunOnSource = true; } ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseCopyStateAction: leave InternalValidate: {0}", base.DatabaseName); } } finally { TaskLogger.LogExit(); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); bool flag = false; bool flag2 = false; bool flag3 = true; bool flag4 = false; bool flag5 = false; Server server = this.OwnerServer; ADObjectId id = new ADObjectId(this.OwnerServer.Guid); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } try { if ((!this.IsEdbFilePathChanged && !this.isLogFolderPathChanged) || (base.ConfigurationOnly && !this.shouldContinueToDoConfigurationOnly)) { TaskLogger.LogExit(); } else { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCheckingReplayState, 10); } base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.OwnerServer.Fqdn)); MdbStatus mdbStatus = AmStoreHelper.GetMdbStatus(this.OwnerServer.Fqdn, this.DataObject.Guid); if (mdbStatus == null) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToGetDatabaseStatus(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity); } if ((mdbStatus.Status & MdbStatusFlags.Backup) != MdbStatusFlags.Offline) { base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity); } else if ((mdbStatus.Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline) { if (!this.Force && !base.ShouldContinue(base.ConfigurationOnly ? Strings.WarningDismountDatabaseToDoConfigurationOnly(this.Identity.ToString()) : Strings.WarningDismountDatabaseToContinue(this.Identity.ToString()))) { TaskLogger.LogExit(); return; } if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDismountingDatabase(this.Identity.ToString()), 20); } base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(id, base.DataSession, typeof(Server))); try { base.WriteVerbose(Strings.VerboseUnmountDatabase(this.DataObject.Identity.ToString())); AmRpcClientHelper.DismountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), 0); } catch (AmServerException ex) { Exception ex2; if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex is AmDatabaseNeverMountedException) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex.Message }); } else { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex.Message }); base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity); } } catch (AmServerTransientException ex3) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while dismounting database: {0}", new object[] { ex3.Message }); base.WriteError(ex3, ErrorCategory.InvalidOperation, this.DataObject.Identity); } flag = true; } if (!base.ConfigurationOnly) { if (this.IsDatabaseFilesCreated && this.IsEdbFilePathChanged) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingEdbFile, 25); } if (!this.TryCopyFile(this.OriginalEdbFilePath.PathName, this.TargetEdbFilePath.PathName)) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMoveEdbFile(this.OriginalEdbFilePath.PathName, this.TargetEdbFilePath.PathName)), ErrorCategory.InvalidOperation, this.Identity); } flag2 = true; } if (this.isLogFolderPathChanged) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingLogFiles, 45); } base.WriteVerbose(Strings.VerboseCopyDatabaseLogFiles(base.OwnerServerName, this.OldLogFolderPath.PathName, this.LogFolderPath.PathName)); if (!this.TryCopyPath(this.OldLogFolderPath.PathName, this.LogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter))) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMoveDatabaseLogFiles(this.OldLogFolderPath.PathName, this.LogFolderPath.PathName)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } flag4 = true; } } if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressSavingADObject, 69); } base.InternalProcessRecord(); flag3 = false; if (flag2) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingEdbFile, 72); } if (!this.TryDeleteFile(this.OriginalEdbFilePath.PathName)) { this.WriteWarning(Strings.FailedToDeleteOldEdbFile(this.OriginalEdbFilePath.PathName)); TaskLogger.Trace("MoveDatabasePath: delete edb \"{0}\" file failed", new object[] { this.OriginalEdbFilePath.PathName }); } } if (flag4) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingLogFiles, 81); } base.WriteVerbose(Strings.VerboseDeleteDatabaseLogFiles(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName)); if (!WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogPathFilter))) { this.WriteWarning(Strings.FailedDeleteOldDatabaseLogFiles(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName)); TaskLogger.Trace("Failed to delete some of the orignal log files.", new object[0]); } } if (this.moveCatalogs && SystemConfigurationTasksHelper.TryCreateDirectory(this.OwnerServer.Fqdn, this.targetCatalogsPath, null, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning))) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingCatalog, 87); } try { base.WriteVerbose(Strings.VerboseCopyDatabaseCatalogFiles(this.OwnerServer.Fqdn, this.originalCatalogsPath, this.targetCatalogsPath)); if (WmiWrapper.CopyFilesInDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath, this.targetCatalogsPath, new WmiWrapper.FileFilter(MoveDatabasePath.ReturnAllFiles))) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingCatalog, 92); } base.WriteVerbose(Strings.VerboseDeleteDatabaseCatalogFiles(this.OwnerServer.Fqdn, this.originalCatalogsPath)); WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath, new WmiWrapper.FileFilter(MoveDatabasePath.ReturnAllFiles)); base.WriteVerbose(Strings.VerboseDeleteDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath)); WmiWrapper.RemoveDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath); } } catch (ManagementException ex4) { TaskLogger.Trace("MoveDatabasePath raised exception {0} while moving catalog files", new object[] { ex4.ToString() }); this.WriteWarning(Strings.ErrorMovingCatalogs(this.Identity.ToString(), ex4.Message)); } catch (ArgumentException ex5) { TaskLogger.Trace("MoveDatabasePath raised exception {0} while moving catalog files", new object[] { ex5.ToString() }); this.WriteWarning(Strings.ErrorMovingCatalogs(this.Identity.ToString(), ex5.Message)); } } this.SendNotificationRpcToReplayService(); flag5 = true; } } catch (WmiException ex6) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex6.Message)), ErrorCategory.InvalidOperation, this.Identity); } catch (UnauthorizedAccessException ex7) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex7.Message)), ErrorCategory.InvalidOperation, this.Identity); } finally { if (flag3) { if (flag2 && !this.TryDeleteFile(this.TargetEdbFilePath.PathName)) { this.WriteWarning(Strings.FailedToDeleteTempEdbFile(this.TargetEdbFilePath.PathName)); TaskLogger.Trace("MoveDatabasePath: delete edb \"{0}\" file failed", new object[] { this.TargetEdbFilePath.PathName }); } if (flag4) { TaskLogger.Trace("Error occurs when Copying path. delete copied log files", new object[0]); base.WriteVerbose(Strings.VerboseDeleteDatabaseLogFiles(this.OwnerServer.Fqdn, this.LogFolderPath.PathName)); if (!WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.LogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter))) { this.WriteWarning(Strings.FailedDeleteTempDatabaseLogFiles(base.OwnerServerName, this.LogFolderPath.PathName)); TaskLogger.Trace("Failed to delete some of the copied log files.", new object[0]); } } } if (!base.ConfigurationOnly && flag) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressRestoringDatabaseStatus, 95); } base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(id, base.DataSession, typeof(Server))); try { if (!flag5) { this.SendNotificationRpcToReplayService(); flag5 = true; } base.WriteVerbose(Strings.VerboseMountDatabase(this.Identity.ToString())); AmRpcClientHelper.MountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), 0, 0, 0); } catch (AmServerException ex8) { string message = ex8.Message; TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while re-mounting Mdb status: {0}", new object[] { message }); this.WriteWarning(Strings.ErrorFailedToRestoreDatabaseStatus(this.Identity.ToString(), message)); } catch (AmServerTransientException ex9) { string message2 = ex9.Message; TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while re-mounting Mdb status: {0}", new object[] { message2 }); this.WriteWarning(Strings.ErrorFailedToRestoreDatabaseStatus(this.Identity.ToString(), message2)); } } TaskLogger.LogExit(); } }
public static void SetDagNetwork(DatabaseAvailabilityGroup dag, SetDagNetworkRequest change) { if (dag.Servers.Count == 0) { return; } AmPamInfo primaryActiveManager = AmRpcClientHelper.GetPrimaryActiveManager(ADObjectWrapperFactory.CreateWrapper(dag)); string targetServerName = primaryActiveManager.ServerName; byte[] changeAsBytes = Serialization.ObjectToBytes(change); DagNetworkRpc.RunRpcOperation(targetServerName, delegate(ReplayRpcClient rpcClient) { ExTraceGlobals.DatabaseAvailabilityGroupTracer.TraceDebug <string>(0L, "SetDagNetwork sending RPC to {0}", targetServerName); return(rpcClient.SetDagNetwork(changeAsBytes)); }); }
private void RunChecks() { TaskLogger.LogEnter(); try { DatabaseHealthValidationRunner validationRunner = new DatabaseHealthValidationRunner(this.m_serverName); if (this.AreConfigBitsSet(ServerConfig.DagMember)) { using (DagMemberMultiChecks dagMemberMultiChecks = new DagMemberMultiChecks(this.m_serverName, this.m_eventManager, "MSExchange Monitoring ReplicationHealth", this.TransientEventSuppressionWindow, ADObjectWrapperFactory.CreateWrapper(this.m_dag))) { this.RunMultiChecks(dagMemberMultiChecks); } } if (this.m_useReplayRpc) { ReplicationCheckGlobals.UsingReplayRpc = true; } if (this.AreConfigBitsSet(ServerConfig.RcrSource)) { using (RcrSourceMultiChecks rcrSourceMultiChecks = new RcrSourceMultiChecks(this.m_serverName, this.m_eventManager, "MSExchange Monitoring ReplicationHealth", validationRunner, this.m_replayConfigs, ReplicationCheckGlobals.CopyStatusResults, this.TransientEventSuppressionWindow)) { this.RunMultiChecks(rcrSourceMultiChecks); } } if (this.AreConfigBitsSet(ServerConfig.RcrTarget) && this.m_dag.ThirdPartyReplication != ThirdPartyReplicationMode.Enabled) { using (TargetCopyMultiChecks targetCopyMultiChecks = new TargetCopyMultiChecks(this.m_serverName, this.m_eventManager, "MSExchange Monitoring ReplicationHealth", validationRunner, this.m_replayConfigs, ReplicationCheckGlobals.CopyStatusResults, this.TransientEventSuppressionWindow)) { this.RunMultiChecks(targetCopyMultiChecks); } } if (this.IsServerStandaloneWithNoReplicas()) { using (StandaloneMultiChecks standaloneMultiChecks = new StandaloneMultiChecks(this.m_serverName, this.m_eventManager, "MSExchange Monitoring ReplicationHealth", this.TransientEventSuppressionWindow)) { this.RunMultiChecks(standaloneMultiChecks); } } } finally { TaskLogger.LogExit(); } }
protected void DismountDatabase() { TDataObject dataObject = base.DataObject; base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.server.Fqdn)); using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(this.server.Fqdn)) { base.WriteVerbose(Strings.VerboseCheckDatabaseStatus(dataObject.Identity.ToString())); Guid[] dbGuids = new Guid[] { dataObject.Guid }; bool flag = false; MdbStatus[] array; if (this.ListMdbStatus(newStoreControllerInstance, dbGuids, out array) == null) { if (array == null || array.Length == 0) { TaskLogger.Trace("The database being removed does not have storage", new object[0]); return; } if (MdbStatusFlags.Backup == (array[0].Status & MdbStatusFlags.Backup)) { base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(dataObject.Name)), ErrorCategory.InvalidOperation, dataObject.Identity); } else if (MdbStatusFlags.Online == (array[0].Status & MdbStatusFlags.Online)) { flag = true; } } if (flag) { base.WriteVerbose(Strings.VerboseUnmountDatabase(this.Identity.ToString())); TDataObject dataObject2 = base.DataObject; if (dataObject2.IsExchange2009OrLater) { try { AmRpcClientHelper.DismountDatabase(ADObjectWrapperFactory.CreateWrapper(base.DataObject), 0); goto IL_300; } catch (AmServerException ex) { Exception ex2; if (ex.TryGetExceptionOrInnerOfType(out ex2)) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetExceptionOrInnerOfType(out ex2)) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetExceptionOrInnerOfType(out ex2)) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetExceptionOrInnerOfType(out ex2)) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetExceptionOrInnerOfType(out ex2)) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex.Message }); Exception exception = ex; ErrorCategory category = ErrorCategory.InvalidOperation; TDataObject dataObject3 = base.DataObject; base.WriteError(exception, category, dataObject3.Identity); } goto IL_300; } catch (AmServerTransientException ex3) { TaskLogger.Trace("RemoveDatabase.InternalProcessRecord raises exception while dismounting database: {0}", new object[] { ex3.Message }); Exception exception2 = ex3; ErrorCategory category2 = ErrorCategory.InvalidOperation; TDataObject dataObject4 = base.DataObject; base.WriteError(exception2, category2, dataObject4.Identity); goto IL_300; } } IConfigDataProvider dataSession = base.DataSession; TDataObject dataObject5 = base.DataObject; LegacyPublicFolderDatabase legacyPublicFolderDatabase = (LegacyPublicFolderDatabase)dataSession.Read <LegacyPublicFolderDatabase>(dataObject5.Identity); StorageGroup storageGroup = (StorageGroup)base.DataSession.Read <StorageGroup>(legacyPublicFolderDatabase.StorageGroup); newStoreControllerInstance.UnmountDatabase(storageGroup.Guid, legacyPublicFolderDatabase.Guid, 0); } IL_300 :; } }
private void QueryDumpsterStats(Server mailboxServer, string databaseDn, ref MailboxDatabase entry) { List <string> serversWithServerRoleInSiteByServer = ReplayConfiguration.GetServersWithServerRoleInSiteByServer(ADObjectWrapperFactory.CreateWrapper(mailboxServer), ServerRole.HubTransport); List <string> list = new List <string>(); List <DumpsterStatisticsEntry> list2 = new List <DumpsterStatisticsEntry>(); foreach (string text in serversWithServerRoleInSiteByServer) { MailSubmissionServiceRpcClient mailSubmissionServiceRpcClient2; MailSubmissionServiceRpcClient mailSubmissionServiceRpcClient = mailSubmissionServiceRpcClient2 = new MailSubmissionServiceRpcClient(text); try { long ticksOldestItem = 0L; long queueSize = 0L; int numberOfItems = 0; long num = mailSubmissionServiceRpcClient.QueryDumpsterStats(databaseDn, ref ticksOldestItem, ref queueSize, ref numberOfItems); if (num != 0L) { ExTraceGlobals.CmdletsTracer.TraceError <string, long>((long)this.GetHashCode(), "GetDatabase.QueryDumpsterStats: RPC to server '{0}' returned {1}", text, num); list.Add(text); } else { list2.Add(new DumpsterStatisticsEntry(text, ticksOldestItem, queueSize, numberOfItems)); } } catch (RpcException) { list.Add(text); } finally { if (mailSubmissionServiceRpcClient2 != null) { ((IDisposable)mailSubmissionServiceRpcClient2).Dispose(); } } } entry.m_DumpsterStatistics = new DumpsterStatisticsEntry[list2.Count]; list2.CopyTo(entry.m_DumpsterStatistics); entry.m_DumpsterServersNotAvailable = new string[list.Count]; list.CopyTo(entry.m_DumpsterServersNotAvailable); }