예제 #1
0
        /// <summary>
        /// Removes all entries from the store.
        /// </summary>
        internal override void ClearInternal()
        {
            base.ClearInternal();
            if (_keyList != null)
            {
                _keyList.Clear();
            }
            if (_logMgr != null)
            {
                _logMgr.Dispose();                  //it clears the operation loggers for each bucket
            }
            _keyListSize = 0;

            if (LocalBuckets == null)
            {
                return;
            }
            //clear the bucket stats
            IDictionaryEnumerator ide = LocalBuckets.GetEnumerator();

            while (ide.MoveNext())
            {
                BucketStatistics stats = ide.Value as BucketStatistics;
                if (stats != null)
                {
                    stats.Clear();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or
 /// resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     lock (_itemDict.SyncRoot)
     {
         _itemDict.Clear();
         _itemDict = null;
     }
     base.Dispose();
 }
예제 #3
0
        protected StateTxfrInfo GetData(int bucketId)
        {
            if (_result.Count > 0)
            {
                _result.Clear();
            }

            long sizeToSend = 0;

            lock (_parent._bucketStateTxfrStatus.SyncRoot)
            {
                _parent._bucketStateTxfrStatus[bucketId] = true;
            }

            if (_parent.Context.NCacheLog.IsInfoEnabled)
            {
                _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "state txfr request for :" + bucketId + " txfrid :" + _lastTxfrId);
            }

            if (_keyList != null && _keyList.Count > 0)
            {
                return(GetCacheItems(bucketId));
            }
            else if (_topicWiseMessageList.Count > 0)
            {
                return(GetMessages(bucketId));
            }
            else if (_transferType == StateTransferType.MOVE_DATA)
            {
                //We need to transfer the logs.
                if (_parent.Context.NCacheLog.IsInfoEnabled)
                {
                    _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "sending log data for bucket: " + bucketId);
                }

                ArrayList list = new ArrayList(1);
                list.Add(bucketId);
                StateTxfrInfo info = GetLoggedData(list);

                if (info.transferCompleted && _transferTypeChanged)
                {
                    StartCompoundFilteration(bucketId);
                }

                return(info);
            }
            else
            {
                //As transfer mode is not MOVE_DATA, therefore no logs are maintained
                //and hence are not transferred.

                StartCompoundFilteration(bucketId);

                return(new StateTxfrInfo(null, true, 0, null, false));
            }
        }
예제 #4
0
 public override void Dispose()
 {
     if (_logMgr != null)
     {
         _logMgr.Dispose();
     }
     if (_keyList != null)
     {
         _keyList.Clear();
     }
     base.Dispose();
 }
예제 #5
0
        public void ClearKeys()
        {
            lock (_interestedKeys)
            {
                foreach (KeyValuePair <string, NotificationEntry> entry in _interestedKeys)
                {
                    if (entry.Value.NotifyOnUpdate)
                    {
                        if (_updatedKeys.ContainsKey(entry.Key))
                        {
                            DecrementOrRemove(ref _updatedKeys, entry.Key);
                        }
                    }

                    if (entry.Value.NotifyOnRemove)
                    {
                        if (_removedKeys.ContainsKey(entry.Key))
                        {
                            DecrementOrRemove(ref _removedKeys, entry.Key);
                        }
                    }
                }

                _interestedKeys.Clear();
            }
        }
예제 #6
0
 public void Clear()
 {
     lock (_mutex)
     {
         _expirationIndex.Clear();
     }
 }
예제 #7
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or
        /// resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (_taskExpiry != null)
            {
                _taskExpiry.Cancel();
                _taskExpiry = null;
            }

            lock (_status_mutex)
            {
                _mainIndex.Clear();
                _mainIndex = null;

                _transitoryIndex.Clear();
                _transitoryIndex       = null;
                _expirationManagerSize = 0;
            }
            GC.SuppressFinalize(this);
        }
예제 #8
0
 public void Dispose()
 {
     if (_loggers != null)
     {
         foreach (OperationLogger logger in _loggers.Values)
         {
             logger.Clear();
         }
         _loggers.Clear();
     }
 }
