You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2018/06/01 12:44:47 UTC

[19/26] asterixdb git commit: [NO ISSUE] Load asterix-dashboard via service provider

[NO ISSUE] Load asterix-dashboard via service provider

Change-Id: I0a5005cb8cfedf7ce2f59e76636f9dd21a0cc151
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2664
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/0a7c5661
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/0a7c5661
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/0a7c5661

Branch: refs/heads/master
Commit: 0a7c5661d369b89a139517201def6a02d6774b91
Parents: 3ae6ef0
Author: Michael Blow <mb...@apache.org>
Authored: Mon May 28 09:26:52 2018 -0400
Committer: Michael Blow <mb...@apache.org>
Committed: Tue May 29 09:05:09 2018 -0700

----------------------------------------------------------------------
 asterixdb/asterix-app/pom.xml                   |  5 ----
 .../hyracks/bootstrap/CCApplication.java        |  7 +++--
 .../api/http/IQueryWebServerRegistrant.java     | 22 ++++++++++++++
 .../asterix/api/http/IServletRegistrant.java    | 26 ++++++++++++++++
 .../api/http/QueryWebServerRegistrant.java      | 22 ++++++++++++++
 .../http/server/QueryWebInterfaceServlet.java   |  2 +-
 .../QueryWebInterfaceServletRegistrant.java     | 31 ++++++++++++++++++++
 ...e.asterix.api.http.IQueryWebServerRegistrant | 19 ++++++++++++
 asterixdb/asterix-server/pom.xml                |  6 ++++
 9 files changed, 132 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-app/pom.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/pom.xml b/asterixdb/asterix-app/pom.xml
index 020bc6c..f06b6d2 100644
--- a/asterixdb/asterix-app/pom.xml
+++ b/asterixdb/asterix-app/pom.xml
@@ -387,11 +387,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.asterix</groupId>
-      <artifactId>asterix-dashboard</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.asterix</groupId>
       <artifactId>asterix-common</artifactId>
       <version>${project.version}</version>
       <type>test-jar</type>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
index 699892e..7224526 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
@@ -29,8 +29,10 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.ServiceLoader;
 import java.util.concurrent.ConcurrentMap;
 
+import org.apache.asterix.api.http.IQueryWebServerRegistrant;
 import org.apache.asterix.api.http.ctx.StatementExecutorContext;
 import org.apache.asterix.api.http.server.ActiveStatsApiServlet;
 import org.apache.asterix.api.http.server.ApiServlet;
@@ -46,7 +48,6 @@ import org.apache.asterix.api.http.server.QueryCancellationServlet;
 import org.apache.asterix.api.http.server.QueryResultApiServlet;
 import org.apache.asterix.api.http.server.QueryServiceServlet;
 import org.apache.asterix.api.http.server.QueryStatusApiServlet;
-import org.apache.asterix.api.http.server.QueryWebInterfaceServlet;
 import org.apache.asterix.api.http.server.RebalanceApiServlet;
 import org.apache.asterix.api.http.server.ServletConstants;
 import org.apache.asterix.api.http.server.ShutdownApiServlet;
@@ -272,7 +273,9 @@ public class CCApplication extends BaseCCApplication {
         HttpServer queryWebServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(),
                 externalProperties.getQueryWebInterfacePort());
         queryWebServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-        queryWebServer.addServlet(new QueryWebInterfaceServlet(appCtx, queryWebServer.ctx(), new String[] { "/*" }));
