Exemplo n.º 1
0
        /// <summary>
        /// Initializes the counter instances and category.
        /// </summary>
        public void InitializePerfCounters()
        {
            lock (this)
            {
                _pcRequestsPerSec           = new RateOfCounter(CustomCounterNames.RequestsPerSec, _instanceName);
                _pcResponsesPerSec          = new RateOfCounter(CustomCounterNames.ResponsesPerSec, _instanceName);
                _pcClientBytesSentPerSec    = new RateOfCounter(CustomCounterNames.ClientBytesSentPerSec, _instanceName);
                _pcClientBytesReceiedPerSec = new RateOfCounter(CustomCounterNames.ClientBytesReceiedPerSec, _instanceName);

                _pcMsecPerCacheOperation     = new AverageCounter(CustomCounterNames.MsecPerCacheOperation, _instanceName);
                _pcMsecPerCacheOperationBase = new RateOfCounter(CustomCounterNames.MsecPerCacheOperationBase, _instanceName);

                _usMsecPerCacheOperation = new UsageStats();
                _nsMsecPerCacheOperation = new NanoSecTimeStats();

                _pcResponseQueueCount = new NumberOfItemCounter(CustomCounterNames.ResponseQueueCount, _instanceName);
                _pcResponseQueueSize  = new NumberOfItemCounter(CustomCounterNames.ResponseQueueSize, _instanceName);
                _pcEventQueueCount    = new NumberOfItemCounter(CustomCounterNames.EventQueueCount, _instanceName);

                _requestLogPerSecond = new RateOfCounter(CustomCounterNames.RequestLogPerSecond, _instanceName);
                _requestLogSize      = new NumberOfItemCounter(CustomCounterNames.RequestLogSize, _instanceName);

                _pcConnectedClients = new NumberOfItemCounter(CustomCounterNames.ConnectedClients, _instanceName);

                //Bulk CustomCounterNames
                _pcMsecPerAddBulkAvg  = new RateOfCounter(CustomCounterNames.MsecPerAddBulkAvg, _instanceName);
                _pcMsecPerGetBulkAvg  = new RateOfCounter(CustomCounterNames.MsecPerGetBulkAvg, _instanceName);
                _pcMsecPerUpdBulkAvg  = new RateOfCounter(CustomCounterNames.MsecPerUpdBulkAvg, _instanceName);
                _pcMsecPerDelBulkAvg  = new RateOfCounter(CustomCounterNames.MsecPerDelBulkAvg, _instanceName);
                _pcMsecPerAddBulkBase = new RateOfCounter(CustomCounterNames.MsecPerAddBulkBase, _instanceName);
                _pcMsecPerGetBulkBase = new RateOfCounter(CustomCounterNames.MsecPerGetBulkBase, _instanceName);
                _pcMsecPerUpdBulkBase = new RateOfCounter(CustomCounterNames.MsecPerUpdBulkBase, _instanceName);
                _pcMsecPerDelBulkBase = new RateOfCounter(CustomCounterNames.MsecPerDelBulkBase, _instanceName);
            }
        }
