FSRecoveryConfig.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.fs_recovery;

  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.  * FSRecoveryConfig
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class FSRecoveryConfig {

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

  36.     /** Indicazione sul numero massimo di tentativi di recovery */
  37.     private int tentativi;
  38.    
  39.     /** Indicazione se deve essere effettuato il log delle query */
  40.     private boolean debug = false;  
  41.    
  42.     /** Indicazione se devono essere ripristinati gli allarmi */
  43.     private boolean ripristinoEventi = false;

  44.     /** Indicazione se devono essere ripristinati le transazioni (con tracce e diagnostici) */
  45.     private boolean ripristinoTransazioni = false;

  46.     /** Indicazione dopo quanti millisecondi iniziare a processare un file presente nel repository */
  47.     private long processingTransactionFileAfterMs;
  48.     private long processingEventFileAfterMs;
  49.    
  50.     /** Repository */
  51.     private String repository = null;
  52.    
  53.     /** DefaultProtocol */
  54.     private String defaultProtocol = null;
  55.    
  56.     /** Costruttore */
  57.     public FSRecoveryConfig(boolean readPropertiesFromFile) throws EngineException{
  58.    
  59.         try{
  60.             if(readPropertiesFromFile){
  61.                
  62.                 this.logCore = LoggerWrapperFactory.getLogger("org.openspcoop2.monitor.engine.fs_recovery");
  63.                 this.logSql = LoggerWrapperFactory.getLogger("org.openspcoop2.monitor.engine.fs_recovery.sql");
  64.                
  65.                 MonitorProperties props = MonitorProperties.getInstance(this.logCore);
  66.    
  67.                 if ("true".equals(props.getProperty(CostantiConfigurazione.FS_RECOVERY_DEBUG, "false", true))) {
  68.                     this.debug = true;
  69.                 } else {
  70.                     this.debug = false;
  71.                 }
  72.                
  73.                 this.repository = props.getProperty(CostantiConfigurazione.FS_RECOVERY_REPOSITORY_DIR, true, true);
  74.                
  75.                 if ("true".equals(props.getProperty(CostantiConfigurazione.FS_RECOVERY_EVENTS_ENABLED, "false", true))) {
  76.                     this.ripristinoEventi = true;
  77.                 } else {
  78.                     this.ripristinoEventi = false;
  79.                 }
  80.                
  81.                 if ("true".equals(props.getProperty(CostantiConfigurazione.FS_RECOVERY_TRANSACTION_ENABLED, "true", true))) {
  82.                     this.ripristinoTransazioni = true;
  83.                 } else {
  84.                     this.ripristinoTransazioni = false;
  85.                 }
  86.                
  87.                 this.tentativi = Integer.parseInt(props.getProperty(CostantiConfigurazione.FS_RECOVERY_MAX_ATTEMPTS, true, true));
  88.                
  89.                 this.processingEventFileAfterMs = Long.parseLong(props.getProperty(CostantiConfigurazione.FS_RECOVERY_EVENTS_PROCESSING_FILE_AFTER_MS, true, true));
  90.                
  91.                 this.processingTransactionFileAfterMs = Long.parseLong(props.getProperty(CostantiConfigurazione.FS_RECOVERY_TRANSACTION_PROCESSING_FILE_AFTER_MS, true, true));
  92.                
  93.                 this.defaultProtocol = props.getProperty(CostantiConfigurazione.PDD_MONITOR_DEFAULT_PROTOCOL, false, true);
  94.             }
  95.            
  96.         }catch(Exception e){
  97.             throw new EngineException(e.getMessage(),e);
  98.         }
  99.     }
  100.    
  101.    
  102.     public Logger getLogCore() {
  103.         return this.logCore;
  104.     }
  105.     public void setLogCore(Logger logCore) {
  106.         this.logCore = logCore;
  107.     }

  108.     public Logger getLogSql() {
  109.         return this.logSql;
  110.     }
  111.     public void setLogSql(Logger logSql) {
  112.         this.logSql = logSql;
  113.     }

  114.     public boolean isDebug() {
  115.         return this.debug;
  116.     }
  117.     public void setDebug(boolean debug) {
  118.         this.debug = debug;
  119.     }
  120.    
  121.     public boolean isRipristinoEventi() {
  122.         return this.ripristinoEventi;
  123.     }
  124.     public void setRipristinoEventi(boolean ripristinoEventi) {
  125.         this.ripristinoEventi = ripristinoEventi;
  126.     }

  127.     public boolean isRipristinoTransazioni() {
  128.         return this.ripristinoTransazioni;
  129.     }
  130.     public void setRipristinoTransazioni(boolean ripristinoTransazioni) {
  131.         this.ripristinoTransazioni = ripristinoTransazioni;
  132.     }

  133.     public String getRepository() {
  134.         return this.repository;
  135.     }
  136.     public void setRepository(String repository) {
  137.         this.repository = repository;
  138.     }

  139.     public int getTentativi() {
  140.         return this.tentativi;
  141.     }
  142.     public void setTentativi(int tentativi) {
  143.         this.tentativi = tentativi;
  144.     }

  145.     public long getProcessingTransactionFileAfterMs() {
  146.         return this.processingTransactionFileAfterMs;
  147.     }
  148.     public void setProcessingTransactionFileAfterMs(long processingTransactionFileAfterMs) {
  149.         this.processingTransactionFileAfterMs = processingTransactionFileAfterMs;
  150.     }

  151.     public long getProcessingEventFileAfterMs() {
  152.         return this.processingEventFileAfterMs;
  153.     }
  154.     public void setProcessingEventFileAfterMs(long processingEventFileAfterMs) {
  155.         this.processingEventFileAfterMs = processingEventFileAfterMs;
  156.     }
  157.    
  158.     public String getDefaultProtocol() {
  159.         return this.defaultProtocol;
  160.     }
  161.     public void setDefaultProtocol(String defaultProtocol) {
  162.         this.defaultProtocol = defaultProtocol;
  163.     }
  164. }