private Socket SendingSocketCreator(IPEndPoint target) { var s = new Socket(target.AddressFamily, SocketType.Stream, ProtocolType.Tcp); try { s.Connect(target); // Prep the socket so it will reset on close and won't Nagle s.LingerState = new LingerOption(true, 0); s.NoDelay = true; WriteConnectionPreemble(s, Constants.SiloDirectConnectionId); // Identifies this client as a direct silo-to-silo socket // Start an asynch receive off of the socket to detect closure var foo = new byte[4]; s.BeginReceive(foo, 0, 1, SocketFlags.None, ReceiveCallback, new Tuple <Socket, IPEndPoint, SocketManager>(s, target, this)); NetworkingStatisticsGroup.OnOpenedSendingSocket(); } catch (Exception) { try { s.Close(); } catch (Exception) { // ignore } throw; } return(s); }
public ClientStatisticsManager( ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions) { this.logStatistics = new LogStatistics(statisticsOptions.Value.LogWriteInterval, false, loggerFactory); MessagingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(); }
private static void FlushHandler(Object sender, LRU <IPEndPoint, Socket> .FlushEventArgs args) { if (args.Value == null) { return; } CloseSocket(args.Value); NetworkingStatisticsGroup.OnClosedSendingSocket(); }
public ClientStatisticsManager( SerializationStatisticsGroup serializationStatistics, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions) { this.statisticsOptions = statisticsOptions.Value; this.logStatistics = new LogStatistics(this.statisticsOptions.LogWriteInterval, false, serializationStatistics, loggerFactory); MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); }
internal ClientStatisticsManager(ClientConfiguration config) { this.config = config; runtimeStats = new RuntimeStatisticsGroup(); logStatistics = new LogStatistics(config.StatisticsLogWriteInterval, false); logger = LogManager.GetLogger(GetType().Name); MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(config.ResponseTimeout); }
internal void InvalidateEntry(IPEndPoint target) { Socket socket; if (!cache.RemoveKey(target, out socket)) { return; } CloseSocket(socket); NetworkingStatisticsGroup.OnClosedSendingSocket(); }
public ClientStatisticsManager(ClientConfiguration config, SerializationManager serializationManager, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { this.config = config; this.serviceProvider = serviceProvider; runtimeStats = new RuntimeStatisticsGroup(loggerFactory); logStatistics = new LogStatistics(config.StatisticsLogWriteInterval, false, serializationManager, loggerFactory); logger = new LoggerWrapper <ClientStatisticsManager>(loggerFactory); this.loggerFactory = loggerFactory; MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(config.ResponseTimeout); }
public ClientStatisticsManager(ClientConfiguration config, SerializationManager serializationManager, IServiceProvider serviceProvider) { this.config = config; this.serviceProvider = serviceProvider; runtimeStats = new RuntimeStatisticsGroup(); logStatistics = new LogStatistics(config.StatisticsLogWriteInterval, false, serializationManager); logger = LogManager.GetLogger(GetType().Name); MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(config.ResponseTimeout); }
public ClientStatisticsManager(ClientConfiguration config, SerializationManager serializationManager, IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, IOptions <ClusterClientOptions> clusterClientOptions) { this.config = config; this.statisticsOptions = statisticsOptions.Value; this.serviceProvider = serviceProvider; this.clusterClientOptions = clusterClientOptions.Value; runtimeStats = new RuntimeStatisticsGroup(loggerFactory); logStatistics = new LogStatistics(this.statisticsOptions.LogWriteInterval, false, serializationManager, loggerFactory); logger = loggerFactory.CreateLogger <ClientStatisticsManager>(); this.loggerFactory = loggerFactory; MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(config.ResponseTimeout); }
public ClientStatisticsManager( IOptions <MonitoringStorageOptions> storageOptions, SerializationManager serializationManager, IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions <ClientStatisticsOptions> statisticsOptions, IOptions <ClusterClientOptions> clusterClientOptions) { this.statisticsOptions = statisticsOptions.Value; this.storageOptions = storageOptions.Value; this.serviceProvider = serviceProvider; this.clusterClientOptions = clusterClientOptions.Value; logStatistics = new LogStatistics(this.statisticsOptions.LogWriteInterval, false, serializationManager, loggerFactory); logger = loggerFactory.CreateLogger <ClientStatisticsManager>(); MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(); this.dnsHostName = Dns.GetHostName(); }
private Socket SendingSocketCreator(IPEndPoint target) { var s = new Socket(target.AddressFamily, SocketType.Stream, ProtocolType.Tcp); try { s.EnableFastpath(); Connect(s, target, connectionTimeout); // Prep the socket so it will reset on close and won't Nagle s.LingerState = new LingerOption(true, 0); s.NoDelay = true; WriteConnectionPreamble(s, Constants.SiloDirectConnectionId); // Identifies this client as a direct silo-to-silo socket // Start an asynch receive off of the socket to detect closure var receiveAsyncEventArgs = new SocketAsyncEventArgs { BufferList = new List <ArraySegment <byte> > { new ArraySegment <byte>(new byte[4]) }, UserToken = new Tuple <Socket, IPEndPoint, SocketManager>(s, target, this) }; receiveAsyncEventArgs.Completed += ReceiveCallback; bool receiveCompleted = s.ReceiveAsync(receiveAsyncEventArgs); NetworkingStatisticsGroup.OnOpenedSendingSocket(); if (!receiveCompleted) { ReceiveCallback(this, receiveAsyncEventArgs); } } catch (Exception) { try { s.Dispose(); } catch (Exception) { // ignore } throw; } return(s); }
internal async Task Start(ClientConfiguration config, StatisticsProviderManager statsManager, IMessageCenter transport, Guid clientId) { MessagingStatisticsGroup.Init(false); NetworkingStatisticsGroup.Init(false); ApplicationRequestsStatisticsGroup.Init(config.ResponseTimeout); runtimeStats.Start(); // Configure Metrics IProvider statsProvider = null; if (!string.IsNullOrEmpty(config.StatisticsProviderName)) { var extType = config.StatisticsProviderName; statsProvider = statsManager.GetProvider(extType); var metricsDataPublisher = statsProvider as IClientMetricsDataPublisher; if (metricsDataPublisher == null) { var msg = String.Format("Trying to create {0} as a metrics publisher, but the provider is not configured." , extType); throw new ArgumentException(msg, "ProviderType (configuration)"); } var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher; if (configurableMetricsDataPublisher != null) { configurableMetricsDataPublisher.AddConfiguration( config.DeploymentId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address); } tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, runtimeStats) { MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval }; } else if (config.UseAzureSystemStore) { // Hook up to publish client metrics to Azure storage table var publisher = await ClientMetricsTableDataManager.GetManager(config, transport.MyAddress.Endpoint.Address, clientId); tableStatistics = new ClientTableStatistics(transport, publisher, runtimeStats) { MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval }; } // Configure Statistics if (config.StatisticsWriteLogStatisticsToTable) { if (statsProvider != null) { logStatistics.StatsTablePublisher = statsProvider as IStatisticsPublisher; // Note: Provider has already been Init-ialized above. } else if (config.UseAzureSystemStore) { var statsDataPublisher = await StatsTableDataManager.GetManager(false, config.DataConnectionString, config.DeploymentId, transport.MyAddress.Endpoint.ToString(), clientId.ToString(), config.DNSHostName); logStatistics.StatsTablePublisher = statsDataPublisher; } } logStatistics.Start(); }