This is an automated email from the ASF dual-hosted git repository.

ztang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 5053e66  [SUBMARINE-192] Submarine workbench server daemon shell script
5053e66 is described below

commit 5053e66dc51b06ff70599fa53675786712c9b42a
Author: Xun Liu <[email protected]>
AuthorDate: Sat Sep 28 22:48:54 2019 +0800

    [SUBMARINE-192] Submarine workbench server daemon shell script
    
    ### What is this PR for?
    Increase the Submarine workbench server daemon script,
    Support to start, stop, restart the submarine workbench server through 
`submarine-daemon.sh`
    
    ```
    ./bin/workbench-daemon.sh [start|stop|restart]
    ```
    
    ### What type of PR is it?
    [Feature]
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/SUBMARINE-192
    
    ### How should this be tested?
    * [CI 
Pass](https://travis-ci.org/liuxunorg/hadoop-submarine/builds/590699956)
    
    ### Screenshots (if appropriate)
    
    
![workbench-daemon-sh](https://user-images.githubusercontent.com/3677382/65811462-2d97d480-e1eb-11e9-87fc-80a7fadab209.gif)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? Yes
    
    Author: Xun Liu <[email protected]>
    
    Closes #20 from liuxunorg/SUBMARINE-192 and squashes the following commits:
    
    07d33e0 [Xun Liu] fixed shell script error.
    d48d8ad [Xun Liu] [SUBMARINE-192] Submarine server daemon shell script
---
 bin/common.sh                                      |  76 ++++++++++
 bin/workbench-daemon.sh                            | 160 +++++++++++++++++++++
 conf/submarine-env.sh.template                     |  22 +++
 {dev-support/bin => conf}/submarine-site.xml       |  64 +++------
 .../submarine-site.xml.template                    |  64 +++------
 dev-support/bin/submarine-daemon.sh                |  22 ---
 docs/README.md                                     |   4 +
 docs/workbench/README.md                           |  67 +++++++++
 submarine-dist/pom.xml                             |   6 -
 submarine-dist/src/assembly/distribution.xml       |  22 ++-
 submarine-workbench/workbench-server/pom.xml       |   6 +
 .../org/apache/submarine/database/MyBatisUtil.java |   6 +-
 ...figuration.java => SubmarineConfiguration.java} |  34 ++---
 .../apache/submarine/server/WorkbenchServer.java   |  25 ++--
 submarine-workbench/workbench-web/pom.xml          |   1 +
 15 files changed, 423 insertions(+), 156 deletions(-)

diff --git a/bin/common.sh b/bin/common.sh
new file mode 100755
index 0000000..5a45dd1
--- /dev/null
+++ b/bin/common.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# 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.
+#
+
+if [[ -L ${BASH_SOURCE-$0} ]]; then
+  FWDIR=$(dirname $(readlink "${BASH_SOURCE-$0}"))
+else
+  FWDIR=$(dirname "${BASH_SOURCE-$0}")
+fi
+
+if [[ -z "${SUBMARINE_HOME}" ]]; then
+  # Make SUBMARINE_HOME look cleaner in logs by getting rid of the
+  # extra ../
+  export SUBMARINE_HOME="$(cd "${FWDIR}/.."; pwd)"
+fi
+
+if [[ -z "${SUBMARINE_CONF_DIR}" ]]; then
+  export SUBMARINE_CONF_DIR="${SUBMARINE_HOME}/conf"
+fi
+
+if [[ -z "${SUBMARINE_LOG_DIR}" ]]; then
+  export SUBMARINE_LOG_DIR="${SUBMARINE_HOME}/logs"
+fi
+
+if [[ -f "${SUBMARINE_CONF_DIR}/submarine-env.sh" ]]; then
+  . "${SUBMARINE_CONF_DIR}/submarine-env.sh"
+fi
+
+WORKBENCH_CLASSPATH+=":${SUBMARINE_CONF_DIR}"
+
+function add_each_jar_in_dir(){
+  if [[ -d "${1}" ]]; then
+    for jar in $(find -L "${1}" -maxdepth 1 -name '*jar'); do
+      WORKBENCH_CLASSPATH="$jar:$WORKBENCH_CLASSPATH"
+    done
+  fi
+}
+
+function add_each_jar_in_dir_recursive(){
+  if [[ -d "${1}" ]]; then
+    for jar in $(find -L "${1}" -type f -name '*jar'); do
+      WORKBENCH_CLASSPATH="$jar:$WORKBENCH_CLASSPATH"
+    done
+  fi
+}
+
+function add_jar_in_dir(){
+  if [[ -d "${1}" ]]; then
+    WORKBENCH_CLASSPATH="${1}/*:${WORKBENCH_CLASSPATH}"
+  fi
+}
+
+JAVA_OPTS+=" ${WORKBENCH_JAVA_OPTS} -Dfile.encoding=UTF-8 ${WORKBENCH_MEM}"
+JAVA_OPTS+=" 
-Dlog4j.configuration=file://${SUBMARINE_CONF_DIR}/log4j.properties"
+export JAVA_OPTS
+
+if [[ -n "${JAVA_HOME}" ]]; then
+  JAVA_RUNNER="${JAVA_HOME}/bin/java"
+else
+  JAVA_RUNNER=java
+fi
+export JAVA_RUNNER
diff --git a/bin/workbench-daemon.sh b/bin/workbench-daemon.sh
new file mode 100755
index 0000000..7a03821
--- /dev/null
+++ b/bin/workbench-daemon.sh
@@ -0,0 +1,160 @@
+#!/bin/bash
+#
+# 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.
+#
+# description: Start and stop daemon script for.
+#
+
+USAGE="-e Usage: workbench-daemon.sh {start|stop|restart|status}"
+
+if [ -L ${BASH_SOURCE-$0} ]; then
+  BIN=$(dirname $(readlink "${BASH_SOURCE-$0}"))
+else
+  BIN=$(dirname ${BASH_SOURCE-$0})
+fi
+BIN=$(cd "${BIN}">/dev/null; pwd)
+
+. "${BIN}/common.sh"
+
+WORKBENCH_NAME="Submarine Workbench"
+WORKBENCH_LOGFILE="${SUBMARINE_LOG_DIR}/workbench.log"
+WORKBENCH_MAIN=org.apache.submarine.server.WorkbenchServer
+JAVA_OPTS+=" -Dworkbench.log.file=${WORKBENCH_LOGFILE}"
+
+add_jar_in_dir "${BIN}/../workbench"
+add_jar_in_dir "${BIN}/../workbench/lib"
+
+function initialize_default_directories() {
+  if [[ ! -d "${SUBMARINE_LOG_DIR}" ]]; then
+    echo "Log dir doesn't exist, create ${SUBMARINE_LOG_DIR}"
+    $(mkdir -p "${SUBMARINE_LOG_DIR}")
+  fi
+}
+
+function found_workbench_server_pid() {
+  process='WorkbenchServer';
+  RUNNING_PIDS=$(ps x | grep ${process} | grep -v grep | awk '{print $1}');
+
+  if [[ -z "${RUNNING_PIDS}" ]]; then
+    return
+  fi
+
+  if ! kill -0 ${RUNNING_PIDS} > /dev/null 2>&1; then
+    echo "${WORKBENCH_NAME} running but process is dead"
+  fi
+
+  echo "${RUNNING_PIDS}"
+}
+
+function wait_for_workbench_to_die() {
+  local pid
+  local count
+
+  pid=`found_workbench_server_pid`
+  timeout=10
+  count=0
+  timeoutTime=$(date "+%s")
+  let "timeoutTime+=$timeout"
+  currentTime=$(date "+%s")
+  forceKill=1
+
+  while [[ $currentTime -lt $timeoutTime ]]; do
+    $(kill ${pid} > /dev/null 2> /dev/null)
+    if kill -0 ${pid} > /dev/null 2>&1; then
+      sleep 3
+    else
+      forceKill=0
+      break
+    fi
+    currentTime=$(date "+%s")
+  done
+
+  if [[ forceKill -ne 0 ]]; then
+    $(kill -9 ${pid} > /dev/null 2> /dev/null)
+  fi
+}
+
+function start() {
+  local pid
+
+  pid=`found_workbench_server_pid`
+  if [[ ! -z "$pid" && "$pid" != 0 ]]; then
+    echo "${WORKBENCH_NAME}:${pid} is already running"
+    return 0;
+  fi
+
+  initialize_default_directories
+
+  echo "WORKBENCH_CLASSPATH: ${WORKBENCH_CLASSPATH}" >> "${WORKBENCH_LOGFILE}"
+
+  nohup $JAVA_RUNNER $JAVA_OPTS -cp $WORKBENCH_CLASSPATH $WORKBENCH_MAIN >> 
"${WORKBENCH_LOGFILE}" 2>&1 < /dev/null &
+  pid=$!
+  if [[ ! -z "${pid}" ]]; then
+    echo "${WORKBENCH_NAME} start"
+    return 1;
+  fi
+}
+
+function stop() {
+  local pid
+  pid=`found_workbench_server_pid`
+
+  if [[ -z "$pid" ]]; then
+    echo "${WORKBENCH_NAME} is not running"
+    return 0;
+  else
+    # submarine workbench daemon kill
+    wait_for_workbench_to_die
+    echo "${WORKBENCH_NAME} stop"
+  fi
+}
+
+function find_workbench_process() {
+  local pid
+  pid=`found_workbench_server_pid`
+
+  if [[ -z "$pid" ]]; then
+    if ! kill -0 ${pid} > /dev/null 2>&1; then
+      echo "${WORKBENCH_NAME} running but process is dead"
+      return 1
+    else
+      echo "${WORKBENCH_NAME} is running"
+    fi
+  else
+    echo "${WORKBENCH_NAME} is not running"
+    return 1
+  fi
+}
+
+case "${1}" in
+  start)
+    start
+    ;;
+  stop)
+    stop
+    ;;
+  restart)
+    echo "${WORKBENCH_NAME} is restarting" >> "${WORKBENCH_LOGFILE}"
+    stop
+    start
+    ;;
+  status)
+    find_workbench_process
+    ;;
+  *)
+    echo ${USAGE}
+esac
diff --git a/conf/submarine-env.sh.template b/conf/submarine-env.sh.template
new file mode 100644
index 0000000..71aa272
--- /dev/null
+++ b/conf/submarine-env.sh.template
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# 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.
+#
+
+# export JAVA_HOME=java
+
+# export WORKBENCH_JAVA_OPTS
+# export WORKBENCH_MEM="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m"
diff --git a/dev-support/bin/submarine-site.xml b/conf/submarine-site.xml
similarity index 61%
copy from dev-support/bin/submarine-site.xml
copy to conf/submarine-site.xml
index 7a0267e..9dcf028 100755
--- a/dev-support/bin/submarine-site.xml
+++ b/conf/submarine-site.xml
@@ -20,113 +20,85 @@
 <configuration>
 
   <property>
