falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srik...@apache.org
Subject [22/47] git commit: checkstyle fixes for client module
Date Fri, 26 Apr 2013 15:50:38 GMT
checkstyle fixes for client module


Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/e69b2205
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/e69b2205
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/e69b2205

Branch: refs/heads/master
Commit: e69b220564e9d63c52dbaccfdc1fd0765a639a8b
Parents: a4d79f0
Author: srikanth.sundarrajan <srikanth.sundarrajan@inmobi.com>
Authored: Tue Apr 16 22:34:38 2013 +0530
Committer: srikanth.sundarrajan <srikanth.sundarrajan@inmobi.com>
Committed: Tue Apr 16 22:34:38 2013 +0530

----------------------------------------------------------------------
 client/src/main/java/org/apache/falcon/Pair.java   |    6 +-
 client/src/main/java/org/apache/falcon/Tag.java    |    3 +
 .../main/java/org/apache/falcon/cli/FalconCLI.java |   66 ++++----
 .../org/apache/falcon/client/FalconClient.java     |  138 ++++++++-------
 .../org/apache/falcon/entity/v0/DateValidator.java |   18 +--
 .../java/org/apache/falcon/entity/v0/Entity.java   |    8 +-
 .../org/apache/falcon/entity/v0/EntityType.java    |    2 +-
 .../org/apache/falcon/entity/v0/Frequency.java     |   21 ++-
 .../org/apache/falcon/entity/v0/SchemaHelper.java  |    8 +-
 .../java/org/apache/falcon/resource/APIResult.java |   11 +-
 .../org/apache/falcon/resource/EntityList.java     |    6 +
 .../apache/falcon/resource/InstancesResult.java    |   13 ++
 .../java/org/apache/falcon/cli/TestCLIParser.java  |    3 +
 .../apache/falcon/entity/v0/DateValidatorTest.java |   68 ++++----
 .../org/apache/falcon/entity/v0/TestFrequency.java |    3 +
 15 files changed, 213 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/Pair.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/Pair.java b/client/src/main/java/org/apache/falcon/Pair.java
index 300be27..4c60feb 100644
--- a/client/src/main/java/org/apache/falcon/Pair.java
+++ b/client/src/main/java/org/apache/falcon/Pair.java
@@ -18,7 +18,11 @@
 
 package org.apache.falcon;
 
