Add holmes-engine-d-standalone module
authortangpeng <tang.peng5@zte.com.cn>
Tue, 21 Feb 2017 08:42:42 +0000 (16:42 +0800)
committertangpeng <tang.peng5@zte.com.cn>
Tue, 21 Feb 2017 08:46:30 +0000 (16:46 +0800)
Change-Id: I92203b32eac0888ba6df0328a6bc0a918909e3b3
Issue-Id:HOLMES-45
Signed-off-by: tangpeng <tang.peng5@zte.com.cn>
engine-d-standalone/pom.xml [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/find_kill_process.bat [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/initDB.bat [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/initDB.sh [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/run.bat [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/run.sh [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/stop.bat [new file with mode: 0644]
engine-d-standalone/src/main/assembly/bin/stop.sh [new file with mode: 0644]
engine-d-standalone/src/main/assembly/conf/engine-d.yml [new file with mode: 0644]
engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql [new file with mode: 0644]
pom.xml

diff --git a/engine-d-standalone/pom.xml b/engine-d-standalone/pom.xml
new file mode 100644 (file)
index 0000000..b6b14e1
--- /dev/null
@@ -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 (file)
index 0000000..6c61d50
--- /dev/null
@@ -0,0 +1,24 @@
+@REM\r
+@REM Copyright 2017 ZTE Corporation.\r
+@REM\r
+@REM Licensed under the Apache License, Version 2.0 (the "License");\r
+@REM you may not use this file except in compliance with the License.\r
+@REM You may obtain a copy of the License at\r
+@REM\r
+@REM     http://www.apache.org/licenses/LICENSE-2.0\r
+@REM\r
+@REM Unless required by applicable law or agreed to in writing, software\r
+@REM distributed under the License is distributed on an "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+@REM See the License for the specific language governing permissions and\r
+@REM limitations under the License.\r
+@REM\r
+\r
+echo %1 | findstr %2 >NUL\r
+echo ERRORLEVEL=%ERRORLEVEL%\r
+IF ERRORLEVEL 1 goto findend\r
+for /f "tokens=1" %%a in (%1) do (  \r
+    echo kill %1\r
+    taskkill /F /pid %%a\r
+)\r
+: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 (file)
index 0000000..29a795c
--- /dev/null
@@ -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 (file)
index 0000000..7f16c2a
--- /dev/null
@@ -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 (file)
index 0000000..89151e8
--- /dev/null
@@ -0,0 +1,41 @@
+@REM\r
+@REM Copyright 2017 ZTE Corporation.\r
+@REM\r
+@REM Licensed under the Apache License, Version 2.0 (the "License");\r
+@REM you may not use this file except in compliance with the License.\r
+@REM You may obtain a copy of the License at\r
+@REM\r
+@REM     http://www.apache.org/licenses/LICENSE-2.0\r
+@REM\r
+@REM Unless required by applicable law or agreed to in writing, software\r
+@REM distributed under the License is distributed on an "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+@REM See the License for the specific language governing permissions and\r
+@REM limitations under the License.\r
+@REM\r
+\r
+@echo off\r
+title holmes-engine-d-service\r
+\r
+set RUNHOME=%~dp0\r
+echo ### RUNHOME: %RUNHOME%\r
+echo ### Starting engine-d-service\r
+set main_path=%RUNHOME%..\\r
+cd /d %main_path%\r
+set JAVA="%JAVA_HOME%\bin\java.exe"\r
+set port=8312\r
+set jvm_opts=-Xms50m -Xmx128m\r
+rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n\r
+set class_path=%main_path%;%main_path%holmes-engine-d.jar\r
+echo ### jvm_opts: %jvm_opts%\r
+echo ### class_path: %class_path%\r
+\r
+%JAVA% -classpath %class_path% %jvm_opts% org.openo.holmes.engine.EngineDActiveApp server %main_path%conf/engine-d.yml\r
+\r
+IF ERRORLEVEL 1 goto showerror\r
+exit\r
+:showerror\r
+echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!\r
+echo After checking, press any key to close \r
+pause\r
+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 (file)
index 0000000..4a93b50
--- /dev/null
@@ -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 (file)
index 0000000..22280e7
--- /dev/null
@@ -0,0 +1,34 @@
+@REM\r
+@REM Copyright 2017 ZTE Corporation.\r
+@REM\r
+@REM Licensed under the Apache License, Version 2.0 (the "License");\r
+@REM you may not use this file except in compliance with the License.\r
+@REM You may obtain a copy of the License at\r
+@REM\r
+@REM     http://www.apache.org/licenses/LICENSE-2.0\r
+@REM\r
+@REM Unless required by applicable law or agreed to in writing, software\r
+@REM distributed under the License is distributed on an "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+@REM See the License for the specific language governing permissions and\r
+@REM limitations under the License.\r
+@REM\r
+\r
+@echo off\r
+title stopping engine-d-service\r
+\r
+set HOME=%~dp0\r
+set Main_Class="org.openo.holmes.engine.EngineDActiveApp"\r
+\r
+echo ================== engine-d-service info =============================================\r
+echo HOME=$HOME\r
+echo Main_Class=%Main_Class%\r
+echo ===============================================================================\r
+\r
+echo ### Stopping engine-d-service\r
+cd /d %HOME%\r
+\r
+for /f "delims=" %%i in ('"%JAVA_HOME%\bin\jcmd"') do (\r
+  call find_kill_process "%%i" %Main_Class%\r
+)\r
+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 (file)
index 0000000..8f81bda
--- /dev/null
@@ -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 (file)
index 0000000..247ac4b
--- /dev/null
@@ -0,0 +1,72 @@
+#\r
+# Copyright 2017 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#     http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+#\r
+server:\r
+  type: simple\r
+  rootPath: '/api/holmes-engine/v1/*'\r
+  applicationContextPath: /\r
+  adminContextPath: /admin\r
+  connector:\r
+    type: http\r
+    port: 12003\r
+\r
+\r
+# Logging settings.\r
+logging:\r
+\r
+  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.\r
+  level: INFO\r
+\r
+  # Logger-specific levels.\r
+  loggers:\r
+\r
+    # Sets the level for 'com.example.app' to DEBUG.\r
+    com.example: DEBUG\r
+\r
+  appenders:\r
+    - type: console\r
+      threshold: INFO\r
+      timeZone: UTC\r
+      logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"\r
+    - type: file\r
+      threshold: INFO\r
+      logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"\r
+      currentLogFilename: ../logs/holmes-engine-d.log\r
+      archivedLogFilenamePattern: ../logs/zip/holmes-engine-d-%d{yyyy-MM-dd}.log.gz\r
+      archivedFileCount: 7\r
+\r
+\r
+database:\r
+  driverClass: com.mysql.jdbc.Driver\r
+  user: root\r
+  password: root321\r
+#  url: jdbc:mysql://${db_ip}:${db_port}/mysql?useUnicode=relationtesttrue&characterEncoding=UTF8\r
+  url: jdbc:mysql://10.74.156.206:3306/mysql?useUnicode=true&characterEncoding=UTF8\r
+  properties:\r
+    charSet: UTF-8\r
+  maxWaitForConnection: 1s\r
+  validationQuery: "/* MyService Health Check */ SELECT 1"\r
+  minSize: 8\r
+  maxSize: 100\r
+  checkConnectionWhileIdle: false\r
+  evictionInterval: 10s\r
+  minIdleTime: 1s\r
+\r
+mqConfig:\r
+  brokerIp: 127.0.0.1\r
+  brokerPort: 61616\r
+  mqServiceName: activemq\r
+  mqServiceVersion: v1\r
+\r
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 (file)
index 0000000..4f5294a
--- /dev/null
@@ -0,0 +1,17 @@
+--\r
+-- Copyright 2017 ZTE Corporation.\r
+--\r
+-- Licensed under the Apache License, Version 2.0 (the "License");\r
+-- you may not use this file except in compliance with the License.\r
+-- You may obtain a copy of the License at\r
+--\r
+--     http://www.apache.org/licenses/LICENSE-2.0\r
+--\r
+-- Unless required by applicable law or agreed to in writing, software\r
+-- distributed under the License is distributed on an "AS IS" BASIS,\r
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+-- See the License for the specific language governing permissions and\r
+-- limitations under the License.\r
+--\r
+\r
+\r
diff --git a/pom.xml b/pom.xml
index 6e90aa4..89c3963 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,7 @@
     <name>holmes-engine-parent</name>
     <modules>
         <module>engine-d</module>
+        <module>engine-d-standalone</module>
     </modules>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <jaxrs.consumer.version>5.0</jaxrs.consumer.version>
         <slf4j.version>1.6.1</slf4j.version>
         <quartz.version>2.2.1</quartz.version>
+
+        <packagename>openo-holmes-engine-d</packagename>
+        <linux64id>linux64</linux64id>
+        <win64id>win64</win64id>
+        <linux64outputdir>target/assembly/${linux64id}</linux64outputdir>
+        <win64outputdir>target/assembly/${win64id}</win64outputdir>
+        <version.output>target/version</version.output>
     </properties>
     <dependencyManagement>
         <dependencies>