You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2014/09/09 16:34:06 UTC

svn commit: r1623835 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common: IDuccEnv.java utils/DuccPropertiesResolver.java

Author: degenaro
Date: Tue Sep  9 14:34:06 2014
New Revision: 1623835

URL: http://svn.apache.org/r1623835
Log:
UIMA-3992 DUCC needs a file for private configuration data ... updates for common

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccEnv.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccPropertiesResolver.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccEnv.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccEnv.java?rev=1623835&r1=1623834&r2=1623835&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccEnv.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccEnv.java Tue Sep  9 14:34:06 2014
@@ -26,8 +26,6 @@ public interface IDuccEnv {
 	
 	public static final String DUCC_HOME_DIR = DUCC_HOME+File.separator;
 	public static final String DUCC_RESOURCES_DIR = DUCC_HOME_DIR+"resources"+File.separator;
-	public static final String DUCC_PRIVATE_DIR = DUCC_RESOURCES_DIR+"private"+File.separator;
-	public static final String DUCC_PRIVATE_PROPERTIES_FILE = DUCC_PRIVATE_DIR+"ducc.private.properties";
 	public static final String DUCC_PROPERTIES_FILE = DUCC_RESOURCES_DIR+"ducc.properties";
 	public static final String DUCC_NODES_FILE_NAME = "ducc.nodes";
 	public static final String DUCC_NODES_FILE_PATH = DUCC_RESOURCES_DIR+DUCC_NODES_FILE_NAME;

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccPropertiesResolver.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccPropertiesResolver.java?rev=1623835&r1=1623834&r2=1623835&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccPropertiesResolver.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccPropertiesResolver.java Tue Sep  9 14:34:06 2014
@@ -24,12 +24,24 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Map.Entry;
 import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.uima.ducc.common.IDuccEnv;
-
+import org.apache.uima.ducc.common.utils.id.DuccId;
 
 public class DuccPropertiesResolver {
-
+	
+	private DuccLogger logger = DuccLogger.getLogger(DuccPropertiesResolver.class, null);
+	private DuccId duccId = null;
+	
+	private AtomicBoolean loadedPrivate = new AtomicBoolean(false);
+	
+	private AtomicBoolean e1 = new AtomicBoolean(false);
+	private AtomicBoolean e2 = new AtomicBoolean(false);
+	private AtomicBoolean e3 = new AtomicBoolean(false);
+	private AtomicBoolean e4 = new AtomicBoolean(false);
+	private AtomicBoolean e5 = new AtomicBoolean(false);
+	
     private static DuccPropertiesResolver duccPropertiesResolver = new DuccPropertiesResolver();
     
     public static DuccPropertiesResolver getInstance() {
@@ -60,6 +72,8 @@ public class DuccPropertiesResolver {
         
     }
     
+    public static final String ducc_private_resources = "ducc.private.resources";
+    
     public static final String ducc_threads_limit = "ducc.threads.limit";
     public static final String ducc_driver_jvm_args = "ducc.driver.jvm.args";
     public static final String ducc_process_jvm_args = "ducc.process.jvm.args";
@@ -150,18 +164,31 @@ public class DuccPropertiesResolver {
     }
     
     private void init(Properties properties) {
+    	String location = "init";
+    	String fileName = null;
         try {
-            File file = new File(IDuccEnv.DUCC_PROPERTIES_FILE);
+        	String componentProperties="ducc.deploy.configuration";
+        	fileName = System.getProperty(componentProperties);
+        	if(fileName == null) {
+        		fileName = IDuccEnv.DUCC_PROPERTIES_FILE;
+        	}
+            File file = new File(fileName);
             FileInputStream fis;
             fis = new FileInputStream(file);
             properties.load(fis);
             fis.close();
         } 
         catch (FileNotFoundException e) {
-            System.out.println("File not found: "+IDuccEnv.DUCC_PROPERTIES_FILE);
+        	if(!e1.get()) {
+            	logger.error(location, duccId, "File not found: "+fileName);
+            	e1.set(true);;
+            }
         } 
         catch (IOException e) {
-            System.out.println("Error reading file: "+IDuccEnv.DUCC_PROPERTIES_FILE);
+        	if(!e2.get()) {
+            	logger.debug(location, duccId, "Error reading file: "+fileName);
+            	e2.set(true);;
+            }
         }
         enrich(properties);
     }
@@ -175,22 +202,45 @@ public class DuccPropertiesResolver {
     }
     
     private Properties getPrivateProperties() {
-    	//String methodName = "getPrivateProperties";
+    	String location = "getPrivateProperties";
     	Properties privateProperties = new Properties();
-    	String fileName = IDuccEnv.DUCC_PRIVATE_PROPERTIES_FILE;
-    	try {
-            File file = new File(fileName);
-            FileInputStream fis;
-            fis = new FileInputStream(file);
-            privateProperties.load(fis);
-            fis.close();
-        } 
-        catch (FileNotFoundException e) {
-            //System.out.println(methodName+" "+"File not found: "+fileName);
-        } 
-        catch (IOException e) {
-            //System.out.println(methodName+" "+"Error reading file: "+fileName);
-        }
+    	String key = ducc_private_resources;
+    	String directory = getProperty(key);
+    	if(directory != null) {
+    		String fileName = directory+File.separator+"ducc.private.properties";
+        	try {
+                File file = new File(fileName);
+                FileInputStream fis;
+                fis = new FileInputStream(file);
+                privateProperties.load(fis);
+                fis.close();
+                if(loadedPrivate.get()) {
+                	logger.debug(location, duccId, "Loaded: "+fileName);
+                }
+                else {
+                	logger.info(location, duccId, "Loaded: "+fileName);
+                }
+                loadedPrivate.set(true);
+            } 
+            catch (FileNotFoundException e) {
+            	if(!e3.get()) {
+                	logger.error(location, duccId, "File not found: "+fileName);
+                	e3.set(true);;
+                }
+            } 
+        	catch (IOException e) {
+        		if(!e4.get()) {
+                	logger.debug(location, duccId, "Error reading file: "+fileName);
+                	e4.set(true);;
+                }
+            }
+    	}
+    	else {
+    		if(!e5.get()) {
+            	logger.debug(location, duccId, "Key not found: "+key);
+            	e5.set(true);;
+            }
+    	}
     	return privateProperties;
     }