Defined initial API for ConfigurationManager
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/ac7170bd Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/ac7170bd Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/ac7170bd Branch: refs/heads/feature/zookeeper-config Commit: ac7170bdf5c973374f141c6f3e031fa748e0af13 Parents: 1ae9242 Author: Imesha Sudasingha <[email protected]> Authored: Sat Apr 1 12:30:55 2017 +0530 Committer: Imesha Sudasingha <[email protected]> Committed: Sat Apr 1 12:30:55 2017 +0530 ---------------------------------------------------------------------- config/pom.xml | 24 +++ .../oodt/config/ConfigurationManager.java | 57 +++++++ .../config/ConfigurationManagerFactory.java | 53 ++++++ .../java/org/apache/oodt/config/Constants.java | 56 +++++++ .../DistributedConfigurationManager.java | 163 +++++++++++++++++++ .../StandaloneConfigurationManager.java | 78 +++++++++ core/pom.xml | 10 ++ filemgr/pom.xml | 4 + .../cas/filemgr/system/XmlRpcFileManager.java | 41 +++-- pom.xml | 1 + 10 files changed, 469 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/pom.xml ---------------------------------------------------------------------- diff --git a/config/pom.xml b/config/pom.xml new file mode 100644 index 0000000..64a4b03 --- /dev/null +++ b/config/pom.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>oodt</artifactId> + <groupId>org.apache.oodt</groupId> + <version>1.1-SNAPSHOT</version> + <relativePath>../core/pom.xml</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>oodt-conf</artifactId> + <packaging>jar</packaging> + <name>OODT - Configuration Management</name> + <description>OODT project for distributed configuration management support</description> + + <dependencies> + <dependency> + <groupId>org.apache.curator</groupId> + <artifactId>curator-framework</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java new file mode 100644 index 0000000..05b33fd --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * The abstract class to define functionalities of the configuration managers. + * + * @author Imesha Sudasingha + */ +public abstract class ConfigurationManager { + + protected String component; + protected List<String> propertiesFiles; + protected List<String> otherFiles; + + public ConfigurationManager(String component, List<String> propertiesFiles, List<String> otherFiles) { + this.component = component; + this.propertiesFiles = propertiesFiles != null ? propertiesFiles : new ArrayList<String>(); + this.otherFiles = otherFiles != null ? otherFiles : new ArrayList<String>(); + } + + /** + * Retrieves a given property from the underlying configuration storage. For example, If we want to get the + * value of the property org.foo.bar, we have to call this method with <pre>org.foo.bar</pre> as the parameter. + * + * @param key Name of the property to be retrieved. + * @return Value of the requested property | null + */ + public abstract String getProperty(String key); + + public abstract void loadProperties() throws IOException; + + public abstract File getPropertiesFile(String filePath) throws FileNotFoundException; + + public abstract File getConfigurationFile(String filePath) throws FileNotFoundException; +} http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java b/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java new file mode 100644 index 0000000..7c026b7 --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config; + +import org.apache.oodt.config.distributed.DistributedConfigurationManager; +import org.apache.oodt.config.standalone.StandaloneConfigurationManager; + +import java.util.List; +import java.util.logging.Logger; + +import static org.apache.oodt.config.Constants.Properties.ENABLE_DISTRIBUTED_CONFIGURATION; + +/** + * Factory class to be used to get the {@link ConfigurationManager} instances accordingly. + * + * @author Imesha Sudasingha + */ +public class ConfigurationManagerFactory { + + /** Logger instance for this class */ + private static final Logger logger = Logger.getLogger(ConfigurationManagerFactory.class.getName()); + + private ConfigurationManagerFactory() {} + + /** + * Returns the {@link ConfigurationManager} to be used by the calling class. Whether to use the standalone version or + * the distributed version of the configuration manager will be determined by the value of the property + * <pre>org.apache.oodt.config.zookeeper == true</pre> + * + * @return ConfigurationManager instance to used by the corresponding component. + */ + public static ConfigurationManager getConfigurationManager(String component, List<String> propertiesFiles, List<String> otherFiles) { + if (System.getProperty(ENABLE_DISTRIBUTED_CONFIGURATION) != null) { + return new DistributedConfigurationManager(component, propertiesFiles, otherFiles); + } + return new StandaloneConfigurationManager(component, propertiesFiles, otherFiles); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/src/main/java/org/apache/oodt/config/Constants.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/Constants.java b/config/src/main/java/org/apache/oodt/config/Constants.java new file mode 100644 index 0000000..03c3e1c --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/Constants.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config; + +/** + * Constants to be used by the config package + * + * @author Imesha Sudasingha + */ +public class Constants { + + private Constants() {} + + /** Node name to be used when the configuration manager is the standalone version */ + public static final String STANDALONE_NODE_NAME = "local"; + + /** Default environment name to be used */ + public static final String DEFAULT_ENVIRONMENT = "default"; + + public static class Properties { + + /** The system property to be set in order to enable distributed configuration management */ + public static final String ENABLE_DISTRIBUTED_CONFIGURATION = "org.apache.oodt.config.distributed"; + + /** System property, which will holf the location of the zookeeper properties file */ + public static final String ZK_PROPERTIES_FILE = "org.apache.oodt.config.zkProperties"; + + /** Property name to fetch connect string to connect to a zookeeper ensemble. */ + public static final String ZK_CONNECT_STRING = "org.apache.oodt.config.zk.connectString"; + + public static final String ZK_CONNECTION_TIMEOUT = "org.apache.oodt.config.zk.connectionTimeoutMs"; + public static final String ZK_SESSION_TIMEOUT = "org.apache.oodt.config.zk.sessionTimeoutMs"; + + public static final String ZK_RETRY_INITIAL_WAIT = "org.apache.oodt.config.zk.retryInitialWaitMs"; + public static final String ZK_RETRY_MAX_RETRIES = "org.apache.oodt.config.zk.maxRetries"; + public static final String ZK_STARTUP_TIMEOUT = "org.apache.oodt.config.zk.startupTimeoutMs"; + + public static final String ZK_USERNAME = "org.apache.oodt.config.zk.username"; + public static final String ZK_PASSWORD = "org.apache.oodt.config.zk.password"; + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java new file mode 100644 index 0000000..e7a3ed2 --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java @@ -0,0 +1,163 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config.distributed; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.api.ACLProvider; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.oodt.config.ConfigurationManager; +import org.apache.oodt.config.Constants; +import org.apache.oodt.config.Constants.Properties; +import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.data.ACL; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.apache.oodt.config.Constants.Properties.ZK_PROPERTIES_FILE; + +/** + * Distributed configuration manager implementation. This class make use of a {@link CuratorFramework} instance to connect + * to zookeeper + * + * @author Imesha Sudasingha. + */ +public class DistributedConfigurationManager extends ConfigurationManager { + + private static final Logger logger = Logger.getLogger(DistributedConfigurationManager.class.getName()); + + private static String environment = Constants.DEFAULT_ENVIRONMENT; + private static String nodeName; + + /** Variables required to connect to zookeeper */ + private String connectString; + private CuratorFramework client; + + public DistributedConfigurationManager(String component, List<String> propertiesFiles, List<String> otherFiles) { + super(component, propertiesFiles, otherFiles); + loadZookeeperProperties(); + startZookeeper(); + } + + /** + * Loads zookeeper related properties from ZK_PROPERTIES_FILE. WIll throw a {@link RuntimeException} if that file is + * not available or couldn't be opened. + */ + private void loadZookeeperProperties() { + if (System.getProperty(ZK_PROPERTIES_FILE) != null) { + throw new IllegalArgumentException("DistributedCOnfigurationManager requires " + ZK_PROPERTIES_FILE + " to be set"); + } + + try { + System.getProperties().load(new FileInputStream(System.getProperty(ZK_PROPERTIES_FILE))); + } catch (IOException e) { + logger.log(Level.SEVERE, "Unable to read ZK_PROPERTIES_FILE " + System.getProperty(ZK_PROPERTIES_FILE)); + throw new IllegalStateException("Couldn't load Zookeeper configuration"); + } + + if (System.getProperty(Properties.ZK_CONNECT_STRING) == null) { + throw new IllegalArgumentException("Zookeeper requires a proper connect string to connect to zookeeper ensemble"); + } + + connectString = System.getProperty(Properties.ZK_CONNECT_STRING); + logger.log(Level.CONFIG, String.format("Using zookeeper connect string : %s", connectString)); + } + + /** + * Creates a {@link CuratorFramework} instance and start it. This method will wait a maximum amount of + * {@link Properties#ZK_STARTUP_TIMEOUT} milli-seconds until the client connects to the zookeeper ensemble. + */ + private void startZookeeper() { + int connectionTimeoutMs = Integer.parseInt(System.getProperty(Properties.ZK_CONNECTION_TIMEOUT, "15")); + int sessionTimeoutMs = Integer.parseInt(System.getProperty(Properties.ZK_CONNECTION_TIMEOUT, "60")); + int retryInitialWaitMs = Integer.parseInt(System.getProperty(Properties.ZK_CONNECTION_TIMEOUT, "1000")); + int maxRetryCount = Integer.parseInt(System.getProperty(Properties.ZK_CONNECTION_TIMEOUT, "3")); + int startupTimeOutMs = Integer.parseInt(System.getProperty(Properties.ZK_STARTUP_TIMEOUT, "30000")); + + CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() + .connectString(connectString) + .retryPolicy(new ExponentialBackoffRetry(retryInitialWaitMs, maxRetryCount)) + .connectionTimeoutMs(connectionTimeoutMs) + .sessionTimeoutMs(sessionTimeoutMs); + + /* + * If authorization information is available, those will be added to the client. NOTE: These auth info are + * for access control, therefore no authentication will happen when the client is being started. These + * info will only be required whenever a client is accessing an already create ZNode. For another client of + * another node to make use of a ZNode created by this node, it should also provide the same auth info. + */ + if (System.getProperty(Properties.ZK_USERNAME) != null && System.getProperty(Properties.ZK_PASSWORD) != null) { + String authenticationString = System.getProperty(Properties.ZK_USERNAME) + ":" + System.getProperty(Properties.ZK_PASSWORD); + builder.authorization("digest", authenticationString.getBytes()) + .aclProvider(new ACLProvider() { + public List<ACL> getDefaultAcl() { + return ZooDefs.Ids.CREATOR_ALL_ACL; + } + + public List<ACL> getAclForPath(String path) { + return ZooDefs.Ids.CREATOR_ALL_ACL; + } + }); + } + + client = builder.build(); + logger.log(Level.CONFIG, String.format("CuratorFramework client built successfully with " + + "connectString: %s, sessionTimeout: %d and connectionTimeout: %d", connectString, sessionTimeoutMs, connectionTimeoutMs)); + + client.start(); + logger.log(Level.CONFIG, "Curator framework start operation invoked"); + + try { + logger.info(String.format("Waiting to connect to zookeeper, startupTimeout : %d", startupTimeOutMs)); + client.blockUntilConnected(startupTimeOutMs, TimeUnit.MILLISECONDS); + } catch (InterruptedException ex) { + logger.severe(String.format("Interrupted while waiting to connect zookeeper (connectString : %s) : %s", ex.getMessage(), connectString)); + } + + if (!client.getZookeeperClient().isConnected()) { + throw new IllegalStateException("Could not connect to ZooKeeper : " + connectString); + } + + logger.info("CuratorFramework client started successfully"); + } + + @Override + public String getProperty(String key) { + // Todo Implement using curator + return null; + } + + @Override + public void loadProperties() { + // todo Implement the logic with Curator + } + + public File getPropertiesFile(String filePath) { + return null; + } + + public File getConfigurationFile(String filePath) { + return null; + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java new file mode 100644 index 0000000..0cf0c78 --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config.standalone; + +import org.apache.oodt.config.ConfigurationManager; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; + +/** + * {@link ConfigurationManager} implementation to be used with standalone configuration management. + * + * @author Imesha Sudasingha + */ +public class StandaloneConfigurationManager extends ConfigurationManager { + + /** Logger instance for logging */ + private static final Logger logger = Logger.getLogger(StandaloneConfigurationManager.class.getName()); + + public StandaloneConfigurationManager(String component, List<String> propertiesFiles, List<String> otherFiles) { + super(component, propertiesFiles, otherFiles); + } + + /** {@inheritDoc} */ + @Override + public String getProperty(String key) { + return System.getProperty(key); + } + + /** {@inheritDoc} */ + @Override + public void loadProperties() throws IOException { + for (String file : propertiesFiles) { + System.getProperties().load(new FileInputStream(new File(file))); + } + } + + /** {@inheritDoc} */ + @Override + public File getPropertiesFile(String filePath) throws FileNotFoundException { + File file = new File(filePath); + if (!propertiesFiles.contains(filePath) || !file.exists()) { + throw new FileNotFoundException("Couldn't find properties file located at: " + filePath); + } + + return file; + } + + /** {@inheritDoc} */ + @Override + public File getConfigurationFile(String filePath) throws FileNotFoundException { + File file = new File(filePath); + if (!otherFiles.contains(filePath) || !file.exists()) { + throw new FileNotFoundException("Couldn't find properties file located at: " + filePath); + } + + return file; + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/core/pom.xml ---------------------------------------------------------------------- diff --git a/core/pom.xml b/core/pom.xml index 019eee2..e55d46c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -248,6 +248,11 @@ the License. <version>8.7</version> </dependency> <dependency> + <groupId>org.apache.curator</groupId> + <artifactId>curator-framework</artifactId> + <version>3.3.0</version> + </dependency> + <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>2.6.0</version> @@ -360,6 +365,11 @@ the License. </dependency> <dependency> <groupId>org.apache.oodt</groupId> + <artifactId>oodt-conf</artifactId> + <version>${project.parent.version}</version> + </dependency> + <dependency> + <groupId>org.apache.oodt</groupId> <artifactId>oodt-product</artifactId> <version>${project.parent.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/filemgr/pom.xml ---------------------------------------------------------------------- diff --git a/filemgr/pom.xml b/filemgr/pom.xml index cfa1327..2e43f30 100644 --- a/filemgr/pom.xml +++ b/filemgr/pom.xml @@ -130,6 +130,10 @@ <artifactId>oodt-commons</artifactId> </dependency> <dependency> + <groupId>org.apache.oodt</groupId> + <artifactId>oodt-conf</artifactId> + </dependency> + <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-core</artifactId> <scope>compile</scope> http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java index beba420..996ac16 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java @@ -52,6 +52,8 @@ import org.apache.oodt.cas.filemgr.versioning.VersioningUtils; import org.apache.oodt.cas.metadata.Metadata; import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; import org.apache.oodt.commons.date.DateUtils; +import org.apache.oodt.config.ConfigurationManager; +import org.apache.oodt.config.ConfigurationManagerFactory; import org.apache.xmlrpc.WebServer; import com.google.common.collect.Lists; @@ -64,12 +66,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Vector; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -84,6 +81,9 @@ import java.util.logging.Logger; */ public class XmlRpcFileManager { + /** Name of this OODT component. TO be used by the configuration management */ + private static final String componentName = "file-mgr"; + /* the port to run the XML RPC web server on, default is 1999 */ private int webServerPort = 1999; @@ -108,6 +108,9 @@ public class XmlRpcFileManager { /* whether or not to expand a product instance into met */ private boolean expandProductMet; + /** Configuration Manager instance which will handle the configiration aspect in distributed/standalone manner */ + private ConfigurationManager configurationManager; + /** * <p> Creates a new XmlRpcFileManager with the given metadata store factory, and the given data store factory, on the * given port. </p> @@ -122,10 +125,20 @@ public class XmlRpcFileManager { webServer.addHandler("filemgr", this); webServer.start(); - this.loadConfiguration(); - LOG.log(Level.INFO, "File Manager started by " - + System.getProperty("user.name", "unknown")); + // set up the configuration, if there is any + if (System.getProperty("org.apache.oodt.cas.filemgr.properties") != null) { + String configFile = System.getProperty("org.apache.oodt.cas.filemgr.properties"); + LOG.log(Level.INFO, "Loading File Manager Configuration Properties from: [" + configFile + "]"); + + List<String> propertiesFiles = new ArrayList<String>(); + propertiesFiles.add(System.getProperty("org.apache.oodt.cas.filemgr.properties")); + configurationManager = ConfigurationManagerFactory.getConfigurationManager(componentName, propertiesFiles,null); + } else { + configurationManager = ConfigurationManagerFactory.getConfigurationManager(componentName,null,null); + } + this.loadConfiguration(); + LOG.log(Level.INFO, "File Manager started by " + System.getProperty("user.name", "unknown")); } public void setCatalog(Catalog catalog) { @@ -1525,15 +1538,7 @@ public class XmlRpcFileManager { } private void loadConfiguration() throws IOException { - // set up the configuration, if there is any - if (System.getProperty("org.apache.oodt.cas.filemgr.properties") != null) { - String configFile = System - .getProperty("org.apache.oodt.cas.filemgr.properties"); - LOG.log(Level.INFO, - "Loading File Manager Configuration Properties from: [" + configFile - + "]"); - System.getProperties().load(new FileInputStream(new File(configFile))); - } + configurationManager.loadProperties(); String metaFactory, dataFactory, transferFactory; http://git-wip-us.apache.org/repos/asf/oodt/blob/ac7170bd/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f5b1c3c..9a5bbbd 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ the License. <module>core</module> <module>commons</module> <module>cli</module> + <module>config</module> <module>pcs/input</module> <module>metadata</module> <module>protocol/api</module>
