This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 39c39c8 Fix get progress missing properties (#11203)
39c39c8 is described below
commit 39c39c8963c6412a22d5c12fa7b12e26535bba90
Author: avalon5666 <[email protected]>
AuthorDate: Thu Jul 8 22:54:48 2021 +0800
Fix get progress missing properties (#11203)
* Fix get progress missing properties
* Refactor scaling start/stop script
---
.../src/main/resources/bin/server_start.sh | 33 +-------------------
.../src/main/resources/bin/server_stop.sh | 35 +---------------------
.../resources/bin/{server_start.sh => start.sh} | 18 +++++++----
.../main/resources/bin/{server_stop.sh => stop.sh} | 12 ++++++--
.../src/main/resources/bin/worker_start.sh | 33 +-------------------
.../src/main/resources/bin/worker_stop.sh | 35 +---------------------
.../scaling/web/HttpServerHandler.java | 6 +++-
7 files changed, 32 insertions(+), 140 deletions(-)
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
index 0fb2625..572d1ec 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
@@ -16,36 +16,5 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
-
cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
-
-LOGS_DIR=${DEPLOY_DIR}/logs
-if [ ! -d ${LOGS_DIR} ]; then
- mkdir ${LOGS_DIR}
-fi
-
-STDOUT_FILE=${LOGS_DIR}/stdout.log
-
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep | awk '{print
$2}'`
-if [ -n "$PIDS" ]; then
- echo "ERROR: The $SERVER_NAME already started!"
- echo "PID: $PIDS"
- exit 1
-fi
-
-CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*
-JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
-
-JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss256k -XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
-
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
-
-echo "Starting the $SERVER_NAME ..."
-
-nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH}
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
-sleep 1
-
-echo "Please check the STDOUT file: $STDOUT_FILE"
+exec ./start.sh server
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
index 9a14be6..0ba5078 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
@@ -16,38 +16,5 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
-
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
-
cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
-
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep "$MAIN_CLASS" | grep -v
grep |awk '{print $2}'`
-if [ -z "$PIDS" ]; then
- echo "ERROR: The $SERVER_NAME does not started!"
- exit 1
-fi
-
-echo -e "Stopping the $SERVER_NAME ...\c"
-for PID in ${PIDS} ; do
- kill ${PID} > /dev/null 2>&1
-done
-
-COUNT=0
-while [ ${COUNT} -lt 1 ]; do
- echo -e ".\c"
- sleep 1
- COUNT=1
- for PID in ${PIDS} ; do
- PID_EXIST=`ps -f -p ${PID} | grep java`
- if [ -n "$PID_EXIST" ]; then
- COUNT=0
- break
- fi
- done
-done
-
-echo "OK!"
-echo "PID: $PIDS"
+exec ./stop.sh server
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/start.sh
similarity index 77%
copy from
shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
copy to
shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/start.sh
index 0fb2625..83e1826 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_start.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/start.sh
@@ -16,7 +16,17 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
+BOOTSTRAP_TYPE=$1
+if [ "server" = ${BOOTSTRAP_TYPE} ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
+elif [ "worker" = ${BOOTSTRAP_TYPE} ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingWorkerBootstrap
+else
+ echo 'Please set the BOOTSTRAP_TYPE(server/worker)'
+ exit 1
+fi
+
+SERVER_NAME=ShardingSphere-Scaling-${BOOTSTRAP_TYPE}
cd `dirname $0`
cd ..
@@ -27,9 +37,9 @@ if [ ! -d ${LOGS_DIR} ]; then
mkdir ${LOGS_DIR}
fi
-STDOUT_FILE=${LOGS_DIR}/stdout.log
+STDOUT_FILE=${LOGS_DIR}/${BOOTSTRAP_TYPE}_stdout.log
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep | awk '{print
$2}'`
+PIDS=`ps -ef | grep java | grep "$MAIN_CLASS" | grep -v grep | awk '{print
$2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
@@ -41,8 +51,6 @@ JAVA_OPTS=" -Djava.awt.headless=true
-Djava.net.preferIPv4Stack=true "
JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss256k -XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
-
echo "Starting the $SERVER_NAME ..."
nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH}
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/stop.sh
similarity index 79%
copy from
shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
copy to
shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/stop.sh
index 9a14be6..7c4e3c3 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/server_stop.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/stop.sh
@@ -16,9 +16,17 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
+BOOTSTRAP_TYPE=$1
+if [ "server" = ${BOOTSTRAP_TYPE} ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
+elif [ "worker" = ${BOOTSTRAP_TYPE} ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingWorkerBootstrap
+else
+ echo 'Please set the BOOTSTRAP_TYPE(server/worker)'
+ exit 1
+fi
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
+SERVER_NAME=ShardingSphere-Scaling-${BOOTSTRAP_TYPE}
cd `dirname $0`
cd ..
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_start.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_start.sh
index 1d9f1fc..2efee92 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_start.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_start.sh
@@ -16,36 +16,5 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
-
cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
-
-LOGS_DIR=${DEPLOY_DIR}/logs
-if [ ! -d ${LOGS_DIR} ]; then
- mkdir ${LOGS_DIR}
-fi
-
-STDOUT_FILE=${LOGS_DIR}/stdout.log
-
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep | awk '{print
$2}'`
-if [ -n "$PIDS" ]; then
- echo "ERROR: The $SERVER_NAME already started!"
- echo "PID: $PIDS"
- exit 1
-fi
-
-CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*
-JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
-
-JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss256k -XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
-
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingWorkerBootstrap
-
-echo "Starting the $SERVER_NAME ..."
-
-nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH}
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
-sleep 1
-
-echo "Please check the STDOUT file: $STDOUT_FILE"
+exec ./start.sh worker
diff --git
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_stop.sh
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_stop.sh
index f66acb0..666f92c 100644
---
a/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_stop.sh
+++
b/shardingsphere-distribution/shardingsphere-scaling-distribution/src/main/resources/bin/worker_stop.sh
@@ -16,38 +16,5 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Scaling
-
-MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingWorkerBootstrap
-
cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
-
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep "$MAIN_CLASS" | grep -v
grep |awk '{print $2}'`
-if [ -z "$PIDS" ]; then
- echo "ERROR: The $SERVER_NAME does not started!"
- exit 1
-fi
-
-echo -e "Stopping the $SERVER_NAME ...\c"
-for PID in ${PIDS} ; do
- kill ${PID} > /dev/null 2>&1
-done
-
-COUNT=0
-while [ ${COUNT} -lt 1 ]; do
- echo -e ".\c"
- sleep 1
- COUNT=1
- for PID in ${PIDS} ; do
- PID_EXIST=`ps -f -p ${PID} | grep java`
- if [ -n "$PID_EXIST" ]; then
- COUNT=0
- break
- fi
- done
-done
-
-echo "OK!"
-echo "PID: $PIDS"
+exec ./stop.sh worker
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java
b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java
index ac0aad9..27227bb 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.scaling.web;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonSerializer;
import com.google.gson.LongSerializationPolicy;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
@@ -39,6 +40,7 @@ import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
import
org.apache.shardingsphere.scaling.core.common.exception.ScalingJobNotFoundException;
import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
+import org.apache.shardingsphere.scaling.core.job.position.ScalingPosition;
import org.apache.shardingsphere.scaling.util.ResponseContentUtil;
import java.sql.SQLException;
@@ -51,7 +53,9 @@ import java.util.Optional;
@Slf4j
public final class HttpServerHandler extends
SimpleChannelInboundHandler<FullHttpRequest> {
- private static final Gson GSON = new
GsonBuilder().disableHtmlEscaping().serializeNulls().setLongSerializationPolicy(LongSerializationPolicy.STRING).create();
+ private static final Gson GSON = new
GsonBuilder().disableHtmlEscaping().serializeNulls().setLongSerializationPolicy(LongSerializationPolicy.STRING)
+ .registerTypeHierarchyAdapter(ScalingPosition.class,
(JsonSerializer) (o, type, jsonSerializationContext) -> new
Gson().toJsonTree(o))
+ .create();
private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();