private void GivenThereIsALoadBalancer(DownstreamReRoute reRoute, ILoadBalancer loadBalancer) { _reRoute = reRoute; _loadBalancer = loadBalancer; _factory.Setup(x => x.Get(_reRoute, _serviceProviderConfig)).ReturnsAsync(loadBalancer); _getResult = _loadBalancerHouse.Get(reRoute, _serviceProviderConfig).Result; }
public SessionHandler(ILogger <SessionHandler> logger, ILoadBalancer balancer, IHttpClientFactory factory, IOptions <RouterConfig> routerConfig) { _logger = logger; _balancer = balancer; _factory = factory; _routerConfig = routerConfig; }
public ConnectionManager(HazelcastClient client) { _client = client; _loadBalancer = client.LoadBalancer; // var config = client.ClientConfig; _networkConfig = config.GetNetworkConfig(); IsSmartRoutingEnabled = _networkConfig.IsSmartRouting(); _labels = client.ClientConfig.Labels; var connectionTimeout = _networkConfig.GetConnectionTimeout(); _connectionTimeout = connectionTimeout == 0 ? int.MaxValue : connectionTimeout; //TODO outboundPorts // this.networking = initNetworking(); // this.outboundPorts.addAll(getOutboundPorts()); // this.outboundPortCount = outboundPorts.size(); _heartbeat = new HeartbeatManager(client, this); _authenticationTimeout = _heartbeat.HeartbeatTimeout; _shuffleMemberList = EnvironmentUtil.ReadBool("hazelcast.client.shuffle.member.list") ?? false; _waitStrategy = InitializeWaitStrategy(client.ClientConfig); var connectionStrategyConfig = client.ClientConfig.GetConnectionStrategyConfig(); _asyncStart = connectionStrategyConfig.AsyncStart; _reconnectMode = connectionStrategyConfig.ReconnectMode; }
public static void ExecuteOnce(this ILoadBalancer lb, Action action, float delay = 0f) { LoadBalancedActionPool.RecycledOneTimeAction recycledOneTimeAction; Ensure.ArgumentNotNull(action, "action"); if (LoadBalancedActionPool._oneTimeActions == null) { LoadBalancedActionPool._oneTimeActions = new Queue <LoadBalancedActionPool.RecycledOneTimeAction>(1); } if (LoadBalancedActionPool._oneTimeActions.Count <= 0) { recycledOneTimeAction = new LoadBalancedActionPool.RecycledOneTimeAction() { action = action }; } else { recycledOneTimeAction = LoadBalancedActionPool._oneTimeActions.Dequeue(); recycledOneTimeAction.action = action; } if (delay <= 0f) { lb.Add(recycledOneTimeAction); return; } lb.Add(recycledOneTimeAction, delay, true); }
public ThriftFactory(IEnumerable <IPEndPoint> remoteHosts, int socketTimeout, Func <TSocket, T> clientBuilder) { this.clientBuilder = clientBuilder; thriftEndpoints = new List <ThriftEndpoint>(remoteHosts.Select(it => new ThriftEndpoint(it, new TSocketPool(it, socketTimeout)))); loadBalancer = new ThriftRoundRobinBalancer(thriftEndpoints); }
public ClientConnectionManager(HazelcastClient client, ILoadBalancer loadBalancer) { _client = client; _router = new Router(loadBalancer); var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; var timeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.request.timeout"); if (timeout > 0) { ThreadUtil.TaskOperationTimeOutMilliseconds = timeout.Value; } _heartBeatTimeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.timeout") ?? _heartBeatTimeout; _heartBeatInterval = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.interval") ?? _heartBeatInterval; }
/// <summary> /// Executes the specified long running action. /// </summary> /// <param name="lb">The load balancer.</param> /// <param name="longRunningAction">The long running action, i.e. an action that will execute in steps by means of an enumerator.</param> /// <param name="maxMillisecondsUsedPerFrame">The maximum milliseconds to use per frame.</param> /// <returns>>A handle that can be used to Stop, pause and resume the action.</returns> public static ILoadBalancedHandle Execute(this ILoadBalancer lb, IEnumerator longRunningAction, int maxMillisecondsUsedPerFrame) { Ensure.ArgumentNotNull(longRunningAction, "longRunningAction"); if (_longActions == null) { _longActions = new Queue <RecycledLongRunningAction>(1); } RecycledLongRunningAction lra; if (_longActions.Count > 0) { lra = _longActions.Dequeue(); lra.iter = longRunningAction; lra.maxMillisecondsUsedPerFrame = maxMillisecondsUsedPerFrame; } else { lra = new RecycledLongRunningAction { iter = longRunningAction, maxMillisecondsUsedPerFrame = maxMillisecondsUsedPerFrame }; } return(lb.Add(lra)); }
/// <summary> /// Executes the specified action once. /// </summary> /// <param name="lb">The load balancer.</param> /// <param name="action">The action.</param> /// <param name="delay">The delay until the action is executed.</param> public static void ExecuteOnce(this ILoadBalancer lb, Action action, float delay = 0f) { Ensure.ArgumentNotNull(action, "action"); if (_oneTimeActions == null) { _oneTimeActions = new Queue <RecycledOneTimeAction>(1); } RecycledOneTimeAction ota; if (_oneTimeActions.Count > 0) { ota = _oneTimeActions.Dequeue(); ota.action = action; } else { ota = new RecycledOneTimeAction { action = action }; } if (delay > 0f) { lb.Add(ota, delay, true); } else { lb.Add(ota); } }
private static ILoadBalancer ServiceUndeployedLoadBalancer() { ILoadBalancer environmentLoadBalancerWithNoNodes = Substitute.For <ILoadBalancer>(); environmentLoadBalancerWithNoNodes.TryGetNode().Returns(Task.FromResult <Node>(null)); return(environmentLoadBalancerWithNoNodes); }
public Server Choose(ILoadBalancer loadBalancer) { var count = 0; while (count++ < 10) { var servers = loadBalancer.ReachableServers(); var serversCount = servers?.Count ?? 0; if (serversCount == 0) { return(null); } var server = servers[GetModulo(serversCount)]; if (server == null) { Thread.Sleep(5 * 1000); continue; } if (server.IsAlive && server.ReadyToServe) { return(server); } } return(null); }
public UserService(ICAPPublisher publisher, IServiceFinder <ConsulService> serviceFinder, ILoadBalancer loadBalancer, IConfiguration configuration) { _publisher = publisher; _loadBalancer = loadBalancer; _serviceFinder = serviceFinder; _conf = configuration; }
public LoadBalancer(Illuminate.Contexts.AgentContext context, string logName) { _dataService = context.NodeDataService; LOGNAME = logName; _sentWarningMessages = new Dictionary<string, List<LoadBalancingWarning.WarningTypeEnum>>(); _systemLoads = new Dictionary<string, Illuminate.Node.Entities.ISystemLoad>(); _nodeAgentManagement = new NodeAgentManagement(_dataService, LOGNAME); _nodeAgentManagement.OnSendWarning += new NodeAgentManagement.OnSendWarningDelegate(QueueWarningEmail); _warningMessages = new List<LoadBalancingWarning>(); _nodeWarningSendTime = new Dictionary<string, DateTime>(); string warningDisplayName = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerDisplayName); if (!string.IsNullOrEmpty(warningDisplayName)) _warningDisplayName = warningDisplayName; Logger.WriteLine("LoadBalancerDisplayName: " + _warningDisplayName, Logger.Severity.Debug, LOGNAME); _warningFromAddress = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerFromAddress); if (string.IsNullOrEmpty(_warningFromAddress)) throw new Illuminate.Exceptions.ErrorException("LoadBalancerFromAddress either not defined or invalid."); Logger.WriteLine("LoadBalancerFromAddress: " + _warningFromAddress, Logger.Severity.Debug, LOGNAME); _warningToAddress = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerWarningDest); if (string.IsNullOrEmpty(_warningToAddress)) throw new Illuminate.Exceptions.ErrorException("LoadBalancerWarningTo either not defined or invalid."); Logger.WriteLine("LoadBalancerWarningTo: " + _warningToAddress, Logger.Severity.Debug, LOGNAME); if (!int.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.MaxWaitBeforeDead), out _maxWaitBeforeDead)) throw new Illuminate.Exceptions.ErrorException("MaxWaitBeforeDead either not defined or invalid."); Logger.WriteLine("MaxWaitBeforeDead: " + _maxWaitBeforeDead.ToString(), Logger.Severity.Debug, LOGNAME); if (!double.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.OptimalSystemLoad), out _optimalSystemLoad)) throw new Illuminate.Exceptions.ErrorException("OptimalSystemLoad either not defined or invalid."); Logger.WriteLine("OptimalSystemLoad: " + _optimalSystemLoad.ToString(), Logger.Severity.Debug, LOGNAME); if (!double.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.OptimalLoadWindowSize), out _optimalLoadWindowSize)) throw new Illuminate.Exceptions.ErrorException("OptimalLoadWindowSize either not defined or invalid."); Logger.WriteLine("OptimalLoadWindowSize: " + _optimalLoadWindowSize.ToString(), Logger.Severity.Debug, LOGNAME); _optimalSystemLoadLowerBound = _optimalSystemLoad - _optimalLoadWindowSize; _optimalSystemLoadUpperBound = _optimalSystemLoad + _optimalLoadWindowSize; string extendedLoadBalancer = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.ExtendedLoadBalancer); if (!string.IsNullOrEmpty(extendedLoadBalancer)) { Logger.WriteLine("ExtendedLoadBalancer: " + extendedLoadBalancer, Logger.Severity.Information, LOGNAME); try { Invoker inv = new Invoker(); _extendedLoadBalancer = (ILoadBalancer)inv.Invoke(context.AgentPath + extendedLoadBalancer, typeof(ILoadBalancer)); _extendedLoadBalancer.InitializePlugin(_dataService, LOGNAME); } catch (Exception ex) { Logger.WriteLine("Unable to load extended load balancer: " + ex.Message, Logger.Severity.Error, LOGNAME); _extendedLoadBalancer = null; } } //load initial data UpdateSystemLoadCache(); }
private void GivenThereIsALoadBalancer(DownstreamRoute route, ILoadBalancer loadBalancer) { _route = route; _loadBalancer = loadBalancer; _factory.Setup(x => x.Get(_route, _serviceProviderConfig)).Returns(new OkResponse <ILoadBalancer>(loadBalancer)); _getResult = _loadBalancerHouse.Get(route, _serviceProviderConfig); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } ILoadBalancer loadBalancer = CreateLoadBalancerFromConfig(); // read the rule from environment //if (Enum.TryParse(typeof(LoadBalancingRule), rule, out object readRule)) // loadBalancer.Rule = (LoadBalancingRule)readRule; app.UseMiddleware <ReverseMiddleware>(loadBalancer); app.Run(async(context) => { StringBuilder sb = new StringBuilder("<h1>Reverse Proxy Running</h1><br/>"); foreach (var s in loadBalancer.Services) { sb.Append($"<h2>{s.Value.Name}</h2>"); foreach (var host in s.Value.Hosts) { sb.Append($"<h5>{host.Address}:{host.Port}</h5>"); } } await context.Response.WriteAsync(sb.ToString()); }); }
private ILoadBalancer CreateLoadBalancer( IAzure azure, IResourceGroup resourceGroup, INetwork network, string lbName) { string privateFrontEndName = lbName + "-FE1"; string backendPoolName1 = lbName + "-BAP1"; string backendPoolName2 = lbName + "-BAP2"; string natPoolName1 = lbName + "-INP1"; string natPoolName2 = lbName + "-INP2"; ILoadBalancer loadBalancer = azure.LoadBalancers.Define(lbName) .WithRegion(resourceGroup.Region) .WithExistingResourceGroup(resourceGroup) // Add two rules that uses above backend and probe .DefineLoadBalancingRule(ruleName1) .WithProtocol(TransportProtocol.Tcp) .FromFrontend(privateFrontEndName) .FromFrontendPort(1000) .ToBackend(backendPoolName1) .WithProbe(probeName1) .Attach() .DefineLoadBalancingRule(ruleName2) .WithProtocol(TransportProtocol.Tcp) .FromFrontend(privateFrontEndName) .FromFrontendPort(1001) .ToBackend(backendPoolName2) .WithProbe(probeName2) .Attach() // Add two nat pools to enable direct VM connectivity to port 44 and 45 .DefineInboundNatPool(natPoolName1) .WithProtocol(TransportProtocol.Tcp) .FromFrontend(privateFrontEndName) .FromFrontendPortRange(8000, 8099) .ToBackendPort(44) .Attach() .DefineInboundNatPool(natPoolName2) .WithProtocol(TransportProtocol.Tcp) .FromFrontend(privateFrontEndName) .FromFrontendPortRange(9000, 9099) .ToBackendPort(45) .Attach() // Explicitly define the frontend .DefinePrivateFrontend(privateFrontEndName) .WithExistingSubnet(network, subnetName1) .Attach() // Add two probes one per rule .DefineHttpProbe(probeName1) .WithRequestPath("/") .Attach() .DefineHttpsProbe(probeName2) .WithRequestPath("/") .Attach() .WithSku(LoadBalancerSkuType.Standard) .Create(); return(loadBalancer); }
public AutoTestWithLoadBalanceService(IDiscoveryClient discoveryClient) { _discoveryClient = discoveryClient; _loadBalancer = new RandomLoadBalancer(_discoveryClient); _handler = new LoadBalancerHttpClientHandler(_loadBalancer); }
/// <summary> /// Channel统一管理 /// </summary> /// <param name="serviceDiscovery"></param> /// <param name="loadBalancer"></param> /// <param name="memoryCache"></param> /// <param name="grpcClientOptions"></param> public ChannelPool(IServiceDiscovery serviceDiscovery, ILoadBalancer loadBalancer, IMemoryCache memoryCache, IOptions <GrpcClientOptions> grpcClientOptions) { this._serviceDiscovery = serviceDiscovery; this._loadBalancer = loadBalancer; this._memoryCache = memoryCache; this._grpcClientOptions = grpcClientOptions.Value; this._serviceDiscovery.ServiceChanged += ServiceDiscovery_ServiceChanged; }
public EventBusKafka( ILoadBalancer <IKafkaPersistentConnection> receiveLoadBlancer, ILoadBalancer <IKafkaPersistentConnection> senderLoadBlancer, ILogger <IEventBus> logger, IServiceProvider lifetimeScope, int reveiverMaxDegreeOfParallelism = 10, int receiverAcquireRetryAttempts = 0, int receiverHandlerTimeoutMillseconds = 0, int senderRetryCount = 3, int senderConfirmTimeoutMillseconds = 1000, int senderConfirmFlushTimeoutMillseconds = 50) { this._reveiverMaxDegreeOfParallelism = reveiverMaxDegreeOfParallelism; this._receiveLoadBlancer = receiveLoadBlancer; this._senderLoadBlancer = senderLoadBlancer; this._senderConfirmTimeoutMillseconds = senderConfirmTimeoutMillseconds; this._senderConfirmFlushTimeoutMillseconds = senderConfirmFlushTimeoutMillseconds; this._lifetimeScope = lifetimeScope ?? throw new ArgumentNullException(nameof(lifetimeScope)); this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); #region 生产端策略 this._senderRetryPolicy = Policy.NoOpAsync();//创建一个空的Policy this._senderRetryPolicy = _senderRetryPolicy.WrapAsync(Policy.Handle <KafkaException>() .Or <SocketException>() .Or <System.IO.IOException>() .WaitAndRetryAsync(senderRetryCount, retryAttempt => TimeSpan.FromMilliseconds(Math.Pow(2, retryAttempt)), (ex, time) => { _logger.LogError(ex.ToString()); })); #endregion #region 消费者策略 _receiverPolicy = Policy.NoOpAsync();//创建一个空的Policy if (receiverAcquireRetryAttempts > 0) { //设置重试策略 _receiverPolicy = _receiverPolicy.WrapAsync(Policy.Handle <Exception>() .RetryAsync(receiverAcquireRetryAttempts, (ex, time) => { _logger.LogError(ex, ex.ToString()); })); } if (receiverHandlerTimeoutMillseconds > 0) { // 设置超时 _receiverPolicy = _receiverPolicy.WrapAsync(Policy.TimeoutAsync( TimeSpan.FromMilliseconds(receiverHandlerTimeoutMillseconds), TimeoutStrategy.Pessimistic, (context, timespan, task) => { return(Task.FromResult(true)); })); } #endregion }
private void CreateLoadBalancer(TrafficRoutingStrategy trafficRoutingStrategy = TrafficRoutingStrategy.RandomByRequestID) { var createLoadBalancer = _kernel.Get <Func <DeploymentIdentifier, ReachabilityCheck, TrafficRoutingStrategy, ILoadBalancer> >(); _loadBalancer = createLoadBalancer( new DeploymentIdentifier(ServiceName, Env, _environment), (n, c) => _reachabilityCheck(n, c), trafficRoutingStrategy); }
public ClusterState(IClusterOptions options, string clusterName, string clientName, Partitioner partitioner, ILoadBalancer loadBalancer, ILoggerFactory loggerFactory) { Options = options; ClusterName = clusterName; ClientName = clientName; Partitioner = partitioner; LoadBalancer = loadBalancer; LoggerFactory = loggerFactory; }
public BestAvailableRuleTest() : base("BestAvailableRule") { _ping = new EasyHttpPing(_factory, 20); var collector = new DefaultServerStatusCollector(); var rule = new BestAvailableRule(collector); _loadBalancer = new BaseLoadBalancer(1 * 1000, base._name, rule, _ping, new SerialPingStrategy(), _factory); _command = new LoadBalancerCommand(_loadBalancer, collector, null, null); }
public LoadBalancingMiddleware( RequestDelegate next, ILogger <LoadBalancingMiddleware> logger, ILoadBalancer loadBalancer) { _next = next ?? throw new ArgumentNullException(nameof(next)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _loadBalancer = loadBalancer ?? throw new ArgumentNullException(nameof(loadBalancer)); }
public RabbitMQBus( ILoadBalancer <IRabbitMQPersistentConnection> publishLoadBlancer, ILoadBalancer <IRabbitMQPersistentConnection> subscribeLoadBlancer, IServiceProvider serviceProvider, ILogger <IBus> logger, int reveiverMaxDegreeOfParallelism = 10, int subscribeRetryCount = 0, int receiverHandlerTimeoutMillseconds = 0, int publishRetryCount = 3, ushort prefetchCount = 1, string exchange = "amp.topic", string exchangeType = "topic") { this._publishLoadBlancer = publishLoadBlancer; this._subscribeLoadBlancer = subscribeLoadBlancer; this._serviceProvider = serviceProvider; this._logger = logger; this._reveiverMaxDegreeOfParallelism = reveiverMaxDegreeOfParallelism; this._prefetchCount = prefetchCount; this._exchange = exchange; this._exchangeType = exchangeType; #region 生产者策略 this._eventBusPublishRetryPolicy = RetryPolicy.Handle <BrokerUnreachableException>() .Or <SocketException>() .Or <IOException>() .Or <AlreadyClosedException>() .WaitAndRetry(publishRetryCount, retryAttempt => TimeSpan.FromMilliseconds(Math.Pow(2, retryAttempt)), (ex, time) => { _logger.LogError(ex.ToString()); }); #endregion #region 消费者策略 _eventBusReceiverPolicy = Policy.NoOpAsync();//创建一个空的Policy if (subscribeRetryCount > 0) { //设置重试策略 _eventBusReceiverPolicy = _eventBusReceiverPolicy.WrapAsync(Policy.Handle <Exception>() .RetryAsync(subscribeRetryCount, (ex, time) => { _logger.LogError(ex, ex.ToString()); })); } if (receiverHandlerTimeoutMillseconds > 0) { // 设置超时 _eventBusReceiverPolicy = _eventBusReceiverPolicy.WrapAsync(Policy.TimeoutAsync(TimeSpan.FromSeconds(receiverHandlerTimeoutMillseconds), TimeoutStrategy.Pessimistic, (context, timespan, task) => { return(Task.FromResult(true)); })); } #endregion }
public LoadBalancerContext(ILoadBalancer loadBalancer, string vipAddress) { ClinetName = "default"; MaxAutoRetriesNextServer = 1; MaxAutoRetries = 0; RetryHandler = new DefaultRetryHandler(); RetryOnAllOperations = false; VipAddress = vipAddress; LoadBalancer = loadBalancer; }
public WeightedResponseTimeRuleTest() : base("WeightedResponseTimeRule") { _ping = new EasyHttpPing(_factory, 20); var collector = new DefaultServerStatusCollector(); var accumulater = new DefaultServerWeightAccumulater(collector); var rule = new WeightedResponseTimeRule(accumulater); _loadBalancer = new BaseLoadBalancer(1 * 1000, base._name, rule, _ping, new SerialPingStrategy(), _factory); _command = new LoadBalancerCommand(_loadBalancer, collector, null, null); }
public Response Add(string key, ILoadBalancer loadBalancer) { if (!_loadBalancers.ContainsKey(key)) { _loadBalancers.Add(key, loadBalancer); } _loadBalancers.Remove(key); _loadBalancers.Add(key, loadBalancer); return(new OkResponse()); }
public static IServiceCollection AddProxy( this IServiceCollection serviceCollection, ILoadBalancer loadBalancer) { if (serviceCollection == null) { throw new ArgumentNullException(nameof(serviceCollection)); } return(serviceCollection.AddSingleton <IProxy>(new Proxy(loadBalancer))); }
public async Task InvokeAsync(HttpContext context, IanvsContext ianvsContext, IIanvsConfigurationStore ianvsConfiguration, LoadBalancerFactory loadBalancerFactory) { // TODO: Implement Load Balancing // WIP - https://github.com/onyx-ws/ianvs/issues/5 // Support for different load balancing modes - Random/Round Robin/etc. _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} finding load balancer"); string loadBalancerMode = ianvsContext.MatchedOperation.LoadBalancerMethod; if (string.IsNullOrWhiteSpace(loadBalancerMode)) { loadBalancerMode = ianvsContext.MatchedEndpoint.LoadBalancerMethod; } if (string.IsNullOrWhiteSpace(loadBalancerMode)) { loadBalancerMode = ianvsConfiguration.LoadBalancerMethod; } ILoadBalancer loadBalancer = loadBalancerFactory.GetLoadBalancer(loadBalancerMode); _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} {loadBalancerMode} load balancer found"); // Operation level servers take priority if (!(ianvsContext.MatchedOperation.Servers?.Count == 0)) { _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Selecting server out of {ianvsContext.MatchedOperation.Servers.Count} server(s)"); ianvsContext.TargetServer = await loadBalancer.Next(ianvsContext.MatchedOperation.Servers); _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Server {ianvsContext.TargetServer.Url} selected"); } // If not operation level servers then use Endpoint level servers else if (!(ianvsContext.MatchedEndpoint.Servers?.Count == 0)) { _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Selecting server out of {ianvsContext.MatchedEndpoint.Servers.Count} server(s)"); ianvsContext.TargetServer = await loadBalancer.Next(ianvsContext.MatchedEndpoint.Servers); _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Server {ianvsContext.TargetServer.Url} selected"); } // Else use global servers defined else { _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Selecting server out of {ianvsConfiguration.Servers.Count} server(s)"); ianvsContext.TargetServer = await loadBalancer.Next(ianvsConfiguration.Servers); _logger.LogInformation($"{Environment.MachineName} {ianvsContext.RequestId} Server {ianvsContext.TargetServer.Url} selected"); } ianvsContext.TargetUrl = ianvsContext.TargetServer.Url + (ianvsContext.MatchedEndpoint.Url == "/" ? "" : ianvsContext.MatchedEndpoint.Url); await _next(context); }
///GENMHASH:03CBA85933E5B90121E4F4AE70F457EE:95BCC3AF459B4DC5CF3EC334E7D52AE2 internal NicIPConfigurationImpl WithExistingLoadBalancerInboundNatRule(ILoadBalancer loadBalancer, string inboundNatRuleName) { foreach (var rule in loadBalancer.Inner.InboundNatRules) { if (rule.Name.Equals(inboundNatRuleName, StringComparison.OrdinalIgnoreCase)) { EnsureInboundNatRules().Add(rule); return(this); } } return(this); }
public ReverseMiddleware(RequestDelegate nextMiddleware, ILoadBalancer loadBalancer) { _next = nextMiddleware; if (_tracer == null) { _tracer = new LogFileTracer(); } LoadBalancer = loadBalancer; //extend the default number of outstanding http calls ServicePointManager.DefaultConnectionLimit = 150; }
/// <summary> /// Initializes a new instance of the <see cref="VNetWebRequester"/> class. /// </summary> /// <param name="balancer">the load balancer for the vnet nodes</param> /// <param name="contentType">Type of the content.</param> public VNetWebRequester(ILoadBalancer balancer, string contentType = "application/x-protobuf") { _balancer = balancer; _contentType = contentType; _credentialCache = null; }
internal Router(ILoadBalancer loadBalancer) { _loadBalancer = loadBalancer; }