Пример #1
0
 /// <summary>
 /// Timestamps the start of sampling interval for Cache avg. and max. per mill-second time of
 /// fetch operations.
 /// </summary>
 public void MsecPerGetBeginSample()
 {
     if (_pcMsecPerGetAvg != null)
     {
         lock (_usMsecPerGet) { _usMsecPerGet.BeginSample(); }
     }
 }
Пример #2
0
 public void MsecPerQueryExecutionTimeBeginSample()
 {
     if (_pcAvgQueryExecutionTime != null)
     {
         lock (_pcAvgQueryExecutionTime) { _usMsecPerQueryExecution.BeginSample(); }
     }
 }
Пример #3
0
 public void MsecPerUpdBeginSample()
 {
     if (_msecPerUpdateAvgStats != null)
     {
         lock (_msecPerUpdateAvgStats) { _usageMsecPerUpdateStats.BeginSample(); }
     }
 }
Пример #4
0
 /// <summary>
 /// Timestamps the start of sampling interval for Cache avg. and max. per mill-second time of
 /// update operations.
 /// </summary>
 public void MsecPerUpdBeginSample()
 {
     if (_pcMsecPerUpdAvg != null)
     {
         lock (_pcMsecPerUpdAvg) { _usMsecPerUpd.BeginSample(); }
     }
 }
Пример #5
0
 public void MsecPerAddBeginSample()
 {
     if (_msecPerAddAvgStats != null)
     {
         lock (_msecPerAddAvgStats) { _usageMsecPerAddStats.BeginSample(); }
     }
 }
Пример #6
0
 public void MsecPerGetBeginSample()
 {
     if (_msecPerGetAvgStats != null)
     {
         lock (_msecPerGetAvgStats) { _usageMsecPerGetStats.BeginSample(); }
     }
 }
Пример #7
0
 /// <summary>
 /// Timestamps the start of sampling interval for Cache avg. and max. per mill-second time of
 /// remove operations.
 /// </summary>
 public void MsecPerDelBeginSample()
 {
     if (_pcMsecPerDelAvg != null)
     {
         lock (_pcMsecPerDelAvg) { _usMsecPerDel.BeginSample(); }
     }
 }
Пример #8
0
        InsertResult <JSONDocument> IDocumentStore.InsertDocument(InsertOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            InsertResult <JSONDocument> result = new InsertResult <JSONDocument>();
            CacheItem citem = new CacheItem();

            citem.Document = operation.Document;
            citem.Flag.SetBit(BitsetConstants.DocumentDirty);
            citem.Flag.SetBit(BitsetConstants.MetaDataDirty);
            citem.Flag.UnsetBit(BitsetConstants.MarkedForDeletion);

            CacheInsert(operation.RowId, citem, false);
            _indexManager.AddToIndex(operation.RowId, operation.Document, operation.OperationId);

            _parent.MetadataIndex.Add(new DocumentKey(operation.Document.Key), operation.RowId, operation.Document, operation.Context);

            PersistenceOperation persistenceOperation = new PersistenceInsertOperation(operation.OperationId, _parent.Name, operation.RowId, citem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            result.RowId = operation.RowId;

            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgInsertTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.InsertsPerSec);
            }
            return(result);
        }
Пример #9
0
 /// <summary>
 /// Timestamps the start of sampling interval for Cache avg. and max. per mill-second time of
 /// add operations.
 /// </summary>
 public void MsecPerAddBeginSample()
 {
     if (_usMsecPerAdd != null)
     {
         _usMsecPerAdd.BeginSample();
     }
 }
Пример #10
0
 /// <summary>
 /// Timestamps the start of sampling interval for Cache avg. and max. per mill-second time of
 /// fetch operations.
 /// </summary>
 public void MsecPerGetBeginSample()
 {
     if (_usMsecPerGet != null)
     {
         _usMsecPerGet.BeginSample();
     }
 }
