falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srik...@apache.org
Subject [2/3] incubator-falcon git commit: FALCON-593 Preserve data type for properties in a vertex. Contributed by Ajay Yadav
Date Tue, 02 Dec 2014 04:24:23 GMT
FALCON-593 Preserve data type for properties in a vertex. Contributed by Ajay Yadav


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

Branch: refs/heads/master
Commit: d8c61614c8debf9fbaf4f77014204d9464939350
Parents: ed4a52f
Author: srikanth.sundarrajan <sriksun@apache.org>
Authored: Tue Dec 2 09:41:29 2014 +0530
Committer: srikanth.sundarrajan <sriksun@apache.org>
Committed: Tue Dec 2 09:41:29 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                       |  3 +++
 .../InstanceRelationshipGraphBuilder.java         |  4 ++--
 .../falcon/metadata/RelationshipGraphBuilder.java |  6 +++---
 .../falcon/workflow/WorkflowExecutionContext.java | 18 ++++++++++++++++++
 4 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/d8c61614/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7d4c085..f671e56 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,9 @@ Trunk (Unreleased)
   NEW FEATURES
 
   IMPROVEMENTS
+   FALCON-593 Preserve data type for properties in a vertex. (Ajay
+   Yadav via Srikanth Sundarrajan)
+
    FALCON-785 Document upgrade path from 0.5 to 0.6. (Balu Vellanki 
    via Srikanth Sundarrajan)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/d8c61614/common/src/main/java/org/apache/falcon/metadata/InstanceRelationshipGraphBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/metadata/InstanceRelationshipGraphBuilder.java
b/common/src/main/java/org/apache/falcon/metadata/InstanceRelationshipGraphBuilder.java
index c9cbf0b..87bac69 100644
--- a/common/src/main/java/org/apache/falcon/metadata/InstanceRelationshipGraphBuilder.java
+++ b/common/src/main/java/org/apache/falcon/metadata/InstanceRelationshipGraphBuilder.java
@@ -71,7 +71,7 @@ public class InstanceRelationshipGraphBuilder extends RelationshipGraphBuilder
{
         LOG.info("Adding process instance: {}", processInstanceName);
 
         Vertex processInstance = addVertex(processInstanceName,
-                RelationshipType.PROCESS_INSTANCE, context.getTimeStampAsISO8601());
+                RelationshipType.PROCESS_INSTANCE, context.getTimeStampAsLong());
         addWorkflowInstanceProperties(processInstance, context);
 
         addInstanceToEntity(processInstance, context.getEntityName(),
@@ -250,7 +250,7 @@ public class InstanceRelationshipGraphBuilder extends RelationshipGraphBuilder
{
                                    String feedName, String clusterName) throws FalconException
{
         LOG.info("Adding feed instance {}", feedInstanceName);
         Vertex feedInstance = addVertex(feedInstanceName, RelationshipType.FEED_INSTANCE,
-                context.getTimeStampAsISO8601());
+                context.getTimeStampAsLong());
 
         addInstanceToEntity(feedInstance, feedName,
                 RelationshipType.FEED_ENTITY, RelationshipLabel.INSTANCE_ENTITY_EDGE);

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/d8c61614/common/src/main/java/org/apache/falcon/metadata/RelationshipGraphBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/metadata/RelationshipGraphBuilder.java
b/common/src/main/java/org/apache/falcon/metadata/RelationshipGraphBuilder.java
index d5685a5..b92224b 100644
--- a/common/src/main/java/org/apache/falcon/metadata/RelationshipGraphBuilder.java
+++ b/common/src/main/java/org/apache/falcon/metadata/RelationshipGraphBuilder.java
@@ -73,7 +73,7 @@ public abstract class RelationshipGraphBuilder {
         return createVertex(name, type);
     }
 
-    protected Vertex addVertex(String name, RelationshipType type, String timestamp) {
+    protected Vertex addVertex(String name, RelationshipType type, long timestamp) {
         Vertex vertex = findVertex(name, type);
         if (vertex != null) {
             LOG.debug("Found an existing vertex for: name={}, type={}", name, type);
@@ -94,10 +94,10 @@ public abstract class RelationshipGraphBuilder {
     }
 
     protected Vertex createVertex(String name, RelationshipType type) {
-        return createVertex(name, type, getCurrentTimeStamp());
+        return createVertex(name, type, System.currentTimeMillis());
     }
 
-    protected Vertex createVertex(String name, RelationshipType type, String timestamp) {
+    protected Vertex createVertex(String name, RelationshipType type, long timestamp) {
         LOG.debug("Creating a new vertex for: name={}, type={}", name, type);
 
         Vertex vertex = graph.addVertex(null);

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/d8c61614/common/src/main/java/org/apache/falcon/workflow/WorkflowExecutionContext.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/workflow/WorkflowExecutionContext.java
b/common/src/main/java/org/apache/falcon/workflow/WorkflowExecutionContext.java
index ebd4dd4..8d69b9a 100644
--- a/common/src/main/java/org/apache/falcon/workflow/WorkflowExecutionContext.java
+++ b/common/src/main/java/org/apache/falcon/workflow/WorkflowExecutionContext.java
@@ -38,9 +38,12 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.TimeZone;
 
 /**
  * Captures the workflow execution context.
@@ -152,6 +155,21 @@ public class WorkflowExecutionContext {
     }
 
     /**
+     * Returns timestamp as a long.
+     * @return Date as long (milliseconds since epoch) for the timestamp.
+     */
+    public long getTimeStampAsLong() {
+        String dateString = getTimestamp();
+        try {
+            DateFormat dateFormat = new SimpleDateFormat(INSTANCE_FORMAT.substring(0, dateString.length()));
+            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+            return dateFormat.parse(dateString).getTime();
+        } catch (java.text.ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
      * Returns timestamp as a ISO8601 formatted string.
      * @return a ISO8601 formatted string
      */


Mime
View raw message