Exemple #1
0
        /// <summary>
        /// Logs the operation
        /// </summary>
        /// <param name="bucket"></param>
        /// <param name="key"></param>
        /// <param name="entry"></param>
        /// <param name="type"></param>
        /// <param name="logMode"></param>
        /// <returns>True, in case operation is logged otherwise false</returns>
        public bool LogOperation(int bucket, object key, Object entry, OperationType type)
        {
            OperationLogger logger = null;

            lock (this)
            {
                if (_loggers.Contains(bucket))
                {
                    logger = _loggers[bucket] as OperationLogger;
                }
            }

            if (logger != null)
            {
                if (_logEnteries)
                {
                    logger.LogOperation(key, entry, type);
                }
                else
                {
                    logger.LogOperation(key, null, type);
                }
                return(true);
            }
            return(false);
        }
Exemple #2
0
 public bool IsLoggingEnbaled(int bucket, LogMode logMode)
 {
     if (_loggers.Contains(bucket))
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         return(logger.LoggingMode == logMode);
     }
     return(false);
 }
Exemple #3
0
 public void StopLogging(int bucket)
 {
     if (_loggers.Contains(bucket))
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         logger.BucketTransfered = _allowOPAfterBuckeTxfrd;;
         logger.Clear();
     }
 }
Exemple #4
0
 /// <summary>
 /// if bucket has been transfered to an another node than operation are not allowed.
 /// </summary>
 /// <param name="bucket"></param>
 /// <returns></returns>
 public bool IsOperationAllowed(int bucket)
 {
     if (_loggers.Contains(bucket))
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         return(!logger.BucketTransfered);
     }
     return(true);
 }
Exemple #5
0
        public bool IsLoggingEnbaled(int bucket, LogMode logMode)
        {
            OperationLogger logger = _loggers[bucket];

            if (logger != null)
            {
                return(logger.LoggingMode == logMode);
            }
            return(false);
        }
Exemple #6
0
        public Hashtable GetLoggedEnteries(int bucket)
        {
            Hashtable result = null;

            if (_loggers.Contains(bucket))
            {
                OperationLogger opLogger = (OperationLogger)_loggers[bucket];

                result = opLogger.LoggedEnteries.Clone() as Hashtable;
                opLogger.Clear();
            }
            return(result);
        }
Exemple #7
0
        public void StopLogging(int bucket)
        {
            OperationLogger logger = _loggers[bucket];

            if (logger != null)
            {
                lock (logger)
                {
                    logger.BucketTransfered = _allowOPAfterBuckeTxfrd;
                    logger.Clear();
                }
            }
        }
Exemple #8
0
 public void StartLogging(int bucket, LogMode loggingMode)
 {
     if (!_loggers.Contains(bucket))
     {
         _loggers.Add(bucket, new OperationLogger(bucket, loggingMode));
     }
     else
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         logger.LoggingMode      = loggingMode;
         logger.BucketTransfered = false;
         logger.Clear();
     }
 }
Exemple #9
0
        /// <summary>
        /// if bucket has been transfered to an another node than operation are not allowed.
        /// </summary>
        /// <param name="bucket"></param>
        /// <returns></returns>
        public bool IsOperationAllowed(int bucket)
        {
            OperationLogger logger = _loggers[bucket];

            if (logger != null && logger.BucketTransfered)
            {
                if (OperationContext.IsReplicationOperation) //replication operations are not filtered
                {
                    return(true);
                }
                return(false);
            }
            return(true);
        }
Exemple #10
0
        public Hashtable GetLoggedEnteries(int bucket)
        {
            Hashtable       result = null;
            OperationLogger logger = _loggers[bucket];

            if (logger != null)
            {
                lock (logger)
                {
                    result = logger.LoggedEnteries.Clone() as Hashtable;
                    logger.Clear();
                }
            }
            return(result);
        }