Пример #11
0
        UpdateResult <JSONDocument> IDocumentStore.UpdateDocument(UpdateOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            UpdateResult <JSONDocument> result = new UpdateResult <JSONDocument>();
            CacheItem cItem;

            if (!_cache.ContainsKey(operation.RowId))
            {
                //TODO: Read-through
                if (!_persistenceManager.MetadataIndex(_parent.Name).ContainsRowId(operation.RowId))
                {
                    if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsWarnEnabled)
                    {
                        LoggerManager.Instance.StorageLogger.Warn("Update : document not found.", "Document not found while updating in metadataIndex. rowId = " + operation.RowId + " collection = " + Name);
                    }
                    AddFailedOperation(operation);
                    return(result);
                }

                cItem = LoadDocument(operation.RowId, operation.Context);
            }
            else
            {
                cItem = CacheGet(operation.RowId);//_cache[operation.RowId];
            }
            if (cItem == null)
            {
                throw new Exception("Item not found in cache.");
            }
            //removing cache item from eviction policy so that it will not be evicted.
            _evictionPolicy.Remove(operation.RowId, cItem.EvictionHint);
            result.OldDocument = cItem.Document.Clone() as JSONDocument;
            cItem.Document     = operation.Update;
            result.RowId       = operation.RowId;
            result.NewDocument = cItem.Document.Clone() as JSONDocument;

            cItem.Flag.SetBit(BitsetConstants.DocumentDirty);


            _indexManager.UpdateIndex(operation.RowId, cItem.Document, operation.Update, operation.OperationId);

            PersistenceOperation persistenceOperation = new PersistenceUpdateOperation(operation.OperationId,
                                                                                       _parent.Name, operation.RowId, cItem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            _parent.MetadataIndex.Update(new DocumentKey(operation.Update.Key), operation);
            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgUpdateTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.UpdatesPerSec);
            }

            return(result);
        }
Пример #12
0
        DeleteResult <JSONDocument> IDocumentStore.DeleteDocument(RemoveOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            DeleteResult <JSONDocument> result = new DeleteResult <JSONDocument>();
            CacheItem cItem;

            if (!_cache.ContainsKey(operation.RowId))
            {
                //TODO: Read-through
                if (!_persistenceManager.MetadataIndex(_parent.Name).ContainsRowId(operation.RowId))
                {
                    if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsWarnEnabled)
                    {
                        LoggerManager.Instance.StorageLogger.Warn("Delete : document not found.", "Document not found while deleting in metadataIndex. rowId = " + operation.RowId + " collection = " + Name);
                    }
                    AddFailedOperation(operation);
                    return(result);
                }
                cItem = LoadDocument(operation.RowId, operation.Context);
            }
            else
            {
                cItem = CacheGet(operation.RowId);
            }

            //Remove an item from eviction index, so that it's not marked for eviction.
            if (cItem != null)
            {
                _evictionPolicy.Remove(operation.RowId, cItem.EvictionHint);
            }

            result.Document = cItem.Document;
            result.RowId    = operation.RowId;
            //_cache.Remove(operation.RowId);
            //CacheRemove(operation.RowId);

            _indexManager.UpdateIndex(operation.RowId, result.Document, new JSONDocument(), operation.OperationId);

            cItem.Flag.SetBit(BitsetConstants.DocumentDirty);
            cItem.Flag.SetBit(BitsetConstants.MarkedForDeletion);

            PersistenceOperation persistenceOperation = new PersistenceDeleteOperation(operation.OperationId, _parent.Name, operation.RowId, cItem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            _persistenceManager.MetadataIndex(_parent.Name).Remove(new DocumentKey(cItem.Document.Key));

            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgDeleteTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.DeletesPerSec);
            }

            return(result);
        }
Пример #13
0
        /// <summary>
        /// Publishes the messages.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="deliverOption"></param>
        /// <param name="notifyDeliveryFailure"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void Publish(Message message, DeliveryOption deliverOption, bool notifyDeliveryFailure = false)
        {
            if (TopicSearchOptions.ByName != _searchOptions)
            {
                throw new OperationFailedException(ErrorCodes.PubSub.PATTERN_BASED_PUBLISHING_NOT_ALLOWED, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.PATTERN_BASED_PUBLISHING_NOT_ALLOWED));
            }
            try
            {
                _readerWriterLock.AcquireReaderLock(Timeout.Infinite);

                if (message == null)
                {
                    throw new ArgumentNullException("message");
                }
                if (_isDisposed)
                {
                    throw new OperationFailedException(ErrorCodes.PubSub.TOPIC_DISPOSED, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.TOPIC_DISPOSED, Name));
                }

                UsageStats stats = new UsageStats();
                stats.BeginSample();
                BitSet flagMap = new BitSet();
                long   size    = 0;
                object value   = message.Payload;


                value = _cacheImpl.SafeSerialize(value, _cacheImpl.Name, ref flagMap, _cacheImpl, ref size, UserObjectType.CacheItem);


                if (_perfStatsCollector != null && value != null && value is byte[])
                {
                    _perfStatsCollector.IncrementAvgItemSize(((byte[])value).Length);
                }

                Hashtable metaInfo = new Hashtable();
                metaInfo.Add(TopicConstant.TopicName, TopicConstant.TopicTag + _topicName);
                metaInfo.Add(TopicConstant.DeliveryOption, ((int)deliverOption).ToString());
                metaInfo.Add(TopicConstant.NotifyOption, notifyDeliveryFailure.ToString());

                long expiration = GetExpirationTime(message);

                _cacheImpl.PublishMessage(message.MessageId, value, message.CreationTime.Ticks, expiration, metaInfo, flagMap);

                if (_perfStatsCollector != null)
                {
                    stats.EndSample();
                    _perfStatsCollector.IncrementMsecPerMessagePublish(stats.Current);
                    _perfStatsCollector.IncrementMessagePublishedPerSec();
                }
            }
            finally
            {
                _readerWriterLock.ReleaseReaderLock();
            }
        }