-
+/**
+ * Simple pair class to hold a pair of object of specific class.
+ * @param <A> - First element in pair.
+ * @param <B> - Second element in pair
+ */
 public class Pair<A, B> {
     public final A first;
     public final B second;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/Tag.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/Tag.java b/client/src/main/java/org/apache/falcon/Tag.java
index fc56632..beeb812 100644
--- a/client/src/main/java/org/apache/falcon/Tag.java
+++ b/client/src/main/java/org/apache/falcon/Tag.java
@@ -20,6 +20,9 @@ package org.apache.falcon;
 
 import org.apache.falcon.entity.v0.EntityType;
 
+/**
+ * Tag to include in the entity type.
+ */
 public enum Tag {
     DEFAULT(EntityType.PROCESS), RETENTION(EntityType.FEED), REPLICATION(EntityType.FEED);
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
index 575d7a5..7c60328 100644
--- a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
+++ b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
@@ -95,11 +95,11 @@ public class FalconCLI {
     }
 
     // TODO help and headers
-    private static final String[] FALCON_HELP = {
-            "the env variable '" + FALCON_URL
-                    + "' is used as default value for the '-" + URL_OPTION + "' option",
-            "custom headers for Falcon web services can be specified using '-D"
-                    + FalconClient.WS_HEADER_PREFIX + "NAME=VALUE'"};
+    private static final String[] FALCON_HELP = { "the env variable '" + FALCON_URL
+                                                          + "' is used as default value for
the '-" + URL_OPTION
+                                                          + "' option",
+                                                  "custom headers for Falcon web services
can be specified using '-D"
+                                                          + FalconClient.WS_HEADER_PREFIX
+ "NAME=VALUE'", };
 
     /**
      * Run a CLI programmatically.
@@ -182,8 +182,7 @@ public class FalconCLI {
 
         colo = getColo(colo);
 
-        validateInstanceCommands(optionsList, entity, type, start, end,
-                filePath, colo, clusters, sourceClusters);
+        validateInstanceCommands(optionsList, entity, type, start, colo);
 
         if (optionsList.contains(RUNNING_OPT)) {
             result = client.getRunningInstances(type, entity, colo);
@@ -209,9 +208,9 @@ public class FalconCLI {
         OUT.get().println(result);
     }
 
-    private void validateInstanceCommands(Set<String> optionsList, String entity, String
type,
-                                          String start, String end, String filePath, String
colo,
-                                          String clusters, String sourceClusters) throws
FalconCLIException {
+    private void validateInstanceCommands(Set<String> optionsList,
+                                          String entity, String type,
+                                          String start, String colo) throws FalconCLIException
{
 
         if (entity == null || entity.equals("")) {
             throw new FalconCLIException("Missing argument: name");
@@ -249,7 +248,8 @@ public class FalconCLI {
     }
 
     private void entityCommand(CommandLine commandLine)
-            throws FalconCLIException, IOException {
+        throws FalconCLIException, IOException {
+
         String falconUrl = getFalconEndpoint(commandLine);
         FalconClient client = new FalconClient(falconUrl);
 
@@ -265,52 +265,52 @@ public class FalconCLI {
         String colo = commandLine.getOptionValue(COLO_OPT);
 
 
-        validateEntityType(optionsList, entityType);
+        validateEntityType(entityType);
 
         if (optionsList.contains(SUBMIT_OPT)) {
-            validateFilePath(optionsList, filePath);
+            validateFilePath(filePath);
             validateColo(optionsList);
             result = client.submit(entityType, filePath);
         } else if (optionsList.contains(UPDATE_OPT)) {
-            validateFilePath(optionsList, filePath);
+            validateFilePath(filePath);
             validateColo(optionsList);
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             result = client.update(entityType, entityName, filePath);
         } else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
-            validateFilePath(optionsList, filePath);
+            validateFilePath(filePath);
             validateColo(optionsList);
             result = client.submitAndSchedule(entityType, filePath);
         } else if (optionsList.contains(VALIDATE_OPT)) {
-            validateFilePath(optionsList, filePath);
+            validateFilePath(filePath);
             validateColo(optionsList);
             result = client.validate(entityType, filePath);
         } else if (optionsList.contains(SCHEDULE_OPT)) {
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             colo = getColo(colo);
             result = client.schedule(entityType, entityName, colo);
         } else if (optionsList.contains(SUSPEND_OPT)) {
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             colo = getColo(colo);
             result = client.suspend(entityType, entityName, colo);
         } else if (optionsList.contains(RESUME_OPT)) {
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             colo = getColo(colo);
             result = client.resume(entityType, entityName, colo);
         } else if (optionsList.contains(DELETE_OPT)) {
             validateColo(optionsList);
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             result = client.delete(entityType, entityName);
         } else if (optionsList.contains(STATUS_OPT)) {
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             colo = getColo(colo);
             result = client.getStatus(entityType, entityName, colo);
         } else if (optionsList.contains(DEFINITION_OPT)) {
             validateColo(optionsList);
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             result = client.getDefinition(entityType, entityName);
         } else if (optionsList.contains(DEPENDENCY_OPT)) {
             validateColo(optionsList);
-            validateEntityName(optionsList, entityName);
+            validateEntityName(entityName);
             result = client.getDependency(entityType, entityName);
         } else if (optionsList.contains(LIST_OPT)) {
             validateColo(optionsList);
@@ -331,29 +331,33 @@ public class FalconCLI {
         return colo;
     }
 
-    private void validateFilePath(Set<String> optionsList, String filePath)
-            throws FalconCLIException {
+    private void validateFilePath(String filePath)
+        throws FalconCLIException {
+
         if (filePath == null || filePath.equals("")) {
             throw new FalconCLIException("Missing argument: file");
         }
     }
 
     private void validateColo(Set<String> optionsList)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         if (optionsList.contains(COLO_OPT)) {
             throw new FalconCLIException("Invalid argument : " + COLO_OPT);
         }
     }
 
-    private void validateEntityName(Set<String> optionsList, String entityName)
-            throws FalconCLIException {
+    private void validateEntityName(String entityName)
+        throws FalconCLIException {
+
         if (entityName == null || entityName.equals("")) {
             throw new FalconCLIException("Missing argument: name");
         }
     }
 
-    private void validateEntityType(Set<String> optionsList, String entityType)
-            throws FalconCLIException {
+    private void validateEntityType(String entityType)
+        throws FalconCLIException {
+
         if (entityType == null || entityType.equals("")) {
             throw new FalconCLIException("Missing argument: type");
         }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/client/FalconClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconClient.java b/client/src/main/java/org/apache/falcon/client/FalconClient.java
index bc8efc1..44e9ccd 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconClient.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconClient.java
@@ -31,7 +31,14 @@ import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Properties;
 
 /**
@@ -40,7 +47,6 @@ import java.util.Properties;
  */
 public class FalconClient {
 
-    private String baseUrl;
     protected static WebResource service;
     public static final String WS_HEADER_PREFIX = "header:";
     private static final String REMOTE_USER = "Remote-User";
@@ -55,9 +61,9 @@ public class FalconClient {
      * @throws IOException
      */
     public FalconClient(String falconUrl) throws IOException {
-        this.baseUrl = notEmpty(falconUrl, "FalconUrl");
-        if (!this.baseUrl.endsWith("/")) {
-            this.baseUrl += "/";
+        String baseUrl = notEmpty(falconUrl, "FalconUrl");
+        if (!baseUrl.endsWith("/")) {
+            baseUrl += "/";
         }
         Client client = Client.create(new DefaultClientConfig());
         setFalconTimeOut(client);
@@ -72,8 +78,8 @@ public class FalconClient {
         Properties prop = new Properties();
         InputStream input = FalconClient.class
                 .getResourceAsStream("/client.properties");
-        int readTimeout = 0;
-        int connectTimeout = 0;
+        int readTimeout;
+        int connectTimeout;
         if (input != null) {
             prop.load(input);
             readTimeout = prop.containsKey("falcon.read.timeout") ? Integer
@@ -172,23 +178,8 @@ public class FalconClient {
         return str;
     }
 
-    /**
-     * Check if the object is not null.
-     *
-     * @param <T>
-     * @param obj
-     * @param name
-     * @return string
-     */
-    public static <T> T notNull(T obj, String name) {
-        if (obj == null) {
-            throw new IllegalArgumentException(name + " cannot be null");
-        }
-        return obj;
-    }
-
     public String schedule(String entityType, String entityName, String colo)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendEntityRequest(Entities.SCHEDULE, entityType, entityName,
                 colo);
@@ -196,63 +187,67 @@ public class FalconClient {
     }
 
     public String suspend(String entityType, String entityName, String colo)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendEntityRequest(Entities.SUSPEND, entityType, entityName, colo);
 
     }
 
     public String resume(String entityType, String entityName, String colo)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendEntityRequest(Entities.RESUME, entityType, entityName, colo);
 
     }
 
     public String delete(String entityType, String entityName)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendEntityRequest(Entities.DELETE, entityType, entityName, null);
 
     }
 
     public String validate(String entityType, String filePath)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         InputStream entityStream = getServletInputStream(filePath);
         return sendEntityRequestWithObject(Entities.VALIDATE, entityType,
                 entityStream, null);
     }
 
     public String submit(String entityType, String filePath)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         InputStream entityStream = getServletInputStream(filePath);
         return sendEntityRequestWithObject(Entities.SUBMIT, entityType,
                 entityStream, null);
     }
 
     public String update(String entityType, String entityName, String filePath)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         InputStream entityStream = getServletInputStream(filePath);
         return sendEntityRequestWithNameAndObject(Entities.UPDATE, entityType,
                 entityName, entityStream);
     }
 
     public String submitAndSchedule(String entityType, String filePath)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         InputStream entityStream = getServletInputStream(filePath);
         return sendEntityRequestWithObject(Entities.SUBMITandSCHEDULE,
                 entityType, entityStream, null);
     }
 
     public String getStatus(String entityType, String entityName, String colo)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendEntityRequest(Entities.STATUS, entityType, entityName, colo);
 
     }
 
     public String getDefinition(String entityType, String entityName)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendDefinitionRequest(Entities.DEFINITION, entityType,
                 entityName);
