Murtadha Hubail has submitted this change and it was merged.
Change subject: [NO ISSUE][API] QueryServiceServlet HTTP API Improvements
......................................................................
[NO ISSUE][API] QueryServiceServlet HTTP API Improvements
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Default NC timeout to Long.MAX.
- Accept signature as parameter and default its
value to true and its returned value to {"*":"*"}.
- Accept "json" as a synonym for "application/json" format.
Change-Id: Ibe77eb8ad08a19ed1f11ffdb63f4379819ca43c8
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2636
Sonar-Qube: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Contrib: Jenkins <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Reviewed-by: Murtadha Hubail <[email protected]>
Reviewed-by: Till Westmann <[email protected]>
---
M
asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
M
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/ExecuteStatementRequestMessage.java
M
hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java
3 files changed, 24 insertions(+), 6 deletions(-)
Approvals:
Anon. E. Moose #1000171:
Till Westmann: Looks good to me, approved
Jenkins: Verified; No violations found; ; Verified
Murtadha Hubail: Looks good to me, but someone else must approve
diff --git
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
index dd03860..3d0858c 100644
---
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
+++
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
@@ -149,7 +149,8 @@
REWRITTEN_EXPRESSION_TREE("rewritten-expression-tree"),
LOGICAL_PLAN("logical-plan"),
OPTIMIZED_LOGICAL_PLAN("optimized-logical-plan"),
- JOB("job");
+ JOB("job"),
+ SIGNATURE("signature");
private final String str;
@@ -212,6 +213,7 @@
boolean logicalPlan;
boolean optimizedLogicalPlan;
boolean job;
+ boolean signature;
@Override
public String toString() {
@@ -233,6 +235,7 @@
on.put("logicalPlan", logicalPlan);
on.put("optimizedLogicalPlan", optimizedLogicalPlan);
on.put("job", job);
+ on.put("signature", signature);
return om.writer(new
MinimalPrettyPrinter()).writeValueAsString(on);
} catch (JsonProcessingException e) { // NOSONAR
LOGGER.debug("unexpected exception marshalling {} instance to
json", getClass(), e);
@@ -311,7 +314,7 @@
if (format.equals(HttpUtil.ContentType.APPLICATION_ADM)) {
return SessionConfig.OutputFormat.ADM;
}
- if (format.startsWith(HttpUtil.ContentType.APPLICATION_JSON)) {
+ if (isJsonFormat(format)) {
return Boolean.parseBoolean(getParameterValue(format,
Attribute.LOSSLESS.str()))
? SessionConfig.OutputFormat.LOSSLESS_JSON :
SessionConfig.OutputFormat.CLEAN_JSON;
}
@@ -350,8 +353,15 @@
}
}
- private static void printSignature(PrintWriter pw) {
- ResultUtil.printField(pw, ResultFields.SIGNATURE.str(), "*");
+ private static void printSignature(PrintWriter pw, RequestParameters
param) {
+ if (param.signature) {
+ pw.print("\t\"");
+ pw.print(ResultFields.SIGNATURE.str());
+ pw.print("\": {\n");
+ pw.print("\t");
+ ResultUtil.printField(pw, "*", "*", false);
+ pw.print("\t},\n");
+ }
}
private static void printType(PrintWriter pw, SessionConfig sessionConfig)
{
@@ -424,6 +434,7 @@
param.logicalPlan = getOptBoolean(jsonRequest,
Parameter.LOGICAL_PLAN.str(), false);
param.optimizedLogicalPlan = getOptBoolean(jsonRequest,
Parameter.OPTIMIZED_LOGICAL_PLAN.str(), false);
param.job = getOptBoolean(jsonRequest, Parameter.JOB.str(),
false);
+ param.signature = getOptBoolean(jsonRequest,
Parameter.SIGNATURE.str(), true);
} catch (JsonParseException | JsonMappingException e) {
// if the JSON parsing fails, the statement is empty and we
get an empty statement error
GlobalConfig.ASTERIX_LOGGER.log(Level.ERROR, e.getMessage(),
e);
@@ -507,7 +518,7 @@
sessionOutput.out().print("{\n");
printRequestId(sessionOutput.out());
printClientContextID(sessionOutput.out(), param);
- printSignature(sessionOutput.out());
+ printSignature(sessionOutput.out(), param);
printType(sessionOutput.out(), sessionConfig);
long errorCount = 1; // so far we just return 1 error
try {
@@ -622,4 +633,9 @@
}
pw.print(",\n");
}
+
+ private static boolean isJsonFormat(String format) {
+ return format.startsWith(HttpUtil.ContentType.APPLICATION_JSON)
+ || format.equalsIgnoreCase(HttpUtil.ContentType.JSON);
+ }
}
diff --git
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/ExecuteStatementRequestMessage.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/ExecuteStatementRequestMessage.java
index 8de3782..977bbe3 100644
---
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/ExecuteStatementRequestMessage.java
+++
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/ExecuteStatementRequestMessage.java
@@ -29,6 +29,7 @@
import org.apache.asterix.api.http.server.ResultUtil;
import org.apache.asterix.app.cc.CCExtensionManager;
import org.apache.asterix.app.translator.RequestParameters;
+import org.apache.asterix.common.api.Duration;
import org.apache.asterix.common.api.IClusterManagementWork;
import org.apache.asterix.common.cluster.IClusterStateManager;
import org.apache.asterix.common.config.GlobalConfig;
@@ -64,7 +65,7 @@
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LogManager.getLogger();
//TODO: Make configurable:
https://issues.apache.org/jira/browse/ASTERIXDB-2062
- public static final long DEFAULT_NC_TIMEOUT_MILLIS =
TimeUnit.MINUTES.toMillis(5);
+ public static final long DEFAULT_NC_TIMEOUT_MILLIS =
TimeUnit.MILLISECONDS.toMillis(Long.MAX_VALUE);
//TODO: Make configurable:
https://issues.apache.org/jira/browse/ASTERIXDB-2063
public static final long DEFAULT_QUERY_CANCELLATION_WAIT_MILLIS =
TimeUnit.MINUTES.toMillis(1);
private final String requestNodeId;
diff --git
a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java
index ffa4d4b..bdd312d 100644
---
a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java
+++
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java
@@ -63,6 +63,7 @@
public static class ContentType {
public static final String APPLICATION_ADM = "application/x-adm";
public static final String APPLICATION_JSON = "application/json";
+ public static final String JSON = "json";
public static final String APPLICATION_X_WWW_FORM_URLENCODED =
"application/x-www-form-urlencoded";
public static final String CSV = "text/csv";
public static final String IMG_PNG = "image/png";
--
To view, visit https://asterix-gerrit.ics.uci.edu/2636
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibe77eb8ad08a19ed1f11ffdb63f4379819ca43c8
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Michael Blow <[email protected]>
Gerrit-Reviewer: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: Till Westmann <[email protected]>
Gerrit-Reviewer: abdullah alamoudi <[email protected]>