From eb0aa9a1b676ebdccf956f040df99fefd1291f47 Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Wed, 15 Jan 2014 13:14:56 +0100 Subject: [PATCH] Cleaned up configuration mess --- ch.psi.fda/Readme.md | 25 ++++++++------- .../psi/fda/aq/AcquisitionConfiguration.java | 32 ++++++------------- .../fda/install/ApplicationConfigurator.java | 4 +-- .../test/resources/home/config/fda.properties | 1 + .../resources/home/config/jcae.properties | 2 +- .../resources/home/config/logging.properties | 22 ++----------- ch.psi.fda/src/test/resources/jcae.properties | 4 --- .../src/test/resources/logging.properties | 14 -------- 8 files changed, 29 insertions(+), 75 deletions(-) delete mode 100644 ch.psi.fda/src/test/resources/jcae.properties delete mode 100644 ch.psi.fda/src/test/resources/logging.properties diff --git a/ch.psi.fda/Readme.md b/ch.psi.fda/Readme.md index 4249546..fa079a0 100644 --- a/ch.psi.fda/Readme.md +++ b/ch.psi.fda/Readme.md @@ -1,7 +1,14 @@ # Overview This package holds the core functionality of FDA. -# Usage +# Development +When checking out the project from the repository there is the `target/generated-sources/xjc` folder missing. +After checking out the project execute `mvn compile` to create the folder and the required classes. + +To build project use `mvn clean install`. + +To upload the latest version to the central artifact repository use `mvn clean deploy`. +Create Zip file via `mvn clean compile assembly:assembly` To use the FDA libary in an other project use: @@ -13,15 +20,9 @@ To use the FDA libary in an other project use: ``` - -# Development -When checking out the project from the repository there is the `target/generated-sources/xjc` folder missing. -After checking out the project execute `mvn compile` to create the folder and the required classes. - -To build project use `mvn clean install`. - -To upload the latest version to the central artifact repository use `mvn clean deploy`. -Create Zip file via `mvn clean compile assembly:assembly` - ## REST -FDA offers a rest service to execute scans. There are 3 distinct service for fda scan, fdaq and cdump. \ No newline at end of file +FDA offers a rest service to execute scans. There are 3 distinct service for fda scan, fdaq and cdump. + +# Notes +## Upgrade FDA 1.x to 2.x +In existing fda.properties file the following property need to be added: `ch.psi.fda.aq.data.dir=../data` \ No newline at end of file diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/aq/AcquisitionConfiguration.java b/ch.psi.fda/src/main/java/ch/psi/fda/aq/AcquisitionConfiguration.java index b108d1e..6333582 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/aq/AcquisitionConfiguration.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/aq/AcquisitionConfiguration.java @@ -19,6 +19,7 @@ package ch.psi.fda.aq; +import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -29,12 +30,6 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import ch.psi.fda.install.ApplicationConfigurator; - -/** - * @author ebner - * - */ public class AcquisitionConfiguration { @@ -77,27 +72,21 @@ public class AcquisitionConfiguration { * The constructor will read the configuration from the /fda.properties file (resource) located in the classpath. */ public AcquisitionConfiguration(){ - loadConfiguration(); - } - - - public void loadConfiguration(){ - loadConfiguration(null); + loadConfiguration(System.getProperty(FDA_CONFIG_FILE)); } /** * Load configuration from properties file */ public void loadConfiguration(String file) { - if(file == null){ - file = System.getProperty(FDA_CONFIG_FILE); - } Properties properties = new Properties(); + File cfile = null; // Only read in the property file if a file is specified if(file != null){ + cfile = new File(file); try { - properties.load(new FileReader(file)); + properties.load(new FileReader(cfile)); } catch (FileNotFoundException e) { throw new RuntimeException("Configuration file "+file+" not found", e); } catch (IOException e) { @@ -118,16 +107,15 @@ public class AcquisitionConfiguration { otfUseCrlogic = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.useCrlogic", "false")); otfCrlogicPrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicPrefix", ""); otfCrlogicKeepTmpFiles = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicKeepTmpFiles", "false")); + - if(System.getProperty(ApplicationConfigurator.FDA_HOME_ARGUMENT)!=null){ // TODO remove - dataBaseDirectory = System.getProperty(ApplicationConfigurator.FDA_HOME_ARGUMENT)+"/data"; + dataBaseDirectory = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.dir","."); + if(cfile!=null && dataBaseDirectory.matches("^\\.\\.?/.*")){ // if basedir starts with . or .. we assume the data directory to be relative to the directory of the configuration file + dataBaseDirectory = cfile.getParentFile().getAbsolutePath()+"/"+dataBaseDirectory; } - else{ - dataBaseDirectory = "./data"; - } - dataFilePrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.filePrefix",""); + actorMoveTimeout = new Long(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".actorMoveTimeout","600000")); smptServer= properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".notification.host","mail.psi.ch"); diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/install/ApplicationConfigurator.java b/ch.psi.fda/src/main/java/ch/psi/fda/install/ApplicationConfigurator.java index e5075aa..dbcd18d 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/install/ApplicationConfigurator.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/install/ApplicationConfigurator.java @@ -43,7 +43,7 @@ public class ApplicationConfigurator { private static final Logger logger = Logger.getLogger(ApplicationConfigurator.class.getName()); - public final static String FDA_HOME_ARGUMENT = "ch.psi.fda.home"; + protected final static String FDA_HOME_ARGUMENT = "ch.psi.fda.home"; private final File home; private final File configdir; @@ -237,7 +237,7 @@ public class ApplicationConfigurator { BufferedWriter writer = new BufferedWriter(new FileWriter(fdaProperties)); PrintWriter w = new PrintWriter(writer); - // w.println("ch.psi.fda.aq.data.baseDirectory="+datadir.getAbsolutePath()); + w.println("ch.psi.fda.aq.data.dir=../data"); w.println("ch.psi.fda.aq.data.filePrefix=${yyyy_MM}/${yyyyMMdd}/${yyyyMMddHHmmss}_${name}/${yyyyMMddHHmm}_"); w.println(); diff --git a/ch.psi.fda/src/test/resources/home/config/fda.properties b/ch.psi.fda/src/test/resources/home/config/fda.properties index 96345a3..616bb3d 100644 --- a/ch.psi.fda/src/test/resources/home/config/fda.properties +++ b/ch.psi.fda/src/test/resources/home/config/fda.properties @@ -1,4 +1,5 @@ # Serialization properties +ch.psi.fda.aq.data.dir=../data ch.psi.fda.aq.data.filePrefix=${yyyy_MM}/${yyyyMMdd}/${yyyyMMddHHmmss}_${name}/${yyyyMMddHHmm}_ # OTF scan related configuration diff --git a/ch.psi.fda/src/test/resources/home/config/jcae.properties b/ch.psi.fda/src/test/resources/home/config/jcae.properties index aed63f1..ad2fec6 100644 --- a/ch.psi.fda/src/test/resources/home/config/jcae.properties +++ b/ch.psi.fda/src/test/resources/home/config/jcae.properties @@ -1,4 +1,4 @@ -ch.psi.jcae.ContextFactory.addressList=129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.77 +ch.psi.jcae.ContextFactory.addressList=129.129.130.188 129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.88 129.129.130.142 ch.psi.jcae.ChannelFactory.timeout=2000 ch.psi.jcae.ChannelFactory.retries=4 ch.psi.jcae.ChannelBeanFactory.timeout=10000 diff --git a/ch.psi.fda/src/test/resources/home/config/logging.properties b/ch.psi.fda/src/test/resources/home/config/logging.properties index 73d2ae3..575282f 100644 --- a/ch.psi.fda/src/test/resources/home/config/logging.properties +++ b/ch.psi.fda/src/test/resources/home/config/logging.properties @@ -1,9 +1,8 @@ # Specify the handlers to create in the root logger -##handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler handlers = java.util.logging.ConsoleHandler # Set the default logging level for the root logger -.level=ALL +.level=INFO # Set the default logging level for new ConsoleHandler instances java.util.logging.ConsoleHandler.level=ALL @@ -11,22 +10,5 @@ java.util.logging.ConsoleHandler.level=ALL # Set the default formatter for new ConsoleHandler instances java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter -# Set the default logging level for new FileHandler instances -##java.util.logging.FileHandler.level=ALL - -# Set the default formatter for new ConsoleHandler instances -##java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter - -# Naming of the output file: -##java.util.logging.FileHandler.pattern=/Users/ebner/Workspace/Eclipse/workspace-xasec/ch.psi.x10/resources/logs/fda-%u.%g.log - -# Limiting size of output file in bytes (10000kb): -##java.util.logging.FileHandler.limit=10000000 - -# Number of output files to cycle through, by appending an -# integer to the base file name: -##java.util.logging.FileHandler.count=10 - # Set the default logging level for the logger named com.mycompany -ch.psi.fda.level=ALL -com.cosylab.epics.level=ALL +ch.psi.level=ALL diff --git a/ch.psi.fda/src/test/resources/jcae.properties b/ch.psi.fda/src/test/resources/jcae.properties deleted file mode 100644 index a6da78d..0000000 --- a/ch.psi.fda/src/test/resources/jcae.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Test properties file -ch.psi.jcae.ContextFactory.addressList=129.129.130.188 129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.88 129.129.130.142 - -ch.psi.jcae.ChannelBeanFactory.retries=4 \ No newline at end of file diff --git a/ch.psi.fda/src/test/resources/logging.properties b/ch.psi.fda/src/test/resources/logging.properties deleted file mode 100644 index 575282f..0000000 --- a/ch.psi.fda/src/test/resources/logging.properties +++ /dev/null @@ -1,14 +0,0 @@ -# Specify the handlers to create in the root logger -handlers = java.util.logging.ConsoleHandler - -# Set the default logging level for the root logger -.level=INFO - -# Set the default logging level for new ConsoleHandler instances -java.util.logging.ConsoleHandler.level=ALL - -# Set the default formatter for new ConsoleHandler instances -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - -# Set the default logging level for the logger named com.mycompany -ch.psi.level=ALL