private void FillMetrics(StringBuilder stats, ClientConnection ownerConnection)
        {
            AddStat(stats, "lastStatisticsCollectionTime", Clock.CurrentTimeMillis());
            AddStat(stats, "enterprise", "false");
            AddStat(stats, "clientType", "CSHARP");
            AddStat(stats, "clientVersion", DllVersion);
            AddStat(stats, "clusterConnectionTimestamp", ownerConnection.ConnectionStartTime);
            AddStat(stats, "clientAddress", ownerConnection.GetLocalSocketAddress());
            AddStat(stats, "clientName", _client.GetName());

            var credentials = _client.GetClientConfig().GetCredentials();

            AddStat(stats, "credentials.principal", credentials.GetPrincipal());

            foreach (var pair in _gauges)
            {
                var gaugeName      = pair.Key;
                var gaugeValueFunc = pair.Value;
                try
                {
                    var value = gaugeValueFunc();
                    AddStat(stats, gaugeName, value);
                }
                catch (Exception e)
                {
                    if (Logger.IsFinestEnabled())
                    {
                        Logger.Finest(string.Format("Could not collect data for gauge {0}", gaugeName), e);
                    }
                }
            }
        }
Example #2
0
        public LifecycleService(HazelcastClient client)
        {
            _client = client;
            var listenerConfigs = client.GetClientConfig().GetListenerConfigs();

            if (listenerConfigs != null && listenerConfigs.Count > 0)
            {
                foreach (var listenerConfig in listenerConfigs)
                {
                    var listener = listenerConfig.GetImplementation();
                    if (listener == null)
                    {
                        try
                        {
                            var className = listenerConfig.GetClassName();
                            var type      = Type.GetType(className);
                            if (type != null)
                            {
                                listener = Activator.CreateInstance(type) as IEventListener;
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.Severe(e);
                        }
                    }
                    var lifecycleListener = listener as ILifecycleListener;
                    if (lifecycleListener != null)
                    {
                        AddLifecycleListener(lifecycleListener);
                    }
                }
            }
            FireLifecycleEvent(LifecycleEvent.LifecycleState.Starting);
        }
        public LifecycleService(HazelcastClient client)
        {
            _client = client;
            var listenerConfigs = client.GetClientConfig().GetListenerConfigs();

            if (listenerConfigs != null && listenerConfigs.Count > 0)
            {
                foreach (var listenerConfig in listenerConfigs)
                {
                    if (listenerConfig.GetImplementation() is ILifecycleListener)
                    {
                        AddLifecycleListener((ILifecycleListener)listenerConfig.GetImplementation());
                    }
                }
            }
            FireLifecycleEvent(LifecycleEvent.LifecycleState.Starting);
        }