You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2019/05/14 00:27:10 UTC
[asterixdb] branch master updated: [ASTERIXDB-2563][API] Allow All
Nodes To Receive Queries
This is an automated email from the ASF dual-hosted git repository.
mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new 73f48f4 [ASTERIXDB-2563][API] Allow All Nodes To Receive Queries
73f48f4 is described below
commit 73f48f4c2016c02e3bfd8dc1be99226318613232
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Thu May 9 15:01:17 2019 +0300
[ASTERIXDB-2563][API] Allow All Nodes To Receive Queries
- user model changes: any node can receive query requests.
- storage format changes: no
- interface changes: no
Details:
- Add required servlets to NCs web server to allow them
to receive query requests.
- Adapt test framework to use NCs endpoints for query requests
when they are configured.
- Make SqlppExecutionTest use NCs endpoints for query requests.
Change-Id: I31f7937d46b4532c30e2201b3e434e62e5c4a4de
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3388
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>
---
.../asterix/hyracks/bootstrap/NCApplication.java | 17 ++++++++++++++++
.../apache/asterix/test/common/TestExecutor.java | 7 ++++++-
.../asterix/test/runtime/SqlppExecutionTest.java | 23 +++++++++++++++++++++-
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
index c3402f9..eba2049 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
@@ -18,13 +18,22 @@
*/
package org.apache.asterix.hyracks.bootstrap;
+import static org.apache.asterix.api.http.server.ServletConstants.HYRACKS_CONNECTION_ATTR;
+import static org.apache.asterix.common.utils.Servlets.QUERY_RESULT;
+import static org.apache.asterix.common.utils.Servlets.QUERY_SERVICE;
+import static org.apache.asterix.common.utils.Servlets.QUERY_STATUS;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
+import org.apache.asterix.algebra.base.ILangExtension;
+import org.apache.asterix.api.http.server.NCQueryServiceServlet;
import org.apache.asterix.api.http.server.NetDiagnosticsApiServlet;
+import org.apache.asterix.api.http.server.QueryResultApiServlet;
+import org.apache.asterix.api.http.server.QueryStatusApiServlet;
import org.apache.asterix.api.http.server.ServletConstants;
import org.apache.asterix.api.http.server.StorageApiServlet;
import org.apache.asterix.app.config.ConfigValidator;
@@ -57,6 +66,7 @@ import org.apache.asterix.common.utils.PrintUtil;
import org.apache.asterix.common.utils.Servlets;
import org.apache.asterix.common.utils.StorageConstants;
import org.apache.asterix.common.utils.StoragePathUtil;
+import org.apache.asterix.compiler.provider.ILangCompilationProvider;
import org.apache.asterix.messaging.MessagingChannelInterfaceFactory;
import org.apache.asterix.messaging.NCMessageBroker;
import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
@@ -186,9 +196,16 @@ public class NCApplication extends BaseNCApplication {
HttpServer apiServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(),
externalProperties.getNcApiPort(), config);
apiServer.setAttribute(ServletConstants.SERVICE_CONTEXT_ATTR, ncServiceCtx);
+ apiServer.setAttribute(HYRACKS_CONNECTION_ATTR, getApplicationContext().getHcc());
apiServer.addServlet(new StorageApiServlet(apiServer.ctx(), getApplicationContext(), Servlets.STORAGE));
apiServer.addServlet(
new NetDiagnosticsApiServlet(apiServer.ctx(), getApplicationContext(), Servlets.NET_DIAGNOSTICS));
+ final ILangCompilationProvider sqlppCompilationProvider =
+ ncExtensionManager.getCompilationProvider(ILangExtension.Language.SQLPP);
+ apiServer.addServlet(new NCQueryServiceServlet(apiServer.ctx(), new String[] { QUERY_SERVICE },
+ getApplicationContext(), sqlppCompilationProvider.getLanguage(), sqlppCompilationProvider, null));
+ apiServer.addServlet(new QueryStatusApiServlet(apiServer.ctx(), getApplicationContext(), QUERY_STATUS));
+ apiServer.addServlet(new QueryResultApiServlet(apiServer.ctx(), getApplicationContext(), QUERY_RESULT));
webManager.add(apiServer);
}
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index 5d5abdf..ab8f172 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -162,6 +162,7 @@ public class TestExecutor {
private static final HashMap<Integer, ITestServer> runningTestServers = new HashMap<>();
private static Map<String, InetSocketAddress> ncEndPoints;
+ private static List<InetSocketAddress> ncEndPointsList = new ArrayList<>();
private static Map<String, InetSocketAddress> replicationAddress;
private final List<Charset> allCharsets;
@@ -202,6 +203,7 @@ public class TestExecutor {
public void setNcEndPoints(Map<String, InetSocketAddress> ncEndPoints) {
this.ncEndPoints = ncEndPoints;
+ ncEndPointsList.addAll(ncEndPoints.values());
}
public void setNcReplicationAddress(Map<String, InetSocketAddress> replicationAddress) {
@@ -1799,7 +1801,10 @@ public class TestExecutor {
protected URI createEndpointURI(String path, String query) throws URISyntaxException {
InetSocketAddress endpoint;
- if (isCcEndPointPath(path)) {
+ if (!ncEndPointsList.isEmpty() && path.equals(Servlets.QUERY_SERVICE)) {
+ int endpointIdx = Math.abs(endpointSelector++ % ncEndPointsList.size());
+ endpoint = ncEndPointsList.get(endpointIdx);
+ } else if (isCcEndPointPath(path)) {
int endpointIdx = Math.abs(endpointSelector++ % endpoints.size());
endpoint = endpoints.get(endpointIdx);
} else {
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SqlppExecutionTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SqlppExecutionTest.java
index f9f57a3..d34eccd 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SqlppExecutionTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SqlppExecutionTest.java
@@ -18,10 +18,16 @@
*/
package org.apache.asterix.test.runtime;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.asterix.common.api.INcApplicationContext;
import org.apache.asterix.test.common.TestExecutor;
import org.apache.asterix.testframework.context.TestCaseContext;
+import org.apache.hyracks.control.nc.NodeControllerService;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,7 +44,9 @@ public class SqlppExecutionTest {
@BeforeClass
public static void setUp() throws Exception {
- LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME, new TestExecutor());
+ final TestExecutor testExecutor = new TestExecutor();
+ LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME, testExecutor);
+ setNcEndpoints(testExecutor);
}
@AfterClass
@@ -61,4 +69,17 @@ public class SqlppExecutionTest {
public void test() throws Exception {
LangExecutionUtil.test(tcCtx);
}
+
+ private static void setNcEndpoints(TestExecutor testExecutor) {
+ final NodeControllerService[] ncs = ExecutionTestUtil.integrationUtil.ncs;
+ final Map<String, InetSocketAddress> ncEndPoints = new HashMap<>();
+ final String ip = InetAddress.getLoopbackAddress().getHostAddress();
+ for (NodeControllerService nc : ncs) {
+ final String nodeId = nc.getId();
+ final INcApplicationContext appCtx = (INcApplicationContext) nc.getApplicationContext();
+ int apiPort = appCtx.getExternalProperties().getNcApiPort();
+ ncEndPoints.put(nodeId, InetSocketAddress.createUnresolved(ip, apiPort));
+ }
+ testExecutor.setNcEndPoints(ncEndPoints);
+ }
}