Пример #14
0
        public void Publish(Message message, DeliveryOption deliverOption, bool notifyDeliveryFailure = false)
        {
            try
            {
                _readerWriterLock.AcquireReaderLock(Timeout.Infinite);

                if (message == null)
                {
                    throw new ArgumentNullException("message");
                }
                if (_isDisposed)
                {
                    throw new Exception(string.Format("Topic '{0}' is disposed.", Name));
                }

                UsageStats stats = new UsageStats();
                stats.BeginSample();
                BitSet flagMap = new BitSet();
                long   size    = 0;
                object value   = message.Payload;


                value = _cacheImpl.SafeSerialize(value, _cacheImpl.Name, ref flagMap, _cacheImpl, ref size);


                if (_perfStatsCollector != null && value != null && value is byte[])
                {
                    _perfStatsCollector.IncrementAvgItemSize(((byte[])value).Length);
                }


                Hashtable metaInfo = new Hashtable();
                metaInfo.Add(TopicConstant.TopicName, TopicConstant.TopicTag + _topicName);
                metaInfo.Add(TopicConstant.DeliveryOption, ((int)deliverOption).ToString());
                metaInfo.Add(TopicConstant.NotifyOption, notifyDeliveryFailure.ToString());

                long expiration = GetExpirationTime(message);

                _cacheImpl.PublishMessage(message.MessageId, value, message.CreationTime.Ticks, expiration, metaInfo,
                                          flagMap);

                if (_perfStatsCollector != null)
                {
                    stats.EndSample();
                    _perfStatsCollector.IncrementMsecPerMessagePublish(stats.Current);
                    _perfStatsCollector.IncrementMessagePublishedPerSec();
                }
            }
            finally
            {
                _readerWriterLock.ReleaseReaderLock();
            }
        }
Пример #15
0
        public bool FillDataChunk(int lastChunkId, ref IDataChunk dataChunk)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();
            bool check = _lastChunkId == lastChunkId?FillNewData(lastChunkId, ref dataChunk) : FillPreviousData(lastChunkId, ref dataChunk);

            stats.EndSample();
            //if (LoggerManager.Instance.QueryLogger != null)
            //    LoggerManager.Instance.QueryLogger.Debug("GetNextChunk", "QueryID: "+_queryId+
            //        ", Refilling last chunk: " + check + ", Time taken: " + stats.Current);

            return(check);
        }
Пример #16
0
        GetResult <JSONDocument> IDocumentStore.GetDocument(GetOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            GetResult <JSONDocument> result = new GetResult <JSONDocument>();
            CacheItem cItem;

            if (!_cache.ContainsKey(operation.RowId))
            {
                //TODO: Read-through
                cItem = LoadDocument(operation.RowId, operation.Context);
                if (_statsCollector != null)
                {
                    _statsCollector.IncrementStatsValue(StatisticsType.CacheMissesPerSec);
                }
            }
            else
            {
                cItem = CacheGetWithoutNotify(operation.RowId);
                if (_statsCollector != null)
                {
                    _statsCollector.IncrementStatsValue(StatisticsType.CacheHitsPerSec);
                }
            }
            if (cItem == null)
            {
                throw new Exception("Item not found in cache.");
            }
            if (!cItem.Flag.IsBitSet(BitsetConstants.MarkedForDeletion))
            {
                result.Document = cItem.Document;
                result.RowId    = operation.RowId;
            }

            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgFetchTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.FetchesPerSec);
            }
            return(result);
        }
