diff options
author | tangpeng <tang.peng5@zte.com.cn> | 2017-02-21 16:42:42 +0800 |
---|---|---|
committer | tangpeng <tang.peng5@zte.com.cn> | 2017-02-21 16:46:30 +0800 |
commit | 9c14e8bc2360c0098a23486ea71fc5c99e2fd64e (patch) | |
tree | c21b6b4f284e0924e9b0b610f921da2263350bff /engine-d-standalone | |
parent | f7907354daf58f6a729556e21ba01cae777de0be (diff) |
Add holmes-engine-d-standalone module
Change-Id: I92203b32eac0888ba6df0328a6bc0a918909e3b3
Issue-Id:HOLMES-45
Signed-off-by: tangpeng <tang.peng5@zte.com.cn>
Diffstat (limited to 'engine-d-standalone')
10 files changed, 503 insertions, 0 deletions
diff --git a/engine-d-standalone/pom.xml b/engine-d-standalone/pom.xml new file mode 100644 index 0000000..b6b14e1 --- /dev/null +++ b/engine-d-standalone/pom.xml @@ -0,0 +1,168 @@ +<?xml version="1.0"?> +<!-- + + Copyright 2017 ZTE Corporation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.openo.holmes.engine-management</groupId> + <artifactId>holmes-engine-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>holmes-engine-d-standalone</artifactId> + <modelVersion>4.0.0</modelVersion> + <name>holmes-engine/holmes-engine-d-standalone</name> + <packaging>pom</packaging> + + <build> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-resources-${linux64id}</id> + <phase>process-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${linux64outputdir}</outputDirectory> + <resources> + <resource> + <directory>src/main/assembly/</directory> + <filtering>false</filtering> + <includes> + <include>**/*</include> + </includes> + <excludes> + <exclude>**/*.bat</exclude> + </excludes> + </resource> + </resources> + <overwrite>true</overwrite> + </configuration> + </execution> + <execution> + <id>copy-resources-${win64id}</id> + <phase>process-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${win64outputdir}</outputDirectory> + <resources> + <resource> + <directory>src/main/assembly/</directory> + <filtering>false</filtering> + <includes> + <include>**/*</include> + </includes> + <excludes> + <exclude>**/*.sh</exclude> + </excludes> + </resource> + </resources> + <overwrite>true</overwrite> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-jar-${linux64id}</id> + <goals> + <goal>copy</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.openo.holmes.engine-management</groupId> + <artifactId>holmes-engine-d</artifactId> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>${linux64outputdir}</outputDirectory> + <destFileName>holmes-engine-d.jar</destFileName> + </artifactItem> + </artifactItems> + </configuration> + </execution> + <execution> + <id>copy-jar-${win64id}</id> + <goals> + <goal>copy</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.openo.holmes.engine-management</groupId> + <artifactId>holmes-engine-d</artifactId> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>${win64outputdir}</outputDirectory> + <destFileName>holmes-engine-d.jar</destFileName> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>distribution</id> + <phase>package</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <target name="distribution"> + <tar destfile="${version.output}/${packagename}-${project.version}-linux64.tar.gz" longfile="posix" compression="gzip"> + <tarfileset dir="target/assembly/linux64" filemode="0644" dirmode="0755"> + <exclude name="**/*.sh"/> + </tarfileset> + <tarfileset dir="target/assembly/linux64" filemode="0755" dirmode="0755"> + <include name="**/*.sh"/> + </tarfileset> + </tar> + <attachartifact file="${version.output}/${packagename}-${project.version}-linux64.tar.gz" classifier="linux64" type="tar.gz"/> + <zip destfile="${version.output}/${packagename}-${project.version}-win64.zip" update="true"> + <zipfileset dir="target/assembly/win64" includes="**"/> + </zip> + <attachartifact file="${version.output}/${packagename}-${project.version}-win64.zip" classifier="win64" type="zip"/> + </target> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.openo.holmes.engine-management</groupId> + <artifactId>holmes-engine-d</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat b/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat new file mode 100644 index 0000000..6c61d50 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat @@ -0,0 +1,24 @@ +@REM
+@REM Copyright 2017 ZTE Corporation.
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+echo %1 | findstr %2 >NUL
+echo ERRORLEVEL=%ERRORLEVEL%
+IF ERRORLEVEL 1 goto findend
+for /f "tokens=1" %%a in (%1) do (
+ echo kill %1
+ taskkill /F /pid %%a
+)
+:findend
\ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/initDB.bat b/engine-d-standalone/src/main/assembly/bin/initDB.bat new file mode 100644 index 0000000..29a795c --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/initDB.bat @@ -0,0 +1,34 @@ +@REM +@REM Copyright 2017 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +set HOME=%~dp0 +set user=%1 +set password=%2 +set port=%3 +set host=%4 +echo start init holmes engine-d db +echo HOME=%HOME% +set main_path=%HOME%..\ +cd /d %main_path% +mysql -u%user% -p%password% -P%port% -h%host% < %main_path%\dbscripts\mysql\openo-holmes_engine_d-createobj.sql +set "err=%errorlevel%" +if "%err%"=="0" ( + echo init engine-d db success + ) else ( + echo failed init engine-d db + pause + )
\ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/initDB.sh b/engine-d-standalone/src/main/assembly/bin/initDB.sh new file mode 100644 index 0000000..7f16c2a --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/initDB.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +user=$1 +password=$2 +port=$3 +host=$4 +echo "start init holmes engine-d db" +main_path=$HOME/../ +mysql -u$user -p$password -P$port -h$host <$main_path/dbscripts/mysql/openo-holmes_engine_d-createobj.sql +sql_result=$? +if [ $sql_result != 0 ] ; then + echo "failed to init engine-d database!" + exit 1 +fi +echo "init engine-d success!" +exit 0 + diff --git a/engine-d-standalone/src/main/assembly/bin/run.bat b/engine-d-standalone/src/main/assembly/bin/run.bat new file mode 100644 index 0000000..89151e8 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/run.bat @@ -0,0 +1,41 @@ +@REM
+@REM Copyright 2017 ZTE Corporation.
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+title holmes-engine-d-service
+
+set RUNHOME=%~dp0
+echo ### RUNHOME: %RUNHOME%
+echo ### Starting engine-d-service
+set main_path=%RUNHOME%..\
+cd /d %main_path%
+set JAVA="%JAVA_HOME%\bin\java.exe"
+set port=8312
+set jvm_opts=-Xms50m -Xmx128m
+rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n
+set class_path=%main_path%;%main_path%holmes-engine-d.jar
+echo ### jvm_opts: %jvm_opts%
+echo ### class_path: %class_path%
+
+%JAVA% -classpath %class_path% %jvm_opts% org.openo.holmes.engine.EngineDActiveApp server %main_path%conf/engine-d.yml
+
+IF ERRORLEVEL 1 goto showerror
+exit
+:showerror
+echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
+echo After checking, press any key to close
+pause
+exit
\ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/run.sh b/engine-d-standalone/src/main/assembly/bin/run.sh new file mode 100644 index 0000000..4a93b50 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/run.sh @@ -0,0 +1,35 @@ +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +RUNHOME=`cd $DIRNAME/; pwd` +echo @RUNHOME@ $RUNHOME + +echo @JAVA_HOME@ $JAVA_HOME +JAVA="$JAVA_HOME/bin/java" +echo @JAVA@ $JAVA +main_path=$RUNHOME/../ +cd $main_path +JAVA_OPTS="-Xms50m -Xmx128m" +port=8312 +#JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n" +echo @JAVA_OPTS@ $JAVA_OPTS + +class_path="$main_path/:$main_path/holmes-engine-d.jar" +echo @class_path@ $class_path + +"$JAVA" $JAVA_OPTS -classpath "$class_path" org.openo.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml" + diff --git a/engine-d-standalone/src/main/assembly/bin/stop.bat b/engine-d-standalone/src/main/assembly/bin/stop.bat new file mode 100644 index 0000000..22280e7 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/stop.bat @@ -0,0 +1,34 @@ +@REM
+@REM Copyright 2017 ZTE Corporation.
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+title stopping engine-d-service
+
+set HOME=%~dp0
+set Main_Class="org.openo.holmes.engine.EngineDActiveApp"
+
+echo ================== engine-d-service info =============================================
+echo HOME=$HOME
+echo Main_Class=%Main_Class%
+echo ===============================================================================
+
+echo ### Stopping engine-d-service
+cd /d %HOME%
+
+for /f "delims=" %%i in ('"%JAVA_HOME%\bin\jcmd"') do (
+ call find_kill_process "%%i" %Main_Class%
+)
+exit
\ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/stop.sh b/engine-d-standalone/src/main/assembly/bin/stop.sh new file mode 100644 index 0000000..8f81bda --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/stop.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +Main_Class="org.openo.holmes.engine.EngineDActiveApp" + +echo ================== engine-d-service info ============================================= +echo HOME=$HOME +echo Main_Class=$Main_Class +echo =============================================================================== +cd $HOME; pwd + +echo @WORK_DIR@ $HOME + +function save_service_pid(){ + service_pid=`ps -ef | grep $Main_Class | grep -v grep | awk '{print $2}'` + echo @service_pid@ $service_pid +} + +function kill_service_process(){ + ps -p $service_pid + if [ $? == 0 ]; then + kill -9 $service_pid + fi +} + +save_service_pid; +echo @C_CMD@ kill -9 $service_pid +kill_service_process;
\ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/conf/engine-d.yml b/engine-d-standalone/src/main/assembly/conf/engine-d.yml new file mode 100644 index 0000000..247ac4b --- /dev/null +++ b/engine-d-standalone/src/main/assembly/conf/engine-d.yml @@ -0,0 +1,72 @@ +#
+# Copyright 2017 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+server:
+ type: simple
+ rootPath: '/api/holmes-engine/v1/*'
+ applicationContextPath: /
+ adminContextPath: /admin
+ connector:
+ type: http
+ port: 12003
+
+
+# Logging settings.
+logging:
+
+ # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
+ level: INFO
+
+ # Logger-specific levels.
+ loggers:
+
+ # Sets the level for 'com.example.app' to DEBUG.
+ com.example: DEBUG
+
+ appenders:
+ - type: console
+ threshold: INFO
+ timeZone: UTC
+ logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"
+ - type: file
+ threshold: INFO
+ logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"
+ currentLogFilename: ../logs/holmes-engine-d.log
+ archivedLogFilenamePattern: ../logs/zip/holmes-engine-d-%d{yyyy-MM-dd}.log.gz
+ archivedFileCount: 7
+
+
+database:
+ driverClass: com.mysql.jdbc.Driver
+ user: root
+ password: root321
+# url: jdbc:mysql://${db_ip}:${db_port}/mysql?useUnicode=relationtesttrue&characterEncoding=UTF8
+ url: jdbc:mysql://10.74.156.206:3306/mysql?useUnicode=true&characterEncoding=UTF8
+ properties:
+ charSet: UTF-8
+ maxWaitForConnection: 1s
+ validationQuery: "/* MyService Health Check */ SELECT 1"
+ minSize: 8
+ maxSize: 100
+ checkConnectionWhileIdle: false
+ evictionInterval: 10s
+ minIdleTime: 1s
+
+mqConfig:
+ brokerIp: 127.0.0.1
+ brokerPort: 61616
+ mqServiceName: activemq
+ mqServiceVersion: v1
+
diff --git a/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql b/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql new file mode 100644 index 0000000..4f5294a --- /dev/null +++ b/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql @@ -0,0 +1,17 @@ +--
+-- Copyright 2017 ZTE Corporation.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+
|