You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by GitBox <gi...@apache.org> on 2019/11/10 02:00:42 UTC

[GitHub] [submarine] liuxunorg commented on a change in pull request #87: SUBMARINE-267. Initial job server which defines REST skeleton

liuxunorg commented on a change in pull request #87: SUBMARINE-267. Initial job server which defines REST skeleton
URL: https://github.com/apache/submarine/pull/87#discussion_r344469025
 
 

 ##########
 File path: submarine-server/server-core/src/main/java/org/apache/submarine/jobserver/JobServer.java
 ##########
 @@ -0,0 +1,165 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.submarine.jobserver;
+
+
+import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.SecureRequestCustomizer;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
+import org.glassfish.jersey.servlet.ServletContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.submarine.commons.utils.SubmarineConfiguration;
+
+
+/**
+ * The ml job server. It will load the classes in rest package when
+ * bootstrap with related configurable settings.
+ * */
+public class JobServer {
+
+  private static final Logger LOG = LoggerFactory.getLogger(JobServer.class);
+
+  private SubmarineConfiguration conf = SubmarineConfiguration.create();
+
+  private Server jobServer;
+
+  public void start() {
+    ServletContextHandler context = new
+        ServletContextHandler(ServletContextHandler.SESSIONS);
+    context.setContextPath("/");
+    setupServer(conf);;
+    jobServer.setHandler(context);
+
+    // Job API servlet
+    ServletHolder apiServlet = context.addServlet(ServletContainer.class,
+        conf.getJobServerUrlPrefix());
+    apiServlet.setInitOrder(1);
+    apiServlet.setInitParameter("jersey.config.server.provider.packages",
+        "org.apache.submarine.jobserver.rest");
+
+    try {
+      jobServer.start();
+      LOG.info("Submarine job server started");
+      jobServer.join();
+    } catch (Exception e) {
+      LOG.info("Submarine job server failed to start");
+      e.printStackTrace();
 
 Review comment:
   Change to LOG.error(...)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org