Improvements to file downloading from zookeeper and tests

Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/99b086b9
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/99b086b9
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/99b086b9

Branch: refs/heads/feature/zookeeper-config
Commit: 99b086b9887cafc8b89de3ff65fa61d3f80cc56c
Parents: e697405
Author: Imesha Sudasingha <[email protected]>
Authored: Mon Jul 10 17:21:51 2017 +0530
Committer: Imesha Sudasingha <[email protected]>
Committed: Mon Jul 10 17:21:51 2017 +0530

----------------------------------------------------------------------
 .../oodt/config/ConfigurationManager.java       |  6 +--
 .../config/ConfigurationManagerFactory.java     | 12 +++--
 .../java/org/apache/oodt/config/Constants.java  | 22 +++++++--
 .../DistributedConfigurationManager.java        | 40 +++++++++++-----
 .../oodt/config/distributed/ZNodePaths.java     |  4 ++
 .../cli/DistributedConfigurationPublisher.java  | 28 +++++------
 .../StandaloneConfigurationManager.java         |  3 +-
 .../src/main/resources/etc/config-publisher.xml |  2 +-
 .../DistributedConfigurationManagerTest.java    | 11 +++--
 .../src/test/resources/etc/config-publisher.xml |  4 +-
 filemgr/src/main/assembly/assembly.xml          | 49 ++++++++++----------
 filemgr/src/main/bin/filemgr                    | 26 +++++++++--
 .../cas/filemgr/system/XmlRpcFileManager.java   |  8 +---
 filemgr/src/main/resources/log4j.xml            | 40 ++++++++++++++++
 14 files changed, 177 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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 d65c4ae..d4706a2 100644
