azkaban-aplcache

Details

diff --git a/azkaban-common/src/main/java/azkaban/database/AbstractJdbcLoader.java b/azkaban-common/src/main/java/azkaban/database/AbstractJdbcLoader.java
index a266c2f..a2e432e 100644
--- a/azkaban-common/src/main/java/azkaban/database/AbstractJdbcLoader.java
+++ b/azkaban-common/src/main/java/azkaban/database/AbstractJdbcLoader.java
@@ -18,57 +18,28 @@ package azkaban.database;
 
 import azkaban.metrics.CommonMetrics;
 import azkaban.utils.Props;
-
 import java.io.IOException;
 import java.sql.Connection;
-
 import org.apache.commons.dbutils.DbUtils;
 import org.apache.commons.dbutils.QueryRunner;
 
 
 public abstract class AbstractJdbcLoader {
-  /**
-   * Used for when we store text data. Plain uses UTF8 encoding.
-   */
-  public enum EncodingType {
-    PLAIN(1), GZIP(2);
-
-    private final int numVal;
-
-    EncodingType(int numVal) {
-      this.numVal = numVal;
-    }
-
-    public int getNumVal() {
-      return numVal;
-    }
-
-    public static EncodingType fromInteger(int x) {
-      switch (x) {
-      case 1:
-        return PLAIN;
-      case 2:
-        return GZIP;
-      default:
-        return PLAIN;
-      }
-    }
-  }
 
-  private AzkabanDataSource dataSource;
+  private final AzkabanDataSource dataSource;
 
-  public AbstractJdbcLoader(Props props) {
-    dataSource = DataSourceUtils.getDataSource(props);
+  public AbstractJdbcLoader(final Props props) {
+    this.dataSource = DataSourceUtils.getDataSource(props);
   }
 
-  protected Connection getDBConnection(boolean autoCommit) throws IOException {
+  protected Connection getDBConnection(final boolean autoCommit) throws IOException {
     Connection connection = null;
     CommonMetrics.INSTANCE.markDBConnection();
-    long startMs = System.currentTimeMillis();
+    final long startMs = System.currentTimeMillis();
     try {
-      connection = dataSource.getConnection();
+      connection = this.dataSource.getConnection();
       connection.setAutoCommit(autoCommit);
-    } catch (Exception e) {
+    } catch (final Exception e) {
       DbUtils.closeQuietly(connection);
       throw new IOException("Error getting DB connection.", e);
     }
@@ -77,10 +48,38 @@ public abstract class AbstractJdbcLoader {
   }
 
   protected QueryRunner createQueryRunner() {
-    return new QueryRunner(dataSource);
+    return new QueryRunner(this.dataSource);
   }
 
   protected boolean allowsOnDuplicateKey() {
-    return dataSource.allowsOnDuplicateKey();
+    return this.dataSource.allowsOnDuplicateKey();
+  }
+
+  /**
+   * Used for when we store text data. Plain uses UTF8 encoding.
+   */
+  public enum EncodingType {
+    PLAIN(1), GZIP(2);
+
+    private final int numVal;
+
+    EncodingType(final int numVal) {
+      this.numVal = numVal;
+    }
+
+    public static EncodingType fromInteger(final int x) {
+      switch (x) {
+        case 1:
+          return PLAIN;
+        case 2:
+          return GZIP;
+        default:
+          return PLAIN;
+      }
+    }
+
+    public int getNumVal() {
+      return this.numVal;
+    }
   }
 }
diff --git a/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseSetup.java b/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseSetup.java
index 5038df7..dab3002 100644
--- a/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseSetup.java
+++ b/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseSetup.java
@@ -16,6 +16,9 @@
 
 package azkaban.database;
 
+import azkaban.database.DataSourceUtils.PropertyType;
+import azkaban.utils.FileIOUtils;
+import azkaban.utils.Props;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -30,26 +33,21 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.commons.dbutils.DbUtils;
 import org.apache.commons.dbutils.QueryRunner;
 import org.apache.commons.dbutils.ResultSetHandler;
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 
-import azkaban.database.DataSourceUtils.PropertyType;
-import azkaban.utils.FileIOUtils;
-import azkaban.utils.Props;
-
 public class AzkabanDatabaseSetup {
-  private static final Logger logger = Logger
-      .getLogger(AzkabanDatabaseSetup.class);
+
   public static final String DATABASE_CHECK_VERSION = "database.check.version";
   public static final String DATABASE_AUTO_UPDATE_TABLES =
       "database.auto.update.tables";
   public static final String DATABASE_SQL_SCRIPT_DIR =
       "database.sql.scripts.dir";
-
+  private static final Logger logger = Logger
+      .getLogger(AzkabanDatabaseSetup.class);
   private static final String DEFAULT_SCRIPT_PATH = "sql";
   private static final String CREATE_SCRIPT_PREFIX = "create.";
   private static final String UPDATE_SCRIPT_PREFIX = "update.";
@@ -62,7 +60,7 @@ public class AzkabanDatabaseSetup {
   private static final String UPDATE_DB_PROPERTY =
       "UPDATE properties SET value=?,modified_time=? WHERE name=? AND type=?";
 
-  private AzkabanDataSource dataSource;
+  private final AzkabanDataSource dataSource;
   private Map<String, String> tables;
   private Map<String, String> installedVersions;
   private Set<String> missingTables;
@@ -72,54 +70,54 @@ public class AzkabanDatabaseSetup {
 
   private String scriptPath = null;
 
-  public AzkabanDatabaseSetup(Props props) {
+  public AzkabanDatabaseSetup(final Props props) {
     this(DataSourceUtils.getDataSource(props));
     this.scriptPath =
         props.getString(DATABASE_SQL_SCRIPT_DIR, DEFAULT_SCRIPT_PATH);
   }
 
-  public AzkabanDatabaseSetup(AzkabanDataSource ds) {
+  public AzkabanDatabaseSetup(final AzkabanDataSource ds) {
     this.dataSource = ds;
-    if (scriptPath == null) {
-      scriptPath = DEFAULT_SCRIPT_PATH;
+    if (this.scriptPath == null) {
+      this.scriptPath = DEFAULT_SCRIPT_PATH;
     }
   }
 
   // TODO kunkun-tang: Refactor this class. loadTableInfo method should sit inside constructor
-  public AzkabanDatabaseSetup(AzkabanDataSource ds, Props props) {
+  public AzkabanDatabaseSetup(final AzkabanDataSource ds, final Props props) {
     this.dataSource = ds;
     this.scriptPath = props.getString(DATABASE_SQL_SCRIPT_DIR, DEFAULT_SCRIPT_PATH);
   }
 
   public void loadTableInfo() throws IOException, SQLException {
-    tables = new HashMap<>();
-    installedVersions = new HashMap<>();
-    missingTables = new HashSet<>();
-    upgradeList = new HashMap<>();
+    this.tables = new HashMap<>();
+    this.installedVersions = new HashMap<>();
+    this.missingTables = new HashSet<>();
+    this.upgradeList = new HashMap<>();
 
-    Props dbProps = loadDBProps();
-    version = dbProps.getString("version");
+    final Props dbProps = loadDBProps();
+    this.version = dbProps.getString("version");
 
     loadInstalledTables();
     loadTableVersion();
     findMissingTables();
     findOutOfDateTables();
 
-    needsUpdating = !upgradeList.isEmpty() || !missingTables.isEmpty();
+    this.needsUpdating = !this.upgradeList.isEmpty() || !this.missingTables.isEmpty();
   }
 
   public boolean needsUpdating() {
-    if (version == null) {
+    if (this.version == null) {
       throw new RuntimeException("Uninitialized. Call loadTableInfo first.");
     }
 
-    return needsUpdating;
+    return this.needsUpdating;
   }
 
   public void printUpgradePlan() {
-    if (!tables.isEmpty()) {
+    if (!this.tables.isEmpty()) {
       logger.info("The following are installed tables");
-      for (Map.Entry<String, String> installedTable : tables.entrySet()) {
+      for (final Map.Entry<String, String> installedTable : this.tables.entrySet()) {
         logger.info(" " + installedTable.getKey() + " version:"
             + installedTable.getValue());
       }
@@ -127,21 +125,21 @@ public class AzkabanDatabaseSetup {
       logger.info("No installed tables found.");
     }
 
-    if (!missingTables.isEmpty()) {
+    if (!this.missingTables.isEmpty()) {
       logger.info("The following are missing tables that need to be installed");
-      for (String table : missingTables) {
+      for (final String table : this.missingTables) {
         logger.info(" " + table);
       }
     } else {
       logger.info("There are no missing tables.");
     }
 
-    if (!upgradeList.isEmpty()) {
+    if (!this.upgradeList.isEmpty()) {
       logger.info("The following tables need to be updated.");
-      for (Map.Entry<String, List<String>> upgradeTable : upgradeList
+      for (final Map.Entry<String, List<String>> upgradeTable : this.upgradeList
           .entrySet()) {
         String tableInfo = " " + upgradeTable.getKey() + " versions:";
-        for (String upVersion : upgradeTable.getValue()) {
+        for (final String upVersion : upgradeTable.getValue()) {
           tableInfo += upVersion + ",";
         }
 
@@ -152,7 +150,7 @@ public class AzkabanDatabaseSetup {
     }
   }
 
-  public void updateDatabase(boolean createTable, boolean updateTable)
+  public void updateDatabase(final boolean createTable, final boolean updateTable)
       throws SQLException, IOException {
     // We call this because it has an unitialize check.
     if (!needsUpdating()) {
@@ -160,19 +158,20 @@ public class AzkabanDatabaseSetup {
       return;
     }
 
-    if (createTable && !missingTables.isEmpty()) {
+    if (createTable && !this.missingTables.isEmpty()) {
       createNewTables();
     }
-    if (updateTable && !upgradeList.isEmpty()) {
+    if (updateTable && !this.upgradeList.isEmpty()) {
       updateTables();
     }
   }
 
   private Props loadDBProps() throws IOException {
-    File dbPropsFile = new File(this.scriptPath, "database.properties");
+    final File dbPropsFile = new File(this.scriptPath, "database.properties");
 
     if (!dbPropsFile.exists()) {
-      throw new IOException("Cannot find 'database.properties' file in " + dbPropsFile.getAbsolutePath());
+      throw new IOException(
+          "Cannot find 'database.properties' file in " + dbPropsFile.getAbsolutePath());
     }
 
     return new Props(null, dbPropsFile);
@@ -180,20 +179,20 @@ public class AzkabanDatabaseSetup {
 
   private void loadTableVersion() throws SQLException {
     logger.info("Searching for table versions in the properties table");
-    if (tables.containsKey("properties")) {
+    if (this.tables.containsKey("properties")) {
       // Load version from settings
-      QueryRunner runner = new QueryRunner(dataSource);
-      Map<String, String> map =
+      final QueryRunner runner = new QueryRunner(this.dataSource);
+      final Map<String, String> map =
           runner.query(FETCH_PROPERTY_BY_TYPE, new PropertiesHandler(),
               PropertyType.DB.getNumVal());
-      for (String key : map.keySet()) {
-        String value = map.get(key);
+      for (final String key : map.keySet()) {
+        final String value = map.get(key);
         if (key.endsWith(".version")) {
-          String tableName =
+          final String tableName =
               key.substring(0, key.length() - ".version".length());
-          installedVersions.put(tableName, value);
-          if (tables.containsKey(tableName)) {
-            tables.put(tableName, value);
+          this.installedVersions.put(tableName, value);
+          if (this.tables.containsKey(tableName)) {
+            this.tables.put(tableName, value);
           }
         }
       }
@@ -206,13 +205,13 @@ public class AzkabanDatabaseSetup {
     logger.info("Searching for installed tables");
     Connection conn = null;
     try {
-      conn = dataSource.getConnection();
-      ResultSet rs =
+      conn = this.dataSource.getConnection();
+      final ResultSet rs =
           conn.getMetaData().getTables(conn.getCatalog(), null, null,
-              new String[] { "TABLE" });
+              new String[]{"TABLE"});
 
       while (rs.next()) {
-        tables.put(rs.getString("TABLE_NAME").toLowerCase(), "2.1");
+        this.tables.put(rs.getString("TABLE_NAME").toLowerCase(), "2.1");
       }
     } finally {
       DbUtils.commitAndCloseQuietly(conn);
@@ -220,63 +219,63 @@ public class AzkabanDatabaseSetup {
   }
 
   private void findMissingTables() {
-    File directory = new File(scriptPath);
-    File[] createScripts =
+    final File directory = new File(this.scriptPath);
+    final File[] createScripts =
         directory.listFiles(new FileIOUtils.PrefixSuffixFileFilter(
             CREATE_SCRIPT_PREFIX, SQL_SCRIPT_SUFFIX));
-    if(createScripts != null) {
-      for (File script : createScripts) {
-        String name = script.getName();
-        String[] nameSplit = name.split("\\.");
-        String tableName = nameSplit[1];
-
-        if (!tables.containsKey(tableName)) {
-          missingTables.add(tableName);
+    if (createScripts != null) {
+      for (final File script : createScripts) {
+        final String name = script.getName();
+        final String[] nameSplit = name.split("\\.");
+        final String tableName = nameSplit[1];
+
+        if (!this.tables.containsKey(tableName)) {
+          this.missingTables.add(tableName);
         }
       }
     }
   }
 
   private void findOutOfDateTables() {
-    for (String key : tables.keySet()) {
-      String version = tables.get(key);
+    for (final String key : this.tables.keySet()) {
+      final String version = this.tables.get(key);
 
-      List<String> upgradeVersions = findOutOfDateTable(key, version);
+      final List<String> upgradeVersions = findOutOfDateTable(key, version);
       if (upgradeVersions != null && !upgradeVersions.isEmpty()) {
-        upgradeList.put(key, upgradeVersions);
+        this.upgradeList.put(key, upgradeVersions);
       }
     }
-    for (String key : missingTables) {
-      List<String> upgradeVersions = findOutOfDateTable(key, "");
+    for (final String key : this.missingTables) {
+      final List<String> upgradeVersions = findOutOfDateTable(key, "");
       if (upgradeVersions != null && !upgradeVersions.isEmpty()) {
-        upgradeList.put(key, upgradeVersions);
+        this.upgradeList.put(key, upgradeVersions);
       }
     }
   }
 
-  private List<String> findOutOfDateTable(String table, String currentVersion) {
-    File directory = new File(scriptPath);
-    ArrayList<String> versions = new ArrayList<String>();
+  private List<String> findOutOfDateTable(final String table, final String currentVersion) {
+    final File directory = new File(this.scriptPath);
+    final ArrayList<String> versions = new ArrayList<>();
 
-    File[] createScripts =
+    final File[] createScripts =
         directory.listFiles(new FileIOUtils.PrefixSuffixFileFilter(
             UPDATE_SCRIPT_PREFIX + table, SQL_SCRIPT_SUFFIX));
     if (createScripts == null || createScripts.length == 0) {
       return null;
     }
 
-    String updateFileNameVersion = UPDATE_SCRIPT_PREFIX + table + "." + currentVersion;
-    for (File file : createScripts) {
-      String fileName = file.getName();
+    final String updateFileNameVersion = UPDATE_SCRIPT_PREFIX + table + "." + currentVersion;
+    for (final File file : createScripts) {
+      final String fileName = file.getName();
       if (fileName.compareTo(updateFileNameVersion) > 0) {
-        String[] split = fileName.split("\\.");
+        final String[] split = fileName.split("\\.");
         String updateScriptVersion = "";
 
         for (int i = 2; i < split.length - 1; ++i) {
           try {
             Integer.parseInt(split[i]);
             updateScriptVersion += split[i] + ".";
-          } catch (NumberFormatException e) {
+          } catch (final NumberFormatException e) {
             break;
           }
         }
@@ -286,7 +285,7 @@ public class AzkabanDatabaseSetup {
           // add to update list if updateScript will update above current
           // version and upto targetVersion in database.properties
           if (updateScriptVersion.compareTo(currentVersion) > 0
-            && updateScriptVersion.compareTo(this.version) <= 0) {
+              && updateScriptVersion.compareTo(this.version) <= 0) {
             versions.add(updateScriptVersion);
           }
         }
@@ -298,19 +297,19 @@ public class AzkabanDatabaseSetup {
   }
 
   private void createNewTables() throws SQLException, IOException {
-    Connection conn = dataSource.getConnection();
+    final Connection conn = this.dataSource.getConnection();
     conn.setAutoCommit(false);
     try {
       // Make sure that properties table is created first.
-      if (missingTables.contains("properties")) {
-        runTableScripts(conn, "properties", version, dataSource.getDBType(),
+      if (this.missingTables.contains("properties")) {
+        runTableScripts(conn, "properties", this.version, this.dataSource.getDBType(),
             false);
       }
-      for (String table : missingTables) {
+      for (final String table : this.missingTables) {
         if (!table.equals("properties")) {
-          runTableScripts(conn, table, version, dataSource.getDBType(), false);
+          runTableScripts(conn, table, this.version, this.dataSource.getDBType(), false);
           // update version as we have create a new table
-          installedVersions.put(table, version);
+          this.installedVersions.put(table, this.version);
         }
       }
     } finally {
@@ -319,20 +318,20 @@ public class AzkabanDatabaseSetup {
   }
 
   private void updateTables() throws SQLException, IOException {
-    Connection conn = dataSource.getConnection();
+    final Connection conn = this.dataSource.getConnection();
     conn.setAutoCommit(false);
     try {
       // Make sure that properties table is created first.
-      if (upgradeList.containsKey("properties")) {
-        for (String version : upgradeList.get("properties")) {
-          runTableScripts(conn, "properties", version, dataSource.getDBType(),
+      if (this.upgradeList.containsKey("properties")) {
+        for (final String version : this.upgradeList.get("properties")) {
+          runTableScripts(conn, "properties", version, this.dataSource.getDBType(),
               true);
         }
       }
-      for (String table : upgradeList.keySet()) {
+      for (final String table : this.upgradeList.keySet()) {
         if (!table.equals("properties")) {
-          for (String version : upgradeList.get(table)) {
-            runTableScripts(conn, table, version, dataSource.getDBType(), true);
+          for (final String version : this.upgradeList.get(table)) {
+            runTableScripts(conn, table, version, this.dataSource.getDBType(), true);
           }
         }
       }
@@ -341,8 +340,8 @@ public class AzkabanDatabaseSetup {
     }
   }
 
-  private void runTableScripts(Connection conn, String table, String version,
-      String dbType, boolean update) throws IOException, SQLException {
+  private void runTableScripts(final Connection conn, final String table, final String version,
+      final String dbType, final boolean update) throws IOException, SQLException {
     String scriptName = "";
     if (update) {
       scriptName = "update." + table + "." + version;
@@ -352,12 +351,12 @@ public class AzkabanDatabaseSetup {
       logger.info("Creating new table " + table + " version " + version);
     }
 
-    String dbSpecificScript = scriptName + "." + dbType + ".sql";
+    final String dbSpecificScript = scriptName + "." + dbType + ".sql";
 
-    File script = new File(scriptPath, dbSpecificScript);
+    File script = new File(this.scriptPath, dbSpecificScript);
     if (!script.exists()) {
-      String dbScript = scriptName + ".sql";
-      script = new File(scriptPath, dbScript);
+      final String dbScript = scriptName + ".sql";
+      script = new File(this.scriptPath, dbScript);
 
       if (!script.exists()) {
         throw new IOException("Creation files do not exist for table " + table);
@@ -367,13 +366,13 @@ public class AzkabanDatabaseSetup {
     BufferedInputStream buff = null;
     try {
       buff = new BufferedInputStream(new FileInputStream(script));
-      String queryStr = IOUtils.toString(buff);
+      final String queryStr = IOUtils.toString(buff);
 
-      String[] splitQuery = queryStr.split(";\\s*\n");
+      final String[] splitQuery = queryStr.split(";\\s*\n");
 
-      QueryRunner runner = new QueryRunner();
+      final QueryRunner runner = new QueryRunner();
 
-      for (String query : splitQuery) {
+      for (final String query : splitQuery) {
         runner.update(conn, query);
       }
 
@@ -383,8 +382,8 @@ public class AzkabanDatabaseSetup {
         conn.commit();
       }
 
-      String propertyName = table + ".version";
-      if (!installedVersions.containsKey(table)) {
+      final String propertyName = table + ".version";
+      if (!this.installedVersions.containsKey(table)) {
         runner.update(conn, INSERT_DB_PROPERTY, propertyName,
             DataSourceUtils.PropertyType.DB.getNumVal(), version,
             System.currentTimeMillis());
@@ -401,12 +400,13 @@ public class AzkabanDatabaseSetup {
 
   public static class PropertiesHandler implements
       ResultSetHandler<Map<String, String>> {
+
     @Override
-    public Map<String, String> handle(ResultSet rs) throws SQLException {
-      Map<String, String> results = new HashMap<>();
+    public Map<String, String> handle(final ResultSet rs) throws SQLException {
+      final Map<String, String> results = new HashMap<>();
       while (rs.next()) {
-        String key = rs.getString(1);
-        String value = rs.getString(2);
+        final String key = rs.getString(1);
+        final String value = rs.getString(2);
         results.put(key, value);
       }
 
diff --git a/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseUpdater.java b/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseUpdater.java
index c506d3f..f492283 100644
--- a/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseUpdater.java
+++ b/azkaban-common/src/main/java/azkaban/database/AzkabanDatabaseUpdater.java
@@ -16,37 +16,35 @@
 
 package azkaban.database;
 
+import azkaban.server.AzkabanServer;
+import azkaban.utils.Props;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.Arrays;
-
 import joptsimple.OptionParser;
 import joptsimple.OptionSet;
 import joptsimple.OptionSpec;
-
 import org.apache.log4j.Logger;
 
-import azkaban.utils.Props;
-import azkaban.server.AzkabanServer;
-
 public class AzkabanDatabaseUpdater {
+
   private static final Logger logger = Logger
       .getLogger(AzkabanDatabaseUpdater.class);
 
-  public static void main(String[] args) throws Exception {
-    OptionParser parser = new OptionParser();
+  public static void main(final String[] args) throws Exception {
+    final OptionParser parser = new OptionParser();
 
-    OptionSpec<String> scriptDirectory =
+    final OptionSpec<String> scriptDirectory =
         parser
             .acceptsAll(Arrays.asList("s", "script"),
                 "Directory of update scripts.").withRequiredArg()
             .describedAs("script").ofType(String.class);
 
-    OptionSpec<Void> updateOption =
+    final OptionSpec<Void> updateOption =
         parser.acceptsAll(Arrays.asList("u", "update"),
             "Will update if necessary");
 
-    Props props = AzkabanServer.loadProps(args, parser);
+    final Props props = AzkabanServer.loadProps(args, parser);
 
     if (props == null) {
       logger.error("Properties not found. Need it to connect to the db.");
@@ -54,7 +52,7 @@ public class AzkabanDatabaseUpdater {
       return;
     }
 
-    OptionSet options = parser.parse(args);
+    final OptionSet options = parser.parse(args);
     boolean updateDB = false;
     if (options.has(updateOption)) {
       updateDB = true;
@@ -70,8 +68,8 @@ public class AzkabanDatabaseUpdater {
     runDatabaseUpdater(props, scriptDir, updateDB);
   }
 
-  public static void runDatabaseUpdater(Props props, String sqlDir,
-      boolean updateDB) throws IOException, SQLException {
+  public static void runDatabaseUpdater(final Props props, final String sqlDir,
+      final boolean updateDB) throws IOException, SQLException {
     logger.info("Use scripting directory " + sqlDir);
 
     if (updateDB) {
@@ -80,7 +78,7 @@ public class AzkabanDatabaseUpdater {
       logger.info("Running DatabaseUpdater in test mode. Use -u to update");
     }
 
-    AzkabanDatabaseSetup setup = new AzkabanDatabaseSetup(props);
+    final AzkabanDatabaseSetup setup = new AzkabanDatabaseSetup(props);
     setup.loadTableInfo();
     if (!setup.needsUpdating()) {
       logger.info("Everything looks up to date.");
diff --git a/azkaban-common/src/main/java/azkaban/database/AzkabanDataSource.java b/azkaban-common/src/main/java/azkaban/database/AzkabanDataSource.java
index 46a27e6..593df27 100644
--- a/azkaban-common/src/main/java/azkaban/database/AzkabanDataSource.java
+++ b/azkaban-common/src/main/java/azkaban/database/AzkabanDataSource.java
@@ -19,6 +19,7 @@ package azkaban.database;
 import org.apache.commons.dbcp2.BasicDataSource;
 
 public abstract class AzkabanDataSource extends BasicDataSource {
+
   public abstract boolean allowsOnDuplicateKey();
 
   public abstract String getDBType();
diff --git a/azkaban-common/src/main/java/azkaban/database/DataSourceUtils.java b/azkaban-common/src/main/java/azkaban/database/DataSourceUtils.java
index 650a9dc..35f96f3 100644
--- a/azkaban-common/src/main/java/azkaban/database/DataSourceUtils.java
+++ b/azkaban-common/src/main/java/azkaban/database/DataSourceUtils.java
@@ -23,32 +23,12 @@ import org.apache.log4j.Logger;
 
 public class DataSourceUtils {
 
-  private static Logger logger = Logger.getLogger(DataSourceUtils.class);
+  private static final Logger logger = Logger.getLogger(DataSourceUtils.class);
 
   /**
-   * Property types
+   * Hidden datasource
    */
-  public static enum PropertyType {
-    DB(1);
-
-    private final int numVal;
-
-    PropertyType(int numVal) {
-      this.numVal = numVal;
-    }
-
-    public int getNumVal() {
-      return numVal;
-    }
-
-    public static PropertyType fromInteger(int x) {
-      switch (x) {
-      case 1:
-        return DB;
-      default:
-        return DB;
-      }
-    }
+  private DataSourceUtils() {
   }
 
   /**
@@ -57,24 +37,24 @@ public class DataSourceUtils {
    * @param props
    * @return
    */
-  public static AzkabanDataSource getDataSource(Props props) {
-    String databaseType = props.getString("database.type");
+  public static AzkabanDataSource getDataSource(final Props props) {
+    final String databaseType = props.getString("database.type");
 
     AzkabanDataSource dataSource = null;
     if (databaseType.equals("mysql")) {
-      int port = props.getInt("mysql.port");
-      String host = props.getString("mysql.host");
-      String database = props.getString("mysql.database");
-      String user = props.getString("mysql.user");
-      String password = props.getString("mysql.password");
-      int numConnections = props.getInt("mysql.numconnections");
+      final int port = props.getInt("mysql.port");
+      final String host = props.getString("mysql.host");
+      final String database = props.getString("mysql.database");
+      final String user = props.getString("mysql.user");
+      final String password = props.getString("mysql.password");
+      final int numConnections = props.getInt("mysql.numconnections");
 
       dataSource =
           getMySQLDataSource(host, port, database, user, password,
               numConnections);
     } else if (databaseType.equals("h2")) {
-      String path = props.getString("h2.path");
-      Path h2DbPath = Paths.get(path).toAbsolutePath();
+      final String path = props.getString("h2.path");
+      final Path h2DbPath = Paths.get(path).toAbsolutePath();
       logger.info("h2 DB path: " + h2DbPath);
       dataSource = getH2DataSource(h2DbPath);
     }
@@ -93,8 +73,8 @@ public class DataSourceUtils {
    * @param numConnections
    * @return
    */
-  public static AzkabanDataSource getMySQLDataSource(String host, Integer port,
-      String dbName, String user, String password, Integer numConnections) {
+  public static AzkabanDataSource getMySQLDataSource(final String host, final Integer port,
+      final String dbName, final String user, final String password, final Integer numConnections) {
     return new MySQLBasicDataSource(host, port, dbName, user, password,
         numConnections);
   }
@@ -105,14 +85,34 @@ public class DataSourceUtils {
    * @param file
    * @return
    */
-  public static AzkabanDataSource getH2DataSource(Path file) {
+  public static AzkabanDataSource getH2DataSource(final Path file) {
     return new EmbeddedH2BasicDataSource(file);
   }
 
   /**
-   * Hidden datasource
+   * Property types
    */
-  private DataSourceUtils() {
+  public static enum PropertyType {
+    DB(1);
+
+    private final int numVal;
+
+    PropertyType(final int numVal) {
+      this.numVal = numVal;
+    }
+
+    public static PropertyType fromInteger(final int x) {
+      switch (x) {
+        case 1:
+          return DB;
+        default:
+          return DB;
+      }
+    }
+
+    public int getNumVal() {
+      return this.numVal;
+    }
   }
 
   /**
@@ -123,17 +123,17 @@ public class DataSourceUtils {
 
     private final String url;
 
-    private MySQLBasicDataSource(String host, int port, String dbName,
-        String user, String password, int numConnections) {
+    private MySQLBasicDataSource(final String host, final int port, final String dbName,
+        final String user, final String password, final int numConnections) {
       super();
 
-      url = "jdbc:mysql://" + (host + ":" + port + "/" + dbName);
+      this.url = "jdbc:mysql://" + (host + ":" + port + "/" + dbName);
       addConnectionProperty("useUnicode", "yes");
       addConnectionProperty("characterEncoding", "UTF-8");
       setDriverClassName("com.mysql.jdbc.Driver");
       setUsername(user);
       setPassword(password);
-      setUrl(url);
+      setUrl(this.url);
       setMaxTotal(numConnections);
       setValidationQuery("/* ping */ select 1");
       setTestOnBorrow(true);
@@ -155,9 +155,10 @@ public class DataSourceUtils {
    *
    */
   public static class EmbeddedH2BasicDataSource extends AzkabanDataSource {
-    private EmbeddedH2BasicDataSource(Path filePath) {
+
+    private EmbeddedH2BasicDataSource(final Path filePath) {
       super();
-      String url = "jdbc:h2:file:" + filePath;
+      final String url = "jdbc:h2:file:" + filePath;
       setDriverClassName("org.h2.Driver");
       setUrl(url);
     }
diff --git a/azkaban-common/src/main/java/azkaban/database/EncodingType.java b/azkaban-common/src/main/java/azkaban/database/EncodingType.java
index ac62ba1..1b17b5d 100644
--- a/azkaban-common/src/main/java/azkaban/database/EncodingType.java
+++ b/azkaban-common/src/main/java/azkaban/database/EncodingType.java
@@ -22,17 +22,13 @@ package azkaban.database;
 public enum EncodingType {
   PLAIN(1), GZIP(2);
 
-  private int numVal;
+  private final int numVal;
 
-  EncodingType(int numVal) {
+  EncodingType(final int numVal) {
     this.numVal = numVal;
   }
 
-  public int getNumVal() {
-    return numVal;
-  }
-
-  public static EncodingType fromInteger(int x) {
+  public static EncodingType fromInteger(final int x) {
     switch (x) {
       case 1:
         return PLAIN;
@@ -42,4 +38,8 @@ public enum EncodingType {
         return PLAIN;
     }
   }
+
+  public int getNumVal() {
+    return this.numVal;
+  }
 }