public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider) { lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; Running = false; MessagingConfiguration = config; GatewayManager = new GatewayManager(config, gatewayListProvider); PendingInboundMessages = new RuntimeQueue <Message>(); registrarGetSystemTarget = GrainClient.GetStaticMethodThroughReflection("Orleans", "Orleans.Runtime.ClientObserverRegistrarFactory", "GetSystemTarget", null); typeManagerGetSystemTarget = GrainClient.GetStaticMethodThroughReflection("Orleans", "Orleans.Runtime.TypeManagerFactory", "GetSystemTarget", null); gatewayConnections = new Dictionary <Uri, GatewayConnection>(); numMessages = 0; registeredLocalObjects = new HashSet <GrainId>(); grainBuckets = new WeakReference[config.ClientSenderBuckets]; logger = TraceLogger.GetLogger("Messaging.ProxiedMessageCenter", TraceLogger.LoggerType.Runtime); if (logger.IsVerbose) { logger.Verbose("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return(gatewayConnections.Values.Count(conn => conn.IsLive)); } }); if (StatisticsCollector.CollectQueueStats) { queueTracking = new QueueTrackingStatistic("ClientReceiver"); } }
public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider) { lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; Running = false; MessagingConfiguration = config; GatewayManager = new GatewayManager(config, gatewayListProvider); PendingInboundMessages = new BlockingCollection <Message>(); gatewayConnections = new Dictionary <Uri, GatewayConnection>(); numMessages = 0; grainBuckets = new WeakReference[config.ClientSenderBuckets]; logger = LogManager.GetLogger("Messaging.ProxiedMessageCenter", LoggerType.Runtime); if (logger.IsVerbose) { logger.Verbose("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return(gatewayConnections.Values.Count(conn => conn.IsLive)); } }); if (StatisticsCollector.CollectQueueStats) { queueTracking = new QueueTrackingStatistic("ClientReceiver"); } }
public ClientMessageCenter( IOptions <GatewayOptions> gatewayOptions, IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ExecutorService executorService, ILoggerFactory loggerFactory, IOptions <NetworkingOptions> networkingOptions, IOptions <StatisticsOptions> statisticsOptions) { this.loggerFactory = loggerFactory; this.openConnectionTimeout = networkingOptions.Value.OpenConnectionTimeout; this.SerializationManager = serializationManager; this.executorService = executorService; lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; GatewayManager = new GatewayManager(gatewayOptions.Value, gatewayListProvider, loggerFactory); PendingInboundMessages = new BlockingCollection <Message>(); gatewayConnections = new Dictionary <Uri, GatewayConnection>(); numMessages = 0; grainBuckets = new WeakReference[clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return(gatewayConnections.Values.Count(conn => conn.IsLive)); } }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public ClientMessageCenter( IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, GrainId clientId, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, ConnectionManager connectionManager, GatewayManager gatewayManager) { this.messageHandlers = new Action <Message> [Enum.GetValues(typeof(Message.Categories)).Length]; this.connectionManager = connectionManager; this.SerializationManager = serializationManager; MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; this.gatewayManager = gatewayManager; PendingInboundMessages = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = false }); numMessages = 0; this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { return(connectionManager.ConnectionCount); }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public ProxiedMessageCenter( ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> messagingOptions) { this.loggerFactory = loggerFactory; this.openConnectionTimeout = messagingOptions.Value.OpenConnectionTimeout; this.SerializationManager = serializationManager; lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; GatewayManager = new GatewayManager(config, gatewayListProvider, loggerFactory); PendingInboundMessages = new BlockingCollection <Message>(); gatewayConnections = new Dictionary <Uri, GatewayConnection>(); numMessages = 0; grainBuckets = new WeakReference[config.ClientSenderBuckets]; logger = new LoggerWrapper <ProxiedMessageCenter>(loggerFactory); if (logger.IsVerbose) { logger.Verbose("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return(gatewayConnections.Values.Count(conn => conn.IsLive)); } }); if (StatisticsCollector.CollectQueueStats) { queueTracking = new QueueTrackingStatistic("ClientReceiver"); } }
public ClientMessageCenter( IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, ClientGrainId clientId, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, ConnectionManager connectionManager, GatewayManager gatewayManager) { this.connectionManager = connectionManager; this.SerializationManager = serializationManager; MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; this.gatewayManager = gatewayManager; numMessages = 0; this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { return(connectionManager.ConnectionCount); }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider) { lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; Running = false; MessagingConfiguration = config; GatewayManager = new GatewayManager(config, gatewayListProvider); PendingInboundMessages = new BlockingCollection<Message>(); gatewayConnections = new Dictionary<Uri, GatewayConnection>(); numMessages = 0; grainBuckets = new WeakReference[config.ClientSenderBuckets]; logger = LogManager.GetLogger("Messaging.ProxiedMessageCenter", LoggerType.Runtime); if (logger.IsVerbose) logger.Verbose("Proxy grain client constructed"); IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return gatewayConnections.Values.Count(conn => conn.IsLive); } }); if (StatisticsCollector.CollectQueueStats) { queueTracking = new QueueTrackingStatistic("ClientReceiver"); } }
private void Test_GatewaySelection(IGatewayListProvider listProvider) { IList<Uri> gatewayUris = listProvider.GetGateways().GetResult(); Assert.IsTrue(gatewayUris.Count > 0, "Found some gateways. Data = {0}", Utils.EnumerableToString(gatewayUris)); var gatewayEndpoints = gatewayUris.Select(uri => { return new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port); }).ToList(); var cfg = new ClientConfiguration { Gateways = gatewayEndpoints }; var gatewayManager = new GatewayManager(cfg, listProvider); var counts = new int[4]; for (int i = 0; i < 2300; i++) { var ip = gatewayManager.GetLiveGateway(); var addr = IPAddress.Parse(ip.Host); Assert.AreEqual(IPAddress.Loopback, addr, "Incorrect IP address returned for gateway"); Assert.IsTrue((0 < ip.Port) && (ip.Port < 5), "Incorrect IP port returned for gateway"); counts[ip.Port - 1]++; } // The following needed to be changed as the gateway manager now round-robins through the available gateways, rather than // selecting randomly based on load numbers. //Assert.IsTrue((500 < counts[0]) && (counts[0] < 1500), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((500 < counts[1]) && (counts[1] < 1500), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((125 < counts[2]) && (counts[2] < 375), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((25 < counts[3]) && (counts[3] < 75), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((287 < counts[0]) && (counts[0] < 1150), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((287 < counts[1]) && (counts[1] < 1150), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((287 < counts[2]) && (counts[2] < 1150), "Gateway selection is incorrectly skewed"); //Assert.IsTrue((287 < counts[3]) && (counts[3] < 1150), "Gateway selection is incorrectly skewed"); int low = 2300 / 4; int up = 2300 / 4; Assert.IsTrue((low <= counts[0]) && (counts[0] <= up), "Gateway selection is incorrectly skewed. " + counts[0]); Assert.IsTrue((low <= counts[1]) && (counts[1] <= up), "Gateway selection is incorrectly skewed. " + counts[1]); Assert.IsTrue((low <= counts[2]) && (counts[2] <= up), "Gateway selection is incorrectly skewed. " + counts[2]); Assert.IsTrue((low <= counts[3]) && (counts[3] <= up), "Gateway selection is incorrectly skewed. " + counts[3]); }