--- a/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java
+++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java
@@ -24,15 +24,15 @@ package org.apache.oodt.config;
  */
 public abstract class ConfigurationManager {
 
-    protected String component;
+    protected Constants.Component component;
 
-    public ConfigurationManager(String component) {
+    public ConfigurationManager(Constants.Component component) {
         this.component = component;
     }
 
     public abstract void loadConfiguration() throws Exception;
 
-    public String getComponent() {
+    public Constants.Component getComponent() {
         return component;
     }
 }

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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
index 4d01e35..e616f96 100644
--- 
a/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java
+++ 
b/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java
@@ -19,9 +19,10 @@ package org.apache.oodt.config;
 
 import org.apache.oodt.config.distributed.DistributedConfigurationManager;
 import org.apache.oodt.config.standalone.StandaloneConfigurationManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.List;
-import java.util.logging.Logger;
 
 import static 
org.apache.oodt.config.Constants.Properties.ENABLE_DISTRIBUTED_CONFIGURATION;
 
@@ -33,7 +34,7 @@ import static 
org.apache.oodt.config.Constants.Properties.ENABLE_DISTRIBUTED_CON
 public class ConfigurationManagerFactory {
 
     /** Logger instance for this class */
-    private static final Logger logger = 
Logger.getLogger(ConfigurationManagerFactory.class.getName());
+    private static final Logger logger = 
LoggerFactory.getLogger(ConfigurationManagerFactory.class);
 
     private ConfigurationManagerFactory() {
     }
@@ -49,10 +50,13 @@ public class ConfigurationManagerFactory {
      *                        management
      * @return ConfigurationManager instance to used by the corresponding 
component.
      */
-    public static ConfigurationManager getConfigurationManager(String 
component, List<String> propertiesFiles) {
-        if (System.getProperty(ENABLE_DISTRIBUTED_CONFIGURATION) != null) {
+    public static ConfigurationManager 
getConfigurationManager(Constants.Component component, List<String> 
propertiesFiles) {
+        if (Boolean.getBoolean(ENABLE_DISTRIBUTED_CONFIGURATION)) {
+            logger.info("Using distributed configuration management for {}", 
component);
             return new DistributedConfigurationManager(component);
         }
+
+        logger.info("Using standalone configuration management for {}", 
component);
         return new StandaloneConfigurationManager(component, propertiesFiles);
     }
 }

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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 8c6f624..5fb62ed 100644
--- a/config/src/main/java/org/apache/oodt/config/Constants.java
+++ b/config/src/main/java/org/apache/oodt/config/Constants.java
@@ -61,9 +61,25 @@ public class Constants {
         public static final String ZK_PASSWORD = 
"org.apache.oodt.config.zk.password";
     }
 
-    public static class Components {
-        public static final String FILE_MANAGER = "filemgr";
-        public static final String RESOURCE_MANAGER = "resmgr";
+    public enum Component {
+        FILE_MANAGER("filemgr", "FILEMGR_HOME"),
+        RESOURCE_MANAGER("resmgr", "RESMGR_HOME");
+
+        String name;
+        String home;
+
+        Component(String name, String home) {
+            this.name = name;
+            this.home = home;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getHome() {
+            return home;
+        }
     }
 
     public static class ZPaths {

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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 67589fe..a5f1ef6 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
@@ -35,6 +35,7 @@ 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.Constants.SEPARATOR;
 
 /**
  * Distributed configuration manager implementation. This class make use of a 
{@link CuratorFramework} instance to connect
@@ -50,13 +51,13 @@ public class DistributedConfigurationManager extends 
ConfigurationManager {
     private String connectString;
     private CuratorFramework client;
     /** Name of the OODT component, to which this class is providing 
configuration support */
-    private String componentName;
+    private Constants.Component component;
     private ZNodePaths zNodePaths;
 
-    public DistributedConfigurationManager(String component) {
+    public DistributedConfigurationManager(Constants.Component component) {
         super(component);
-        this.componentName = component;
-        this.zNodePaths = new ZNodePaths(component);
+        this.component = component;
+        this.zNodePaths = new ZNodePaths(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");
@@ -107,13 +108,13 @@ public class DistributedConfigurationManager extends 
ConfigurationManager {
 
     @Override
     public void loadConfiguration() throws Exception {
-        logger.debug("Loading properties for : {}", componentName);
+        logger.debug("Loading properties for : {}", component);
         loadProperties();
-        logger.info("Properties loaded for : {}", componentName);
+        logger.info("Properties loaded for : {}", component);
 
-        logger.debug("Saving configuration files for : {}", componentName);
+        logger.debug("Saving configuration files for : {}", component);
         saveConfigFiles();
-        logger.info("Configuration files saved for : {}", componentName);
+        logger.info("Configuration files saved for : {}", component);
     }
 
     /**
@@ -136,8 +137,12 @@ public class DistributedConfigurationManager extends 
ConfigurationManager {
             try (InputStream in = new ByteArrayInputStream(bytes)) {
                 System.getProperties().load(in);
             }
-
             logger.info("Properties loaded from ZNode at : {}", 
propertiesFileZNodePath);
+
+            String localFilePath = 
zNodePaths.getLocalPropertiesFilePath(propertiesFileZNodePath);
+            localFilePath = fixForComponentHome(localFilePath);
+            FileUtils.writeByteArrayToFile(new File(localFilePath), bytes);
+            logger.info("Properties file from ZNode at {} saved to {}", 
propertiesFileZNodePath, localFilePath);
         }
     }
 
@@ -161,13 +166,24 @@ public class DistributedConfigurationManager extends 
ConfigurationManager {
             byte[] bytes = client.getData().forPath(configFileZNodePath);
 
             String localFilePath = 
zNodePaths.getLocalConfigFilePath(configFileZNodePath);
+            localFilePath = fixForComponentHome(localFilePath);
             FileUtils.writeByteArrayToFile(new File(localFilePath), bytes);
-            logger.info("Config file from ZNode at {} saved to {}", 
configFileZNodePath);
+            logger.info("Config file from ZNode at {} saved to {}", 
configFileZNodePath, localFilePath);
+        }
+    }
+
+    private String fixForComponentHome(String suffixPath) {
+        String prefix = System.getenv().get(component.getHome());
+        StringBuilder path = new StringBuilder();
+        if (prefix != null) {
+            path.append(prefix.endsWith(SEPARATOR) ? prefix : prefix + 
SEPARATOR);
         }
+        path.append(suffixPath.startsWith(SEPARATOR) ? suffixPath.substring(1) 
: suffixPath);
+        return path.toString();
     }
 
-    public String getComponentName() {
-        return componentName;
+    public Constants.Component getComponent() {
+        return component;
     }
 
     public ZNodePaths getzNodePaths() {

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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 90fa9a5..eb40fa4 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
@@ -81,4 +81,8 @@ public class ZNodePaths {
     public String getLocalConfigFilePath(String zNodePath) {
         return zNodePath.substring(configurationZNodeRoot.length());
     }
+
+    public String getLocalPropertiesFilePath(String zNodePath) {
+        return zNodePath.substring(propertiesZNodeRoot.length());
+    }
 }

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java
 
b/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java
index 8cdc6c6..0036664 100644
--- 
a/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java
+++ 
b/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java
@@ -54,11 +54,11 @@ public class DistributedConfigurationPublisher {
     private String connectString;
     private CuratorFramework client;
     private ZNodePaths zNodePaths;
-    private String componentName;
+    private Constants.Component component;
 
-    public DistributedConfigurationPublisher(String componentName) {
-        this.componentName = componentName;
-        this.zNodePaths = new ZNodePaths(componentName);
+    public DistributedConfigurationPublisher(Constants.Component component) {
+        this.component = component;
+        this.zNodePaths = new ZNodePaths(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");
@@ -150,7 +150,7 @@ public class DistributedConfigurationPublisher {
     }
 
     /**
-     * Removes all the nodes from zookeeper where the configuration 
corresponding to component {@link #componentName} is
+     * Removes all the nodes from zookeeper where the configuration 
corresponding to component {@link #component} is
      * stored
      *
      * @throws Exception zookeeper errors
@@ -284,20 +284,20 @@ public class DistributedConfigurationPublisher {
 
             for (Object bean : distributedConfigurationPublisher.values()) {
                 DistributedConfigurationPublisher publisher = 
(DistributedConfigurationPublisher) bean;
-                System.out.println(String.format("\nProcessing commands for 
component : %s", publisher.getComponentName()));
+                System.out.println(String.format("\nProcessing commands for 
component : %s", publisher.getComponent()));
 
                 if (cmdLineOptions.isPublish()) {
-                    System.out.println(String.format("Publishing configuration 
for : %s", publisher.getComponentName()));
+                    System.out.println(String.format("Publishing configuration 
for : %s", publisher.getComponent()));
                     publisher.publishConfiguration();
-                    System.out.println(String.format("Published configuration 
for : %s", publisher.getComponentName()));
+                    System.out.println(String.format("Published configuration 
for : %s", publisher.getComponent()));
                     System.out.println();
                 }
 
                 if (cmdLineOptions.isVerify()) {
-                    System.out.println(String.format("Verifying configuration 
for : %s", publisher.getComponentName()));
+                    System.out.println(String.format("Verifying configuration 
for : %s", publisher.getComponent()));
                     if (publisher.verifyPublishedConfiguration()) {
                         System.out.println("OK... Configuration verified");
-                        System.out.println(String.format("Verified 
configuration for : %s", publisher.getComponentName()));
+                        System.out.println(String.format("Verified 
configuration for : %s", publisher.getComponent()));
                     } else {
                         System.err.println("ERROR... Published configuration 
doesn't match the local files. Please check above logs");
                     }
@@ -305,9 +305,9 @@ public class DistributedConfigurationPublisher {
                 }
 
                 if (cmdLineOptions.isClear()) {
-                    System.out.println(String.format("Clearing configuration 
for : %s", publisher.getComponentName()));
+                    System.out.println(String.format("Clearing configuration 
for : %s", publisher.getComponent()));
                     publisher.clearConfiguration();
-                    System.out.println(String.format("Cleared configuration 
for : %s", publisher.getComponentName()));
+                    System.out.println(String.format("Cleared configuration 
for : %s", publisher.getComponent()));
                     System.out.println();
                 }
 
@@ -324,7 +324,7 @@ public class DistributedConfigurationPublisher {
         logger.info("Exiting CLI ...");
     }
 
-    public String getComponentName() {
-        return componentName;
+    public Constants.Component getComponent() {
+        return component;
     }
 }

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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
index 8d932fb..3e82580 100644
--- 
a/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java
+++ 
b/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java
@@ -18,6 +18,7 @@
 package org.apache.oodt.config.standalone;
 
 import org.apache.oodt.config.ConfigurationManager;
+import org.apache.oodt.config.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,7 +38,7 @@ public class StandaloneConfigurationManager extends 
ConfigurationManager {
 
     private List<String> propertiesFiles;
 
-    public StandaloneConfigurationManager(String component, List<String> 
propertiesFiles) {
+    public StandaloneConfigurationManager(Constants.Component component, 
List<String> propertiesFiles) {
         super(component);
         this.propertiesFiles = propertiesFiles != null ? propertiesFiles : new 
ArrayList<String>();
     }

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/config/src/main/resources/etc/config-publisher.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/etc/config-publisher.xml 
b/config/src/main/resources/etc/config-publisher.xml
index dab33c3..443a7a5 100644
--- a/config/src/main/resources/etc/config-publisher.xml
+++ b/config/src/main/resources/etc/config-publisher.xml
@@ -21,7 +21,7 @@
 
     <!-- Configuration publisher for File Manager OODT Component -->
     <bean id="filemgr-config-publisher" 
class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher">
-        <constructor-arg value="filemgr"/>
+        <constructor-arg value="FILE_MANAGER"/>
         <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/99b086b9/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 2aa855c..1d8c716 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
@@ -70,20 +70,25 @@ public class DistributedConfigurationManagerTest extends 
AbstractDistributedConf
     @Test
     public void loadConfigurationTest() throws Exception {
         for (DistributedConfigurationPublisher publisher : publishers) {
-            ConfigurationManager configurationManager = new 
DistributedConfigurationManager(publisher.getComponentName());
+            ConfigurationManager configurationManager = new 
DistributedConfigurationManager(publisher.getComponent());
             configurationManager.loadConfiguration();
 
             // Checking for configuration files
             for (Map.Entry<String, String> entry : 
publisher.getPropertiesFiles().entrySet()) {
-                File file = new File(entry.getKey());
+                File originalFile = new File(entry.getKey());
                 Properties properties = new Properties();
-                try (InputStream in = new FileInputStream(file)) {
+                try (InputStream in = new FileInputStream(originalFile)) {
                     properties.load(in);
                 }
 
                 for (String key : properties.stringPropertyNames()) {
                     Assert.assertEquals(properties.getProperty(key), 
System.getProperty(key));
                 }
+
+                String fileName = entry.getValue();
+                fileName = fileName.startsWith(SEPARATOR) ? 
fileName.substring(1) : fileName;
+                File downloadedFile = new File(fileName);
+                Assert.assertTrue(downloadedFile.exists());
             }
 
             // Checking for configuration files

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/config/src/test/resources/etc/config-publisher.xml
----------------------------------------------------------------------
diff --git a/config/src/test/resources/etc/config-publisher.xml 
b/config/src/test/resources/etc/config-publisher.xml
index f779f14..89e16f3 100644
--- a/config/src/test/resources/etc/config-publisher.xml
+++ b/config/src/test/resources/etc/config-publisher.xml
@@ -20,7 +20,7 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>
 
     <bean id="filemgr-config-publisher" 
class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher">
-        <constructor-arg value="filemgr"/>
+        <constructor-arg value="FILE_MANAGER"/>
         <property name="propertiesFiles">
             <map key-type="java.lang.String" value-type="java.lang.String">
                 <entry 
key="src/main/resources/examples/filemgr/filemgr.properties" 
value="/etc/filemgr.properties"/>
@@ -39,7 +39,7 @@
     </bean>
 
     <bean id="resmgr-config-publisher" 
class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher">
-        <constructor-arg value="resmgr"/>
+        <constructor-arg value="RESOURCE_MANAGER"/>
         <property name="propertiesFiles">
             <map key-type="java.lang.String" value-type="java.lang.String">
                 <entry 
key="src/main/resources/examples/resmgr/resource.properties" 
value="/etc/resource.properties"/>

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/filemgr/src/main/assembly/assembly.xml
----------------------------------------------------------------------
diff --git a/filemgr/src/main/assembly/assembly.xml 
b/filemgr/src/main/assembly/assembly.xml
index db50901..07a8a9c 100644
--- a/filemgr/src/main/assembly/assembly.xml
+++ b/filemgr/src/main/assembly/assembly.xml
@@ -17,24 +17,24 @@
  */
 
 $Id$
--->
-<assembly>
-  <id>dist</id>
-  <formats>
+-->
+<assembly>
+  <id>dist</id>
+  <formats>
     <format>tar.gz</format>
-    <format>zip</format>
+    <format>zip</format>
   </formats>
   <includeBaseDirectory>true</includeBaseDirectory>
   <baseDirectory>${project.artifactId}-${project.version}</baseDirectory>
-  <includeSiteDirectory>false</includeSiteDirectory>
-  <fileSets>
-    <fileSet>
-      <directory>${basedir}</directory>
-      <outputDirectory>.</outputDirectory>
-      <includes>
-        <include>LICENSE.txt</include>
-        <include>CHANGES.txt</include>
-      </includes>
+  <includeSiteDirectory>false</includeSiteDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${basedir}</directory>
+      <outputDirectory>.</outputDirectory>
+      <includes>
+        <include>LICENSE.txt</include>
+        <include>CHANGES.txt</include>
+      </includes>
     </fileSet>
     <fileSet>
       <directory>${basedir}/src/main/bin</directory>
@@ -55,6 +55,7 @@ $Id$
       <includes>
         <include>filemgr.properties</include>
         <include>logging.properties</include>
+        <include>log4j.xml</include>
       </includes>
     </fileSet>
     <fileSet>
@@ -83,15 +84,15 @@ $Id$
       <filtered>false</filtered>
       <outputDirectory>doc</outputDirectory>
       <excludes/>
-    </fileSet>
-  </fileSets>
-  <dependencySets>
-    <dependencySet>
-      <outputDirectory>lib</outputDirectory>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
       <unpack>false</unpack>
       <useProjectArtifact>true</useProjectArtifact>
-      <useTransitiveDependencies>true</useTransitiveDependencies>
-      <unpackOptions/>
-    </dependencySet>
-  </dependencySets>
-</assembly>
+      <useTransitiveDependencies>true</useTransitiveDependencies>
+      <unpackOptions/>
+    </dependencySet>
+  </dependencySets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/filemgr/src/main/bin/filemgr
----------------------------------------------------------------------
diff --git a/filemgr/src/main/bin/filemgr b/filemgr/src/main/bin/filemgr
index 2049ded..1a4af47 100644
--- a/filemgr/src/main/bin/filemgr
+++ b/filemgr/src/main/bin/filemgr
@@ -34,14 +34,14 @@ else
 fi
 
 export JAVA_HOME
-CAS_FILEMGR_HOME=..
-export CAS_FILEMGR_HOME
-RUN_HOME=${CAS_FILEMGR_HOME}/../run
+FILEMGR_HOME=..
+export FILEMGR_HOME
+RUN_HOME=${FILEMGR_HOME}/../run
 export RUN_HOME
 CAS_FILEMGR_PROPS=../etc/filemgr.properties
 export CAS_FILEMGR_PROPS
 
-PATH=${JAVA_HOME}/bin:${CAS_FILEMGR_HOME}/bin:/usr/bin:/bin:/usr/sbin:/sbin
+PATH=${JAVA_HOME}/bin:${FILEMGR_HOME}/bin:/usr/bin:/bin:/usr/sbin:/sbin
 export PATH
 
 ## make sure that casfile manager has a run directory
@@ -52,13 +52,29 @@ for file in `find ../lib/*.jar`; do
      LIB_DEPS="${file}:${LIB_DEPS}"
 done
 
+if [ ! -z $OODT_DISTRIBUTED_CONF ]
+    then
+    if [ ! -z $ZK_CONNECT_STRING ]
+        then
+        echo "Using distributed configuration management"
+        
DISTRIBUTED_CONF_PROPERTIES="-Dorg.apache.oodt.config.zk.connectString=${ZK_CONNECT_STRING}
 -Dorg.apache.oodt.config.distributed=true"
+    else
+        echo "Zookeeper connect string (ZK_CONNECT_STRING) is not set while 
OODT_DISTRIBUTED_CONF is set"
+        exit 1
+    fi
+else
+    echo "Using standalone configuration management"
+fi
+
 # See how we were called.
 case "$1" in
   start)
         echo -n "Starting cas file manager: "
         $JAVA_HOME/bin/java \
                -cp ${LIB_DEPS} \
-               
-Djava.util.logging.config.file=${CAS_FILEMGR_HOME}/etc/logging.properties \
+               ${DISTRIBUTED_CONF_PROPERTIES} \
+               -Dlog4j.configuration=./${FILEMGR_HOME}/etc/log4j.xml \
+               
-Djava.util.logging.config.file=${FILEMGR_HOME}/etc/logging.properties \
            -Dorg.apache.oodt.cas.filemgr.properties=${CAS_FILEMGR_PROPS} \
                org.apache.oodt.cas.filemgr.system.XmlRpcFileManager \
                --portNum $SERVER_PORT &       

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/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 0b9501e..60ee1bf 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
@@ -43,6 +43,7 @@ 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.oodt.config.Constants;
 import org.apache.xmlrpc.WebServer;
 
 import java.io.*;
@@ -54,9 +55,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import static org.apache.oodt.config.Constants.Components.FILE_MANAGER;
-
-
 /**
  * @author mattmann
  * @author bfoster
@@ -111,12 +109,10 @@ public class XmlRpcFileManager {
 
     // set up the configuration, if there is any
     if (System.getProperty("org.apache.oodt.cas.filemgr.properties") != null) {
-      String propertiesFile = 
System.getProperty("org.apache.oodt.cas.filemgr.properties");
-      LOG.log(Level.INFO, "Using File Manager Configuration Properties file : 
[" + propertiesFile + "]");
       
propertiesFiles.add(System.getProperty("org.apache.oodt.cas.filemgr.properties"));
     }
 
-    configurationManager = 
ConfigurationManagerFactory.getConfigurationManager(FILE_MANAGER, 
propertiesFiles);
+    configurationManager = 
ConfigurationManagerFactory.getConfigurationManager(Constants.Component.FILE_MANAGER,
 propertiesFiles);
 
     this.loadConfiguration();
     LOG.log(Level.INFO, "File Manager started by " + 
System.getProperty("user.name", "unknown"));

http://git-wip-us.apache.org/repos/asf/oodt/blob/99b086b9/filemgr/src/main/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/filemgr/src/main/resources/log4j.xml 
b/filemgr/src/main/resources/log4j.xml
new file mode 100644
index 0000000..0421de2
--- /dev/null
+++ b/filemgr/src/main/resources/log4j.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ 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.
+  -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">
+        <param name="Target" value="System.out"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
+        </layout>
+    </appender>
+
+    <root>
+        <priority value="INFO"/>
+        <appender-ref ref="console"/>
+    </root>
+
+    <logger name="org.apache.zookeeper">
+        <level value="ERROR"/>
+    </logger>
+    <logger name="org.apache.curator">
+        <level value="ERROR"/>
+    </logger>
+</log4j:configuration>
\ No newline at end of file

Reply via email to