Ejemplo n.º 1
0
        /// <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();
        }
Ejemplo n.º 2
0
        /// <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();
        }