Skip to content
This repository has been archived by the owner on Apr 4, 2021. It is now read-only.

FALCON-2247 include status of entities in getDetailExtensionJobs #345

Closed
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
622cae4
FALCON-2225 extension owner added for trusted extensions
PracheerAgarwal-zz Dec 20, 2016
daa3ffc
FALCON-2225 extension owner added for trusted extensions
PracheerAgarwal-zz Dec 20, 2016
46042fd
Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
PracheerAgarwal-zz Dec 23, 2016
7f572a1
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal-zz Jan 2, 2017
b20f044
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal-zz Jan 4, 2017
066c8e2
Merge branch 'master' of https://github.com/apache/falcon
Jan 5, 2017
e3728d5
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal Jan 6, 2017
a93d71a
Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
PracheerAgarwal Jan 6, 2017
fda3b28
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal-zz Jan 7, 2017
a932633
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal Jan 10, 2017
e39808d
Merge branch 'master' of https://github.com/apache/falcon
PracheerAgarwal-zz Jan 22, 2017
778c579
Merge branch 'master' of https://github.com/PracheerAgarwal/falcon
PracheerAgarwal-zz Jan 22, 2017
5d01f9c
FALCON-2247 include status of entities in getDetailExtensionJobs
PracheerAgarwal-zz Jan 23, 2017
2ad4ce7
bug fixes
PracheerAgarwal-zz Jan 23, 2017
c38c51b
indentation changes
PracheerAgarwal-zz Jan 23, 2017
76215d7
changes for review comments
PracheerAgarwal-zz Jan 23, 2017
56492e7
Merge branch 'master' of https://github.com/apache/falcon into FALCON…
PracheerAgarwal-zz Jan 23, 2017
c57efa2
FALCON-2247 review commits changes
sandeepSamudrala Jan 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -58,6 +60,8 @@ public class AbstractExtensionManager extends AbstractSchedulableEntityManager {
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 +146,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 +270,17 @@ 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 {
EntityUtil.getEntity(type, entity);
} catch (EntityNotRegisteredException e) {
entityObject.put(entity, ENTITY_NOT_EXISTS_STATUS);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By JSON standards, the keys are usually constant strings. This should be { "name" : "abc, "status" : "EXISTS"}

This makes it easy to consume programmatically also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid point. Have made the changes.

}
entityObject.put(entity, ENTITY_EXISTS_STATUS);
}
return entityObject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ 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("sample", "EXISTS");

Assert.assertEquals(processes, processObject.toString());
process = (Process) getClient().getDefinition(EntityType.PROCESS.toString(), "sample", null);
Assert.assertEquals(process.getPipelines(), "testSample");

Expand Down