You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by su...@apache.org on 2015/04/20 09:32:23 UTC
falcon git commit: FALCON-1158 Rename the parameter 'pattern' in LIST
API to 'nameseq'. Contributed by Ying Zheng
Repository: falcon
Updated Branches:
refs/heads/master 71cfc47b8 -> 1dd301810
FALCON-1158 Rename the parameter 'pattern' in LIST API to 'nameseq'. Contributed by Ying Zheng
Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/1dd30181
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/1dd30181
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/1dd30181
Branch: refs/heads/master
Commit: 1dd3018105814372362e957b6a7bf5b26e58fae7
Parents: 71cfc47
Author: Suhas Vasu <su...@inmobi.com>
Authored: Mon Apr 20 13:01:52 2015 +0530
Committer: Suhas Vasu <su...@inmobi.com>
Committed: Mon Apr 20 13:01:52 2015 +0530
----------------------------------------------------------------------
CHANGES.txt | 3 ++
.../java/org/apache/falcon/cli/FalconCLI.java | 11 +++----
.../org/apache/falcon/client/FalconClient.java | 14 ++++-----
docs/src/site/twiki/FalconCLI.twiki | 3 +-
docs/src/site/twiki/restapi/EntityList.twiki | 33 ++++++++++++++++++--
.../falcon/resource/AbstractEntityManager.java | 18 +++++------
.../proxy/SchedulableEntityManagerProxy.java | 4 +--
.../resource/SchedulableEntityManager.java | 4 +--
.../java/org/apache/falcon/cli/FalconCLIIT.java | 2 +-
9 files changed, 61 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 859bad0..9cd3f2d 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -42,6 +42,9 @@ Branch: 0.6.1 (Proposed Release Version: 0.6.1)
FALCON-822 Add reverse look up API (Ajay Yadava via Suhas Vasu)
IMPROVEMENTS
+ FALCON-1158 Rename the parameter "pattern" in LIST API to "nameseq"
+ (Ying Zheng via Suhas Vasu)
+
FALCON-1142 ClusterEntityParserTest.testClusterWithOnlyStaging
fails when run alone(Pallavi Rao via Suhas Vasu)
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
index 4ea9fc3..7d56b01 100644
--- a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
+++ b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
@@ -97,7 +97,7 @@ public class FalconCLI {
public static final String OFFSET_OPT = "offset";
public static final String NUM_RESULTS_OPT = "numResults";
public static final String NUM_INSTANCES_OPT = "numInstances";
- public static final String PATTERN_OPT = "pattern";
+ public static final String NAMESEQ_OPT = "nameseq";
public static final String FORCE_RERUN_FLAG = "force";
public static final String INSTANCE_CMD = "instance";
@@ -393,7 +393,7 @@ public class FalconCLI {
String sortOrder = commandLine.getOptionValue(SORT_ORDER_OPT);
String filterBy = commandLine.getOptionValue(FILTER_BY_OPT);
String filterTags = commandLine.getOptionValue(TAGS_OPT);
- String searchPattern = commandLine.getOptionValue(PATTERN_OPT);
+ String nameseq = commandLine.getOptionValue(NAMESEQ_OPT);
String fields = commandLine.getOptionValue(FIELDS_OPT);
String feedInstancePath = commandLine.getOptionValue(PATH_OPT);
Integer offset = parseIntegerInput(commandLine.getOptionValue(OFFSET_OPT), 0, "offset");
@@ -463,7 +463,7 @@ public class FalconCLI {
validateOrderBy(orderBy, entityAction);
validateFilterBy(filterBy, entityAction);
EntityList entityList = client.getEntityList(entityType, fields, filterBy,
- filterTags, orderBy, sortOrder, offset, numResults, searchPattern);
+ filterTags, orderBy, sortOrder, offset, numResults, nameseq);
result = entityList != null ? entityList.toString() : "No entity of type (" + entityType + ") found.";
} else if (optionsList.contains(SUMMARY_OPT)) {
validateEntityTypeForSummary(entityType);
@@ -681,8 +681,7 @@ public class FalconCLI {
Option fields = new Option(FIELDS_OPT, true, "Entity fields to show for a request");
Option filterBy = new Option(FILTER_BY_OPT, true,
"Filter returned entities by the specified status");
- Option searchPattern = new Option(PATTERN_OPT, true,
- "Filter entities by fuzzy matching with specified pattern");
+ Option nameseq = new Option(NAMESEQ_OPT, true, "Subsequence of entity name");
Option filterTags = new Option(TAGS_OPT, true, "Filter returned entities by the specified tags");
Option orderBy = new Option(ORDER_BY_OPT, true,
"Order returned entities by this field");
@@ -707,7 +706,7 @@ public class FalconCLI {
entityOptions.addOption(end);
entityOptions.addOption(fields);
entityOptions.addOption(filterBy);
- entityOptions.addOption(searchPattern);
+ entityOptions.addOption(nameseq);
entityOptions.addOption(filterTags);
entityOptions.addOption(orderBy);
entityOptions.addOption(sortOrder);
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/client/src/main/java/org/apache/falcon/client/FalconClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconClient.java b/client/src/main/java/org/apache/falcon/client/FalconClient.java
index 8b40ef2..fedcea6 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconClient.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconClient.java
@@ -370,9 +370,9 @@ public class FalconClient {
public EntityList getEntityList(String entityType, String fields, String filterBy, String filterTags,
String orderBy, String sortOrder, Integer offset,
- Integer numResults, String searchPattern) throws FalconCLIException {
+ Integer numResults, String nameseq) throws FalconCLIException {
return sendListRequest(Entities.LIST, entityType, fields, filterBy,
- filterTags, orderBy, sortOrder, offset, numResults, searchPattern);
+ filterTags, orderBy, sortOrder, offset, numResults, nameseq);
}
public EntitySummaryResult getEntitySummary(String entityType, String cluster, String start, String end,
@@ -608,7 +608,7 @@ public class FalconClient {
String start, String end, String runId, String colo,
String fields, String filterBy, String tags,
String orderBy, String sortOrder, Integer offset,
- Integer numResults, Integer numInstances, String searchPattern,
+ Integer numResults, Integer numInstances, String nameseq,
Boolean isForced) {
if (!StringUtils.isEmpty(fields)) {
@@ -648,8 +648,8 @@ public class FalconClient {
resource = resource.queryParam("numInstances", numInstances.toString());
}
- if (!StringUtils.isEmpty(searchPattern)) {
- resource = resource.queryParam("pattern", searchPattern);
+ if (!StringUtils.isEmpty(nameseq)) {
+ resource = resource.queryParam("nameseq", nameseq);
}
if (isForced != null) {
resource = resource.queryParam("force", String.valueOf(isForced));
@@ -833,11 +833,11 @@ public class FalconClient {
//SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
private EntityList sendListRequest(Entities entities, String entityType, String fields, String filterBy,
String filterTags, String orderBy, String sortOrder, Integer offset,
- Integer numResults, String searchPattern) throws FalconCLIException {
+ Integer numResults, String nameseq) throws FalconCLIException {
WebResource resource = service.path(entities.path)
.path(entityType);
resource = addParamsToResource(resource, null, null, null, null, fields, filterBy, filterTags,
- orderBy, sortOrder, offset, numResults, null, searchPattern, null);
+ orderBy, sortOrder, offset, numResults, null, nameseq, null);
ClientResponse clientResponse = resource
.header("Cookie", AUTH_COOKIE_EQ + authenticationToken)
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/docs/src/site/twiki/FalconCLI.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/FalconCLI.twiki b/docs/src/site/twiki/FalconCLI.twiki
index 22ffbe7..0e42ae2 100644
--- a/docs/src/site/twiki/FalconCLI.twiki
+++ b/docs/src/site/twiki/FalconCLI.twiki
@@ -51,7 +51,8 @@ Entities of a particular type can be listed with list sub-command.
Usage:
$FALCON_HOME/bin/falcon entity -type [cluster|feed|process] -list
-Optional Args : -fields <<field1,field2>> -filterBy <<field1:value1,field2:value2>> -tags <<tagkey=tagvalue,tagkey=tagvalue>>
+Optional Args : -fields <<field1,field2>> -filterBy <<field1:value1,field2:value2>>
+-tags <<tagkey=tagvalue,tagkey=tagvalue>> -nameseq <<namesubsequence>>
-orderBy <<field>> -sortOrder <<sortOrder>> -offset 0 -numResults 10
<a href="./Restapi/EntityList.html">Optional params described here.</a>
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/docs/src/site/twiki/restapi/EntityList.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/EntityList.twiki b/docs/src/site/twiki/restapi/EntityList.twiki
index 5e11691..08dd304 100644
--- a/docs/src/site/twiki/restapi/EntityList.twiki
+++ b/docs/src/site/twiki/restapi/EntityList.twiki
@@ -11,9 +11,10 @@ Get list of the entities.
* :entity-type Valid options are cluster, feed or process.
* fields <optional param> Fields of entity that the user wants to view, separated by commas.
* Valid options are STATUS, TAGS, PIPELINES.
- * pattern <optional param> Find string which contains this sequence of characters. Example: pattern=abc
- * matching is case insensitive.
- * For example a pattern mhs will match a process named New-My-Hourly-Summary.
+ * nameseq <optional param> Subsequence of entity name. Not case sensitive.
+ * The entity name needs to contain all the characters in the subsequence in the same order.
+ * Example 1: "sample1" will match the entity named "SampleFeed1-2".
+ * Example 2: "mhs" will match the entity named "New-My-Hourly-Summary".
* filterBy <optional param> Filter results by list of field:value pairs. Example: filterBy=STATUS:RUNNING,PIPELINES:clickLogs
* Supported filter fields are NAME, STATUS, PIPELINES, CLUSTER.
* Query will do an AND among filterBy fields.
@@ -96,3 +97,29 @@ GET http://localhost:15000/api/entities/list/process?filterBy=STATUS:RUNNING,PIP
]
}
</verbatim>
+
+---+++ Rest Call
+<verbatim>
+GET http://localhost:15000/api/entities/list/feed?nameseq=samplebill&numResults=2&offset=1&fields=status,clusters,tags
+</verbatim>
+---+++ Result
+<verbatim>
+{
+ "entity”:[
+ {
+ "type":"FEED”,
+ "name":"SampleUSHealthBill”,
+ "status":"SUBMITTED”,
+ "tags”: {"tag":["related=ushealthcare","department=billingDepartment"]},
+ "clusters": {"cluster":["SampleCluster1","primaryCluster”]}
+ },
+ {
+ "type":"FEED”,
+ "name":"SampleHealthBill”,
+ "status":"SUBMITTED”,
+ "tags”: {"tag":["related=healthcare","department=billingDepartment"]},
+ "clusters": {"cluster":"primaryCluster”}
+ }
+ ]
+}
+</verbatim>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
index 1e2fc82..25cb312 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
@@ -577,14 +577,14 @@ public abstract class AbstractEntityManager {
*/
public EntityList getEntityList(String type, String fieldStr, String filterBy, String filterTags,
String orderBy, String sortOrder, Integer offset, Integer resultsPerPage,
- String pattern) {
+ String nameseq) {
HashSet<String> fields = new HashSet<String>(Arrays.asList(fieldStr.toLowerCase().split(",")));
validateEntityFilterByClause(filterBy);
List<Entity> entities;
try {
entities = getEntities(type, "", "", "", filterBy, filterTags, orderBy, sortOrder, offset,
- resultsPerPage, pattern);
+ resultsPerPage, nameseq);
} catch (Exception e) {
LOG.error("Failed to get entity list", e);
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
@@ -609,7 +609,7 @@ public abstract class AbstractEntityManager {
protected List<Entity> getEntities(String type, String startDate, String endDate, String cluster,
String filterBy, String filterTags, String orderBy, String sortOrder, int offset,
- int resultsPerPage, String pattern) throws FalconException, IOException {
+ int resultsPerPage, String nameseq) throws FalconException, IOException {
final Map<String, String> filterByFieldsValues = getFilterByFieldsValues(filterBy);
final List<String> filterByTags = getFilterByTags(filterTags);
@@ -648,7 +648,7 @@ public abstract class AbstractEntityManager {
continue;
}
- if (StringUtils.isNotBlank(pattern) && !fuzzySearch(entity.getName(), pattern)) {
+ if (StringUtils.isNotBlank(nameseq) && !fuzzySearch(entity.getName(), nameseq)) {
continue;
}
entities.add(entity);
@@ -665,16 +665,16 @@ public abstract class AbstractEntityManager {
}
//RESUME CHECKSTYLE CHECK ParameterNumberCheck
- boolean fuzzySearch(String enityName, String pattern) {
- int currentIndex = 0; // current index in pattern which is to be matched
- char[] searchPattern = pattern.toLowerCase().toCharArray();
+ boolean fuzzySearch(String enityName, String nameseq) {
+ int currentIndex = 0; // current index in name subsequence which is to be matched
+ char[] nameseqArray = nameseq.toLowerCase().toCharArray();
String name = enityName.toLowerCase();
for (Character c : name.toCharArray()) {
- if (currentIndex < searchPattern.length && c == searchPattern[currentIndex]) {
+ if (currentIndex < nameseqArray.length && c == nameseqArray[currentIndex]) {
currentIndex++;
}
- if (currentIndex == searchPattern.length) {
+ if (currentIndex == nameseqArray.length) {
return true;
}
}
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
index 8bfc099..6ccfd09 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
@@ -460,8 +460,8 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
@DefaultValue("0") @QueryParam("offset") Integer offset,
@DefaultValue(DEFAULT_NUM_RESULTS)
@QueryParam("numResults") Integer resultsPerPage,
- @QueryParam("pattern") String pattern) {
- return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage, pattern);
+ @QueryParam("nameseq") String nameseq) {
+ return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage, nameseq);
}
@GET
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
index 4740c71..82a622c 100644
--- a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
+++ b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
@@ -68,8 +68,8 @@ public class SchedulableEntityManager extends AbstractSchedulableEntityManager {
@DefaultValue("0") @QueryParam("offset") Integer offset,
@DefaultValue(DEFAULT_NUM_RESULTS)
@QueryParam("numResults") Integer resultsPerPage,
- @QueryParam("pattern") String pattern) {
- return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage, pattern);
+ @QueryParam("nameseq") String nameseq) {
+ return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage, nameseq);
}
@GET
http://git-wip-us.apache.org/repos/asf/falcon/blob/1dd30181/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java b/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
index bfad011..dd14e9c 100644
--- a/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
+++ b/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
@@ -558,7 +558,7 @@ public class FalconCLIIT {
Assert.assertEquals(executeWithURL("entity -list -type process -fields status "
+ " -filterBy STATUS:SUBMITTED,TYPE:process -orderBy name "
- + " -sortOrder asc -offset 1 -numResults 1 -pattern abc"), 0);
+ + " -sortOrder asc -offset 1 -numResults 1 -nameseq abc"), 0);
Assert.assertEquals(executeWithURL("entity -list -type process -fields status "
+ " -filterBy STATUS:SUBMITTED,TYPE:process -orderBy name "