Пример #17
0
        public void Process()
        {
            try
            {
                if (_parent != null && _parent._cache.AsyncEventHandler != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();

                    if (_command is AddCommand)
                    {
                        _parent._cache.AsyncEventHandler.OnAsyncAddCompleted(_key,
                                                                             ((AddCommand)_command).AsycItemAddedOpComplete, _asyncOpResult, _notifyAsync);
                    }
                    else if (_command is InsertCommand)
                    {
                        _parent._cache.AsyncEventHandler.OnAsyncInsertCompleted(_key,
                                                                                ((InsertCommand)_command).AsycItemUpdatedOpComplete, _asyncOpResult, _notifyAsync);
                    }
                    else if (_command is RemoveCommand)
                    {
                        _parent._cache.AsyncEventHandler.OnAsyncRemoveCompleted(_key,
                                                                                ((RemoveCommand)_command).AsyncItemRemovedOpComplete, _asyncOpResult, _notifyAsync);
                    }
                    else if (_command is ClearCommand)
                    {
                        _parent._cache.AsyncEventHandler.OnAsyncClearCompleted(
                            ((ClearCommand)_command).AsyncCacheClearedOpComplete, _asyncOpResult, _notifyAsync);
                    }
                }

                _stats.EndSample();
                _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("Async Operation completed Event Task.Process", ex.ToString());
                }
            }
        }
Пример #18
0
 public void Process()
 {
     try
     {
         if (_parent != null)
         {
             _stats = new UsageStats();
             _stats.BeginSample();
             _parent._cache.EventListener.OnCustomNotification(CompactBinaryFormatter.FromByteBuffer(_key, _cacheId), CompactBinaryFormatter.FromByteBuffer(_value, _cacheId), _notifyAsync);
             _stats.EndSample();
             _parent._perfStatsColl.IncrementAvgEventProcessingSample(_stats.Current);
         }
     }
     catch (Exception ex)
     {
         if (_parent.Logger.IsErrorLogsEnabled)
         {
             _parent.Logger.NCacheLog.Error("Custome Event Task.Process", ex.ToString());
         }
     }
 }
        public void Process()
        {
            try
            {
                if (_parent != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();
                    _parent._cache.EventListener.OnClientConnectivityChange(_cacheId, _clientInfo, _status);

                    _stats.EndSample();
                    _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("Client Connectivity Change Task.Process", ex.ToString());
                }
            }
        }
Пример #20
0
        public void Process()
        {
            try
            {
                if (_parent != null && _parent._cache.AsyncEventHandler != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();
                    _parent._cache.EventListener.OnCustomRemoveCallback(_callBackId, _key, _value, _reason, _flag, _notifyAsync, _item, _dataFilter);

                    _stats.EndSample();
                    _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("Item Remove CallBack Task.Process", ex.ToString());
                }
            }
        }
Пример #21
0
        public void Process()
        {
            try
            {
                if (_parent != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();


                    _stats.EndSample();
                    _parent._perfStatsColl.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("Cache Cleared Task.Process", ex.ToString());
                }
            }
        }
Пример #22
0
        public void Process()
        {
            try
            {
                if (_parent != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();
                    _parent._cache.EventListener.OnItemUpdated(_key, _notifyAsync, _item, _oldItem, _flag);

                    _stats.EndSample();
                    _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("Item Updated Task.Process", ex.ToString());
                }
            }
        }
Пример #23
0
        public void Process()
        {
            try
            {
                if (_parent != null && _parent._cache.AsyncEventHandler != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();

                    _parent._cache.AsyncEventHandler.OnDataSourceUpdated(_callBackId, _result, _opCode, _notifyAsync);

                    _stats.EndSample();
                    _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("DS Update event Task.Process", ex.ToString());
                }
            }
        }
Пример #24
0
        public void Process()
        {
            try
            {
                if (_parent != null)
                {
                    _stats = new UsageStats();
                    _stats.BeginSample();

                    _parent._cache.EventListener.OnActiveQueryChanged(_queryId, _changeType, _key, _notifyAsync, _item,
                                                                      _oldItem, _flag, _datafilter);

                    _stats.EndSample();
                    _parent._perfStatsColl2.IncrementAvgEventProcessingSample(_stats.Current);
                }
            }
            catch (Exception ex)
            {
                if (_parent.Logger.IsErrorLogsEnabled)
                {
                    _parent.Logger.NCacheLog.Error("CQ Callback Task.Process", ex.ToString());
                }
            }
        }