/// <summary>
        /// Called after the membership has been changed. Lets the members do some
        /// member oriented tasks.
        /// </summary>
        public override void OnAfterMembershipChange()
        {
            base.OnAfterMembershipChange();
            _context.ExpiryMgr.AllowClusteredExpiry = Cluster.IsCoordinator;

            if (_taskUpdate == null)
            {
                _taskUpdate = new PeriodicPresenceAnnouncer(this, _statsReplInterval);
                _context.TimeSched.AddTask(_taskUpdate);

                StartStateTransfer();
            }

            if (_localStatsUpdater == null)
            {
                _localStatsUpdater = new PeriodicStatsUpdater(this);
                _context.TimeSched.AddTask(_localStatsUpdater);
            }

            Context.NCacheLog.Info("OnAfterMembershipChange", "bridge replicator started with source cache unique id: " + ((ClusterCacheBase)this).BridgeSourceCacheId);

            
            //async replicator is used to replicate the update index operations to other replica nodes.
            if (Cluster.Servers.Count > 1)
            {
                if (_asyncReplicator == null) _asyncReplicator = new AsyncItemReplicator(Context, new TimeSpan(0, 0, 2));
                _asyncReplicator.Start();
                Context.NCacheLog.CriticalInfo("OnAfterMembershipChange", "async-replicator started.");
            }
            else
            {
                if (_asyncReplicator != null)
                {
                    _asyncReplicator.Stop(false);
                    _asyncReplicator = null;
                    Context.NCacheLog.CriticalInfo("OnAfterMembershipChange", "async-replicator stopped.");
                }
            }

            UpdateCacheStatistics();
        }
        /// <summary>
        /// Called after the membership has been changed. Lets the members do some
        /// member oriented tasks.
        /// </summary>
        public override void OnAfterMembershipChange()
        {
            //Ata
            //nTrace.error("PartitionedCache.OnAfterMembershipChanged", "membership changed");
            try
            {
                NotifyHashmapChanged(Cluster.LastViewID, _distributionMgr.GetOwnerHashMapTable(Cluster.Renderers), GetClientMappedServers(Cluster.Servers.Clone() as ArrayList),true, true);
            }
            catch (Exception exc)
            {
            }

            base.OnAfterMembershipChange();

            if (_taskUpdate == null)
            {
                _taskUpdate = new PeriodicPresenceAnnouncer(this, _statsReplInterval);
                _context.TimeSched.AddTask(_taskUpdate);
                _statusLatch.SetStatusBit(NodeStatus.Running, NodeStatus.Initializing);

                //Set joining completion status.
                _initialJoiningStatusLatch.SetStatusBit(NodeStatus.Running, NodeStatus.Initializing);
            }

            //muds:
            //coordinator is responsible for carrying out the automatic load
            //balancing...
            if (Cluster.IsCoordinator)
            {
                if (_isAutoBalancingEnabled)
                {
                    if (_autoBalancingTask == null)
                    {
                        _autoBalancingTask = new AutomaticDataLoadBalancer(this, _autoBalancingInterval);
                        _context.TimeSched.AddTask(_autoBalancingTask);
                    }
                }
            }

           StartStateTransfer(false);

            UpdateCacheStatistics();
            //We announces our status aa uninitalized
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or 
        /// resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
            if (_stateTransferTask != null)
            {
                _stateTransferTask.StopProcessing();
            }
            if (_taskUpdate != null)
            {
                _taskUpdate.Cancel();
                _taskUpdate = null;
            }

            if (_localStatsUpdater != null)
            {
                _localStatsUpdater.Cancel();
                _localStatsUpdater = null;
            }

            if (_internalCache != null)
            {
                _internalCache.Dispose();
                _internalCache = null;
            }

            base.Dispose();
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or 
        /// resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
            HasDisposed = true;

            if (_taskUpdate != null)
            {
                _taskUpdate.Cancel();
                _taskUpdate = null;
            }
            if (_autoBalancingTask != null)
            {
                _autoBalancingTask.Cancel();
                _autoBalancingTask = null;
            }
            if (_internalCache != null)
            {
                _internalCache.Dispose();
                _internalCache = null;
            }
            if (_stateTransferTask != null)
            {
                _stateTransferTask.Stop();
                _stateTransferTask = null;
            }

            threadRunning = false;
            base.Dispose();
        }