Skip to content

Commit

Permalink
FALCON-2247 include status of entities in getDetailExtensionJobs
Browse files Browse the repository at this point in the history
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 apache#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
  • Loading branch information
PracheerAgarwal-zz authored and Pallavi Nagesha Rao committed Feb 16, 2018
1 parent 0d873b4 commit d6bf43f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -142,8 +147,8 @@ private JSONObject buildExtensionJobDetailResult(final String jobName) throws Fa
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());
Expand Down Expand Up @@ -266,4 +271,18 @@ protected static void checkIfExtensionJobNameExists(String jobName, String exten
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,11 @@ public void testExtensionJobOperations() throws Exception {
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");

Expand Down

0 comments on commit d6bf43f

Please sign in to comment.