Ejemplo n.º 1
0
 private void GetAndAccumulateClientProfileReport(string cacheName, ClientUsage clientUsage)
 {
     {
         try
         {
             var clientProfile = _cacheServer.GetClientProfileReport(cacheName);
             if (clientProfile != null && !hasDefaultValues(clientProfile))
             {
                 clientUsage.UpdateClientUsageProfile(clientProfile);
             }
         }
         catch (Exception ex)
         {
             if (NCacheServiceLogger.Logger != null)
             {
                 NCacheServiceLogger.Logger.Error("GetAndAccumulateCacheFeatureReport", ex.ToString());
             }
         }
     }
 }
Ejemplo n.º 2
0
        //Thread is initiated to get all the running caches featureUsageReport.The Thread must sleep for an autostart delay for all the configured caches to get started( caches set with autostart property).
        private void PerformDataCollection()
        {
            try
            {
                bool threadAbort = false;
                if (_autoStartDelay > 0)
                {
                    Thread.Sleep(_autoStartDelay * 1000);
                }

                while (!threadAbort)
                {
                    try
                    {
                        _mergedFeatureReport = null;

                        //  load config state from configuration file.
                        _featureConfigManager.LoadConfiguration();

                        // Get user profile state from running service and syncronize it with persistance state.
                        _featureConfigManager.UpdateFeatureUsageInfo(_featureConfigManager.GetLastPostingTime());
                        // Get hardward profile state from running service and update the persistant state .
                        ProfileUsageCollector.Instance.PopulateHardwareProfile(_featureConfigManager.GetMachineId());
                        _featureConfigManager.UpdateHardwareProfile(ProfileUsageCollector.Instance.ReportHardwareProfile());

                        ProfileUsageCollector.Instance.PopulateUserProfile();
                        _featureConfigManager.UpdateUserInfo(ProfileUsageCollector.Instance.ReportUserProfile());


                        // Get caching profile state from running service and syncronize it with persistance state.
                        _cachingProfile = ProfileUsageCollector.Instance.PopulateCachingProfile();
                        _featureConfigManager.MergeCachingProfile(_cachingProfile);

                        ClientUsage clientUsage = new ClientUsage();
                        foreach (DictionaryEntry cache in _cacheServer.Caches)
                        {
                            String cacheName = cache.Key.ToString().ToLower();
                            GetAndAccumulateCacheFeatureReport(cacheName);
                            GetAndAccumulateClientProfileReport(cacheName, clientUsage);
                        }

                        MergeServiceFeatureReport();

                        _featureConfigManager.SyncClientProfiletoPresistanceState(clientUsage.GetClientProfile());

                        _featureConfigManager.MergeFeaturesWithConfiguration(_mergedFeatureReport);

                        SaveFeatureReport();
                    }
                    catch (ThreadAbortException)
                    {
                        threadAbort = true;
                        break;
                    }
                    catch (ThreadInterruptedException)
                    {
                        threadAbort = true;
                        break;
                    }
                    catch (Exception ex)
                    {
                        if (NCacheServiceLogger.Logger != null)
                        {
                            NCacheServiceLogger.Logger.Error("Data Collector", ex.ToString());
                        }
                    }

                    Thread.Sleep(TimeSpan.FromMinutes(ServiceConfiguration.FeatureDataCollectionInterval));
                }
            }
            catch (ThreadAbortException)
            {
                return;
            }
            catch (ThreadInterruptedException)
            {
                return;
            }
            catch (Exception ex)
            {
                if (NCacheServiceLogger.Logger != null)
                {
                    NCacheServiceLogger.Logger.Error("Data Collector", ex.ToString());
                }
            }
        }