예제 #9
0
 public void Dispose()
 {
     if (_asyncProcessor != null)
     {
         _asyncProcessor.Stop();
         _asyncProcessor = null;
     }
     if (_indexMap != null)
     {
         _indexMap.Clear();
         _indexMap = null;
     }
     _cache = null;
 }
예제 #10
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or
        /// resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (_taskExpiry != null)
            {
                _taskExpiry.Cancel();
                _taskExpiry = null;
            }


            if (_cdbSyncMgr != null)
            {
                _cdbSyncMgr.ClearResourcePools();
                //_cdbSyncMgr.Clear();
            }

            if (_notifBasedDepMgr != null)
            {
                _notifBasedDepMgr.EndOperations();
                _notifBasedDepMgr.Dispose(false);
                _notifBasedDepMgr.Clear();
                _notifBasedDepMgr = null;
            }


            lock (_status_mutex)
            {
                _mainIndex.Clear();
                _mainIndex = null;

                _transitoryIndex.Clear();
                _transitoryIndex = null;

                _expirationManagerSize = 0;
            }
            GC.SuppressFinalize(this);
        }
예제 #11
0
        public void ClearCache(bool raisenotification)
        {
            lock (this)
            {
                foreach (KeyValuePair <string, ClientNotificationMgr> kvp in _clients)
                {
                    kvp.Value.ClearKeys();
                }
                _registeredKeys.Clear();
                _removedKeys.Clear();
                _updatedKeys.Clear();
            }

            if (raisenotification)
            {
                lock (this)
                {
                    IDictionaryEnumerator ide = _clients.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        _lastChangeTime = HPTime.Now;
                        ((ClientNotificationMgr)ide.Value).AddKey(_clearKey, null, null);

                        if (!_registeredKeys.ContainsKey(_clearKey))
                        {
                            _registeredKeys.Add(_clearKey, new KeyInfo());
                        }

                        KeyInfo keyInfo = _registeredKeys[_clearKey];

                        keyInfo.UpdatedTime = HPTime.Now;
                        keyInfo             = keyInfo.Clone() as KeyInfo;
                        keyInfo.UpdatedBy   = ide.Key as string;

                        if (!_updatedKeys.ContainsKey(_clearKey))
                        {
                            _updatedKeys.Add(_clearKey, keyInfo);
                        }
                        else
                        {
                            _updatedKeys[_clearKey] = keyInfo;
                        }
                    }
                }
            }
        }
예제 #12
0
 public void Clear()
 {
     lock (_mutex)
     {
         if (_indexForAll)
         {
             _indexTable.Clear();
         }
         else
         {
             IDictionaryEnumerator e = _indexTable.GetEnumerator();
             while (e.MoveNext())
             {
                 Hashtable tbl = e.Value as Hashtable;
                 tbl.Clear();
             }
         }
     }
 }
