private string GetDatabaseIdentityString(DatabaseId databaseId) { this.DisposeCheck(); if (null == databaseId) { throw new ArgumentNullException("databaseId"); } if (string.IsNullOrEmpty(databaseId.DatabaseName)) { try { MdbStatus databaseStatus = this.GetDatabaseStatus(databaseId, false); if (databaseStatus == null) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId>((long)this.GetHashCode(), "Cannot get status for database '{0}'", databaseId); } else { databaseId = new DatabaseId(databaseId.MapiEntryId, databaseStatus.VServerName, databaseStatus.MdbName, databaseId.Guid); } } catch (MapiTransientException ex) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId, string>((long)this.GetHashCode(), "Getting status for database '{0}' caught an exception: '{1}'", databaseId, ex.Message); } catch (MapiOperationException ex2) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId, string>((long)this.GetHashCode(), "Getting status for database '{0}' caught an exception: '{1}'", databaseId, ex2.Message); } } return(databaseId.ToString()); }
// Token: 0x0600049B RID: 1179 RVA: 0x00018C94 File Offset: 0x00016E94 internal static MountStatus GetStoreDatabaseMountStatus(AmServerName serverName, Guid mdbGuid) { Exception ex = null; MountStatus result = MountStatus.Unknown; MdbStatus mdbStatus = AmStoreHelper.GetMdbStatus(serverName, mdbGuid, out ex); if (ex == null) { if (mdbStatus != null) { if ((mdbStatus.Status & MdbStatusFlags.Online) == MdbStatusFlags.Online) { result = MountStatus.Mounted; } else { result = MountStatus.Dismounted; } } else { result = MountStatus.Dismounted; } } else if (AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex)) { result = MountStatus.Dismounted; } return(result); }
// Token: 0x0600049A RID: 1178 RVA: 0x00018C68 File Offset: 0x00016E68 internal static bool IsMounted(AmServerName serverName, Guid mdbGuid) { bool result = false; Exception ex; MdbStatus mdbStatus = AmStoreHelper.GetMdbStatus(serverName, mdbGuid, out ex); if (mdbStatus != null && (mdbStatus.Status & MdbStatusFlags.Online) == MdbStatusFlags.Online) { result = true; } return(result); }
// Token: 0x0600049E RID: 1182 RVA: 0x00018D14 File Offset: 0x00016F14 internal static MdbStatus GetMdbStatus(AmServerName serverName, Guid mdbGuid, string clientTypeId, TimeSpan?timeout, out Exception exception) { MdbStatus result = null; exception = null; string text = AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn; try { using (IListMDBStatus storeListMDBStatusInstance = Dependencies.GetStoreListMDBStatusInstance(text, clientTypeId)) { MdbStatus[] array = storeListMDBStatusInstance.ListMdbStatus(new Guid[] { mdbGuid }, timeout); if (array != null && array.Length > 0) { result = array[0]; } } } catch (MapiPermanentException ex) { AmTrace.Error("Caught exception in GetMdbStatus({0}, {1}): {2}", new object[] { text, mdbGuid, ex.Message }); exception = ex; } catch (MapiRetryableException ex2) { AmTrace.Error("Caught exception in GetMdbStatus({0}, {1}): {2}", new object[] { text, mdbGuid, ex2.Message }); exception = ex2; } return(result); }
// Token: 0x06000195 RID: 405 RVA: 0x000084FC File Offset: 0x000066FC private DatabaseInfo TryCreateDatabaseInfo(MdbStatus mdbStatus) { DatabaseInfo databaseInfo = null; try { base.CatchMeIfYouCan(delegate { Exception ex2 = null; try { databaseInfo = new DatabaseInfo(mdbStatus.MdbGuid, mdbStatus.MdbName, mdbStatus.MdbLegacyDN, (mdbStatus.Status & MdbStatusFlags.IsPublic) != MdbStatusFlags.Offline); } catch (LocalServerNotFoundException ex3) { ex2 = ex3; } catch (DataValidationException ex4) { ex2 = ex4; } catch (ArgumentException ex5) { ex2 = ex5; } if (ex2 != null) { throw new TransientDatabaseException(ex2); } }, "DatabaseManager"); } catch (AIException ex) { ExTraceGlobals.DatabaseManagerTracer.TraceError <DatabaseManager, string, AIException>((long)this.GetHashCode(), "{0}: Failed to create DatabaseInfo for database {1}. Exception={2}", this, mdbStatus.MdbName, ex); base.LogEvent(AssistantsEventLogConstants.Tuple_DatabaseManagerTransientFailure, ex.ToString(), new object[] { ex.ToString() }); } return(databaseInfo); }
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(); } }
// Token: 0x0600120B RID: 4619 RVA: 0x000384FC File Offset: 0x000366FC private static MailboxDatabaseWithLocationInfo VerifyStatusAndSelectDB(List <MailboxDatabaseWithLocationInfo> databases, string domainController, LogMessageDelegate logger, ScopeSet scopeSet) { Guid[] array = new Guid[1]; MdbStatus[] array2 = new MdbStatus[1]; Dictionary <string, ExRpcAdmin> dictionary = new Dictionary <string, ExRpcAdmin>(100); Dictionary <string, string> dictionary2 = new Dictionary <string, string>(100); ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController); IConfigurationSession configurationSession = null; if (scopeSet != null && !PhysicalResourceLoadBalancing.IsDatacenter) { configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromCustomScopeSet(scopeSet, topologyConfigurationSession.SessionSettings.RootOrgId, topologyConfigurationSession.SessionSettings.CurrentOrganizationId, topologyConfigurationSession.SessionSettings.ExecutingUserOrganizationId, true), 801, "VerifyStatusAndSelectDB", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\Provisioning\\LoadBalancing\\PhysicalResourceLoadBalancing.cs"); } try { Random random = new Random(); for (int i = databases.Count - 1; i >= 0; i--) { if (i != 0) { int index = random.Next(i + 1); MailboxDatabaseWithLocationInfo value = databases[index]; databases[index] = databases[i]; databases[i] = value; } MailboxDatabase mailboxDatabase = databases[i].MailboxDatabase; string text = string.Empty; try { if (configurationSession != null) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCheckingDatabaseIsAllowedOnScope(mailboxDatabase.Id.ToDNString()), logger); ADScopeException ex; if (!configurationSession.TryVerifyIsWithinScopes(mailboxDatabase, false, out ex)) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotInUserScope(mailboxDatabase.Id.ToDNString(), ex.ToString()), logger); goto IL_2C6; } } DatabaseLocationInfo databaseLocationInfo = databases[i].DatabaseLocationInfo; text = databaseLocationInfo.ServerFqdn; ADObjectId serverSite = databaseLocationInfo.ServerSite; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseAndServerTry(mailboxDatabase.Id.ToDNString(), text ?? "null"), logger); if (!string.IsNullOrEmpty(text) && !dictionary2.ContainsKey(text)) { ExRpcAdmin exRpcAdmin; if (dictionary.ContainsKey(text)) { exRpcAdmin = dictionary[text]; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbExRpcAdminExists, logger); } else { exRpcAdmin = ExRpcAdmin.Create("Client=Management", text, null, null, null); dictionary.Add(text, exRpcAdmin); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCreateNewExRpcAdmin, logger); } array[0] = mailboxDatabase.Id.ObjectGuid; array2 = exRpcAdmin.ListMdbStatus(array); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbTryRetrieveDatabaseStatus, logger); if ((array2[0].Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseFound, logger); return(new MailboxDatabaseWithLocationInfo(mailboxDatabase, databaseLocationInfo)); } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseIsNotOnline((int)array2[0].Status), logger); } else { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbServerDownSoMarkDatabaseDown, logger); } } catch (DatabaseNotFoundException ex2) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotFoundException(ex2.Message), logger); } catch (ObjectNotFoundException ex3) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException(ex3.Message), logger); } catch (MapiExceptionNetworkError mapiExceptionNetworkError) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNetworkError(mapiExceptionNetworkError.Message), logger); dictionary2.Add(text, text); } catch (MapiPermanentException ex4) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbPermanentException(ex4.Message), logger); dictionary2.Add(text, text); } catch (MapiRetryableException ex5) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRetryableException(ex5.Message), logger); } IL_2C6 :; } } finally { foreach (string text2 in dictionary.Keys) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDisposeExRpcAdmin(text2), logger); dictionary[text2].Dispose(); } } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger); return(null); }
// Token: 0x06000190 RID: 400 RVA: 0x00007EB0 File Offset: 0x000060B0 internal static bool IsOnlineDatabase(MdbStatus mdbStatus) { return((mdbStatus.Status & MdbStatusFlags.InRecoverySG) == MdbStatusFlags.Offline && (mdbStatus.Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline); }