public string AddDistributedObjectListener(IDistributedObjectListener listener) { var isSmart = _client.GetClientConfig().GetNetworkConfig().IsSmartRouting(); var request = ClientAddDistributedObjectListenerCodec.EncodeRequest(isSmart); var context = new ClientContext(_client.GetSerializationService(), _client.GetClientClusterService(), _client.GetClientPartitionService(), _client.GetInvocationService(), _client.GetClientExecutionService(), _client.GetListenerService(), _client.GetNearCacheManager(), this, _client.GetClientConfig()); DistributedEventHandler eventHandler = delegate(IClientMessage message) { ClientAddDistributedObjectListenerCodec.EventHandler.HandleEvent(message, (name, serviceName, eventType) => { var _event = new LazyDistributedObjectEvent(eventType, serviceName, name, this); switch (eventType) { case DistributedObjectEvent.EventType.Created: listener.DistributedObjectCreated(_event); break; case DistributedObjectEvent.EventType.Destroyed: listener.DistributedObjectDestroyed(_event); break; default: Logger.Warning(string.Format("Undefined DistributedObjectListener event type received: {0} !!!", eventType)); break; } }); }; return(context.GetListenerService().RegisterListener(request, m => ClientAddDistributedObjectListenerCodec.DecodeResponse(m).response, ClientRemoveDistributedObjectListenerCodec.EncodeRequest, eventHandler)); }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; const int defaultHeartbeatInterval = 5000; const int defaultHeartbeatTimeout = 60000; var heartbeatTimeoutMillis = EnvironmentUtil.ReadInt("hazelcast.client.heartbeat.timeout") ?? defaultHeartbeatInterval; var heartbeatIntervalMillis = EnvironmentUtil.ReadInt("hazelcast.client.heartbeat.interval") ?? defaultHeartbeatTimeout; _heartbeatTimeout = TimeSpan.FromMilliseconds(heartbeatTimeoutMillis); _heartbeatInterval = TimeSpan.FromMilliseconds(heartbeatIntervalMillis); }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; var timeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds"); if (timeout > 0) { ThreadUtil.TaskOperationTimeOutMilliseconds = timeout.Value*1000; } _heartbeatTimeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.timeout") ?? _heartbeatTimeout; _heartbeatInterval = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.interval") ?? _heartbeatInterval; }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; var timeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds"); if (timeout > 0) { ThreadUtil.TaskOperationTimeOutMilliseconds = timeout.Value * 1000; } _heartbeatTimeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.timeout") ?? _heartbeatTimeout; _heartbeatInterval = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.interval") ?? _heartbeatInterval; }
public ClientClusterService(HazelcastClient client) { _client = client; var listenerConfigs = client.GetClientConfig().GetListenerConfigs(); 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 membershipListener = listener as IMembershipListener; if (membershipListener != null) { AddMembershipListenerWithoutInit(membershipListener); } } }
protected ClientInvocationService(HazelcastClient client) { _client = client; _redoOperations = client.GetClientConfig().GetNetworkConfig().IsRedoOperation(); _invocationTimeoutMillis = (EnvironmentUtil.ReadInt("hazelcast.client.invocation.timeout.seconds") ?? DefaultInvocationTimeout) * 1000; }
public string AddDistributedObjectListener(IDistributedObjectListener listener) { var isSmart = _client.GetClientConfig().GetNetworkConfig().IsSmartRouting(); var request = ClientAddDistributedObjectListenerCodec.EncodeRequest(isSmart); var context = new ClientContext(_client.GetSerializationService(), _client.GetClientClusterService(), _client.GetClientPartitionService(), _client.GetInvocationService(), _client.GetClientExecutionService(), _client.GetListenerService(), this, _client.GetClientConfig()); //EventHandler<PortableDistributedObjectEvent> eventHandler = new _EventHandler_211(this, listener); DistributedEventHandler eventHandler = delegate(IClientMessage message) { ClientAddDistributedObjectListenerCodec.AbstractEventHandler.Handle(message, (name, serviceName, type) => { var ns = new ObjectNamespace(serviceName, name); ClientProxy proxy; _proxies.TryGetValue(ns, out proxy); if (proxy == null) { proxy = GetProxy(serviceName, name); } var _event = new DistributedObjectEvent(type, serviceName, proxy); if (DistributedObjectEvent.EventType.Created.Equals(type)) { listener.DistributedObjectCreated(_event); } else { if (DistributedObjectEvent.EventType.Destroyed.Equals(type)) { listener.DistributedObjectDestroyed(_event); } } }); }; //PortableDistributedObjectEvent return(context.GetListenerService().RegisterListener(request, m => ClientAddDistributedObjectListenerCodec.DecodeResponse(m).response, ClientRemoveDistributedObjectListenerCodec.EncodeRequest, eventHandler)); }
public ProxyManager(HazelcastClient client) { _client = client; var listenerConfigs = client.GetClientConfig().GetListenerConfigs(); if (listenerConfigs != null && listenerConfigs.Count > 0) { foreach (var listenerConfig in listenerConfigs.Where(listenerConfig => listenerConfig.GetImplementation() is IDistributedObjectListener)) { AddDistributedObjectListener((IDistributedObjectListener)listenerConfig.GetImplementation()); } } }
public TransactionContextProxy(HazelcastClient client, TransactionOptions options) { _client = client; var clusterService = (ClientClusterService)client.GetClientClusterService(); TxnOwnerNode = client.GetClientConfig().GetNetworkConfig().IsSmartRouting() ? client.GetLoadBalancer().Next(): clusterService.GetMember(clusterService.GetOwnerConnectionAddress()); if (TxnOwnerNode == null) { throw new HazelcastException("Could not find matching member"); } _transaction = new TransactionProxy(client, options, TxnOwnerNode); }
public ClientListenerService(HazelcastClient client) { _client = client; _connectionManager = client.GetConnectionManager(); var eventTreadCount = EnvironmentUtil.ReadInt("hazelcast.client.event.thread.count") ?? DefaultEventThreadCount; var eventQueueCapacity = EnvironmentUtil.ReadInt("hazelcast.client.event.queue.capacity") ?? DefaultEventQueueCapacity; _eventExecutor = new StripedTaskScheduler(eventTreadCount, eventQueueCapacity, client.GetName() + ".event"); _registrationScheduler = new StripedTaskScheduler(1, eventQueueCapacity, client.GetName() + ".eventRegistration"); _registrations = new ConcurrentDictionary <string, ListenerRegistration>(); _eventHandlers = new ConcurrentDictionary <long, DistributedEventHandler>(); _failedRegistrations = new ConcurrentDictionary <ClientConnection, ICollection <ListenerRegistration> >(); IsSmart = client.GetClientConfig().GetNetworkConfig().IsSmartRouting(); }
public LifecycleService(HazelcastClient client) { this.client = client; IList<ListenerConfig> listenerConfigs = client.GetClientConfig().GetListenerConfigs(); if (listenerConfigs != null && listenerConfigs.Count > 0) { foreach (ListenerConfig listenerConfig in listenerConfigs) { if (listenerConfig.GetImplementation() is ILifecycleListener) { AddLifecycleListener((ILifecycleListener) listenerConfig.GetImplementation()); } } } FireLifecycleEvent(LifecycleEvent.LifecycleState.Starting); }
protected ClientInvocationService(HazelcastClient client) { _client = client; _redoOperations = client.GetClientConfig().GetNetworkConfig().IsRedoOperation(); var eventTreadCount = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.event.thread.count") ?? DefaultEventThreadCount; _taskScheduler = new StripedTaskScheduler(eventTreadCount); _invocationTimeoutMillis = (EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds") ?? DefaultInvocationTimeout) * 1000; _clientConnectionManager = client.GetConnectionManager(); _clientConnectionManager.AddConnectionListener(this); }
protected ClientInvocationService(HazelcastClient client) { _client = client; _redoOperations = client.GetClientConfig().GetNetworkConfig().IsRedoOperation(); var eventTreadCount = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.event.thread.count") ?? DefaultEventThreadCount; _taskScheduler = new StripedTaskScheduler(eventTreadCount); _invocationTimeoutMillis = (EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds") ?? DefaultInvocationTimeout) * 1000; _clientConnectionManager = (ClientConnectionManager)client.GetConnectionManager(); _clientConnectionManager.AddConnectionListener(this); }
public ClientInvocationService(HazelcastClient client) { _client = client; _redoOperations = client.GetClientConfig().GetNetworkConfig().IsRedoOperation(); var eventTreadCount = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.event.thread.count") ?? DefaultEventThreadCount; _taskScheduler = new StripedTaskScheduler(eventTreadCount); // TODO: These should be consoliated with the way it's done in the Java client _retryCount = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.request.retry.count") ?? _retryCount; _retryWaitTime = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.request.retry.wait.time") ?? _retryWaitTime; _clientConnectionManager = (ClientConnectionManager)client.GetConnectionManager(); _clientConnectionManager.AddConnectionListener(this); _clientConnectionManager.AddConnectionHeartBeatListener(this); }
public BaseNearCache GetOrCreateNearCache(string mapName) { var nearCacheConfig = _client.GetClientConfig().GetNearCacheConfig(mapName); return(nearCacheConfig == null ? null : _caches.GetOrAdd(mapName, newMapName => { BaseNearCache nearCache; if (SupportsRepairableNearCache()) { nearCache = new NearCache(newMapName, _client, nearCacheConfig); } else { nearCache = new NearCachePre38(newMapName, _client, nearCacheConfig); } InitNearCache(nearCache); return nearCache; })); }
public ClientClusterService(HazelcastClient client) { _membersRef.Set(new Dictionary <Address, IMember>()); _client = client; var networkConfig = GetClientConfig().GetNetworkConfig(); var connAttemptLimit = networkConfig.GetConnectionAttemptLimit(); _connectionAttemptPeriod = networkConfig.GetConnectionAttemptPeriod(); _connectionAttemptLimit = connAttemptLimit == 0 ? int.MaxValue : connAttemptLimit; _shuffleMemberList = EnvironmentUtil.ReadBool("hazelcast.client.shuffle.member.list") ?? false; var listenerConfigs = client.GetClientConfig().GetListenerConfigs(); 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 membershipListener = listener as IMembershipListener; if (membershipListener != null) { AddMembershipListenerWithoutInit(membershipListener); } } }
private ClientConfig GetClientConfig() { return(_client.GetClientConfig()); }