falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject [2/3] falcon git commit: FALCON-1617 Enable SLA monitoring for instances in past. Contributed by Narayan Periwal.
Date Tue, 15 Dec 2015 12:24:05 GMT
FALCON-1617 Enable SLA monitoring for instances in past. Contributed by Narayan Periwal.


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

Branch: refs/heads/master
Commit: 15e43a883f9e67a7eded65b51040905694591c58
Parents: 8be383e
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Tue Dec 15 16:55:29 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Tue Dec 15 17:53:16 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                      |  2 ++
 .../org/apache/falcon/entity/FeedHelper.java     | 19 +++++++++++++++++++
 .../falcon/service/FeedSLAMonitoringService.java |  9 +++++++++
 3 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/15e43a88/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0f773de..bf3e47f 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -35,6 +35,8 @@ Trunk (Unreleased)
     FALCON-1213 Base framework of the native scheduler(Pallavi Rao)
 
   IMPROVEMENTS
+    FALCON-1617 Enable SLA monitoring for instances in past(Narayan Periwal via Ajay Yadava)
+
     FALCON-1577 Migration of EntityManagerJerseyIT to use falcon unit (Narayan Periwal via
Pallavi Rao)
 
     FALCON-1658 MySql Support for Native Scheduler(Pavan Kumar Kolamuri via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/15e43a88/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/FeedHelper.java b/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
index 29daff3..138a43f 100644
--- a/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
+++ b/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
@@ -1011,4 +1011,23 @@ public final class FeedHelper {
         }
         return  retentionFrequency;
     }
+
+    public static Frequency getOldRetentionFrequency(Feed feed) {
+        Frequency feedFrequency = feed.getFrequency();
+        Frequency defaultFrequency = new Frequency("hours(24)");
+        if (DateUtil.getFrequencyInMillis(feedFrequency) < DateUtil.getFrequencyInMillis(defaultFrequency))
{
+            return new Frequency("hours(6)");
+        } else {
+            return defaultFrequency;
+        }
+    }
+
+    public static Frequency getRetentionFrequency(Feed feed, Cluster feedCluster) throws
FalconException {
+        Frequency retentionFrequency;
+        retentionFrequency = getLifecycleRetentionFrequency(feed, feedCluster.getName());
+        if (retentionFrequency == null) {
+            retentionFrequency = getOldRetentionFrequency(feed);
+        }
+        return retentionFrequency;
+    }
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/15e43a88/prism/src/main/java/org/apache/falcon/service/FeedSLAMonitoringService.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/service/FeedSLAMonitoringService.java b/prism/src/main/java/org/apache/falcon/service/FeedSLAMonitoringService.java
index b302539..1cd571e 100644
--- a/prism/src/main/java/org/apache/falcon/service/FeedSLAMonitoringService.java
+++ b/prism/src/main/java/org/apache/falcon/service/FeedSLAMonitoringService.java
@@ -326,6 +326,15 @@ public final class FeedSLAMonitoringService implements ConfigurationChangeListen
                     BlockingQueue<Date> instances = pendingInstances.get(key);
                     if (instances == null) {
                         instances = new LinkedBlockingQueue<>(queueSize);
+                        Date feedStartTime = feedCluster.getValidity().getStart();
+                        Frequency retentionFrequency = FeedHelper.getRetentionFrequency(feed,
feedCluster);
+                        ExpressionHelper evaluator = ExpressionHelper.get();
+                        ExpressionHelper.setReferenceDate(new Date());
+                        Date retention = new Date(evaluator.evaluate(retentionFrequency.toString(),
Long.class));
+                        if (feedStartTime.before(retention)) {
+                            feedStartTime = retention;
+                        }
+                        nextInstanceTime = feedStartTime;
                     }
                     Set<Date> exists = new HashSet<>(instances);
                     org.apache.falcon.entity.v0.cluster.Cluster currentCluster =


Mime
View raw message