Пример #1
0
 /// <summary>
 /// This function is called client is dis-connected
 /// </summary>
 /// <param name="clientID"></param>
 /// <param name="cacheId"></param>
 public void OnClientDisconnected(string clientID, string cacheId, Runtime.Caching.ClientInfo clientInfo, long count)
 {
     if (_cache != null)
     {
         _cache.OnClientDisconnected(clientID, cacheId, clientInfo, count);
     }
 }
Пример #2
0
 public virtual void OnClientConnectivityChange(string cacheId, Runtime.Caching.ClientInfo clientInfo,
                                                ConnectivityStatus status)
 {
     if (_listener != null)
     {
         _listener.OnClientConnectivityChange(cacheId, clientInfo, status);
     }
 }
 public virtual void OnClientConnectivityChange(string cacheId, Runtime.Caching.ClientInfo clientInfo,
                                                ConnectivityStatus status)
 {
     if (_parent._cacheClientConnectivityChanged != null)
     {
         _parent._cacheClientConnectivityChanged.Invoke(cacheId, clientInfo, status);
     }
 }
 public ClientConnectivityChangeTask(Broker parent, string cacheId, ClientInfo clientInfo,
                                     ConnectivityStatus status)
 {
     cacheId     = _cacheId;
     _clientInfo = clientInfo;
     _status     = status;
     _parent     = parent;
 }
Пример #5
0
 private void OnCacheClientConnectivityChanged(string cacheId, Runtime.Caching.ClientInfo client)
 {
     if (_client != null)
     {
         if (_client.ClientVersion >= 4124)
         {
             BulkEventItemResponse eventItem = new BulkEventItemResponse();
             eventItem.eventType = BulkEventItemResponse.EventType.CLIENT_CONNECTIVITY;
             eventItem.clientConnectivityChangeEvent =
                 EventHelper.GetClientConnectivityChangeEventResponse(cacheId, client);
             ClientManager clientReference = _client;
             if (clientReference != null)
             {
                 clientReference.ConnectionManager.EnqueueEvent(eventItem, clientReference.SlaveId);
             }
         }
     }
 }
Пример #6
0
        internal static ClientConnectivityChangeEventResponse GetClientConnectivityChangeEventResponse(string cacheId,
                                                                                                       Runtime.Caching.ClientInfo client)
        {
            ClientConnectivityChangeEventResponse response = new ClientConnectivityChangeEventResponse();

            response.cacheId                = cacheId;
            response.clientInfo             = new Common.Protobuf.ClientInfo();
            response.clientInfo.appName     = client.AppName;
            response.clientInfo.machineName = client.MachineName;
            response.clientInfo.ipAddress   = client.IPAddress.ToString();
            response.clientInfo.clientId    = client.ClientID;
            response.clientInfo.processId   = client.ProcessID;
            response.status = (int)client.Status;
            return(response);
        }
Пример #7
0
        public InitCommand(string clientid, string id, string clientLocalIP, IPAddress requestedServerAddress, Runtime.Caching.ClientInfo clientInfo)
        {
            _initCommand = new Alachisoft.NCache.Common.Protobuf.InitCommand();
            base.name    = "InitCommand";

            _currentVersion                     = Alachisoft.NCache.Common.ProductVersion.ProductInfo;
            _initCommand.cacheId                = id;
            _initCommand.clientId               = clientid;
            _initCommand.isDotnetClient         = true;
            _initCommand.requestId              = base.RequestId;
            _initCommand.clientInfo             = new ClientInfo();
            _initCommand.clientInfo.machineName = clientInfo.MachineName;
            _initCommand.clientInfo.processId   = clientInfo.ProcessID;
            _initCommand.clientInfo.appName     = clientInfo.AppName;
            _initCommand.clientInfo.clientId    = clientInfo.ClientID;
            if (_initCommand.productVersion == null)
            {
                _initCommand.productVersion = new Common.Protobuf.ProductVersion();
            }

            _initCommand.productVersion.AddiotionalData = _currentVersion.AdditionalData;
            _initCommand.productVersion.EditionID       = _currentVersion.EditionID;
            _initCommand.productVersion.MajorVersion1   = this.ParseToByteArray(_currentVersion.MajorVersion1);
            _initCommand.productVersion.MajorVersion2   = this.ParseToByteArray(_currentVersion.MajorVersion2);
            _initCommand.productVersion.MinorVersion1   = this.ParseToByteArray(_currentVersion.MinorVersion1);
            _initCommand.productVersion.MinorVersion2   = this.ParseToByteArray(_currentVersion.MinorVersion2);
            _initCommand.productVersion.ProductName     = _currentVersion.ProductName;


            _initCommand.clientVersion = 4620;
        }
