public static OwaService GetOwaService(ExchangePrincipal principal) { OwaService owaService = null; try { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 197); owaService = (from x in currentServiceTopology.FindAll <OwaService>(principal, ClientAccessType.External, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 200) where x.IsFrontEnd select x).FirstOrDefault <OwaService>(); if (owaService == null) { owaService = (from x in currentServiceTopology.FindAll <OwaService>(principal, ClientAccessType.Internal, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MultiMailboxSearch\\LinkUtils.cs", "GetOwaService", 207) where x.IsFrontEnd select x).FirstOrDefault <OwaService>(); } if (owaService == null) { Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToGetOWAService, null, new object[] { principal.MailboxInfo.Location.ServerFqdn }); } } catch (ReadTopologyTimeoutException ex) { Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToGetOWAServiceWithException, null, new object[] { principal.MailboxInfo.Location.ServerFqdn, ex.ToString() }); } return(owaService); }
public void Should_not_update_after_dispose() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application", new Dictionary <string, string> { { "key", "value1" } }); CreateReplicaNode(new ReplicaInfo("default", "application", "https://github.com/vostok")); using (var storage = GetApplicationsStorage()) { var expected = ServiceTopology.Build(new List <Uri> { new Uri("https://github.com/vostok") }, new Dictionary <string, string> { { "key", "value1" } }); ShouldReturnImmediately(storage, "default", "application", expected); storage.Dispose(); CreateApplicationNode("default", "application", new Dictionary <string, string> { { "key", "value2" } }); storage.UpdateAll(); ShouldReturnImmediately(storage, "default", "application", expected); } }
public static int?LookupVersion(string server) { int versionNumber; if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Cafe.ServersCache.Enabled) { try { bool flag; MiniServer serverByFQDN = ServersCache.GetServerByFQDN(server, out flag); versionNumber = serverByFQDN.VersionNumber; goto IL_90; } catch (LocalServerNotFoundException) { return(null); } } ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\Common\\Misc\\ServerLookup.cs", "LookupVersion", 45); if (!currentServiceTopology.TryGetServerVersion(server, out versionNumber, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Common\\Misc\\ServerLookup.cs", "LookupVersion", 47)) { return(null); } IL_90: return(new int?(versionNumber)); }
public static bool TryGetSite(this ServiceTopology serviceTopology, string fqdn, out Site site) { if (serviceTopology == null) { throw new ArgumentNullException("serviceTopology"); } if (string.IsNullOrEmpty(fqdn)) { throw new ArgumentNullException("fqdn"); } site = null; try { site = serviceTopology.GetSite(fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Misc\\Extensions.cs", "TryGetSite", 495); } catch (ServerNotFoundException) { return(false); } catch (ServerNotInSiteException) { return(false); } return(true); }
public void Should_track_application_properties() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application"); CreateReplicaNode(new ReplicaInfo("default", "application", "https://github.com/vostok")); using (var storage = GetApplicationsStorage()) { for (var times = 0; times < 10; times++) { var properties = new Dictionary <string, string> { { "key", $"value_{times}" } }; CreateApplicationNode("default", "application", properties); var expected = ServiceTopology.Build(new List <Uri> { new Uri("https://github.com/vostok") }, properties); if (times == 0) { ShouldReturnImmediately(storage, "default", "application", expected); } else { ShouldReturn(storage, "default", "application", expected); } } } }
// Token: 0x0600040F RID: 1039 RVA: 0x00017934 File Offset: 0x00015B34 public static bool TryGetSite(this ServiceTopology serviceTopology, string fqdn, out Site site) { if (serviceTopology == null) { throw new ArgumentNullException("serviceTopology"); } if (string.IsNullOrEmpty(fqdn)) { throw new ArgumentNullException("fqdn"); } site = null; try { site = serviceTopology.GetSite(fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Misc\\Extensions.cs", "TryGetSite", 483); } catch (ServerNotFoundException) { return(false); } catch (ServerNotInSiteException) { return(false); } return(true); }
protected override void RedirectIfNeeded(BackEndServer mailboxServer) { if (mailboxServer == null) { throw new ArgumentNullException("mailboxServer"); } if (!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 537); Site targetSite = currentServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 538); ADSite localSite = LocalSiteCache.LocalSite; if (!localSite.DistinguishedName.Equals(targetSite.DistinguishedName) && (!this.IsLocalRequest(LocalServerCache.LocalServerFqdn) || !this.IsLAMUserAgent(base.ClientRequest.UserAgent))) { HttpService targetService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.Internal, (ServiceType internalService) => internalService != null && internalService.IsFrontEnd && internalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 550); if (!this.ShouldExecuteSSORedirect(targetService)) { HttpService httpService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.IsFrontEnd && externalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 561); if (httpService != null) { Uri url = httpService.Url; if (Uri.Compare(url, base.ClientRequest.Url, UriComponents.Host, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0) { UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url); uriBuilder.Host = url.Host; ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaEcpProxyRequestHandler::RedirectIfNeeded]: Stop processing and redirect to {0}.", uriBuilder.Uri.AbsoluteUri); throw new ServerSideTransferException(uriBuilder.Uri.AbsoluteUri, LegacyRedirectTypeOptions.Silent); } } } } } }
public void Should_works_disconnected() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application"); CreateReplicaNode(new ReplicaInfo("default", "application", "https://github.com/vostok")); using (var storage = GetApplicationsStorage()) { var properties = new Dictionary <string, string> { { "key", "value" } }; CreateApplicationNode("default", "application", properties); var expected = ServiceTopology.Build(new List <Uri> { new Uri("https://github.com/vostok") }, properties); ShouldReturnImmediately(storage, "default", "application", expected); Ensemble.Stop(); ShouldReturnImmediately(storage, "default", "application", expected); Ensemble.Start(); ShouldReturnImmediately(storage, "default", "application", expected); } }
public void Should_never_forget_replicas() { topology = ServiceTopology.Build(new[] { replica1 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1 }.Cast <object>()); topology = ServiceTopology.Build(new List <Uri>(), null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1 }.Cast <object>()); topology = ServiceTopology.Build(new[] { replica2 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2 }.Cast <object>()); topology = ServiceTopology.Build(new[] { replica1, replica2 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2 }.Cast <object>()); topology = ServiceTopology.Build(new List <Uri>(), null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2 }.Cast <object>()); topology = ServiceTopology.Build(new[] { replica1, replica2, replica3 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2, replica3 }.Cast <object>()); topology = ServiceTopology.Build(new[] { replica3 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2, replica3 }.Cast <object>()); topology = ServiceTopology.Build(new List <Uri>(), null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2, replica3 }.Cast <object>()); }
private static Uri GetFrontEndHttpServiceUrl <ServiceType>(IExchangePrincipal exchangePrincipal) where ServiceType : HttpService { if (exchangePrincipal == null) { throw new ArgumentNullException("exchangePrincipal"); } if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && FrontEndLocator.IsDatacenter) { return(GlobalServiceUrls.GetExternalUrl <ServiceType>()); } ServiceTopology serviceTopology = FrontEndLocator.IsDatacenter ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276); ServerVersion serverVersion = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion); int majorversion = serverVersion.Major; IList <ServiceType> services = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.External, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 281); Uri uri = FrontEndLocator.FindServiceInList <ServiceType>(services); if (uri == null) { services = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.Internal, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 285); uri = FrontEndLocator.FindServiceInList <ServiceType>(services); } if (uri != null) { ExTraceGlobals.CafeTracer.TraceDebug <string>(0L, "[FrontEndLocator.GetFrontEndHttpServiceUrl] Found HTTP service for the specified back end server {0}.", exchangePrincipal.MailboxInfo.Location.ServerFqdn); return(uri); } throw new ServerNotFoundException("Unable to find proper HTTP service."); }
private void UpdateServiceTopology() { lock (updateServiceTopologySync) { ServiceTopology = ServiceTopology.Build(replicasContainer.Value, applicationContainer.Value?.Properties); } }
// Token: 0x060001F4 RID: 500 RVA: 0x00009BF0 File Offset: 0x00007DF0 private void TriggerServerMapRefreshIfNeeded(ServiceTopology topology, List <DownLevelServerStatusEntry> serverList) { bool flag = false; if (serverList.Count == 0) { flag = true; } using (List <DownLevelServerStatusEntry> .Enumerator enumerator = serverList.GetEnumerator()) { while (enumerator.MoveNext()) { if (!DownLevelServerManager.IsServerDiscoverable(enumerator.Current.BackEndServer.Fqdn)) { flag = true; break; } } } if (flag) { ThreadPool.QueueUserWorkItem(delegate(object o) { this.RefreshServerMap(true); }); } }
// Token: 0x06000254 RID: 596 RVA: 0x0000BC90 File Offset: 0x00009E90 private bool IsLocalSiteE15MailboxServer(BackEndServer server, string resourceForest) { if (!server.IsE15OrHigher) { return(false); } if ((!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossForestServerLocate.Enabled) || string.IsNullOrEmpty(resourceForest) || string.Equals(HttpProxyGlobals.LocalMachineForest.Member, resourceForest, StringComparison.OrdinalIgnoreCase)) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 238); Site site = null; try { site = currentServiceTopology.GetSite(server.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 243); } catch (ServerNotFoundException) { return(false); } catch (ServerNotInSiteException) { return(false); } if (HttpProxyGlobals.LocalSite.Member.Equals(site)) { return(true); } return(false); } return(false); }
// Token: 0x060005A4 RID: 1444 RVA: 0x0001F490 File Offset: 0x0001D690 protected override void RedirectIfNeeded(BackEndServer mailboxServer) { if (mailboxServer == null) { throw new ArgumentNullException("mailboxServer"); } if (!Utilities.IsPartnerHostedOnly && !CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).NoCrossSiteRedirect.Enabled) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 438); Site targetSite = currentServiceTopology.GetSite(mailboxServer.Fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 439); if (!LocalSiteCache.LocalSite.DistinguishedName.Equals(targetSite.DistinguishedName) && (!this.IsLocalRequest(LocalServerCache.LocalServerFqdn) || !this.IsLAMUserAgent(base.ClientRequest.UserAgent))) { HttpService targetService = currentServiceTopology.FindAny <ServiceType>(0, (ServiceType internalService) => internalService != null && internalService.IsFrontEnd && internalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 451); if (!this.ShouldExecuteSSORedirect(targetService)) { HttpService httpService = currentServiceTopology.FindAny <ServiceType>(1, (ServiceType externalService) => externalService != null && externalService.IsFrontEnd && externalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 462); if (httpService != null) { Uri url = httpService.Url; if (Uri.Compare(url, base.ClientRequest.Url, UriComponents.Host, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0) { UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url); uriBuilder.Host = url.Host; if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaEcpProxyRequestHandler::RedirectIfNeeded]: Stop processing and redirect to {0}.", uriBuilder.Uri.AbsoluteUri); } throw new HttpException(302, this.GetCrossSiteRedirectUrl(targetSite.DistinguishedName, uriBuilder.Path, uriBuilder.Query)); } } } } } }
private bool IsLocalSiteE15MailboxServer(BackEndServer server, string resourceForest) { if (!server.IsE15OrHigher) { return(false); } if ((!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossForestServerLocate.Enabled) || string.IsNullOrEmpty(resourceForest) || string.Equals(HttpProxyGlobals.LocalMachineForest.Member, resourceForest, StringComparison.OrdinalIgnoreCase)) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 226); Site other = null; try { other = currentServiceTopology.GetSite(server.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Cache\\LocalSiteMailboxServerCache.cs", "IsLocalSiteE15MailboxServer", 231); } catch (ServerNotFoundException) { return(false); } catch (ServerNotInSiteException) { return(false); } if (HttpProxyGlobals.LocalSite.Member.Equals(other)) { return(true); } return(false); } return(false); }
public void Should_track_application_replicas() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application"); using (var storage = GetApplicationsStorage()) { var expectedReplicas = new List <Uri>(); for (var times = 0; times < 10; times++) { CreateReplicaNode(new ReplicaInfo("default", "application", $"https://github.com/vostok/{times}")); expectedReplicas.Add(new Uri($"https://github.com/vostok/{times}")); var expected = ServiceTopology.Build(expectedReplicas, null); if (times == 0) { ShouldReturnImmediately(storage, "default", "application", expected); } else { ShouldReturn(storage, "default", "application", expected); } } } }
public void UpdateAll_should_force_update() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application"); using (var storage = GetApplicationsStorage()) { var expectedReplicas = new List <Uri>(); for (var times = 0; times < 10; times++) { var properties = new Dictionary <string, string> { { "key", $"value_{times}" } }; CreateApplicationNode("default", "application", properties); CreateReplicaNode(new ReplicaInfo("default", "application", $"https://github.com/vostok/{times}")); expectedReplicas.Add(new Uri($"https://github.com/vostok/{times}")); storage.UpdateAll(); var expected = ServiceTopology.Build(expectedReplicas, properties); ShouldReturnImmediately(storage, "default", "application", expected); } } }
public static string DiscoverEwsUrl(IExchangePrincipal mailbox) { Uri uri; if (!EwsHelper.IsDatacenter) { EwsHelper.Tracer.TraceDebug(0L, "Not running in DC. Will use ServiceTopology to discover the url"); ServerVersion mailboxVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion); IList <WebServicesService> list; try { ClientAccessType clientAccessType = EwsHelper.ClientAccessType; EwsHelper.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType); ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 119); list = currentServiceTopology.FindAll <WebServicesService>(mailbox, clientAccessType, delegate(WebServicesService service) { ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber); return(mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor <= serverVersion.Minor && !service.IsOutOfService); }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 121); } catch (LocalizedException arg) { EwsHelper.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailbox, arg); return(null); } if (list.Count == 0) { EwsHelper.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailbox); return(null); } WebServicesService webServicesService; if ((webServicesService = list.FirstOrDefault((WebServicesService service) => string.Equals(service.ServerFullyQualifiedDomainName, mailbox.MailboxInfo.Location.ServerFqdn, StringComparison.OrdinalIgnoreCase) && service.Url != null)) == null && (webServicesService = list.FirstOrDefault(delegate(WebServicesService service) { ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber); return(service.Url != null && mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor == serverVersion.Minor); })) == null) { webServicesService = list.FirstOrDefault((WebServicesService service) => service.Url != null); } WebServicesService webServicesService2 = webServicesService; uri = ((webServicesService2 == null) ? null : webServicesService2.Url); goto IL_1EA; } EwsHelper.Tracer.TraceDebug(0L, "Running in DC. Will use BackEndLocator to discover the url"); if (EwsHelper.discoveryEwsInternalUrl == null) { EwsHelper.discoveryEwsInternalUrl = (Func <IMailboxInfo, Uri>)Delegate.CreateDelegate(typeof(Func <IMailboxInfo, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetBackEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(IMailboxInfo) }, null)); } uri = EwsHelper.discoveryEwsInternalUrl(mailbox.MailboxInfo); IL_1EA: if (!(uri == null)) { return(uri.ToString()); } return(null); }
public void Should_return_new_replicas_from_new_topology() { topology = ServiceTopology.Build(new[] { replica1, replica2 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica1, replica2 }.Cast <object>()); topology = ServiceTopology.Build(new[] { replica2 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { replica2 }.Cast <object>()); }
public void Build_should_not_return_null_with_replicas_without_properties() { var topology = ServiceTopology.Build(new List <Uri>(), new Dictionary <string, string>()); topology.Should().NotBeNull(); topology.Replicas.Should().BeEmpty(); topology.Properties.Should().BeEmpty(); }
public void Should_filter_some_replicas_when_they_has_no_tags() { var applicationInfo = new ApplicationInfo(environment, application, null); topology = ServiceTopology.Build(replicas, applicationInfo.Properties.SetPersistentReplicaTags(replica1.ToString(), new TagCollection { "tag1" })); filter.Filter(replicas, context).Should().BeEquivalentTo(replica1); }
private Uri GetEcpUrl(ExchangePrincipal mailbox) { Uri uri = null; Exception ex = null; try { if (mailbox.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && GlobalSettings.IsMultiTenancyEnabled) { uri = FrontEndLocator.GetFrontEndEcpUrl(mailbox); AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (E15 Multitenancy)", mailbox, uri); } else { ServiceTopology serviceTopology = GlobalSettings.IsMultiTenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605); ServerVersion serverVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion); int majorversion = serverVersion.Major; IList <EcpService> list = serviceTopology.FindAll <EcpService>(mailbox, ClientAccessType.External, (EcpService service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 610); foreach (EcpService ecpService in list) { if (ecpService != null && ecpService.Url != null) { uri = ecpService.Url; AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (not E15 Multitenancy)", mailbox, uri); break; } } } } catch (ServerNotFoundException ex2) { ex = ex2; } catch (ADTransientException ex3) { ex = ex3; } catch (DataSourceOperationException ex4) { ex = ex4; } catch (DataValidationException ex5) { ex = ex5; } finally { if (ex != null) { AirSyncDiagnostics.TraceError <ExchangePrincipal, Exception>(ExTraceGlobals.RequestsTracer, null, "ABQMail:Could not retrieve ECP URL for user {0} - {1}", mailbox, ex); } } return(uri); }
public void Should_return_last_seen_non_empty_replicas_set() { var aliveReplicas = new[] { replica1, replica2 }; topology = ServiceTopology.Build(aliveReplicas, null); provider.GetCluster().Should().BeEquivalentTo(aliveReplicas.Cast <object>()); topology = ServiceTopology.Build(new List <Uri>(), null); provider.GetCluster().Should().BeEquivalentTo(aliveReplicas.Cast <object>()); }
public void Should_return_last_seen_non_empty_replicas_set_and_aply_new_blacklist_that_was_added_after_moment_of_caching() { var aliveReplicas = new[] { replica1, replica2 }; topology = ServiceTopology.Build(aliveReplicas, null); provider.GetCluster().Should().BeEquivalentTo(aliveReplicas.Cast <object>()); topology = ServiceTopology.Build(new List <Uri>(), CreateApplicationInfoPropertiesWithBlackList(new[] { replica1 })); provider.GetCluster().Should().BeEquivalentTo(new[] { replica2 }.Cast <object>()); }
public void Should_correct_merge_fqdn_and_nofqdn_replicas_and_replace_by_the_last_one_it_saw() { var r1 = new Uri("http://razr02:80"); var r2 = new Uri("http://razr02.domain.whatever:80"); topology = ServiceTopology.Build(new[] { r1 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { r1 }.Cast <object>()); topology = ServiceTopology.Build(new[] { r2 }, null); provider.GetCluster().Should().BeEquivalentTo(new[] { r2 }.Cast <object>()); }
public ServerInfoAnchorMailbox(BackEndServer backendServer, IRequestContext requestContext) : base(AnchorSource.ServerInfo, backendServer.Fqdn, requestContext) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\ServerInfoAnchorMailbox.cs", ".ctor", 60); int num; if (!currentServiceTopology.TryGetServerVersion(backendServer.Fqdn, out num, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\ServerInfoAnchorMailbox.cs", ".ctor", 62)) { throw new ArgumentException("Invalid value"); } this.BackEndServer = backendServer; }
public void Should_filter_all_blacklisted_replicas() { blacklist = new[] { replica2, replica1 }; var applicationInfo = new ApplicationInfo(environment, application, null); topology = ServiceTopology.Build( new[] { replica1, replica2 }, applicationInfo.Properties.SetBlacklist(blacklist)); provider.GetCluster().Should().BeEmpty(); }
public void Should_return_null_without_application() { CreateEnvironmentNode("default"); using (var storage = GetApplicationsStorage()) { ShouldReturnImmediately(storage, "default", "application", null); CreateApplicationNode("default", "application"); ShouldReturn(storage, "default", "application", ServiceTopology.Build(new Uri[0], null)); } }
private static Uri FindRedirectOwaUrlCrossSite(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause) { failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None; isSameAuthMethod = false; bool isSameAuthExternalService = false; OwaService clientExternalService = null; ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 390); string mailboxServerFQDN = backEndServer.Fqdn; new List <OwaService>(); currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService) { if (ServiceTopology.IsOnSite(owaService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 401) && owaService.ClientAccessType == ClientAccessType.External) { int major = OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major; if (major == expectedMajorVersion) { bool flag = false; if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None && (owaService.AuthenticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None)) { flag = true; if (!isSameAuthExternalService) { clientExternalService = null; isSameAuthExternalService = true; } } if (flag || !isSameAuthExternalService) { if (clientExternalService == null) { clientExternalService = owaService; return; } if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 432) < 0) { clientExternalService = owaService; } } } } }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 396); if (clientExternalService != null) { isSameAuthMethod = isSameAuthExternalService; return(clientExternalService.Url); } failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound; return(null); }
public void Should_return_empty_list_without_replicas() { CreateEnvironmentNode("default"); CreateApplicationNode("default", "application"); using (var storage = GetApplicationsStorage()) { ShouldReturnImmediately(storage, "default", "application", ServiceTopology.Build(new Uri[0], null)); CreateReplicaNode(new ReplicaInfo("default", "application", "https://github.com/vostok")); var expected = ServiceTopology.Build(new[] { new Uri("https://github.com/vostok") }, null); ShouldReturn(storage, "default", "application", expected); } }