-    <name>submarine.server.addr</name>
+    <name>workbench.server.addr</name>
     <value>0.0.0.0</value>
     <description>Server address</description>
   </property>
 
   <property>
-    <name>submarine.server.port</name>
+    <name>workbench.server.port</name>
     <value>8080</value>
     <description>Server port.</description>
   </property>
 
   <property>
-    <name>submarine.ssl</name>
+    <name>workbench.ssl</name>
     <value>false</value>
-    <description>Should SSL be used by the servers?</description>
+    <description>Should SSL be used by the workbench servers?</description>
   </property>
 
   <property>
-    <name>submarine.server.ssl.port</name>
+    <name>workbench.server.ssl.port</name>
     <value>8443</value>
     <description>Server ssl port. (used when ssl property is set to 
true)</description>
   </property>
 
   <property>
-    <name>submarine.server.context.path</name>
-    <value>/</value>
-    <description>Context Path of the Web Application</description>
-  </property>
-
-  <property>
-    <name>submarine.war.tempdir</name>
-    <value>webapps</value>
-    <description>Location of jetty temporary directory</description>
-  </property>
-
-  <property>
-    <name>submarine.ssl.client.auth</name>
+    <name>workbench.ssl.client.auth</name>
     <value>false</value>
     <description>Should client authentication be used for SSL 
