falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srik...@apache.org
Subject [29/47] git commit: Check style fixes relating to metrics module
Date Fri, 26 Apr 2013 15:50:45 GMT
Check style fixes relating to metrics 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/2a94690d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/2a94690d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/2a94690d

Branch: refs/heads/master
Commit: 2a94690df67c1df868dcb7f816fffa6cd2f6651b
Parents: 46f07b3
Author: srikanth.sundarrajan <srikanth.sundarrajan@inmobi.com>
Authored: Wed Apr 17 15:57:46 2013 +0530
Committer: srikanth.sundarrajan <srikanth.sundarrajan@inmobi.com>
Committed: Wed Apr 17 15:57:46 2013 +0530

----------------------------------------------------------------------
 .../apache/falcon/aspect/AbstractFalconAspect.java |   11 +++-----
 .../org/apache/falcon/aspect/GenericAlert.java     |   12 +++++++--
 .../org/apache/falcon/aspect/ResourceMessage.java  |    7 ++++-
 .../java/org/apache/falcon/monitors/Dimension.java |    3 ++
 .../java/org/apache/falcon/monitors/Monitored.java |    3 ++
 .../java/org/apache/falcon/monitors/TimeTaken.java |    3 ++
 .../org/apache/falcon/plugin/LoggingPlugin.java    |    3 ++
 .../org/apache/falcon/plugin/MonitoringPlugin.java |    3 ++
 .../falcon/util/ResourcesReflectionUtil.java       |   19 ++++++++-------
 9 files changed, 44 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/aspect/AbstractFalconAspect.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/aspect/AbstractFalconAspect.java b/metrics/src/main/java/org/apache/falcon/aspect/AbstractFalconAspect.java
index 1f3f256..314e27b 100644
--- a/metrics/src/main/java/org/apache/falcon/aspect/AbstractFalconAspect.java
+++ b/metrics/src/main/java/org/apache/falcon/aspect/AbstractFalconAspect.java
@@ -34,8 +34,7 @@ import java.util.Map;
 @Aspect
 public abstract class AbstractFalconAspect {
 
-    private static final Logger LOG = Logger
-            .getLogger(AbstractFalconAspect.class);
+    private static final Logger LOG = Logger.getLogger(AbstractFalconAspect.class);
 
     @Around("@annotation(org.apache.falcon.monitors.Monitored)")
     public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
@@ -88,11 +87,9 @@ public abstract class AbstractFalconAspect {
         }
         Integer timeTakenArg = ResourcesReflectionUtil
                 .getResourceTimeTakenName(methodName);
-        return timeTakenArg == null ? new ResourceMessage(action, dimensions,
-                status, executionTime) : new ResourceMessage(action,
-                dimensions, status, Long.valueOf(args[timeTakenArg]
-                .toString()));
+        return timeTakenArg == null ? new ResourceMessage(action, dimensions, status, executionTime)
+            : new ResourceMessage(action, dimensions, status, Long.valueOf(args[timeTakenArg].toString()));
     }
 
-    abstract public void publishMessage(ResourceMessage message);
+    public abstract void publishMessage(ResourceMessage message);
 }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/aspect/GenericAlert.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/aspect/GenericAlert.java b/metrics/src/main/java/org/apache/falcon/aspect/GenericAlert.java
index b792434..8099760 100644
--- a/metrics/src/main/java/org/apache/falcon/aspect/GenericAlert.java
+++ b/metrics/src/main/java/org/apache/falcon/aspect/GenericAlert.java
@@ -27,8 +27,11 @@ import org.aspectj.lang.annotation.Aspect;
  * and iMon, invoke this method from code.
  */
 @Aspect