예제 #13
0
 /// <summary>
 /// Clears queue and helping datastructures like map, cache, itemstobereplicated
 /// </summary>
 internal void Clear()
 {
     try
     {
         lock (_sync_mutex)
         {
             _queue.Clear();
             _keyToIndexMap.Clear();
             _indexToKeyMap.Clear();
             _tail           = _head = -1;
             _tailMaxReached = false;
             _size           = 0;
             _count          = 0;
         }
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }
예제 #14
0
 public void Dispose()
 {
     taskOutput.Clear();
 }
예제 #15
0
 public void Clear()
 {
     _keyToValue.Clear();
     _valueToKey.Clear();
 }
예제 #16
0
        //protected StateTxfrInfo GetData(ArrayList bucketIds)
        //{
        //    try
        //    {
        //        object[] keys = null;
        //        Hashtable data = null;
        //        Hashtable result = new Hashtable();
        //        ArrayList payLoad = new ArrayList();
        //        ArrayList payLoadCompilationInfo = new ArrayList();

        //        if (!_sendLogData)
        //        {
        //            IEnumerator ie = bucketIds.GetEnumerator();
        //            while (ie.MoveNext())
        //            {
        //                int bucketId = (int)ie.Current;
        //                if (_parent.Context.NCacheLog.IsInfoEnabled) _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(1)", "transfering data for bucket : " + bucketId);
        //                bool enableLogs = _transferType == StateTransferType.MOVE_DATA ? true : false;
        //                _parent.InternalCache.GetKeyList(bucketId, enableLogs, _keyList);
        //                _logableBuckets.Add(bucketId);

        //                data = null;
        //                if (keyList != null)
        //                {
        //                    if (_parent.Context.NCacheLog.IsInfoEnabled) _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(1)", "bucket : " + bucketId + " [" + keyList.Count + " ]");

        //                    keys = keyList.ToArray();

        //                    OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
        //                    operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true);
        //                    data = _parent.InternalCache.Get(keys,operationContext);
        //                }

        //                if (data != null && data.Count > 0)
        //                {
        //                    if (result.Count == 0)
        //                    {
        //                        result = data.Clone() as Hashtable;
        //                    }
        //                    else
        //                    {
        //                        IDictionaryEnumerator ide = data.GetEnumerator();
        //                        while (ide.MoveNext())
        //                        {
        //                            CacheEntry entry = ide.Value as CacheEntry;
        //                            UserBinaryObject ubObject = null;
        //                            if (entry.Value is CallbackEntry)
        //                            {
        //                                ubObject = ((CallbackEntry)entry.Value).Value as UserBinaryObject;
        //                            }
        //                            else
        //                                ubObject = entry.Value as UserBinaryObject;

        //                            payLoad.AddRange(ubObject.Data);
        //                            long size = entry.DataSize;
        //                            int index = payLoadCompilationInfo.Add(size);
        //                            PayloadInfo payLoadInfo = new PayloadInfo(entry.CloneWithoutValue(), index);
        //                            result[ide.Key] = payLoadInfo;
        //                        }

        //                    }
        //                }
        //            }
        //            _sendLogData = true;
        //            if (_parent.Context.NCacheLog.IsInfoEnabled)
        //                _parent.Context.NCacheLog.Info("State Transfer Corresponder", "BalanceDataLoad = " + _isBalanceDataLoad.ToString());
        //            if (_isBalanceDataLoad)
        //            {
        //                _parent.Context.PerfStatsColl.IncrementDataBalPerSecStatsBy(result.Count);
        //            }
        //            else
        //            {
        //                _parent.Context.PerfStatsColl.IncrementStateTxfrPerSecStatsBy(result.Count);
        //            }

        //            return new StateTxfrInfo(result,payLoad,payLoadCompilationInfo, false);
        //        }
        //        else
        //            return GetLoggedData(bucketIds);
        //    }
        //    catch (Exception ex)
        //    {
        //        _parent.Context.NCacheLog.Error("StateTxfrCorresponder.GetData(1)", ex.ToString());
        //        return null;
        //    }
        //}

        protected StateTxfrInfo GetData(int bucketId)
        {
            if (_result.Count > 0)
            {
                _result.Clear();
            }

            long sizeToSend = 0;

            lock (_parent._bucketStateTxfrStatus.SyncRoot)
            {
                _parent._bucketStateTxfrStatus[bucketId] = true;
            }

            if (_parent.Context.NCacheLog.IsInfoEnabled)
            {
                _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "state txfr request for :" + bucketId + " txfrid :" + _lastTxfrId);
            }

            if (_keyList != null && _keyList.Count > 0)
            {
                if (_parent.Context.NCacheLog.IsInfoEnabled)
                {
                    _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "bucket size :" + _keyList.Count);
                }

                for (_keyCount = 0; _keyCount < _keyList.Count; _keyCount++)
                {
                    string key = _keyList[_keyCount] as string;

                    OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true);
                    CacheEntry entry = _parent.InternalCache.InternalCache.Get(key, false, operationContext);
                    if (entry != null)
                    {
                        long size = (entry.InMemorySize + Common.MemoryUtil.GetStringSize(key)); //.DataSize;
                        if (sizeToSend > _threshold)
                        {
                            break;
                        }

                        _result[key] = entry;
                        sizeToSend  += size;
                    }
                }
                if (_parent.Context.NCacheLog.IsInfoEnabled)
                {
                    _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "items sent :" + _keyCount);
                }

                if (_parent.Context.NCacheLog.IsInfoEnabled)
                {
                    _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "BalanceDataLoad = " + _isBalanceDataLoad.ToString());
                }

                if (_isBalanceDataLoad)
                {
                    _parent.Context.PerfStatsColl.IncrementDataBalPerSecStatsBy(_result.Count);
                }
                else
                {
                    _parent.Context.PerfStatsColl.IncrementStateTxfrPerSecStatsBy(_result.Count);
                }

                return(new StateTxfrInfo(_result, false, sizeToSend, this.stream));
            }
            else if (_transferType == StateTransferType.MOVE_DATA)
            {
                //We need to transfer the logs.
                if (_parent.Context.NCacheLog.IsInfoEnabled)
                {
                    _parent.Context.NCacheLog.Info("StateTxfrCorresponder.GetData(2)", "sending log data for bucket: " + bucketId);
                }

                ArrayList list = new ArrayList(1);
                list.Add(bucketId);
                return(GetLoggedData(list));
            }
            else
            {
                //As transfer mode is not MOVE_DATA, therefore no logs are maintained
                //and hence are not transferred.
                return(new StateTxfrInfo(null, true, 0, null));
            }
        }
