Skip to content

Commit

Permalink
fix issue #104 , add weevent processor module (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristic authored and saintping committed Oct 23, 2019
1 parent 5e6b5d8 commit c382473
Show file tree
Hide file tree
Showing 44 changed files with 4,950 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ WeEvent支持三种安装方式:[Docker镜像](https://hub.docker.com/r/weeven
$ docker pull weevent/weevent:1.0.0; docker run -d -p 8080:8080 weevent/weevent:1.0.0 /root/run.sh
```

<<<<<<< HEAD
#### Bash一键安装
下载并且解压安装包,如weevent-1.0.0.tar.gz ,在解压目录中执行安装脚本。
```
=======
### Bash一键安装
[下载](https://weeventdoc.readthedocs.io/zh_CN/latest/install/download.html)并且解压安装包,如weevent-1.0.0.tar.gz。在解压目录中执行安装脚本。
```shell
>>>>>>> 5e6b5d840ce6f2dd841a3825c60e831f0fb19391
$ ./install-all.sh -p /usr/local/weevent/
```

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ include "weevent-client"
include "weevent-broker"
include "weevent-governance"
include "weevent-robust"
include "weevent-processor"
include "weevent-jmeter"

14 changes: 14 additions & 0 deletions weevent-build/bin/check-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ function check_governance(){
yellow_echo "governance service is error"
fi
}
function check_processor(){
echo "check processor service"
curl -s "http://127.0.0.1:8080/weevent/processor/getCEPRuleListByPage?currPage=1&pageSize=10" | grep 302000 >>/dev/null
if [[ $? -eq 0 ]];then
yellow_echo "processor service is ok"
else
yellow_echo "processor service is error"
fi
}


check_broker
if [[ -d "governance" ]]; then
check_governance
fi

if [[ -d "processor" ]]; then
check_processor
fi

21 changes: 20 additions & 1 deletion weevent-build/install-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ mysql_port=
mysql_user=
mysql_password=

processor_port=


current_path=$PWD

function yellow_echo (){
Expand Down Expand Up @@ -65,6 +68,9 @@ function set_global_param(){
mysql_port=$(properties_get "governance.mysql.port")
mysql_user=$(properties_get "governance.mysql.user")
mysql_password=$(properties_get "governance.mysql.password")

processor_enable=$(properties_get "processor.enable")
processor_port=$(properties_get "processor.port")
}

function check_port(){
Expand Down Expand Up @@ -138,6 +144,13 @@ function install_module(){
./install-governance.sh --out_path ${out_path}/governance --server_port ${governance_port} --mysql_ip ${mysql_ip} --mysql_port ${mysql_port} --mysql_user ${mysql_user} --mysql_pwd ${mysql_password} &>> ${current_path}/install.log
check_result "install governance"
fi
if [[ ${processor_enable} = "true" ]];then
yellow_echo "install module processor"
cd ${current_path}/modules/processor
./install-processor.sh --out_path ${out_path}/processor --server_port ${processor_port} --mysql_ip ${mysql_ip} --mysql_port ${mysql_port} --mysql_user ${mysql_user} --mysql_pwd ${mysql_password} &>> ${current_path}/install.log
check_result "install processor"
fi

}

function config_java_home(){
Expand All @@ -152,7 +165,13 @@ function config_java_home(){
fi
if [[ -e ${current_path}/modules/governance/init-governance.sh ]];then
sed -i "/JAVA_HOME=/cJAVA_HOME=${java_home_path}" ${current_path}/modules/governance/init-governance.sh
fi
fi
if [[ -e ${current_path}/modules/processor/processor.sh ]];then
sed -i "/JAVA_HOME=/cJAVA_HOME=${java_home_path}" ${current_path}/modules/processor/processor.sh
fi
if [[ -e ${current_path}/modules/governance/init-processor.sh ]];then
sed -i "/JAVA_HOME=/cJAVA_HOME=${java_home_path}" ${current_path}/modules/processor/init-processor.sh
fi
}

function update_server_port(){
Expand Down
101 changes: 101 additions & 0 deletions weevent-build/modules/processor/install-processor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash

function processor_setup() {
echo "install processor into ${out_path} "

#create processor list
mkdir -p ${out_path}
cp -r ./* ${out_path}/
rm -f ${out_path}/install-processor.sh

if [[ -z ${server_port} ]];then
echo "server_port is empty."
echo "set server_port failed"
exit 1
else
sed -i "/server.port*/cserver.port=${server_port}" ${out_path}/conf/application-prod.properties
fi
echo "set server_port success"

if [[ -z ${mysql_ip} ]];then
echo "mysql_ip is empty."
echo "set mysql_ip failed"
exit 1
else
sed -i "s/127.0.0.1:3306/${mysql_ip}:3306/" ${out_path}/conf/application-prod.properties
fi
echo "set mysql_ip success"

if [[ -z ${mysql_port} ]];then
echo "mysql_port is empty."
echo "set mysql_port failed"
exit 1
else
sed -i "s/3306/${mysql_port}/" ${out_path}/conf/application-prod.properties
fi
echo "set mysql_port success"

if [[ -z ${mysql_user} ]];then
echo "mysql_user is empty."
echo "set mysql_user failed"
exit 1
else
sed -i "s/xxxx/${mysql_user}/" ${out_path}/conf/application-prod.properties
fi
echo "set mysql_user success"

if [[ -z ${mysql_pwd} ]];then
echo "mysql_pwd is empty"
echo "set mysql_pwd failed"
exit 1
else
sed -i "s/yyyy/${mysql_pwd}/" ${out_path}/conf/application-prod.properties
fi
echo "set mysql_pwd success"


# init db, create database and tables
cd ${out_path}
./init-processor.sh
if [[ $? -ne 0 ]];then
echo "Error,init mysql fail"
exit 1
fi
echo "init db success"

echo "processor module install success"
}

#get parameter
para=""

# usage
if [[ $# -lt 2 ]]; then
echo "Usage:"
echo " $0 --out_path /data/app/weevent-install/processor "
echo " --server_port --mysql_ip --mysql_port --mysql_user --mysql_pwd "
exit 1
fi

server_port=""
mysql_ip=""
mysql_port=""
mysql_user=""
mysql_pwd=""
out_path=""
current_path=$(pwd)
echo "current path $current_path"

while [[ $# -ge 2 ]] ; do
case "$1" in
--out_path) para="$1 = $2;";out_path="$2";shift 2;;
--server_port) para="$1 = $2;";server_port="$2";shift 2;;
--mysql_ip) para="$1 = $2;";mysql_ip="$2";shift 2;;
--mysql_port) para="$1 = $2;";mysql_port="$2";shift 2;;
--mysql_user) para="$1 = $2;";mysql_user="$2";shift 2;;
--mysql_pwd) para="$1 = $2;";mysql_pwd="$2";shift 2;;
*) echo "unknown parameter $1." ; exit 1 ; break;;
esac
done

processor_setup
32 changes: 32 additions & 0 deletions weevent-build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ function copy_install_file(){
cp ${current_path}/modules/governance/install-governance.sh ${out_path}/modules/governance
cp -r ${top_path}/weevent-governance/dist/* ${out_path}/modules/governance

mkdir -p ${out_path}/modules/processor
cp ${current_path}/modules/processor/install-processor.sh ${out_path}/modules/processor
cp -r ${top_path}/weevent-processor/dist/* ${out_path}/modules/processor



mkdir -p ${out_path}/modules/nginx
cp ${current_path}/modules/nginx/install-nginx.sh ./modules/nginx/nginx.sh ${out_path}/modules/nginx
cp -r ${current_path}/modules/nginx/conf ${out_path}/modules/nginx
Expand All @@ -125,6 +131,11 @@ function switch_to_prod(){
if [[ -e ${out_path}/modules/governance/conf/application.properties ]]; then
sed -i 's/dev/prod/' ${out_path}/modules/governance/conf/application.properties
fi

rm -rf ${out_path}/modules/processor/conf/application-dev.properties
if [[ -e ${out_path}/modules/processor/conf/application.properties ]]; then
sed -i 's/dev/prod/' ${out_path}/modules/processor/conf/application.properties
fi
}

function tar_broker(){
Expand Down Expand Up @@ -159,6 +170,23 @@ function tar_governance(){
rm -rf ${current_path}/governance-${version}
}


function tar_processor(){
local target=$1
yellow_echo "generate ${target}"

cp -r ${out_path}/modules/processor ${current_path}/processor-${version}
# no need install shell
rm -rf ${current_path}/processor-${version}/install-processor.sh

# do not tar the top dir
cd ${current_path}/processor-${version}
tar -czpvf ${target} *
mv ${target} ${current_path}

rm -rf ${current_path}/processor-${version}
}

function tar_weevent(){
local target=$1
yellow_echo "generate ${target}"
Expand All @@ -171,6 +199,7 @@ function tar_weevent(){
if [[ -e ${out_path}/modules/governance/lib/${commonjar} ]]; then
cp ${out_path}/modules/broker/lib/${commonjar} ${out_path}/modules/lib
rm ${out_path}/modules/governance/lib/${commonjar}
rm ${out_path}/modules/processor/lib/${commonjar}
rm ${out_path}/modules/broker/lib/${commonjar}
fi
done
Expand Down Expand Up @@ -203,6 +232,9 @@ function package(){
# tar governance module
tar_governance weevent-governance-${version}.tar.gz

# tar processor module
tar_processor weevent-processor-${version}.tar.gz

# tar weevent
tar_weevent weevent-${version}.tar.gz

Expand Down
82 changes: 82 additions & 0 deletions weevent-processor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"

dependencies {
// spring boot
implementation("org.springframework.boot:spring-boot-starter")

implementation("org.springframework.boot:spring-boot-starter-web")

runtime('mysql:mysql-connector-java')

// spring boot with log4j2
implementation("org.springframework.boot:spring-boot-starter-log4j2")

// avoid "Log4j appears to be running in a Servlet environment, but there's no log4j-web module available."
implementation("org.apache.logging.log4j:log4j-web:2.11.2")

implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1")

implementation("org.apache.tomcat:tomcat-jdbc:8.5.23");

implementation("log4j:log4j:1.2.17")

implementation("com.webank.weevent:weevent-client:1.0.0")

//fastjson
implementation("com.alibaba:fastjson:1.2.47")

// redis
implementation("redis.clients:jedis:3.0.1")

testImplementation("org.springframework.boot:spring-boot-starter-test")

implementation("org.apache.commons:commons-pool2:2.7.0")

implementation("org.apache.commons:commons-jexl3:3.1")

implementation("org.springframework:spring-context-support")
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
implementation("org.quartz-scheduler:quartz:2.2.1")
}

bootJar {
destinationDir file("dist/apps")
archiveName project.name + "-" + version + ".jar"

// thin spring boot jar
excludes = ["*.jar"]

doLast {
copy {
from file("src/main/resources/")
into "dist/conf"
}
copy {
from configurations.runtimeClasspath
into "dist/lib"
}
}
}
//mybatis generator plugin ------ start
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.arenagod.gradle:mybatis-generator-plugin:1.4"
}
}

apply plugin: "com.arenagod.gradle.MybatisGenerator"

configurations {
mybatisGenerator
}

mybatisGenerator {
verbose = true
configFile = 'src/main/resources/tools/generatorConfig.xml'
}
Loading

0 comments on commit c382473

Please sign in to comment.