-public class GenericAlert {
+public final class GenericAlert {
 
+    private GenericAlert() {}
+
+    //SUSPEND CHECKSTYLE CHECK
     @Monitored(event = "retry-instance-failed")
     public static String alertRetryFailed(
             @Dimension(value = "entity-type") String entityType,
@@ -65,7 +68,8 @@ public class GenericAlert {
             @Dimension(value = "error-message") String errorMessage,
             @Dimension(value = "message") String message,
             @TimeTaken long timeTaken)
-            throws Exception {
+        throws Exception {
+
         return "IGNORE";
     }
 
@@ -80,9 +84,11 @@ public class GenericAlert {
             @Dimension(value = "operation") String operation,
             @Dimension(value = "start-time") String startTime,
             @TimeTaken long timeTaken)
-            throws Exception {
+        throws Exception {
+
         return "IGNORE";
     }
+    //RESUME CHECKSTYLE CHECK
 
     @Monitored(event = "rerun-queue-failed")
     public static String alertRerunConsumerFailed(

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/aspect/ResourceMessage.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/aspect/ResourceMessage.java b/metrics/src/main/java/org/apache/falcon/aspect/ResourceMessage.java
index c7ad8e7..d989f9e 100644
--- a/metrics/src/main/java/org/apache/falcon/aspect/ResourceMessage.java
+++ b/metrics/src/main/java/org/apache/falcon/aspect/ResourceMessage.java
@@ -20,7 +20,9 @@ package org.apache.falcon.aspect;
 
 import java.util.Map;
 
-//Message to be sent to logging system
+/**
+ * Message to be sent to logging system.
+ */
 public class ResourceMessage {
 
     private String action;
@@ -28,6 +30,9 @@ public class ResourceMessage {
     private Status status;
     private long executionTime;
 
+    /**
+     * Convenient enum for resource message status.
+     */
     public enum Status {
         SUCCEEDED, FAILED
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/monitors/Dimension.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/monitors/Dimension.java b/metrics/src/main/java/org/apache/falcon/monitors/Dimension.java
index 233e2f7..387e43a 100644
--- a/metrics/src/main/java/org/apache/falcon/monitors/Dimension.java
+++ b/metrics/src/main/java/org/apache/falcon/monitors/Dimension.java
@@ -23,6 +23,9 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * Dimension annotation for metrics collection.
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.PARAMETER)
 public @interface Dimension {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/monitors/Monitored.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/monitors/Monitored.java b/metrics/src/main/java/org/apache/falcon/monitors/Monitored.java
index 83314d4..768aa4e 100644
--- a/metrics/src/main/java/org/apache/falcon/monitors/Monitored.java
+++ b/metrics/src/main/java/org/apache/falcon/monitors/Monitored.java
@@ -23,6 +23,9 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * Monitored annotation for metrics collection.
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.METHOD)
 public @interface Monitored {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/monitors/TimeTaken.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/monitors/TimeTaken.java b/metrics/src/main/java/org/apache/falcon/monitors/TimeTaken.java
index 94854b2..5b5aec4 100644
--- a/metrics/src/main/java/org/apache/falcon/monitors/TimeTaken.java
+++ b/metrics/src/main/java/org/apache/falcon/monitors/TimeTaken.java
@@ -23,6 +23,9 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * Time taken  annotation for metrics collection.
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.PARAMETER)
 public @interface TimeTaken {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/plugin/LoggingPlugin.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/plugin/LoggingPlugin.java b/metrics/src/main/java/org/apache/falcon/plugin/LoggingPlugin.java
index d7e5a3a..41a52bf 100644
--- a/metrics/src/main/java/org/apache/falcon/plugin/LoggingPlugin.java
+++ b/metrics/src/main/java/org/apache/falcon/plugin/LoggingPlugin.java
@@ -21,6 +21,9 @@ package org.apache.falcon.plugin;
 import org.apache.falcon.aspect.ResourceMessage;
 import org.apache.log4j.Logger;
 
+/**
+ * Plugin for logging metrics using log4j.
+ */
 public class LoggingPlugin implements MonitoringPlugin {
     private static final Logger METRIC = Logger.getLogger("METRIC");
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/plugin/MonitoringPlugin.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/plugin/MonitoringPlugin.java b/metrics/src/main/java/org/apache/falcon/plugin/MonitoringPlugin.java
index 36a108c..d33e65a 100644
--- a/metrics/src/main/java/org/apache/falcon/plugin/MonitoringPlugin.java
+++ b/metrics/src/main/java/org/apache/falcon/plugin/MonitoringPlugin.java
@@ -19,6 +19,9 @@ package org.apache.falcon.plugin;
 
 import org.apache.falcon.aspect.ResourceMessage;
 
+/**
+ * Generic interface to receiving monitoring and metric messages.
+ */
 public interface MonitoringPlugin {
 
     void monitor(ResourceMessage message);

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2a94690d/metrics/src/main/java/org/apache/falcon/util/ResourcesReflectionUtil.java
----------------------------------------------------------------------
diff --git a/metrics/src/main/java/org/apache/falcon/util/ResourcesReflectionUtil.java b/metrics/src/main/java/org/apache/falcon/util/ResourcesReflectionUtil.java
index 119a7f7..8744ad8 100644
--- a/metrics/src/main/java/org/apache/falcon/util/ResourcesReflectionUtil.java
+++ b/metrics/src/main/java/org/apache/falcon/util/ResourcesReflectionUtil.java
@@ -32,13 +32,11 @@ import java.util.Map;
  * Builds a cached of methods annotated with Monitored and params of methods
  * annotated with Dimension.
  */
-public class ResourcesReflectionUtil {
+public final class ResourcesReflectionUtil {
 
-    private static final Map<String, MethodAnnotation> methods = new HashMap<String,
MethodAnnotation>();
+    private static final Map<String, MethodAnnotation> METHODS = new HashMap<String,
MethodAnnotation>();
 
-    private ResourcesReflectionUtil() {
-
-    }
+    private ResourcesReflectionUtil() { }
 
     static {
         //TODO load these classes from properties file
@@ -50,18 +48,21 @@ public class ResourcesReflectionUtil {
     }
 
     public static Map<Integer, String> getResourceDimensionsName(String methodName)
{
-        return methods.get(methodName) != null ? Collections.unmodifiableMap(methods.get(methodName).params)
: null;
+        return METHODS.get(methodName) != null ? Collections.unmodifiableMap(METHODS.get(methodName).params)
: null;
     }
 
     public static String getResourceMonitorName(String methodName) {
-        return methods.get(methodName) != null ? methods.get(methodName).monitoredName :
null;
+        return METHODS.get(methodName) != null ? METHODS.get(methodName).monitoredName :
null;
     }
 
     public static Integer getResourceTimeTakenName(String methodName) {
-        return methods.get(methodName) != null ? methods.get(methodName).timeTakenArgIndex
+        return METHODS.get(methodName) != null ? METHODS.get(methodName).timeTakenArgIndex
                 : null;
     }
 
+    /**
+     * Holder class for method annotation.
+     */
     public static class MethodAnnotation {
         private String monitoredName;
         // argument <index,DimensionValue>
@@ -101,7 +102,7 @@ public class ResourcesReflectionUtil {
                             .getParameterAnnotations();
                     // scan every param
                     annotation.params = getDeclaredParamAnnots(paramAnnots, annotation);
-                    methods.put(
+                    METHODS.put(
                             clazz.getSimpleName() + "."
                                     + declMethod.getName(), annotation);
                 }


Mime
View raw message