connections?</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.path</name>
+    <name>workbench.ssl.keystore.path</name>
     <value>keystore</value>
     <description>Path to keystore relative to submarine configuration 
directory</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.type</name>
+    <name>workbench.ssl.keystore.type</name>
     <value>JKS</value>
     <description>The format of the given keystore (e.g. JKS or 
PKCS12)</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.password</name>
+    <name>workbench.ssl.keystore.password</name>
     <value>change me</value>
     <description>Keystore password. Can be obfuscated by the Jetty Password 
tool</description>
   </property>
 
   <!--
   <property>
-    <name>submarine.ssl.key.manager.password</name>
+    <name>workbench.ssl.key.manager.password</name>
     <value>change me</value>
     <description>Key Manager password. Defaults to keystore password. Can be 
obfuscated.</description>
   </property>
   -->
 
   <property>
-    <name>submarine.ssl.truststore.path</name>
+    <name>workbench.ssl.truststore.path</name>
     <value>truststore</value>
-    <description>Path to truststore relative to submarine configuration 
directory. Defaults to the keystore path
-    </description>
+    <description>Path to truststore relative to submarine configuration 
directory. Defaults to the keystore path</description>
   </property>
 
   <property>
-    <name>submarine.ssl.truststore.type</name>
+    <name>workbench.ssl.truststore.type</name>
     <value>JKS</value>
-    <description>The format of the given truststore (e.g. JKS or PKCS12). 
Defaults to the same type as the keystore
-      type
-    </description>
+    <description>The format of the given truststore (e.g. JKS or PKCS12). 
Defaults to the same type as the keystore type</description>
   </property>
 
   <!--
   <property>