Exemplo n.º 2
0
 public override string ReformatSpecificObject(string objtype, string createsql)
 {
     if (objtype == "view")
     {
         try
         {
             MySQLLexer        lexer  = new MySQLLexer(new ANTLRReaderStream(new StringReader(createsql)));
             CommonTokenStream tokens = new CommonTokenStream(lexer);
             MySQLParser       parser = new MySQLParser(tokens);
             var res = parser.create_view();
             if (parser.Errors != null)
             {
                 UsageStats.Usage("warning:badview", "viewsql", createsql);
                 return(createsql);
             }
             var tree = (Antlr.Runtime.Tree.ITree)res.Tree;
             var sw   = new StringWriter();
             var dmp  = this.CreateDumper(sw);
             var admp = new AntlrTreeDumper(tree, createsql, dmp);
             admp.Run();
             return(sw.ToString());
         }
         catch { }
     }
     return(base.ReformatSpecificObject(objtype, createsql));
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the counter instances and category.
        /// </summary>
        public void InitializePerfCounters()
        {
            try
            {
                if (!UserHasAccessRights)
                {
                    return;
                }

                lock (this)
                {
                    _pcRequestsPerSec           = new PerformanceCounter(PC_CATEGORY, "Requests/sec", _instanceName, false);
                    _pcResponsesPerSec          = new PerformanceCounter(PC_CATEGORY, "Responses/sec", _instanceName, false);
                    _pcClientBytesSentPerSec    = new PerformanceCounter(PC_CATEGORY, "Client bytes sent/sec", _instanceName, false);
                    _pcClientBytesReceiedPerSec = new PerformanceCounter(PC_CATEGORY, "Client bytes received/sec", _instanceName, false);

                    _pcMsecPerCacheOperation     = new PerformanceCounter(PC_CATEGORY, "Average �s/cache operation", _instanceName, false);
                    _pcMsecPerCacheOperationBase = new PerformanceCounter(PC_CATEGORY, "Average �s/cache operation base", _instanceName, false);

                    _usMsecPerCacheOperation = new UsageStats();
                    _nsMsecPerCacheOperation = new NanoSecTimeStats();

                    _generalNotificationQueueSize = new PerformanceCounter(PC_CATEGORY, "General Notifications Queue Size", _instanceName, false);
                    _pcResponseQueueCount         = new PerformanceCounter(PC_CATEGORY, "Response Queue Count", _instanceName, false);
                    _pcResponseQueueSize          = new PerformanceCounter(PC_CATEGORY, "Response Queue Size", _instanceName, false);
                    _pcEventQueueCount            = new PerformanceCounter(PC_CATEGORY, "Event Queue Count", _instanceName, false);
                }
            }
            catch (Exception e)
            {
                AppUtil.LogEvent("NCache", "An error occured while initializing counters for NCache Server. " + e.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError);
            }
        }
Exemplo n.º 5
0
            /// <summary>
            /// Loads all the plugins from the directory where AWB resides
            /// </summary>
            /// <param name="awb">IAutoWikiBrowser instance of AWB</param>
            /// <param name="Plugins">Array of Plugin Names</param>
            /// <param name="afterStartup">Whether the plugin(s) are being loaded post-startup</param>
            internal static void LoadPlugins(IAutoWikiBrowser awb, string[] Plugins, bool afterStartup)
            {
                try
                {
                    foreach (string Plugin in Plugins)
                    {
                        if (Plugin.EndsWith("DotNetWikiBot.dll") || Plugin.EndsWith("Diff.dll") ||
                            Plugin.EndsWith("WikiFunctions.dll"))
                        {
                            continue;
                        }

                        Assembly asm = null;
                        try
                        {
                            asm = Assembly.LoadFile(Plugin);
                        }
                        catch { }

                        if (asm != null)
                        {
                            Type[] types = asm.GetTypes();

                            foreach (Type t in types)
                            {
                                if (t.GetInterface("IAWBPlugin") != null)
                                {
                                    IAWBPlugin plugin = (IAWBPlugin)Activator.CreateInstance(t);
                                    Items.Add(plugin.Name, plugin);
                                    InitialisePlugin(plugin, awb);

                                    if (afterStartup)
                                    {
                                        UsageStats.AddedPlugin(plugin);
                                    }
                                }
                                else if (t.GetInterface("IListMakerPlugin") != null)
                                {
                                    IListMakerPlugin plugin = (IListMakerPlugin)Activator.CreateInstance(t);
                                    WikiFunctions.Controls.Lists.ListMaker.AddProvider(plugin);

                                    if (afterStartup)
                                    {
                                        UsageStats.AddedPlugin(plugin);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
#if debug
                    ErrorHandler.Handle(ex);
#else
                    MessageBox.Show(ex.Message, "Problem loading plugins");
#endif
                }
            }
Exemplo n.º 6
0
            public static void RecordUsage(ILegal Obj)
            {
                UsageStats ObjStats = new UsageStats {
                    UseDate = DateTime.Now, SoftwareName = Obj.KiteLionGamesSoftwareName
                };

                KiteLionGamesSoftware.Add(Obj, ObjStats);
            }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes the counter instances and category.
        /// </summary>
        public void InitializePerfCounters()
        {
#if NETCORE
            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux))
            {
                return;
            }
#endif
            try
            {
                if (!UserHasAccessRights)
                {
                    return;
                }

                lock (this)
                {
                    _pcRequestsPerSec           = new PerformanceCounter(PC_CATEGORY, "Requests/sec", _instanceName, false);
                    _pcResponsesPerSec          = new PerformanceCounter(PC_CATEGORY, "Responses/sec", _instanceName, false);
                    _pcClientBytesSentPerSec    = new PerformanceCounter(PC_CATEGORY, "Client bytes sent/sec", _instanceName, false);
                    _pcClientBytesReceiedPerSec = new PerformanceCounter(PC_CATEGORY, "Client bytes received/sec", _instanceName, false);

                    _pcMsecPerCacheOperation     = new PerformanceCounter(PC_CATEGORY, "Average us/cache operation", _instanceName, false);
                    _pcMsecPerCacheOperationBase = new PerformanceCounter(PC_CATEGORY, "Average us/cache operation base", _instanceName, false);

                    _usMsecPerCacheOperation = new UsageStats();
                    _nsMsecPerCacheOperation = new NanoSecTimeStats();

                    _generalNotificationQueueSize = new PerformanceCounter(PC_CATEGORY, "General Notifications Queue Size", _instanceName, false);
                    _pcResponseQueueCount         = new PerformanceCounter(PC_CATEGORY, "Response Queue Count", _instanceName, false);
                    _pcResponseQueueSize          = new PerformanceCounter(PC_CATEGORY, "Response Queue Size", _instanceName, false);
                    _pcEventQueueCount            = new PerformanceCounter(PC_CATEGORY, "Event Queue Count", _instanceName, false);

                    _requestLogPerSecond = new PerformanceCounter(PC_CATEGORY, "Requests Logged/sec", _instanceName, false);
                    _requestLogSize      = new PerformanceCounter(PC_CATEGORY, "Request Log Ledger Size", _instanceName, false);

                    _pcConnectedClients = new PerformanceCounter(PC_CATEGORY, "# Clients", _instanceName, false);

                    //Bulk Counters
                    _pcMsecPerAddBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/addbulk", _instanceName, false);
                    _pcMsecPerGetBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/fetchbulk", _instanceName, false);
                    _pcMsecPerUpdBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/insertbulk", _instanceName, false);
                    _pcMsecPerDelBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/removebulk", _instanceName, false);
                    _pcMsecPerAddBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/addbulk base", _instanceName, false);
                    _pcMsecPerGetBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/fetchbulk base", _instanceName, false);
                    _pcMsecPerUpdBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/insertbulk base", _instanceName, false);
                    _pcMsecPerDelBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/removebulk base", _instanceName, false);
                }
            }
            catch (Exception e)
            {
                AppUtil.LogEvent("NCache", "An error occurred while initializing counters for NCache Server. " + e.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError);

                //nTrace.warn("SocketServer.PerfStatsCollector.PerfStatsCollector()", e.ToString());
            }
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
        void HandleTimerCallback(object state)
        {
            UsageStatsManager mUsageStatsManager = (UsageStatsManager)GetSystemService(UsageStatsService);
            long   endTime        = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
            long   beginTime      = endTime - 1000 * 60 * 2;
            string topPackageName = "";

            IList <UsageStats> queryUsageStats = mUsageStatsManager.QueryUsageStats(UsageStatsInterval.Best, beginTime, endTime);

            if (queryUsageStats == null || queryUsageStats.Count == 0)
            {
                return;
            }
            queryUsageStats = queryUsageStats.OrderByDescending(u => u.LastTimeUsed).ToList();

            UsageStats usageStatsIns   = queryUsageStats[0];
            Field      mLastEventField = null;

            try
            {
                mLastEventField = usageStatsIns.Class.GetField("mLastEvent");
            }
            catch (Java.Lang.Exception e)
            {
                e.PrintStackTrace();
            }
            foreach (UsageStats usageStats in queryUsageStats)
            {
                if (mLastEventField != null)
                {
                    int lastEvent = 0;
                    try
                    {
                        lastEvent = mLastEventField.GetInt(usageStats);
                    }
                    catch (IllegalAccessException e)
                    {
                        e.PrintStackTrace();
                    }
                    if (lastEvent == 1)
                    {
                        topPackageName = usageStats.PackageName;
                        break;
                    }
                }
            }
            Console.WriteLine("当前应用的包名:" + topPackageName);
            if (!whiteList.ContainsKey(topPackageName))
            {
                Intent intent = new Intent("com.companyname.ttp.ListenAppService");
                intent.PutExtra("Message", 40);
                SendBroadcast(intent);
            }
        }
Exemplo n.º 12
0
        public void InitializePerfCounters(bool inproc, bool ModuleConfigured = false)
        {
            try
            {
                _countStats = new NumberOfItemCounter(CounterNames.Count, _instanceName);
                _sizeStats  = new NumberOfItemCounter(CounterNames.CacheSize, _instanceName);

                _addStats                   = new RateOfCounter(CounterNames.AddPerSec, _instanceName);
                _updateStats                = new RateOfCounter(CounterNames.UpdPerSec, _instanceName);
                _fetchStats                 = new RateOfCounter(CounterNames.GetPerSec, _instanceName);
                _hitStats                   = new RateOfCounter(CounterNames.HitsPerSec, _instanceName);
                _missStats                  = new RateOfCounter(CounterNames.MissPerSec, _instanceName);
                _usageMsecPerGetStats       = new UsageStats();
                _cacheLastAccessCountStats  = new NumberOfItemCounter(CounterNames.CacheLastAccessCount, _instanceName);
                _hitsRatioSecStats          = new RateOfCounter(CounterNames.HitsRatioSec, _instanceName);
                _deleteStats                = new RateOfCounter(CounterNames.DelPerSec, _instanceName);
                _evictPerSecStats           = new RateOfCounter(CounterNames.EvictPerSec, _instanceName);
                _expiryPerSecStats          = new RateOfCounter(CounterNames.ExpiryPerSec, _instanceName);
                _stateTxfrPerSecStats       = new RateOfCounter(CounterNames.StateTxfrPerSec, _instanceName);
                _dataBalPerSecStats         = new RateOfCounter(CounterNames.DataBalPerSec, _instanceName);
                _msecPerGetAvgStats         = new AverageCounter(CounterNames.MsecPerGetAvg, _instanceName);
                _msecPerAddAvgStats         = new AverageCounter(CounterNames.MsecPerAddAvg, _instanceName);
                _usageMsecPerAddStats       = new UsageStats();
                _msecPerUpdateAvgStats      = new AverageCounter(CounterNames.MsecPerUpdAvg, _instanceName);
                _usageMsecPerUpdateStats    = new UsageStats();
                _msecPerDeleteAvgStats      = new AverageCounter(CounterNames.MsecPerDelAvg, _instanceName);
                _usageMsecPerDeleteStats    = new UsageStats();
                _mirrorQueueSizeStats       = new NumberOfItemCounter(CounterNames.MirrorQueueSize, _instanceName);
                _slidingIndexQueueSizeStats = new NumberOfItemCounter(CounterNames.SlidingIndexQueueSize, _instanceName);
                _evictionIndexSizeStats     = new NumberOfItemCounter(CounterNames.EvictionIndexSize, _instanceName);
                _expirationIndexSizeStats   = new NumberOfItemCounter(CounterNames.ExpirationIndexSize, _instanceName);

                #region Pub_Sub
                _pubsubCounterList         = new Dictionary <string, PerformanceCounterBase>();
                _messageCountStats         = new NumberOfItemCounter(CounterNames.MessageCount, _instanceName);
                _topicCountStats           = new NumberOfItemCounter(CounterNames.TopicCount, _instanceName);
                _messageStoreSizeStats     = new NumberOfItemCounter(CounterNames.MessageStoreSize, _instanceName);
                _messagePublishPerSecStats = new RateOfCounter(CounterNames.MessagePublishPerSec, _instanceName);
                _messageDeliverPerSecStats = new RateOfCounter(CounterNames.MessageDeliveryPerSec, _instanceName);
                _messageExpiredPerSecStats = new RateOfCounter(CounterNames.MessageExpiredPerSec, _instanceName);
                _pubsubCounterList.Add(CounterNames.MessageCount, _messageCountStats);
                _pubsubCounterList.Add(CounterNames.TopicCount, _topicCountStats);
                _pubsubCounterList.Add(CounterNames.MessageStoreSize, _messageStoreSizeStats);
                _pubsubCounterList.Add(CounterNames.MessagePublishPerSec, _messagePublishPerSecStats);
                _pubsubCounterList.Add(CounterNames.MessageDeliveryPerSec, _messageDeliverPerSecStats);
                _pubsubCounterList.Add(CounterNames.MessageExpiredPerSec, _messageExpiredPerSecStats);
            }
            catch (Exception ex)
            {
                throw new Exception("PerfStatsCollector.PerfStatsCollector()", ex);
            }

            #endregion
        }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes the counter instances and category.
        /// </summary>
        public void InitializePerfCounters(bool inproc)
        {
            try
            {
                if (!UserHasAccessRights)
                {
                    return;
                }

                lock (this)
                {
                    int    ncounter = 1;
                    string instname = _instanceName;

                    _pcAddPerSec = new PerformanceCounter(PC_CATEGORY, "Additions/sec", _instanceName, false);
                    _pcGetPerSec = new PerformanceCounter(PC_CATEGORY, "Fetches/sec", _instanceName, false);
                    _pcUpdPerSec = new PerformanceCounter(PC_CATEGORY, "Updates/sec", _instanceName, false);
                    _pcDelPerSec = new PerformanceCounter(PC_CATEGORY, "Deletes/sec", _instanceName, false);

                    _pcEventTriggeredPerSec = new PerformanceCounter(PC_CATEGORY, "Events Triggered/sec", _instanceName, false);
                    _pcEventProcesedPerSec  = new PerformanceCounter(PC_CATEGORY, "Events Proccesed/sec", _instanceName, false);


                    _pcMsecPerGetAvg  = new PerformanceCounter(PC_CATEGORY, "Average µs/fetch", _instanceName, false);
                    _pcMsecPerGetBase = new PerformanceCounter(PC_CATEGORY, "Average µs/fetch base", _instanceName, false);
                    _usMsecPerGet     = new UsageStats();
                    _pcMsecPerAddAvg  = new PerformanceCounter(PC_CATEGORY, "Average µs/add", _instanceName, false);
                    _pcMsecPerAddBase = new PerformanceCounter(PC_CATEGORY, "Average µs/add base", _instanceName, false);
                    _usMsecPerAdd     = new UsageStats();
                    _pcMsecPerUpdAvg  = new PerformanceCounter(PC_CATEGORY, "Average µs/insert", _instanceName, false);
                    _pcMsecPerUpdBase = new PerformanceCounter(PC_CATEGORY, "Average µs/insert base", _instanceName, false);
                    _usMsecPerUpd     = new UsageStats();
                    _pcMsecPerDelAvg  = new PerformanceCounter(PC_CATEGORY, "Average µs/remove", _instanceName, false);
                    _pcMsecPerDelBase = new PerformanceCounter(PC_CATEGORY, "Average µs/remove base", _instanceName, false);
                    _usMsecPerDel     = new UsageStats();

                    _pcReqrQueueSize = new PerformanceCounter(PC_CATEGORY, "Request queue size", _instanceName, false);

                    _pcMsecPerEventAvg  = new PerformanceCounter(PC_CATEGORY, "Average µs/event", _instanceName, false);
                    _pcMsecPerEventBase = new PerformanceCounter(PC_CATEGORY, "Average µs/event base", _instanceName, false);
                    _usMsecPerEvent     = new UsageStats();

                    _usMsecPerDel = new UsageStats();

                    _pcMsecPerSerializationAvg     = new PerformanceCounter(PC_CATEGORY, "Average µs/serialization", _instanceName, false);
                    _pcMsecPerSerializationAvgBase = new PerformanceCounter(PC_CATEGORY, "Average µs/serialization base", _instanceName, false);
                }
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes the counter instances and category.
        /// </summary>
        public void InitializePerfCounters()
        {
            try
            {
                if (!UserHasAccessRights)
                {
                    return;
                }

                lock (this)
                {
                    _pcRequestsPerSec           = new PerformanceCounter(PC_CATEGORY, "Requests/sec", _instanceName, false);
                    _pcResponsesPerSec          = new PerformanceCounter(PC_CATEGORY, "Responses/sec", _instanceName, false);
                    _pcClientBytesSentPerSec    = new PerformanceCounter(PC_CATEGORY, "Client bytes sent/sec", _instanceName, false);
                    _pcClientBytesReceiedPerSec = new PerformanceCounter(PC_CATEGORY, "Client bytes received/sec", _instanceName, false);

                    _pcMsecPerCacheOperation     = new PerformanceCounter(PC_CATEGORY, "Average us/cache operation", _instanceName, false);
                    _pcMsecPerCacheOperationBase = new PerformanceCounter(PC_CATEGORY, "Average us/cache operation base", _instanceName, false);

                    _usMsecPerCacheOperation = new UsageStats();
                    _nsMsecPerCacheOperation = new NanoSecTimeStats();

                    _generalNotificationQueueSize = new PerformanceCounter(PC_CATEGORY, "General Notifications Queue Size", _instanceName, false);
                    _pcResponseQueueCount         = new PerformanceCounter(PC_CATEGORY, "Response Queue Count", _instanceName, false);
                    _pcResponseQueueSize          = new PerformanceCounter(PC_CATEGORY, "Response Queue Size", _instanceName, false);
                    _pcEventQueueCount            = new PerformanceCounter(PC_CATEGORY, "Event Queue Count", _instanceName, false);

                    _requestLogCount     = new PerformanceCounter(PC_CATEGORY, "Logged Request Count", _instanceName, false);
                    _requestLogPerSecond = new PerformanceCounter(PC_CATEGORY, "Requests Logged/sec", _instanceName, false);
                    _requestLogSize      = new PerformanceCounter(PC_CATEGORY, "Request Log Ledger Size", _instanceName, false);

                    // Bulk Counters
                    _pcMsecPerAddBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/addbulk", _instanceName, false);
                    _pcMsecPerGetBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/fetchbulk", _instanceName, false);
                    _pcMsecPerUpdBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/insertbulk", _instanceName, false);
                    _pcMsecPerDelBulkAvg  = new PerformanceCounter(PC_CATEGORY, "Average us/removebulk", _instanceName, false);
                    _pcMsecPerAddBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/addbulk base", _instanceName, false);
                    _pcMsecPerGetBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/fetchbulk base", _instanceName, false);
                    _pcMsecPerUpdBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/insertbulk base", _instanceName, false);
                    _pcMsecPerDelBulkBase = new PerformanceCounter(PC_CATEGORY, "Average us/removebulk base", _instanceName, false);
                }
            }
            catch (Exception e)
            {
#if JAVA
                AppUtil.LogEvent("TayzGrid", "An error occurred while initializing counters for TayzGrid Server. " + e.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError);
#else
                AppUtil.LogEvent("NCache", "An error occurred while initializing counters for NCache Server. " + e.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError);
#endif
            }
        }
Exemplo n.º 16
0
            internal static void LoadPlugins(IAutoWikiBrowser awb, string[] Plugins, bool afterStartup)
            {
                try
                {
                    foreach (string Plugin in Plugins)
                    {
                        if (Plugin.EndsWith("DotNetWikiBot.dll") || Plugin.EndsWith("Diff.dll"))
                        {
                            continue;
                        }

                        Assembly asm = null;
                        try
                        {
                            asm = Assembly.LoadFile(Plugin);
                        }
                        catch { }

                        if (asm != null)
                        {
                            Type[] types = asm.GetTypes();

                            foreach (Type t in types)
                            {
                                if (t.GetInterface("IAWBPlugin") != null)
                                {
                                    IAWBPlugin plugin = (IAWBPlugin)Activator.CreateInstance(t);
                                    Items.Add(plugin.Name, plugin);
                                    if (plugin.Name == "Kingbotk Plugin" && t.Assembly.GetName().Version.Major < 2)
                                    {
                                        MessageBox.Show("You are using an out of date version of the Kingbotk Plugin. Please upgrade.",
                                                        "Kingbotk Plugin", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    }

                                    InitialisePlugin(plugin, awb);

                                    if (afterStartup)
                                    {
                                        UsageStats.AddedPlugin(plugin);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Problem loading plugins");
                }
            }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
    /// <summary>
    /// Sends the score to the leaderboard async.
    /// </summary>
    /// <param name="score">The player's high score.</param>
    /// <param name="stats">The player's round statistics</param>
    /// <param name="callback">The callback accepting the web response.</param>
    public void SendStats(int score, UsageStats stats, Action <string> callback)
    {
        UserStatSubmission scoreSubmission = new UserStatSubmission();

        scoreSubmission.score = score;
        scoreSubmission.usage = stats;

        var jsonSubmission = JsonUtility.ToJson(scoreSubmission);

        byte[] postBody = Encoding.ASCII.GetBytes(jsonSubmission);

        var authenticationHeaders = BuildAuthenticationHeaders();
        WWW request = new WWW(this.baseUrl + "/" + urlPrefix + "/arcade/stats", postBody, authenticationHeaders);

        StartCoroutine(WaitTillDoneString(request, callback));
    }
Exemplo n.º 19
0
    public static UsageStats operator+(UsageStats left, UsageStats right)
    {
        UsageStats combined = new UsageStats {
            playTime           = left.playTime + right.playTime,
            shotsFired         = left.shotsFired + right.shotsFired,
            enemiesKilled      = left.enemiesKilled + right.enemiesKilled,
            asteroidsDestroyed = left.asteroidsDestroyed + right.asteroidsDestroyed,
            powerUpsCollected  = left.powerUpsCollected + right.powerUpsCollected,
            tagfeeCannonShots  = left.tagfeeCannonShots + right.tagfeeCannonShots,
            missileShots       = left.missileShots + right.missileShots,
            bombsDropped       = left.bombsDropped + right.bombsDropped,
            uturnsMade         = left.uturnsMade + right.uturnsMade,
            userClickedSignup  = left.userClickedSignup || right.userClickedSignup
        };

        return(combined);
    }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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());
                }
            }
        }
Exemplo n.º 22
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());
         }
     }
 }
Exemplo n.º 23
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());
                }
            }
        }
Exemplo n.º 24
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());
                }
            }
        }
