falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pall...@apache.org
Subject falcon git commit: FALCON-2247 include status of entities in getDetailExtensionJobs
Date Tue, 24 Jan 2017 10:56:55 GMT
Repository: falcon
Updated Branches:
  refs/heads/master c67556852 -> 9da6d3804


FALCON-2247 include status of entities in getDetailExtensionJobs

Author: Pracheer Agarwal <pracheer.agarwal@inmobi.com>
Author: Pracheer Agarwal <pracheeragarwal@gmail.com>
Author: Pracheer Agarwal <pr@im2216-x0.corp.inmobi.com>
Author: sandeep <sandysmdl@gmail.com>

Reviewers: @sandeepSamudrala, @pallavi-rao

Closes #345 from PracheerAgarwal/FALCON-2247 and squashes the following commits:

c57efa2 [sandeep] FALCON-2247 review commits changes
56492e7 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon into
FALCON-2247
76215d7 [Pracheer Agarwal] changes for review comments
c38c51b [Pracheer Agarwal] indentation changes
2ad4ce7 [Pracheer Agarwal] bug fixes
5d01f9c [Pracheer Agarwal] FALCON-2247 include status of entities in getDetailExtensionJobs
778c579 [Pracheer Agarwal] Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
e39808d [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
a932633 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
fda3b28 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
a93d71a [Pracheer Agarwal] Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
e3728d5 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
066c8e2 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
b20f044 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
7f572a1 [Pracheer Agarwal] Merge branch 'master' of https://github.com/apache/falcon
46042fd [Pracheer Agarwal] Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
daa3ffc [Pracheer Agarwal] FALCON-2225 extension owner added for trusted extensions
622cae4 [Pracheer Agarwal] FALCON-2225 extension owner added for trusted extensions


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

Branch: refs/heads/master
Commit: 9da6d380491f375749fa3f39f995563bf6834240
Parents: c675568
Author: Pracheer Agarwal <pracheer.agarwal@inmobi.com>
Authored: Tue Jan 24 16:26:41 2017 +0530
Committer: Pallavi Rao <pallavi.rao@inmobi.com>
Committed: Tue Jan 24 16:26:41 2017 +0530

----------------------------------------------------------------------
 .../resource/AbstractExtensionManager.java      | 23 ++++++++++++++++++--
 .../org/apache/falcon/unit/TestFalconUnit.java  |  6 ++++-
 2 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/9da6d380/prism/src/main/java/org/apache/falcon/resource/AbstractExtensionManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractExtensionManager.java
b/prism/src/main/java/org/apache/falcon/resource/AbstractExtensionManager.java
index c7da6e3..ab08e00 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractExtensionManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractExtensionManager.java
@@ -21,6 +21,8 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.falcon.FalconException;
 import org.apache.falcon.FalconWebException;
+import org.apache.falcon.entity.EntityNotRegisteredException;
+import org.apache.falcon.entity.EntityUtil;
 import org.apache.falcon.entity.parser.ValidationException;
 import org.apache.falcon.extensions.ExtensionStatus;
 import org.apache.falcon.entity.v0.EntityType;
@@ -55,9 +57,12 @@ public class AbstractExtensionManager extends AbstractSchedulableEntityManager
{
     private static final String LAST_UPDATE_TIME  = "lastUpdatedTime";
 
     public static final String NAME = "name";
+    public static final String STATUS = "status";
     private static final String EXTENSION_TYPE = "type";
     private static final String EXTENSION_DESC = "description";
     private static final String EXTENSION_LOCATION = "location";
+    private static final String ENTITY_EXISTS_STATUS = "EXISTS";
+    private static final String ENTITY_NOT_EXISTS_STATUS = "NOT_EXISTS";
 
     protected static void validateExtensionName(final String extensionName) {
         if (StringUtils.isBlank(extensionName)) {
@@ -142,8 +147,8 @@ public class AbstractExtensionManager extends AbstractSchedulableEntityManager
{
         try {
             detailsObject.put(JOB_NAME, jobsBean.getJobName());
             detailsObject.put(EXTENSION_NAME, jobsBean.getExtensionName());
-            detailsObject.put(FEEDS, StringUtils.join(jobsBean.getFeeds(), ","));
-            detailsObject.put(PROCESSES, StringUtils.join(jobsBean.getProcesses(), ","));
+            detailsObject.put(FEEDS, getEntitiesStatus(jobsBean.getFeeds(), EntityType.FEED));
+            detailsObject.put(PROCESSES, getEntitiesStatus(jobsBean.getProcesses(), EntityType.PROCESS));
             detailsObject.put(CONFIG, jobsBean.getConfig());
             detailsObject.put(CREATION_TIME, jobsBean.getCreationTime());
             detailsObject.put(LAST_UPDATE_TIME, jobsBean.getLastUpdatedTime());
@@ -266,4 +271,18 @@ public class AbstractExtensionManager extends AbstractSchedulableEntityManager
{
                     Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
+
+    private JSONObject getEntitiesStatus(List<String> entities, EntityType type) throws
JSONException, FalconException {
+        JSONObject entityObject = new JSONObject();
+        for (String entity : entities) {
+            try {
+                entityObject.put(NAME, entity);
+                EntityUtil.getEntity(type, entity);
+                entityObject.put(STATUS, ENTITY_EXISTS_STATUS);
+            } catch (EntityNotRegisteredException e) {
+                entityObject.put(STATUS, ENTITY_NOT_EXISTS_STATUS);
+            }
+        }
+        return entityObject;
+    }
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/9da6d380/unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java
----------------------------------------------------------------------
diff --git a/unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java b/unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java
index 72280f7..8949c41 100644
--- a/unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java
+++ b/unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java
@@ -482,7 +482,11 @@ public class TestFalconUnit extends FalconUnitTestBase {
         assertStatus(apiResult);
 
         String processes = new JSONObject(getExtensionJobDetails(TEST_JOB).getMessage()).get("processes").toString();
-        Assert.assertEquals(processes, "sample");
+        JSONObject processObject = new JSONObject();
+        processObject.put("name", "sample");
+        processObject.put("status", "EXISTS");
+
+        Assert.assertEquals(processes, processObject.toString());
         process = (Process) getClient().getDefinition(EntityType.PROCESS.toString(), "sample",
null);
         Assert.assertEquals(process.getPipelines(), "testSample");
 


Mime
View raw message