-    <name>submarine.ssl.truststore.password</name>
+    <name>workbench.ssl.truststore.password</name>
     <value>change me</value>
     <description>Truststore password. Can be obfuscated by the Jetty Password 
tool. Defaults to the keystore password</description>
   </property>
   -->
 
   <property>
-    <name>submarine.websocket.max.text.message.size</name>
-    <value>1024000</value>
-    <description>Size in characters of the maximum text message to be received 
by websocket. Defaults to 1024000
-    </description>
-  </property>
-
-  <property>
-    <name>submarine.server.default.dir.allowed</name>
-    <value>false</value>
-    <description>Enable directory listings on server.</description>
-  </property>
-
-  <property>
-    <name>submarine.run.mode</name>
-    <value>auto</value>
-    <description>'auto|local|k8s|docker'</description>
+    <name>workbench.web.war</name>
+    <value>workbench/workbench-web.war</value>
+    <description>Submarine workbench web war file path.</description>
   </property>
 
 </configuration>
diff --git a/dev-support/bin/submarine-site.xml 
b/conf/submarine-site.xml.template
similarity index 61%
rename from dev-support/bin/submarine-site.xml
rename to conf/submarine-site.xml.template
index 7a0267e..9dcf028 100755
--- a/dev-support/bin/submarine-site.xml
+++ b/conf/submarine-site.xml.template
@@ -20,113 +20,85 @@
 <configuration>
 
   <property>
-    <name>submarine.server.addr</name>
+    <name>workbench.server.addr</name>
     <value>0.0.0.0</value>
     <description>Server address</description>
   </property>
 
   <property>
-    <name>submarine.server.port</name>
+    <name>workbench.server.port</name>
     <value>8080</value>
     <description>Server port.</description>
   </property>
 
   <property>
-    <name>submarine.ssl</name>
+    <name>workbench.ssl</name>
     <value>false</value>
-    <description>Should SSL be used by the servers?</description>
+    <description>Should SSL be used by the workbench servers?</description>
   </property>
 
   <property>
-    <name>submarine.server.ssl.port</name>
+    <name>workbench.server.ssl.port</name>
     <value>8443</value>
     <description>Server ssl port. (used when ssl property is set to 
true)</description>
   </property>
 
   <property>
-    <name>submarine.server.context.path</name>
-    <value>/</value>
-    <description>Context Path of the Web Application</description>
-  </property>
-
-  <property>
-    <name>submarine.war.tempdir</name>
-    <value>webapps</value>
-    <description>Location of jetty temporary directory</description>
-  </property>
-
-  <property>
-    <name>submarine.ssl.client.auth</name>
+    <name>workbench.ssl.client.auth</name>
     <value>false</value>
     <description>Should client authentication be used for SSL 
connections?</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.path</name>
+    <name>workbench.ssl.keystore.path</name>
     <value>keystore</value>
     <description>Path to keystore relative to submarine configuration 
directory</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.type</name>
+    <name>workbench.ssl.keystore.type</name>
     <value>JKS</value>
     <description>The format of the given keystore (e.g. JKS or 
PKCS12)</description>
   </property>
 
   <property>
-    <name>submarine.ssl.keystore.password</name>
+    <name>workbench.ssl.keystore.password</name>
     <value>change me</value>
     <description>Keystore password. Can be obfuscated by the Jetty Password 
tool</description>
   </property>
 
   <!--
   <property>
-    <name>submarine.ssl.key.manager.password</name>
+    <name>workbench.ssl.key.manager.password</name>
     <value>change me</value>
     <description>Key Manager password. Defaults to keystore password. Can be 
obfuscated.</description>
   </property>
   -->
 
   <property>
-    <name>submarine.ssl.truststore.path</name>
+    <name>workbench.ssl.truststore.path</name>
     <value>truststore</value>
-    <description>Path to truststore relative to submarine configuration 
directory. Defaults to the keystore path
-    </description>
+    <description>Path to truststore relative to submarine configuration 
directory. Defaults to the keystore path</description>
   </property>
 
   <property>
-    <name>submarine.ssl.truststore.type</name>
+    <name>workbench.ssl.truststore.type</name>
     <value>JKS</value>
-    <description>The format of the given truststore (e.g. JKS or PKCS12). 
Defaults to the same type as the keystore
-      type
-    </description>
+    <description>The format of the given truststore (e.g. JKS or PKCS12). 
Defaults to the same type as the keystore type</description>
   </property>
 
   <!--
   <property>
-    <name>submarine.ssl.truststore.password</name>
+    <name>workbench.ssl.truststore.password</name>
     <value>change me</value>
     <description>Truststore password. Can be obfuscated by the Jetty Password 