@@ -260,7 +255,8 @@ public class FalconClient {
     }
 
     public String getDependency(String entityType, String entityName)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         return sendDependencyRequest(Entities.DEPENDENCY, entityType,
                 entityName);
     }
@@ -270,70 +266,78 @@ public class FalconClient {
     }
 
     public String getRunningInstances(String type, String entity, String colo)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return sendInstanceRequest(Instances.RUNNING, type, entity, null, null,
                 null, null, colo);
     }
 
     public String getStatusOfInstances(String type, String entity,
-                                       String start, String end, String runid, String colo)
-            throws FalconCLIException {
+                                       String start, String end,
+                                       String runid, String colo)
+        throws FalconCLIException {
 
         return sendInstanceRequest(Instances.STATUS, type, entity, start, end,
                 null, null, colo);
     }
 
     public String killInstances(String type, String entity, String start,
-                                String end, String colo, String clusters, String sourceClusters)
-            throws FalconCLIException, UnsupportedEncodingException {
+                                String end, String colo, String clusters,
+                                String sourceClusters)
+        throws FalconCLIException, UnsupportedEncodingException {
 
         return sendInstanceRequest(Instances.KILL, type, entity, start, end,
                 getServletInputStream(clusters, sourceClusters, null), null, colo);
     }
 
     public String suspendInstances(String type, String entity, String start,
-                                   String end, String colo, String clusters, String sourceClusters)
-            throws FalconCLIException, UnsupportedEncodingException {
+                                   String end, String colo, String clusters,
+                                   String sourceClusters)
+        throws FalconCLIException, UnsupportedEncodingException {
 
         return sendInstanceRequest(Instances.SUSPEND, type, entity, start, end,
                 getServletInputStream(clusters, sourceClusters, null), null, colo);
     }
 
     public String resumeInstances(String type, String entity, String start,
-                                  String end, String colo, String clusters, String sourceClusters)
-            throws FalconCLIException, UnsupportedEncodingException {
+                                  String end, String colo, String clusters,
+                                  String sourceClusters)
+        throws FalconCLIException, UnsupportedEncodingException {
 
         return sendInstanceRequest(Instances.RESUME, type, entity, start, end,
                 getServletInputStream(clusters, sourceClusters, null), null, colo);
     }
 
     public String rerunInstances(String type, String entity, String start,
-                                 String end, String filePath, String colo, String clusters,
-                                 String sourceClusters) throws FalconCLIException, IOException
{
-        StringBuffer sb = new StringBuffer();
+                                 String end, String filePath, String colo,
+                                 String clusters, String sourceClusters)
+        throws FalconCLIException, IOException {
+
+        StringBuilder buffer = new StringBuilder();
         if (filePath != null) {
             BufferedReader in = new BufferedReader(new FileReader(filePath));
             String str;
             while ((str = in.readLine()) != null) {
-                sb.append(str).append("\n");
+                buffer.append(str).append("\n");
             }
             in.close();
         }
-        String temp = (sb.length() == 0) ? null : sb.toString();
+        String temp = (buffer.length() == 0) ? null : buffer.toString();
         return sendInstanceRequest(Instances.RERUN, type, entity, start, end,
                 getServletInputStream(clusters, sourceClusters, temp), null, colo);
     }
 
     public String rerunInstances(String type, String entity, String start,
                                  String end, String colo, String clusters, String sourceClusters)
