public DatabaseGuidRoutingEntry GetDatabaseGuidRoutingEntry(DatabaseGuidRoutingKey databaseGuidRoutingKey, IRoutingDiagnostics diagnostics) { if (databaseGuidRoutingKey == null) { throw new ArgumentNullException("databaseGuidRoutingKey"); } DatabaseGuidRoutingEntry result; try { BackEndServer backEndServerForDatabase = this.databaseLocationProvider.GetBackEndServerForDatabase(databaseGuidRoutingKey.DatabaseGuid, databaseGuidRoutingKey.DomainName, databaseGuidRoutingKey.ResourceForest, diagnostics); if (backEndServerForDatabase == null) { result = this.CreateFailedEntry(databaseGuidRoutingKey, "Could not find database"); } else { result = new SuccessfulDatabaseGuidRoutingEntry(databaseGuidRoutingKey, new ServerRoutingDestination(backEndServerForDatabase.Fqdn, new int?(backEndServerForDatabase.Version)), 0L); } } catch (DatabaseLocationProviderException ex) { result = this.CreateFailedEntry(databaseGuidRoutingKey, ex.Message); } return(result); }
public DatabaseGuidRoutingEntry GetDatabaseGuidRoutingEntry(DatabaseGuidRoutingKey databaseGuidRoutingKey, IRoutingDiagnostics diagnostics) { if (databaseGuidRoutingKey == null) { throw new ArgumentNullException("databaseGuidRoutingKey"); } DatabaseGuidRoutingEntry result; try { MailboxServerCacheEntry mailboxServerCacheEntry; if (this.sharedCache.TryGet <MailboxServerCacheEntry>(databaseGuidRoutingKey.DatabaseGuid.ToString(), out mailboxServerCacheEntry, diagnostics)) { result = new SuccessfulDatabaseGuidRoutingEntry(databaseGuidRoutingKey, new ServerRoutingDestination(mailboxServerCacheEntry.BackEndServer.Fqdn, new int?(mailboxServerCacheEntry.BackEndServer.Version)), DateTime.UtcNow.ToFileTimeUtc()); } else { result = null; } } catch (SharedCacheException ex) { ErrorRoutingDestination destination = new ErrorRoutingDestination(ex.Message); result = new FailedDatabaseGuidRoutingEntry(databaseGuidRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc()); } return(result); }
public SuccessfulDatabaseGuidRoutingEntry(DatabaseGuidRoutingKey key, ServerRoutingDestination destination, long timestamp) : base(key, timestamp) { if (destination == null) { throw new ArgumentNullException("destination"); } this.destination = destination; }
public FailedDatabaseGuidRoutingEntry(DatabaseGuidRoutingKey key, ErrorRoutingDestination destination, long timestamp) : base(key, timestamp) { if (destination == null) { throw new ArgumentNullException("destination"); } this.destination = destination; }
protected DatabaseGuidRoutingEntry(DatabaseGuidRoutingKey key, long timestamp) { if (key == null) { throw new ArgumentNullException("key"); } this.key = key; this.timestamp = timestamp; }
string ISharedCache.GetSharedCacheKeyFromRoutingKey(IRoutingKey key) { string text = string.Empty; switch (key.RoutingItemType) { case RoutingItemType.ArchiveSmtp: { ArchiveSmtpRoutingKey archiveSmtpRoutingKey = key as ArchiveSmtpRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.Smtp, archiveSmtpRoutingKey.SmtpAddress); text += "_Archive"; break; } case RoutingItemType.DatabaseGuid: { DatabaseGuidRoutingKey databaseGuidRoutingKey = key as DatabaseGuidRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.DatabaseGuid, databaseGuidRoutingKey.DatabaseGuid); break; } case RoutingItemType.MailboxGuid: { MailboxGuidRoutingKey mailboxGuidRoutingKey = key as MailboxGuidRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.MailboxGuid, mailboxGuidRoutingKey.MailboxGuid); break; } case RoutingItemType.Smtp: { SmtpRoutingKey smtpRoutingKey = key as SmtpRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.Smtp, smtpRoutingKey.SmtpAddress); break; } case RoutingItemType.ExternalDirectoryObjectId: { ExternalDirectoryObjectIdRoutingKey externalDirectoryObjectIdRoutingKey = key as ExternalDirectoryObjectIdRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.ExternalDirectoryObjectId, externalDirectoryObjectIdRoutingKey.UserGuid); break; } case RoutingItemType.LiveIdMemberName: { LiveIdMemberNameRoutingKey liveIdMemberNameRoutingKey = key as LiveIdMemberNameRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.LiveIdMemberName, liveIdMemberNameRoutingKey.LiveIdMemberName); break; } } return(text); }
IRoutingEntry IRoutingLookup.GetRoutingEntry(IRoutingKey routingKey, IRoutingDiagnostics diagnostics) { if (routingKey == null) { throw new ArgumentNullException("routingKey"); } if (diagnostics == null) { throw new ArgumentNullException("diagnostics"); } DatabaseGuidRoutingKey databaseGuidRoutingKey = routingKey as DatabaseGuidRoutingKey; if (databaseGuidRoutingKey == null) { string message = string.Format("Routing key type {0} is not supported", routingKey.GetType()); throw new ArgumentException(message, "routingKey"); } return(this.GetDatabaseGuidRoutingEntry(databaseGuidRoutingKey, diagnostics)); }
public static bool AddEntry(this ISharedCacheClient cacheClient, IRoutingEntry entry) { SuccessfulMailboxRoutingEntry firstRoutingEntry = entry as SuccessfulMailboxRoutingEntry; if (firstRoutingEntry != null) { DatabaseGuidRoutingDestination databaseGuidRoutingDestination = entry.Destination as DatabaseGuidRoutingDestination; if (databaseGuidRoutingDestination != null) { string sharedCacheKeyFromRoutingKey = cacheClient.GetSharedCacheKeyFromRoutingKey(entry.Key); AnchorMailboxCacheEntry anchorMailboxCacheEntry = new AnchorMailboxCacheEntry(); anchorMailboxCacheEntry.Database = new ADObjectId(databaseGuidRoutingDestination.DatabaseGuid, databaseGuidRoutingDestination.ResourceForest); anchorMailboxCacheEntry.DomainName = databaseGuidRoutingDestination.DomainName; DateTime utcNow = DateTime.UtcNow; string text; return(cacheClient.TryInsert(sharedCacheKeyFromRoutingKey, anchorMailboxCacheEntry.ToByteArray(), utcNow, out text)); } } else { SuccessfulDatabaseGuidRoutingEntry successfulDatabaseGuidRoutingEntry = entry as SuccessfulDatabaseGuidRoutingEntry; if (successfulDatabaseGuidRoutingEntry != null) { ServerRoutingDestination serverRoutingDestination = entry.Destination as ServerRoutingDestination; if (serverRoutingDestination != null) { BackEndServer backEndServer = new BackEndServer(serverRoutingDestination.Fqdn, serverRoutingDestination.Version ?? 0); string resourceForest; if (Utilities.TryExtractForestFqdnFromServerFqdn(backEndServer.Fqdn, out resourceForest)) { MailboxServerCacheEntry value = new MailboxServerCacheEntry(backEndServer, resourceForest, DateTime.UtcNow, false); DateTime utcNow2 = DateTime.UtcNow; DatabaseGuidRoutingKey databaseGuidRoutingKey = successfulDatabaseGuidRoutingEntry.Key as DatabaseGuidRoutingKey; string text2; return(cacheClient.TryInsert(databaseGuidRoutingKey.DatabaseGuid.ToString(), value, utcNow2, out text2)); } } } } return(false); }
private static IRoutingKey DeserializeRoutingKey(string type, string value) { switch (type) { case "ArchiveSmtp": { ArchiveSmtpRoutingKey result; if (ArchiveSmtpRoutingKey.TryParse(value, out result)) { return(result); } break; } case "DatabaseGuid": { DatabaseGuidRoutingKey result2; if (DatabaseGuidRoutingKey.TryParse(value, out result2)) { return(result2); } break; } case "MailboxGuid": { MailboxGuidRoutingKey result3; if (MailboxGuidRoutingKey.TryParse(value, out result3)) { return(result3); } break; } case "Smtp": { SmtpRoutingKey result4; if (SmtpRoutingKey.TryParse(value, out result4)) { return(result4); } break; } case "Server": { ServerRoutingKey result5; if (ServerRoutingKey.TryParse(value, out result5)) { return(result5); } break; } case "Oid": { ExternalDirectoryObjectIdRoutingKey result6; if (ExternalDirectoryObjectIdRoutingKey.TryParse(value, out result6)) { return(result6); } break; } case "LiveIdMemberName": { LiveIdMemberNameRoutingKey result7; if (LiveIdMemberNameRoutingKey.TryParse(value, out result7)) { return(result7); } break; } } return(new UnknownRoutingKey(type, value)); }
private FailedDatabaseGuidRoutingEntry CreateFailedEntry(DatabaseGuidRoutingKey databaseGuidRoutingKey, string message) { ErrorRoutingDestination destination = new ErrorRoutingDestination(message); return(new FailedDatabaseGuidRoutingEntry(databaseGuidRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc())); }