public IEnumerable <DirectoryDatabase> GetDatabasesOwnedByServer(DirectoryServer server) { IOperationRetryManager retryManager = LoadBalanceOperationRetryManager.Create(this.logger); foreach (MailboxDatabase database in this.ConfigurationSession.GetDatabasesOnServer(server.Identity)) { DirectoryDatabase result = null; MailboxDatabase databaseCopy = database; OperationRetryManagerResult operationResult = retryManager.TryRun(delegate { result = this.DirectoryDatabaseFromDatabase(databaseCopy); }); if (!operationResult.Succeeded) { this.logger.LogError(operationResult.Exception, "Could not retrieve database {0} for server {1}.", new object[] { databaseCopy.Name, server.Name }); } else if (result != null) { yield return(result); } } yield break; }
protected virtual void InjectMoves(LoadContainer database, BatchName batchName, IEnumerable <LoadEntity> mailboxes, bool throwIfNotValid) { IRequestQueue injectorQueue = this.queueManager.GetInjectionQueue((DirectoryDatabase)database.DirectoryObject); IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(this.logger); using (IEnumerator <LoadEntity> enumerator = mailboxes.GetEnumerator()) { while (enumerator.MoveNext()) { LoadEntity mailbox = enumerator.Current; if (mailbox.DirectoryObject == null) { this.logger.Log(MigrationEventType.Warning, "Not injecting move for {0} because its DirectoryObject is null", new object[] { mailbox }); } else { OperationRetryManagerResult operationRetryManagerResult = operationRetryManager.TryRun(delegate { DirectoryObject directoryObject = mailbox.DirectoryObject; ConstraintValidationResult constraintValidationResult = database.Constraint.Accept(mailbox); if (constraintValidationResult.Accepted) { database.CommittedLoad += mailbox.ConsumedLoad; if (directoryObject.SupportsMoving) { DirectoryObject directoryObject2 = database.DirectoryObject; IRequest request = directoryObject.CreateRequestToMove(directoryObject2.Identity, batchName.ToString(), this.logger); injectorQueue.EnqueueRequest(request); return; } if (throwIfNotValid) { throw new ObjectCannotBeMovedException(mailbox.DirectoryObjectIdentity.ObjectType.ToString(), mailbox.DirectoryObjectIdentity.ToString()); } } else { this.logger.Log(MigrationEventType.Warning, "Not injecting move for {0} because it violates the target database constraints: {1}", new object[] { mailbox, constraintValidationResult }); if (throwIfNotValid) { constraintValidationResult.Constraint.ValidateAccepted(mailbox); } } }); if (!operationRetryManagerResult.Succeeded && throwIfNotValid) { throw operationRetryManagerResult.Exception; } } } } }
// Token: 0x06000370 RID: 880 RVA: 0x0001410C File Offset: 0x0001230C private AnrManager.LookupState GetNamesByAnrFromAD(string name, List <ResolvedRecipient> recipients) { IList <ABObject> addressBookObjects = null; OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate { addressBookObjects = this.GetAddressBookSession().FindByANR(name, 1000); }); if (operationRetryManagerResult.Succeeded) { using (IEnumerator <ABObject> enumerator = addressBookObjects.GetEnumerator()) { while (enumerator.MoveNext()) { ABObject abobject = enumerator.Current; if (abobject.CanEmail) { ResolvedRecipient resolvedRecipient = new ResolvedRecipient(new RecipientAddress { AddressOrigin = AddressOrigin.Directory, DisplayName = abobject.DisplayName, RoutingAddress = abobject.LegacyExchangeDN, RoutingType = "EX", SmtpAddress = abobject.EmailAddress }); ABContact abcontact = abobject as ABContact; if (abcontact != null) { resolvedRecipient.Picture = abcontact.Picture; } recipients.Add(resolvedRecipient); } } goto IL_F7; } } AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestTracer, 0, "AnrManager.GetNamesByAnrFromAD(): Exception thrown by FindByANR: {0}", operationRetryManagerResult.Exception); IL_F7: switch (recipients.Count) { case 0: return(AnrManager.LookupState.FoundNone); case 1: return(AnrManager.LookupState.FoundExact); default: return(AnrManager.LookupState.FoundMany); } }
protected override OperationRetryManagerResult InternalTryRun(Action operation) { OperationRetryManagerResult result = OperationRetryManagerResult.Success; Action operationToRun = operation; CommonUtils.ProcessKnownExceptionsWithoutTracing(delegate { this.Run(operationToRun); }, delegate(Exception exception) { this.logger.Log(MigrationEventType.Verbose, exception, "Error running operation {0}.", new object[] { operation.Method.Name }); OperationRetryManagerResultCode resultCode = CommonUtils.IsTransientException(exception) ? OperationRetryManagerResultCode.RetryableError : OperationRetryManagerResultCode.PermanentError; result = new OperationRetryManagerResult(resultCode, exception); return(true); }); return(result); }
public void Execute() { Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.SearchQueryLength, this.searchQuery.Length); if (this.user.IsConsumerOrganizationUser) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command not supported for consumer users"); return; } if (this.minRange >= GlobalSettings.MaxGALSearchResults) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command min range specified is outside our configured maximum. No results will be returned"); return; } UnicodeCategory unicodeCategory = char.GetUnicodeCategory(this.searchQuery, 0); if (this.searchQuery.Length < GlobalSettings.MinGALSearchLength && unicodeCategory != UnicodeCategory.OtherLetter) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch search string is shorter than MinGALSearchLength. No results will be returned"); Command.CurrentCommand.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, "SearchStringTooShort"); return; } OperationRetryManagerResult operationRetryManagerResult = GalSearchProvider.retryManager.TryRun(delegate { IABSessionSettings sessionSettings = ABDiscoveryManager.GetSessionSettings(this.user.ExchangePrincipal, new int?(this.lcid), null, GlobalSettings.SyncLog, this.user.ClientSecurityContextWrapper.ClientSecurityContext); using (ABSession absession = ADABSession.Create(sessionSettings)) { this.addressBookObjects = absession.FindByANR(this.searchQuery, GlobalSettings.MaxGALSearchResults); } }); if (operationRetryManagerResult.Succeeded) { if (this.pictureOptions != null && this.user.Features.IsEnabled(EasFeature.HDPhotos) && this.user.Context.Request.Version >= 160) { this.photoRetriever = new AirSyncPhotoRetriever(this.user.Context); List <string> list = new List <string>(); int num = this.minRange; while (this.addressBookObjects != null && num <= this.maxRange && num < this.addressBookObjects.Count) { ABObject abobject = this.addressBookObjects[num]; if (abobject == null) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned null addresBookObject. Continue."); } else { ABContact abcontact = abobject as ABContact; if (abcontact == null) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned object that is not a \"ABContact\". Continue."); } else { list.Add(abcontact.EmailAddress); } } num++; } this.photoRetriever.BeginGetThumbnailPhotoFromMailbox(list, this.pictureOptions.PhotoSize); } return; } if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException) { throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "ABSubsDisabled" }; } if (operationRetryManagerResult.Exception is DataValidationException) { throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "BadADDataInGalSearch" }; } if (operationRetryManagerResult.Exception is DataSourceOperationException) { throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "BadADDataSource" }; } if (operationRetryManagerResult.Exception != null) { throw operationRetryManagerResult.Exception; } throw new InvalidOperationException("GalSearch failed with result code: " + operationRetryManagerResult.ResultCode); }
public void RemoveFromDatabase() { ByteQuantifiedSize currentSize = this.database.GetSize().CurrentPhysicalSize; ByteQuantifiedSize currentSize2 = currentSize; List <NonConnectedMailbox> source = this.database.GetDisconnectedMailboxes().ToList <NonConnectedMailbox>(); this.context.Logger.LogInformation("Beginning soft-deleted mailbox cleanup on database '{0}'", new object[] { this.database.Name }); this.context.Logger.LogInformation("Current size of database '{0}' is {1}, with a target size of {2}", new object[] { this.database.Name, currentSize, this.targetDatabaseSize }); int totalCountRemoved = 0; ByteQuantifiedSize totalSizeRemoved = default(ByteQuantifiedSize); IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(1, TimeSpan.Zero, this.context.Logger); using (IEnumerator <NonConnectedMailbox> enumerator = (from o in source orderby o.DisconnectDate select o).GetEnumerator()) { while (enumerator.MoveNext()) { NonConnectedMailbox softDeletedMailbox = enumerator.Current; if (currentSize < this.targetDatabaseSize) { this.context.Logger.LogInformation("Current size of database '{0}' is below max size allowed by soft deleted threshold. Done deleting soft deleted mailboxes", new object[] { this.database.Name }); break; } if (softDeletedMailbox.IsSoftDeleted) { Exception exception = null; bool success = false; SoftDeletedMailboxRemovalLogEntry entry = new SoftDeletedMailboxRemovalLogEntry(); entry[SoftDeletedMailboxRemovalLogEntrySchema.MailboxGuid] = softDeletedMailbox.Guid; entry[SoftDeletedMailboxRemovalLogEntrySchema.DatabaseName] = this.database.Name; entry[SoftDeletedMailboxRemovalLogEntrySchema.TargetDatabaseSize] = this.targetDatabaseSize; entry[SoftDeletedMailboxRemovalLogEntrySchema.CurrentDatabaseSize] = currentSize; entry[SoftDeletedMailboxRemovalLogEntrySchema.OriginalDatabaseSize] = currentSize2; entry[SoftDeletedMailboxRemovalLogEntrySchema.MailboxSize] = softDeletedMailbox.PhysicalSize; OperationRetryManagerResult operationRetryManagerResult = operationRetryManager.TryRun(delegate { this.context.Logger.LogVerbose("Removing SoftDeleted Mailbox from database '{0}'. MailboxGuid: {1} MailboxSize: {2}", new object[] { this.database.Name, softDeletedMailbox.Guid, softDeletedMailbox.PhysicalSize }); SoftDeleteMailboxRemovalCheckRemoval mailboxRemovalReadiness = this.GetMailboxRemovalReadiness(softDeletedMailbox); entry[SoftDeletedMailboxRemovalLogEntrySchema.RemovalAllowed] = mailboxRemovalReadiness.CanRemove; entry[SoftDeletedMailboxRemovalLogEntrySchema.RemovalDisallowedReason] = mailboxRemovalReadiness.Reason; if (mailboxRemovalReadiness.CanRemove) { success = this.context.TryRemoveSoftDeletedMailbox(softDeletedMailbox.Guid, this.database.Guid, out exception); if (success) { currentSize -= softDeletedMailbox.PhysicalSize; totalCountRemoved++; totalSizeRemoved += softDeletedMailbox.PhysicalSize; this.context.Logger.LogVerbose("Mailbox '{0}' removed", new object[] { softDeletedMailbox.Guid }); } } }); if (!operationRetryManagerResult.Succeeded) { exception = operationRetryManagerResult.Exception; } entry[SoftDeletedMailboxRemovalLogEntrySchema.Removed] = success; entry[SoftDeletedMailboxRemovalLogEntrySchema.Error] = exception; this.logCollector.LogObject <SoftDeletedMailboxRemovalLogEntry>(entry); } } } this.context.Logger.LogInformation("Approximate final size of database '{0}' is {1}. Target size was {2}. {3} total mailboxes with total size of {4} deleted.", new object[] { this.database.Name, currentSize, this.targetDatabaseSize, totalCountRemoved, totalSizeRemoved }); this.context.Logger.LogInformation("Finished soft-deleted mailbox cleanup on database '{0}'", new object[] { this.database.Name }); }
// Token: 0x0600036E RID: 878 RVA: 0x00013D5C File Offset: 0x00011F5C private RecipientAddress ConstructStoreRecipientAddress(Participant participant, string displayName, StoreObjectId storeId) { RecipientAddress recipientAddress = new RecipientAddress(); recipientAddress.DisplayName = displayName; recipientAddress.AddressOrigin = AddressOrigin.Store; recipientAddress.RoutingType = participant.RoutingType; if (!string.IsNullOrEmpty(participant.EmailAddress)) { recipientAddress.RoutingAddress = participant.EmailAddress; if (string.Equals(recipientAddress.RoutingType, "EX", StringComparison.OrdinalIgnoreCase)) { string text = participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string; if (string.IsNullOrEmpty(text)) { ABObject recipient = null; OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate { recipient = this.GetAddressBookSession().FindByLegacyExchangeDN(recipientAddress.RoutingAddress); }); if (!operationRetryManagerResult.Succeeded) { if (operationRetryManagerResult.Exception is ABProviderLoadException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, EASServerStrings.UnableToLoadAddressBookProvider, operationRetryManagerResult.Exception, true) { ErrorStringForProtocolLogger = "ABProviderNotFound" }; } if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "ABSubscriptionDisabled" }; } if (operationRetryManagerResult.Exception is DataValidationException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "AnrError:ADDataInvalid" }; } if (operationRetryManagerResult.Exception is ABOperationException) { ABOperationException ex = (ABOperationException)operationRetryManagerResult.Exception; throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "AnrError:ABOperationException" }; } if (operationRetryManagerResult.Exception is ABTransientException) { AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestTracer, null, "AnrManager.ConstructStoreRecipientAddress(): ABTransientException was thrown by FindByLegacyExchangeDN: {0}", operationRetryManagerResult.Exception.Message); } } if (recipient == null) { return(null); } recipientAddress.SmtpAddress = recipient.EmailAddress; } else { recipientAddress.SmtpAddress = text; } } else { if (!string.Equals(recipientAddress.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase)) { return(null); } recipientAddress.SmtpAddress = recipientAddress.RoutingAddress; } } recipientAddress.StoreObjectId = storeId; return(recipientAddress); }