+        ServiceLoader.load(IQueryWebServerRegistrant.class).iterator()
+                .forEachRemaining(c -> c.register(appCtx, queryWebServer));
+
         return queryWebServer;
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IQueryWebServerRegistrant.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IQueryWebServerRegistrant.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IQueryWebServerRegistrant.java
new file mode 100644
index 0000000..c05396a
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IQueryWebServerRegistrant.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.api.http;
+
+public interface IQueryWebServerRegistrant extends IServletRegistrant {
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IServletRegistrant.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IServletRegistrant.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IServletRegistrant.java
new file mode 100644
index 0000000..f6f2b3e
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/IServletRegistrant.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.api.http;
+
+import org.apache.asterix.common.dataflow.ICcApplicationContext;
+import org.apache.hyracks.http.server.HttpServer;
+
+public interface IServletRegistrant {
+    void register(ICcApplicationContext appCtx, HttpServer webServer);
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/QueryWebServerRegistrant.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/QueryWebServerRegistrant.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/QueryWebServerRegistrant.java
new file mode 100644
index 0000000..a33d6ce
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/api/http/QueryWebServerRegistrant.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.api.http;
+
+public interface QueryWebServerRegistrant extends IServletRegistrant {
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServlet.java b/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServlet.java
index 598d802..91b22e9 100644
--- a/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServlet.java
+++ b/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServlet.java
@@ -40,7 +40,7 @@ public class QueryWebInterfaceServlet extends StaticResourceServlet {
     private static final Logger LOGGER = LogManager.getLogger();
     private ICcApplicationContext appCtx;
 
-    public QueryWebInterfaceServlet(ICcApplicationContext appCtx, ConcurrentMap<String, Object> ctx, String[] paths) {
+    QueryWebInterfaceServlet(ICcApplicationContext appCtx, ConcurrentMap<String, Object> ctx, String... paths) {
         super(ctx, paths);
         this.appCtx = appCtx;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServletRegistrant.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServletRegistrant.java b/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServletRegistrant.java
new file mode 100644
index 0000000..5cc462e
--- /dev/null
+++ b/asterixdb/asterix-dashboard/src/main/java/org/apache/asterix/api/http/server/QueryWebInterfaceServletRegistrant.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.api.http.server;
+
+import org.apache.asterix.api.http.IQueryWebServerRegistrant;
+import org.apache.asterix.common.dataflow.ICcApplicationContext;
+import org.apache.hyracks.http.server.HttpServer;
+
+public class QueryWebInterfaceServletRegistrant implements IQueryWebServerRegistrant {
+
+    @Override
+    public void register(ICcApplicationContext appCtx, HttpServer webServer) {
+        webServer.addServlet(new QueryWebInterfaceServlet(appCtx, webServer.ctx(), "/*"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-dashboard/src/main/resources/META-INF/services/org.apache.asterix.api.http.IQueryWebServerRegistrant
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-dashboard/src/main/resources/META-INF/services/org.apache.asterix.api.http.IQueryWebServerRegistrant b/asterixdb/asterix-dashboard/src/main/resources/META-INF/services/org.apache.asterix.api.http.IQueryWebServerRegistrant
new file mode 100644
index 0000000..7d23f78
--- /dev/null
+++ b/asterixdb/asterix-dashboard/src/main/resources/META-INF/services/org.apache.asterix.api.http.IQueryWebServerRegistrant
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.asterix.api.http.server.QueryWebInterfaceServletRegistrant
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a7c5661/asterixdb/asterix-server/pom.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-server/pom.xml b/asterixdb/asterix-server/pom.xml
index d014d2b..71bd35e 100644
--- a/asterixdb/asterix-server/pom.xml
+++ b/asterixdb/asterix-server/pom.xml
@@ -402,6 +402,7 @@
             <usedDependency>org.apache.asterix:asterix-external-data</usedDependency>
             <usedDependency>org.codehaus.mojo.appassembler:appassembler-booter</usedDependency>
             <usedDependency>org.apache.asterix:asterix-fuzzyjoin</usedDependency>
+            <usedDependency>org.apache.asterix:asterix-dashboard</usedDependency>
           </usedDependencies>
         </configuration>
       </plugin>
@@ -655,5 +656,10 @@
       <artifactId>hyracks-test-support</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.asterix</groupId>
+      <artifactId>asterix-dashboard</artifactId>
+      <version>${project.version}</version>
+    </dependency>
   </dependencies>
 </project>