You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2017/08/30 16:40:14 UTC
[45/52] [abbrv] oodt git commit: Introducing the concept of 'project'
to distributed configuration management
Introducing the concept of 'project' to distributed configuration management
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/1d70bd55
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/1d70bd55
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/1d70bd55
Branch: refs/heads/master
Commit: 1d70bd559467a6acde75056b8d76084cb21c22ce
Parents: 72722e0
Author: Imesha Sudasingha <im...@gmail.com>
Authored: Sun Aug 6 14:52:32 2017 +0530
Committer: Imesha Sudasingha <im...@gmail.com>
Committed: Sun Aug 6 14:52:32 2017 +0530
----------------------------------------------------------------------
.../oodt/config/ConfigurationManager.java | 10 +++
.../java/org/apache/oodt/config/Constants.java | 16 ++++-
.../DistributedConfigurationManager.java | 14 ++--
.../DistributedConfigurationPublisher.java | 28 ++++++--
.../oodt/config/distributed/ZNodePaths.java | 20 ++++--
.../config/distributed/utils/ConfigUtils.java | 75 ++++++++++++++++++++
.../config/distributed/utils/FilePathUtils.java | 59 ---------------
config/src/main/resources/config-publisher.xml | 4 ++
.../DistributedConfigurationManagerTest.java | 15 ++--
config/src/test/resources/config-publisher.xml | 2 +
filemgr/pom.xml | 1 +
.../cas/filemgr/system/XmlRpcFileManager.java | 1 +
.../distributed/config/config-publisher.xml | 3 +
13 files changed, 162 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/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
index 2554604..53aacef 100644
--- a/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java
+++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java
@@ -27,9 +27,15 @@ import java.util.List;
public abstract class ConfigurationManager {
protected Component component;
+ protected String project;
public ConfigurationManager(Component component) {
+ this(component, Constants.DEFAULT_PROJECT);
+ }
+
+ public ConfigurationManager(Component component, String project) {
this.component = component;
+ this.project = project;
}
public abstract void loadConfiguration() throws Exception;
@@ -53,4 +59,8 @@ public abstract class ConfigurationManager {
* @return list of locally stored files
*/
public abstract List<String> getSavedFiles();
+
+ public String getProject() {
+ return project;
+ }
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/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
index 53a1116..611f81e 100644
--- a/config/src/main/java/org/apache/oodt/config/Constants.java
+++ b/config/src/main/java/org/apache/oodt/config/Constants.java
@@ -35,12 +35,23 @@ public class Constants {
public static final String STANDALONE_NODE_NAME = "local";
/** Default environment name to be used */
- public static final String DEFAULT_ENVIRONMENT = "default";
+ public static final String DEFAULT_PROJECT = "default";
/** The XML file name in which the configuration to be published to zookeeper is defined */
public static final String DEFAULT_CONFIG_PUBLISHER_XML = "etc" + SEPARATOR + "config-publisher.xml";
+ public static class Env {
+ /** Environment variable name to specify OODT project name */
+ public static final String OODT_PROJECT = "OODT_PROJECT";
+ }
+
public static class Properties {
+ /**
+ * Name of the OODT project. This property allows us to run same type OODT components to be run with different
+ * configuration using the same zookeeper ensemble.
+ */
+ public static final String OODT_PROJECT = "org.apache.oodt.config.project";
+
/** 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";
@@ -68,6 +79,9 @@ public class Constants {
/** Namespace to be used when creating ZNodes in Zookeeper */
public static final String NAMESPACE = "oodt";
+ /** Where configuration for separate projects are stored */
+ public static final String PROJECTS_PATH_NAME = "projects";
+
/** Where OODT components related configuration are stored */
public static final String COMPONENTS_PATH_NAME = "components";
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/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
index 6b6ef21..ae8912a 100644
--- a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java
+++ b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java
@@ -23,8 +23,8 @@ import org.apache.oodt.config.Component;
import org.apache.oodt.config.ConfigurationManager;
import org.apache.oodt.config.Constants;
import org.apache.oodt.config.Constants.Properties;
+import org.apache.oodt.config.distributed.utils.ConfigUtils;
import org.apache.oodt.config.distributed.utils.CuratorUtils;
-import org.apache.oodt.config.distributed.utils.FilePathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,10 +38,11 @@ import java.util.concurrent.TimeUnit;
import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING;
import static org.apache.oodt.config.Constants.Properties.ZK_PROPERTIES_FILE;
+import static org.apache.oodt.config.distributed.utils.ConfigUtils.getOODTProjectName;
/**
* Distributed configuration manager implementation. This class make use of a {@link CuratorFramework} instance to
- * connect to zookeeper
+ * connect to zookeeper.
*
* @author Imesha Sudasingha.
*/
@@ -52,16 +53,13 @@ public class DistributedConfigurationManager extends ConfigurationManager {
/** Connection string required to connect to zookeeper */
private String connectString;
private CuratorFramework client;
- /** Name of the OODT component, to which this class is providing configuration support */
- private Component component;
private ZNodePaths zNodePaths;
private List<String> savedFiles = new ArrayList<>();
public DistributedConfigurationManager(Component component) {
- super(component);
- this.component = component;
- this.zNodePaths = new ZNodePaths(this.component.getName());
+ super(component, getOODTProjectName());
+ this.zNodePaths = new ZNodePaths(this.project, this.component.getName());
if (System.getProperty(ZK_PROPERTIES_FILE) == null && System.getProperty(Constants.Properties.ZK_CONNECT_STRING) == null) {
throw new IllegalArgumentException("Zookeeper requires system properties " + ZK_PROPERTIES_FILE + " or " + ZK_CONNECT_STRING + " to be set");
@@ -170,7 +168,7 @@ public class DistributedConfigurationManager extends ConfigurationManager {
}
private void saveFile(String path, byte[] data) throws IOException {
- String localFilePath = FilePathUtils.fixForComponentHome(component, path);
+ String localFilePath = ConfigUtils.fixForComponentHome(component, path);
File localFile = new File(localFilePath);
if (localFile.exists()) {
logger.warn("Deleting already existing file at {} before writing new content", localFilePath);
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisher.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisher.java b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisher.java
index a36aee2..6229e96 100644
--- a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisher.java
+++ b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisher.java
@@ -31,6 +31,7 @@ import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import static org.apache.oodt.config.Constants.DEFAULT_PROJECT;
import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING;
import static org.apache.oodt.config.Constants.Properties.ZK_PROPERTIES_FILE;
@@ -49,11 +50,18 @@ public class DistributedConfigurationPublisher {
private String connectString;
private CuratorFramework client;
private ZNodePaths zNodePaths;
+
private Component component;
+ private String project;
public DistributedConfigurationPublisher(Component component) {
+ this(component, DEFAULT_PROJECT);
+ }
+
+ public DistributedConfigurationPublisher(Component component, String project) {
this.component = component;
- this.zNodePaths = new ZNodePaths(this.component.getName());
+ this.project = project;
+ this.zNodePaths = new ZNodePaths(this.project, this.component.getName());
if (System.getProperty(ZK_PROPERTIES_FILE) == null && System.getProperty(ZK_CONNECT_STRING) == null) {
throw new IllegalArgumentException("Zookeeper requires system properties " + ZK_PROPERTIES_FILE + " or " + ZK_CONNECT_STRING + " to be set");
@@ -161,7 +169,7 @@ public class DistributedConfigurationPublisher {
for (Map.Entry<String, String> entry : fileMapping.entrySet()) {
String filePath = entry.getKey();
String relativeZNodePath = entry.getValue();
- logger.info("Publishing configuration {} to {}", filePath, relativeZNodePath);
+ logger.debug("Publishing configuration {} to {}", filePath, relativeZNodePath);
String content = getFileContent(filePath);
@@ -174,9 +182,9 @@ public class DistributedConfigurationPublisher {
} else {
Stat stat = client.setData().forPath(zNodePath, content.getBytes());
if (stat != null) {
- logger.info("Replaced old published configuration at {} with content of file : {}", relativeZNodePath, filePath);
+ logger.info("Replaced old published configuration at {} with content of file : {}", zNodePath, filePath);
} else {
- logger.warn("Unable to replace published configuration at {} with file: {}", relativeZNodePath, filePath);
+ logger.warn("Unable to replace published configuration at {} with file: {}", zNodePath, filePath);
}
}
} else {
@@ -185,7 +193,7 @@ public class DistributedConfigurationPublisher {
* when no child node is present under them.
*/
client.create().creatingParentContainersIfNeeded().forPath(zNodePath, content.getBytes());
- logger.info("Published configuration file {} to {}", filePath, relativeZNodePath);
+ logger.info("Published configuration file {} to {}", filePath, zNodePath);
}
}
}
@@ -195,7 +203,7 @@ public class DistributedConfigurationPublisher {
for (Map.Entry<String, String> entry : fileMapping.entrySet()) {
String filePath = entry.getKey();
String relativeZNodePath = entry.getValue();
- logger.info("Checking published configuration for {} - {}", filePath, relativeZNodePath);
+ logger.debug("Checking published configuration for {} - {}", filePath, relativeZNodePath);
String originalContent = getFileContent(filePath);
@@ -216,6 +224,10 @@ public class DistributedConfigurationPublisher {
logger.info("{} - {} configuration checked and OK", filePath, relativeZNodePath);
}
+ if (!noError) {
+ logger.warn("There are errors in configuration publishing");
+ }
+
return noError;
}
@@ -254,4 +266,8 @@ public class DistributedConfigurationPublisher {
public Component getComponent() {
return component;
}
+
+ public String getProject() {
+ return project;
+ }
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java b/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java
index 01792ba..cf3ca00 100644
--- a/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java
+++ b/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java
@@ -17,8 +17,10 @@
package org.apache.oodt.config.distributed;
+import static org.apache.oodt.config.Constants.DEFAULT_PROJECT;
import static org.apache.oodt.config.Constants.ZPaths.COMPONENTS_PATH_NAME;
import static org.apache.oodt.config.Constants.ZPaths.CONFIGURATION_PATH_NAME;
+import static org.apache.oodt.config.Constants.ZPaths.PROJECTS_PATH_NAME;
import static org.apache.oodt.config.Constants.ZPaths.PROPERTIES_PATH_NAME;
import static org.apache.oodt.config.Constants.ZPaths.SEPARATOR;
@@ -29,15 +31,15 @@ import static org.apache.oodt.config.Constants.ZPaths.SEPARATOR;
*/
public class ZNodePaths {
- /** ZNode for distinct components. /components/${component} */
+ /** ZNode for distinct components. /projects/${project}/components/${component} */
private String componentZNodePath;
private String componentZNodeRoot;
- /** ZNode path for properties files. /components/${component}/properties */
+ /** ZNode path for properties files. /projects/${project}/components/${component}/properties */
private String propertiesZNodePath;
private String propertiesZNodeRoot;
- /** ZNode path for other configuration files. /components/${component}/configuration */
+ /** ZNode path for other configuration files. /projects/${project}/components/${component}/configuration */
private String configurationZNodePath;
private String configurationZNodeRoot;
@@ -47,12 +49,20 @@ public class ZNodePaths {
*
* @param componentName Name of the OODT component
*/
- public ZNodePaths(String componentName) {
+ public ZNodePaths(String project, String componentName) {
+ if (project == null) {
+ project = DEFAULT_PROJECT;
+ }
+
if (componentName == null) {
throw new IllegalArgumentException("Component name cannot be null");
}
- componentZNodePath = SEPARATOR + COMPONENTS_PATH_NAME + SEPARATOR + componentName;
+ /* ZNode for distinct projects. /projects/${project} */
+ String projectZNodePath = SEPARATOR + PROJECTS_PATH_NAME + SEPARATOR + project;
+ String projectZNodeRoot = projectZNodePath + SEPARATOR;
+
+ componentZNodePath = projectZNodeRoot + COMPONENTS_PATH_NAME + SEPARATOR + componentName;
componentZNodeRoot = componentZNodePath + SEPARATOR;
propertiesZNodePath = componentZNodeRoot + PROPERTIES_PATH_NAME;
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/main/java/org/apache/oodt/config/distributed/utils/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/oodt/config/distributed/utils/ConfigUtils.java b/config/src/main/java/org/apache/oodt/config/distributed/utils/ConfigUtils.java
new file mode 100644
index 0000000..6e4d677
--- /dev/null
+++ b/config/src/main/java/org/apache/oodt/config/distributed/utils/ConfigUtils.java
@@ -0,0 +1,75 @@
+/*
+ * 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.utils;
+
+import org.apache.oodt.config.Component;
+import org.apache.oodt.config.Constants;
+import org.apache.oodt.config.Constants.Env;
+import org.apache.oodt.config.Constants.ZPaths;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.oodt.config.Constants.Properties.OODT_PROJECT;
+import static org.apache.oodt.config.Constants.SEPARATOR;
+
+public class ConfigUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
+
+ private ConfigUtils() {
+ }
+
+ /**
+ * Fix a given path to start from given {@link Component}'s home directory. Home directory will be fetched either
+ * through a system property or through an environment variable.
+ *
+ * @param component OODT {@link Component}
+ * @param suffixPath path to be fixed
+ * @return fixed path
+ */
+ public static String fixForComponentHome(Component component, String suffixPath) {
+ String prefix = System.getProperty(component.getHome());
+ if (prefix == null) {
+ prefix = System.getenv().get(component.getHome());
+ }
+
+ StringBuilder path = new StringBuilder();
+ if (prefix != null && !prefix.trim().isEmpty()) {
+ prefix = prefix.trim();
+ logger.debug("Found prefix {}:{} for suffixPath: {}", component.getHome(), prefix, suffixPath);
+ path.append(prefix.endsWith(SEPARATOR) ? prefix : prefix + SEPARATOR);
+ }
+ path.append(suffixPath.startsWith(ZPaths.SEPARATOR) ? suffixPath.substring(ZPaths.SEPARATOR.length()) : suffixPath);
+ logger.debug("Fixed path for {} is {}", suffixPath, path.toString());
+ return path.toString();
+ }
+
+ /**
+ * Get the name of the project name (optional) if specified. Else return a default value
+ *
+ * @return OODT project name
+ */
+ public static String getOODTProjectName() {
+ String project = System.getProperty(OODT_PROJECT);
+ if (project == null) {
+ project = System.getenv(Env.OODT_PROJECT);
+ }
+
+ return project == null ? Constants.DEFAULT_PROJECT : project;
+ }
+}
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/main/java/org/apache/oodt/config/distributed/utils/FilePathUtils.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/oodt/config/distributed/utils/FilePathUtils.java b/config/src/main/java/org/apache/oodt/config/distributed/utils/FilePathUtils.java
deleted file mode 100644
index cfb5ff9..0000000
--- a/config/src/main/java/org/apache/oodt/config/distributed/utils/FilePathUtils.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.utils;
-
-import org.apache.oodt.config.Component;
-import org.apache.oodt.config.Constants.ZPaths;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.oodt.config.Constants.SEPARATOR;
-
-public class FilePathUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(FilePathUtils.class);
-
- private FilePathUtils() {
- }
-
- public static String fixForComponentHome(Component component, String suffixPath) {
- String prefix = System.getProperty(component.getHome());
- if (prefix == null) {
- prefix = System.getenv().get(component.getHome());
- }
-
- StringBuilder path = new StringBuilder();
- if (prefix != null && !prefix.trim().isEmpty()) {
- prefix = prefix.trim();
- logger.debug("Found prefix {}:{} for suffixPath: {}", component.getHome(), prefix, suffixPath);
- path.append(prefix.endsWith(SEPARATOR) ? prefix : prefix + SEPARATOR);
- }
- path.append(suffixPath.startsWith(ZPaths.SEPARATOR) ? suffixPath.substring(ZPaths.SEPARATOR.length()) : suffixPath);
- logger.debug("Fixed path for {} is {}", suffixPath, path.toString());
- return path.toString();
- }
-
- public static String unfixForComponentHome(Component component, String path) {
- String prefix = System.getenv().get(component.getHome());
- if (prefix != null && path.startsWith(prefix)) {
- return path.substring(prefix.length() + SEPARATOR.length());
- }
-
- return path;
- }
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/main/resources/config-publisher.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/config-publisher.xml b/config/src/main/resources/config-publisher.xml
index d5b387a..ab6ee12 100644
--- a/config/src/main/resources/config-publisher.xml
+++ b/config/src/main/resources/config-publisher.xml
@@ -22,6 +22,10 @@
<!-- File Manager example configuration publisher -->
<bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher">
<constructor-arg value="FILE_MANAGER"/>
+
+ <!-- An optional project name, if you want to run several instances of the same component with different configuration -->
+ <!--<constructor-arg value="project-x"/>-->
+
<property name="propertiesFiles">
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="examples/filemgr/filemgr.properties" value="/etc/filemgr.properties"/>
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
----------------------------------------------------------------------
diff --git a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
index a4315a5..0bf2dde 100644
--- a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
+++ b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
@@ -19,7 +19,7 @@ package org.apache.oodt.config.distributed;
import org.apache.oodt.config.ConfigurationManager;
import org.apache.oodt.config.distributed.cli.ConfigPublisher;
-import org.apache.oodt.config.distributed.utils.FilePathUtils;
+import org.apache.oodt.config.distributed.utils.ConfigUtils;
import org.apache.oodt.config.test.AbstractDistributedConfigurationTest;
import org.junit.After;
import org.junit.Assert;
@@ -36,7 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import static org.apache.oodt.config.Constants.SEPARATOR;
+import static org.apache.oodt.config.Constants.Properties.OODT_PROJECT;
import static org.junit.Assert.fail;
/**
@@ -77,6 +77,8 @@ public class DistributedConfigurationManagerTest extends AbstractDistributedConf
@Test
public void loadConfigurationTest() throws Exception {
for (DistributedConfigurationPublisher publisher : publishers) {
+ System.setProperty(OODT_PROJECT, publisher.getProject());
+
ConfigurationManager configurationManager = new DistributedConfigurationManager(publisher.getComponent());
configurationManager.loadConfiguration();
@@ -87,7 +89,6 @@ public class DistributedConfigurationManagerTest extends AbstractDistributedConf
try (InputStream in = new FileInputStream(originalFile)) {
properties.load(in);
} catch (Exception e) {
- e.printStackTrace();
fail(e.getMessage());
}
@@ -96,8 +97,7 @@ public class DistributedConfigurationManagerTest extends AbstractDistributedConf
}
String fileName = entry.getValue();
- fileName = fileName.startsWith(SEPARATOR) ? fileName.substring(SEPARATOR.length()) : fileName;
- fileName = FilePathUtils.fixForComponentHome(publisher.getComponent(), fileName);
+ fileName = ConfigUtils.fixForComponentHome(publisher.getComponent(), fileName);
File downloadedFile = new File(fileName);
Assert.assertNotNull(downloadedFile);
Assert.assertTrue(downloadedFile.exists());
@@ -106,8 +106,7 @@ public class DistributedConfigurationManagerTest extends AbstractDistributedConf
// Checking for configuration files
for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) {
String fileName = entry.getValue();
- fileName = fileName.startsWith(SEPARATOR) ? fileName.substring(SEPARATOR.length()) : fileName;
- fileName = FilePathUtils.fixForComponentHome(publisher.getComponent(), fileName);
+ fileName = ConfigUtils.fixForComponentHome(publisher.getComponent(), fileName);
File file = new File(fileName);
Assert.assertTrue(file.exists());
}
@@ -118,6 +117,8 @@ public class DistributedConfigurationManagerTest extends AbstractDistributedConf
File file = new File(localFile);
Assert.assertFalse(file.exists());
}
+
+ System.clearProperty(OODT_PROJECT);
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/config/src/test/resources/config-publisher.xml
----------------------------------------------------------------------
diff --git a/config/src/test/resources/config-publisher.xml b/config/src/test/resources/config-publisher.xml
index 5720dab..bff93c2 100644
--- a/config/src/test/resources/config-publisher.xml
+++ b/config/src/test/resources/config-publisher.xml
@@ -21,6 +21,7 @@
<bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher">
<constructor-arg value="FILE_MANAGER"/>
+ <constructor-arg value="project1"/>
<property name="propertiesFiles">
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="target/resources/examples/filemgr/filemgr.properties" value="/etc/filemgr.properties"/>
@@ -49,6 +50,7 @@
<bean id="resmgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher">
<constructor-arg value="RESOURCE_MANAGER"/>
+ <constructor-arg value="project2"/>
<property name="propertiesFiles">
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="target/resources/examples/resmgr/resource.properties" value="/etc/resource.properties"/>
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/filemgr/pom.xml
----------------------------------------------------------------------
diff --git a/filemgr/pom.xml b/filemgr/pom.xml
index 84d6198..4fadcb8 100644
--- a/filemgr/pom.xml
+++ b/filemgr/pom.xml
@@ -237,6 +237,7 @@
</systemProperties>
<environmentVariables>
<OODT_FILEMGR_HOME>${project.basedir}</OODT_FILEMGR_HOME>
+ <OODT_PROJECT>primary</OODT_PROJECT>
</environmentVariables>
<forkedProcessTimeoutInSeconds>0</forkedProcessTimeoutInSeconds>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/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 aa7075c..8e70479 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
@@ -1224,6 +1224,7 @@ public class XmlRpcFileManager {
}
public boolean shutdown() {
+ configurationManager.clearConfiguration();
if (this.webServer != null) {
this.webServer.shutdown();
this.webServer = null;
http://git-wip-us.apache.org/repos/asf/oodt/blob/1d70bd55/filemgr/src/test/resources/distributed/config/config-publisher.xml
----------------------------------------------------------------------
diff --git a/filemgr/src/test/resources/distributed/config/config-publisher.xml b/filemgr/src/test/resources/distributed/config/config-publisher.xml
index 19e9f8c..f6a97c1 100644
--- a/filemgr/src/test/resources/distributed/config/config-publisher.xml
+++ b/filemgr/src/test/resources/distributed/config/config-publisher.xml
@@ -21,6 +21,9 @@
<bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher">
<constructor-arg value="FILE_MANAGER"/>
+
+ <constructor-arg value="primary"/>
+
<property name="propertiesFiles">
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="src/test/resources/distributed/config/filemgr.properties" value="target/filemgr/etc/filemgr.properties"/>