Ejemplo n.º 1
0
 /// <summary>
 /// Load analysis configuration by making a copy of orignal config
 /// </summary>
 /// <param name="analysisPolicy"></param>
 public void LoadConfig(AnalysisPolicyElement analysisPolicy)
 {
     try
     {
         this.rwLock.AcquireWriterLock(Timeout.Infinite);
         this.effectivePolicy = analysisPolicy;
     }
     finally
     {
         this.rwLock.ReleaseWriterLock();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create an instance of CustomPolicyGenerator
 /// </summary>
 /// <param name="analysisPolicy">Analysis policy as specified in config</param>
 public CustomPolicyGenerator(AnalysisPolicyElement analysisPolicy)
 {
     this.analysisPolicy = analysisPolicy;
     if (this.analysisPolicy == null)
     {
         this.analysisPolicy = new AnalysisPolicyElement()
         {
             CacheEnableThreshold  = 0,
             DbSyncDependency      = false,
             DefaultExpirationType = CachePolicy.Expirations.Absolute,
             DefualtExpirationTime = 180
         };
     }
     this.queries    = new Dictionary <string, QueryPolicyGenerator>();
     this.rwLock     = new ReaderWriterLock();
     this.queriesGen = new Dictionary <string, QueryPolicyElementGenerator>();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Called when configuraion changes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Instance_ConfigurationUpdated(object sender, ConfiguraitonUpdatedEventArgs e)
 {
     if (e != null && e.Configuration != null)
     {
         ///Analysis was running and user changed the mode. We need to stop analysis and write report
         if (this.IsRunning && e.Configuration.Mode != ApplicationConfigurationElement.AppMode.Analysis)
         {
             this.Stop();
         }
         ///Start the analysis
         else if (!this.IsRunning && e.Configuration.Mode == ApplicationConfigurationElement.AppMode.Analysis)
         {
             if (e.Configuration.AnalysisPolicy != null)
             {
                 this.effectivePolicy = e.Configuration.AnalysisPolicy.Clone() as AnalysisPolicyElement;
             }
             else
             {
                 this.effectivePolicy = null;
             }
             this.Start(this.effectivePolicy);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Start analysis
        /// </summary>
        /// <param name="policy">Analysis policy</param>
        public void Start(AnalysisPolicyElement policy)
        {
            lock (this)
            {
                if (policy == null)
                {
                    Logger.Instance.TraceError("No 'analysis-policy' found in configuration. Analysis cannot start");
                    return;
                }
                this.customPolicyGen = new CustomPolicyGenerator(policy);

                if (this.IsRunning)
                {
                    return;
                }

                if (policy.AnalysisTime > 0)
                {
                    this.StartTimer(policy.AnalysisTime);
                }
                this.effectivePolicy = policy.Clone() as AnalysisPolicyElement;
                this.IsRunning       = true;
            }
        }
Ejemplo n.º 5
0
 public QueryPolicyGenerator(Query query, AnalysisPolicyElement analysisPolicy)
 {
     this.analysisPolicy = analysisPolicy;
     this.query          = query;
     this.callCount      = 0;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create an instance of QueryPolicyGenerator
 /// </summary>
 /// <param name="query">Query command</param>
 /// <param name="analysisPolicy">Analysis policy as specified in config</param>
 public QueryPolicyGenerator(string query, AnalysisPolicyElement analysisPolicy)
 {
     this.analysisPolicy = analysisPolicy;
     this.queryCommand   = query;
     this.callCount      = 0;
 }
Ejemplo n.º 7
0
 public QueryPolicyElementGenerator(Query query, AnalysisPolicyElement analysisPolicy)
 {
     queryPolGen    = new QueryPolicyGenerator(query, analysisPolicy);
     this.rwLock    = new ReaderWriterLock();
     cachePolicyGen = new QueryCachePolicyGenerator(query, analysisPolicy);
 }