Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getWorkers bug on RunConfig #2747

Merged
merged 11 commits into from
May 19, 2020
6 changes: 0 additions & 6 deletions dolphinscheduler-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<codehaus.janino.version>3.1.0</codehaus.janino.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -589,10 +588,5 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>${codehaus.janino.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/dolphinscheduler
spring.datasource.username=test
spring.datasource.password=test

# mysql
# connection configuration
#spring.datasource.initialSize=5
# min connection number
Expand Down Expand Up @@ -61,4 +60,4 @@ spring.datasource.password=test

# open PSCache, specify count PSCache for every connection
#spring.datasource.poolPreparedStatements=true
#spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
#spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dolphinscheduler.server.monitor;

import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -52,7 +54,18 @@ public void setMasters(String masters) {
}

public String getWorkers() {
return workers;
StringBuilder sb = new StringBuilder(50);
if(StringUtils.isNotBlank(workers)){
String[] workersArr = workers.trim().split(Constants.COMMA);
for (String workerGroup : workersArr) {
sb.append(workerGroup.split(Constants.COLON)[0]).append(Constants.COMMA);
}
}
if( sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}

return sb.toString();
}

public void setWorkers(String workers) {
Expand Down
18 changes: 15 additions & 3 deletions script/scp-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
txt="''"
fi

declare -A workersGroupMap=()

workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'`
workersGroupMap+=([$worker]=$groupName)
done


hostsArr=(${ips//,/ })
for host in ${hostsArr[@]}
do
Expand All @@ -39,9 +51,9 @@ do

for dsDir in bin conf lib script sql ui install.sh
do
# if worker in workersGroup
if [[ "${workersGroup[${host}]}" ]] && [[ "${dsDir}" == "conf" ]]; then
sed -i ${txt} "s#worker.group.*#worker.group=${workersGroup[${host}]}#g" ${dsDir}/worker.properties
# if worker in workersGroupMap
if [[ "${workersGroupMap[${host}]}" ]] && [[ "${dsDir}" == "conf" ]]; then
sed -i ${txt} "s#worker.group.*#worker.group=${workersGroupMap[${host}]}#g" ${dsDir}/worker.properties
fi

echo "start to scp $dsDir to $host/$installPath"
Expand Down
13 changes: 12 additions & 1 deletion script/start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ workDir=`dirname $0`
workDir=`cd ${workDir};pwd`
source $workDir/../conf/config/install_config.conf

declare -A workersGroupMap=()

workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'`
workersGroupMap+=([$worker]=$groupName)
done

mastersHost=(${masters//,/ })
for master in ${mastersHost[@]}
do
Expand All @@ -28,7 +39,7 @@ do

done

for worker in ${!workersGroup[*]}
for worker in ${!workersGroupMap[*]}
do
echo "$worker worker server is starting"

Expand Down
13 changes: 12 additions & 1 deletion script/stop-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ workDir=`cd ${workDir};pwd`

source $workDir/../conf/config/install_config.conf

declare -A workersGroupMap=()

workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'`
workersGroupMap+=([$worker]=$groupName)
done

mastersHost=(${masters//,/ })
for master in ${mastersHost[@]}
do
Expand All @@ -29,7 +40,7 @@ do

done

for worker in ${!workersGroup[*]}
for worker in ${!workersGroupMap[*]}
do
echo "$worker worker server is stopping"
ssh -p $sshPort $worker "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop worker-server;"
Expand Down