/// <summary>
 /// Fetch state from a cluster member. If the node is the coordinator there is
 /// no need to do the state transfer.
 /// </summary>
 protected override void StartStateTransfer(bool isBalanceDataLoad)
 {
     /// Tell everyone that we are not fully-functional, i.e., initilizing.
     if (NCacheLog.IsInfoEnabled)
         NCacheLog.Info("PartitionedCache.StartStateTransfer()", "Requesting state transfer " + LocalAddress);
     if (_stateTransferTask == null)
         _stateTransferTask = new StateTransferTask(this, Cluster.LocalAddress);
     _stateTransferTask.IsBalanceDataLoad = isBalanceDataLoad;
     _stateTransferTask.DoStateTransfer(_distributionMgr.GetBucketsList(Cluster.LocalAddress), false);
 }
        /// <summary>
        /// Fetch state from a cluster member. If the node is the coordinator there is
        /// no need to do the state transfer.
        /// </summary>
        protected void StartStateTransfer()
        {
            if (!Cluster.IsCoordinator)
            {
                /// Tell everyone that we are not fully-functional, i.e., initilizing.
                if (Context.NCacheLog.IsInfoEnabled) Context.NCacheLog.Info("ReplicatedCache.StartStateTransfer()", "Requesting state transfer " + LocalAddress);

                /// Start the initialization(state trasfer) task.
                if (_stateTransferTask == null) _stateTransferTask = new StateTransferTask(this);
                _context.AsyncProc.Enqueue(_stateTransferTask);
            }
            else
            {
                _stateTransferLatch.SetStatusBit((byte)ReplicatedStateTransferStatus.STATE_TRANSFER_COMPLETED, (byte)ReplicatedStateTransferStatus.UNDER_STATE_TRANSFER);
                _allowEventRaiseLocally = true;
                _statusLatch.SetStatusBit(NodeStatus.Running, NodeStatus.Initializing);
                UpdateCacheStatistics();
                AnnouncePresence(true);
            }
        }
        /// <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();
        }