Exemple #11
0
        internal override CacheInsResult InsertInternal(object key, CacheEntry cacheEntry, bool isUserOperation, CacheEntry oldEntry, OperationContext operationContext)
        {
            int             bucketId = GetBucketId(key as string);
            OperationLogger opLogger = null;

            //muds:
            //fetch the operation logger...
            if (_logMgr.IsOperationAllowed(bucketId) && LocalBuckets.Contains(bucketId))
            {
                long oldEntrysize = oldEntry == null ? 0 : oldEntry.DataSize;

                if (_logMgr.IsLoggingEnbaled(bucketId, LogMode.LogBeforeActualOperation) && isUserOperation)
                {
                    _logMgr.LogOperation(bucketId, key, cacheEntry, OperationType.Insert);
                    return(oldEntry != null ? CacheInsResult.SuccessOverwrite : CacheInsResult.Success);
                }

                CacheEntry clone = (CacheEntry)cacheEntry.Clone();

                CacheInsResult result = base.InsertInternal(key, cacheEntry, isUserOperation, oldEntry, operationContext);

                switch (result)
                {
                case CacheInsResult.SuccessNearEvicition:
                case CacheInsResult.Success:
                    if (isUserOperation)
                    {
                        _logMgr.LogOperation(bucketId, key, clone, OperationType.Insert);
                    }
                    IncrementBucketStats(key as string, bucketId, cacheEntry.DataSize);
                    break;

                case CacheInsResult.SuccessOverwriteNearEviction:
                case CacheInsResult.SuccessOverwrite:
                    if (isUserOperation)
                    {
                        _logMgr.LogOperation(bucketId, key, clone, OperationType.Insert);
                    }
                    DecrementBucketStats(key as string, bucketId, oldEntrysize);
                    IncrementBucketStats(key as string, bucketId, cacheEntry.DataSize);
                    break;
                }

                return(result);
            }

            throw new StateTransferException("I am no more the owner of this bucket");
        }
Exemple #12
0
 /// <summary>
 /// Logs the operation
 /// </summary>
 /// <param name="bucket"></param>
 /// <param name="key"></param>
 /// <param name="entry"></param>
 /// <param name="type"></param>
 /// <param name="logMode"></param>
 /// <returns>True, in case operation is logged otherwise false</returns>
 public bool LogOperation(int bucket, object key, CacheEntry entry, OperationType type)
 {
     if (_loggers.Contains(bucket))
     {
         OperationLogger logger = _loggers[bucket] as OperationLogger;
         if (_logEnteries)
         {
             logger.LogOperation(key, entry, type);
         }
         else
         {
             logger.LogOperation(key, null, type);
         }
         return(true);
     }
     return(false);
 }
Exemple #13
0
        public void StartLogging(int bucket, LogMode loggingMode)
        {
            OperationLogger logger = _loggers[bucket];

            if (logger == null)
            {
                logger           = new OperationLogger(bucket, loggingMode);
                _loggers[bucket] = logger;
            }
            lock (logger)
            {
                logger.LoggingMode      = loggingMode;
                logger.BucketTransfered = false;
                logger.Clear();
            }
            //}
        }
Exemple #14
0
        /// <summary>
        /// Logs the operation
        /// </summary>
        /// <param name="bucket"></param>
        /// <param name="key"></param>
        /// <param name="entry"></param>
        /// <param name="type"></param>
        /// <param name="logMode"></param>
        /// <returns>True, in case operation is logged otherwise false</returns>
        public bool LogOperation(int bucket, object key, Object entry, OperationType type)
        {
            OperationLogger logger = _loggers[bucket];

            if (logger != null)
            {
                if (_logEnteries)
                {
                    logger.LogOperation(key, entry, type);
                }
                else
                {
                    logger.LogOperation(key, null, type);
                }
                return(true);
            }
            return(false);
        }
Exemple #15
0
        public Hashtable GetLoggedEnteries(int bucket)
        {
            Hashtable       result = null;
            OperationLogger logger = null;

            lock (this)
            {
                if (_loggers.Contains(bucket))
                {
                    logger = _loggers[bucket] as OperationLogger;
                }
            }
            if (logger != null)
            {
                result = logger.LoggedEnteries.Clone() as Hashtable;
                logger.Clear();
            }

            return(result);
        }
Exemple #16
0
        /// <summary>
        /// if bucket has been transfered to an another node than operation are not allowed.
        /// </summary>
        /// <param name="bucket"></param>
        /// <returns></returns>
        public bool IsOperationAllowed(int bucket)
        {
            OperationLogger logger = null;

            lock (this)
            {
                if (_loggers.Contains(bucket))
                {
                    logger = _loggers[bucket] as OperationLogger;
                }
            }

            if (logger != null && logger.BucketTransfered)
            {
                if (OperationContext.IsReplicationOperation) //replication operations are not filtered
                {
                    return(true);
                }

                return(false);
            }

            return(true);
        }