Beispiel #1
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);
        }
Beispiel #2
0
        internal HazelcastClient GetClient()
        {
            HazelcastClient c = _client;

            if (c == null || !c.GetLifecycleService().IsRunning())
            {
                throw new HazelcastInstanceNotActiveException();
            }
            return(c);
        }
        /// <summary>
        ///     Creates a new hazelcast client using the given configuration object created programmaticly.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <returns>IHazelcastInstance.</returns>
        /// <code>
        ///     var configuration = new Configuration();
        ///     //configure configuration ...
        ///     var hazelcastInstance = Hazelcast.NewHazelcastClient(configuration);
        ///     var myMap = hazelcastInstance.GetMap("myMap");
        /// </code>
        public static IHazelcastInstance NewHazelcastClient(Configuration config)
        {
            if (config == null)
            {
                config = XmlClientConfigBuilder.Build();
            }
            var client = new HazelcastClient(config);

            client.Start();
            Clients.TryAdd(client._instanceName, client);
            return(client);
        }
        /// <summary>
        ///     Creates a new hazelcast client using the given configuration object created programmaticly.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <returns>IHazelcastInstance.</returns>
        /// <code>
        ///     var clientConfig = new ClientConfig();
        ///     //configure clientConfig ...
        ///     var hazelcastInstance = Hazelcast.NewHazelcastClient(clientConfig);
        ///     var myMap = hazelcastInstance.GetMap("myMap");
        /// </code>
        public static IHazelcastInstance NewHazelcastClient(ClientConfig config)
        {
            if (config == null)
            {
                config = XmlClientConfigBuilder.Build();
            }
            var client = new HazelcastClient(config);

            client.Start();
            var proxy = new HazelcastClientProxy(client);

            Clients.TryAdd(client.id, proxy);
            return(proxy);
        }
        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);
        }
 internal HazelcastClientProxy(HazelcastClient client)
 {
     _client = client;
 }
Beispiel #7
0
 public Statistics(HazelcastClient client)
 {
     _client  = client;
     _enabled = EnvironmentUtil.ReadBool("hazelcast.client.statistics.enabled") ?? false;
     _period  = EnvironmentUtil.ReadInt("hazelcast.client.statistics.period.seconds") ?? 3;
 }
 public LifecycleService(HazelcastClient client)
 {
     _client = client;
 }
 public LifecycleService(HazelcastClient client)
 {
     _client        = client;
     _eventExecutor = new StripedTaskScheduler(1, 1000, client.Name + ".lifecycle.event");
 }
Beispiel #10
0
        public ILifecycleService GetLifecycleService()
        {
            HazelcastClient hz = _client;

            return(hz != null?hz.GetLifecycleService() : new TerminatedLifecycleService());
        }