tool. Defaults to the keystore password</description>
   </property>
   -->
 
   <property>
-    <name>submarine.websocket.max.text.message.size</name>
-    <value>1024000</value>
-    <description>Size in characters of the maximum text message to be received 
by websocket. Defaults to 1024000
-    </description>
-  </property>
-
-  <property>
-    <name>submarine.server.default.dir.allowed</name>
-    <value>false</value>
-    <description>Enable directory listings on server.</description>
-  </property>
-
-  <property>
-    <name>submarine.run.mode</name>
-    <value>auto</value>
-    <description>'auto|local|k8s|docker'</description>
+    <name>workbench.web.war</name>
+    <value>workbench/workbench-web.war</value>
+    <description>Submarine workbench web war file path.</description>
   </property>
 
 </configuration>
diff --git a/dev-support/bin/submarine-daemon.sh 
b/dev-support/bin/submarine-daemon.sh
deleted file mode 100755
index 35fe6aa..0000000
--- a/dev-support/bin/submarine-daemon.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-# description: Start and stop daemon script for.
-#
-
-${JAVA_HOME}/bin/java -cp 
"../../workbench-server/target/workbench-server-0.3.0-SNAPSHOT-shade.jar" 
org.apache.submarine.server.WorkbenchServer
diff --git a/docs/README.md b/docs/README.md
index e89602f..ebba845 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -28,6 +28,10 @@ Click below contents if you want to understand more.
 
 [Apache Hadoop Submarine Community Guide](./community/README.md)
 
+## Submarine Workbench
+
+[Submarine Workbench Guide](./workbench/README.md)
+
 ## Examples
 
 Here're some examples about Submarine usage.
diff --git a/docs/workbench/README.md b/docs/workbench/README.md
new file mode 100644
index 0000000..4ceb071
--- /dev/null
+++ b/docs/workbench/README.md
@@ -0,0 +1,67 @@
+<!--
+   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.
+-->
+# Submarine Workbench
+
+Submarine Workbench is an UI designed for data scientists. 
+Data scientists can interact with Submarine Workbench UI to access notebooks, 
+submit/manage jobs, manage models, create model training workflows, access 
dataset, etc.
+
+## Run Workbench
+
+```$xslt
+cd submarine
+./bin/workbench-daemon.sh [start|stop|restart]
+```
+
+## submarine-env.sh
+
+`submarine-env.sh` is automatically executed each time the `workbench.sh` 
script is executed, so we can set the `workbench.sh` script and the environment 
variables in the `WorkbenchServer` process via `submarine-env.sh`.
+
+| Name                | Variable                                               
      |
+| ------------------- | 
------------------------------------------------------------ |
+| JAVA_HOME           | Set your java home path, default is `java`.            
      |
+| WORKBENCH_JAVA_OPTS | Set the JAVA OPTS parameter when the Workbench process 
starts. If you need to debug the Workbench process, you can set it to 
`-agentlib:jdwp=transport=dt_socket, server=y,suspend=n,address=5005` |
+| WORKBENCH_MEM       | Set the java memory parameter when the Workbench 
process starts. |
+
+## submarine-site.xml
+
+`submarine-site.xml` is the configuration file for the entire `Submarine` 
system to run.
+
+| Name                               | Variable                                
                     |
+| ---------------------------------- | 
------------------------------------------------------------ |
+| workbench.server.addr              | workbench server address, default is 
`0.0.0.0`               |
+| workbench.server.port              | workbench server port, default `8080`   
                     |
+| workbench.ssl                      | Should SSL be used by the workbench 
servers?, default `false` |
+| workbench.server.ssl.port          | Server ssl port. (used when ssl 
property is set to true), default `8483` |
+| workbench.ssl.client.auth          | Should client authentication be used 
for SSL connections?    |
+| workbench.ssl.keystore.path        | Path to keystore relative to submarine 
configuration directory |
+| workbench.ssl.keystore.type        | The format of the given keystore (e.g. 
JKS or PKCS12)        |
+| workbench.ssl.keystore.password    | Keystore password. Can be obfuscated by 
the Jetty Password tool |
+| workbench.ssl.key.manager.password | Key Manager password. Defaults to 
keystore password. Can be obfuscated. |
+| workbench.ssl.truststore.path      | Path to truststore relative to 
submarine configuration directory. Defaults to the keystore path |
+| workbench.ssl.truststore.type      | The format of the given truststore 
(e.g. JKS or PKCS12). Defaults to the same type as the keystore type |
+| workbench.ssl.truststore.password  | Truststore password. Can be obfuscated 
by the Jetty Password tool. Defaults to the keystore password |
+| workbench.web.war                  | Submarine workbench web war file path.  
                     |
