Murtadha Hubail has submitted this change and it was merged. ( https://asterix-gerrit.ics.uci.edu/3388 )
Change subject: [ASTERIXDB-2563][API] Allow All Nodes To Receive Queries ...................................................................... [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 <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Till Westmann <[email protected]> --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SqlppExecutionTest.java 3 files changed, 45 insertions(+), 2 deletions(-) Approvals: Jenkins: Verified; Verified Anon. E. Moose (1000171): Till Westmann: Looks good to me, approved Objections: Jenkins: Violations found 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.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 @@ 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 @@ 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 void setNcEndPoints(Map<String, InetSocketAddress> ncEndPoints) { this.ncEndPoints = ncEndPoints; + ncEndPointsList.addAll(ncEndPoints.values()); } public void setNcReplicationAddress(Map<String, InetSocketAddress> replicationAddress) { @@ -1799,7 +1801,10 @@ 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 @@ @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 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); + } } -- To view, visit https://asterix-gerrit.ics.uci.edu/3388 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I31f7937d46b4532c30e2201b3e434e62e5c4a4de Gerrit-Change-Number: 3388 Gerrit-PatchSet: 4 Gerrit-Owner: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[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]>