-            throws FalconCLIException, UnsupportedEncodingException {
+        throws FalconCLIException, UnsupportedEncodingException {
+
         return sendInstanceRequest(Instances.RERUN, type, entity, start, end,
                 getServletInputStream(clusters, sourceClusters, "oozie.wf.rerun.failnodes=true\n"),
null, colo);
     }
 
     public String getLogsOfInstances(String type, String entity, String start,
-                                     String end, String colo, String runId) throws FalconCLIException
{
+                                     String end, String colo, String runId)
+        throws FalconCLIException {
 
         return sendInstanceRequest(Instances.LOG, type, entity, start, end,
                 null, runId, colo);
@@ -350,44 +354,42 @@ public class FalconClient {
     /**
      * Converts a InputStream into ServletInputStream.
      *
-     * @param filePath
+     * @param filePath - Path of file to stream
      * @return ServletInputStream
      * @throws FalconCLIException
-     * @throws java.io.IOException
      */
     private InputStream getServletInputStream(String filePath)
-            throws FalconCLIException {
+        throws FalconCLIException {
+
         if (filePath == null) {
             return null;
         }
-        InputStream stream = null;
+        InputStream stream;
         try {
             stream = new FileInputStream(filePath);
         } catch (FileNotFoundException e) {
             throw new FalconCLIException("File not found:", e);
-        } catch (IOException e) {
-            throw new FalconCLIException("Unable to read file: ", e);
         }
         return stream;
     }
 
     private InputStream getServletInputStream(String clusters,
-                                              String sourceClusters, String properties) throws
FalconCLIException,
-                                                                                        
      UnsupportedEncodingException {
+                                              String sourceClusters, String properties)
+        throws FalconCLIException, UnsupportedEncodingException {
 
-        InputStream stream = null;
-        StringBuffer sb = new StringBuffer();
+        InputStream stream;
+        StringBuilder buffer = new StringBuilder();
         if (clusters != null) {
-            sb.append(FALCON_INSTANCE_ACTION_CLUSTERS + "=" + clusters + "\n");
+            buffer.append(FALCON_INSTANCE_ACTION_CLUSTERS).append('=').append(clusters).append('\n');
         }
         if (sourceClusters != null) {
-            sb.append(FALCON_INSTANCE_SOURCE_CLUSTERS + "=" + sourceClusters + "\n");
+            buffer.append(FALCON_INSTANCE_SOURCE_CLUSTERS).append('=').append(sourceClusters).append('\n');
         }
         if (properties != null) {
-            sb.append(properties);
+            buffer.append(properties);
         }
-        stream = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
-        return (sb.length() == 0) ? null : stream;
+        stream = new ByteArrayInputStream(buffer.toString().getBytes("UTF-8"));
+        return (buffer.length() == 0) ? null : stream;
     }
     // private ServletInputStream getServletInputStream(final InputStream
     // stream)
@@ -538,7 +540,7 @@ public class FalconClient {
     }
 
     private String sendAdminRequest(AdminOperations job)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         ClientResponse clientResponse = service.path(job.path)
                 .header(REMOTE_USER, USER).accept(job.mimeType)
@@ -547,14 +549,14 @@ public class FalconClient {
     }
 
     private String parseAPIResult(ClientResponse clientResponse)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         APIResult result = clientResponse.getEntity(APIResult.class);
         return result.getMessage();
     }
 
     private String parseEntityList(ClientResponse clientResponse)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         EntityList result = clientResponse.getEntity(EntityList.class);
         if (result == null || result.getElements() == null) {
@@ -565,7 +567,7 @@ public class FalconClient {
     }
 
     private String parseStringResult(ClientResponse clientResponse)
-            throws FalconCLIException {
+        throws FalconCLIException {
 
         return clientResponse.getEntity(String.class);
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/entity/v0/DateValidator.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/entity/v0/DateValidator.java b/client/src/main/java/org/apache/falcon/entity/v0/DateValidator.java
index cde7792..e9cdd87 100644
--- a/client/src/main/java/org/apache/falcon/entity/v0/DateValidator.java
+++ b/client/src/main/java/org/apache/falcon/entity/v0/DateValidator.java
@@ -23,11 +23,11 @@ import java.util.regex.Pattern;
 /**
  * Date utility class.
  */
-public class DateValidator {
+public final class DateValidator {
 
     private static final String DATE_PATTERN =
             "(2\\d\\d\\d|19\\d\\d)-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])T([0-1][0-9]|2[0-3]):([0-5][0-9])Z";
-    private static final Pattern pattern = Pattern.compile(DATE_PATTERN);
+    private static final Pattern PATTERN = Pattern.compile(DATE_PATTERN);
 
     private DateValidator() {
     }
@@ -40,7 +40,7 @@ public class DateValidator {
      */
     public static boolean validate(final String date) {
 
-        Matcher matcher = pattern.matcher(date);
+        Matcher matcher = PATTERN.matcher(date);
 
         if (matcher.matches()) {
 
@@ -60,17 +60,9 @@ public class DateValidator {
                 } else if (month.equals("2") || month.equals("02")) {
                     // leap year
                     if (year % 4 == 0) {
-                        if (day.equals("30") || day.equals("31")) {
-                            return false;
-                        } else {
-                            return true;
-                        }
+                        return !(day.equals("30") || day.equals("31"));
                     } else {
-                        if (day.equals("29") || day.equals("30") || day.equals("31")) {
-                            return false;
-                        } else {
-                            return true;
-                        }
+                        return !(day.equals("29") || day.equals("30") || day.equals("31"));
                     }
                 } else {
                     return true;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/entity/v0/Entity.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/entity/v0/Entity.java b/client/src/main/java/org/apache/falcon/entity/v0/Entity.java
index 9fb926d..8759976 100644
--- a/client/src/main/java/org/apache/falcon/entity/v0/Entity.java
+++ b/client/src/main/java/org/apache/falcon/entity/v0/Entity.java
@@ -23,7 +23,10 @@ import javax.xml.bind.Unmarshaller;
 import java.io.StringReader;
 import java.io.StringWriter;
 
-public abstract class Entity {
+/**
+ * Base class that all entity jaxb object will extend.
+ */
+public abstract class Entity implements Cloneable{
     public abstract String getName();
 
     public EntityType getEntityType() {
@@ -86,7 +89,8 @@ public abstract class Entity {
     }
 
     @Override
-    public Entity clone() {
+    public Entity clone() throws CloneNotSupportedException {
+        Object ignore = super.clone();
         return fromString(getEntityType(), toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/entity/v0/EntityType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/entity/v0/EntityType.java b/client/src/main/java/org/apache/falcon/entity/v0/EntityType.java
index d33bdf0..758308e 100644
--- a/client/src/main/java/org/apache/falcon/entity/v0/EntityType.java
+++ b/client/src/main/java/org/apache/falcon/entity/v0/EntityType.java
@@ -27,7 +27,7 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
 /**
- * Enum for types of entities in Falcon Process, Feed and Cluster
+ * Enum for types of entities in Falcon Process, Feed and Cluster.
  */
 public enum EntityType {
     FEED(Feed.class, "/feed-0.1.xsd", "name"),

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/entity/v0/Frequency.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/entity/v0/Frequency.java b/client/src/main/java/org/apache/falcon/entity/v0/Frequency.java
index 0d1be26..911073a 100644
--- a/client/src/main/java/org/apache/falcon/entity/v0/Frequency.java
+++ b/client/src/main/java/org/apache/falcon/entity/v0/Frequency.java
@@ -22,10 +22,15 @@ import java.util.Calendar;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-
+/**
+ * Frequency as supported in the xsd definitions.
+ */
 public class Frequency {
     private static final Pattern PATTERN = Pattern.compile("(minutes|hours|days|months)\\((\\d+)\\)");
 
+    /**
+     * TimeUnit corresponding to the frequency.
+     */
     public static enum TimeUnit {
         minutes(Calendar.MINUTE), hours(Calendar.HOUR), days(Calendar.DATE), months(Calendar.MONTH);
 
@@ -90,11 +95,15 @@ public class Frequency {
         }
 
         Frequency freq = (Frequency) obj;
-        if (this == freq) {
-            return true;
-        }
+        return this == freq || this.getFrequency() == freq.getFrequency()
+                && this.getTimeUnit() == freq.getTimeUnit();
 
-        return this.getFrequency() == freq.getFrequency() &&
-                this.getTimeUnit() == freq.getTimeUnit();
+    }
+
+    @Override
+    public int hashCode() {
+        int result = timeUnit.hashCode();
+        result = 31 * result + frequency;
+        return result;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/entity/v0/SchemaHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/entity/v0/SchemaHelper.java b/client/src/main/java/org/apache/falcon/entity/v0/SchemaHelper.java
index 9baf827..c6de668 100644
--- a/client/src/main/java/org/apache/falcon/entity/v0/SchemaHelper.java
+++ b/client/src/main/java/org/apache/falcon/entity/v0/SchemaHelper.java
@@ -24,7 +24,13 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.TimeZone;
 
-public class SchemaHelper {
+/**
+ * Support function to parse and format date in xsd string.
+ */
+public final class SchemaHelper {
+
+    private SchemaHelper() {}
+
     public static String getTimeZoneId(TimeZone tz) {
         return tz.getID();
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/resource/APIResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/APIResult.java b/client/src/main/java/org/apache/falcon/resource/APIResult.java
index 7b138bc..2f1420d 100644
--- a/client/src/main/java/org/apache/falcon/resource/APIResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/APIResult.java
@@ -31,7 +31,7 @@ import java.util.UUID;
 
 /**
  * APIResult is the output returned by all the APIs; status-SUCCEEDED or FAILED
- * message- detailed message
+ * message- detailed message.
  */
 @XmlRootElement(name = "result")
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -43,16 +43,19 @@ public class APIResult {
 
     private String requestId;
 
-    private static final JAXBContext jc;
+    private static final JAXBContext JAXB_CONTEXT;
 
     static {
         try {
-            jc = JAXBContext.newInstance(APIResult.class);
+            JAXB_CONTEXT = JAXBContext.newInstance(APIResult.class);
         } catch (JAXBException e) {
             throw new RuntimeException(e);
         }
     }
 
+    /**
+     * API Result status.
+     */
     public static enum Status {
         SUCCEEDED, PARTIAL, FAILED
     }
@@ -93,7 +96,7 @@ public class APIResult {
     public String toString() {
         try {
             StringWriter stringWriter = new StringWriter();
-            Marshaller marshaller = jc.createMarshaller();
+            Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
             marshaller.marshal(this, stringWriter);
             return stringWriter.toString();
         } catch (JAXBException e) {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/resource/EntityList.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/EntityList.java b/client/src/main/java/org/apache/falcon/resource/EntityList.java
index 24771cc..61110b2 100644
--- a/client/src/main/java/org/apache/falcon/resource/EntityList.java
+++ b/client/src/main/java/org/apache/falcon/resource/EntityList.java
@@ -25,6 +25,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+/**
+ * Entity list used for marshalling / unmarshalling with REST calls.
+ */
 @XmlRootElement(name = "entities")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class EntityList {
@@ -32,6 +35,9 @@ public class EntityList {
     @XmlElement(name = "entity")
     private EntityElement[] elements;
 
+    /**
+     * Element within an entity.
+     */
     public static class EntityElement {
         @XmlElement
         public String type;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/InstancesResult.java b/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
index f790df1..cc737a5 100644
--- a/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
@@ -22,8 +22,15 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import java.util.Date;
 
+/**
+ * Pojo for JAXB marshalling / unmarshalling.
+ */
 @XmlRootElement
 public class InstancesResult extends APIResult {
+
+    /**
+     * Workflow status as being set in result object.
+     */
     public static enum WorkflowStatus {
         WAITING, RUNNING, SUSPENDED, KILLED, FAILED, SUCCEEDED, ERROR
     }
@@ -58,6 +65,9 @@ public class InstancesResult extends APIResult {
         this.instances = instances;
     }
 
+    /**
+     * A single instance object inside instance result.
+     */
     @XmlRootElement(name = "instance")
     public static class Instance {
         @XmlElement
@@ -147,6 +157,9 @@ public class InstancesResult extends APIResult {
         }
     }
 
+    /**
+     * Instance action inside an instance object.
+     */
     @XmlRootElement(name = "actions")
     public static class InstanceAction {
         @XmlElement

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/test/java/org/apache/falcon/cli/TestCLIParser.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/falcon/cli/TestCLIParser.java b/client/src/test/java/org/apache/falcon/cli/TestCLIParser.java
index a52da32..6ac3e9f 100644
--- a/client/src/test/java/org/apache/falcon/cli/TestCLIParser.java
+++ b/client/src/test/java/org/apache/falcon/cli/TestCLIParser.java
@@ -24,6 +24,9 @@ import org.apache.commons.cli.ParseException;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+/**
+ * Command parser for CLI.
+ */
 public class TestCLIParser {
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/test/java/org/apache/falcon/entity/v0/DateValidatorTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/falcon/entity/v0/DateValidatorTest.java b/client/src/test/java/org/apache/falcon/entity/v0/DateValidatorTest.java
index fc81896..e288b39 100644
--- a/client/src/test/java/org/apache/falcon/entity/v0/DateValidatorTest.java
+++ b/client/src/test/java/org/apache/falcon/entity/v0/DateValidatorTest.java
@@ -23,58 +23,58 @@ import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
- * Date format yyyy/mm/dd validator Testing
+ * Date format yyyy/mm/dd validator Testing.
  */
 public class DateValidatorTest {
 
     @DataProvider
-    public Object[][] ValidDateProvider() {
+    public Object[][] validDateProvider() {
         return new Object[][]{
-                new Object[]{"2011-11-01T00:00Z"}, new Object[]{"2020-01-01T00:00Z"},
-                new Object[]{"2010-01-31T00:59Z"}, new Object[]{"2020-01-31T00:00Z"},
-                new Object[]{"2008-02-29T01:00Z"}, new Object[]{"2008-02-29T00:00Z"},
-                new Object[]{"2009-02-28T01:01Z"}, new Object[]{"2009-02-28T00:00Z"},
-                new Object[]{"2010-03-31T23:00Z"}, new Object[]{"2010-03-31T00:00Z"},
-                new Object[]{"2010-04-30T23:59Z"}, new Object[]{"2010-04-30T00:00Z"},
-                new Object[]{"2010-05-31T23:23Z"}, new Object[]{"2010-05-31T00:00Z"},
-                new Object[]{"2010-06-30T00:00Z"}, new Object[]{"2010-06-30T00:00Z"},
-                new Object[]{"2010-07-31T00:00Z"}, new Object[]{"2010-07-31T00:00Z"},
-                new Object[]{"2010-08-31T00:00Z"}, new Object[]{"2010-08-31T00:00Z"},
-                new Object[]{"2010-09-30T00:00Z"}, new Object[]{"2010-09-30T00:00Z"},
-                new Object[]{"2010-10-31T00:00Z"}, new Object[]{"2010-10-31T00:00Z"},
-                new Object[]{"2010-11-30T00:00Z"}, new Object[]{"2010-11-30T00:00Z"},
-                new Object[]{"2010-12-31T00:00Z"}, new Object[]{"2010-12-31T00:00Z"},
-                new Object[]{"1999-01-30T01:00Z"}, new Object[]{"2999-12-31T00:00Z"}
+            new Object[]{"2011-11-01T00:00Z", }, new Object[]{"2020-01-01T00:00Z", },
+            new Object[]{"2010-01-31T00:59Z", }, new Object[]{"2020-01-31T00:00Z", },
+            new Object[]{"2008-02-29T01:00Z", }, new Object[]{"2008-02-29T00:00Z", },
+            new Object[]{"2009-02-28T01:01Z", }, new Object[]{"2009-02-28T00:00Z", },
+            new Object[]{"2010-03-31T23:00Z", }, new Object[]{"2010-03-31T00:00Z", },
+            new Object[]{"2010-04-30T23:59Z", }, new Object[]{"2010-04-30T00:00Z", },
+            new Object[]{"2010-05-31T23:23Z", }, new Object[]{"2010-05-31T00:00Z", },
+            new Object[]{"2010-06-30T00:00Z", }, new Object[]{"2010-06-30T00:00Z", },
+            new Object[]{"2010-07-31T00:00Z", }, new Object[]{"2010-07-31T00:00Z", },
+            new Object[]{"2010-08-31T00:00Z", }, new Object[]{"2010-08-31T00:00Z", },
+            new Object[]{"2010-09-30T00:00Z", }, new Object[]{"2010-09-30T00:00Z", },
+            new Object[]{"2010-10-31T00:00Z", }, new Object[]{"2010-10-31T00:00Z", },
+            new Object[]{"2010-11-30T00:00Z", }, new Object[]{"2010-11-30T00:00Z", },
+            new Object[]{"2010-12-31T00:00Z", }, new Object[]{"2010-12-31T00:00Z", },
+            new Object[]{"1999-01-30T01:00Z", }, new Object[]{"2999-12-31T00:00Z", },
         };
     }
 
     @DataProvider
-    public Object[][] InvalidDateProvider() {
+    public Object[][] invalidDateProvider() {
         return new Object[][]{
-                new Object[]{"2010-12-31T00:60Z"}, new Object[]{"2010-12-31T24:00Z"},
-                new Object[]{"2010-01-32T00:00Z"}, new Object[]{"2020-01-32T00:00Z"},
-                new Object[]{"2010-13-1T00:00Z"}, new Object[]{"1820-01-01T00:00Z"},
-                new Object[]{"2007-2-29T00:00Z"}, new Object[]{"2007-02-29T00:00Z"},
-                new Object[]{"2008-2-30T00:00Z"}, new Object[]{"2008-02-31T00:00Z"},
-                new Object[]{"2008-a-29T00:00Z"}, new Object[]{"2008-02aT00:00Z"},
-                new Object[]{"2008-2-333T00:00Z"}, new Object[]{"200a-02-29T00:00Z"},
-                new Object[]{"2010-4-31T00:00Z"}, new Object[]{"2010-04-31T00:00Z"},
-                new Object[]{"2010-6-31T00:00Z"}, new Object[]{"2010-06-31T00:00Z"},
-                new Object[]{"2010-9-31T00:00Z"}, new Object[]{"2010-09-31T00:00Z"},
-                new Object[]{"2010-11-31T00:00Z"}, new Object[]{"1999-04-31T01:00Z"},
+            new Object[]{"2010-12-31T00:60Z", }, new Object[]{"2010-12-31T24:00Z", },
+            new Object[]{"2010-01-32T00:00Z", }, new Object[]{"2020-01-32T00:00Z", },
+            new Object[]{"2010-13-1T00:00Z", }, new Object[]{"1820-01-01T00:00Z", },
+            new Object[]{"2007-2-29T00:00Z", }, new Object[]{"2007-02-29T00:00Z", },
+            new Object[]{"2008-2-30T00:00Z", }, new Object[]{"2008-02-31T00:00Z", },
+            new Object[]{"2008-a-29T00:00Z", }, new Object[]{"2008-02aT00:00Z", },
+            new Object[]{"2008-2-333T00:00Z", }, new Object[]{"200a-02-29T00:00Z", },
+            new Object[]{"2010-4-31T00:00Z", }, new Object[]{"2010-04-31T00:00Z", },
+            new Object[]{"2010-6-31T00:00Z", }, new Object[]{"2010-06-31T00:00Z", },
+            new Object[]{"2010-9-31T00:00Z", }, new Object[]{"2010-09-31T00:00Z", },
+            new Object[]{"2010-11-31T00:00Z", }, new Object[]{"1999-04-31T01:00Z", },
         };
     }
 
-    @Test(dataProvider = "ValidDateProvider")
-    public void ValidDateTest(String date) {
+    @Test(dataProvider = "validDateProvider")
+    public void validDateTest(String date) {
         boolean valid = DateValidator.validate(date);
         System.out.println("Date is valid : " + date + " , " + valid);
         Assert.assertEquals(valid, true);
     }
 
-    @Test(dataProvider = "InvalidDateProvider",
-            dependsOnMethods = "ValidDateTest")
-    public void InValidDateTest(String date) {
+    @Test(dataProvider = "invalidDateProvider",
+            dependsOnMethods = "validDateTest")
+    public void invalidDateTest(String date) {
         boolean valid = DateValidator.validate(date);
         System.out.println("Date is valid : " + date + " , " + valid);
         Assert.assertEquals(valid, false);

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e69b2205/client/src/test/java/org/apache/falcon/entity/v0/TestFrequency.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/falcon/entity/v0/TestFrequency.java b/client/src/test/java/org/apache/falcon/entity/v0/TestFrequency.java
index 05e9352..e5eb3f1 100644
--- a/client/src/test/java/org/apache/falcon/entity/v0/TestFrequency.java
+++ b/client/src/test/java/org/apache/falcon/entity/v0/TestFrequency.java
@@ -21,6 +21,9 @@ package org.apache.falcon.entity.v0;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+/**
+ * Test frequency.
+ */
 @Test
 public class TestFrequency {
 


Mime
View raw message