+
+
+
+## Compile
+
+[Build From Code Guide](./development/BuildFromCode.md)
+
+```$xslt
+cd 
submarine/submarine-dist/target/submarine-dist-<version>/submarine-dist-<version>/
+./bin/workbench-daemon.sh [start|stop|restart]
+```
diff --git a/submarine-dist/pom.xml b/submarine-dist/pom.xml
index c35f086..35d57bb 100644
--- a/submarine-dist/pom.xml
+++ b/submarine-dist/pom.xml
@@ -50,12 +50,6 @@
       <artifactId>submarine-core</artifactId>
       <version>${project.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.submarine</groupId>
-      <artifactId>workbench-web</artifactId>
-      <version>${project.version}</version>
-      <type>war</type>
-    </dependency>
   </dependencies>
 
   <profiles>
diff --git a/submarine-dist/src/assembly/distribution.xml 
b/submarine-dist/src/assembly/distribution.xml
index 516c233..f656237 100644
--- a/submarine-dist/src/assembly/distribution.xml
+++ b/submarine-dist/src/assembly/distribution.xml
@@ -49,7 +49,7 @@
     <dependencySet>
       <outputDirectory>/workbench</outputDirectory>
       <includes>
-        <include>org.apache.submarine:workbench-web</include>
+        <include>${project.groupId}:workbench-web</include>
       </includes>
     </dependencySet>
   </dependencySets>
@@ -72,6 +72,19 @@
       <directory>../licenses-binary</directory>
       <outputDirectory>/licenses</outputDirectory>
     </fileSet>
+
+    <fileSet>
+      <directory>../conf</directory>
+      <outputDirectory>/conf</outputDirectory>
+      <fileMode>0755</fileMode>
+    </fileSet>
+
+    <fileSet>
+      <directory>../bin</directory>
+      <outputDirectory>/bin</outputDirectory>
+      <fileMode>0755</fileMode>
+    </fileSet>
+
     <fileSet>
       <directory>../submarine-all/target/</directory>
       <outputDirectory>/</outputDirectory>
@@ -80,6 +93,13 @@
       </includes>
     </fileSet>
     <fileSet>
+      <directory>../submarine-workbench/workbench-web/target</directory>
+      <outputDirectory>/workbench</outputDirectory>
+      <includes>
+        <include>workbench-web.war</include>
+      </includes>
+    </fileSet>
+    <fileSet>
       <directory>../submarine-workbench/workbench-server/target</directory>
       <outputDirectory>/workbench</outputDirectory>
       <includes>
diff --git a/submarine-workbench/workbench-server/pom.xml 
b/submarine-workbench/workbench-server/pom.xml
index 9be455e..476a9d8 100644
--- a/submarine-workbench/workbench-server/pom.xml
+++ b/submarine-workbench/workbench-server/pom.xml
@@ -122,6 +122,12 @@
     </dependency>
 
     <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>${commons-collections.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>cglib</groupId>
       <artifactId>cglib</artifactId>
       <version>${cglib.version}</version>
diff --git 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
index 0cb6d8c..1ddad2d 100755
--- 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
+++ 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
@@ -17,7 +17,7 @@ import org.apache.ibatis.io.Resources;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
-import org.apache.submarine.server.WorkbenchConfiguration;
+import org.apache.submarine.server.SubmarineConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,7 +42,7 @@ public class MyBatisUtil {
 
       checkCalledByTestMethod();
 
-      WorkbenchConfiguration conf = WorkbenchConfiguration.create();
+      SubmarineConfiguration conf = SubmarineConfiguration.create();
       String jdbcClassName = conf.getJdbcDriverClassName();
       String jdbcUrl = conf.getJdbcUrl();
       String jdbcUserName = conf.getJdbcUserName();
@@ -90,7 +90,7 @@ public class MyBatisUtil {
   private static void usingTestDatabase() {
     LOG.info("Run the test unit using the test database");
     // Run the test unit using the test database
-    WorkbenchConfiguration conf = WorkbenchConfiguration.create();
+    SubmarineConfiguration conf = SubmarineConfiguration.create();
     conf.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/submarineDB_test?" +
         
"useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true&amp;" +
         
"failOverReadOnly=false&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false");
diff --git 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchConfiguration.java
 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
similarity index 93%
rename from 
submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchConfiguration.java
rename to 
submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
index dd06785..ce1557e 100644
--- 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchConfiguration.java
+++ 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
@@ -27,17 +27,17 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-public class WorkbenchConfiguration extends XMLConfiguration {
-  private static final Logger LOG = 
LoggerFactory.getLogger(WorkbenchConfiguration.class);
+public class SubmarineConfiguration extends XMLConfiguration {
+  private static final Logger LOG = 
LoggerFactory.getLogger(SubmarineConfiguration.class);
   private static final long serialVersionUID = 4749303235693848035L;
 
-  private static final String WORKBENCH_SITE_XML = "workbench-site.xml";
+  private static final String SUBMARINE_SITE_XML = "submarine-site.xml";
 
-  private static WorkbenchConfiguration conf;
+  private static SubmarineConfiguration conf;
 
   private Map<String, String> properties = new HashMap<>();
 
-  public WorkbenchConfiguration(URL url) throws ConfigurationException {
+  public SubmarineConfiguration(URL url) throws ConfigurationException {
     setDelimiterParsingDisabled(true);
     load(url);
     initProperties();
@@ -57,7 +57,7 @@ public class WorkbenchConfiguration extends XMLConfiguration {
     }
   }
 
-  public WorkbenchConfiguration() {
+  public SubmarineConfiguration() {
     ConfVars[] vars = ConfVars.values();
     for (ConfVars v : vars) {
       if (v.getType() == ConfVars.VarType.BOOLEAN) {
@@ -76,7 +76,7 @@ public class WorkbenchConfiguration extends XMLConfiguration {
     }
   }
 
-  public static synchronized WorkbenchConfiguration create() {
+  public static synchronized SubmarineConfiguration create() {
     if (conf != null) {
       return conf;
     }
@@ -84,27 +84,27 @@ public class WorkbenchConfiguration extends 
XMLConfiguration {
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     URL url;
 
-    url = WorkbenchConfiguration.class.getResource(WORKBENCH_SITE_XML);
+    url = SubmarineConfiguration.class.getResource(SUBMARINE_SITE_XML);
     if (url == null) {
-      ClassLoader cl = WorkbenchConfiguration.class.getClassLoader();
+      ClassLoader cl = SubmarineConfiguration.class.getClassLoader();
       if (cl != null) {
-        url = cl.getResource(WORKBENCH_SITE_XML);
+        url = cl.getResource(SUBMARINE_SITE_XML);
       }
     }
     if (url == null) {
-      url = classLoader.getResource(WORKBENCH_SITE_XML);
+      url = classLoader.getResource(SUBMARINE_SITE_XML);
     }
 
     if (url == null) {
       LOG.warn("Failed to load configuration, proceeding with a default");
-      conf = new WorkbenchConfiguration();
+      conf = new SubmarineConfiguration();
     } else {
       try {
         LOG.info("Load configuration from " + url);
-        conf = new WorkbenchConfiguration(url);
+        conf = new SubmarineConfiguration(url);
       } catch (ConfigurationException e) {
         LOG.warn("Failed to load configuration from " + url + " proceeding 
with a default", e);
-        conf = new WorkbenchConfiguration();
+        conf = new SubmarineConfiguration();
       }
     }
 
@@ -115,9 +115,6 @@ public class WorkbenchConfiguration extends 
XMLConfiguration {
       LOG.info("Server SSL Port: " + conf.getServerSslPort());
     }
 
-    // LOG.info("Context Path: " + conf.getServerContextPath());
-    // LOG.info("Submarine Version: " + Util.getVersion());
-
     return conf;
   }
 
@@ -377,8 +374,7 @@ public class WorkbenchConfiguration extends 
XMLConfiguration {
         
"failOverReadOnly=false&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"),
     JDBC_USERNAME("jdbc.username", "submarine"),
     JDBC_PASSWORD("jdbc.password", "password"),
-    SUBMARINE_WAR("workbench.war", "submarine-workbench/workbench-web/dist"),
-    WAR_TEMPDIR("workbench.war.tempdir", "webapps");
+    WORKBENCH_WEB_WAR("workbench.web.war", 
"submarine-workbench/workbench-web/dist");
 
     private String varName;
     @SuppressWarnings("rawtypes")
diff --git 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchServer.java
 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchServer.java
index 304c60a..099edc2 100644
--- 
a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchServer.java
+++ 
b/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/WorkbenchServer.java
@@ -33,7 +33,7 @@ import org.glassfish.jersey.server.ResourceConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.submarine.server.WorkbenchConfiguration.ConfVars;
+import org.apache.submarine.server.SubmarineConfiguration.ConfVars;
 
 import javax.inject.Inject;
 import java.io.File;
@@ -43,12 +43,12 @@ public class WorkbenchServer extends ResourceConfig {
 
   public static Server jettyWebServer;
 
-  private static WorkbenchConfiguration conf = WorkbenchConfiguration.create();
+  private static SubmarineConfiguration conf = SubmarineConfiguration.create();
 
   public static void main(String[] args) throws InterruptedException {
     
PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));
 
-    final WorkbenchConfiguration conf = WorkbenchConfiguration.create();
+    final SubmarineConfiguration conf = SubmarineConfiguration.create();
 
     jettyWebServer = setupJettyServer(conf);
 
@@ -95,7 +95,7 @@ public class WorkbenchServer extends ResourceConfig {
     jettyWebServer.join();
   }
 
-  private static void setupRestApiContextHandler(WebAppContext webapp, 
WorkbenchConfiguration conf) {
+  private static void setupRestApiContextHandler(WebAppContext webapp, 
SubmarineConfiguration conf) {
     final ServletHolder servletHolder =
         new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer());
 
@@ -107,10 +107,11 @@ public class WorkbenchServer extends ResourceConfig {
   }
 
   private static WebAppContext setupWebAppContext(ContextHandlerCollection 
contexts,
-                                                  WorkbenchConfiguration conf) 
{
+                                                  SubmarineConfiguration conf) 
{
     WebAppContext webApp = new WebAppContext();
     webApp.setContextPath("/");
-    File warPath = new File(conf.getString(ConfVars.SUBMARINE_WAR));
+    File warPath = new File(conf.getString(ConfVars.WORKBENCH_WEB_WAR));
+    LOG.info("workbench web war file path is {}.", 
conf.getString(ConfVars.WORKBENCH_WEB_WAR));
     if (warPath.isDirectory()) {
       // Development mode, read from FS
       // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
@@ -119,9 +120,8 @@ public class WorkbenchServer extends ResourceConfig {
     } else {
       // use packaged WAR
       webApp.setWar(warPath.getAbsolutePath());
-      File warTempDirectory = new 
File(conf.getRelativeDir(ConfVars.WAR_TEMPDIR));
+      File warTempDirectory = new File("webapps");
       warTempDirectory.mkdir();
-      LOG.info("submarineServer Webapp path: {}", warTempDirectory.getPath());
       webApp.setTempDirectory(warTempDirectory);
     }
     // Explicit bind to root
@@ -131,7 +131,7 @@ public class WorkbenchServer extends ResourceConfig {
     return webApp;
   }
 
-  private static Server setupJettyServer(WorkbenchConfiguration conf) {
+  private static Server setupJettyServer(SubmarineConfiguration conf) {
     ThreadPool threadPool =
         new 
QueuedThreadPool(conf.getInt(ConfVars.SERVER_JETTY_THREAD_POOL_MAX),
             conf.getInt(ConfVars.SERVER_JETTY_THREAD_POOL_MIN),
@@ -152,8 +152,7 @@ public class WorkbenchServer extends ResourceConfig {
       SecureRequestCustomizer src = new SecureRequestCustomizer();
       httpsConfig.addCustomizer(src);
 
-      connector =
-          new ServerConnector(
+      connector = new ServerConnector(
               server,
               new SslConnectionFactory(getSslContextFactory(conf), 
HttpVersion.HTTP_1_1.asString()),
               new HttpConnectionFactory(httpsConfig));
@@ -178,7 +177,7 @@ public class WorkbenchServer extends ResourceConfig {
     return server;
   }
 
-  private static SslContextFactory getSslContextFactory(WorkbenchConfiguration 
conf) {
+  private static SslContextFactory getSslContextFactory(SubmarineConfiguration 
conf) {
     SslContextFactory sslContextFactory = new SslContextFactory();
 
     // Set keystore
@@ -200,7 +199,7 @@ public class WorkbenchServer extends ResourceConfig {
   }
 
   private static void configureRequestHeaderSize(
-      WorkbenchConfiguration conf, ServerConnector connector) {
+      SubmarineConfiguration conf, ServerConnector connector) {
     HttpConnectionFactory cf =
         (HttpConnectionFactory) 
connector.getConnectionFactory(HttpVersion.HTTP_1_1.toString());
     int requestHeaderSize = conf.getJettyRequestHeaderSize();
diff --git a/submarine-workbench/workbench-web/pom.xml 
b/submarine-workbench/workbench-web/pom.xml
index 6919c20..c147185 100644
--- a/submarine-workbench/workbench-web/pom.xml
+++ b/submarine-workbench/workbench-web/pom.xml
@@ -101,6 +101,7 @@
         <artifactId>maven-war-plugin</artifactId>
         <version>${plugin.war.version}</version>
         <configuration>
+          <warName>${project.artifactId}</warName>
           <failOnMissingWebXml>true</failOnMissingWebXml>
           <warSourceDirectory>dist</warSourceDirectory>
           <webXml>src/WEB-INF/web.xml</webXml>

Reply via email to