Пример #8
0
        public static Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.Caching.ClientInfo> > GetCacheClients(string cacheName, string initialNodeName, Common.CacheManagement.CacheContext context, int port)
        {
            CacheService cacheService = GetCacheService(context);

            if (port != 0)
            {
                cacheService.Port = port;
            }
            string startingNode = initialNodeName;

            Alachisoft.NCache.Config.Dom.CacheServerConfig cacheServerConfig = null;
            Alachisoft.NCache.Management.ICacheServer      cacheServer       = null;
            Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.Caching.ClientInfo> > clientList = new Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.Caching.ClientInfo> >();

            try
            {
                if (initialNodeName.Equals(string.Empty))
                {
                    cacheServerConfig = GetCacheConfigThroughClientConfig(cacheName, port, context);

                    if (cacheServerConfig == null)
                    {
                        throw new ManagementException("cache with name " + cacheName + " not found in " + config);
                    }
                }
                else
                {
                    cacheService.ServerName = initialNodeName;
                    cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                    if (cacheServer == null)
                    {
                        throw new ManagementException("provided initial node not available");
                    }

                    cacheServerConfig = cacheServer.GetCacheConfiguration(cacheName);
                    if (cacheServerConfig == null)
                    {
                        throw new ManagementException(ErrorCodes.CacheInit.CACHE_NOT_REGISTERED_ON_NODE, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_NOT_REGISTERED_ON_NODE, cacheName));
                    }
                }

                //Copied Code from NCManager

                //For Local Cache
                if (cacheServerConfig.CacheType.Equals(LOCALCACHE, StringComparison.OrdinalIgnoreCase))
                {
                    if (cacheServerConfig.InProc)
                    {
                        throw new ArgumentException("API is not supported for Local Inproc Cache");
                    }

                    cacheService.ServerName = Environment.MachineName;
                    cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                    if (cacheServer != null)
                    {
                        if (cacheServer.IsRunning(cacheName))
                        {
                            Runtime.CacheManagement.ServerNode serverNode = new Runtime.CacheManagement.ServerNode();
                            serverNode.ServerIP = Environment.MachineName;

                            List <Alachisoft.NCache.Common.Monitoring.ClientProcessStats> clients = cacheServer.GetClientProcessStats(cacheServerConfig.Name);
                            List <Runtime.Caching.ClientInfo> list = new List <Runtime.Caching.ClientInfo>();
                            foreach (Alachisoft.NCache.Common.Monitoring.ClientProcessStats clientNode in clients)
                            {
                                Runtime.Caching.ClientInfo clientInfo = new Runtime.Caching.ClientInfo();
                                clientInfo.IPAddress = clientNode.Address.IpAddress;
                                clientInfo.ProcessID = Int32.Parse(clientNode.ProcessID);
                                list.Add(clientInfo);
                            }
                            clientList.Add(serverNode, list);
                        }
                    }
                    return(clientList);
                }
                //For Clustered Cache
                else
                {
                    ArrayList initialHost = InitialHostList(cacheServerConfig.Cluster.Channel.InitialHosts);
                    foreach (object host in initialHost)
                    {
                        try
                        {
                            cacheService.ServerName = (string)host;
                            cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                            if (cacheServer.IsRunning(cacheName))
                            {
                                Runtime.CacheManagement.ServerNode serverNode = new Runtime.CacheManagement.ServerNode();
                                serverNode.ServerIP = host as string;
                                serverNode.Port     = cacheServerConfig.Cluster.Channel.TcpPort;

                                List <Alachisoft.NCache.Common.Monitoring.ClientProcessStats> clients = cacheServer.GetClientProcessStats(cacheServerConfig.Name);
                                List <Runtime.Caching.ClientInfo> list = new List <Runtime.Caching.ClientInfo>();
                                foreach (Alachisoft.NCache.Common.Monitoring.ClientProcessStats clientNode in clients)
                                {
                                    Runtime.Caching.ClientInfo clientInfo = new Runtime.Caching.ClientInfo();
                                    clientInfo.IPAddress = clientNode.Address.IpAddress;
                                    clientInfo.ProcessID = Int32.Parse(clientNode.ProcessID);
                                    list.Add(clientInfo);
                                }
                                clientList.Add(serverNode, list);
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    return(clientList);
                }
            }
            catch (Exception ex)
            {
                throw new ManagementException(ex.Message);
            }
            finally
            {
                if (cacheServer != null)
                {
                    cacheServer.Dispose();
                }
                cacheService.Dispose();
            }
        }
Пример #9
0
        internal NCache(string cacheId, bool isDotNetClient, ClientManager client, string licenceInfo, string userId, string password, byte[] userIdBinary, byte[] paswordBinary, Runtime.Caching.ClientInfo clientInfo)
        {
            this._cacheId        = cacheId;
            this._isDotNetClient = isDotNetClient;
            this._client         = client;
            this._licenceCode    = licenceInfo;


            _cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cacheId);

            if (_cache == null)
            {
                throw new Exception("Cache is not registered");
            }

            if (!_cache.IsRunning)
            {
                throw new Exception("Cache is not running");
            }

            EventHelper.EventDataFormat = _cache.SocketServerDataService;
#if !CLIENT
            if (_cache.CacheType.Equals("mirror-server") && !_cache.IsCoordinator)
            {
                throw new OperationNotSupportedException("Cannot connect to Passive Node in Mirror Cluster.");
            }
#endif

            _onItemUpdatedCallback            = new CustomUpdateCallback(CustomUpdate);
            _cache.CustomUpdateCallbackNotif += _onItemUpdatedCallback;

            _onItemRemoveCallback             = new CustomRemoveCallback(CustomRemove);
            _cache.CustomRemoveCallbackNotif += _onItemRemoveCallback;

            _pollRequestCallback             = new Caching.PollRequestCallback(PollRequest);
            _cache.PollRequestCallbackNotif += _pollRequestCallback;


            if (SocketServer.Logger.IsErrorLogsEnabled)
            {
                SocketServer.Logger.NCacheLog.Error(_cacheserver + ".ctor", "Registering cache stopped event for " + _client.ClientID);
            }

            _cacheStopped        = new CacheStoppedCallback(OnCacheStopped);
            _cache.CacheStopped += _cacheStopped;

            if (SocketServer.Logger.IsErrorLogsEnabled)
            {
                SocketServer.Logger.NCacheLog.Error(_cacheserver + ".ctor", "Cache stopped event registered for " + _client.ClientID);
            }



            _asyncOperationCallback         = new AsyncOperationCompletedCallback(AsyncOperationCompleted);
            _cache.AsyncOperationCompleted += _asyncOperationCallback;


            _cacheBecomeActive        = new CacheBecomeActiveCallback(OnCacheBecomeActive);
            _cache.CacheBecomeActive += _cacheBecomeActive;

            _configModified = new ConfigurationModified(OnConfigModified);
            _cache.ConfigurationModified += _configModified;

            _onCompactTypeModifiedCallback = new CompactTypeModifiedCallback(CompactTypesModified);
            _cache.CompactTypeModified    += _onCompactTypeModifiedCallback;

            _blockClientActivity  = new BlockClientActivity(BlockClientActivity);
            _cache.BlockActivity += this._blockClientActivity;

            _unblockClientActivity  = new UnBlockClientActivity(UnBlockClientActivity);
            _cache.UnBlockActivity += this._unblockClientActivity;

            _operationModeChanged       += new OperationModeChangedCallback(OperationModeChanged);
            _cache.OperationModeChanged += _operationModeChanged;
        }
Пример #10
0
        public InitCommand(string clientid, string id, string clientLocalIP, IPAddress requestedServerAddress, Runtime.Caching.ClientInfo clientInfo, int operationTimeout)
        {
            _initCommand = new Alachisoft.NCache.Common.Protobuf.InitCommand();


            _currentVersion                     = Alachisoft.NCache.Common.ProductVersion.ProductInfo;
            _initCommand.cacheId                = id;
            _initCommand.clientId               = clientid;
            _initCommand.isDotnetClient         = true;
            _initCommand.requestId              = base.RequestId;
            _initCommand.clientInfo             = new ClientInfo();
            _initCommand.clientInfo.machineName = clientInfo.MachineName;
            _initCommand.clientInfo.processId   = clientInfo.ProcessID;
            _initCommand.clientInfo.appName     = clientInfo.AppName;
            _initCommand.clientVersion          = clientInfo.ClientVersion;
            _initCommand.clientInfo.clientId    = clientInfo.ClientID;


            //Protobuf. Product Version is assigned values
            if (_initCommand.productVersion == null)
            {
                _initCommand.productVersion = new Common.Protobuf.ProductVersion();
            }

            _initCommand.productVersion.AddiotionalData = _currentVersion.AdditionalData;
            _initCommand.productVersion.EditionID       = _currentVersion.EditionID;
            _initCommand.productVersion.MajorVersion1   = this.ParseToByteArray(_currentVersion.MajorVersion1);
            _initCommand.productVersion.MajorVersion2   = this.ParseToByteArray(_currentVersion.MajorVersion2);
            _initCommand.productVersion.MinorVersion1   = this.ParseToByteArray(_currentVersion.MinorVersion1);
            _initCommand.productVersion.MinorVersion2   = this.ParseToByteArray(_currentVersion.MinorVersion2);
            _initCommand.productVersion.ProductName     = _currentVersion.ProductName;

            _initCommand.operationTimeout = operationTimeout;
            _initCommand.clientVersion    = 5000;
            _initCommand.OperationSystem  = GetOSPlatform().ToString();
        }