From 540a86c45a5017fc311bd25afa1ac97dc65cd35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=B4=E7=AB=A0?= Date: Sat, 10 Sep 2022 16:28:35 +0800 Subject: [PATCH 1/3] fix(doc) modify quick start --- ...ar\345\214\205\345\220\257\345\212\250.md" | 8 +-- rsqldb-disk/conf/rsqldb.conf | 49 +------------------ rsqldb-disk/distribution.xml | 5 ++ 3 files changed, 11 insertions(+), 51 deletions(-) diff --git "a/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" "b/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" index eb42655..1adf8e3 100644 --- "a/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" +++ "b/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" @@ -29,16 +29,16 @@ tar -zxvf rsqldb-distribution.tar.gz;cd rsqldb ### 配置rsqldb服务端 - 打开conf目录下rsqldb.conf文件; -- 修改filePathAndName,filePathAndName为保存流处理任务的文件,可以修改为rsqldb解压路径,加上文件名称; +- 修改filePathAndName项目,filePathAndName为保存流处理任务的文件,可以修改为rsqldb解压路径,加上文件名称,例如~/rsqldb/dipper.cs ### 启动rsqldb服务端 ```shell sh bin/startAll.sh ``` -### 配置sql文件 -sendDataFromFile.sql中创建的任务,需要从本地文件指定位置读取数据,所以需要修改sendDataFromFile.sql中filePath变量的位置,修改为数据文件data.txt的绝对路径。 - +### 配置sql +执行sql以sendDataFromFile.sql为例,该sql任务的数据处理流程为:从本地data.txt文件中读取数据(data.txt文件在client目录中),过滤出field_1=1的数据,并打印在日志中;为了顺利执行,需要做以下配置: +- client/sendDataFromFile.sql中修改filePath指向data.txt的全路径,例如为:/home/rsqldb/client/data.txt; ### 提交任务 执行路径依然在rsqldb解压目录下 diff --git a/rsqldb-disk/conf/rsqldb.conf b/rsqldb-disk/conf/rsqldb.conf index e821c1d..29cdc41 100644 --- a/rsqldb-disk/conf/rsqldb.conf +++ b/rsqldb-disk/conf/rsqldb.conf @@ -4,55 +4,10 @@ namespace=test ## checkpoint存储配置,可以是memory, DB 或者file, 除了checkpoint外, 任务序列化的内容也会被缓存在该存储 dipper.configurable.service.type=file -rsldb.custom.function.jar.path= -## 当checkpoint为DB时 -#dipper.rds.jdbc.type=mysql -#dipper.rds.jdbc.url=jdbc:mysql://host:port/database?serverTimezone=Asia/Shanghai -#dipper.rds.jdbc.username= -#dipper.rds.jdbc.password= -#dipper.rds.jdbc.driver=com.mysql.jdbc.Driver -#dipper.rds.table.name=dipper_configure -## 任务从存储反序列化的频次 -#dipper.configurable.polling.time=60 -#pipeline.qps.print=true -#homologous.expression.cache.size=100000 -#homologous.pre.fingerprint.cache.size=100000 -#homologous.optimization.switch=true -## 监控日志的相关配置 -# dipper.monitor.output.level=INFO #日志等级,有三种INFO,SLOW,ERROR -#dipper.monitor.slow.timeout=60000 -# dipper.monitor.logs.dir=./logs #日志目录 ## 窗口配置 #group by 时窗口大小,单位s,sql中不配置或者这里不指定的话默认600s dipper.window.default.iterval.size.time=10 -# dipper.window.join.default.interval.size.time= #join的默认窗口大小 -# dipper.window.join.default.retain.window.count= #需要保留几个窗口 -# dipper.window.default.fire.delay.second= #窗口延迟多长时间触发 -# dipper.window.default.interval.size.time= #统计默认的窗口大小,单位是分钟。默认是滚动窗口,大小是1个小时 -# dipper.window.default.time.unit.adjust= #统计默认的窗口大小,单位是分钟。默认是滚动窗口,大小是1个小时 -# dipper.window.over.default.interval.size.time= #over partition窗口的默认时间 -## 窗口shuffle配置 -window.shuffle.channel.type=memory -# window.shuffle.channel.type=rocketmq #shuffle使用的数据存储类型 -# window.shuffle.channel.topic= #根据type的配置,有不同的配置, topic是指用于shuffle的rocketmq的topic; -# window.shuffle.channel.tags= #根据type的配置,有不同的配置, tags是指用于shuffle的rocketmq的tags; -# window.shuffle.channel.group= #根据type的配置,有不同的配置, group是指用于shuffle的rocketmq的group; -# window.system.message.channel.owner=#如果能做消息过滤,只过滤本window的消息,可以配置这个属性,如rocketmq的tags.不支持的会做客户端过滤 -## 自定义配置文件路径, 默认查找classpath下的配置文件,或者在jar包所在目录的资源文件 -#client产生的流计算任务位置,目前需要填绝对路径,client生成后,runner从该位置读取流计算任务。 +#client产生的流计算任务位置,目前需要填绝对路径,client生成后,runner从该位置读取流计算任务。配置形式为: +#filePathAndName=/Users/rsqldb/rsqldb-disk/server/dipper.cs filePathAndName=/Users/nize/code/github/rsqldb/rsqldb-disk/server/dipper.cs - -## 把所有的输出重新定向,当测试时,不需要把结果写入正式的输出时,可以使用,默认会打印,如果需要输出到其他存储,可以配置# -# out.mock.switch=false -## mock的类型,可以是print,metaq和sls。下面是具体类型的配置 -# out.mock.type=print -# out.mock.metaq.topic= -# out.mock.metaq.tag= -# out.mock.metaq.consumerGroup= -# out.mock.sls.endPoint= -# out.mock.sls.project= -# out.mock.sls.logstore= -# out.mock.sls.accessKey= -# out.mock.sls.accessId= -# out.mock.sls.group= \ No newline at end of file diff --git a/rsqldb-disk/distribution.xml b/rsqldb-disk/distribution.xml index 9a7c568..1447895 100644 --- a/rsqldb-disk/distribution.xml +++ b/rsqldb-disk/distribution.xml @@ -41,6 +41,11 @@ limitations under the License. conf /conf + + 0775 + customFunction + /customFunction + From 0296c3789aea720f2f2489f9170cb9c42a0037dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=B4=E7=AB=A0?= Date: Sat, 10 Sep 2022 18:14:32 +0800 Subject: [PATCH 2/3] auto filePathAndName in shell --- ...234\260jar\345\214\205\345\220\257\345\212\250.md" | 11 ----------- rsqldb-disk/bin/startAll.sh | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git "a/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" "b/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" index 1adf8e3..bdf62b2 100644 --- "a/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" +++ "b/docs/other_quick_start/\346\234\254\345\234\260jar\345\214\205\345\220\257\345\212\250.md" @@ -27,10 +27,6 @@ mvn clean package -DskipTest -U tar -zxvf rsqldb-distribution.tar.gz;cd rsqldb ``` -### 配置rsqldb服务端 -- 打开conf目录下rsqldb.conf文件; -- 修改filePathAndName项目,filePathAndName为保存流处理任务的文件,可以修改为rsqldb解压路径,加上文件名称,例如~/rsqldb/dipper.cs - ### 启动rsqldb服务端 ```shell sh bin/startAll.sh @@ -78,13 +74,6 @@ sh client/clientExector.sh stopTask - 本地安装并启动RocketMQ,[安装文档](https://rocketmq.apache.org/docs/quick-start/) -- 配置rsqldb服务端 -```xml -打开conf目录下rsqldb.conf文件; -修改filePathAndName,filePathAndName为保存流处理任务的文件,可以修改为rsqldb解压路径,加上文件名称; -如果有必要,可以修改NAMESRV_ADDR,执行自己配置的namesrv地址; -``` - - 启动rsqldb服务端 ```shell sh bin/startAll.sh diff --git a/rsqldb-disk/bin/startAll.sh b/rsqldb-disk/bin/startAll.sh index 4429a44..8f561d0 100644 --- a/rsqldb-disk/bin/startAll.sh +++ b/rsqldb-disk/bin/startAll.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e binDir=$(cd `dirname $0`;pwd) echo "binDir=$binDir" @@ -13,6 +14,16 @@ if [ ! -d log ]; then mkdir log fi +path=$homeDir/dipper.cs + +sysOS=`uname -s` + +if [ $sysOS == "Darwin" ];then + sed -i '' 's#^filePathAndName.*$#filePathAndName='$path'#g' $homeDir/conf/rsqldb.conf; +elif [ $sysOS == "Linux" ];then + sed -i 's#^filePathAndName.*$#filePathAndName='$path'#g' $homeDir/conf/rsqldb.conf; +fi + cd $binDir chmod +x startTaskExecutor.sh From 31f63df1be19ca89b302c3ace30aae78afa7ea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=B4=E7=AB=A0?= Date: Sun, 11 Sep 2022 16:11:56 +0800 Subject: [PATCH 3/3] docker-compose.sql 0.2 --- .gitignore | 4 ++-- docker-compose.yml | 4 ++-- rsqldb-disk/bin/startAll.sh | 2 +- rsqldb-disk/client/rocketmq.sql | 5 +++++ rsqldb-disk/client/sendDataFromFile.sql | 2 +- rsqldb-disk/conf/rsqldb.conf | 4 ++-- .../java/org/alibaba/rsqldb/runner/StreamRunner.java | 12 +++++++----- .../java/com/alibaba/rsqldb/server/Application.java | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 254ef36..592dd66 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ target/ *.iml *.ipr *.gz -*/dipper.cs +*/rsqldb.cs ### NetBeans ### nbproject/private/ @@ -32,4 +32,4 @@ _book/ */dependency-reduced-pom.xml /rsqldb-disk/log/ -/rsqldb-disk/server/dipper.cs +/rsqldb-disk/server/rsqldb.cs diff --git a/docker-compose.yml b/docker-compose.yml index ef8b320..f3b1271 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: command: sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf rsqldb: - image: unclerangoo/rsqldb:0.1 + image: unclerangoo/rsqldb:0.2 hostname: rsqldb container_name: rsqldb networks: @@ -53,7 +53,7 @@ services: - NAMESRV_ADDR=namesrv:9876 rsqldb-client: - image: unclerangoo/rsqldb-client:0.1 + image: unclerangoo/rsqldb-client:0.2 hostname: rsqldb-client container_name: rsqldb-client networks: diff --git a/rsqldb-disk/bin/startAll.sh b/rsqldb-disk/bin/startAll.sh index 8f561d0..681d826 100644 --- a/rsqldb-disk/bin/startAll.sh +++ b/rsqldb-disk/bin/startAll.sh @@ -14,7 +14,7 @@ if [ ! -d log ]; then mkdir log fi -path=$homeDir/dipper.cs +path=$homeDir/rsqldb.cs sysOS=`uname -s` diff --git a/rsqldb-disk/client/rocketmq.sql b/rsqldb-disk/client/rocketmq.sql index f81241d..568f7e7 100644 --- a/rsqldb-disk/client/rocketmq.sql +++ b/rsqldb-disk/client/rocketmq.sql @@ -22,6 +22,11 @@ CREATE TABLE `task_sink_2` ) WITH ( type = 'print' ); +-- 写入rocketmq中 +-- type = 'rocketmq', +-- topic = 'rsqldb-sink', +-- groupName = 'rsqldb-group', +-- namesrvAddr = '127.0.0.1:9876' insert into task_sink_2 select field_1 diff --git a/rsqldb-disk/client/sendDataFromFile.sql b/rsqldb-disk/client/sendDataFromFile.sql index b234d2b..7960a15 100644 --- a/rsqldb-disk/client/sendDataFromFile.sql +++ b/rsqldb-disk/client/sendDataFromFile.sql @@ -7,7 +7,7 @@ CREATE TABLE `test_source` ) WITH ( type = 'file', -- 需要根据自身填写data.txt的绝对路径 - filePath = '', + filePath = '/Users/nize/code/github/rsqldb/rsqldb-disk/client/data.txt', isJsonData = 'true', msgIsJsonArray = 'false' ); diff --git a/rsqldb-disk/conf/rsqldb.conf b/rsqldb-disk/conf/rsqldb.conf index 29cdc41..0f39c6b 100644 --- a/rsqldb-disk/conf/rsqldb.conf +++ b/rsqldb-disk/conf/rsqldb.conf @@ -9,5 +9,5 @@ dipper.configurable.service.type=file dipper.window.default.iterval.size.time=10 #client产生的流计算任务位置,目前需要填绝对路径,client生成后,runner从该位置读取流计算任务。配置形式为: -#filePathAndName=/Users/rsqldb/rsqldb-disk/server/dipper.cs -filePathAndName=/Users/nize/code/github/rsqldb/rsqldb-disk/server/dipper.cs +#filePathAndName=/Users/rsqldb/rsqldb-disk/server/rsqldb.cs +filePathAndName=/Users/nize/code/github/rsqldb/rsqldb-disk/server/rsqldb.cs diff --git a/rsqldb-runner/src/main/java/org/alibaba/rsqldb/runner/StreamRunner.java b/rsqldb-runner/src/main/java/org/alibaba/rsqldb/runner/StreamRunner.java index 08d7bb9..9a7eb95 100644 --- a/rsqldb-runner/src/main/java/org/alibaba/rsqldb/runner/StreamRunner.java +++ b/rsqldb-runner/src/main/java/org/alibaba/rsqldb/runner/StreamRunner.java @@ -53,17 +53,19 @@ public static void main(String[] args) throws Throwable { Properties properties = new Properties(); properties.load(in); - Map env = System.getenv(); - String namesrvAddrEnv = env.get(MixAll.NAMESRV_ADDR_ENV); - if (namesrvAddrEnv != null) { - properties.put(MixAll.NAMESRV_ADDR_ENV, namesrvAddrEnv); - } String filePathAndName = properties.getProperty("filePathAndName"); if (StringUtils.isEmpty(filePathAndName)) { throw new IllegalArgumentException("filePathAndName is required."); } + //使用env中配置的namesrv地址覆盖rsqldb.conf中的; + Map env = System.getenv(); + String namesrvAddrEnv = env.get(MixAll.NAMESRV_ADDR_ENV); + if (namesrvAddrEnv != null) { + properties.put(MixAll.NAMESRV_ADDR_ENV, namesrvAddrEnv); + } + String namesrvAddrs = properties.getProperty(MixAll.NAMESRV_ADDR_ENV); String[] temp = namesrvAddrs.trim().split(";"); diff --git a/rsqldb-server/src/main/java/com/alibaba/rsqldb/server/Application.java b/rsqldb-server/src/main/java/com/alibaba/rsqldb/server/Application.java index f2a10b9..061d514 100644 --- a/rsqldb-server/src/main/java/com/alibaba/rsqldb/server/Application.java +++ b/rsqldb-server/src/main/java/com/alibaba/rsqldb/server/Application.java @@ -21,11 +21,11 @@ public static void main(String[] args) { if (!file.exists()) { boolean result = file.mkdirs(); if (!result) { - throw new RuntimeException("create dipper.cs path error"); + throw new RuntimeException("create rsqldb.cs path error"); } } - System.setProperty("cs.dir", dipperCsParentPath + "/dipper.cs"); + System.setProperty("cs.dir", dipperCsParentPath + "/rsqldb.cs"); System.out.println(System.getProperty("cs.dir"));