예제 #17
0
        public void Run()
        {
            try
            {
                if (parent.Context != null)
                {
                    if (parent.Context.NCacheLog.IsInfoEnabled)
                    {
                        parent.Context.NCacheLog.Info("ReducerTask(" + parent.TaskId + ").Start", "Reducer task is started");
                    }
                }

                bool isCompeletedSuccessfully = true;

                while (isAlive)
                {
                    try
                    {
                        object currObj = null;
                        lock (ReducerInputQueue)
                        {
                            if (ReducerInputQueue.Count == 0 && !isMappercompleted)
                            {
                                Monitor.Wait(ReducerInputQueue);
                            }
                            if (ReducerInputQueue.Count > 0)
                            {
                                currObj = ReducerInputQueue.Dequeue();
                            }
                        }
                        if (currObj != null)
                        {
                            Alachisoft.NCache.Runtime.MapReduce.KeyValuePair entry = (Alachisoft.NCache.Runtime.MapReduce.KeyValuePair)currObj;
                            Object   key = entry.Key;
                            IReducer r   = null;
                            lock (mutex)
                            {
                                if (!reducers.ContainsKey(key))
                                {
                                    r = reducerFactory.Create(key);
                                    r.BeginReduce();
                                    reducers.Add(key, r);
                                }
                                else
                                {
                                    r = (IReducer)reducers[key];
                                }
                            }
                            r.Reduce(entry.Value);
                            ReducedCount = ReducedCount + 1; // increment the reducedCount
                            if (parent.Context.PerfStatsColl != null)
                            {
                                parent.Context.PerfStatsColl.IncrementReducedPerSecRate();
                            }
                        }
                        else
                        {
                            if (isMappercompleted)
                            {
                                parent.PersistOutput(FinalizeReducers());
                                if (parent.Context.NCacheLog.IsInfoEnabled)
                                {
                                    parent.Context.NCacheLog.Info("ReducerTask(" + parent.TaskId + ").Run ", "Reducer Completed, output persisted.");
                                }

                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (parent.ExceptionCount < parent.MaxExceptions)
                        {
                            if (parent.Context.NCacheLog != null)
                            {
                                parent.Context.NCacheLog.Error("ReducerTask(" + parent.TaskId + ").Run", " Exception:" + ex.Message);
                            }
                            parent.ExceptionCount = parent.ExceptionCount + 1;
                        }
                        else
                        {
                            isCompeletedSuccessfully = false;
                            parent.LocalReducerFailed();

                            lock (mutex)
                            {
                                //Dispose Reducers
                                foreach (IReducer rr in reducers.Values)
                                {
                                    rr.Dispose();
                                }
                                reducers.Clear();
                            }

                            break;
                        }
                    }
                }

                if (isCompeletedSuccessfully && isAlive)
                {
                    if (parent.Context.NCacheLog.IsInfoEnabled)
                    {
                        parent.Context.NCacheLog.Info("ReducerTask (" + parent.TaskId + ").Run ", "Reduced Total Keys : " + this.ReducedCount);
                    }
                    parent.LocalReducerCompleted();
                    lock (mutex)
                    {
                        foreach (IReducer rr in reducers.Values)
                        {
                            rr.Dispose();
                        }
                        reducers.Clear();
                    }
                }
            }
            catch (Exception e)
            {
                try
                {
                    parent.LocalReducerFailed();
                }
                catch (Exception)
                {}
            }
        }
예제 #18
0
 public virtual void Dispose()
 {
     _keyToRowIndex.Clear();
     _rowToFileIndex.Clear();
     _bucketKeyIndex.Clear();
 }
예제 #19
0
        public void Run()
        {
            try
            {
                if (parent.Context != null)
                {
                    if (parent.Context.NCacheLog.IsInfoEnabled)
                    {
                        parent.Context.NCacheLog.Info("CombinerTask(" + parent.TaskId + ").Start", "Combiner task is started");
                    }
                }

                bool completedSuccessfully = true;
                while (isAlive)
                {
                    try
                    {
                        object currObj = null;
                        lock (CombinerInputQueue)
                        {
                            if (CombinerInputQueue.Count == 0 && isMapperAlive)
                            {
                                Monitor.Wait(CombinerInputQueue);
                            }
                            if (CombinerInputQueue.Count > 0)
                            {
                                currObj = CombinerInputQueue.Dequeue();
                            }
                        }

                        if (currObj != null)
                        {
                            if (currObj.GetType().Equals(typeof(bool)))
                            {
                                bool finalizeChunk = (bool)currObj;
                                if (finalizeChunk)
                                {
                                    FinalizeCombiners();
                                    parent.SendReducerData();

                                    lock (mutex)
                                    {
                                        foreach (ICombiner cc in combiners.Values)
                                        {
                                            cc.Dispose();
                                        }
                                        combiners.Clear();
                                    }
                                }
                            }
                            else
                            {
                                DictionaryEntry entry = (DictionaryEntry)currObj;
                                object          key   = entry.Key;
                                ICombiner       c     = null;
                                lock (mutex)
                                {
                                    if (!combiners.ContainsKey(key))
                                    {
                                        c = combinerFactory.Create(key);
                                        c.BeginCombine();
                                        combiners.Add(key, c);
                                    }
                                    else
                                    {
                                        c = (ICombiner)combiners[key];
                                    }
                                }

                                c.Combine(entry.Value);
                                totalKeysCombined++;
                                if (parent.Context.PerfStatsColl != null)
                                {
                                    parent.Context.PerfStatsColl.IncrementCombinedPerSecRate();
                                }
                            }
                        }
                        else
                        {
                            if (!IsMapperAlive)
                            {
                                FinalizeCombiners();
                                parent.SendReducerData();
                                lock (mutex)
                                {
                                    foreach (ICombiner cc in combiners.Values)
                                    {
                                        cc.Dispose();
                                    }
                                    combiners.Clear();
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (parent.ExceptionCount < parent.MaxExceptions)
                        {
                            if (parent.Context.NCacheLog != null)
                            {
                                parent.Context.NCacheLog.Error("CombinerTask (" + parent.TaskId + ").Run", " Exception: " + ex.Message);
                            }
                            parent.ExceptionCount = parent.ExceptionCount + 1;
                        }
                        else
                        {
                            completedSuccessfully = false;
                            parent.LocalCombinerFailed();
                        }
                    }
                }

                if (completedSuccessfully && isAlive)
                {
                    if (parent.Context.NCacheLog != null)
                    {
                        if (parent.Context.NCacheLog.IsInfoEnabled)
                        {
                            parent.Context.NCacheLog.Info("CombinerTask (" + parent.TaskId + ").Run", "Total Keys Combined : " + totalKeysCombined);
                        }
                    }
                    parent.LocalCombinerCompleted();
                }
            }
            catch (Exception e)
            {
                try
                {
                    parent.LocalCombinerFailed();
                }
                catch (Exception)
                {
                }
            }
        }
예제 #20
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or
 /// resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     _itemDict.Clear();
     _itemDict = null;
     base.Dispose();
 }