azkaban-aplcache

Add an API to allow Props to load both current and parent properties

2/22/2018 6:56:27 PM

Details

diff --git a/az-core/src/main/java/azkaban/utils/Props.java b/az-core/src/main/java/azkaban/utils/Props.java
index 7df3c35..9ee0869 100644
--- a/az-core/src/main/java/azkaban/utils/Props.java
+++ b/az-core/src/main/java/azkaban/utils/Props.java
@@ -667,7 +667,9 @@ public class Props {
   }
 
   /**
-   * Returns a java.util.Properties file populated with the stuff in here.
+   * Returns a java.util.Properties file populated with the current Properties in here.
+   * Note: if you want to import parent properties (e.g., database credentials), please use
+   * toAllProperties
    */
   public Properties toProperties() {
     final Properties p = new Properties();
@@ -679,6 +681,21 @@ public class Props {
   }
 
   /**
+   * Returns a java.util.Properties file populated with both current and parent properties.
+   */
+  public Properties toAllProperties() {
+    Properties allProp = new Properties();
+    // import local properties
+    allProp.putAll(toProperties());
+
+    // import parent properties
+    if(_parent != null)
+      allProp.putAll(_parent.toProperties());
+
+    return allProp;
+  }
+
+  /**
    * Store all properties, those local and also those in parent props
    *
    * @param file The file to store to
diff --git a/azkaban-web-server/src/main/java/azkaban/scheduler/QuartzScheduler.java b/azkaban-web-server/src/main/java/azkaban/scheduler/QuartzScheduler.java
index ddcacc6..9115ab1 100644
--- a/azkaban-web-server/src/main/java/azkaban/scheduler/QuartzScheduler.java
+++ b/azkaban-web-server/src/main/java/azkaban/scheduler/QuartzScheduler.java
@@ -54,8 +54,11 @@ public class QuartzScheduler {
     if (!azProps.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) {
       return;
     }
+    // TODO kunkun-tang: Many quartz properties should be defaulted such that not necessarily being
+    // checked into azkaban.properties. Also, we need to only assemble Quartz related properties
+    // here, which should be done in Azkaban WebServer Guice Module.
     final StdSchedulerFactory schedulerFactory =
-        new StdSchedulerFactory(azProps.toProperties());
+        new StdSchedulerFactory(azProps.toAllProperties());
     this.scheduler = schedulerFactory.getScheduler();
 
     // Currently Quartz only support internal job schedules. When we migrate to User Production