Пример #1
0
 private void Start()
 {
     try
     {
         var configuredListeners = InstantiateConfiguredListenerObjects();
         LifecycleService.Start(configuredListeners);
         InvocationService.Start();
         ClusterService.Start(configuredListeners);
         ConnectionManager.Start();
         ClusterService.WaitInitialMemberListFetched();
         ConnectionManager.ConnectToAllClusterMembers();
         ListenerService.Start();
         ProxyManager.Init(ClientConfig);
         LoadBalancer.Init(((IHazelcastInstance)this).Cluster, ClientConfig);
         // Statistics.Start();
         AddClientConfigAddedListeners(configuredListeners);
     }
     catch (Exception e)
     {
         try
         {
             LifecycleService.Terminate();
         }
         catch (Exception)
         {
             //ignore
         }
         throw ExceptionUtil.Rethrow(e);
     }
 }
        private HazelcastClient(ClientConfig config)
        {
            this.config = config;
            var groupConfig = config.GetGroupConfig();

            instanceName = "hz.client_" + id + (groupConfig != null ? "_" + groupConfig.GetName() : string.Empty);

            //threadGroup = new ThreadGroup(instanceName);
            lifecycleService = new LifecycleService(this);
            try
            {
                string partitioningStrategyClassName = null;
                //TODO make partition strategy parametric
                //Runtime.GetProperty(PropPartitioningStrategyClass);
                IPartitioningStrategy partitioningStrategy;
                if (partitioningStrategyClassName != null && partitioningStrategyClassName.Length > 0)
                {
                    partitioningStrategy = null;
                }
                else
                {
                    //new Instance for partitioningStrategyClassName;
                    partitioningStrategy = new DefaultPartitioningStrategy();
                }
                serializationService =
                    new SerializationServiceBuilder().SetManagedContext(new HazelcastClientManagedContext(this,
                                                                                                          config.GetManagedContext()))
                    .SetConfig(config.GetSerializationConfig())
                    .SetPartitioningStrategy(partitioningStrategy)
                    .SetVersion(SerializationService.SerializerVersion)
                    .Build();
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
            proxyManager = new ProxyManager(this);

            //TODO EXECUTION SERVICE
            executionService  = new ClientExecutionService(instanceName, config.GetExecutorPoolSize());
            clusterService    = new ClientClusterService(this);
            loadBalancer      = config.GetLoadBalancer() ?? new RoundRobinLB();
            connectionManager = new ClientConnectionManager(this, loadBalancer);
            invocationService = GetInvocationService(config);
            listenerService   = new ClientListenerService(this);
            userContext       = new ConcurrentDictionary <string, object>();
            loadBalancer.Init(GetCluster(), config);
            proxyManager.Init(config);
            partitionService = new ClientPartitionService(this);
        }
Пример #3
0
        private HazelcastClient(ClientConfig config)
        {
            _config = config;
            var groupConfig = config.GetGroupConfig();

            _instanceName = "hz.client_" + _id + (groupConfig != null ? "_" + groupConfig.GetName() : string.Empty);

            _lifecycleService = new LifecycleService(this);
            try
            {
                //TODO make partition strategy parametric
                var partitioningStrategy = new DefaultPartitioningStrategy();
                _serializationService =
                    new SerializationServiceBuilder().SetManagedContext(new HazelcastClientManagedContext(this,
                                                                                                          config.GetManagedContext()))
                    .SetConfig(config.GetSerializationConfig())
                    .SetPartitioningStrategy(partitioningStrategy)
                    .SetVersion(SerializationService.SerializerVersion)
                    .Build();
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
            _proxyManager = new ProxyManager(this);

            //TODO EXECUTION SERVICE
            _executionService = new ClientExecutionService(_instanceName, config.GetExecutorPoolSize());
            _clusterService   = new ClientClusterService(this);
            _loadBalancer     = config.GetLoadBalancer() ?? new RoundRobinLB();

            _addressProvider          = new AddressProvider(_config);
            _connectionManager        = new ClientConnectionManager(this);
            _invocationService        = CreateInvocationService();
            _listenerService          = new ClientListenerService(this);
            _userContext              = new ConcurrentDictionary <string, object>();
            _partitionService         = new ClientPartitionService(this);
            _lockReferenceIdGenerator = new ClientLockReferenceIdGenerator();
            _statistics         = new Statistics(this);
            _nearCacheManager   = new NearCacheManager(this);
            _credentialsFactory = InitCredentialsFactory(config);
        }
 private HazelcastClient(Configuration config)
 {
     Configuration       = config;
     HazelcastProperties = new HazelcastProperties(config.Properties);
     if (config.InstanceName != null)
     {
         _instanceName = config.InstanceName;
     }
     else
     {
         _instanceName = "hz.client_" + _id;
     }
     LifecycleService = new LifecycleService(this);
     try
     {
         //TODO make partition strategy parametric
         var partitioningStrategy = new DefaultPartitioningStrategy();
         SerializationService = new SerializationServiceBuilder().SetConfig(config.SerializationConfig)
                                .SetPartitioningStrategy(partitioningStrategy)
                                .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build();
     }
     catch (Exception e)
     {
         throw ExceptionUtil.Rethrow(e);
     }
     ProxyManager = new ProxyManager(this);
     //TODO EXECUTION SERVICE
     ExecutionService         = new ExecutionService(_instanceName);
     LoadBalancer             = config.LoadBalancer ?? new RoundRobinLB();
     PartitionService         = new PartitionService(this);
     AddressProvider          = new AddressProvider(Configuration.NetworkConfig, HazelcastProperties);
     ConnectionManager        = new ConnectionManager(this);
     InvocationService        = new InvocationService(this);
     ListenerService          = new ListenerService(this);
     ClusterService           = new ClusterService(this);
     LockReferenceIdGenerator = new ClientLockReferenceIdGenerator();
     // Statistics = new Statistics(this);
     NearCacheManager   = new NearCacheManager(this);
     CredentialsFactory = config.SecurityConfig.AsCredentialsFactory() ??
                          new StaticCredentialsFactory(new UsernamePasswordCredentials());
 }
Пример #5
0
 private HazelcastClient(ClientConfig config)
 {
     ClientConfig = config;
     if (config.InstanceName != null)
     {
         _instanceName = config.InstanceName;
     }
     else
     {
         _instanceName = "hz.client_" + _id;
     }
     LifecycleService = new LifecycleService(this);
     try
     {
         //TODO make partition strategy parametric
         var partitioningStrategy = new DefaultPartitioningStrategy();
         SerializationService = new SerializationServiceBuilder().SetConfig(config.GetSerializationConfig())
                                .SetPartitioningStrategy(partitioningStrategy)
                                .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build();
     }
     catch (Exception e)
     {
         throw ExceptionUtil.Rethrow(e);
     }
     ProxyManager = new ProxyManager(this);
     //TODO EXECUTION SERVICE
     ExecutionService         = new ExecutionService(_instanceName, config.GetExecutorPoolSize());
     LoadBalancer             = config.GetLoadBalancer() ?? new RoundRobinLB();
     PartitionService         = new PartitionService(this);
     AddressProvider          = new AddressProvider(ClientConfig);
     ConnectionManager        = new ConnectionManager(this);
     InvocationService        = new InvocationService(this);
     ListenerService          = new ListenerService(this);
     ClusterService           = new ClusterService(this);
     LockReferenceIdGenerator = new ClientLockReferenceIdGenerator();
     // Statistics = new Statistics(this);
     NearCacheManager   = new NearCacheManager(this);
     CredentialsFactory = InitCredentialsFactory(config);
 }
 void IDisposable.Dispose()
 {
     LifecycleService.Shutdown();
 }
 void IHazelcastInstance.Shutdown()
 {
     LifecycleService.Shutdown();
 }