Exemplo n.º 25
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());
                }
            }
        }
        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());
                }
            }
        }
Exemplo n.º 27
0
 private static bool LoadStats()
 {
     //Load from file
     if (File.Exists(Application.persistentDataPath + "/stats.save"))
     {
         using (BinaryReader reader = new BinaryReader(File.OpenRead(Application.persistentDataPath + "/stats.save")))
         {
             playerOverallStats  = UsageStats.Read(reader);
             lastPlayStats       = UsageStats.Read(reader);
             bestPlayStats       = UsageStats.Read(reader);
             PlayersHighestScore = reader.ReadInt32();
             TotalGamesPlayed    = reader.ReadInt32();
         }
         return(true);
     }
     else
     {
         playerOverallStats = playerOverallStats ?? new UsageStats();
         lastPlayStats      = lastPlayStats ?? new UsageStats();
         bestPlayStats      = bestPlayStats ?? new UsageStats();
     }
     return(false);
 }
Exemplo n.º 28
0
    /// <summary>
    /// Sends the score to the leaderboard async.
    /// </summary>
    /// <param name="score">The player's high score.</param>
    /// <param name="stats">The player's round statistics</param>
    /// <param name="callback">The callback accepting the web response.</param>
    public void SendScore(int score, UsageStats stats, Action <UserScoresResponse> callback)
    {
        // This Method referenced Moz internal code and so areas have been redacted
        string cookie = ""; // Redacted

        if (!string.IsNullOrEmpty(cookie))
        {
            UserScoreSubmission scoreSubmission = new UserScoreSubmission();
            scoreSubmission.id       = 0;              // Redacted
            scoreSubmission.username = "******"; // Redacted
            scoreSubmission.score    = score;
            scoreSubmission.admin    = false;          // Redacted
            scoreSubmission.usage    = stats;

            var    jsonSubmission = JsonUtility.ToJson(scoreSubmission);
            byte[] postBody       = Encoding.ASCII.GetBytes(jsonSubmission);

            var authenticationHeaders = BuildAuthenticationHeaders();
            WWW request = new WWW(this.baseUrl + "/" + urlPrefix + "/score", postBody, authenticationHeaders);

            StartCoroutine(WaitTillDone(request, callback));
        }
    }
Exemplo n.º 29
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());
                }
            }
        }
Exemplo n.º 30
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());
                }
            }
        }