StatisticsConfig.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.monitor.engine.statistic;

  21. import org.openspcoop2.monitor.engine.exceptions.EngineException;
  22. import org.openspcoop2.monitor.engine.config.MonitorProperties;
  23. import org.openspcoop2.monitor.engine.constants.CostantiConfigurazione;

  24. import org.openspcoop2.utils.LoggerWrapperFactory;
  25. import org.slf4j.Logger;

  26. /**
  27.  * StatisticsConfig
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class StatisticsConfig {

  34.     private Logger logCore = null;
  35.     private Logger logSql = null;

  36.     /** Indicazione se deve essere effettuato il log delle query */
  37.     private boolean debug = false;  
  38.    
  39.     /** Indicazione se deve essere usata la union per calcolare i tempi di latenza */
  40.     private boolean useUnionForLatency = false;
  41.    
  42.     /** Indicazione se devono essere generate le statistiche custom */
  43.     private boolean generazioneStatisticheCustom = false;
  44.    
  45.     /** Indicazione se devono analizzate le transazioni custom */
  46.     private boolean analisiTransazioniCustom = false;
  47.    
  48.     /** Intervallo di attesa prima di passare al prossimo intervallo */
  49.     private long waitMsBeforeNextInterval = -1;
  50.    
  51.     /** Attesa che tutte le transazioni siano state consegnate con successo prima di passare al prossimo intervallo */
  52.     private boolean waitStatiInConsegna = false;
  53.    
  54.     /** Tipologie di statistiche */
  55.     private boolean statisticheOrarie = false;
  56.     private boolean statisticheGiornaliere = false;
  57.     private boolean statisticheSettimanali = false;
  58.     private boolean statisticheMensili = false;
  59.    
  60.     /** Tipologie di statistiche: gestione ultimo intervallo */
  61.     private boolean statisticheOrarieGestioneUltimoIntervallo = false;
  62.     private boolean statisticheGiornaliereGestioneUltimoIntervallo = false;
  63.     private boolean statisticheSettimanaliGestioneUltimoIntervallo = false;
  64.     private boolean statisticheMensiliGestioneUltimoIntervallo = false;
  65.        
  66.     /** Lista di indici forzati */
  67.     private StatisticsForceIndexConfig forceIndexConfig = null;
  68.    
  69.     private static final String FALSE = "false";
  70.    
  71.     /** Costruttore */
  72.     public StatisticsConfig(boolean readPropertiesFromFile) throws EngineException{
  73.    
  74.         try{
  75.             if(readPropertiesFromFile){
  76.                
  77.                 this.logCore = LoggerWrapperFactory.getLogger("org.openspcoop2.monitor.engine.statistic");
  78.                 this.logSql = LoggerWrapperFactory.getLogger("org.openspcoop2.monitor.engine.statistic.sql");
  79.                
  80.                 MonitorProperties props = MonitorProperties.getInstance(this.logCore);
  81.    
  82.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_DEBUG, FALSE, true))) {
  83.                     this.debug = true;
  84.                 } else {
  85.                     this.debug = false;
  86.                 }
  87.                
  88.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_USE_UNION_FOR_LATENCY, FALSE, true))) {
  89.                     this.useUnionForLatency = true;
  90.                 } else {
  91.                     this.useUnionForLatency = false;
  92.                 }
  93.                
  94.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_CUSTOM_STATISTICS, FALSE, true))) {
  95.                     this.generazioneStatisticheCustom = true;
  96.                 } else {
  97.                     this.generazioneStatisticheCustom = false;
  98.                 }
  99.                
  100.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_CUSTOM_TRANSACTION_STATISTICS, FALSE, true))) {
  101.                     this.analisiTransazioniCustom = true;
  102.                 } else {
  103.                     this.analisiTransazioniCustom = false;
  104.                 }
  105.        
  106.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_HOURLY, "true", true))) {
  107.                     this.statisticheOrarie = true;
  108.                 } else {
  109.                     this.statisticheOrarie = false;
  110.                 }
  111.                
  112.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_DAILY, "true", true))) {
  113.                     this.statisticheGiornaliere = true;
  114.                 } else {
  115.                     this.statisticheGiornaliere = false;
  116.                 }
  117.        
  118.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_WEEKLY, "true", true))) {
  119.                     this.statisticheSettimanali = true;
  120.                 } else {
  121.                     this.statisticheSettimanali = false;
  122.                 }
  123.        
  124.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_MONTHLY, "true", true))) {
  125.                     this.statisticheMensili = true;
  126.                 } else {
  127.                     this.statisticheMensili = false;
  128.                 }
  129.        
  130.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_HOURLY_LASTINT, "true", true))) {
  131.                     this.statisticheOrarieGestioneUltimoIntervallo = true;
  132.                 } else {
  133.                     this.statisticheOrarieGestioneUltimoIntervallo = false;
  134.                 }
  135.                
  136.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_DAILY_LASTINT, "true", true))) {
  137.                     this.statisticheGiornaliereGestioneUltimoIntervallo = true;
  138.                 } else {
  139.                     this.statisticheGiornaliereGestioneUltimoIntervallo = false;
  140.                 }
  141.        
  142.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_WEEKLY_LASTINT, "true", true))) {
  143.                     this.statisticheSettimanaliGestioneUltimoIntervallo = true;
  144.                 } else {
  145.                     this.statisticheSettimanaliGestioneUltimoIntervallo = false;
  146.                 }
  147.        
  148.                 if ("true".equals(props.getProperty(CostantiConfigurazione.STAT_MONTHLY_LASTINT, "true", true))) {
  149.                     this.statisticheMensiliGestioneUltimoIntervallo = true;
  150.                 } else {
  151.                     this.statisticheMensiliGestioneUltimoIntervallo = false;
  152.                 }
  153.             }
  154.            
  155.         }catch(Exception e){
  156.             throw new EngineException(e.getMessage(),e);
  157.         }
  158.     }
  159.    
  160.     public Logger getLogCore() {
  161.         return this.logCore;
  162.     }
  163.    
  164.     public void setLogCore(Logger logCore) {
  165.         this.logCore = logCore;
  166.     }

  167.     public Logger getLogSql() {
  168.         return this.logSql;
  169.     }

  170.     public void setLogSql(Logger logSql) {
  171.         this.logSql = logSql;
  172.     }
  173.    
  174.     public boolean isDebug() {
  175.         return this.debug;
  176.     }

  177.     public void setDebug(boolean debug) {
  178.         this.debug = debug;
  179.     }

  180.     public boolean isUseUnionForLatency() {
  181.         return this.useUnionForLatency;
  182.     }

  183.     public void setUseUnionForLatency(boolean useUnionForLatency) {
  184.         this.useUnionForLatency = useUnionForLatency;
  185.     }
  186.    
  187.     public boolean isGenerazioneStatisticheCustom() {
  188.         return this.generazioneStatisticheCustom;
  189.     }

  190.     public void setGenerazioneStatisticheCustom(boolean generazioneStatisticheCustom) {
  191.         this.generazioneStatisticheCustom = generazioneStatisticheCustom;
  192.     }

  193.     public boolean isStatisticheOrarie() {
  194.         return this.statisticheOrarie;
  195.     }

  196.     public void setStatisticheOrarie(boolean statisticheOrarie) {
  197.         this.statisticheOrarie = statisticheOrarie;
  198.     }

  199.     public boolean isStatisticheGiornaliere() {
  200.         return this.statisticheGiornaliere;
  201.     }

  202.     public void setStatisticheGiornaliere(boolean statisticheGiornaliere) {
  203.         this.statisticheGiornaliere = statisticheGiornaliere;
  204.     }

  205.     public boolean isStatisticheSettimanali() {
  206.         return this.statisticheSettimanali;
  207.     }

  208.     public void setStatisticheSettimanali(boolean statisticheSettimanali) {
  209.         this.statisticheSettimanali = statisticheSettimanali;
  210.     }

  211.     public boolean isStatisticheMensili() {
  212.         return this.statisticheMensili;
  213.     }

  214.     public void setStatisticheMensili(boolean statisticheMensili) {
  215.         this.statisticheMensili = statisticheMensili;
  216.     }

  217.     public boolean isStatisticheOrarieGestioneUltimoIntervallo() {
  218.         return this.statisticheOrarieGestioneUltimoIntervallo;
  219.     }

  220.     public void setStatisticheOrarieGestioneUltimoIntervallo(
  221.             boolean statisticheOrarieGestioneUltimoIntervallo) {
  222.         this.statisticheOrarieGestioneUltimoIntervallo = statisticheOrarieGestioneUltimoIntervallo;
  223.     }

  224.     public boolean isStatisticheGiornaliereGestioneUltimoIntervallo() {
  225.         return this.statisticheGiornaliereGestioneUltimoIntervallo;
  226.     }

  227.     public void setStatisticheGiornaliereGestioneUltimoIntervallo(
  228.             boolean statisticheGiornaliereGestioneUltimoIntervallo) {
  229.         this.statisticheGiornaliereGestioneUltimoIntervallo = statisticheGiornaliereGestioneUltimoIntervallo;
  230.     }

  231.     public boolean isStatisticheSettimanaliGestioneUltimoIntervallo() {
  232.         return this.statisticheSettimanaliGestioneUltimoIntervallo;
  233.     }

  234.     public void setStatisticheSettimanaliGestioneUltimoIntervallo(
  235.             boolean statisticheSettimanaliGestioneUltimoIntervallo) {
  236.         this.statisticheSettimanaliGestioneUltimoIntervallo = statisticheSettimanaliGestioneUltimoIntervallo;
  237.     }

  238.     public boolean isStatisticheMensiliGestioneUltimoIntervallo() {
  239.         return this.statisticheMensiliGestioneUltimoIntervallo;
  240.     }

  241.     public void setStatisticheMensiliGestioneUltimoIntervallo(
  242.             boolean statisticheMensiliGestioneUltimoIntervallo) {
  243.         this.statisticheMensiliGestioneUltimoIntervallo = statisticheMensiliGestioneUltimoIntervallo;
  244.     }
  245.    
  246.     public boolean isAnalisiTransazioniCustom() {
  247.         return this.analisiTransazioniCustom;
  248.     }

  249.     public void setAnalisiTransazioniCustom(boolean analisiTransazioniCustom) {
  250.         this.analisiTransazioniCustom = analisiTransazioniCustom;
  251.     }
  252.    
  253.     public StatisticsForceIndexConfig getForceIndexConfig() {
  254.         return this.forceIndexConfig;
  255.     }

  256.     public void setForceIndexConfig(StatisticsForceIndexConfig forceIndexConfig) {
  257.         this.forceIndexConfig = forceIndexConfig;
  258.     }
  259.    
  260.     public long getWaitMsBeforeNextInterval() {
  261.         return this.waitMsBeforeNextInterval;
  262.     }

  263.     public void setWaitMsBeforeNextInterval(long waitMsBeforeNextInterval) {
  264.         this.waitMsBeforeNextInterval = waitMsBeforeNextInterval;
  265.     }

  266.     public boolean isWaitStatiInConsegna() {
  267.         return this.waitStatiInConsegna;
  268.     }

  269.     public void setWaitStatiInConsegna(boolean waitStatiInConsegna) {
  270.         this.waitStatiInConsegna = waitStatiInConsegna;
  271.     }
  272. }