Skip to content

Commit

Permalink
modify start shell
Browse files Browse the repository at this point in the history
  • Loading branch information
ni-ze committed Jun 18, 2022
1 parent 244fe95 commit 1c2e568
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 132 deletions.
47 changes: 0 additions & 47 deletions rsqldb-disk/bin/recover.sh

This file was deleted.

2 changes: 1 addition & 1 deletion rsqldb-disk/bin/start-sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ JVM_CONFIG=$4


if [ -z "${JVM_CONFIG}" ]; then
JVM_CONFIG="-Xms2048m -Xmx2048m -Xss512k"
JVM_CONFIG="-Xms2048m -Xmx2048m -Xmn1024m"
fi
ROCKETMQ_STREAMS_HOME=$(cd $(dirname ${BASH_SOURCE[0]})/..; pwd)
ROCKETMQ_STREAMS_CONFIGURATION=$ROCKETMQ_STREAMS_HOME/conf
Expand Down
40 changes: 13 additions & 27 deletions rsqldb-disk/bin/start.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
#!/bin/sh
set -e

PROG_NAME=$0
JOB_NAMESPACE=$1
JOB_NAMES=$2
JVM_CONFIG=$3
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"

export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=.:${BASE_DIR}/conf:${BASE_DIR}/lib/*:${CLASSPATH}

if [ -z "${JVM_CONFIG}" ]; then
JVM_CONFIG="-Xms2048m -Xmx2048m -Xss512k"
fi
ROCKETMQ_STREAMS_HOME=$(cd $(dirname ${BASH_SOURCE[0]})/..; pwd)
ROCKETMQ_STREAMS_JOBS_DIR=$ROCKETMQ_STREAMS_HOME/jobs
ROCKETMQ_STREAMS_CONFIGURATION=$ROCKETMQ_STREAMS_HOME/conf
ROCKETMQ_STREAMS_EXT=$ROCKETMQ_STREAMS_HOME/ext
ROCKETMQ_STREAMS_DEPENDENCIES=$ROCKETMQ_STREAMS_HOME/lib
ROCKETMQ_STREAMS_LOGS=$ROCKETMQ_STREAMS_HOME/log/catalina.out

if [ -z "${JAVA_HOME:-}" ]; then
JAVA="java -server"
else
JAVA="$JAVA_HOME/bin/java -server"
fi
JVM_CONFIG="-Xms2048m -Xmx2048m -Xmn1024m"

JAVA_OPTIONS=${JAVA_OPTIONS:-}

Expand All @@ -33,17 +22,14 @@ if [ ! -z "${JVM_CONFIG}" ]; then
JVM_OPTS+=("${JVM_CONFIG}")
fi

JVM_OPTS+=( "-Dlog4j.configuration=$ROCKETMQ_STREAMS_CONFIGURATION/log4j.xml" )
JVM_OPTS="${JVM_OPTS} -cp ${CLASSPATH}"

#JVM_OPTS+=( "-Dlog4j.configuration=$ROCKETMQ_STREAMS_CONFIGURATION/log4j.xml" )

# shellcheck disable=SC2068
# shellcheck disable=SC2039

if [ ! -z "${JOB_NAMES}" -a ! -z "${JOB_NAMESPACE}" ]; then
eval exec $JAVA ${JVM_OPTS[@]} -classpath "$ROCKETMQ_STREAMS_DEPENDENCIES/*:$ROCKETMQ_STREAMS_EXT/*:$ROCKETMQ_STREAMS_CONFIGURATION/*" org.apache.rsqldb.runner.StartAction $ROCKETMQ_STREAMS_JOBS_DIR $JOB_NAMESPACE $JOB_NAMES "&" >>"$ROCKETMQ_STREAMS_LOGS" 2>&1
elif [ ! -z "${JOB_NAMESPACE}" ]; then
eval exec $JAVA ${JVM_OPTS[@]} -classpath "$ROCKETMQ_STREAMS_DEPENDENCIES/*:$ROCKETMQ_STREAMS_EXT/*:$ROCKETMQ_STREAMS_CONFIGURATION/*" org.apache.rsqldb.runner.StartAction $ROCKETMQ_STREAMS_JOBS_DIR $JOB_NAMESPACE "&" >>"$ROCKETMQ_STREAMS_LOGS" 2>&1
else
eval exec $JAVA ${JVM_OPTS[@]} -classpath "$ROCKETMQ_STREAMS_DEPENDENCIES/*:$ROCKETMQ_STREAMS_EXT/*:$ROCKETMQ_STREAMS_CONFIGURATION/*" org.apache.rsqldb.runner.StartAction $ROCKETMQ_STREAMS_JOBS_DIR "&" >>"$ROCKETMQ_STREAMS_LOGS" 2>&1
fi
$JAVA ${JVM_OPTS} org.alibaba.rsqldb.runner.StreamServer ${BASE_DIR}/conf/rsqldb.conf



26 changes: 0 additions & 26 deletions rsqldb-disk/bin/stop.sh

This file was deleted.

51 changes: 51 additions & 0 deletions rsqldb-disk/conf/log4j.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">


<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p %c{1} %m %n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="INFO"/>
<param name="levelMax" value="ERROR"/>
<param name="AcceptOnMatch" value="true"/>
</filter>
</appender>

<appender name="fileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${log4j.home}/rocketmq-streams.log"/>
<param name="Append" value="true"/>
<param name="DatePattern" value="'.'yyyy-MM-dd'.log'"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p %c{1} %m %n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="${log4j.level}"/>
<param name="levelMax" value="ERROR"/>
<param name="AcceptOnMatch" value="true"/>
</filter>
</appender>

<appender name="traceAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${log4j.home}/trace.log"/>
<param name="Append" value="true"/>
<param name="DatePattern" value="'.'yyyy-MM-dd'.log'"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p %c{1} %m %n"/>
</layout>
</appender>

<!--<category name="org.apache.rocketmq.streams.common.utils.TraceUtil" additivity="false">-->
<!--<level value="INFO"/>-->
<!--<appender-ref ref="traceAppender"/>-->
<!--</category>-->

<root>
<appender-ref ref="console"/>
<!--<appender-ref ref="fileAppender"/>-->
</root>

</log4j:configuration>
2 changes: 2 additions & 0 deletions rsqldb-disk/conf/rsqldb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAMESRV_ADDR=127.0.0.1:9876
namespace=test
6 changes: 6 additions & 0 deletions rsqldb-disk/distribution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ limitations under the License.
<directory>log</directory>
<outputDirectory>/log</outputDirectory>
</fileSet>

<fileSet>
<fileMode>0775</fileMode>
<directory>conf</directory>
<outputDirectory>/conf</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
Expand Down
Empty file removed rsqldb-disk/log/catalina.out
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@

package org.alibaba.rsqldb.runner;

import com.google.common.collect.Lists;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.streams.RocketMQChannelBuilder;
import org.apache.rocketmq.streams.common.component.ComponentCreator;
import org.apache.rocketmq.streams.common.configure.ConfigureFileKey;
Expand All @@ -36,43 +38,34 @@
public class StreamServer {
private static ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(5);

public static void main(String[] args) {
String namespace = "default";
if (args.length > 0) {
namespace = args[0];
public static void main(String[] args) throws Throwable {
if (args == null || args.length < 1) {
throw new IllegalArgumentException("rsqldb.conf is a required arg");
}

//获取mqnamesrv文件信息
List<String> mqNameServers = Lists.newArrayList();
InputStream inputStream = null;
String line;
try {
inputStream = StreamServer.class.getClassLoader().getResourceAsStream("mqnamesrv");
if (inputStream != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = reader.readLine()) != null) {
mqNameServers.add(line.trim() + ":9876");
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
Properties properties = PropertiesUtils.getResourceProperties("conf/dipper.properties");
String configFile = args[0];
InputStream in = new BufferedInputStream(new FileInputStream(configFile));
Properties properties = new Properties();
properties.load(in);

String namesrvAddrs = properties.getProperty(MixAll.NAMESRV_ADDR_ENV);

String[] temp = namesrvAddrs.trim().split(";");
List<String> mqNameServers = Arrays.asList(temp);

String shuffleChannelType = properties.getProperty("window.shuffle.channel.type");
if (RocketMQChannelBuilder.TYPE.equals(shuffleChannelType) && !mqNameServers.isEmpty()) {
properties.setProperty("window.shuffle.channel.namesrvAddr", String.join(";", mqNameServers));
properties.setProperty("window.shuffle.channel.topic", "default_shuffle_topic");
properties.setProperty("window.shuffle.channel.group", "default_shuffle_group");
}
ComponentCreator.setProperties(properties);

String namespace = properties.getProperty("namespace");
if (StringUtils.isEmpty(namespace)) {
namespace = "default";
}

ConfigurableComponent configurableComponent = ComponentCreator.getComponent(namespace, ConfigurableComponent.class);
final String finalNamespace = namespace;

Expand Down

0 comments on commit 1c2e568

Please sign in to comment.