initial commit
This commit is contained in:
36
.classpath
Normal file
36
.classpath
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_45"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-collections.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-io.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-net-ftp-2.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ezmorph-1.0.4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jpcap.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/json-lib-2.2.2-jdk15.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/junit.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ojdbc14.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/mail.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/sigar.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ObjectSNMP.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/fileComment.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/snmp4j-2.0.3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ant.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ganymed-ssh2-build210.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bonecp/bonecp-0.8.0-rc2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bonecp/guava-14.0-rc3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bonecp/slf4j-api-1.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bonecp/slf4j-log4j12-1.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.0-bin.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/tools-1.8.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jconsole-1.8.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/druid-1.1.10.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/FUtil-0.5.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/netty-all-4.1.28.Final.jar" sourcepath="lib/netty-all-4.1.28.Final-sources.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>nms_server</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
4
.settings/org.eclipse.core.resources.prefs
Normal file
4
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#Mon Feb 18 10:07:20 CST 2013
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/myconfig.properties=UTF-8
|
||||||
|
encoding/<project>=UTF-8
|
||||||
3
META-INF/MANIFEST.MF
Normal file
3
META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Sealed: true
|
||||||
|
|
||||||
BIN
cer/client.cer
Normal file
BIN
cer/client.cer
Normal file
Binary file not shown.
BIN
cer/client_ks
Normal file
BIN
cer/client_ks
Normal file
Binary file not shown.
BIN
cer/client_ts
Normal file
BIN
cer/client_ts
Normal file
Binary file not shown.
BIN
cer/server.cer
Normal file
BIN
cer/server.cer
Normal file
Binary file not shown.
BIN
cer/server_ks
Normal file
BIN
cer/server_ks
Normal file
Binary file not shown.
BIN
cer/server_ts
Normal file
BIN
cer/server_ts
Normal file
Binary file not shown.
BIN
lib/FUtil-0.5.jar
Normal file
BIN
lib/FUtil-0.5.jar
Normal file
Binary file not shown.
BIN
lib/ObjectSNMP.jar
Normal file
BIN
lib/ObjectSNMP.jar
Normal file
Binary file not shown.
BIN
lib/ant.jar
Normal file
BIN
lib/ant.jar
Normal file
Binary file not shown.
BIN
lib/bonecp/bonecp-0.8.0-rc2.jar
Normal file
BIN
lib/bonecp/bonecp-0.8.0-rc2.jar
Normal file
Binary file not shown.
BIN
lib/bonecp/guava-14.0-rc3.jar
Normal file
BIN
lib/bonecp/guava-14.0-rc3.jar
Normal file
Binary file not shown.
BIN
lib/bonecp/slf4j-api-1.6.1.jar
Normal file
BIN
lib/bonecp/slf4j-api-1.6.1.jar
Normal file
Binary file not shown.
BIN
lib/bonecp/slf4j-log4j12-1.6.1.jar
Normal file
BIN
lib/bonecp/slf4j-log4j12-1.6.1.jar
Normal file
Binary file not shown.
BIN
lib/commons-beanutils-1.7.jar
Normal file
BIN
lib/commons-beanutils-1.7.jar
Normal file
Binary file not shown.
BIN
lib/commons-collections.jar
Normal file
BIN
lib/commons-collections.jar
Normal file
Binary file not shown.
BIN
lib/commons-io.jar
Normal file
BIN
lib/commons-io.jar
Normal file
Binary file not shown.
BIN
lib/commons-lang.jar
Normal file
BIN
lib/commons-lang.jar
Normal file
Binary file not shown.
BIN
lib/commons-logging.jar
Normal file
BIN
lib/commons-logging.jar
Normal file
Binary file not shown.
BIN
lib/commons-net-ftp-2.0.jar
Normal file
BIN
lib/commons-net-ftp-2.0.jar
Normal file
Binary file not shown.
BIN
lib/druid-1.1.10.jar
Normal file
BIN
lib/druid-1.1.10.jar
Normal file
Binary file not shown.
BIN
lib/ezmorph-1.0.4.jar
Normal file
BIN
lib/ezmorph-1.0.4.jar
Normal file
Binary file not shown.
BIN
lib/fileComment.jar
Normal file
BIN
lib/fileComment.jar
Normal file
Binary file not shown.
BIN
lib/ganymed-ssh2-build210.jar
Normal file
BIN
lib/ganymed-ssh2-build210.jar
Normal file
Binary file not shown.
BIN
lib/jconsole-1.8.0.jar
Normal file
BIN
lib/jconsole-1.8.0.jar
Normal file
Binary file not shown.
BIN
lib/jpcap.jar
Normal file
BIN
lib/jpcap.jar
Normal file
Binary file not shown.
BIN
lib/json-lib-2.2.2-jdk15.jar
Normal file
BIN
lib/json-lib-2.2.2-jdk15.jar
Normal file
Binary file not shown.
BIN
lib/junit.jar
Normal file
BIN
lib/junit.jar
Normal file
Binary file not shown.
BIN
lib/log4j-1.2.15.jar
Normal file
BIN
lib/log4j-1.2.15.jar
Normal file
Binary file not shown.
BIN
lib/mail.jar
Normal file
BIN
lib/mail.jar
Normal file
Binary file not shown.
BIN
lib/mysql-connector-java-5.1.0-bin.jar
Normal file
BIN
lib/mysql-connector-java-5.1.0-bin.jar
Normal file
Binary file not shown.
BIN
lib/netty-all-4.1.28.Final.jar
Normal file
BIN
lib/netty-all-4.1.28.Final.jar
Normal file
Binary file not shown.
BIN
lib/ojdbc14.jar
Normal file
BIN
lib/ojdbc14.jar
Normal file
Binary file not shown.
BIN
lib/ostermillerutils_1_07_00.jar
Normal file
BIN
lib/ostermillerutils_1_07_00.jar
Normal file
Binary file not shown.
BIN
lib/sigar.jar
Normal file
BIN
lib/sigar.jar
Normal file
Binary file not shown.
BIN
lib/snmp4j-2.0.3.jar
Normal file
BIN
lib/snmp4j-2.0.3.jar
Normal file
Binary file not shown.
BIN
lib/tools-1.8.0.jar
Normal file
BIN
lib/tools-1.8.0.jar
Normal file
Binary file not shown.
2
linuxinstall/conf/jvm.conf
Normal file
2
linuxinstall/conf/jvm.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-Xms64m
|
||||||
|
-Xmx128m
|
||||||
281
linuxinstall/install.sh
Normal file
281
linuxinstall/install.sh
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DEFAULT_DATA_DIR="/home/nms/nmsdata"
|
||||||
|
DEFAULT_INSTALL_DIR="/home/nms/datacontroller"
|
||||||
|
|
||||||
|
# --- set install dir
|
||||||
|
PRG="$0"
|
||||||
|
PRGDIR=`dirname "$PRG"`
|
||||||
|
CUR_PRGDIR=`cd "$PRGDIR"; pwd`
|
||||||
|
|
||||||
|
if [ $# = 0 ]
|
||||||
|
then
|
||||||
|
echo -n "enter intall dir [default: $DEFAULT_INSTALL_DIR]:"
|
||||||
|
read INSTALL_DIR
|
||||||
|
if [ -z "$INSTALL_DIR" ]; then
|
||||||
|
INSTALL_DIR="$DEFAULT_INSTALL_DIR"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
INSTALL_DIR="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $INSTALL_DIR ]
|
||||||
|
then
|
||||||
|
mkdir -p $INSTALL_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
INSTALL_DIR=`cd "$INSTALL_DIR"; pwd`
|
||||||
|
|
||||||
|
# --- check jdk and jdk-version
|
||||||
|
install_jdk=0
|
||||||
|
javaversion=`java -version 2>&1|grep "java version"`
|
||||||
|
if [ -n "$javaversion" ]
|
||||||
|
then
|
||||||
|
# javaversion=${javaversion:14:3}
|
||||||
|
javavmajor=`echo $javaversion | cut -c15`
|
||||||
|
javavminor=`echo $javaversion | cut -c17`
|
||||||
|
# OS_TYPE=$( lsb_release -d| cut -d: -f2| cut -f2 )
|
||||||
|
# if [ "`echo $OS_TYPE | cut -c1-6`" = "Ubuntu" ]
|
||||||
|
# then
|
||||||
|
# if [ 2 -gt $javavmajor ]; then
|
||||||
|
# if [ 6 -gt $javavminor ]; then
|
||||||
|
# install_jdk=1
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
if [[ 2 -gt $javavmajor && 6 -gt $javavminor ]]; then
|
||||||
|
install_jdk=1
|
||||||
|
fi
|
||||||
|
# fi
|
||||||
|
else
|
||||||
|
install_jdk=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- install jdk
|
||||||
|
cd "$INSTALL_DIR"/..
|
||||||
|
NMS_JDK="$(pwd)/nmsjdk"
|
||||||
|
JDK_DIR="$(pwd)/jdk1.7.0_80"
|
||||||
|
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-i586.tar.gz"
|
||||||
|
if [ "`uname -i`" = "x86_64" ];then
|
||||||
|
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-x64.tar.gz"
|
||||||
|
fi
|
||||||
|
if [ $install_jdk = 1 ]
|
||||||
|
then
|
||||||
|
if [ ! -e "$NMS_JDK" ]
|
||||||
|
then
|
||||||
|
echo "JDK bin file: $JDK_BIN_FILE"
|
||||||
|
echo "now, install jdk: $JDK_DIR"
|
||||||
|
sleep 3
|
||||||
|
if [ ! -e "$JDK_DIR" ];then
|
||||||
|
mkdir -p $JDK_DIR
|
||||||
|
fi
|
||||||
|
tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
|
||||||
|
if [ -n "$installJdk" ];then
|
||||||
|
echo "install jdk failure, exit program"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ln -s $JDK_DIR $NMS_JDK
|
||||||
|
echo "install jdk done"
|
||||||
|
fi
|
||||||
|
elif [ -n "$JAVA_HOME" ];then
|
||||||
|
ln -s $JAVA_HOME $NMS_JDK
|
||||||
|
else
|
||||||
|
echo "JDK bin file: $JDK_BIN_FILE"
|
||||||
|
echo "now, install jdk: $JDK_DIR"
|
||||||
|
sleep 3
|
||||||
|
if [ ! -e "$JDK_DIR" ];then
|
||||||
|
mkdir -p $JDK_DIR
|
||||||
|
fi
|
||||||
|
tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
|
||||||
|
if [ -n "$installJdk" ];then
|
||||||
|
echo "install jdk failure, exit program"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ln -s $JDK_DIR $NMS_JDK
|
||||||
|
echo "install jdk done"
|
||||||
|
fi
|
||||||
|
cd "$CUR_PRGDIR"
|
||||||
|
|
||||||
|
echo "==========================================="
|
||||||
|
echo "NMS_JDK: $NMS_JDK"
|
||||||
|
echo "INSTALL_DIR: $INSTALL_DIR"
|
||||||
|
echo "==========================================="
|
||||||
|
|
||||||
|
# --- copy file to install_dir
|
||||||
|
if [ "$INSTALL_DIR" == "$CUR_PRGDIR" ]
|
||||||
|
then
|
||||||
|
echo "install directory is current program directory..."
|
||||||
|
else
|
||||||
|
echo "install program, it may take a few time..."
|
||||||
|
CP_DIR=(
|
||||||
|
bin
|
||||||
|
lib
|
||||||
|
conf
|
||||||
|
shell
|
||||||
|
)
|
||||||
|
#cp
|
||||||
|
for CP_NAME in ${CP_DIR[@]}
|
||||||
|
do
|
||||||
|
echo $CP_NAME
|
||||||
|
cp -a $CUR_PRGDIR"/$CP_NAME" $INSTALL_DIR
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
function modify_file(){
|
||||||
|
if [ $# != 2 ]
|
||||||
|
then
|
||||||
|
echo "usage: modify_file [prop_name] [prop_value]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
prop_name="$1"
|
||||||
|
prop_value="$2"
|
||||||
|
#echo "modify_file $prop_name $prop_value"
|
||||||
|
if [ -z "$(cat $PROP_FILE |grep $prop_name)" ]
|
||||||
|
then
|
||||||
|
echo "" >> $PROP_FILE
|
||||||
|
echo "$prop_name=$prop_value" >> $PROP_FILE
|
||||||
|
else
|
||||||
|
sed -i "s|^$prop_name.*|$prop_name=$prop_value|" $PROP_FILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
enter_password=""
|
||||||
|
function readPasswd(){
|
||||||
|
enter_password=""
|
||||||
|
stty -echo cbreak
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
character=$(dd if=/dev/tty bs=1 count=1 2> /dev/null)
|
||||||
|
case $character in
|
||||||
|
$(echo -e "\n"))
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
$(echo -e "\b"))
|
||||||
|
if [ -n "$enter_password" ]; then
|
||||||
|
echo -n -e "\b \b"
|
||||||
|
enter_password=$(echo "$password" | sed 's/.$//g')
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
enter_password=$enter_password$character
|
||||||
|
echo -n '*'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
stty -cbreak echo
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# modify property
|
||||||
|
PROP_FILE=$INSTALL_DIR"/conf/myconfig.properties"
|
||||||
|
|
||||||
|
#echo "PROP_FILE: $PROP_FILE"
|
||||||
|
|
||||||
|
#-------------data dir
|
||||||
|
echo -n "enter data dir [default $DEFAULT_DATA_DIR]: "
|
||||||
|
read data_path
|
||||||
|
if [ -z "$data_path" ]
|
||||||
|
then
|
||||||
|
data_path="$DEFAULT_DATA_DIR"
|
||||||
|
fi
|
||||||
|
#-------------local ip
|
||||||
|
echo -n "enter local ip: "
|
||||||
|
read local_ip
|
||||||
|
while [ -z "$local_ip" ]
|
||||||
|
do
|
||||||
|
echo -n "local ip cannot null, please enter local ip: "
|
||||||
|
read local_ip
|
||||||
|
done
|
||||||
|
#-------------nmsweb ip
|
||||||
|
echo -n "enter nmsweb ip: "
|
||||||
|
read nmsweb_ip
|
||||||
|
while [ -z "$nmsweb_ip" ]
|
||||||
|
do
|
||||||
|
echo -n "nmsweb ip cannot null, please enter nmsweb ip: "
|
||||||
|
read nmsweb_ip
|
||||||
|
done
|
||||||
|
#-------------db url
|
||||||
|
#echo -n "enter database url: "
|
||||||
|
#read db_url
|
||||||
|
#while [ -z "$db_url" ]
|
||||||
|
# do
|
||||||
|
# echo -n "database url cannot null, please enter database url: "
|
||||||
|
# read db_url
|
||||||
|
#done
|
||||||
|
|
||||||
|
#2018-08-26 修改url为只传host和port(默认3306)拼接完成后赋值给db.url
|
||||||
|
DBPORT=3306
|
||||||
|
#-------------db host
|
||||||
|
echo -n "enter database host:"
|
||||||
|
read db_host
|
||||||
|
while [ -z "$db_host" ]
|
||||||
|
do
|
||||||
|
echo -n "database host cannot null,please enter database host:"
|
||||||
|
read db_host
|
||||||
|
done
|
||||||
|
|
||||||
|
#-------------db port
|
||||||
|
echo -n "enter database port[default port 3306]:"
|
||||||
|
read db_port
|
||||||
|
if [ -z "$db_port" ]
|
||||||
|
then
|
||||||
|
db_port="$DBPORT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#-----------db url
|
||||||
|
db_url="jdbc:mysql://"${db_host}":"${db_port}"/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true"
|
||||||
|
|
||||||
|
#-------------db username
|
||||||
|
echo -n "enter database username: "
|
||||||
|
read db_username
|
||||||
|
while [ -z "$db_username" ]
|
||||||
|
do
|
||||||
|
echo -n "database username cannot null, please enter database username: "
|
||||||
|
read db_username
|
||||||
|
done
|
||||||
|
#-------------db password
|
||||||
|
echo -n "enter database password: "
|
||||||
|
readPasswd
|
||||||
|
db_passwd="$enter_password"
|
||||||
|
while [ -z "$db_passwd" ]
|
||||||
|
do
|
||||||
|
echo -n "database password cannot null, please enter database password: "
|
||||||
|
readPasswd
|
||||||
|
db_passwd="$enter_password"
|
||||||
|
done
|
||||||
|
#-------------log4j dir
|
||||||
|
echo -n "enter logs path [default $data_path/dc_logs]: "
|
||||||
|
read logs_path
|
||||||
|
if [ -z "$logs_path" ]
|
||||||
|
then
|
||||||
|
logs_path="$data_path/dc_logs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
modify_file "common.datas.dir" $data_path
|
||||||
|
modify_file "system.inet.address" $local_ip
|
||||||
|
modify_file "web.socket.ip" $nmsweb_ip
|
||||||
|
modify_file "db.url" $db_url
|
||||||
|
modify_file "db.username" $db_username
|
||||||
|
modify_file "db.password" $db_passwd
|
||||||
|
|
||||||
|
# modify log4j
|
||||||
|
PROP_FILE=$INSTALL_DIR"/conf/log4j.properties"
|
||||||
|
encoding=${LANG#*.}
|
||||||
|
modify_file "log4j.appender.stdout.encoding" $encoding
|
||||||
|
modify_file "log4j.appender.debugAppender.encoding" $encoding
|
||||||
|
modify_file "log4j.appender.infoAppender.encoding" $encoding
|
||||||
|
modify_file "log4j.appender.debugAppender.File" "$logs_path/datacontroller_debug.log"
|
||||||
|
modify_file "log4j.appender.infoAppender.File" "$logs_path/datacontroller_info.log"
|
||||||
|
|
||||||
|
#permit
|
||||||
|
cd $INSTALL_DIR"/shell"
|
||||||
|
chmod 755 *.sh
|
||||||
|
cd $CUR_DIR
|
||||||
|
|
||||||
|
if [ -z "$(cat /etc/rc.local|grep $INSTALL_DIR"/shell/startup.sh")" ]
|
||||||
|
then
|
||||||
|
echo $INSTALL_DIR"/shell/startup.sh" >> /etc/rc.local
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "install successed..."
|
||||||
|
echo "please use [$INSTALL_DIR/shell/startup.sh] to run the program..."
|
||||||
47
linuxinstall/readme.txt
Normal file
47
linuxinstall/readme.txt
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
DC--Linux下的安装文件结构:
|
||||||
|
|
||||||
|
|--DC_install
|
||||||
|
| |--bin
|
||||||
|
| | |--cer
|
||||||
|
| | | |--client_ks
|
||||||
|
| | | |--client_ts
|
||||||
|
| | | |--server_ks
|
||||||
|
| | | |--server_ts
|
||||||
|
| | |--DataController.jar
|
||||||
|
| |--conf
|
||||||
|
| | |--jvm.conf
|
||||||
|
| | |--log4j.properties
|
||||||
|
| | |--myconfig.properties
|
||||||
|
| |--jre_install
|
||||||
|
| | |--jre-6u45-linux-i586.bin
|
||||||
|
| | |--jre-6u45-linux-x64.bin
|
||||||
|
| |--lib
|
||||||
|
| | |--ant.jar
|
||||||
|
| | |--bonecp-0.7.1.RELEASE.jar
|
||||||
|
| | |--commons-beanutils-1.7.jar
|
||||||
|
| | |--commons-collections.jar
|
||||||
|
| | |--commons-io.jar
|
||||||
|
| | |--commons-lang.jar
|
||||||
|
| | |--commons-logging.jar
|
||||||
|
| | |--ezmorph-1.0.4.jar
|
||||||
|
| | |--fileComment.jar
|
||||||
|
| | |--google-collections-1.0.jar
|
||||||
|
| | |--jpcap.jar
|
||||||
|
| | |--json-lib-2.2.2-jdk15.jar
|
||||||
|
| | |--junit.jar
|
||||||
|
| | |--log4j-1.2.15.jar
|
||||||
|
| | |--mail.jar
|
||||||
|
| | |--ObjectSNMP.jar
|
||||||
|
| | |--ojdbc14.jar
|
||||||
|
| | |--ostermillerutils_1_07_00.jar
|
||||||
|
| | |--sigar.jar
|
||||||
|
| | |--slf4j-api-1.5.10.jar
|
||||||
|
| | |--slf4j-log4j12-1.5.10.jar
|
||||||
|
| | |--snmp4j-2.0.3.jar
|
||||||
|
| |--shell
|
||||||
|
| | |--datacontroller.sh
|
||||||
|
| | |--shutdown.sh
|
||||||
|
| | |--startup.sh
|
||||||
|
| |--install.sh
|
||||||
|
|
||||||
|
注意:.properties配置文件中不能包含汉字。
|
||||||
11
linuxinstall/shell/07-15-Linux下定时重启DC更新说明.txt
Normal file
11
linuxinstall/shell/07-15-Linux下定时重启DC更新说明.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
DC更新步骤:
|
||||||
|
1.更新DC的脚本restart.sh 和 datacontroller.sh
|
||||||
|
2.更新DC的zip包:bin(DataController.exe 和 DCConfig.exe)、lib
|
||||||
|
3.新建crontab定时任务(每隔2天,在晚上23:59分重启DC)
|
||||||
|
任务内容为:59 23 */2 * * /home/nms/datacontroller/shell/restart.sh
|
||||||
|
相关命令:
|
||||||
|
编辑定时任务:crontab -e
|
||||||
|
查看定时任务:crontab -l
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
197
linuxinstall/shell/datacontroller.sh
Normal file
197
linuxinstall/shell/datacontroller.sh
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Start/Stop Script for the DATACONTROLLER Server
|
||||||
|
#
|
||||||
|
# Environment Variable Prequisites
|
||||||
|
#
|
||||||
|
# DATACONTROLLER_HOME May point at your DATACONTROLLER "build" directory.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# resolve links - $0 may be a softlink
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PRGDIR=`dirname "$PRG"`
|
||||||
|
|
||||||
|
# Only set DATACONTROLLER_HOME if not already set
|
||||||
|
[ -z "$DATACONTROLLER_HOME" ] && DATACONTROLLER_HOME=`cd "$PRGDIR/.." ; pwd`
|
||||||
|
cd "$DATACONTROLLER_HOME"/shell
|
||||||
|
|
||||||
|
if [ -z "$DATACONTROLLER_TMPDIR" ] ; then
|
||||||
|
DATACONTROLLER_TMPDIR="$DATACONTROLLER_HOME"/temp
|
||||||
|
fi
|
||||||
|
if [ ! -d $DATACONTROLLER_TMPDIR ]
|
||||||
|
then
|
||||||
|
mkdir $DATACONTROLLER_TMPDIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------- check jdk
|
||||||
|
# check nmsjdk
|
||||||
|
NMS_HOME=`cd "$DATACONTROLLER_HOME/.." ; pwd`
|
||||||
|
cd "$DATACONTROLLER_HOME"/shell
|
||||||
|
NMS_JDK="$NMS_HOME"/nmsjdk
|
||||||
|
if [ ! -e "$NMS_JDK" ]
|
||||||
|
then
|
||||||
|
echo "$NMS_JDK not exist"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# check java -version
|
||||||
|
javaversion=`$NMS_JDK/bin/java -version 2>&1|grep "java version"`
|
||||||
|
if [ ! -n "$javaversion" ]
|
||||||
|
then
|
||||||
|
echo "$NMS_JDK cannot use, please install"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------- set jdk path
|
||||||
|
export JAVA_HOME=$NMS_JDK
|
||||||
|
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
|
||||||
|
temp=$CLASSPATH
|
||||||
|
#setting libs path
|
||||||
|
libs="$DATACONTROLLER_HOME"/lib/*
|
||||||
|
append(){
|
||||||
|
temp=$temp":"$1
|
||||||
|
}
|
||||||
|
for file in $libs; do
|
||||||
|
append $file
|
||||||
|
done
|
||||||
|
jars="$DATACONTROLLER_HOME"/bin/*
|
||||||
|
for file in $jars; do
|
||||||
|
append $file
|
||||||
|
done
|
||||||
|
export DC_CLASSPATH=$temp:.:$DATACONTROLLER_HOME/conf
|
||||||
|
export LD_LIBRARY_PATH=$DATACONTROLLERT_HOME/lib
|
||||||
|
export LANG=zh_CN.UTF-8
|
||||||
|
|
||||||
|
echo "Using DATACONTROLLER_HOME: $DATACONTROLLER_HOME"
|
||||||
|
echo "Using DATACONTROLLER_TMPDIR: $DATACONTROLLER_TMPDIR"
|
||||||
|
echo "Using JAVA_HOME: $JAVA_HOME"
|
||||||
|
echo "Using CLASSPATH: $DC_CLASSPATH"
|
||||||
|
|
||||||
|
# ---- get jvm param
|
||||||
|
jvmconf_file=$DATACONTROLLER_HOME"/conf/jvm.conf"
|
||||||
|
if [ -f $jvmconf_file ]
|
||||||
|
then
|
||||||
|
XmsOpt=`sed -n '/-Xms/p' $jvmconf_file`
|
||||||
|
XmxOpt=`sed -n '/-Xmx/p' $jvmconf_file`
|
||||||
|
JAVA_OPTS="$XmsOpt $XmxOpt -XX:+UseParNewGC"
|
||||||
|
else
|
||||||
|
JAVA_OPTS="-Xms64m -Xmx256m -XX:+UseParNewGC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
program="com.nms.server.DataController"
|
||||||
|
name="DataController"
|
||||||
|
|
||||||
|
proc_id=
|
||||||
|
|
||||||
|
writePid()
|
||||||
|
{
|
||||||
|
ps aux|grep java|grep $program|grep -v grep|awk '{print $2}' > $DATACONTROLLER_TMPDIR/serverPid.temp
|
||||||
|
}
|
||||||
|
getPid()
|
||||||
|
{
|
||||||
|
unset proc_id
|
||||||
|
proc_id=`ps aux|grep java|grep $program|grep -v grep|awk '{print $2}'`
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "start" ] ; then
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "$name already running......"
|
||||||
|
else
|
||||||
|
nohup java $JAVA_OPTS -classpath $DC_CLASSPATH $program >/dev/null &
|
||||||
|
sleep 3
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "$name start success!!!!!"
|
||||||
|
writePid
|
||||||
|
else
|
||||||
|
echo "$name start error!!!!!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [ "$1" = "stop" ]; then
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "$name is start, now kill......"
|
||||||
|
kill -15 $proc_id
|
||||||
|
sleep 3
|
||||||
|
writePid
|
||||||
|
echo "$name kill ok !!!!!!!!!!!!!"
|
||||||
|
else
|
||||||
|
echo "$name is not start!!!!!!!!!!!"
|
||||||
|
fi
|
||||||
|
elif [ "$1" = "restart" ] ; then
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name is start, now restart......" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
count=1
|
||||||
|
while [ $count -le 3 ]
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
kill -15 $proc_id
|
||||||
|
sleep 1
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name stop error!!!!!!!!!!" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
else
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name stop success!!!!!!!!!!" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
count=$count+1
|
||||||
|
done
|
||||||
|
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
sleep 1
|
||||||
|
kill -9 $proc_id
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name stop -9 error!!!!!!!!!!" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name is not start, now start......" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--------copy right, start proc
|
||||||
|
nohup java $JAVA_OPTS -classpath $DC_CLASSPATH $program >/dev/null &
|
||||||
|
sleep 3
|
||||||
|
getPid
|
||||||
|
if [ -n "$proc_id" ]
|
||||||
|
then
|
||||||
|
writePid
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name restart success!!!!!!!!!!" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
else
|
||||||
|
echo "`date +%Y-%m-%d" "%H:%M:%S` :$name restart error!!!!!!!!!!" >> $DATACONTROLLER_TMPDIR/job.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Usage: datacontroller.sh ( commands ... )"
|
||||||
|
echo "commands:"
|
||||||
|
echo " start Start $name"
|
||||||
|
echo " stop Stop $name"
|
||||||
|
echo " restart ReStart $name in a separate window"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd -
|
||||||
30
linuxinstall/shell/restart.sh
Normal file
30
linuxinstall/shell/restart.sh
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Retart Script for the DataController
|
||||||
|
#
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# resolve links - $0 may be a softlink
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PRGDIR=`dirname "$PRG"`
|
||||||
|
EXECUTABLE=datacontroller.sh
|
||||||
|
|
||||||
|
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
|
||||||
|
echo "Cannot find $PRGDIR/$EXECUTABLE"
|
||||||
|
echo "This file is needed to run this program"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$PRGDIR"/"$EXECUTABLE" restart "$@"
|
||||||
1
linuxinstall/shell/root
Normal file
1
linuxinstall/shell/root
Normal file
@@ -0,0 +1 @@
|
|||||||
|
59 23 */2 * * /home/nms/datacontroller/shell/restart.sh
|
||||||
30
linuxinstall/shell/shutdown.sh
Normal file
30
linuxinstall/shell/shutdown.sh
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Stop Script for the NMS Server
|
||||||
|
#
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# resolve links - $0 may be a softlink
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PRGDIR=`dirname "$PRG"`
|
||||||
|
EXECUTABLE=datacontroller.sh
|
||||||
|
|
||||||
|
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
|
||||||
|
echo "Cannot find $PRGDIR/$EXECUTABLE"
|
||||||
|
echo "This file is needed to run this program"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
|
||||||
34
linuxinstall/shell/startup.sh
Normal file
34
linuxinstall/shell/startup.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Start/Stop Script for the NMSSERVER Server
|
||||||
|
#
|
||||||
|
# Environment Variable Prequisites
|
||||||
|
#
|
||||||
|
# NMSSERVER_HOME May point at your NMSSERVER "build" directory.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# resolve links - $0 may be a softlink
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PRGDIR=`dirname "$PRG"`
|
||||||
|
|
||||||
|
EXECUTABLE=datacontroller.sh
|
||||||
|
|
||||||
|
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
|
||||||
|
echo "Cannot find $PRGDIR/$EXECUTABLE"
|
||||||
|
echo "This file is needed to run this program"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
|
||||||
132
src/com/nms/server/DataController.java
Normal file
132
src/com/nms/server/DataController.java
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
package com.nms.server;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.fang.lang.Db;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Config;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.thread.InitServerThread;
|
||||||
|
import com.nms.server.thread.WritePidThread;
|
||||||
|
import com.nms.server.thread.netty.NettyServer;
|
||||||
|
import com.nms.server.thread.socket.SSLServerManager;
|
||||||
|
import com.nms.server.util.DbPool;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataController 程序启动主方法类
|
||||||
|
* @date Aug 10, 2011 1:55:25 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DataController {
|
||||||
|
private static Logger logger = Logger.getLogger(DataController.class);
|
||||||
|
|
||||||
|
public static void doShutDownWork() {
|
||||||
|
logger.info("注册程序退出事件");
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
// Thread.currentThread().setName("退出DC,缓存数据清理线程");
|
||||||
|
Thread.currentThread().setName("Exit DC, Caching Data Cleaning Thread");
|
||||||
|
Common.stop();//程序停止运行
|
||||||
|
logger.info("停止DataController,处理缓存数据。。。");
|
||||||
|
Common.clearDataInMem();
|
||||||
|
logger.info("停止DataController,处理缓存数据 完成");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Stop DataController, cache data entry anomalies, cache data to disk", ex);//1.全部入库,入库异常时存盘 或 2.全部存盘,下次启动时入库
|
||||||
|
Common.saveDataInMemToDisk();
|
||||||
|
logger.error("Stop DataController, cache data entry anomalies, cache data stored in hard disk to complete", ex);//1.全部入库,入库异常时存盘 或 2.全部存盘,下次启动时入库
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* DataController程序启动入口
|
||||||
|
* @time Jan 5, 2012-11:37:59 AM
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String [] args) {
|
||||||
|
// Thread.currentThread().setName("主程序");
|
||||||
|
Thread.currentThread().setName("Main Program");
|
||||||
|
logger.info("------- DataController 启动开始------------");
|
||||||
|
|
||||||
|
doShutDownWork();//注册shutdown事件
|
||||||
|
|
||||||
|
//书写PID
|
||||||
|
Common.service.submit(new WritePidThread());
|
||||||
|
// WritePidThread pidth = new WritePidThread();
|
||||||
|
// pidth.run();
|
||||||
|
|
||||||
|
//- 初始化数据库连接池(在优化方向:将数据库连接池创建及维护通过 其专有维护线程实现独立管理)
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
DbPool.initPool();
|
||||||
|
//初始化Common.Db
|
||||||
|
Common.initDb(new Db(new Db.DataSource() {
|
||||||
|
@Override
|
||||||
|
public Connection getConnection() {
|
||||||
|
try {
|
||||||
|
return DbPool.getConnection();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Thread.sleep(3000);
|
||||||
|
String sequenceTable=Config.getString("sequence.table", "detection_info");
|
||||||
|
if(!sequenceTable.equals("0")){
|
||||||
|
String[] split=sequenceTable.split(",");
|
||||||
|
Common.initSequence(Common.getDb().getConnection(),split);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
logger.error("Load database driver failure");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Initialization of connection pool exception:"+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 启动加密通讯端口监听
|
||||||
|
try {
|
||||||
|
Common.service.submit(new SSLServerManager(Constants.SSL_SERVER_PORT,true)); //与web和Agent端通讯线程启动
|
||||||
|
if(Constants.NETTY_SERVER_FLAG == 1){
|
||||||
|
//启动netty server
|
||||||
|
Common.service.submit(new NettyServer(Constants.NETTY_SERVER_PORT, Constants.NETTY_SERVER_SSL));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// String info = "通讯服务启动失败!\n请确定程序是否未启动或检查服务端口["+Constants.SSL_SERVER_PORT+"]未被占用!\n"+e.getMessage();
|
||||||
|
String info = "The communication service failed to start! \n please confirm whether the program has not started or checked the service port["+Constants.SSL_SERVER_PORT+"]is not occupied!!\n"+e.getMessage();
|
||||||
|
// String info = "i18n_server.DataController.showMsg_n81i["+Constants.SSL_SERVER_PORT+"]i18n_server.DataController.isExists_n81i!\n"+e.getMessage();
|
||||||
|
logger.error(info);//i18nlog
|
||||||
|
// JOptionPane.showMessageDialog(null, info, "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
// JOptionPane.showMessageDialog(null, info, "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
JOptionPane.showMessageDialog(null, info, "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 获取本机IP
|
||||||
|
/*try {
|
||||||
|
String localIp = Common.getLocalIp();
|
||||||
|
|
||||||
|
if(StringUtils.isBlank(localIp)){
|
||||||
|
String info = "读取本地IP失败 程序无法启动 请检查配置文件";
|
||||||
|
logger.error(info);
|
||||||
|
JOptionPane.showMessageDialog(null, info, "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
String info = "主线程执行异常,被迫中止\n"+e.getMessage();
|
||||||
|
logger.error(info);
|
||||||
|
JOptionPane.showMessageDialog(null, info, "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
System.exit(0);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//- 执行加载启动操作
|
||||||
|
Common.service.submit(new InitServerThread());
|
||||||
|
}
|
||||||
|
}
|
||||||
197
src/com/nms/server/bean/AlarmInfo.java
Normal file
197
src/com/nms/server/bean/AlarmInfo.java
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警信息对象
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AlarmInfo {
|
||||||
|
/**
|
||||||
|
* 告警设置id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 监测设置ID
|
||||||
|
*/
|
||||||
|
private Long setInfoId;
|
||||||
|
/**
|
||||||
|
* 监测类型名称(cpu...)
|
||||||
|
*/
|
||||||
|
private String checkType;
|
||||||
|
/**
|
||||||
|
* 进程标识
|
||||||
|
*/
|
||||||
|
private String processIden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段表字段Id
|
||||||
|
*/
|
||||||
|
private Long metadataId;
|
||||||
|
/**
|
||||||
|
* 字段序号
|
||||||
|
*/
|
||||||
|
private Integer showNum;
|
||||||
|
/**
|
||||||
|
* 字段描述
|
||||||
|
*/
|
||||||
|
private String filedCommonts;
|
||||||
|
/**
|
||||||
|
* 报警状态
|
||||||
|
*/
|
||||||
|
private String policeState;
|
||||||
|
/**
|
||||||
|
* 报警值
|
||||||
|
*/
|
||||||
|
private String policeValue;
|
||||||
|
/**
|
||||||
|
* 报警单位
|
||||||
|
*/
|
||||||
|
private String policeUnit;
|
||||||
|
/**
|
||||||
|
* 报警比较符:针对number型数据>、<、>=、<=、= 针对字符串类型数据equal、 include、exclude
|
||||||
|
*/
|
||||||
|
private String policeSysmbols;
|
||||||
|
/**
|
||||||
|
* 报警等级
|
||||||
|
*/
|
||||||
|
private Integer policeLevel;
|
||||||
|
/**
|
||||||
|
* 报警紧急标示告警 (是否紧急 0:紧急 1:非紧急 默认为1)
|
||||||
|
*/
|
||||||
|
private Integer policeEmergent;
|
||||||
|
/**
|
||||||
|
* 设置告警时,指定多个标识符(如多个盘符、多个CPU、多个网卡),如硬盘使用率,空:所有盘存在一个盘使用率超过告警值,则告警;all:所有盘总的使用率超过告警值,则告警;指定多个盘符:指定盘存在一个盘使用率超过告警值,则告警
|
||||||
|
*/
|
||||||
|
private String marker;
|
||||||
|
/**
|
||||||
|
* 标识符对应字段在metadata表中的id
|
||||||
|
*/
|
||||||
|
private Integer markerFiledId;;
|
||||||
|
/**
|
||||||
|
* 标识符对应字段在metadata表中的showNum
|
||||||
|
*/
|
||||||
|
private Integer markerFiledShowNum;
|
||||||
|
|
||||||
|
|
||||||
|
public Long getSetInfoId() {
|
||||||
|
return setInfoId;
|
||||||
|
}
|
||||||
|
public void setSetInfoId(Long setInfoId) {
|
||||||
|
this.setInfoId = setInfoId;
|
||||||
|
}
|
||||||
|
public Long getMetadataId() {
|
||||||
|
return metadataId;
|
||||||
|
}
|
||||||
|
public void setMetadataId(Long metadataId) {
|
||||||
|
this.metadataId = metadataId;
|
||||||
|
}
|
||||||
|
public Integer getShowNum() {
|
||||||
|
return showNum;
|
||||||
|
}
|
||||||
|
public void setShowNum(Integer showNum) {
|
||||||
|
this.showNum = showNum;
|
||||||
|
}
|
||||||
|
public String getPoliceState() {
|
||||||
|
return policeState;
|
||||||
|
}
|
||||||
|
public void setPoliceState(String policeState) {
|
||||||
|
this.policeState = policeState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPoliceValue() {
|
||||||
|
return policeValue;
|
||||||
|
}
|
||||||
|
public void setPoliceValue(String policeValue) {
|
||||||
|
this.policeValue = policeValue;
|
||||||
|
}
|
||||||
|
public String getPoliceUnit() {
|
||||||
|
return policeUnit;
|
||||||
|
}
|
||||||
|
public void setPoliceUnit(String policeUnit) {
|
||||||
|
this.policeUnit = policeUnit;
|
||||||
|
}
|
||||||
|
public String getPoliceSysmbols() {
|
||||||
|
return policeSysmbols;
|
||||||
|
}
|
||||||
|
public void setPoliceSysmbols(String policeSysmbols) {
|
||||||
|
this.policeSysmbols = policeSysmbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
public Integer getPoliceLevel() {
|
||||||
|
return policeLevel;
|
||||||
|
}
|
||||||
|
public void setPoliceLevel(Integer policeLevel) {
|
||||||
|
this.policeLevel = policeLevel;
|
||||||
|
}
|
||||||
|
public String getCheckType() {
|
||||||
|
return checkType;
|
||||||
|
}
|
||||||
|
public void setCheckType(String checkType) {
|
||||||
|
this.checkType = checkType;
|
||||||
|
}
|
||||||
|
public String getProcessIden() {
|
||||||
|
return processIden;
|
||||||
|
}
|
||||||
|
public void setProcessIden(String processIden) {
|
||||||
|
this.processIden = processIden;
|
||||||
|
}
|
||||||
|
public String getFiledCommonts() {
|
||||||
|
return filedCommonts;
|
||||||
|
}
|
||||||
|
public void setFiledCommonts(String filedCommonts) {
|
||||||
|
this.filedCommonts = filedCommonts;
|
||||||
|
}
|
||||||
|
public Integer getPoliceEmergent() {
|
||||||
|
return policeEmergent;
|
||||||
|
}
|
||||||
|
public void setPoliceEmergent(Integer policeEmergent) {
|
||||||
|
if(policeEmergent==null){policeEmergent = 1;}
|
||||||
|
this.policeEmergent = policeEmergent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "showNum=" + showNum + ",policeSysmbols=" + policeSysmbols
|
||||||
|
+ ",policeValue=" + policeValue + ",policeLevel=" + policeLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toStringVal(){
|
||||||
|
return showNum + "|" + policeSysmbols + "|" + policeValue + "|"
|
||||||
|
+ policeLevel + "|" + filedCommonts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMarker()
|
||||||
|
{
|
||||||
|
return marker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarker(String marker)
|
||||||
|
{
|
||||||
|
this.marker = marker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMarkerFiledId()
|
||||||
|
{
|
||||||
|
return markerFiledId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkerFiledId(Integer markerFiledId)
|
||||||
|
{
|
||||||
|
this.markerFiledId = markerFiledId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMarkerFiledShowNum()
|
||||||
|
{
|
||||||
|
return markerFiledShowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkerFiledShowNum(Integer markerFiledShowNum)
|
||||||
|
{
|
||||||
|
this.markerFiledShowNum = markerFiledShowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
127
src/com/nms/server/bean/ContactSetInfo.java
Normal file
127
src/com/nms/server/bean/ContactSetInfo.java
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端用到的监测设置信息实体
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ContactSetInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测设置信息ID
|
||||||
|
*/
|
||||||
|
private Long missionId;
|
||||||
|
private String missionName;
|
||||||
|
private String nodeGroupName;
|
||||||
|
private String nodeGroupsId;
|
||||||
|
private String nodeIpsId;
|
||||||
|
private String nodeIpsName;
|
||||||
|
private Long missionType;
|
||||||
|
private Long missionState;
|
||||||
|
private Long isLoop;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
private Long viewLevel;
|
||||||
|
private Long createUserId;
|
||||||
|
private Long createUserGroupId;
|
||||||
|
private Long systemId;
|
||||||
|
private String contactUserIds;
|
||||||
|
public Long getViewLevel() {
|
||||||
|
return viewLevel;
|
||||||
|
}
|
||||||
|
public void setViewLevel(Long viewLevel) {
|
||||||
|
this.viewLevel = viewLevel;
|
||||||
|
}
|
||||||
|
public Long getCreateUserId() {
|
||||||
|
return createUserId;
|
||||||
|
}
|
||||||
|
public void setCreateUserId(Long createUserId) {
|
||||||
|
this.createUserId = createUserId;
|
||||||
|
}
|
||||||
|
public Long getCreateUserGroupId() {
|
||||||
|
return createUserGroupId;
|
||||||
|
}
|
||||||
|
public void setCreateUserGroupId(Long createUserGroupId) {
|
||||||
|
this.createUserGroupId = createUserGroupId;
|
||||||
|
}
|
||||||
|
public Long getSystemId() {
|
||||||
|
return systemId;
|
||||||
|
}
|
||||||
|
public void setSystemId(Long systemId) {
|
||||||
|
this.systemId = systemId;
|
||||||
|
}
|
||||||
|
public String getContactUserIds() {
|
||||||
|
return contactUserIds;
|
||||||
|
}
|
||||||
|
public void setContactUserIds(String contactUserIds) {
|
||||||
|
this.contactUserIds = contactUserIds;
|
||||||
|
}
|
||||||
|
public Long getMissionId() {
|
||||||
|
return missionId;
|
||||||
|
}
|
||||||
|
public void setMissionId(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
public String getMissionName() {
|
||||||
|
return missionName;
|
||||||
|
}
|
||||||
|
public void setMissionName(String missionName) {
|
||||||
|
this.missionName = missionName;
|
||||||
|
}
|
||||||
|
public String getNodeGroupName() {
|
||||||
|
return nodeGroupName;
|
||||||
|
}
|
||||||
|
public void setNodeGroupName(String nodeGroupName) {
|
||||||
|
this.nodeGroupName = nodeGroupName;
|
||||||
|
}
|
||||||
|
public Long getMissionType() {
|
||||||
|
return missionType;
|
||||||
|
}
|
||||||
|
public void setMissionType(Long missionType) {
|
||||||
|
this.missionType = missionType;
|
||||||
|
}
|
||||||
|
public Long getMissionState() {
|
||||||
|
return missionState;
|
||||||
|
}
|
||||||
|
public void setMissionState(Long missionState) {
|
||||||
|
this.missionState = missionState;
|
||||||
|
}
|
||||||
|
public Long getIsLoop() {
|
||||||
|
return isLoop;
|
||||||
|
}
|
||||||
|
public void setIsLoop(Long isLoop) {
|
||||||
|
this.isLoop = isLoop;
|
||||||
|
}
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
public void setEndTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
public void setNodeGroupsId(String nodeGroupsId) {
|
||||||
|
this.nodeGroupsId = nodeGroupsId;
|
||||||
|
}
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
public String getNodeIpsName() {
|
||||||
|
return nodeIpsName;
|
||||||
|
}
|
||||||
|
public void setNodeIpsName(String nodeIpsName) {
|
||||||
|
this.nodeIpsName = nodeIpsName;
|
||||||
|
}
|
||||||
|
}
|
||||||
328
src/com/nms/server/bean/DetecAllInfo.java
Normal file
328
src/com/nms/server/bean/DetecAllInfo.java
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测信息
|
||||||
|
* @author Nan,Fang
|
||||||
|
* 2016-2-29
|
||||||
|
*/
|
||||||
|
public class DetecAllInfo {
|
||||||
|
|
||||||
|
|
||||||
|
/* 基本信息解析格式变量 */
|
||||||
|
private String seqId = null; //seqId
|
||||||
|
private String setInfoId = null; //监测设置ID
|
||||||
|
private String checkType = null; //监测类别
|
||||||
|
private String process = null; //进程名称(监测类别设置名称)
|
||||||
|
private Long startTime = null; //监测服务启动时间
|
||||||
|
|
||||||
|
private Integer delayTime = null; //检测时延(秒)
|
||||||
|
private Long checkTime = null; //本次检测时间
|
||||||
|
private Integer currentTimes = null; //尝试次数
|
||||||
|
private Long nextCheckTime = null; //下次计划监测时间
|
||||||
|
private Long arriveTime;
|
||||||
|
|
||||||
|
private Integer state = -1; //执行状态是否成功是否正常
|
||||||
|
private String showNums = null; //告警序列(数据)
|
||||||
|
private Integer pLevel = 99; //告警级别(数据)
|
||||||
|
//private int pl = 99; //告警级别(入库)
|
||||||
|
private String pValue = null; //告 警 值(数据)
|
||||||
|
private String dsinfo = null; //状态信息(描述信息)
|
||||||
|
private String pdata = null; //性能数据
|
||||||
|
private List<Map<String,String>> details;//详细参数
|
||||||
|
private boolean delyFlag; //是否解析详细参数标志
|
||||||
|
private int urgentLevel ; //紧急级别
|
||||||
|
private String alarmInfo;//告警信息
|
||||||
|
|
||||||
|
private boolean sendEmailFlag;//邮件发送标志
|
||||||
|
private boolean stateChangeFlag;//状态变更标志
|
||||||
|
private long statusChangTime = -1L;//状态变更时间
|
||||||
|
|
||||||
|
private EmailInfo emailInfo;//邮件信息
|
||||||
|
|
||||||
|
private List<String[]> diskInfoList; // net 特殊格式追加详细信息
|
||||||
|
private List<String[]> netInfoList; // net 特殊格式追加详细信息
|
||||||
|
|
||||||
|
private DetecAllInfo appendWarningInfo ;//延迟数据,追加告警信息
|
||||||
|
|
||||||
|
private byte[] dsb;//存放字节数字格式的监测数据,用于解析异常时,存监测数据到硬盘的时候用
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以下属性用于记录原监测数据
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String valid;
|
||||||
|
private String detectionInfoId;
|
||||||
|
private String waitTime;
|
||||||
|
/**
|
||||||
|
* 无参构造方法
|
||||||
|
*/
|
||||||
|
public DetecAllInfo(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSeqId() {
|
||||||
|
return seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeqId(String seqId) {
|
||||||
|
this.seqId = seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSetInfoId() {
|
||||||
|
return setInfoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSetInfoId(String setInfoId) {
|
||||||
|
this.setInfoId = setInfoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCheckType() {
|
||||||
|
return checkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckType(String checkType) {
|
||||||
|
this.checkType = checkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcess() {
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcess(String process) {
|
||||||
|
this.process = process;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(Long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDelayTime() {
|
||||||
|
return delayTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelayTime(Integer delayTime) {
|
||||||
|
this.delayTime = delayTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCheckTime() {
|
||||||
|
return checkTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckTime(Long checkTime) {
|
||||||
|
this.checkTime = checkTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCurrentTimes() {
|
||||||
|
return currentTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentTimes(Integer currentTimes) {
|
||||||
|
this.currentTimes = currentTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNextCheckTime() {
|
||||||
|
return nextCheckTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextCheckTime(Long nextCheckTime) {
|
||||||
|
this.nextCheckTime = nextCheckTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShowNums() {
|
||||||
|
return showNums;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowNums(String showNums) {
|
||||||
|
this.showNums = showNums;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getpValue() {
|
||||||
|
return pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setpValue(String pValue) {
|
||||||
|
this.pValue = pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDsinfo() {
|
||||||
|
return dsinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDsinfo(String dsinfo) {
|
||||||
|
this.dsinfo = dsinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPdata() {
|
||||||
|
return pdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPdata(String pdata) {
|
||||||
|
this.pdata = pdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, String>> getDetails() {
|
||||||
|
return details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetails(List<Map<String, String>> details) {
|
||||||
|
this.details = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getArriveTime() {
|
||||||
|
return arriveTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArriveTime(Long arriveTime) {
|
||||||
|
this.arriveTime = arriveTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDelyFlag() {
|
||||||
|
return delyFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelyFlag(boolean delyFlag) {
|
||||||
|
this.delyFlag = delyFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUrgentLevel() {
|
||||||
|
return urgentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrgentLevel(int urgentLevel) {
|
||||||
|
this.urgentLevel = urgentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlarmInfo() {
|
||||||
|
return alarmInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmInfo(String alarmInfo) {
|
||||||
|
this.alarmInfo = alarmInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStateChangeFlag() {
|
||||||
|
return stateChangeFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStateChangeFlag(boolean stateChangeFlag) {
|
||||||
|
this.stateChangeFlag = stateChangeFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isSendEmailFlag() {
|
||||||
|
return sendEmailFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSendEmailFlag(boolean sendEmailFlag) {
|
||||||
|
this.sendEmailFlag = sendEmailFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(Integer state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getpLevel() {
|
||||||
|
return pLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setpLevel(Integer pLevel) {
|
||||||
|
this.pLevel = pLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailInfo getEmailInfo() {
|
||||||
|
return emailInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailInfo(EmailInfo emailInfo) {
|
||||||
|
this.emailInfo = emailInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStatusChangTime() {
|
||||||
|
return statusChangTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusChangTime(long statusChangTime) {
|
||||||
|
this.statusChangTime = statusChangTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<String[]> getDiskInfoList() {
|
||||||
|
return diskInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiskInfoList(List<String[]> diskInfoList) {
|
||||||
|
this.diskInfoList = diskInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String[]> getNetInfoList() {
|
||||||
|
return netInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNetInfoList(List<String[]> netInfoList) {
|
||||||
|
this.netInfoList = netInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetecAllInfo getAppendWarningInfo() {
|
||||||
|
return appendWarningInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppendWarningInfo(DetecAllInfo appendWarningInfo) {
|
||||||
|
this.appendWarningInfo = appendWarningInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValid(String valid) {
|
||||||
|
this.valid = valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetectionInfoId() {
|
||||||
|
return detectionInfoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetectionInfoId(String detectionInfoId) {
|
||||||
|
this.detectionInfoId = detectionInfoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWaitTime() {
|
||||||
|
return waitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWaitTime(String waitTime) {
|
||||||
|
this.waitTime = waitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] getDsb()
|
||||||
|
{
|
||||||
|
return dsb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setDsb(byte[] dsb)
|
||||||
|
{
|
||||||
|
this.dsb = dsb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
403
src/com/nms/server/bean/DetectInfo.java
Normal file
403
src/com/nms/server/bean/DetectInfo.java
Normal file
@@ -0,0 +1,403 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import com.fang.U;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Config;
|
||||||
|
import com.nms.server.dao.OracleToMysql;
|
||||||
|
|
||||||
|
public class DetectInfo {
|
||||||
|
|
||||||
|
public static final int SEQID = 0; //seqId
|
||||||
|
public static final int SETINFOID = 1; //监测设置ID
|
||||||
|
public static final int CHECKTYPE = 2; //监测类别
|
||||||
|
public static final int PROCESS = 3; //进程名称(监测类别设置名称)
|
||||||
|
public static final int STARTTIME = 4; //监测服务启动时间
|
||||||
|
public static final int DELAYTIME = 5; //检测时延(秒)
|
||||||
|
public static final int CHECKTIME = 6; //本次检测时间
|
||||||
|
public static final int CURRENTTIMES = 7; //尝试次数
|
||||||
|
public static final int NEXTCHECKTIME = 8; //下次计划监测时间
|
||||||
|
public static final int ARRIVETIME = 9;
|
||||||
|
public static final int STATE = 10; //执行状态是否成功是否正常
|
||||||
|
public static final int SHOWNUMS = 11; //告警序列(数据)
|
||||||
|
public static final int PLEVEL = 12; //告警级别(数据)
|
||||||
|
public static final int PVALUE = 13; //告 警 值(数据)
|
||||||
|
public static final int DSINFO = 14; //状态信息(描述信息)
|
||||||
|
public static final int PDATA = 15; //性能数据
|
||||||
|
public static final int DETAILS = 16;//详细参数
|
||||||
|
public static final int DELYFLAG = 17; //是否解析详细参数标志
|
||||||
|
public static final int URGENTLEVEL =18 ; //紧急级别
|
||||||
|
public static final int ALARMINFO =19 ;//告警信息
|
||||||
|
public static final int SENDEMAILFLAG =20;//邮件发送标志
|
||||||
|
public static final int STATECHANGEFLAG =21;//状态变更标志
|
||||||
|
public static final int STATUSCHANGTIME = 22;//状态变更时间
|
||||||
|
public static final int EMAILINFO = 23;//邮件信息
|
||||||
|
public static final int DISKINFOLIST = 24; // net 特殊格式追加详细信息
|
||||||
|
public static final int NETINFOLIST =25; // net 特殊格式追加详细信息
|
||||||
|
public static final int APPENDWARNINGINFO = 26;//延迟数据,追加告警信息
|
||||||
|
//public static final int DSB = 27;//存放字节数字格式的监测数据,用于解析异常时,存监测数据到硬盘的时候用
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以下属性用于记录原监测数据
|
||||||
|
*/
|
||||||
|
public static final int VALID = 27;
|
||||||
|
public static final int DETECTIONINFOID = 28;
|
||||||
|
public static final int WAITTIME = 29;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从解析之后数据恢复成原数据时使用
|
||||||
|
*/
|
||||||
|
public static final int SHOWNUMLIST = 30;
|
||||||
|
public static final int PLEVELLIST = 31;
|
||||||
|
public static final int ALARMLIST = 32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* detect_queue 的 key
|
||||||
|
*/
|
||||||
|
public static final String INFO_KEY = "INFO";
|
||||||
|
public static final String DISK_STR_KEY = "DISK_STR";
|
||||||
|
public static final String NET_STR_KEY = "NET_STR";
|
||||||
|
/**
|
||||||
|
* 详细表中的外键字段名
|
||||||
|
*/
|
||||||
|
public static final String DETECTION_INFO_ID = "DETECTION_INFO_ID";
|
||||||
|
|
||||||
|
public static final String DETECTION_INFO="detection_info";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 该字段是针对,同一时间点多条具体数据(写多个文件),比如:网卡监测(多个网卡问题)
|
||||||
|
*/
|
||||||
|
private List<String> detailDatas = new LinkedList<String>();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 针对公共数据的描述信息
|
||||||
|
*/
|
||||||
|
private String descInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试次数 (小于最大尝试次数)
|
||||||
|
*/
|
||||||
|
private int testTimes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测时间
|
||||||
|
*/
|
||||||
|
private long checkTime;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 该字段是针对一条数据,关联的其他表的数据;写入到一个文件的: String 是解析标识, List<String[]>是多条数据(String[]存入表中的数据)
|
||||||
|
* 如:系统信息监测,数据中有网卡数量,网卡数量关联着其他表(表中又有多个字段,如网卡名称,IP,子网掩码等等)
|
||||||
|
*/
|
||||||
|
private Map<String, List<String[]>> relatedDatas;
|
||||||
|
|
||||||
|
public List<String> getDetailDatas() {
|
||||||
|
return detailDatas;
|
||||||
|
}
|
||||||
|
public void setDetailDatas(List<String> detailDatas) {
|
||||||
|
this.detailDatas = detailDatas;
|
||||||
|
}
|
||||||
|
public String getDescInfo() {
|
||||||
|
return descInfo;
|
||||||
|
}
|
||||||
|
public void setDescInfo(String descInfo) {
|
||||||
|
this.descInfo = descInfo;
|
||||||
|
}
|
||||||
|
public Map<String, List<String[]>> getRelatedDatas() {
|
||||||
|
return relatedDatas;
|
||||||
|
}
|
||||||
|
public void setRelatedDatas(Map<String, List<String[]>> relatedDatas) {
|
||||||
|
this.relatedDatas = relatedDatas;
|
||||||
|
}
|
||||||
|
public int getTestTimes() {
|
||||||
|
return testTimes;
|
||||||
|
}
|
||||||
|
public void setTestTimes(int testTimes) {
|
||||||
|
this.testTimes = testTimes;
|
||||||
|
}
|
||||||
|
public long getCheckTime() {
|
||||||
|
return checkTime;
|
||||||
|
}
|
||||||
|
public void setCheckTime(long checkTime) {
|
||||||
|
this.checkTime = checkTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DETECTION_INFO insert sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getInsertInfoSql(){
|
||||||
|
String insertInfoSql = "";
|
||||||
|
if(Common.SEQUENCE.get(DetectInfo.DETECTION_INFO)!=null){
|
||||||
|
insertInfoSql = "INSERT INTO DETECTION_INFO (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT,STATUS_CHANGE_TIME,SEQUENCE)"
|
||||||
|
+" VALUES (?, ?, ?, ?, ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, ?, ?, ?, ?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),?)";
|
||||||
|
}else{
|
||||||
|
insertInfoSql = "INSERT INTO DETECTION_INFO (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT,STATUS_CHANGE_TIME)"
|
||||||
|
+" VALUES (?, ?, ?, ?, ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, ?, ?, ?, ?,to_date(?,'yyyy-mm-dd hh24:mi:ss'))";
|
||||||
|
}
|
||||||
|
|
||||||
|
return OracleToMysql.trans(insertInfoSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织detail表的insert语句
|
||||||
|
* @param fieldNames
|
||||||
|
* @param detailTableName
|
||||||
|
* @param tempMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String createDetailSql(List<String> fieldNames,
|
||||||
|
String detailTableName, Map<String, String> tempMap) {
|
||||||
|
String insertDetailSql;
|
||||||
|
StringBuffer preSql = new StringBuffer();
|
||||||
|
StringBuffer sufSql = new StringBuffer();
|
||||||
|
preSql.append(",DETECTION_INFO_ID");
|
||||||
|
sufSql.append(",?");
|
||||||
|
fieldNames.add("DETECTION_INFO_ID");
|
||||||
|
for(String tempField : tempMap.keySet()){
|
||||||
|
fieldNames.add(tempField);
|
||||||
|
preSql.append("," + tempField);
|
||||||
|
sufSql.append(",?");
|
||||||
|
}
|
||||||
|
insertDetailSql = "insert into "+detailTableName +" ( "+ preSql.substring(1) +" ) values (" + sufSql.substring(1) +" )";
|
||||||
|
return insertDetailSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算 detection_info 及详细表的关联主键
|
||||||
|
* @param checkTime 监测时间
|
||||||
|
* @param seqId 节点id
|
||||||
|
* @param setId 监测设置id
|
||||||
|
* @return 10位时间戳 + 5位 seqId + 3位 setId
|
||||||
|
*/
|
||||||
|
public static String computeId(String checkTime,String seqId,String setId){
|
||||||
|
if(U.Strs.isAllNotBlank(checkTime,seqId,setId)){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
checkTime = checkTime.substring(checkTime.length() -10);//截取时间戳 后10位
|
||||||
|
sb.append("00000");
|
||||||
|
sb.append(seqId);
|
||||||
|
seqId = sb.substring(sb.length()-5);// seqId 占 5位
|
||||||
|
sb.delete(0, sb.length());//清空sb
|
||||||
|
sb.append("000");
|
||||||
|
sb.append(setId);
|
||||||
|
setId = sb.substring(sb.length() - 3); // set info id 占 3位
|
||||||
|
sb.setLength(0);
|
||||||
|
sb.append(checkTime);
|
||||||
|
sb.append(seqId);
|
||||||
|
sb.append(setId);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测设置查询权限 为 1 2 3 的邮件列表 sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getDetecEmailListOf123Sql(){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(" select distinct c.id, xyj1.email ");
|
||||||
|
sb.append(" from xt_yh_jbxx xyj1, ");
|
||||||
|
sb.append(" (select dsi.id, ',' || dsi.contact_user_ids || ',' as ids ");
|
||||||
|
sb.append(" from detection_set_info dsi ");
|
||||||
|
sb.append(" where dsi.contact_user_ids is not null) c ");
|
||||||
|
sb.append(" where c.ids like ('%,' || xyj1.yhid || ',%') ");
|
||||||
|
sb.append(" and xyj1.email is not null ");
|
||||||
|
sb.append(" union ");
|
||||||
|
sb.append(" (select distinct dsi.id,xyj.email ");
|
||||||
|
sb.append(" from detection_set_info dsi ");
|
||||||
|
sb.append(" left join xt_js_jbxx xjj ");
|
||||||
|
sb.append(" on dsi.create_usergroup_id = xjj.jsbh ");
|
||||||
|
sb.append(" left join xt_yh_js_index xyji ");
|
||||||
|
sb.append(" on xjj.jsbh = xyji.jsbh ");
|
||||||
|
sb.append(" left join xt_yh_jbxx xyj ");
|
||||||
|
sb.append(" on xyj.yhid = xyji.yhid ");
|
||||||
|
sb.append(" where xyj.is_receiveemail = '0' ");
|
||||||
|
sb.append(" and xjj.zxbz = 0 ");
|
||||||
|
sb.append(" and xjj.type = 1 ");
|
||||||
|
sb.append(" and xyj.zxbz = 0 ");
|
||||||
|
sb.append(" and dsi.view_level = 2 ");
|
||||||
|
sb.append(" and xyj.email is not null ");
|
||||||
|
sb.append(" and dsi.create_usergroup_id is not null ");
|
||||||
|
sb.append(" and dsi.contact_user_ids is null) ");
|
||||||
|
sb.append(" union ");
|
||||||
|
sb.append(" ( ");
|
||||||
|
sb.append(" select distinct dsi.id,xyj.email from detection_set_info dsi ");
|
||||||
|
sb.append(" left join gorup_system_table gst ");
|
||||||
|
sb.append(" on gst.system_id = dsi.system_id ");
|
||||||
|
sb.append(" left join xt_js_jbxx xjj ");
|
||||||
|
sb.append(" on gst.user_group_id = xjj.jsbh ");
|
||||||
|
sb.append(" left join xt_yh_js_index xyji ");
|
||||||
|
sb.append(" on xjj.jsbh = xyji.jsbh ");
|
||||||
|
sb.append(" left join xt_yh_jbxx xyj ");
|
||||||
|
sb.append(" on xyji.yhid = xyj.yhid ");
|
||||||
|
sb.append(" where xyj.is_receiveemail = '0' ");
|
||||||
|
sb.append(" and xjj.zxbz = 0 ");
|
||||||
|
sb.append(" and xjj.type = 1 ");
|
||||||
|
sb.append(" and xyj.zxbz = 0 ");
|
||||||
|
sb.append(" and dsi.view_level = 3 ");
|
||||||
|
sb.append(" and xyj.email is not null ");
|
||||||
|
sb.append(" and dsi.contact_user_ids is null ");
|
||||||
|
sb.append(" ) ");
|
||||||
|
return OracleToMysql.trans(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测设置查看权限为 4 的 邮件列表 sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getDetecEmailListOf4Sql(){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(" select distinct nt.seq_id ,xyj.email");
|
||||||
|
sb.append(" from xt_yh_jbxx xyj ");
|
||||||
|
sb.append(" left join xt_yh_js_index xyji ");
|
||||||
|
sb.append(" on xyji.yhid = xyj.yhid ");
|
||||||
|
sb.append(" left join xt_js_jbxx xjj ");
|
||||||
|
sb.append(" on xjj.jsbh = xyji.jsbh ");
|
||||||
|
sb.append(" left join gorup_system_table gst ");
|
||||||
|
sb.append(" on gst.user_group_id = xjj.jsbh ");
|
||||||
|
sb.append(" left join system_table st ");
|
||||||
|
sb.append(" on st.system_id = gst.system_id ");
|
||||||
|
sb.append(" left join node_table nt ");
|
||||||
|
sb.append(" on nt.system_id = gst.system_id ");
|
||||||
|
sb.append(" left join nodegroup_table ngt ");
|
||||||
|
sb.append(" on ngt.group_id = nt.node_group_id ");
|
||||||
|
sb.append(" where xyj.is_receiveemail = '0' ");
|
||||||
|
sb.append(" and nt.node_state = 0 ");
|
||||||
|
sb.append(" and ngt.is_valid = 1 ");
|
||||||
|
sb.append(" and st.system_state = 0 ");
|
||||||
|
sb.append(" and xjj.zxbz = 0 ");
|
||||||
|
sb.append(" and xjj.type = 1 ");
|
||||||
|
sb.append(" and xyj.zxbz = 0 ");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* detection_info 表的 insert 语句
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getInsertDetectInfoSql(){
|
||||||
|
String insertInfoSql="";
|
||||||
|
if(Common.SEQUENCE.get(DetectInfo.DETECTION_INFO)==null){
|
||||||
|
insertInfoSql = "INSERT INTO DETECTION_INFO (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT)"
|
||||||
|
+" VALUES (?, ?, ?, ?, ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, ?, ?, ?, ?)";
|
||||||
|
}else{
|
||||||
|
insertInfoSql = "INSERT INTO DETECTION_INFO (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT,SEQUENCE)"
|
||||||
|
+" VALUES (?, ?, ?, ?, ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, ?, ?, ?, ?,?)";
|
||||||
|
}
|
||||||
|
return OracleToMysql.trans(insertInfoSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* detection_warning 表的insert 语句
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getInsertWarningSql(){
|
||||||
|
//插入warning表
|
||||||
|
String insertWaringSql = "INSERT INTO DETECTION_INFO_WARNING (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT)"
|
||||||
|
+" VALUES (?, ?, ?, ?, ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, to_date(?,'yyyy-mm-dd hh24:mi:ss'), to_date(?,'yyyy-mm-dd hh24:mi:ss'), ?, ?, ?, ?, ?)";
|
||||||
|
return OracleToMysql.trans(insertWaringSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* email_info 表的insert语句
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getInsertEmailSql(){
|
||||||
|
//插入email_table表
|
||||||
|
String insertEmailSql = " insert into email_table (to_address,action_type,content,send_flag,action_ip,action_date,action_desc,send_level,CREATE_TIME)" +
|
||||||
|
" values(?,?,?,?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'))";
|
||||||
|
return OracleToMysql.trans(insertEmailSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新状态变更时间
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getUpdateStatusSql(){
|
||||||
|
String sql = "update detection_info_new din set din.status_change_time =to_date(?,'yyyy-mm-dd hh24:mi:ss') where din.seq_id=?";
|
||||||
|
return OracleToMysql.trans(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSaveToNewSql(){
|
||||||
|
String sql=" insert into detection_info_new(detection_set_info_id ,detection_state_info ,"
|
||||||
|
+ "performace_data ,current_times ,start_time ,wait_time ,delay_time ,next_check_time ,"
|
||||||
|
+ "police_level ,data_check_time ,data_arrive_time ,detectioned_state ,"
|
||||||
|
+ "status_change_time ,seq_id ,detection_info_id,data_check_time_digital,data_arrive_time_digital ,"
|
||||||
|
+ "POLICE_EMERGENT ) VALUES"
|
||||||
|
+"(?,?,"
|
||||||
|
+ "?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),"
|
||||||
|
+ "?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,"
|
||||||
|
+ "to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,?,?,?,?)";
|
||||||
|
return OracleToMysql.trans(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUpdateToNewSql(){
|
||||||
|
String sql=" update detection_info_new din set "
|
||||||
|
|
||||||
|
+"din.detection_state_info = ?"
|
||||||
|
|
||||||
|
+", din.performace_data = ?"
|
||||||
|
|
||||||
|
+", din.current_times = ?"
|
||||||
|
|
||||||
|
+", din.start_time = to_date(?,'yyyy-mm-dd hh24:mi:ss')"
|
||||||
|
|
||||||
|
+", din.wait_time = ?"
|
||||||
|
|
||||||
|
+" , din.delay_time = ?"
|
||||||
|
|
||||||
|
+" , din.next_check_time = to_date(?,'yyyy-mm-dd hh24:mi:ss')"
|
||||||
|
|
||||||
|
+" , din.police_level = ?"
|
||||||
|
|
||||||
|
+" , din.data_check_time = to_date(?,'yyyy-mm-dd hh24:mi:ss')"
|
||||||
|
|
||||||
|
+" , din.data_arrive_time = to_date(?,'yyyy-mm-dd hh24:mi:ss')"
|
||||||
|
|
||||||
|
+", din.detectioned_state = ?"
|
||||||
|
|
||||||
|
+" , din.status_change_time = to_date(?,'yyyy-mm-dd hh24:mi:ss')"
|
||||||
|
|
||||||
|
+" , detection_info_id = ?"
|
||||||
|
|
||||||
|
+" ,data_check_time_digital = ?"
|
||||||
|
|
||||||
|
+" ,data_arrive_time_digital = ?"
|
||||||
|
|
||||||
|
+" ,POLICE_EMERGENT = ?"
|
||||||
|
|
||||||
|
+" where din.detection_set_info_id = ?"
|
||||||
|
|
||||||
|
+" and din.seq_id = ?";
|
||||||
|
return OracleToMysql.trans(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getChangeWarningInfoSql(){
|
||||||
|
String sql="update detection_info_warning set valid =0 where SEQ_ID=? and DETECTION_SET_INFO_ID=? and valid=1";
|
||||||
|
return OracleToMysql.trans(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/com/nms/server/bean/DownloadFileModel.java
Normal file
43
src/com/nms/server/bean/DownloadFileModel.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断点下载文件 数据模板
|
||||||
|
* @date Mar 8, 2012 4:33:41 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DownloadFileModel {
|
||||||
|
private String fileName;
|
||||||
|
private String MD5Val;
|
||||||
|
private Future<Object> bpDownFuture;
|
||||||
|
|
||||||
|
public DownloadFileModel(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadFileModel(String fileName,String MD5Val,Future<Object> bpDownFuture){
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.MD5Val = MD5Val;
|
||||||
|
this.bpDownFuture = bpDownFuture;
|
||||||
|
}
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
public String getMD5Val() {
|
||||||
|
return MD5Val;
|
||||||
|
}
|
||||||
|
public void setMD5Val(String val) {
|
||||||
|
MD5Val = val;
|
||||||
|
}
|
||||||
|
public Future<Object> getBpDownFuture() {
|
||||||
|
return bpDownFuture;
|
||||||
|
}
|
||||||
|
public void setBpDownFuture(Future<Object> bpDownFuture) {
|
||||||
|
this.bpDownFuture = bpDownFuture;
|
||||||
|
}
|
||||||
|
}
|
||||||
148
src/com/nms/server/bean/EmailInfo.java
Normal file
148
src/com/nms/server/bean/EmailInfo.java
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
public class EmailInfo {
|
||||||
|
/**
|
||||||
|
* 邮件ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 目标地址
|
||||||
|
*/
|
||||||
|
private String toAddress; //接收地址
|
||||||
|
/**
|
||||||
|
* 事件类型
|
||||||
|
* 10监测恢复,11监测信息异常,12:监测结果超时,
|
||||||
|
* 20主动告警恢复,21主动告警异常,
|
||||||
|
* 31结果失败,32任务状态变更,
|
||||||
|
* 40系统运行异常恢复,41系统运行异常
|
||||||
|
*/
|
||||||
|
private Integer actionType; //
|
||||||
|
/**
|
||||||
|
* 事件标题(具体的监测、任务等名称标题)
|
||||||
|
*/
|
||||||
|
private String actionDesc; //
|
||||||
|
/**
|
||||||
|
* 事件摘要(监测或任务下的,典型描述)
|
||||||
|
private String actionDesc2; //
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 事件地点
|
||||||
|
*/
|
||||||
|
private String actionIp; //
|
||||||
|
/**
|
||||||
|
* 事件时间
|
||||||
|
*/
|
||||||
|
private String actionDate; //
|
||||||
|
/**
|
||||||
|
* 事件内容及结果
|
||||||
|
*/
|
||||||
|
private String content; //
|
||||||
|
/**
|
||||||
|
* 发送标示
|
||||||
|
* 0未发送 1已发送
|
||||||
|
*/
|
||||||
|
private Integer sendFlag; //
|
||||||
|
/**
|
||||||
|
* 发送标示
|
||||||
|
* 0紧急发送 1 非紧急
|
||||||
|
*/
|
||||||
|
private Integer sendLevel; //
|
||||||
|
|
||||||
|
public EmailInfo (){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailInfo (EmailInfo info){
|
||||||
|
this.toAddress = info.getToAddress();
|
||||||
|
this.actionType = info.getActionType();
|
||||||
|
this.actionDesc = info.getActionDesc();
|
||||||
|
// this.actionDesc2 = info.getActionDesc2();
|
||||||
|
this.actionIp = info.getActionIp();
|
||||||
|
this.actionDate = info.getActionDate();
|
||||||
|
this.content = info.getContent();
|
||||||
|
this.sendFlag = info.getSendFlag();
|
||||||
|
this.sendLevel = info.getSendLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailInfo (Integer actionType,String actionDesc,/*String actionDesc2,*/String actionIp,String actionDate,String content,Integer sendFlag,Integer sendLevel){
|
||||||
|
this.actionType = actionType;
|
||||||
|
this.actionDesc = actionDesc;
|
||||||
|
// this.actionDesc2 = actionDesc2;
|
||||||
|
this.actionIp = actionIp;
|
||||||
|
this.actionDate = actionDate;
|
||||||
|
this.content = content;
|
||||||
|
this.sendFlag = sendFlag;
|
||||||
|
this.sendLevel = sendLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToAddress() {
|
||||||
|
return toAddress;
|
||||||
|
}
|
||||||
|
public void setToAddress(String toAddress) {
|
||||||
|
this.toAddress = toAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getActionType() {
|
||||||
|
return actionType;
|
||||||
|
}
|
||||||
|
public void setActionType(Integer actionType) {
|
||||||
|
this.actionType = actionType;
|
||||||
|
}
|
||||||
|
public String getActionIp() {
|
||||||
|
return actionIp;
|
||||||
|
}
|
||||||
|
public void setActionIp(String actionIp) {
|
||||||
|
this.actionIp = actionIp;
|
||||||
|
}
|
||||||
|
public String getActionDate() {
|
||||||
|
return actionDate;
|
||||||
|
}
|
||||||
|
public void setActionDate(String actionDate) {
|
||||||
|
this.actionDate = actionDate;
|
||||||
|
}
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
public Integer getSendFlag() {
|
||||||
|
return sendFlag;
|
||||||
|
}
|
||||||
|
public void setSendFlag(Integer sendFlag) {
|
||||||
|
this.sendFlag = sendFlag;
|
||||||
|
}
|
||||||
|
public String getActionDesc() {
|
||||||
|
return actionDesc;
|
||||||
|
}
|
||||||
|
public void setActionDesc(String actionDesc) {
|
||||||
|
this.actionDesc = actionDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public String getActionDesc2() {
|
||||||
|
return actionDesc2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionDesc2(String actionDesc2) {
|
||||||
|
this.actionDesc2 = actionDesc2;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public Integer getSendLevel() {
|
||||||
|
return sendLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSendLevel(Integer sendLevel) {
|
||||||
|
this.sendLevel = sendLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
36
src/com/nms/server/bean/EmailModel.java
Normal file
36
src/com/nms/server/bean/EmailModel.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
public class EmailModel {
|
||||||
|
private String toAddress; //接收地址
|
||||||
|
private String subjectDesc; //主题
|
||||||
|
private String content; //邮件内容
|
||||||
|
private Integer sendFlag; //0未发送 1已发送 2即时发送
|
||||||
|
|
||||||
|
|
||||||
|
public String getToAddress() {
|
||||||
|
return toAddress;
|
||||||
|
}
|
||||||
|
public void setToAddress(String toAddress) {
|
||||||
|
this.toAddress = toAddress;
|
||||||
|
}
|
||||||
|
public String getSubjectDesc() {
|
||||||
|
return subjectDesc;
|
||||||
|
}
|
||||||
|
public void setSubjectDesc(String subjectDesc) {
|
||||||
|
this.subjectDesc = subjectDesc;
|
||||||
|
}
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
public Integer getSendFlag() {
|
||||||
|
return sendFlag;
|
||||||
|
}
|
||||||
|
public void setSendFlag(Integer sendFlag) {
|
||||||
|
this.sendFlag = sendFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
128
src/com/nms/server/bean/EventRecordLibrary.java
Normal file
128
src/com/nms/server/bean/EventRecordLibrary.java
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EventRecordLibrary entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventRecordLibrary implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String recordType;
|
||||||
|
private String recordContent;
|
||||||
|
private Long seqId;
|
||||||
|
private Long state;
|
||||||
|
private String recordCommand;
|
||||||
|
private Date createTime; // 创建时间
|
||||||
|
// private String tableName; // 操作表
|
||||||
|
// private Long tableId; //表主键
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public EventRecordLibrary() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** full constructor */
|
||||||
|
public EventRecordLibrary(String recordType, String recordContent,
|
||||||
|
Long seqId, Long state, String recordCommand) {
|
||||||
|
this.recordType = recordType;
|
||||||
|
this.recordContent = recordContent;
|
||||||
|
this.seqId = seqId;
|
||||||
|
this.state = state;
|
||||||
|
this.recordCommand = recordCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecordType() {
|
||||||
|
return this.recordType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordType(String recordType) {
|
||||||
|
this.recordType = recordType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecordContent() {
|
||||||
|
return this.recordContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordContent(String recordContent) {
|
||||||
|
this.recordContent = recordContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSeqId() {
|
||||||
|
return seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeqId(Long seqId) {
|
||||||
|
this.seqId = seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(Long state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecordCommand() {
|
||||||
|
return this.recordCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordCommand(String recordCommand) {
|
||||||
|
this.recordCommand = recordCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Long getPid() {
|
||||||
|
// return pid;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setPid(Long pid) {
|
||||||
|
// this.pid = pid;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public String getTableName() {
|
||||||
|
// return tableName;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setTableName(String tableName) {
|
||||||
|
// this.tableName = tableName;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public Long getTableId() {
|
||||||
|
// return tableId;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setTableId(Long tableId) {
|
||||||
|
// this.tableId = tableId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
53
src/com/nms/server/bean/LoopMissionRoundInfo.java
Normal file
53
src/com/nms/server/bean/LoopMissionRoundInfo.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MissionStateTable entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LoopMissionRoundInfo implements java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 8184110460944634042L;
|
||||||
|
private Long missionId;
|
||||||
|
private Long curMissionId;
|
||||||
|
private Long missionState;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
public Long getMissionId() {
|
||||||
|
return missionId;
|
||||||
|
}
|
||||||
|
public void setMissionId(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
public Long getCurMissionId() {
|
||||||
|
return curMissionId;
|
||||||
|
}
|
||||||
|
public void setCurMissionId(Long curMissionId) {
|
||||||
|
this.curMissionId = curMissionId;
|
||||||
|
}
|
||||||
|
public Long getMissionState() {
|
||||||
|
return missionState;
|
||||||
|
}
|
||||||
|
public void setMissionState(Long missionSate) {
|
||||||
|
this.missionState = missionSate;
|
||||||
|
}
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
public void setEndTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/com/nms/server/bean/MissionResult.java
Normal file
41
src/com/nms/server/bean/MissionResult.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
public class MissionResult {
|
||||||
|
private Long missionId;// 任务ID
|
||||||
|
private String nodeIp;// 节点IP
|
||||||
|
private Long uuid;// 节点IP
|
||||||
|
private Long result;// 结果
|
||||||
|
private String description;// 结果描述
|
||||||
|
public Long getMissionId() {
|
||||||
|
return missionId;
|
||||||
|
}
|
||||||
|
public void setMissionId(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
public String getNodeIp() {
|
||||||
|
return nodeIp;
|
||||||
|
}
|
||||||
|
public void setNodeIp(String nodeIp) {
|
||||||
|
this.nodeIp = nodeIp;
|
||||||
|
}
|
||||||
|
public Long getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public void setResult(Long result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
public Long getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
public void setUuid(Long uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
118
src/com/nms/server/bean/MissionResult2.java
Normal file
118
src/com/nms/server/bean/MissionResult2.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
public class MissionResult2 implements Serializable{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2036264131238309952L;
|
||||||
|
private Long missionId;// 任务ID
|
||||||
|
private Long missionType;// 节点IP
|
||||||
|
private Long uuid;// 节点IP
|
||||||
|
private Long startTime;// 配置截取文本
|
||||||
|
private Long EndTime;// 配置截取文本
|
||||||
|
private String text;// 配置截取文本
|
||||||
|
private Long result;// 结果
|
||||||
|
private String description;// 结果描述
|
||||||
|
private String fileInfo;// 回传文件
|
||||||
|
private Long loopFlag;// 周期标识 0 非周期,1 周期
|
||||||
|
private Long resultDetail;//执行结果失败的具体原因,目前只有下发失败41
|
||||||
|
|
||||||
|
public MissionResult2() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MissionResult2(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MissionResult2(Long missionId,Long missionType,Long uuid,Long startTime,Long EndTime,String text,Long result,String description,String fileInfo,Long loopFlag) {
|
||||||
|
this.missionId = missionId;// 任务ID
|
||||||
|
this.missionType = missionType;;// 节点IP
|
||||||
|
this.uuid = uuid;;// 节点IP
|
||||||
|
this.startTime = startTime;;// 配置截取文本
|
||||||
|
this.EndTime = EndTime;;// 配置截取文本
|
||||||
|
this.text = text;;// 配置截取文本
|
||||||
|
this.result = result;;// 结果
|
||||||
|
this.description = description;;// 结果描述
|
||||||
|
this.fileInfo = fileInfo;;// 结果描述
|
||||||
|
this.loopFlag = loopFlag;;// 周期标识 0 非周期,1 周期
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMissionId() {
|
||||||
|
return missionId;
|
||||||
|
}
|
||||||
|
public void setMissionId(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
public Long getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public void setResult(Long result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
public Long getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
public void setUuid(Long uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
public Long getMissionType() {
|
||||||
|
return missionType;
|
||||||
|
}
|
||||||
|
public void setMissionType(Long missionType) {
|
||||||
|
this.missionType = missionType;
|
||||||
|
}
|
||||||
|
public Long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(Long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
public Long getEndTime() {
|
||||||
|
return EndTime;
|
||||||
|
}
|
||||||
|
public void setEndTime(Long endTime) {
|
||||||
|
EndTime = endTime;
|
||||||
|
}
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
public String getFileInfo() {
|
||||||
|
return fileInfo;
|
||||||
|
}
|
||||||
|
public void setFileInfo(String fileInfo) {
|
||||||
|
this.fileInfo = fileInfo;
|
||||||
|
}
|
||||||
|
public Long getLoopFlag() {
|
||||||
|
return loopFlag;
|
||||||
|
}
|
||||||
|
public void setLoopFlag(Long loopFlag) {
|
||||||
|
this.loopFlag = loopFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Long getResultDetail()
|
||||||
|
{
|
||||||
|
return resultDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setResultDetail(Long resultDetail)
|
||||||
|
{
|
||||||
|
this.resultDetail = resultDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
152
src/com/nms/server/bean/MissionStateTable.java
Normal file
152
src/com/nms/server/bean/MissionStateTable.java
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MissionStateTable entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MissionStateTable implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -1342600696641355325L;
|
||||||
|
private Long missionId;
|
||||||
|
// private String missionName;
|
||||||
|
private Long missionType;
|
||||||
|
// private String missionTypeName;
|
||||||
|
private Long missionState;
|
||||||
|
// private Long viewLevel;
|
||||||
|
// private Long userId;
|
||||||
|
// private String userIdName;
|
||||||
|
private Long groupId;
|
||||||
|
private Long nodeListId;
|
||||||
|
private String nodeIpsId;
|
||||||
|
// private Long nodeListId1;
|
||||||
|
private String nodeGroupsId;
|
||||||
|
// private String groupIdName;
|
||||||
|
// private Date createTime;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
// private String failDesc;
|
||||||
|
private Long systemId;
|
||||||
|
// private String systemIdName;
|
||||||
|
private Long loopFlag = 0L;
|
||||||
|
private Long loopDelay;
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public MissionStateTable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMissionId() {
|
||||||
|
return missionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMissionId(Long missionId) {
|
||||||
|
this.missionId = missionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMissionType() {
|
||||||
|
return missionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMissionType(Long missionType) {
|
||||||
|
this.missionType = missionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMissionState() {
|
||||||
|
return missionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMissionState(Long missionState) {
|
||||||
|
this.missionState = missionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(Long groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSystemId() {
|
||||||
|
return systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSystemId(Long systemId) {
|
||||||
|
this.systemId = systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLoopFlag() {
|
||||||
|
return loopFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoopFlag(Long loopFlag) {
|
||||||
|
this.loopFlag = loopFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLoopDelay() {
|
||||||
|
return loopDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoopDelay(Long loopDelay) {
|
||||||
|
this.loopDelay = loopDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNodeListId() {
|
||||||
|
return nodeListId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeListId(Long nodeListId) {
|
||||||
|
this.nodeListId = nodeListId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Long getNodeListId1() {
|
||||||
|
// return nodeListId1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setNodeListId1(Long nodeListId1) {
|
||||||
|
// this.nodeListId1 = nodeListId1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeGroupsId(String groupsId) {
|
||||||
|
this.nodeGroupsId = groupsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
86
src/com/nms/server/bean/NmsErrorCode.java
Normal file
86
src/com/nms/server/bean/NmsErrorCode.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NmsErrorCode entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class NmsErrorCode implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String errorCode;
|
||||||
|
private String errorName;
|
||||||
|
private String errorDes;
|
||||||
|
private Long errorLevel;
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public NmsErrorCode() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** minimal constructor */
|
||||||
|
public NmsErrorCode(Long id, String errorCode, String errorName,
|
||||||
|
Long errorLevel) {
|
||||||
|
this.id = id;
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorName = errorName;
|
||||||
|
this.errorLevel = errorLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** full constructor */
|
||||||
|
public NmsErrorCode(Long id, String errorCode, String errorName,
|
||||||
|
String errorDes, Long errorLevel) {
|
||||||
|
this.id = id;
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorName = errorName;
|
||||||
|
this.errorDes = errorDes;
|
||||||
|
this.errorLevel = errorLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorCode() {
|
||||||
|
return this.errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorCode(String errorCode) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorName() {
|
||||||
|
return this.errorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorName(String errorName) {
|
||||||
|
this.errorName = errorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorDes() {
|
||||||
|
return this.errorDes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorDes(String errorDes) {
|
||||||
|
this.errorDes = errorDes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getErrorLevel() {
|
||||||
|
return this.errorLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorLevel(Long errorLevel) {
|
||||||
|
this.errorLevel = errorLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
135
src/com/nms/server/bean/NmsErrorInfo.java
Normal file
135
src/com/nms/server/bean/NmsErrorInfo.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NmsErrorInfo entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class NmsErrorInfo implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String errorCode;
|
||||||
|
private Date errorTime;
|
||||||
|
private String errortGetip;
|
||||||
|
private String errortIp;
|
||||||
|
private String errortDesc;
|
||||||
|
private Long errorState;
|
||||||
|
private Date stateUpdateTime;
|
||||||
|
private Long stateUpdateUserid;
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public NmsErrorInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** minimal constructor */
|
||||||
|
public NmsErrorInfo(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** full constructor */
|
||||||
|
// public NmsErrorInfo(Long id, String errorCode, Date errorTime,
|
||||||
|
// String errortGetip, String errortIp, Long errorState,
|
||||||
|
// Date stateUpdateTime, Long stateUpdateUserid,String errortDesc) {
|
||||||
|
// this.id = id;
|
||||||
|
// this.errorCode = errorCode;
|
||||||
|
// this.errorTime = errorTime;
|
||||||
|
// this.errortGetip = errortGetip;
|
||||||
|
// this.errortIp = errortIp;
|
||||||
|
// this.errorState = errorState;
|
||||||
|
// this.errortDesc = errortDesc;
|
||||||
|
// this.stateUpdateTime = stateUpdateTime;
|
||||||
|
// this.stateUpdateUserid = stateUpdateUserid;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public NmsErrorInfo(String errorCode, Date errorTime,
|
||||||
|
String errortGetip, String errortIp, Long errorState,String errortDesc) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorTime = errorTime;
|
||||||
|
this.errortGetip = errortGetip;
|
||||||
|
this.errortIp = errortIp;
|
||||||
|
this.errorState = errorState;
|
||||||
|
this.errortDesc = errortDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorCode() {
|
||||||
|
return this.errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorCode(String errorCode) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getErrorTime() {
|
||||||
|
return this.errorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorTime(Date errorTime) {
|
||||||
|
this.errorTime = errorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrortGetip() {
|
||||||
|
return this.errortGetip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrortGetip(String errortGetip) {
|
||||||
|
this.errortGetip = errortGetip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrortIp() {
|
||||||
|
return this.errortIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrortIp(String errortIp) {
|
||||||
|
this.errortIp = errortIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getErrorState() {
|
||||||
|
return this.errorState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorState(Long errorState) {
|
||||||
|
this.errorState = errorState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStateUpdateTime() {
|
||||||
|
return this.stateUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStateUpdateTime(Date stateUpdateTime) {
|
||||||
|
this.stateUpdateTime = stateUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStateUpdateUserid() {
|
||||||
|
return this.stateUpdateUserid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStateUpdateUserid(Long stateUpdateUserid) {
|
||||||
|
this.stateUpdateUserid = stateUpdateUserid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrortDesc() {
|
||||||
|
return errortDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrortDesc(String errortDesc) {
|
||||||
|
this.errortDesc = errortDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
131
src/com/nms/server/bean/NodeModel.java
Normal file
131
src/com/nms/server/bean/NodeModel.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NodeTable entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class NodeModel implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1984053252904108229L;
|
||||||
|
private Long nodeId;
|
||||||
|
private String nodeIp;
|
||||||
|
|
||||||
|
/* 节点类型 0服务器 1交换机 */
|
||||||
|
private Long nodeType;
|
||||||
|
// private String nodeName;
|
||||||
|
|
||||||
|
/* 节点状态 0有效 1无效*/
|
||||||
|
private Long nodeState;
|
||||||
|
private Long systemId;
|
||||||
|
private Long seqId;
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
|
||||||
|
private String nodeUserName;
|
||||||
|
private String nodePassword;
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public NodeModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeModel(String nodeIp,Long nodeType) {
|
||||||
|
this.nodeIp = nodeIp;
|
||||||
|
this.nodeType = nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** minimal constructor */
|
||||||
|
public NodeModel(Long nodeId, Long nodeState,
|
||||||
|
Long systemId) {
|
||||||
|
this.nodeId = nodeId;
|
||||||
|
// this.nodeName = nodeName;
|
||||||
|
this.nodeState = nodeState;
|
||||||
|
this.systemId = systemId;
|
||||||
|
//this.nodeLatticeId=nodeLatticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getNodeId() {
|
||||||
|
return this.nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeId(Long nodeId) {
|
||||||
|
this.nodeId = nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNodeState() {
|
||||||
|
return this.nodeState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeState(Long nodeState) {
|
||||||
|
this.nodeState = nodeState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSystemId() {
|
||||||
|
return this.systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSystemId(Long systemId) {
|
||||||
|
this.systemId = systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeIp() {
|
||||||
|
return nodeIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeIp(String nodeIp) {
|
||||||
|
this.nodeIp = nodeIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNodeType() {
|
||||||
|
return nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeType(Long nodeType) {
|
||||||
|
this.nodeType = nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSeqId() {
|
||||||
|
return seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeqId(Long seqId) {
|
||||||
|
this.seqId = seqId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(Long groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeUserName() {
|
||||||
|
return nodeUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeUserName(String nodeUserName) {
|
||||||
|
this.nodeUserName = nodeUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodePassword() {
|
||||||
|
return nodePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodePassword(String nodePassword) {
|
||||||
|
this.nodePassword = nodePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
66
src/com/nms/server/bean/NodegroupModel.java
Normal file
66
src/com/nms/server/bean/NodegroupModel.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NodegroupTable entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class NodegroupModel implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -5562024412959332727L;
|
||||||
|
private Long groupId;
|
||||||
|
private String groupName;
|
||||||
|
private Long groupType;
|
||||||
|
private Long systemId;
|
||||||
|
private Long isValid;//0是失效,1是生效
|
||||||
|
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getGroupId() {
|
||||||
|
return this.groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(Long groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return this.groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getGroupType() {
|
||||||
|
return this.groupType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupType(Long groupType) {
|
||||||
|
this.groupType = groupType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSystemId(Long systemId) {
|
||||||
|
this.systemId = systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getIsValid() {
|
||||||
|
return this.isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(Long isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSystemId() {
|
||||||
|
return systemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
106
src/com/nms/server/bean/ReturnFilePO.java
Normal file
106
src/com/nms/server/bean/ReturnFilePO.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class ReturnFilePO {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
private Long taskId;
|
||||||
|
/**
|
||||||
|
* 类型:4 命令执行,6 升级
|
||||||
|
*/
|
||||||
|
private long taskType;
|
||||||
|
/**
|
||||||
|
* 唯一标志一台物理机(类似于IP)
|
||||||
|
*/
|
||||||
|
private long uuid;
|
||||||
|
/**
|
||||||
|
* 回传路径集: key 文件实际路径 value 文件别名
|
||||||
|
*/
|
||||||
|
// private Map<String, String> filePathMap;
|
||||||
|
/**
|
||||||
|
* 当前要回传的文件
|
||||||
|
*/
|
||||||
|
// private File curRetrunFile;
|
||||||
|
/**
|
||||||
|
* 回传文件名(统一处理后一个任务只有一个回传文件)
|
||||||
|
*/
|
||||||
|
private String returnFileName;
|
||||||
|
/**
|
||||||
|
* 回传状态:0 成功,1 失败
|
||||||
|
*/
|
||||||
|
private long state;
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private Date startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 是否循环任务
|
||||||
|
*/
|
||||||
|
private long isLoop;
|
||||||
|
/**
|
||||||
|
* 回传文件的结果描述
|
||||||
|
*/
|
||||||
|
private String resDesc;
|
||||||
|
|
||||||
|
public Long getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
public void setTaskId(Long taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
public long getTaskType() {
|
||||||
|
return taskType;
|
||||||
|
}
|
||||||
|
public void setTaskType(long taskType) {
|
||||||
|
this.taskType = taskType;
|
||||||
|
}
|
||||||
|
public long getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
public void setState(long state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
public void setEndTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
public long getIsLoop() {
|
||||||
|
return isLoop;
|
||||||
|
}
|
||||||
|
public void setIsLoop(long isLoop) {
|
||||||
|
this.isLoop = isLoop;
|
||||||
|
}
|
||||||
|
public String getResDesc() {
|
||||||
|
return resDesc;
|
||||||
|
}
|
||||||
|
public void setResDesc(String resDesc) {
|
||||||
|
this.resDesc = resDesc;
|
||||||
|
}
|
||||||
|
public String getReturnFileName() {
|
||||||
|
return returnFileName;
|
||||||
|
}
|
||||||
|
public void setReturnFileName(String returnFileName) {
|
||||||
|
this.returnFileName = returnFileName;
|
||||||
|
}
|
||||||
|
public long getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
public void setUuid(long uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
src/com/nms/server/bean/ServerIpSegment.java
Normal file
32
src/com/nms/server/bean/ServerIpSegment.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
public class ServerIpSegment {
|
||||||
|
public String startIp;
|
||||||
|
public Long startIpn;
|
||||||
|
public String endIp;
|
||||||
|
public Long endIpn;
|
||||||
|
public String getStartIp() {
|
||||||
|
return startIp;
|
||||||
|
}
|
||||||
|
public void setStartIp(String startIp) {
|
||||||
|
this.startIp = startIp;
|
||||||
|
}
|
||||||
|
public Long getStartIpn() {
|
||||||
|
return startIpn;
|
||||||
|
}
|
||||||
|
public void setStartIpn(Long startIpn) {
|
||||||
|
this.startIpn = startIpn;
|
||||||
|
}
|
||||||
|
public String getEndIp() {
|
||||||
|
return endIp;
|
||||||
|
}
|
||||||
|
public void setEndIp(String endIp) {
|
||||||
|
this.endIp = endIp;
|
||||||
|
}
|
||||||
|
public Long getEndIpn() {
|
||||||
|
return endIpn;
|
||||||
|
}
|
||||||
|
public void setEndIpn(Long endIpn) {
|
||||||
|
this.endIpn = endIpn;
|
||||||
|
}
|
||||||
|
}
|
||||||
121
src/com/nms/server/bean/ServerTable.java
Normal file
121
src/com/nms/server/bean/ServerTable.java
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ServerTable entity.
|
||||||
|
*
|
||||||
|
* @author MyEclipse Persistence Tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ServerTable implements java.io.Serializable {
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Long id; //数据库DC 注册ID
|
||||||
|
private String serverName; //当前DC名称
|
||||||
|
private Long serverState; //当前DC状态
|
||||||
|
private String serverIp; //当前DC IP
|
||||||
|
private Long serverIpn; //当前DC IPN
|
||||||
|
private int index; //当前dc 在数据库的排序
|
||||||
|
private int conut; //当前dc 总数
|
||||||
|
//- 当前DC 的IP管理范围(空时 过滤条件为空,即为管理全部 注意)
|
||||||
|
private List<ServerIpSegment> ipSegList = new LinkedList<ServerIpSegment>();
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/** default constructor */
|
||||||
|
public ServerTable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** full constructor */
|
||||||
|
public ServerTable(String serverName, Long serverState, String serverIp,
|
||||||
|
Long serverIpn) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.serverState = serverState;
|
||||||
|
this.serverIp = serverIp;
|
||||||
|
this.serverIpn = serverIpn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** All constructor */
|
||||||
|
public ServerTable(Long id,String serverName, Long serverState, String serverIp,
|
||||||
|
Long serverIpn) {
|
||||||
|
this.id = id;
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.serverState = serverState;
|
||||||
|
this.serverIp = serverIp;
|
||||||
|
this.serverIpn = serverIpn;
|
||||||
|
}
|
||||||
|
// Property accessors
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return this.serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerName(String serverName) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getServerState() {
|
||||||
|
return this.serverState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerState(Long serverState) {
|
||||||
|
this.serverState = serverState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerIp() {
|
||||||
|
return this.serverIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerIp(String serverIp) {
|
||||||
|
this.serverIp = serverIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getServerIpn() {
|
||||||
|
return this.serverIpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerIpn(Long serverIpn) {
|
||||||
|
this.serverIpn = serverIpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServerIpSegment> getIpSegList() {
|
||||||
|
return ipSegList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIpSegList(List<ServerIpSegment> ipSegList) {
|
||||||
|
this.ipSegList = ipSegList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getConut() {
|
||||||
|
return conut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConut(int conut) {
|
||||||
|
this.conut = conut;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
277
src/com/nms/server/bean/SetInfo.java
Normal file
277
src/com/nms/server/bean/SetInfo.java
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端用到的监测设置信息实体
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @author chuan
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SetInfo {
|
||||||
|
/**
|
||||||
|
* 监测设置信息ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测类型
|
||||||
|
*/
|
||||||
|
private String checkTypeName;//如:CPU、DISK等
|
||||||
|
private Long checkTypeId;//检测类型的ID,预留
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标IP
|
||||||
|
*/
|
||||||
|
// private String nodeIp;//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大测试次数
|
||||||
|
*/
|
||||||
|
private Long checkMaxTimes;
|
||||||
|
/**
|
||||||
|
* 节点组ID
|
||||||
|
*/
|
||||||
|
// private Long groupId;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String nodeGroupsId;
|
||||||
|
/**
|
||||||
|
* 最大测试次数
|
||||||
|
*/
|
||||||
|
private String nodeIpsId;
|
||||||
|
/**
|
||||||
|
* 时间间隔(单位:分钟)
|
||||||
|
*/
|
||||||
|
private Long checkGap;
|
||||||
|
/**
|
||||||
|
* 超时时间(单位:秒)
|
||||||
|
*/
|
||||||
|
private Long checkOutTime;
|
||||||
|
/**
|
||||||
|
* 监测状态:0无效;1有效
|
||||||
|
*/
|
||||||
|
private String checkState;
|
||||||
|
/**
|
||||||
|
* 监测方式:0主动,1被动
|
||||||
|
*/
|
||||||
|
private String checkWay;
|
||||||
|
/**
|
||||||
|
* 进程标志
|
||||||
|
*/
|
||||||
|
private String processIden;
|
||||||
|
/**
|
||||||
|
* 进程执行文件
|
||||||
|
*/
|
||||||
|
private String processFile;
|
||||||
|
/**
|
||||||
|
* 进程执行文件路径
|
||||||
|
*/
|
||||||
|
private String processPath;
|
||||||
|
/**
|
||||||
|
* 是否系统启动(NMSAgent启动/第三方自己启动);默认0自启动;1NMSAgent启动
|
||||||
|
*/
|
||||||
|
private String IsControlStart;
|
||||||
|
/* *//**
|
||||||
|
* 是否需下发文件:0需要;1不需要 默认1
|
||||||
|
*//*
|
||||||
|
private String isIssueFile;
|
||||||
|
*//**
|
||||||
|
* 文件下发是否成功;0成功;1不成功 默认1
|
||||||
|
*//*
|
||||||
|
private String isIssued;
|
||||||
|
*//**
|
||||||
|
* 是否下发设置:0下发;1未下发 默认值为1如新添加或者修改一项设置之后设置为未下发,需要完成其他配置信息后才执行一次下发
|
||||||
|
*//*
|
||||||
|
private String isIssue;*/
|
||||||
|
/**
|
||||||
|
* 控制启动时间
|
||||||
|
*/
|
||||||
|
private Long controlStartTime;
|
||||||
|
/**
|
||||||
|
*上传数据时间间隔单位分钟:不能为空,默认15分钟。监测数据上传到NMSServer周期。
|
||||||
|
*/
|
||||||
|
private Long uploadGap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划检测时间:针对当前配置信息首次执行时间
|
||||||
|
*/
|
||||||
|
private Long planCheckTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否预置监测
|
||||||
|
*/
|
||||||
|
private String isSchedule;
|
||||||
|
/**
|
||||||
|
* 监测级别
|
||||||
|
*/
|
||||||
|
private Long viewLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定IP操作
|
||||||
|
*/
|
||||||
|
private String nodeIp2; //指定单个IP
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程搜索关键字
|
||||||
|
*/
|
||||||
|
private String processSearchKeyCode; //指定单个IP
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否SNMP检测 0:objectSNMP 1:SNMP4j
|
||||||
|
*/
|
||||||
|
private Long isSNMP;
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
public String getCheckTypeName() {
|
||||||
|
return checkTypeName;
|
||||||
|
}
|
||||||
|
public void setCheckTypeName(String checkTypeName) {
|
||||||
|
this.checkTypeName = checkTypeName;
|
||||||
|
}
|
||||||
|
public Long getCheckTypeId() {
|
||||||
|
return checkTypeId;
|
||||||
|
}
|
||||||
|
public Long getCheckMaxTimes() {
|
||||||
|
return checkMaxTimes;
|
||||||
|
}
|
||||||
|
public void setCheckMaxTimes(Long checkMaxTimes) {
|
||||||
|
this.checkMaxTimes = checkMaxTimes;
|
||||||
|
}
|
||||||
|
public Long getCheckGap() {
|
||||||
|
return checkGap;
|
||||||
|
}
|
||||||
|
public void setCheckGap(Long checkGap) {
|
||||||
|
this.checkGap = checkGap;
|
||||||
|
}
|
||||||
|
public Long getCheckOutTime() {
|
||||||
|
return checkOutTime;
|
||||||
|
}
|
||||||
|
public void setCheckOutTime(Long checkOutTime) {
|
||||||
|
this.checkOutTime = checkOutTime;
|
||||||
|
}
|
||||||
|
public String getCheckState() {
|
||||||
|
return checkState;
|
||||||
|
}
|
||||||
|
public void setCheckState(String checkState) {
|
||||||
|
this.checkState = checkState;
|
||||||
|
}
|
||||||
|
public String getProcessIden() {
|
||||||
|
return processIden;
|
||||||
|
}
|
||||||
|
public void setProcessIden(String processIden) {
|
||||||
|
this.processIden = processIden;
|
||||||
|
}
|
||||||
|
public String getProcessFile() {
|
||||||
|
return processFile;
|
||||||
|
}
|
||||||
|
public void setProcessFile(String processFile) {
|
||||||
|
this.processFile = processFile;
|
||||||
|
}
|
||||||
|
public String getProcessPath() {
|
||||||
|
return processPath;
|
||||||
|
}
|
||||||
|
public void setProcessPath(String processPath) {
|
||||||
|
this.processPath = processPath;
|
||||||
|
}
|
||||||
|
public void setCheckTypeId(Long checkTypeId) {
|
||||||
|
this.checkTypeId = checkTypeId;
|
||||||
|
}
|
||||||
|
public String getCheckWay() {
|
||||||
|
return checkWay;
|
||||||
|
}
|
||||||
|
public void setCheckWay(String checkWay) {
|
||||||
|
this.checkWay = checkWay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ReflectionToStringBuilder.toString(this);
|
||||||
|
}
|
||||||
|
// public String getNodeIp() {
|
||||||
|
// return nodeIp;
|
||||||
|
// }
|
||||||
|
// public void setNodeIp(String nodeIp) {
|
||||||
|
// this.nodeIp = nodeIp;
|
||||||
|
// }
|
||||||
|
public String getIsControlStart() {
|
||||||
|
return IsControlStart;
|
||||||
|
}
|
||||||
|
public void setIsControlStart(String isControlStart) {
|
||||||
|
IsControlStart = isControlStart;
|
||||||
|
}
|
||||||
|
public Long getControlStartTime() {
|
||||||
|
return controlStartTime;
|
||||||
|
}
|
||||||
|
public void setControlStartTime(Long controlStartTime) {
|
||||||
|
this.controlStartTime = controlStartTime;
|
||||||
|
}
|
||||||
|
public Long getPlanCheckTime() {
|
||||||
|
return planCheckTime;
|
||||||
|
}
|
||||||
|
public void setPlanCheckTime(Long planCheckTime) {
|
||||||
|
this.planCheckTime = planCheckTime;
|
||||||
|
}
|
||||||
|
public Long getUploadGap() {
|
||||||
|
return uploadGap;
|
||||||
|
}
|
||||||
|
public void setUploadGap(Long uploadGap) {
|
||||||
|
this.uploadGap = uploadGap;
|
||||||
|
}
|
||||||
|
public String getIsSchedule() {
|
||||||
|
return isSchedule;
|
||||||
|
}
|
||||||
|
public void setIsSchedule(String isSchedule) {
|
||||||
|
this.isSchedule = isSchedule;
|
||||||
|
}
|
||||||
|
// public Long getGroupId() {
|
||||||
|
// return groupId;
|
||||||
|
// }
|
||||||
|
// public void setGroupId(Long groupId) {
|
||||||
|
// this.groupId = groupId;
|
||||||
|
// }
|
||||||
|
public Long getIsSNMP() {
|
||||||
|
return isSNMP;
|
||||||
|
}
|
||||||
|
public void setIsSNMP(Long isSNMP) {
|
||||||
|
this.isSNMP = isSNMP;
|
||||||
|
}
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
public void setNodeGroupsId(String nodeGroupsId) {
|
||||||
|
this.nodeGroupsId = nodeGroupsId;
|
||||||
|
}
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
public String getNodeIp2() {
|
||||||
|
return nodeIp2;
|
||||||
|
}
|
||||||
|
public void setNodeIp2(String nodeIp2) {
|
||||||
|
this.nodeIp2 = nodeIp2;
|
||||||
|
}
|
||||||
|
public Long getViewLevel() {
|
||||||
|
return viewLevel;
|
||||||
|
}
|
||||||
|
public void setViewLevel(Long viewLevel) {
|
||||||
|
this.viewLevel = viewLevel;
|
||||||
|
}
|
||||||
|
public String getProcessSearchKeyCode() {
|
||||||
|
return processSearchKeyCode;
|
||||||
|
}
|
||||||
|
public void setProcessSearchKeyCode(String processSearchKeyCode) {
|
||||||
|
this.processSearchKeyCode = processSearchKeyCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/com/nms/server/bean/SimpleNode.java
Normal file
29
src/com/nms/server/bean/SimpleNode.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 简单节点对象
|
||||||
|
* @date Jun 18, 2013 3:51:28 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SimpleNode {
|
||||||
|
private String nodeIp; //节点IP
|
||||||
|
private Integer snmpVersion; // 节点SNMP版本 version1 version2c version3
|
||||||
|
public SimpleNode(String nodeIp,Integer snmpVersion){
|
||||||
|
this.nodeIp = nodeIp;
|
||||||
|
this.snmpVersion = snmpVersion;
|
||||||
|
}
|
||||||
|
public String getNodeIp() {
|
||||||
|
return nodeIp;
|
||||||
|
}
|
||||||
|
public void setNodeIp(String nodeIp) {
|
||||||
|
this.nodeIp = nodeIp;
|
||||||
|
}
|
||||||
|
public Integer getSnmpVersion() {
|
||||||
|
return snmpVersion;
|
||||||
|
}
|
||||||
|
public void setSnmpVersion(Integer snmpVersion) {
|
||||||
|
this.snmpVersion = snmpVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
src/com/nms/server/bean/TableColumnsModel.java
Normal file
57
src/com/nms/server/bean/TableColumnsModel.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段详细信息
|
||||||
|
* @date Jun 18, 2013 4:02:44 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TableColumnsModel {
|
||||||
|
|
||||||
|
private String filedName; //字段名称 表字段名称
|
||||||
|
private String filedComments; //字段描述 中文名称
|
||||||
|
private String filedType; //字段类型
|
||||||
|
private String oid; //字段OID 用于snmp
|
||||||
|
// private Integer showNum;
|
||||||
|
|
||||||
|
public TableColumnsModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
public TableColumnsModel(String filedName,String filedComments,String filedType,String oid) {
|
||||||
|
this.filedName = filedName;
|
||||||
|
this.filedComments = filedComments;
|
||||||
|
this.filedType = filedType;
|
||||||
|
this.oid = oid;
|
||||||
|
// this.showNum = showNum;
|
||||||
|
}
|
||||||
|
public String getFiledName() {
|
||||||
|
return filedName;
|
||||||
|
}
|
||||||
|
public void setFiledName(String filedName) {
|
||||||
|
this.filedName = filedName;
|
||||||
|
}
|
||||||
|
public String getFiledComments() {
|
||||||
|
return filedComments;
|
||||||
|
}
|
||||||
|
public void setFiledComments(String filedComments) {
|
||||||
|
this.filedComments = filedComments;
|
||||||
|
}
|
||||||
|
public String getFiledType() {
|
||||||
|
return filedType;
|
||||||
|
}
|
||||||
|
public void setFiledType(String filedType) {
|
||||||
|
this.filedType = filedType;
|
||||||
|
}
|
||||||
|
public String getOid() {
|
||||||
|
return oid;
|
||||||
|
}
|
||||||
|
public void setOid(String oid) {
|
||||||
|
this.oid = oid;
|
||||||
|
}
|
||||||
|
// public Integer getShowNum() {
|
||||||
|
// return showNum;
|
||||||
|
// }
|
||||||
|
// public void setShowNum(Integer showNum) {
|
||||||
|
// this.showNum = showNum;
|
||||||
|
// }
|
||||||
|
}
|
||||||
39
src/com/nms/server/bean/TableModel.java
Normal file
39
src/com/nms/server/bean/TableModel.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测类别信息
|
||||||
|
* @date Jun 18, 2013 4:04:15 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TableModel {
|
||||||
|
private String tableName ; //表名称 库表名称
|
||||||
|
private String oid ; // 监测类别对应的OID
|
||||||
|
private Long isSnmp; // 监测类别是否是snmp
|
||||||
|
public TableModel (){
|
||||||
|
|
||||||
|
}
|
||||||
|
public TableModel (String tableName,String oid,Long isSnmp){
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.oid = oid;
|
||||||
|
this.isSnmp = isSnmp;
|
||||||
|
}
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
public void setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
public String getOid() {
|
||||||
|
return oid;
|
||||||
|
}
|
||||||
|
public void setOid(String oid) {
|
||||||
|
this.oid = oid;
|
||||||
|
}
|
||||||
|
public Long getIsSnmp() {
|
||||||
|
return isSnmp;
|
||||||
|
}
|
||||||
|
public void setIsSnmp(Long isSnmp) {
|
||||||
|
this.isSnmp = isSnmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/com/nms/server/bean/Task1.java
Normal file
70
src/com/nms/server/bean/Task1.java
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务实体类:1 文件推送
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Task1 {
|
||||||
|
/**
|
||||||
|
* 任务ID
|
||||||
|
*/
|
||||||
|
private Long taskId;
|
||||||
|
/**
|
||||||
|
* 任务类型:1 文件推送,2 非流文本数据获取,3 流文本数据获取,4 命令执行,5 shell注册
|
||||||
|
*/
|
||||||
|
private long taskType;
|
||||||
|
/**
|
||||||
|
* 节点组Id
|
||||||
|
*/
|
||||||
|
private Long nodeListId;
|
||||||
|
private String nodeIpsId;
|
||||||
|
// private Long nodeListId1;
|
||||||
|
private String nodeGroupsId;
|
||||||
|
/**
|
||||||
|
* 节点组Id
|
||||||
|
*/
|
||||||
|
private String taskParam;
|
||||||
|
public Long getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
public void setTaskId(Long taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
public long getTaskType() {
|
||||||
|
return taskType;
|
||||||
|
}
|
||||||
|
public void setTaskType(long taskType) {
|
||||||
|
this.taskType = taskType;
|
||||||
|
}
|
||||||
|
public Long getNodeListId() {
|
||||||
|
return nodeListId;
|
||||||
|
}
|
||||||
|
public void setNodeListId(Long nodeListId) {
|
||||||
|
this.nodeListId = nodeListId;
|
||||||
|
}
|
||||||
|
public String getTaskParam() {
|
||||||
|
return taskParam;
|
||||||
|
}
|
||||||
|
public void setTaskParam(String taskParam) {
|
||||||
|
this.taskParam = taskParam;
|
||||||
|
}
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
public void setNodeGroupsId(String groupsId) {
|
||||||
|
this.nodeGroupsId = groupsId;
|
||||||
|
}
|
||||||
|
// public Long getNodeListId1() {
|
||||||
|
// return nodeListId1;
|
||||||
|
// }
|
||||||
|
// public void setNodeListId1(Long nodeListId1) {
|
||||||
|
// this.nodeListId1 = nodeListId1;
|
||||||
|
// }
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
}
|
||||||
165
src/com/nms/server/bean/Task4.java
Normal file
165
src/com/nms/server/bean/Task4.java
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务实体类:4 命令执行
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Task4 {
|
||||||
|
/**
|
||||||
|
* 任务ID
|
||||||
|
*/
|
||||||
|
private Long taskId;
|
||||||
|
/**
|
||||||
|
* 任务类型:1 文件推送,2 非流文本数据获取,3 流文本数据获取,4 命令执行,5 shell注册
|
||||||
|
*/
|
||||||
|
private long taskType;
|
||||||
|
/**
|
||||||
|
* 命令类型:1 Agent原生支持命令,2 脚本,3 shell命令
|
||||||
|
*/
|
||||||
|
private long commandType;
|
||||||
|
/**
|
||||||
|
* 命令名称
|
||||||
|
*/
|
||||||
|
private String commandName;
|
||||||
|
/**
|
||||||
|
* 命令参数
|
||||||
|
*/
|
||||||
|
private String commandParam;
|
||||||
|
/**
|
||||||
|
* 脚本路径
|
||||||
|
*/
|
||||||
|
private String scriptPath;
|
||||||
|
/**
|
||||||
|
* 执行状态:4下发任务(40 下发成功,41下发失败),5杀进程(50成功,51失败)、6备份、7更新(覆盖) 、8启动进程
|
||||||
|
*/
|
||||||
|
private long state;
|
||||||
|
/**
|
||||||
|
* 执行状态:0 周期执行,5撤销执行
|
||||||
|
*/
|
||||||
|
private Long missionState;
|
||||||
|
/**
|
||||||
|
* 如果是升级,旧的版本
|
||||||
|
*/
|
||||||
|
private Long version;
|
||||||
|
/**
|
||||||
|
* 节点组Id
|
||||||
|
*/
|
||||||
|
private Long nodeListId;
|
||||||
|
private String nodeIpsId;
|
||||||
|
private String nodeGroupsId;
|
||||||
|
/**
|
||||||
|
* 执行时间
|
||||||
|
*/
|
||||||
|
private Long startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Long endTime;
|
||||||
|
/**
|
||||||
|
* 是否循环任务
|
||||||
|
*/
|
||||||
|
private Long isLoop;
|
||||||
|
/**
|
||||||
|
* 如果是循环任务,循环周期
|
||||||
|
*/
|
||||||
|
private Long loopDelay;
|
||||||
|
public Long getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
public void setTaskId(Long taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
public long getTaskType() {
|
||||||
|
return taskType;
|
||||||
|
}
|
||||||
|
public void setTaskType(long taskType) {
|
||||||
|
this.taskType = taskType;
|
||||||
|
}
|
||||||
|
public long getCommandType() {
|
||||||
|
return commandType;
|
||||||
|
}
|
||||||
|
public void setCommandType(long commandType) {
|
||||||
|
this.commandType = commandType;
|
||||||
|
}
|
||||||
|
public String getCommandName() {
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
public void setCommandName(String commandName) {
|
||||||
|
this.commandName = commandName;
|
||||||
|
}
|
||||||
|
public String getCommandParam() {
|
||||||
|
return commandParam;
|
||||||
|
}
|
||||||
|
public void setCommandParam(String commandParam) {
|
||||||
|
this.commandParam = commandParam;
|
||||||
|
}
|
||||||
|
public String getScriptPath() {
|
||||||
|
return scriptPath;
|
||||||
|
}
|
||||||
|
public void setScriptPath(String scriptPath) {
|
||||||
|
this.scriptPath = scriptPath;
|
||||||
|
}
|
||||||
|
public long getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
public void setState(long state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
public Long getMissionState() {
|
||||||
|
return missionState;
|
||||||
|
}
|
||||||
|
public void setMissionState(Long missionState) {
|
||||||
|
this.missionState = missionState;
|
||||||
|
}
|
||||||
|
public Long getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
public void setVersion(Long version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
public Long getNodeListId() {
|
||||||
|
return nodeListId;
|
||||||
|
}
|
||||||
|
public void setNodeListId(Long nodeListId) {
|
||||||
|
this.nodeListId = nodeListId;
|
||||||
|
}
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
public void setNodeGroupsId(String nodeGroupsId) {
|
||||||
|
this.nodeGroupsId = nodeGroupsId;
|
||||||
|
}
|
||||||
|
public Long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(Long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
public Long getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
public void setEndTime(Long endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
public Long getIsLoop() {
|
||||||
|
return isLoop;
|
||||||
|
}
|
||||||
|
public void setIsLoop(Long isLoop) {
|
||||||
|
this.isLoop = isLoop;
|
||||||
|
}
|
||||||
|
public Long getLoopDelay() {
|
||||||
|
return loopDelay;
|
||||||
|
}
|
||||||
|
public void setLoopDelay(Long loopDelay) {
|
||||||
|
this.loopDelay = loopDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
181
src/com/nms/server/bean/Task6.java
Normal file
181
src/com/nms/server/bean/Task6.java
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务实体类:6 升级
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Task6 {
|
||||||
|
/**
|
||||||
|
* 任务ID
|
||||||
|
*/
|
||||||
|
private Long taskId;
|
||||||
|
/**
|
||||||
|
* 任务类型:1 文件推送,4 命令执行,5 shell注册,6 升级
|
||||||
|
*/
|
||||||
|
private long taskType;
|
||||||
|
/**
|
||||||
|
* 命令类型:4 Agent原生支持命令
|
||||||
|
*/
|
||||||
|
private long commandType;
|
||||||
|
/**
|
||||||
|
* 命令名称
|
||||||
|
*/
|
||||||
|
private String commandName;
|
||||||
|
/**
|
||||||
|
* 命令参数
|
||||||
|
*/
|
||||||
|
private String commandParam;
|
||||||
|
/**
|
||||||
|
* 执行状态:4下发任务(40 下发成功,41下发失败),5杀进程(50成功,51失败)、6备份、7更新(覆盖) 、8启动进程
|
||||||
|
*/
|
||||||
|
private Long state;
|
||||||
|
/**
|
||||||
|
* 当前版本
|
||||||
|
*/
|
||||||
|
private Long version;
|
||||||
|
/**
|
||||||
|
* 节点组Id(Agent无用)
|
||||||
|
*/
|
||||||
|
private Long nodeListId;
|
||||||
|
private String nodeIpsId;
|
||||||
|
// private Long nodeListId1;
|
||||||
|
private String nodeGroupsId;
|
||||||
|
/**
|
||||||
|
* 升级时间
|
||||||
|
*/
|
||||||
|
private Long upgradeTime;
|
||||||
|
/**
|
||||||
|
* 推送文件名
|
||||||
|
*/
|
||||||
|
private String fileName;
|
||||||
|
/**
|
||||||
|
* 推送目的地
|
||||||
|
*/
|
||||||
|
private String destPath;
|
||||||
|
/**
|
||||||
|
* 推送文件的MD5值
|
||||||
|
*/
|
||||||
|
private String md5Value;
|
||||||
|
/**
|
||||||
|
* 全局权限用户名(未来)
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 全局权限密码(未来 约定加密方式)
|
||||||
|
*/
|
||||||
|
private String userpwd;
|
||||||
|
/**
|
||||||
|
* 重新执行,原任务ID
|
||||||
|
*/
|
||||||
|
private Long oldTaskId;
|
||||||
|
public Long getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
public void setTaskId(Long taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
public long getTaskType() {
|
||||||
|
return taskType;
|
||||||
|
}
|
||||||
|
public void setTaskType(long taskType) {
|
||||||
|
this.taskType = taskType;
|
||||||
|
}
|
||||||
|
public long getCommandType() {
|
||||||
|
return commandType;
|
||||||
|
}
|
||||||
|
public void setCommandType(long commandType) {
|
||||||
|
this.commandType = commandType;
|
||||||
|
}
|
||||||
|
public String getCommandName() {
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
public void setCommandName(String commandName) {
|
||||||
|
this.commandName = commandName;
|
||||||
|
}
|
||||||
|
public String getCommandParam() {
|
||||||
|
return commandParam;
|
||||||
|
}
|
||||||
|
public void setCommandParam(String commandParam) {
|
||||||
|
this.commandParam = commandParam;
|
||||||
|
}
|
||||||
|
public Long getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
public void setState(Long state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
public Long getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
public void setVersion(Long version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
public Long getNodeListId() {
|
||||||
|
return nodeListId;
|
||||||
|
}
|
||||||
|
public void setNodeListId(Long nodeListId) {
|
||||||
|
this.nodeListId = nodeListId;
|
||||||
|
}
|
||||||
|
public Long getUpgradeTime() {
|
||||||
|
return upgradeTime;
|
||||||
|
}
|
||||||
|
public void setUpgradeTime(Long upgradeTime) {
|
||||||
|
this.upgradeTime = upgradeTime;
|
||||||
|
}
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
public String getDestPath() {
|
||||||
|
return destPath;
|
||||||
|
}
|
||||||
|
public void setDestPath(String destPath) {
|
||||||
|
this.destPath = destPath;
|
||||||
|
}
|
||||||
|
public String getMd5Value() {
|
||||||
|
return md5Value;
|
||||||
|
}
|
||||||
|
public void setMd5Value(String md5Value) {
|
||||||
|
this.md5Value = md5Value;
|
||||||
|
}
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
public String getUserpwd() {
|
||||||
|
return userpwd;
|
||||||
|
}
|
||||||
|
public void setUserpwd(String userpwd) {
|
||||||
|
this.userpwd = userpwd;
|
||||||
|
}
|
||||||
|
public Long getOldTaskId() {
|
||||||
|
return oldTaskId;
|
||||||
|
}
|
||||||
|
public void setOldTaskId(Long oldTaskId) {
|
||||||
|
this.oldTaskId = oldTaskId;
|
||||||
|
}
|
||||||
|
public String getNodeGroupsId() {
|
||||||
|
return nodeGroupsId;
|
||||||
|
}
|
||||||
|
public void setNodeGroupsId(String groupsId) {
|
||||||
|
this.nodeGroupsId = groupsId;
|
||||||
|
}
|
||||||
|
// public Long getNodeListId1() {
|
||||||
|
// return nodeListId1;
|
||||||
|
// }
|
||||||
|
// public void setNodeListId1(Long nodeListId1) {
|
||||||
|
// this.nodeListId1 = nodeListId1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
public String getNodeIpsId() {
|
||||||
|
return nodeIpsId;
|
||||||
|
}
|
||||||
|
public void setNodeIpsId(String nodeIpsId) {
|
||||||
|
this.nodeIpsId = nodeIpsId;
|
||||||
|
}
|
||||||
|
}
|
||||||
162
src/com/nms/server/bean/TrapMessageInfo.java
Normal file
162
src/com/nms/server/bean/TrapMessageInfo.java
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
package com.nms.server.bean;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.snmp4j.PDU;
|
||||||
|
import org.snmp4j.smi.Variable;
|
||||||
|
|
||||||
|
public class TrapMessageInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
private String agentSendIP;
|
||||||
|
private String pduAgentIP;
|
||||||
|
private Timestamp receiverTime;
|
||||||
|
private int trapVersion;
|
||||||
|
private int trapV1GenericType;
|
||||||
|
private int trapV1SpecificType;
|
||||||
|
private String trapName;
|
||||||
|
private String trapOID;
|
||||||
|
private List trapPDUOIDs;
|
||||||
|
private List trapPDUOIDValues;
|
||||||
|
private PDU originalPDU;
|
||||||
|
public static final int TrapVersionV1 = 1;
|
||||||
|
public static final int TrapVersionV2 = 2;
|
||||||
|
|
||||||
|
public TrapMessageInfo()
|
||||||
|
{
|
||||||
|
agentSendIP = "";
|
||||||
|
pduAgentIP = "";
|
||||||
|
receiverTime = new Timestamp(System.currentTimeMillis());
|
||||||
|
trapVersion = 1;
|
||||||
|
trapV1GenericType = -1;
|
||||||
|
trapV1SpecificType = -1;
|
||||||
|
trapName = "";
|
||||||
|
trapOID = "";
|
||||||
|
trapPDUOIDs = new ArrayList();
|
||||||
|
trapPDUOIDValues = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Variable getOIDValue(String s)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < trapPDUOIDs.size(); i++)
|
||||||
|
{
|
||||||
|
String s1 = (String)trapPDUOIDs.get(i);
|
||||||
|
if (s.equals(s1))
|
||||||
|
return (Variable)trapPDUOIDValues.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAgentSendIP()
|
||||||
|
{
|
||||||
|
return agentSendIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAgentSendIP(String s)
|
||||||
|
{
|
||||||
|
agentSendIP = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getReceiverTime()
|
||||||
|
{
|
||||||
|
return receiverTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceiverTime(Timestamp timestamp)
|
||||||
|
{
|
||||||
|
receiverTime = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTrapVersion()
|
||||||
|
{
|
||||||
|
return trapVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapVersion(int i)
|
||||||
|
{
|
||||||
|
trapVersion = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrapName()
|
||||||
|
{
|
||||||
|
return trapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapName(String s)
|
||||||
|
{
|
||||||
|
trapName = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrapOID()
|
||||||
|
{
|
||||||
|
return trapOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapOID(String s)
|
||||||
|
{
|
||||||
|
trapOID = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPduAgentIP()
|
||||||
|
{
|
||||||
|
return pduAgentIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPduAgentIP(String s)
|
||||||
|
{
|
||||||
|
pduAgentIP = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTrapV1GenericType()
|
||||||
|
{
|
||||||
|
return trapV1GenericType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapV1GenericType(int i)
|
||||||
|
{
|
||||||
|
trapV1GenericType = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTrapV1SpecificType()
|
||||||
|
{
|
||||||
|
return trapV1SpecificType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapV1SpecificType(int i)
|
||||||
|
{
|
||||||
|
trapV1SpecificType = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getTrapPDUOIDs()
|
||||||
|
{
|
||||||
|
return trapPDUOIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapPDUOIDs(List list)
|
||||||
|
{
|
||||||
|
trapPDUOIDs = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getTrapPDUOIDValues()
|
||||||
|
{
|
||||||
|
return trapPDUOIDValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrapPDUOIDValues(List list)
|
||||||
|
{
|
||||||
|
trapPDUOIDValues = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalPDU(PDU pdu)
|
||||||
|
{
|
||||||
|
originalPDU = pdu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDU getOriginalPDU()
|
||||||
|
{
|
||||||
|
return originalPDU;
|
||||||
|
}
|
||||||
|
}
|
||||||
2798
src/com/nms/server/common/Common.java
Normal file
2798
src/com/nms/server/common/Common.java
Normal file
File diff suppressed because it is too large
Load Diff
68
src/com/nms/server/common/CommonResources.java
Normal file
68
src/com/nms/server/common/CommonResources.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
import java.util.ListResourceBundle;
|
||||||
|
|
||||||
|
public class CommonResources extends ListResourceBundle{
|
||||||
|
static final Object[][] contents = new String[][]{
|
||||||
|
// { "ms_1", "已创建" },
|
||||||
|
// { "ms_2", "进行中" },
|
||||||
|
// { "ms_3", "已完成" },
|
||||||
|
// { "ms_30", "全部成功" },
|
||||||
|
// { "ms_31", "全部失败" },
|
||||||
|
// { "ms_32", "部分成功" },
|
||||||
|
// { "ms_4", "未能执行" },
|
||||||
|
// { "ms_5", "撤销准备" },
|
||||||
|
// { "ms_6", "撤销开始" },
|
||||||
|
// { "ms_7", "撤销完成" },
|
||||||
|
// { "mt_1", "推送文件" },
|
||||||
|
// { "mt_4", "命令执行" },
|
||||||
|
// { "mt_6", "升级部署" },
|
||||||
|
// { "loop_0", "非周期任务" },
|
||||||
|
// { "loop_1", "周期任务" },
|
||||||
|
// { "ec_1", "任务开始下发" },
|
||||||
|
// { "ec_4", "任务开始下发" },
|
||||||
|
// { "ec_6", "任务开始下发"}};
|
||||||
|
|
||||||
|
// { "ms_1", "Created" },
|
||||||
|
// { "ms_2", "In progress" },
|
||||||
|
// { "ms_3", "Completed" },
|
||||||
|
// { "ms_30", "All succeeded" },
|
||||||
|
// { "ms_31", "All failed" },
|
||||||
|
// { "ms_32", "Partially successful" },
|
||||||
|
// { "ms_4", "Failed to execute" },
|
||||||
|
// { "ms_5", "Undo preparation" },
|
||||||
|
// { "ms_6", "Revocation starts" },
|
||||||
|
// { "ms_7", "Undo completed" },
|
||||||
|
// { "mt_1", "Push File" },
|
||||||
|
// { "mt_4", "Command execution" },
|
||||||
|
// { "mt_6", "Upgrade deployment" },
|
||||||
|
// { "loop_0", "Acyclic tasks" },
|
||||||
|
// { "loop_1", "Period tasks" },
|
||||||
|
// { "ec_1", "Mission started" },
|
||||||
|
// { "ec_4", "Mission started" },
|
||||||
|
// { "ec_6", "Mission started"}};
|
||||||
|
|
||||||
|
|
||||||
|
{ "ms_1", "i18n_server.CommonResources.ms_1_n81i" },
|
||||||
|
{ "ms_2", "i18n_server.CommonResources.ms_2_n81i" },
|
||||||
|
{ "ms_3", "i18n_server.CommonResources.ms_3_n81i" },
|
||||||
|
{ "ms_30", "i18n_server.CommonResources.ms_30_n81i" },
|
||||||
|
{ "ms_31", "i18n_server.CommonResources.ms_31_n81i" },
|
||||||
|
{ "ms_32", "i18n_server.CommonResources.ms_32_n81i" },
|
||||||
|
{ "ms_4", "i18n_server.CommonResources.ms_4_n81i" },
|
||||||
|
{ "ms_5", "i18n_server.CommonResources.ms_5_n81i" },
|
||||||
|
{ "ms_6", "i18n_server.CommonResources.ms_6_n81i" },
|
||||||
|
{ "ms_7", "i18n_server.CommonResources.ms_7_n81i" },
|
||||||
|
{ "mt_1", "i18n_server.CommonResources.mt_1_n81i" },
|
||||||
|
{ "mt_4", "i18n_server.CommonResources.mt_4_n81i" },
|
||||||
|
{ "mt_6", "Upgrade deployment" },
|
||||||
|
{ "loop_0", "i18n_server.CommonResources.loop_0_n81i" },
|
||||||
|
{ "loop_1", "i18n_server.CommonResources.loop_1_n81i" },
|
||||||
|
{ "ec_1", "i18n_server.CommonResources.ec_1_n81i" },
|
||||||
|
{ "ec_4", "i18n_server.CommonResources.ec_1_n81i" },
|
||||||
|
{ "ec_6", "i18n_server.CommonResources.ec_1_n81i"}};
|
||||||
|
public Object[][] getContents() {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
159
src/com/nms/server/common/Config.java
Normal file
159
src/com/nms/server/common/Config.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取和保存myconfig信息的类
|
||||||
|
*
|
||||||
|
* @author ZGGG3
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Config {
|
||||||
|
private static Logger logger = Logger.getLogger(Config.class);
|
||||||
|
private static Properties properties;
|
||||||
|
private static String url = null;
|
||||||
|
public static Config config = Config.getInstance();
|
||||||
|
// private static ResourceBundle resource;
|
||||||
|
|
||||||
|
public static String getSystemDir() {
|
||||||
|
return System.getProperty("user.dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单例 初始化获取实例
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Config getInstance() {
|
||||||
|
if (config == null)
|
||||||
|
return new Config();
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单例 重新读取文件已获取参数
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Config reinitialize() {
|
||||||
|
config = null;
|
||||||
|
return new Config();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数私有,用于单例实例
|
||||||
|
*/
|
||||||
|
private Config() {
|
||||||
|
//执行参数更新及检查
|
||||||
|
ConfigUpdate.getInstance();
|
||||||
|
//加载配置文件
|
||||||
|
URL urlObj = Config.class.getClassLoader().getResource("myconfig.properties");
|
||||||
|
// resource = ResourceBundle.getBundle(DefaultConfig.class.getName());
|
||||||
|
if(urlObj==null){
|
||||||
|
// JOptionPane.showMessageDialog(null, "未找到参数配文件!\n请运行"+Constants.COMMON_CONFIG_EXE_NAME+"初始化参数配置", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
JOptionPane.showMessageDialog(null, "Parameter configuration file not found! \nPlease run "+Constants.COMMON_CONFIG_EXE_NAME+"initialization parameter configuration", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
// JOptionPane.showMessageDialog(null, "i18n_server.Config.initConfig_n81i"+Constants.COMMON_CONFIG_EXE_NAME+"i18n_server.Config.initConfig.init_n81i", "i18n_server.Config.error_n81i", JOptionPane.ERROR_MESSAGE);
|
||||||
|
System.exit(0);
|
||||||
|
}else{
|
||||||
|
url = urlObj.getPath().replaceAll("%20", " ");
|
||||||
|
}
|
||||||
|
properties = new Properties();
|
||||||
|
try {
|
||||||
|
properties.load(new FileInputStream(url));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Reading properties file error"+"",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据name获取value
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Boolean getBoolan(String name,Boolean defaultValue) {
|
||||||
|
try {
|
||||||
|
String val = getString(name,defaultValue==null?null:defaultValue.toString());
|
||||||
|
return StringUtils.isEmpty(val)? null : Boolean.valueOf(val);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Digital formatting error", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据name获取value
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Integer getInteger(String name,Integer defaultValue) {
|
||||||
|
try {
|
||||||
|
String val = getString(name,defaultValue==null?null:defaultValue.toString());
|
||||||
|
return StringUtils.isEmpty(val)? null : Integer.parseInt(val);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Digital formatting error", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据name获取value
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getString(String name,String defaultValue) {
|
||||||
|
String str = null;
|
||||||
|
/* 获取参数值:先从资源文件取值,如果为空,则从默认参数配置中取值 */
|
||||||
|
str = properties.getProperty(name,defaultValue);
|
||||||
|
|
||||||
|
if(StringUtils.isNotEmpty(str)){
|
||||||
|
str = str.trim();
|
||||||
|
}else{
|
||||||
|
logger.warn("Resource configuration file abnormality >> "+name+" Value is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向资源配置文件中添加或更新一个键值对
|
||||||
|
*
|
||||||
|
* @time Jul 7, 2011-3:52:45 PM
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public static void setValueByName(String key, String value) {
|
||||||
|
// 添加或更新键值对
|
||||||
|
properties.setProperty(key, value);
|
||||||
|
try {
|
||||||
|
// 保存到文件
|
||||||
|
if (url != null && !"".equals(url)) {
|
||||||
|
String fileName = url.substring(
|
||||||
|
url.lastIndexOf(File.separator), url.length());
|
||||||
|
properties.store(new FileOutputStream(url), fileName);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
logger.error("The properties file Set Value file does not find ERROR "+"",e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Properties file Set Value set value ERROR"+"",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
// 测试主函数
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Config cfg=new Config();
|
||||||
|
String oid="mission.file.download.dir";
|
||||||
|
System.out.println("---------"+cfg.getString(oid));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
264
src/com/nms/server/common/ConfigUpdate.java
Normal file
264
src/com/nms/server/common/ConfigUpdate.java
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取和保存myconfig信息的类
|
||||||
|
*
|
||||||
|
* @author ZGGG3
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConfigUpdate {
|
||||||
|
private static Logger logger = Logger.getLogger(ConfigUpdate.class);
|
||||||
|
private static Properties properties;
|
||||||
|
private static String url = null;
|
||||||
|
public static List<String> proList = new LinkedList<String>();
|
||||||
|
public static ConfigUpdate config = ConfigUpdate.getInstance();
|
||||||
|
private static ResourceBundle resource;
|
||||||
|
/**
|
||||||
|
* 单例 初始化获取实例
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ConfigUpdate getInstance() {
|
||||||
|
if (config == null)
|
||||||
|
return new ConfigUpdate();
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单例 重新读取文件已获取参数
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ConfigUpdate reinitialize() {
|
||||||
|
config = null;
|
||||||
|
return new ConfigUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数私有,用于单例实例
|
||||||
|
*/
|
||||||
|
private ConfigUpdate() {
|
||||||
|
// Thread.currentThread().setName("更新参数");
|
||||||
|
resource = ResourceBundle.getBundle(UpdateParams.class.getName());
|
||||||
|
|
||||||
|
URL urlObj = ConfigUpdate.class.getClassLoader().getResource("myconfig.properties");
|
||||||
|
if(urlObj!= null){
|
||||||
|
url = urlObj.getPath().replaceAll("%20", " ");
|
||||||
|
}else{
|
||||||
|
url = new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath()+"/conf/myconfig.properties";
|
||||||
|
}
|
||||||
|
logger.info("参数文件:"+url);
|
||||||
|
BufferedReader reader = null;
|
||||||
|
FileInputStream fis = null;
|
||||||
|
properties = new Properties();
|
||||||
|
|
||||||
|
try {
|
||||||
|
File file = new File(url).getAbsoluteFile();
|
||||||
|
/*外部资源文件是否已存在*/
|
||||||
|
if(file.exists()){ // 存在 则读取已存在的文件信息 ,将内部资源文件参数更新到外部资源文件中
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
properties.load(fis);
|
||||||
|
|
||||||
|
//判断是否更新properties
|
||||||
|
String updateFlag = properties.getProperty(UpdateParams.CONFIG_UPDATE_FLAG,"-1");
|
||||||
|
if(updateFlag.equals(resource.getString(UpdateParams.CONFIG_UPDATE_FLAG))){ //配置文件已经更新,退出操作
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else{ // 不存在无操作
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新参数
|
||||||
|
/*Enumeration<String> en = resource.getKeys();
|
||||||
|
while (en.hasMoreElements()) {
|
||||||
|
String elem = (String) en.nextElement();
|
||||||
|
String value = properties.getProperty(elem);
|
||||||
|
if(StringUtils.isBlank(value)){
|
||||||
|
properties.setProperty(elem, configRb.getString(elem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
fis.close();
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
reader = new BufferedReader(new InputStreamReader(fis,Charset.forName("utf-8")));
|
||||||
|
String str =null;
|
||||||
|
while((str = reader.readLine() )!=null){
|
||||||
|
proList.add(str);
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Reading properties file error"+"",e);
|
||||||
|
}finally{
|
||||||
|
try {
|
||||||
|
if(reader!= null)reader.close();
|
||||||
|
if(fis!= null)fis.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据name获取value
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Integer getInteger(String name) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(getString(name));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据name获取value
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getString(String name) {
|
||||||
|
String str = null;
|
||||||
|
try {
|
||||||
|
str = properties.getProperty(name);
|
||||||
|
if(StringUtils.isNotEmpty(str)){
|
||||||
|
str = str.trim();
|
||||||
|
}else{
|
||||||
|
logger.warn("Resource configuration file abnormality >> "+name+" Value is empty");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Resource configuration file abnormality", e);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向资源配置文件中添加或更新一个键值对
|
||||||
|
*
|
||||||
|
* @time Jul 7, 2011-3:52:45 PM
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public static void setValueByName(String key, String value) {
|
||||||
|
// 添加或更新键值对
|
||||||
|
String oldValue = properties.getProperty(key);
|
||||||
|
properties.setProperty(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存到文件
|
||||||
|
* @time Jan 6, 2013-1:24:07 PM
|
||||||
|
*/
|
||||||
|
public static void save() {
|
||||||
|
BufferedWriter writer = null;
|
||||||
|
try {
|
||||||
|
//将properties中的值更新到proList中
|
||||||
|
Enumeration<String> en = resource.getKeys();
|
||||||
|
while (en.hasMoreElements()) {
|
||||||
|
String elem = (String) en.nextElement();
|
||||||
|
String value = resource.getString(elem);
|
||||||
|
boolean addFlag = true;
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < proList.size(); i++) {
|
||||||
|
String str = proList.get(i);
|
||||||
|
if(StringUtils.isEmpty(str)){continue;}
|
||||||
|
if(str.split("=", 2)[0].trim().equals(elem)){
|
||||||
|
// str = elem+" = "+value;
|
||||||
|
// proList.set(i, str);
|
||||||
|
addFlag = false;
|
||||||
|
// logger.info("参数更新:"+elem+" = "+(StringUtils.isBlank(value)?"":value));
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(addFlag){
|
||||||
|
proList.add(elem+" = "+value);
|
||||||
|
logger.info("参数新增:"+elem+" = "+(StringUtils.isBlank(value)?"":value));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Properties file Set Value set value ERROR "+elem,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File file = new File(url).getAbsoluteFile();
|
||||||
|
if(!file.exists()){
|
||||||
|
if(!file.getParentFile().exists()){
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
//将文件信息写入到文件中
|
||||||
|
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),Charset.forName("utf-8")));
|
||||||
|
Iterator<String> it = proList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
String elem = (String) it.next();
|
||||||
|
writer.write((elem==null?"":elem)+"\r\n");
|
||||||
|
}
|
||||||
|
writer.flush();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("资源配置文件取值异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally{
|
||||||
|
try {
|
||||||
|
if(writer!= null ){
|
||||||
|
writer.close();
|
||||||
|
writer = null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向资源配置文件host_uuid.properties中更新UUID键值
|
||||||
|
*/
|
||||||
|
/*public static void saveResource(String value) {
|
||||||
|
try {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
if (uuidUrl != null && !"".equals(uuidUrl)) {
|
||||||
|
properties.load(new FileInputStream(uuidUrl));
|
||||||
|
// 添加或更新键值对
|
||||||
|
properties.setProperty(AGENT_HOST_UUID_KEY, value);
|
||||||
|
// 保存到文件
|
||||||
|
properties.store(new FileOutputStream(uuidUrl), "");
|
||||||
|
}
|
||||||
|
properties.clear();
|
||||||
|
|
||||||
|
if(value != null && !"".equals(value)){
|
||||||
|
Contants.AGENT_HOST_UUID = Long.parseLong(value);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/* public static void pl(Object obj){
|
||||||
|
System.out.println(obj==null?null:obj.toString());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/* public static void main(String [] args){
|
||||||
|
// pl(log4jRb.getString("log4j.appender.logfile.File"));
|
||||||
|
// pl(configRb.getString("email.flag"));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
844
src/com/nms/server/common/Constants.java
Normal file
844
src/com/nms/server/common/Constants.java
Normal file
@@ -0,0 +1,844 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import javax.net.ssl.SSLServerSocket;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.util.LocalAddress;
|
||||||
|
import com.zhtelecom.common.snmp.SNMPTarget;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataController 公共常量和配置文件参数信息类
|
||||||
|
* @date Jan 5, 2012 11:38:45 AM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Constants {
|
||||||
|
private static final Logger logger = Logger.getLogger(Constants.class);
|
||||||
|
// private static ResourceBundle resource = ResourceBundle.getBundle(DefaultConfig.class.getName());
|
||||||
|
// #---Common-------
|
||||||
|
/**
|
||||||
|
* DC初始化标识
|
||||||
|
*/
|
||||||
|
public static boolean flag_init = false;
|
||||||
|
/**
|
||||||
|
* 全局 邮件信息保存参数
|
||||||
|
* 1保存 0 不保存 DC端默认为0 缺省配置为1
|
||||||
|
* PS:当同步web端邮件功能配置时,可以创建发送通讯,变更该变量信息
|
||||||
|
*/
|
||||||
|
public static int flag_email = 0; //Email 信息创建标示 1创建 0 不创建 DC端默认为0
|
||||||
|
public static final String ERROR_INFO_RESOVE_MANAGER = "errorInfoResoveManager"; //错误信息解析入库管理线程 标识, futureMap 中的Key值
|
||||||
|
public static final String ERROR_INFO_RESOVE = "errorInfoResove"; //错误信息解析入库操作线程 标识, futureMap 中的Key值
|
||||||
|
public static final Integer ERROR_INFO_RESOVE_PERIOD; //监测数据解析周期(秒)
|
||||||
|
|
||||||
|
public static final String MAILING_MANAGER = "errorInfoResoveManager"; //错误信息解析入库管理线程 标识, futureMap 中的Key值
|
||||||
|
public static final String MAILING_THREAD = "errorInfoResove"; //错误信息解析入库操作线程 标识, futureMap 中的Key值
|
||||||
|
// public static final Integer MAILING_PERIOD; //监测数据解析周期(秒)
|
||||||
|
|
||||||
|
public static final String DETEC_DATA_RESOVE_MANAGER = "detecDataResoveManager";
|
||||||
|
// public static final String DETEC_DATA_COLLECT_MANAGER = "detecDataCollectManager";//DC端主动收集监测数据
|
||||||
|
public static final String DATA_COLLECT_MANAGER = "dataCollectManager";//DC端主动收集数据:监测数据、任务结果、回传文件
|
||||||
|
public static final String ERROR_NODE_DATA_COLLECT_MANAGER = "errorNodeDataCollectManager";//异常节点管理线程
|
||||||
|
public static final String NO_DETECT_DATA_NODE_DATA_COLLECT_MANAGER = "noDetectDataNodeDataCollectManager";//无监测数据节点管理线程
|
||||||
|
public static final String EMAIL_START_THREAD = "emailStartThread";//DC端刷新邮件启动标识线程
|
||||||
|
public static final String NONRLTTASK_RESULT_COLLECT_MANAGER = "nonRltTaskResultCollectManager";//DC端主动收集数据:执行完成,但无任务结果的任务的结果信息
|
||||||
|
public static final String DETEC_DATA_RESOVE = "detecDataResove"; //监测数据解析线程 标识, futureMap 中的Key值
|
||||||
|
public static final String OVERRUN_DATA_RESOVE_MANAGER = "overrunDataResove"; //硬盘数据解析入库管理线程 标识, futureMap 中的Key值
|
||||||
|
|
||||||
|
public static final String OVRERUN_DETEC_DATA_RESOVE = "overrunDetecDataResove"; //硬盘监测数据解析线程 标识, futureMap 中的Key值
|
||||||
|
public static final String OVRERUN_WARNING_DATA_RESOVE = "overrunWarningDataResove"; //硬盘告警数据解析线程 标识, futureMap 中的Key值
|
||||||
|
public static final String OVRERUN_RESULT_DATA_RESOVE = "overrunResultDataResove"; //硬盘任务结果数据解析线程 标识, futureMap 中的Key值
|
||||||
|
|
||||||
|
public static final String DELETE_TMP_FILES_MANAGER = "deteleTmpFilesManager";//删除log等临时文件
|
||||||
|
|
||||||
|
public static final String DETEC_DATA_COLLECT = "detecDataCollect"; //监测数据主动收集线程 标识, futureMap 中的Key值-暂未使用
|
||||||
|
public static final String DATA_COLLECT = "dataCollect"; //监测数据主动收集线程 标识, futureMap 中的Key值
|
||||||
|
public static final String NO_DETECT_DATA_COLLECT = "noDetectDataCollect"; //异常监测数据主动收集线程 标识, futureMap 中的Key值
|
||||||
|
public static final String NONRLTTASK_RESULT_COLLECT = "nonRltTaskResultCollect"; //无任务结果的任务的结果数据的主动收集线程 标识, futureMap 中的Key值
|
||||||
|
public static final String ALARM_DATA_RESOVE_MANAGER = "alarmDataResoveManager";
|
||||||
|
public static final String ALARM_DATA_RESOVE = "alarmDataResove"; //告警数据解析线程 标识, futureMap 中的Key值
|
||||||
|
public static final String MISSION_THREAD = "missionThread";
|
||||||
|
|
||||||
|
public static final String DELETE_TMP_FILES = "deleteTmpFiles"; //删除log等文件线程 标识, futureMap 中的Key值
|
||||||
|
|
||||||
|
public static final String UNZIP_FILE_MANAGER = "unZipFileManager";
|
||||||
|
public static final String UNZIP_FILE = "unZipFile";
|
||||||
|
|
||||||
|
public static final String SUCCESS = "success";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String MISSION_RESULT_RESOVE_MANAGER = "missionResultResoveManager";
|
||||||
|
public static final String MISSION_RESULT_RESOVE = "missionResultResove";
|
||||||
|
public static final String MISSION_FILE_UPLOAD = "missionFileUpload";
|
||||||
|
|
||||||
|
public static final String CHANGE_OPERATIONS_MANAGER = "changeOperationsManager";
|
||||||
|
public static final String CHANGE_OPERATIONS = "changeOperations";
|
||||||
|
|
||||||
|
public static final String DETECTION_INFO_TABLE_NAME = "detection_info_new";//监测数据表名
|
||||||
|
public static final String DETECTION_WARNING_TABLE_NAME = "detection_info_warning";//告警数据表名
|
||||||
|
|
||||||
|
public static final Boolean DETECSELFTHREAD_FLAG ;//DetecSelfThread 开关
|
||||||
|
public static final String DETECTI_SELF_THREAD_NAME = "DetecSelfThread";//监测数据表名
|
||||||
|
public static final Long DETECSELFTHREAD_PERIOD;//监测间隔,单位:秒
|
||||||
|
public static final Long DETECSELFTHREAD_INITIALDELAY;//监测延迟启动时间,单位:秒
|
||||||
|
public static final String DETECTI_DATA_COLLECT_THREAD_NAME = "DetecDataCollectThread";//监测数据收集线程是否正常运行
|
||||||
|
public static final String RESET_SERVER_THREAD_NAME = "ResetServerThread";//告警数据表名
|
||||||
|
|
||||||
|
public static final String DB_CONNECTION_THREAD_NAME = "DbConnectionThreadName";//数据库连接线程名
|
||||||
|
|
||||||
|
public static final String EMAIL_TYPE_IDENTITY = "emailflag";//是否发送邮件的参数配置标识
|
||||||
|
|
||||||
|
// public static final String NO_DETECTDATA_STATUS_INFO = "数据收集超时,未获取监测数据";//DC收集数据,无监测数据时默认的提示信息
|
||||||
|
// public static final String NO_DETECTDATA_STATUS_INFO = "Data collection is out of time and no monitoring data is obtained";//DC收集数据,无监测数据时默认的提示信息
|
||||||
|
public static final String NO_DETECTDATA_STATUS_INFO = "i18n_server.Constants.NO_DETECTDATA_STATUS_INFO_n81i";//DC收集数据,无监测数据时默认的提示信息
|
||||||
|
|
||||||
|
|
||||||
|
// #---Common-------
|
||||||
|
public static final String COMMON_CONFIG_EXE_NAME ; //参数配置程序名称
|
||||||
|
public static final String COMMON_TEXT_CODING ; //公用字符流编码格式
|
||||||
|
public static final String COMMON_DATE_FORMAT; //公用日期格式化标准格式DEFAULT_DATE_FORMAT
|
||||||
|
public static final String COMMON_DATAS_DIR;
|
||||||
|
public static final Integer COMMON_SNMP_VERSION = SNMPTarget.VERSION2C ; //公用字符流编码格式
|
||||||
|
public static final String COMMON_DATA_SPLIT = "\\$@\\$"; //主动告警信息解析标识串-用于分隔字符
|
||||||
|
public static final String COMMON_DATA_POINT = "$@$"; //主动告警信息解析标识串-用于连接字符
|
||||||
|
public static final String COMMON_TEMP_DIR ; //安装程序下临时目录
|
||||||
|
public static final String COMMON_RUNTIME_PID_FILE ; //程序运行时PID文件
|
||||||
|
public static final String SYSTEM_PATH; //DataController应用启动主目录
|
||||||
|
public static final String SYSTEM_INET_ADDRESS;
|
||||||
|
public static final Integer SYSTEM_CLEAR_PERIOD = 24; // [1,99999999]hours 每SYSTEM_CLEAR_PERIOD系统清理一次
|
||||||
|
public static final Integer SYSTEM_CLEAR_TIME = 20; // [00:00:00,24:00:00] 每天某时间(精确到小时),执行系统数据清理
|
||||||
|
public static final Integer MAX_NETWORK_BANDWIDTH; //证书有效期(天)
|
||||||
|
|
||||||
|
// #---Executor /ThreadPool-------
|
||||||
|
public static final Integer EXECUTOR_SOCKET_THREAD_SIZE ; //线程池 通讯线程最大数
|
||||||
|
public static final Integer EXECUTOR_DATA_RESOVE_THREAD_SIZE ;
|
||||||
|
public static final Integer EXECUTOR_SCHEDULED_THREAD_SIZE ; //线程池 周期性线程最大数
|
||||||
|
// #---Change Operations-------
|
||||||
|
public static final Integer CHANGE_OPERATIONS_PERIOD ;
|
||||||
|
public static final Integer CHANGE_RELEASE_SEMAPHORE_MAX ;
|
||||||
|
|
||||||
|
// #---Detection Resolve-------
|
||||||
|
// public static final Integer DETEC_TIMEOUT_ALARM_PERIOD_TIMES; //监测数据告警周期数
|
||||||
|
public static final Integer DETEC_DATA_RESOLVE_PERIOD; //缓存监测数据解析周期(秒)
|
||||||
|
public static final Integer DISK_DATA_RESOLVE_PERIOD; //硬盘监测数据解析周期(秒)
|
||||||
|
public static final int CHECK_DETEC_DATA_OVERRUN = 5; //检查 监测数据量是否过大(导致无法及时、完整的入库) 的次数,即5*DETEC_DATA_RESOLVE_PERIOD
|
||||||
|
public static final int CHECK_WARNING_DATA_OVERRUN = 5; //检查 告警数据量是否过大(导致无法及时、完整的入库) 的次数,即5*告警数据解析周期
|
||||||
|
public static final int CHECK_RESULT_DATA_OVERRUN = 5; //检查 任务结果数据量是否过大(导致无法及时、完整的入库) 的次数,即5*任务结果解析周期
|
||||||
|
|
||||||
|
public static final int REFRESH_EMAIL_FLAG_PEROID = 300; //刷新邮件功能启用标示周期:5分钟
|
||||||
|
// public static final Integer DETEC_DATA_COLLECT_PERIOD; //监测数据主动收集周期
|
||||||
|
public static final Integer DATA_COLLECT_PERIOD; //DC端主动收集数据(监测数据、任务结果、回传文件)周期
|
||||||
|
public static final Integer ERROR_NODE_DATA_COLLECT_PERIOD; //DC端主动收集数据(监测数据、任务结果、回传文件)周期(针对异常节点)
|
||||||
|
public static final Integer DATA_COLLECT_DAILY; //DC端主动收集数据:等待时间
|
||||||
|
public static final Integer ERROR_NODE_DATA_COLLECT_DAILY; //DC端主动收集数据:等待时间(针对问题节点)
|
||||||
|
public static final Integer SINGLE_NODE_DETECT_TIMEOUT; //DC端主动监测,单节点超时时间
|
||||||
|
public static final Integer DETEC_RELEASE_SEMAPHORE_MAX;
|
||||||
|
public static final String DETEC_PING_STR; //ping配置名称 与数据库监测类别表 ping对应 谨慎一致修改
|
||||||
|
public static final String DETEC_NMSC_STR; //NMSClient端通信握手配置名称 与数据库监测类别表 NMSClient对 应谨慎一致修改
|
||||||
|
public static final String DETEC_SNMP_STR;
|
||||||
|
public static final String DETEC_SWITCH_STR;
|
||||||
|
public static final String DETEC_SYSTEMINFO_STR;
|
||||||
|
public static final String DETEC_SYSTEM_STR;
|
||||||
|
public static final String DETEC_SYSTEMDATE_STR;
|
||||||
|
public static final String DETEC_IFXTABLE_STR;
|
||||||
|
|
||||||
|
public static final String ALARM_SNMP_TRAP_STR;
|
||||||
|
|
||||||
|
public static final Integer DELETE_TMP_FILES_PERIOD; //删除log等临时文件的线程执行间隔时间
|
||||||
|
public static final Integer KEEP_FILE_DAYS; //保留log等临时文件的天数
|
||||||
|
|
||||||
|
// #---Alarm Resolve-------
|
||||||
|
public static final Integer ALARM_DATA_RESOLVE_PERIOD; //告警数据解析周期
|
||||||
|
|
||||||
|
public static final Integer NONRLTTASK_RESULT_COLLECT_PERIOD; //DC端主动收集数据(执行完成,但无任务结果的任务的结果信息)周期
|
||||||
|
|
||||||
|
// #---Web-------
|
||||||
|
// public static final String WEB_DOWNLOAD_URL; //NMSWeb 文件下载路径
|
||||||
|
public static final String WEB_SOCKET_IP; //指定非加密通讯通信IP
|
||||||
|
public static final Integer WEB_SOCKET_PORT; //指定非加密通讯通信端口
|
||||||
|
|
||||||
|
// #---Mission Control-------
|
||||||
|
public static final Integer MISSION_FIRST_START = 0;//10; //任务下发线程启动时间 计算式:(agent任务结果上传周期+MISSION_RESULTS_SAVE_PERIOD)/MISSION_RESULTS_SAVE_PERIOD ,取其进1整数*MISSION_RESULTS_SAVE_PERIOD+MISSION_RESULTS_SAVE_START+1
|
||||||
|
public static final Integer MISSION_RESULTS_SAVE_START = 60; //任务结果入库线程启动时间 秒
|
||||||
|
public static final Integer MISSION_RESULTS_SAVE_PERIOD = 120; //任务结果入库线程循环周期 秒
|
||||||
|
public static final Integer MISSION_CHECK_NEW_START = 10;//10; //新任务检查线程启动在first_start之后
|
||||||
|
public static final Integer MISSION_CHECK_NEW_PERIOD = 300; //周期间隔可以稍长
|
||||||
|
public static final Integer TASK_RLT_COLLECT_RESERVED_PERIOD = 600; //任务结果收集估计预留时间,单位秒
|
||||||
|
public static final Integer MISSION_LOOP_PRESET_NUMBER; //周期预置数
|
||||||
|
// public static final String MISSION_LOOP_FINISHING_DAILY; //周期任务 完成状态变更时间(未使用)
|
||||||
|
public static final Integer MISSION_UPGRADE_DAILY; //DataController应用启动主目录
|
||||||
|
|
||||||
|
// #---Mission release-------
|
||||||
|
public static final Integer MISSION_RELEASE_SEMAPHORE_MAX; ////信号计数,每申请一个信号,创建两个线程,一个任务执行线程,一个结果接收线程
|
||||||
|
public static final Integer MISSION_RELEASE_TIMES; //下发任务尝试次数
|
||||||
|
public static final Integer MISSION_RELEASE_PERIOD; //下发任务间隔周期
|
||||||
|
|
||||||
|
// #---Mission File-------
|
||||||
|
public static final String MISSION_FILE_DOWNLOAD_DIR ; //下发任务文件目录(推送文件用)
|
||||||
|
public static final Integer MISSION_FILE_DOWNLOAD_DELAY; //上传最大等待时间(秒)
|
||||||
|
public static final String MISSION_FILE_UPLOAD_DIR ; //上传回传文件目录(推送文件用)
|
||||||
|
public static final Integer MISSION_FILE_UPLOAD_PERIOD; //上传周期(分)
|
||||||
|
|
||||||
|
// #---Email-------
|
||||||
|
// public static final String EMAIL_ADDRESS ;
|
||||||
|
// public static final String EMAIL_USERNAME ;
|
||||||
|
// public static final String EMAIL_PASSWORD;
|
||||||
|
// public static final String EMAIL_HOST ;
|
||||||
|
|
||||||
|
// #---DataBase-------
|
||||||
|
public static final String DB_POOL_TYPE;//连接池类型
|
||||||
|
public static final String DB_DRIVER; //数据库链接驱动
|
||||||
|
public static final String DB_USER_NAME; //数据库链接用户名
|
||||||
|
public static final String DB_PASSWORD; //数据库链接密码
|
||||||
|
public static final String DB_URL; //数据库链接地址
|
||||||
|
public static final String DB_DATE_FORMAT; //数据库日期格式化格式
|
||||||
|
public static final Integer DB_EXECUTE_BATCH; //数据库批处理更新操作单次最大处理量
|
||||||
|
public static final Integer DB_STATEMENT_EXECUTE_TIMEOUT ;
|
||||||
|
public static final Integer DB_POOL_PARTITION_COUNT ; //连接池 设置分区 缺省值 3
|
||||||
|
public static final Integer DB_POOL_CONNECTIONS_PER_PARTITION_MAX; //设置每个分区中的最大连接数 缺省值 30
|
||||||
|
public static final Integer DB_POOL_CONNECTIONS_PER_PARTITION_MIN ; //设置每个分区中的最小连接数 缺省值 10
|
||||||
|
public static final Integer DB_POOL_ACQUIRE_INCREMENT; //当连接池中的连接耗尽的时候 BoneCP一次同时获取的连接数 缺省值3
|
||||||
|
public static final Integer DB_POOL_IDLE_CONNECTION_TEST_PERIOD ; //设置每60秒检查数据库中的空闲连接数 单位 秒 缺省值 60
|
||||||
|
public static final Integer DB_POOL_IDLE_MAX_AGE ; //设置连接空闲时间 单位 分钟 缺省值 240
|
||||||
|
public static final Integer DB_GET_CONNECTION_TIMEOUT ; //设置获取连接超时时间,默认30秒
|
||||||
|
public static final Integer DB_POOL_MAX_CONNECTION_AGE;
|
||||||
|
public static final Integer DB_POOL_RELEASE_HELPER_THREADS ; //连接释放处理 缺省值3
|
||||||
|
public static final Integer DB_POOL_STATEMENT_RELEASE_HELPER_THREADS;
|
||||||
|
public static final Integer DB_POOL_QUERY_EXECUTE_TIME_LIMIT ; //sql执行超时时间
|
||||||
|
public static final boolean DB_POOL_LOG_STATEMENT_ENABLE;
|
||||||
|
// #---DATA-------
|
||||||
|
/*
|
||||||
|
public static final String DATA_DIR; //DataController端未解析数据文件存放目录
|
||||||
|
public static final String DATA_BACKUP_RIGHT_DIR; //DataController端解析正确的数据文件备份目录
|
||||||
|
public static final String DATA_BACKUP_WRONG_DIR; //DataController端解析错误的数据文件备份目录
|
||||||
|
*/
|
||||||
|
// #---ZIP File-------
|
||||||
|
public static final String ZIP_FILE_DETECT_DATA_DIR;
|
||||||
|
public static final String ZIP_FILE_TASK_RESULT_DIR;
|
||||||
|
public static final String ZIP_FILE_TASK_RETURN_DIR;
|
||||||
|
|
||||||
|
// #---ZIP File Resove-------
|
||||||
|
public static final String ZIP_RESOVE_DETECT_DATA_DIR;
|
||||||
|
public static final String ZIP_RESOVE_TASK_RESULT_DIR;
|
||||||
|
public static final String ZIP_RESOVE_TASK_RETURN_DIR;
|
||||||
|
public static final String ERROR_DETEC_FILE_DIR;
|
||||||
|
public static final int ERROR_DETEC_FILE_DIR_FILE_SIZES = 500;
|
||||||
|
public static final String DEFAULT_NODE_GROUP_NAME;
|
||||||
|
|
||||||
|
//20160909 单个节点默认收集后加入监测数据列表的最大监测数据条数,如果一次收集超过设置的条数,则存入dc_overrun/detect/zip_resove中(避免解析时数据过多导致内存溢出)
|
||||||
|
public static final int MAX_COLLECT_RESOVE_DETECT_DATA_NUM;
|
||||||
|
//20160912 内存中监测数据的条数超过MAX_DETECT_DATA_RESOVE_LIMIT_NUM,则不再向内存中添加监测数据,而是暂存硬盘,待之后解析入库,避免内存溢出,默认10万
|
||||||
|
public static final int MAX_DETECT_DATA_RESOVE_LIMIT_NUM;
|
||||||
|
|
||||||
|
// #---overrun detect data file path-------
|
||||||
|
public static final String OVERRUN_DETEC_FILE_DIR;//超出处理能力的监测数据文件存放路径
|
||||||
|
// #---overrun warning data file path-------
|
||||||
|
public static final String OVERRUN_WARNING_FILE_DIR;//超出处理能力的告警数据文件存放路径
|
||||||
|
// #---overrun result data file path-------
|
||||||
|
public static final String OVERRUN_RESULT_FILE_DIR;//超出处理能力的任务结果数据文件存放路径
|
||||||
|
|
||||||
|
// 第三方监测脚本
|
||||||
|
public static final String PLUGIN_SCRIPT_FILE_DIR; // 第三方检测脚本存储路径
|
||||||
|
|
||||||
|
|
||||||
|
// #---SNMP-------
|
||||||
|
public static final Integer SNMP_TRAP_THREAD_POOL_SIZE; //指定SNMP 共同体名称
|
||||||
|
public static final Integer SNMP_CLIENT_PORT; //指定SNMP client get端口
|
||||||
|
public static final Integer SNMP_TRAP_PORT; //指定SNMP trap get端口
|
||||||
|
public static final String SNMP_COMMUNITY; //指定SNMP 共同体名称
|
||||||
|
/* public static final String SNMP_MIB_DIR ; //
|
||||||
|
public static final String SNMP_CLASS_PATH ;
|
||||||
|
public static final String SNMP_CLASS_DIR ;
|
||||||
|
*/
|
||||||
|
public static final String SNMP_CLASS_PACKAGE ;
|
||||||
|
public static final Integer SNMP_V3_SECURITY_LEVEL ; // ##--SNMP 加密认证等级
|
||||||
|
public static final String SNMP_V3_SECURITY_NAME ; // ##--SNMP 加密认证用户 用户名
|
||||||
|
public static final String SNMP_V3_AUTH_PROTOCOL ; // ##--SNMP 认证协议方式
|
||||||
|
public static final String SNMP_V3_PRIV_PROTOCOL ; // ##--SNMP 加密协议方式
|
||||||
|
public static final String SNMP_V3_AUTH_PASSPHRASE ; // ##--SNMP 认证密码明文
|
||||||
|
public static final String SNMP_V3_PRIV_PASSPHRASE ; // ##--SNMP 加密密码明文
|
||||||
|
|
||||||
|
// #---SSL Init-------
|
||||||
|
public static final Integer SSL_SO_TIMEOUT; //SSL加密通信类型
|
||||||
|
public static final String SSL_TYPE; //SSL加密通信类型
|
||||||
|
public static final String SSL_KEYSTORE_TYPE; //SSL加密通信加密密匙库类型
|
||||||
|
public static final Integer SSL_SERVER_PORT; //SSL加密通信接收端口
|
||||||
|
public static final Integer SSL_CLIENT_PORT; //SSL加密通信请求端口
|
||||||
|
public static final String SSL_DIR ; //证书存放目录
|
||||||
|
public static final String SSL_SERVER_EXPORT ; //程序初始化服务端证书导出名称
|
||||||
|
public static final String SSL_CLIENT_EXPORT ; //程序初始化客户端通用证书导出名称
|
||||||
|
|
||||||
|
// public static final String SSL_INIT_SERVER_KEY; //程序初始化服务端证书 (安装时用)
|
||||||
|
// public static final String SSL_INIT_SERVER_KEY_PSW ; //程序初始化服务端证书密码
|
||||||
|
// public static final String SSL_INIT_CLIENT_KEY ; //程序初始化客户端通用证书 (安装时用)
|
||||||
|
// public static final String SSL_INIT_CLIENT_KEY_PSW ; //程序初始化客户端证书密码
|
||||||
|
// #---SSL Server-------
|
||||||
|
public static final String SSL_SERVER_STORE ; //通讯接收端证书密匙库
|
||||||
|
public static final String SSL_CLIENT_STORE ; //通讯请求端证书密匙库
|
||||||
|
public static final String SSL_SERVER_STORE_PSW ; //通讯接收端证书密匙库密码
|
||||||
|
public static final String SSL_SERVER_TRUST; //通讯接收端证书公钥库
|
||||||
|
public static final String SSL_CLIENT_TRUST; //通讯请求端证书公钥库
|
||||||
|
public static final String SSL_SERVER_TRUST_PSW; //通讯接收端证书公钥库密码
|
||||||
|
public static final String SSL_SERVER_KEY_NEW; //通讯接收端新密匙
|
||||||
|
public static final String SSL_SERVER_KEY_NEW_PSW;
|
||||||
|
public static final String SSL_SERVER_KEY_OLD ; //通讯接收端旧密匙
|
||||||
|
public static final String SSL_SERVER_KEY_OLD_PSW; //通讯接收端旧密匙密码
|
||||||
|
public static final String SSL_CLIENT_KEY ; //通讯请求端密匙
|
||||||
|
public static final String SSL_CLIENT_KEY_PSW ; //通讯请求端密匙密码
|
||||||
|
public static final Integer SSL_KEY_VALIDITY; //证书有效期(天)
|
||||||
|
// #---SSL Bat-------
|
||||||
|
// public static final String SSL_BAT_IMPORT ;
|
||||||
|
// public static final String SSL_BAT_GENKEY_EXPORT ;
|
||||||
|
// public static final String SSL_BAT_SERVER_INIT ;
|
||||||
|
|
||||||
|
//监测执行失败时,握手监测-默认的告警级别:0
|
||||||
|
public static final int DETECT_FAIL_NMSC_POLICE_LEVEL;//0
|
||||||
|
//监测执行失败时,握手监测-默认的紧急状态:0紧急
|
||||||
|
public static final int DETECT_FAIL_NMSC_POLICE_EMERGENT;//0
|
||||||
|
//监测执行失败时,非握手监测-默认的告警级别:1级
|
||||||
|
public static final int DETECT_FAIL_NON_NMSC_POLICE_LEVEL;//1
|
||||||
|
//监测执行失败时,非握手监测-默认的紧急状态:非紧急
|
||||||
|
public static final int DETECT_FAIL_NON_NMSC_POLICE_EMERGENT;//1
|
||||||
|
//NC主动告警(默认为紧急),state=-2时,默认的告警级别:0级,
|
||||||
|
public static final String NC_ALARM_POLICE_LEVEL;//1
|
||||||
|
|
||||||
|
/**监测信息状态集合
|
||||||
|
* [0] -2 监测线程异常
|
||||||
|
* [1] -1 监测任务失败
|
||||||
|
* [2] 0 监测信息异常
|
||||||
|
* [3] 1 监测信息正常
|
||||||
|
* [4] 2 监测线程正常
|
||||||
|
* */
|
||||||
|
private static final Integer [] DETECTION_INFO_STATE = new Integer[]{-2,-1,0,1,2};
|
||||||
|
/**监测线程异常 -2*/
|
||||||
|
public static final Integer DETECTION_INFO_ALARM_WRONG = DETECTION_INFO_STATE[1];
|
||||||
|
/**监测线程正常 2*/
|
||||||
|
public static final Integer DETECTION_INFO_ALARM_RIGHT = DETECTION_INFO_STATE[3];
|
||||||
|
/**监测任务失败 -1*/
|
||||||
|
public static final Integer DETECTION_INFO_DETEC_ERROR = DETECTION_INFO_STATE[1];
|
||||||
|
/**监测信息异常 0*/
|
||||||
|
public static final Integer DETECTION_INFO_DETEC_WRONG = DETECTION_INFO_STATE[2];
|
||||||
|
/**监测信息正常 1*/
|
||||||
|
public static final Integer DETECTION_INFO_DETEC_RIGHT = DETECTION_INFO_STATE[3];
|
||||||
|
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
// public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
|
||||||
|
public static final String ERROR_CODE_CREATE_SOCKET= "CreateSocketError";
|
||||||
|
public static final String ERROR_CODE_SOCKET_RUNTIME= "DCSocketRuntimeError";
|
||||||
|
public static final String ERROR_CODE_SOCKET_SERVER_START = "DCSocketServerStartError";
|
||||||
|
public static final String ERROR_CODE_SOCKET_SERVER_RUNTIME = "DCSocketServerRuntimeError";
|
||||||
|
public static final String ERROR_CODE_DB_CONNECT= "DBConnectError";
|
||||||
|
public static final String ERROR_CODE_DATA_COLLECT= "DataCollectError";
|
||||||
|
// public static final String ERROR_DESC_DATA_COLLECT= "数据收集管理线程停止运行";
|
||||||
|
// public static final String ERROR_DESC_DATA_COLLECT= "The data collection management thread stopped running";
|
||||||
|
public static final String ERROR_DESC_DATA_COLLECT= "i18n_server.Constants.ERROR_DESC_DATA_COLLECT_n81i";
|
||||||
|
// public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "数据收集管理线程未启动";
|
||||||
|
// public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "Data Collection Management thread did not start";
|
||||||
|
public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "i18n_server.Constants.ERROR_DESC_DATA_COLLECT_NO_RUN_n81i";
|
||||||
|
|
||||||
|
public static final long ERROR_INFO_SATAE_ERROR = 1;//异常
|
||||||
|
public static final long ERROR_INFO_SATAE_RIGHT = 0;//已解决,手动置为已解决的
|
||||||
|
public static final long ERROR_INFO_SATAE_RIGHT_AUTO = 2;//已恢复,自己恢复的
|
||||||
|
|
||||||
|
public static final int PORT_ALARM_LEVEL;//端口异常,默认的告警级别:5
|
||||||
|
public static final int PORT_ALARM_EMERGENT;//端口异常,默认的紧急状态:1,非紧急
|
||||||
|
|
||||||
|
// #---Test Flag-------
|
||||||
|
public static final Integer FLAG_ZIP;
|
||||||
|
// public static final Integer FLAG_DETEC_TIMEOUT;
|
||||||
|
public static final Integer FLAG_DETEC_RESOVE;
|
||||||
|
public static final Integer FLAG_ERROR_INFO;
|
||||||
|
public static final Integer FLAG_FILES_READER_RESOVE;
|
||||||
|
public static final Integer FLAG_DATA_COLLECT;//数据收集标志(是否启动数据收集管理线程)
|
||||||
|
public static final Integer FLAG_HANDWALK_SSH;//握手时,是否进行ssh判断
|
||||||
|
public static final Integer FLAG_DATA_COLLECT_ONLY_HANDSHAKE;//数据收集线程里只握手,不收集数据
|
||||||
|
public static final Integer FLAG_NONRLTTASK_RESULT_COLLECT;//执行完成,但无任务结果的任务的结果信息的收集标志
|
||||||
|
public static final Integer FLAG_DELETE_TMP_FILES;//删除日志等文件标识
|
||||||
|
public static final Integer FLAG_FILE_UPLOAD;
|
||||||
|
public static final Integer FLAG_CHANGE_OPERATIONS;
|
||||||
|
public static final Integer FLAG_PING;
|
||||||
|
public static final Integer FLAG_NMSC;
|
||||||
|
public static final Integer FLAG_SNMP;
|
||||||
|
public static final Integer FLAG_SWITCH;
|
||||||
|
public static final Integer FLAG_SYSTEMDATE;
|
||||||
|
public static final Integer FLAG_MISSION;
|
||||||
|
public static final Integer FLAG_MISSION_RESULT;
|
||||||
|
/*public static final Integer FLAG_RESOVE_READ_FILE;
|
||||||
|
public static final Integer FLAG_RESOVE_RESOVE_FILE;
|
||||||
|
public static final Integer FLAG_MOVE_FILE;*/
|
||||||
|
public static final Integer FLAG_RESOVE_COMMIT_DB;
|
||||||
|
public static final Integer FLAG_ALARM_RESOVE;
|
||||||
|
public static final Integer FLAG_TRAP;
|
||||||
|
|
||||||
|
public static final Integer FLAG_EMAIL_START;//是否启用邮件发送功能
|
||||||
|
|
||||||
|
|
||||||
|
//20151229 hyx
|
||||||
|
public static final Integer FLAG_DETECT_DATA_SAVE_DISK_RESOVE;//监测数据过多时是否保存硬盘:1保存
|
||||||
|
public static final Integer FLAG_WARN_DATA_SAVE_DISK_RESOVE;//告警数据过多时是否保存硬盘:1保存
|
||||||
|
public static final Integer FLAG_ERROR_DATA_SAVE_DISK_RESOVE;//错误数据过多时是否保存硬盘:1保存
|
||||||
|
public static final Integer FLAG_TASK_RLT_SAVE_DISK_RESOVE;//任务结果过多时是否保存硬盘:1保存
|
||||||
|
|
||||||
|
public static final String OS_WIN = "win";
|
||||||
|
public static final String OS_LINUX = "linux";
|
||||||
|
|
||||||
|
public static SSLServerSocket sslServer = null;
|
||||||
|
|
||||||
|
public static int LEVEL_OF_EMERGENCY = 0;//紧急级别对应的level(0:紧急;1-5:非紧急)
|
||||||
|
|
||||||
|
public static int VARCHAR_MAX_LENGTH = 4000-1;//oracle中varchar2类型的最大长度为4000个字节
|
||||||
|
|
||||||
|
public static Integer DETECTION_INFO_DATA_MAX_ROWS;//监测数据每多少条数据入库一次
|
||||||
|
|
||||||
|
public static int FETCH_SIZE;//如果不设置自动取的是10,当网络情况不好的时候,一次查询的数据较多的时候(批量监测数据入库就会一次查出new表和端口表等的数据,多达几万条),就会多次从数据库取数据,在网络上浪费时间,因此这个值需要设置的大一些,但是这个值设置的越大,占用的内存就越大,所以一般设置50或者100是比较合适的
|
||||||
|
|
||||||
|
public static int SSH_CONNECT_TIMEOUT;
|
||||||
|
|
||||||
|
public static boolean IS_HANDEL_EXCEPTION_NODE = false;//正常收集线程是否处理异常节点的具体异常原因
|
||||||
|
|
||||||
|
|
||||||
|
//批量解析数据限制数量
|
||||||
|
public static final int BATCH_RESOVE_COUNT;
|
||||||
|
// public static final Integer FLAG_TEST;
|
||||||
|
// public static final Integer TEST_COMPUTER;
|
||||||
|
// public static final Integer TEST_SWITCH;
|
||||||
|
//static final 自变量的初始化
|
||||||
|
|
||||||
|
public static final String DB_TYPE;
|
||||||
|
public static final boolean IS_MYSQL;
|
||||||
|
//dc监测数据入库模式,1:由web 主控控制入库,2:自己主动入库,3,智能模式,4,数据上传
|
||||||
|
public static final Integer DETECT_INSERT_MODE;
|
||||||
|
public static final Integer WEB_NOTICE_INSERT_DETECT_OVER_TIMES ;// web通知监测入库超时次数,只有 配置 DETECT_INSERT_MODE = 3 有效
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测数据入库线程模式,1:单线程,2:双线程(info,detail)
|
||||||
|
*/
|
||||||
|
public static final int DETECT_INSERT_THREAD_MODE;
|
||||||
|
/**
|
||||||
|
* INFO入库线程运行模式,1:每隔 N秒 运行一次,2:间隔 N 秒运行一次
|
||||||
|
*/
|
||||||
|
public static final int DETECT_INFO_THREAD_MODE;
|
||||||
|
/**
|
||||||
|
* INFO入库线程 每隔 或间隔 时间 ,单位:S
|
||||||
|
*/
|
||||||
|
public static final int DETECT_INFO_THREAD_TIME;
|
||||||
|
public static final int DETECT_INFO_THREAD_DELAY;
|
||||||
|
/**
|
||||||
|
* DETAIL入库线程运行模式,1:每隔 N秒 运行一次,2:间隔 N 秒运行一次
|
||||||
|
*/
|
||||||
|
public static final int DETECT_DETAIL_THREAD_MODE;
|
||||||
|
/**
|
||||||
|
* DETAIL入库线程 每隔 或间隔 时间 ,单位:S
|
||||||
|
*/
|
||||||
|
public static final int DETECT_DETAIL_THREAD_TIME;
|
||||||
|
public static final int DETECT_DETAIL_THREAD_DELAY;
|
||||||
|
/**
|
||||||
|
* future key
|
||||||
|
*/
|
||||||
|
public static final String DETECT_INFO_THREAD_KEY = "DETECT_INFO_THREAD_KEY" ;
|
||||||
|
public static final String DETECT_DETAIL_THREAD_KEY = "DETECT_DETAIL_THREAD_KEY" ;
|
||||||
|
/**
|
||||||
|
* 监测数据解析线程
|
||||||
|
*/
|
||||||
|
public static final String DETECT_RESOVE_THREAD_KEY = "DETECT_RESOVE_THREAD_KEY" ;
|
||||||
|
|
||||||
|
public static final int NETTY_SERVER_FLAG;
|
||||||
|
public static final int NETTY_SERVER_PORT;
|
||||||
|
public static final boolean NETTY_SERVER_SSL;//是否使用加密通信
|
||||||
|
public static final int NETTY_IDLE_TIME;
|
||||||
|
public static final int NETTY_SO_BACKLOG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器握手监测 周期时间
|
||||||
|
*/
|
||||||
|
public static final int SERVER_NMSC_THREAD_INTERVAL;
|
||||||
|
|
||||||
|
public static final String NEXTVAL_FUNCTION_NAME ;
|
||||||
|
public static final String CURRVAL_FUNCTION_NAME ;
|
||||||
|
|
||||||
|
public static final Long HANDSHANK_DELAY_TIME;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
// InetAddress inetAddress = null;
|
||||||
|
// try {
|
||||||
|
// inetAddress = InetAddress.getLocalHost();
|
||||||
|
// } catch (UnknownHostException e) {
|
||||||
|
// logger.error("LocalHost InetAddress 获取失败",e);
|
||||||
|
// }
|
||||||
|
BATCH_RESOVE_COUNT=Config.getInteger("batch.resove.count",500);
|
||||||
|
// #---Common-------
|
||||||
|
SYSTEM_PATH = formatPath(Config.getSystemDir());
|
||||||
|
COMMON_CONFIG_EXE_NAME = Config.getString("common.config.exe.name","DCConfig.exe");
|
||||||
|
COMMON_TEXT_CODING = Config.getString("common.text.coding","UTF-8");
|
||||||
|
COMMON_DATE_FORMAT = Config.getString("common.date.format","yyyy-MM-dd HH:mm:ss");
|
||||||
|
COMMON_DATAS_DIR = Config.getString("common.datas.dir",SYSTEM_PATH+"/nmsdata");
|
||||||
|
|
||||||
|
COMMON_TEMP_DIR = Config.getString("common.temp.dir","temp");
|
||||||
|
COMMON_RUNTIME_PID_FILE = Config.getString("common.Runtime.pid","DataControllerPid.temp");
|
||||||
|
|
||||||
|
// if(inetAddress!= null){
|
||||||
|
// SYSTEM_INET_ADDRESS = StringUtils.isEmpty(Config.getString("system.inet.address"))
|
||||||
|
// ?inetAddress.getHostAddress().toString()
|
||||||
|
// :Config.getString("system.inet.address");
|
||||||
|
// }else {
|
||||||
|
String localIP = Config.getString("system.inet.address",null);
|
||||||
|
try {
|
||||||
|
String localIP2 = LocalAddress.getRealIp();
|
||||||
|
// if(StringUtils.isEmpty(localIP)){
|
||||||
|
// localIP = localIP2;
|
||||||
|
// logger.warn("配置IP【"+localIP+"】为空 程序获取IP【"+localIP2+"】将使用程序获取IP");
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(!localIP.equals(localIP2)){
|
||||||
|
logger.warn("Local IP exception configuration IP【"+localIP+"】 Program to get IP【"+localIP2+"】 will use the configuration IP");
|
||||||
|
}
|
||||||
|
} catch (SocketException e1) {
|
||||||
|
logger.error("Program gets IP failure", e1);
|
||||||
|
}
|
||||||
|
SYSTEM_INET_ADDRESS = localIP;
|
||||||
|
// }
|
||||||
|
MAX_NETWORK_BANDWIDTH = Config.getInteger("max.network.bandwidth",0);
|
||||||
|
// #---Executor /ThreadPool-------
|
||||||
|
EXECUTOR_SOCKET_THREAD_SIZE = Config.getInteger("executor.socket.thread.size",120);
|
||||||
|
EXECUTOR_SCHEDULED_THREAD_SIZE = Config.getInteger("executor.scheduled.thread.size",30);
|
||||||
|
EXECUTOR_DATA_RESOVE_THREAD_SIZE = Config.getInteger("executor.data.resove.thread.size",3);
|
||||||
|
|
||||||
|
// #---Change Operations-------
|
||||||
|
CHANGE_OPERATIONS_PERIOD = Config.getInteger("change.operations.period",120);
|
||||||
|
CHANGE_RELEASE_SEMAPHORE_MAX = Config.getInteger("change.release.semaphore.max",20);
|
||||||
|
// #---Detection Resolve-------
|
||||||
|
// String outTimes = Config.getString("detec.timeout.alarm.period.times");
|
||||||
|
//
|
||||||
|
// int outT = 1;
|
||||||
|
// if(outTimes != null ){
|
||||||
|
// try {
|
||||||
|
// outT = Integer.parseInt(outTimes);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// logger.error("detec.timeout.alarm.period.times 取值失败",e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// DETEC_TIMEOUT_ALARM_PERIOD_TIMES = Config.getInteger("detec.timeout.alarm.period.times");;
|
||||||
|
DETEC_RELEASE_SEMAPHORE_MAX = Config.getInteger("detec.release.semaphore.max",(int)(EXECUTOR_SOCKET_THREAD_SIZE*0.8));
|
||||||
|
|
||||||
|
DETEC_DATA_RESOLVE_PERIOD = Config.getInteger("detec.data.resovle.period",60);
|
||||||
|
DISK_DATA_RESOLVE_PERIOD = Config.getInteger("disk.data.resovle.period",600);
|
||||||
|
ERROR_INFO_RESOVE_PERIOD = Config.getInteger("error.info.resovle.period",60);
|
||||||
|
// MAILING_PERIOD = Config.getInteger("mailing.period",120);
|
||||||
|
// DETEC_DATA_COLLECT_PERIOD = Config.getInteger("detec.data.collect.period");
|
||||||
|
DATA_COLLECT_PERIOD = Config.getInteger("data.collect.period",300);
|
||||||
|
ERROR_NODE_DATA_COLLECT_PERIOD = Config.getInteger("error.node.data.collect.period",600);
|
||||||
|
NONRLTTASK_RESULT_COLLECT_PERIOD = Config.getInteger("nonRltTask.result.collect.period",600);
|
||||||
|
DETEC_PING_STR = Config.getString("detec.ping.str","ping");
|
||||||
|
DETEC_NMSC_STR = Config.getString("detec.nmsc.str","nmsclient");
|
||||||
|
DETEC_SNMP_STR = Config.getString("detec.snmp.str","SNMP");
|
||||||
|
DETEC_SWITCH_STR = Config.getString("detec.switch.str","switchport");
|
||||||
|
DETEC_SYSTEMINFO_STR = Config.getString("detec.systeminfo.str","systeminfo");
|
||||||
|
DETEC_SYSTEM_STR = Config.getString("detec.system.str","system");
|
||||||
|
DETEC_SYSTEMDATE_STR = Config.getString("detec.systemdate.str","systemdate");
|
||||||
|
DETEC_IFXTABLE_STR = Config.getString("detec.ifxtable.str","ifXTable");
|
||||||
|
DELETE_TMP_FILES_PERIOD = Config.getInteger("delete.files.period",24);
|
||||||
|
KEEP_FILE_DAYS = Config.getInteger("keep.file.days",7);
|
||||||
|
|
||||||
|
ALARM_SNMP_TRAP_STR = Config.getString("alarm.snmp.trap.str","SNMP_TRAP");
|
||||||
|
|
||||||
|
// #---Alarm Resolve-------
|
||||||
|
ALARM_DATA_RESOLVE_PERIOD = Config.getInteger("alarm.data.resovle.period",60);
|
||||||
|
|
||||||
|
// #---Web-------
|
||||||
|
// WEB_DOWNLOAD_URL = formatPath(Config.getValue("web.download.url")); //指定IP通信
|
||||||
|
WEB_SOCKET_IP = Config.getString("web.socket.ip",null); //指定IP通信
|
||||||
|
WEB_SOCKET_PORT = Config.getInteger("web.socket.port",60703) ; //指定IP通信端口
|
||||||
|
|
||||||
|
// #---Mission Control-------
|
||||||
|
MISSION_LOOP_PRESET_NUMBER = Config.getInteger("mission.loop.preset.number",10);
|
||||||
|
// MISSION_LOOP_FINISHING_DAILY = Config.getString("mission.loop.finishing.daily");
|
||||||
|
|
||||||
|
// #---Mission release-------
|
||||||
|
MISSION_RELEASE_SEMAPHORE_MAX = Config.getInteger("mission.release.semaphore.max",(int)(EXECUTOR_SOCKET_THREAD_SIZE*0.3));
|
||||||
|
MISSION_RELEASE_TIMES = Config.getInteger("mission.release.times",3);
|
||||||
|
MISSION_RELEASE_PERIOD = Config.getInteger("mission.release.period",180);
|
||||||
|
|
||||||
|
// #---Mission File-------
|
||||||
|
MISSION_FILE_DOWNLOAD_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("mission.file.download.dir","dc_downLoad"));
|
||||||
|
|
||||||
|
// int downloadDelay = (int)Config.getInteger("mission.file.download.delay");
|
||||||
|
MISSION_FILE_DOWNLOAD_DELAY = Config.getInteger("mission.file.download.delay",60);
|
||||||
|
MISSION_FILE_UPLOAD_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("mission.file.upload.dir","dc_upload"));
|
||||||
|
MISSION_FILE_UPLOAD_PERIOD = Config.getInteger("mission.file.upload.period",120);
|
||||||
|
MISSION_UPGRADE_DAILY = Config.getInteger("mission.update.daily",300);
|
||||||
|
|
||||||
|
// #---Email-------
|
||||||
|
/*
|
||||||
|
FLAG_EMAIL = Config.getInteger("email.flag",0);
|
||||||
|
if(FLAG_EMAIL==1){
|
||||||
|
EMAIL_ADDRESS = Config.getString("email.address");
|
||||||
|
EMAIL_USERNAME = Config.getString("email.userName");
|
||||||
|
EMAIL_PASSWORD = Config.getString("email.password");
|
||||||
|
EMAIL_HOST = Config.getString("email.host");
|
||||||
|
}else{
|
||||||
|
EMAIL_ADDRESS = null;
|
||||||
|
EMAIL_USERNAME = null;
|
||||||
|
EMAIL_PASSWORD = null;
|
||||||
|
EMAIL_HOST = null;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// #---DataBase-------
|
||||||
|
DB_POOL_TYPE = Config.getString("db.pool.type", "bonecp");//默认 bonecp
|
||||||
|
DB_URL = Config.getString("db.url",null);
|
||||||
|
DB_USER_NAME = Config.getString("db.username",null);
|
||||||
|
DB_PASSWORD = Config.getString("db.password",null);
|
||||||
|
DB_DRIVER = Config.getString("db.driver","oracle.jdbc.driver.OracleDriver");
|
||||||
|
DB_DATE_FORMAT = Config.getString("db.date.format","yyyy-MM-dd HH24:mi:ss");
|
||||||
|
DB_EXECUTE_BATCH = Config.getInteger("db.execute.batch",1000);
|
||||||
|
|
||||||
|
// Integer partitionCount = (Integer) resource.getObject("db.pool.partitionCount");
|
||||||
|
DB_STATEMENT_EXECUTE_TIMEOUT = Config.getInteger("db.statement.execute.timeout",60);
|
||||||
|
DB_POOL_PARTITION_COUNT = Config.getInteger("db.pool.partitionCount",3);
|
||||||
|
DB_POOL_CONNECTIONS_PER_PARTITION_MAX = Config.getInteger("db.pool.maxConnectionsPerPartition",5);
|
||||||
|
DB_POOL_CONNECTIONS_PER_PARTITION_MIN = Config.getInteger("db.pool.minConnectionsPerPartition",3);
|
||||||
|
DB_POOL_ACQUIRE_INCREMENT = Config.getInteger("db.pool.acquireIncrement",3);
|
||||||
|
|
||||||
|
DB_POOL_IDLE_CONNECTION_TEST_PERIOD = Config.getInteger("db.pool.idleConnectionTestPeriod",15);
|
||||||
|
DB_POOL_IDLE_MAX_AGE = Config.getInteger("db.pool.idleMaxAge",30);
|
||||||
|
DB_GET_CONNECTION_TIMEOUT = Config.getInteger("db.get.connection.timeout",30);
|
||||||
|
DB_POOL_MAX_CONNECTION_AGE = Config.getInteger("db.pool.max.connection.age",DB_POOL_IDLE_MAX_AGE*2);
|
||||||
|
|
||||||
|
DB_POOL_RELEASE_HELPER_THREADS = Config.getInteger("db.pool.releaseHelperThreads",DB_POOL_PARTITION_COUNT);
|
||||||
|
DB_POOL_STATEMENT_RELEASE_HELPER_THREADS = Config.getInteger("db.pool.statement.releaseHelperThreads",DB_POOL_PARTITION_COUNT);
|
||||||
|
|
||||||
|
DB_POOL_QUERY_EXECUTE_TIME_LIMIT = Config.getInteger("db.pool.queryExecuteTimeLimit",60);
|
||||||
|
|
||||||
|
DB_POOL_LOG_STATEMENT_ENABLE = Config.getBoolan("db.pool.logStatementEnable",true);
|
||||||
|
|
||||||
|
// #---DATA-------
|
||||||
|
/*
|
||||||
|
DATA_DIR = formatPath(Config.getString("data.dir"));
|
||||||
|
DATA_BACKUP_RIGHT_DIR = formatPath(Config.getString("data.backup.right.dir"));
|
||||||
|
DATA_BACKUP_WRONG_DIR = formatPath(Config.getString("data.backup.wrong.dir"));
|
||||||
|
*/
|
||||||
|
// #---ZIP File-------
|
||||||
|
ZIP_FILE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.detect.data.dir","dc_zip/detect"));
|
||||||
|
ZIP_FILE_TASK_RESULT_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.task.result.dir","dc_zip/result"));
|
||||||
|
ZIP_FILE_TASK_RETURN_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.task.return.dir","dc_zip/return"));
|
||||||
|
|
||||||
|
// #---ZIP File Resove-------
|
||||||
|
// ZIP_RESOVE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.detect.data.dir","dc_zip/resove/detect"));
|
||||||
|
ZIP_RESOVE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.detect.data.dir","dc_overrun/detect/zip_resove"));//为了避免因长时间未收集数据,导致一次性收集大量的数据(nc端默认1000csv打包zip,所以如果监测数据打包发送,表明数据较多),如果全部进行解析入库,会导致内存溢出,所以存入dc_overrun等待之后慢慢解析
|
||||||
|
ZIP_RESOVE_TASK_RESULT_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.task.result.dir","dc_zip/resove/result"));
|
||||||
|
ZIP_RESOVE_TASK_RETURN_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.task.return.dir","dc_zip/resove/return"));
|
||||||
|
|
||||||
|
ERROR_DETEC_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("error.detect.file.dir","dc_error/detect"));
|
||||||
|
|
||||||
|
OVERRUN_DETEC_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.detect.file.dir","dc_overrun/detect"));
|
||||||
|
OVERRUN_WARNING_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.warning.file.dir","dc_overrun/warning"));
|
||||||
|
OVERRUN_RESULT_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.result.file.dir","dc_overrun/result"));
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
PLUGIN_SCRIPT_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("detecScript","dc_detecScript"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","默认节点组");
|
||||||
|
// DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","Default Node Group");
|
||||||
|
DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","i18n_server.Constants.defaultNodeGroup_n81i");
|
||||||
|
MAX_COLLECT_RESOVE_DETECT_DATA_NUM = Config.getInteger("max.collect.resove.detect.data.num",60);
|
||||||
|
MAX_DETECT_DATA_RESOVE_LIMIT_NUM = Config.getInteger("max.detect.data.resove.limit.num",60000);
|
||||||
|
|
||||||
|
|
||||||
|
// #---SNMP-------
|
||||||
|
SNMP_CLIENT_PORT = Config.getInteger("snmp.client.port",161);
|
||||||
|
SNMP_TRAP_THREAD_POOL_SIZE = Config.getInteger("snmp.trap.thread.pool.size",10);
|
||||||
|
SNMP_TRAP_PORT = Config.getInteger("snmp.trap.port",162);
|
||||||
|
SNMP_COMMUNITY = Config.getString("snmp.community","public");
|
||||||
|
/*SNMP_MIB_DIR = formatPath(Config.getString("snmp.mib.dir"));
|
||||||
|
SNMP_CLASS_PATH = formatPath(Config.getString("snmp.class.path"));
|
||||||
|
SNMP_CLASS_DIR = SNMP_CLASS_PATH+SNMP_CLASS_PACKAGE.replaceAll("\\.", "/")+"/";*/
|
||||||
|
SNMP_CLASS_PACKAGE = Config.getString("snmp.class.package","osDomains");
|
||||||
|
|
||||||
|
/*##--SNMP 加密认证级别 0 不认证 不加密'zg' 1 认证 不加密'hckings' ,2认证 且 加密'dxy'*/
|
||||||
|
SNMP_V3_SECURITY_LEVEL = Config.getInteger("snmp.v3.security.level",0);
|
||||||
|
SNMP_V3_SECURITY_NAME = Config.getString("snmp.v3.security.name","zg");
|
||||||
|
SNMP_V3_AUTH_PROTOCOL = Config.getString("snmp.v3.auth.protocol","MD5");
|
||||||
|
SNMP_V3_PRIV_PROTOCOL = Config.getString("snmp.v3.priv.protocol","DES");
|
||||||
|
SNMP_V3_AUTH_PASSPHRASE = Config.getString("snmp.v3.auth.passphrase","12345678");
|
||||||
|
SNMP_V3_PRIV_PASSPHRASE = Config.getString("snmp.v3.priv.passphrase","12345678");
|
||||||
|
|
||||||
|
// #---SSL Init-------
|
||||||
|
SSL_SO_TIMEOUT = Config.getInteger("ssl.so.timeout",600);
|
||||||
|
SSL_TYPE = Config.getString("ssl.type","TLS");
|
||||||
|
SSL_DIR = formatPath(Config.getString("ssl.dir","cer"));
|
||||||
|
SSL_SERVER_PORT = Config.getInteger("ssl.server.port",60702);
|
||||||
|
SSL_CLIENT_PORT = Config.getInteger("ssl.client.port",60701);
|
||||||
|
SSL_KEYSTORE_TYPE = Config.getString("ssl.keystore.type","jceks");
|
||||||
|
SSL_SERVER_STORE = Config.getString("ssl.server.store","server_ks");
|
||||||
|
SSL_SERVER_STORE_PSW = Config.getString("ssl.server.store.psw","client");
|
||||||
|
SSL_SERVER_TRUST = Config.getString("ssl.server.trust","server_ts");
|
||||||
|
SSL_SERVER_TRUST_PSW = Config.getString("ssl.server.trust.psw","client");
|
||||||
|
SSL_SERVER_EXPORT = Config.getString("ssl.server.export","server.cer");
|
||||||
|
SSL_CLIENT_EXPORT = Config.getString("ssl.client.export","client.cer");
|
||||||
|
SSL_SERVER_KEY_NEW = Config.getString("ssl.server.key.new","serverks20110828");
|
||||||
|
SSL_SERVER_KEY_OLD = Config.getString("ssl.server.key.old","serverks20110828");
|
||||||
|
SSL_SERVER_KEY_NEW_PSW = Config.getString("ssl.server.key.new.psw","123456");
|
||||||
|
SSL_SERVER_KEY_OLD_PSW = Config.getString("ssl.server.key.old.psw","123456");
|
||||||
|
SSL_CLIENT_KEY = Config.getString("ssl.client.key","serverks20110828");
|
||||||
|
SSL_CLIENT_KEY_PSW = Config.getString("ssl.client.key.psw","123456");
|
||||||
|
SSL_CLIENT_STORE = Config.getString("ssl.client.store","client_ks");
|
||||||
|
SSL_CLIENT_TRUST= Config.getString("ssl.client.trust","client_ts");
|
||||||
|
SSL_KEY_VALIDITY= Config.getInteger("ssl.key.validity",90);
|
||||||
|
|
||||||
|
|
||||||
|
// #---Test Flag-------
|
||||||
|
FLAG_ZIP = Config.getInteger("zip.flag",1);
|
||||||
|
// FLAG_DETEC_TIMEOUT = Config.getInteger("detec.timeout.flag");
|
||||||
|
FLAG_FILE_UPLOAD= Config.getInteger("file.upload.flag",1);
|
||||||
|
FLAG_DETEC_RESOVE= Config.getInteger("file.resove.flag",1);
|
||||||
|
FLAG_ERROR_INFO= Config.getInteger("error.info.flag",1);
|
||||||
|
FLAG_FILES_READER_RESOVE= Config.getInteger("data.files.reader.flag",1);
|
||||||
|
FLAG_DATA_COLLECT= Config.getInteger("data.collect.flag",1);
|
||||||
|
FLAG_HANDWALK_SSH= Config.getInteger("handwalk.ssh.flag",1);
|
||||||
|
FLAG_DATA_COLLECT_ONLY_HANDSHAKE= Config.getInteger("data.collect.flag.only.handshake",1);
|
||||||
|
FLAG_EMAIL_START= Config.getInteger("email.start.flag",1);
|
||||||
|
FLAG_NONRLTTASK_RESULT_COLLECT= Config.getInteger("nonRltTask.result.collect.flag",1);
|
||||||
|
FLAG_DELETE_TMP_FILES= Config.getInteger("delete.files.flag",1);
|
||||||
|
FLAG_CHANGE_OPERATIONS= Config.getInteger("change.operations.flag",1);
|
||||||
|
FLAG_PING= Config.getInteger("ping.flag",1);
|
||||||
|
FLAG_NMSC= Config.getInteger("nmsc.flag",1);
|
||||||
|
FLAG_SNMP= Config.getInteger("snmp.flag",1);
|
||||||
|
FLAG_SWITCH= Config.getInteger("switch.flag",1);
|
||||||
|
FLAG_SYSTEMDATE = Config.getInteger("systemdate.flag",1);
|
||||||
|
|
||||||
|
FLAG_MISSION= Config.getInteger("mission.flag",1);
|
||||||
|
FLAG_MISSION_RESULT= Config.getInteger("result.flag",1);
|
||||||
|
/*FLAG_RESOVE_READ_FILE= Config.getInteger("file.resove.readFile.flag");
|
||||||
|
FLAG_RESOVE_RESOVE_FILE= Config.getInteger("file.resove.resoveFile.flag");
|
||||||
|
FLAG_MOVE_FILE= Config.getInteger("file.moveFile.flag");*/
|
||||||
|
FLAG_RESOVE_COMMIT_DB= Config.getInteger("file.resove.commitDB.flag",1);
|
||||||
|
FLAG_ALARM_RESOVE = Config.getInteger("alarm.resove.flag",1);
|
||||||
|
FLAG_TRAP = Config.getInteger("trap.flag",1);
|
||||||
|
// FLAG_TEST = Config.getInteger("test.flag");
|
||||||
|
// TEST_COMPUTER = Config.getInteger("computer.size");
|
||||||
|
// TEST_SWITCH = Config.getInteger("switch.size");
|
||||||
|
// SSL_INIT_SERVER_KEY = Config.getValue("ssl.init.server.key");
|
||||||
|
// SSL_INIT_CLIENT_KEY = Config.getValue("ssl.init.client.key");
|
||||||
|
// SSL_INIT_SERVER_KEY_PSW = Config.getValue("ssl.init.server.key.psw");
|
||||||
|
// SSL_INIT_CLIENT_KEY_PSW = Config.getValue("ssl.init.client.key.psw");
|
||||||
|
|
||||||
|
// #---SSL Bat-------
|
||||||
|
// SSL_BAT_IMPORT = Config.getValue("ssl.bat.import");
|
||||||
|
// SSL_BAT_GENKEY_EXPORT = Config.getValue("ssl.bat.genkey.export");
|
||||||
|
// SSL_BAT_SERVER_INIT = Config.getValue("ssl.bat.server.init");
|
||||||
|
// SYSTEM_INET_ADDRESS = Common.getLocalIp();
|
||||||
|
|
||||||
|
PORT_ALARM_LEVEL = Config.getInteger("port.alarm.level",5);
|
||||||
|
PORT_ALARM_EMERGENT = Config.getInteger("port.alarm.level",1);
|
||||||
|
|
||||||
|
DETECT_FAIL_NMSC_POLICE_LEVEL = Config.getInteger("detect.fail.nmsc.police.level",0);
|
||||||
|
DETECT_FAIL_NMSC_POLICE_EMERGENT = Config.getInteger("detect.fail.nmsc.police.emergent",0);
|
||||||
|
DETECT_FAIL_NON_NMSC_POLICE_LEVEL = Config.getInteger("detect.fail.non.nmsc.police.level",1);
|
||||||
|
DETECT_FAIL_NON_NMSC_POLICE_EMERGENT = Config.getInteger("detect.fail.non.nmsc.police.emergent",1);
|
||||||
|
NC_ALARM_POLICE_LEVEL = Config.getString("nc.alarm.police.level","0");
|
||||||
|
|
||||||
|
SINGLE_NODE_DETECT_TIMEOUT = Config.getInteger("single.node.detect.timeout", 180);
|
||||||
|
|
||||||
|
VARCHAR_MAX_LENGTH = Config.getInteger("varchar.max.length",4000)-1;
|
||||||
|
|
||||||
|
|
||||||
|
FLAG_DETECT_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.detect.data.save.disk.resove",1);
|
||||||
|
FLAG_WARN_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.warn.data.save.disk.resove",1);
|
||||||
|
FLAG_ERROR_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.error.data.save.disk.resove",1);
|
||||||
|
FLAG_TASK_RLT_SAVE_DISK_RESOVE = Config.getInteger("flag.task.rlt.save.disk.resove",1);
|
||||||
|
|
||||||
|
DETECTION_INFO_DATA_MAX_ROWS = Config.getInteger("detection_info_data_max_rows", 500);
|
||||||
|
FETCH_SIZE = Config.getInteger("fetch.size", 100);
|
||||||
|
DATA_COLLECT_DAILY = Config.getInteger("data.collect.daily", 120);
|
||||||
|
ERROR_NODE_DATA_COLLECT_DAILY = Config.getInteger("error.node.data.collect.daily", 540);
|
||||||
|
|
||||||
|
SSH_CONNECT_TIMEOUT = Config.getInteger("ssh.connect.timeout", 2000);
|
||||||
|
|
||||||
|
IS_HANDEL_EXCEPTION_NODE = Config.getBoolan("is.handel.exception.node", false);
|
||||||
|
/**
|
||||||
|
* 数据库类型
|
||||||
|
*/
|
||||||
|
DB_TYPE = Config.getString("db.type", "oracle");
|
||||||
|
/**
|
||||||
|
* 是否是 mysql 数据库
|
||||||
|
*/
|
||||||
|
IS_MYSQL = "mysql".equalsIgnoreCase(DB_TYPE);
|
||||||
|
/**
|
||||||
|
* //dc监测数据入库模式,1:由web 主控控制入库,2:自己主动入库
|
||||||
|
*/
|
||||||
|
DETECT_INSERT_MODE = Config.getInteger("detect.insert.mode", 2);
|
||||||
|
WEB_NOTICE_INSERT_DETECT_OVER_TIMES = Config.getInteger("web.notice.insert.detect.over.times", 3);
|
||||||
|
|
||||||
|
DETECSELFTHREAD_FLAG = Config.getBoolan("DETECSELFTHREAD_FLAG", true);//DETECSELFTHREAD 开关
|
||||||
|
DETECSELFTHREAD_PERIOD = Long.valueOf(Config.getInteger("DETECSELFTHREAD_PERIOD", 30));//监测间隔,单位:秒
|
||||||
|
DETECSELFTHREAD_INITIALDELAY = Long.valueOf(Config.getInteger("DETECSELFTHREAD_PERIOD", 30));//监测延迟启动时间,单位:秒
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测数据入库线程模式,1:单线程,2:双线程(info,detail)
|
||||||
|
*/
|
||||||
|
DETECT_INSERT_THREAD_MODE = Config.getInteger("detect.insert.thread.mode", 1);
|
||||||
|
/**
|
||||||
|
* INFO入库线程运行模式,1:每隔 N秒 运行一次,2:间隔 N 秒运行一次
|
||||||
|
*/
|
||||||
|
DETECT_INFO_THREAD_MODE = Config.getInteger("detect.info.thread.mode", 1);
|
||||||
|
/**
|
||||||
|
* INFO入库线程 每隔 或间隔 时间 ,单位:S
|
||||||
|
*/
|
||||||
|
DETECT_INFO_THREAD_TIME = Config.getInteger("detect.info.thread.time", 60);
|
||||||
|
DETECT_INFO_THREAD_DELAY = Config.getInteger("detect.INFO.thread.delay", 5);
|
||||||
|
/**
|
||||||
|
* DETAIL入库线程运行模式,1:每隔 N秒 运行一次,2:间隔 N 秒运行一次
|
||||||
|
*/
|
||||||
|
DETECT_DETAIL_THREAD_MODE = Config.getInteger("detect.detail.thread.mode", 1);
|
||||||
|
/**
|
||||||
|
* DETAIL入库线程 每隔 或间隔 时间 ,单位:S
|
||||||
|
*/
|
||||||
|
DETECT_DETAIL_THREAD_TIME = Config.getInteger("detect.detail.thread.time", 60);
|
||||||
|
DETECT_DETAIL_THREAD_DELAY = Config.getInteger("detect.detail.thread.delay", 5);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* netty server
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//0:启用
|
||||||
|
NETTY_SERVER_FLAG = Config.getInteger("netty.server.flag", 1);
|
||||||
|
NETTY_SERVER_PORT = Config.getInteger("netty.server.port", 9527);
|
||||||
|
NETTY_SERVER_SSL = Config.getBoolan("netty.server.ssl", true);
|
||||||
|
NETTY_IDLE_TIME = Config.getInteger("netty.idle.time", 15);
|
||||||
|
NETTY_SO_BACKLOG = Config.getInteger("netty.so.backlog", 6000);
|
||||||
|
SERVER_NMSC_THREAD_INTERVAL = Config.getInteger("server.nmsc.thread.interval", 300);
|
||||||
|
|
||||||
|
NEXTVAL_FUNCTION_NAME = Config.getString("nextval_function_name", "nextval");
|
||||||
|
CURRVAL_FUNCTION_NAME = Config.getString("currval_function_name", "currval");
|
||||||
|
HANDSHANK_DELAY_TIME = Long.parseLong(Config.getString("handshank.delay.time", 15000+""));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//文件传输 临时文件命名后缀
|
||||||
|
public static final String TEMP_SUFFIX = ".tp";
|
||||||
|
|
||||||
|
private static String formatPath(String path){
|
||||||
|
if(StringUtils.isNotEmpty(path)){
|
||||||
|
path = path.replaceAll("\\\\", "/");
|
||||||
|
if(!path.endsWith("/") && !path.endsWith("=")){
|
||||||
|
path = path+"/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/com/nms/server/common/DetectionConstants.java
Normal file
5
src/com/nms/server/common/DetectionConstants.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
public class DetectionConstants {
|
||||||
|
|
||||||
|
}
|
||||||
74
src/com/nms/server/common/EmailTypeConstants.java
Normal file
74
src/com/nms/server/common/EmailTypeConstants.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
public class EmailTypeConstants {
|
||||||
|
// private static final Object[][] type =new Object[][]{
|
||||||
|
// {10,"监测信息恢复"},
|
||||||
|
// {11,"监测信息异常"},
|
||||||
|
// {12,"监测信息超时"},
|
||||||
|
// {20,"主动告警异常"},
|
||||||
|
// {21,"主动告警恢复"},
|
||||||
|
// {31,"节点结果失败"},
|
||||||
|
// {32,"任务状态变更"},
|
||||||
|
// {40,"系统运行异常"},
|
||||||
|
// {41,"系统运行恢复"},
|
||||||
|
// };
|
||||||
|
|
||||||
|
public static final String ERROR_PROCESSS_NOT_EXIST = "ProcessNotExist"; //进程不存在
|
||||||
|
public static final String ERROR_HANDSHAKE = "HandShakeError"; //握手失败
|
||||||
|
public static final String ERROR_THREAD_RUNTIME = "ThreadRuntimeError"; //执行异常
|
||||||
|
public static final String ERROR_PROT_LISTENER = "ProtListenerError"; //端口监听失败
|
||||||
|
public static final String ERROR_DEAMON_NOT_EXIST = "DeamonNotExist"; //守护进程不存在
|
||||||
|
public static final String ERROR_DATA_RESOVE = "DataResoveError"; //数据解析错误
|
||||||
|
public static final String ERROR_SOCKET = "SocketError"; //通讯失败
|
||||||
|
|
||||||
|
// public static final int STATE_OK = 0; //已解决
|
||||||
|
// public static final int STATE_FAIL = 1; //未解决
|
||||||
|
// public static final int STATE_RECOVER = 2; //已恢复
|
||||||
|
|
||||||
|
public static final int FLAG_SEND_LATER = 0;
|
||||||
|
public static final int FLAG_SEND_ALLREADY = 1;
|
||||||
|
public static final int FLAG_SEND_IMMEDIATELY = 2;
|
||||||
|
|
||||||
|
public static final int URGENT_IMMEDIATELY = 0;
|
||||||
|
public static final int URGENT_LATER = 1;
|
||||||
|
|
||||||
|
public static final int TYPE_DETECTION_INFO_RECOVER = 10;
|
||||||
|
// public static final String DESC_DETECTION_INFO_RECOVER = "监测信息恢复";
|
||||||
|
// public static final String DESC_DETECTION_INFO_RECOVER = "Monitoring Information Recovery";
|
||||||
|
public static final String DESC_DETECTION_INFO_RECOVER = "i18n_server.EmailTypeConstants.DESC_DETECTION_INFO_RECOVER_n81i";
|
||||||
|
public static final int TYPE_DETECTION_INFO_EXCEPTION = 11;
|
||||||
|
// public static final String DESC_DETECTION_INFO_EXCEPTION = "监测信息异常";
|
||||||
|
// public static final String DESC_DETECTION_INFO_EXCEPTION = "Monitoring information is abnormal";
|
||||||
|
public static final String DESC_DETECTION_INFO_EXCEPTION = "i18n_server.EmailTypeConstants.DESC_DETECTION_INFO_EXCEPTION_n81i";
|
||||||
|
public static final int TYPE_DETECTION_INFO_TIMEOUT = 12;
|
||||||
|
// public static final String DESC_DETECTION_INFO_TIMEOUT = "监测信息超时";
|
||||||
|
// public static final String DESC_DETECTION_INFO_TIMEOUT = "Monitoring information timeout";
|
||||||
|
public static final String DESC_DETECTION_INFO_TIMEOUT = "i18n_server.EmailTypeConstants.DESC_DETECTION_INFO_TIMEOUT_n81i";
|
||||||
|
|
||||||
|
public static final int TYPE_ALARM_INFO_EXCEPTION = 20;
|
||||||
|
// public static final String DESC_ALARM_INFO_EXCEPTION = "主动告警异常";
|
||||||
|
// public static final String DESC_ALARM_INFO_EXCEPTION = "Active alarm exception";
|
||||||
|
public static final String DESC_ALARM_INFO_EXCEPTION = "i18n_server.EmailTypeConstants.DESC_ALARM_INFO_EXCEPTION_n81i";
|
||||||
|
public static final int TYPE_ALARM_INFO_RECOVER = 21;
|
||||||
|
// public static final String DESC_ALARM_INFO_RECOVER = "主动告警恢复";
|
||||||
|
// public static final String DESC_ALARM_INFO_RECOVER = "Active Alarm Recovery";
|
||||||
|
public static final String DESC_ALARM_INFO_RECOVER = "i18n_server.EmailTypeConstants.DESC_ALARM_INFO_RECOVER_n81i";
|
||||||
|
|
||||||
|
public static final int TYPE_TASK_NODE_RESULT_ERROR = 31;
|
||||||
|
// public static final String DESC_TASK_NODE_RESULT_ERROR = "节点结果失败";
|
||||||
|
// public static final String DESC_TASK_NODE_RESULT_ERROR = "Node result failed";
|
||||||
|
public static final String DESC_TASK_NODE_RESULT_ERROR = "i18n_server.EmailTypeConstants.DESC_TASK_NODE_RESULT_ERROR_n81i";
|
||||||
|
public static final int TYPE_TASK_STATE_CHANGE = 32;
|
||||||
|
// public static final String DESC_TASK_STATE_CHANGE = "任务状态变更";
|
||||||
|
// public static final String DESC_TASK_STATE_CHANGE = "Change of task status";
|
||||||
|
public static final String DESC_TASK_STATE_CHANGE = "i18n_server.EmailTypeConstants.DESC_TASK_STATE_CHANGE_n81i";
|
||||||
|
|
||||||
|
public static final int TYPE_SYSTEM_RUNNING_EXCEPTION = 40;
|
||||||
|
// public static final String DESC_SYSTEM_RUNNING_EXCEPTION = "系统运行异常";
|
||||||
|
// public static final String DESC_SYSTEM_RUNNING_EXCEPTION = "System operation is abnormal";
|
||||||
|
public static final String DESC_SYSTEM_RUNNING_EXCEPTION = "i18n_server.EmailTypeConstants.DESC_SYSTEM_RUNNING_EXCEPTION_n81i";
|
||||||
|
public static final int TYPE_SYSTEM_RUNNING_RECOVER = 41;
|
||||||
|
// public static final String DESC_SYSTEM_RUNNING_RECOVER = "系统运行恢复";
|
||||||
|
// public static final String DESC_SYSTEM_RUNNING_RECOVER = "System Operation Recovery";
|
||||||
|
public static final String DESC_SYSTEM_RUNNING_RECOVER = "i18n_server.EmailTypeConstants.DESC_SYSTEM_RUNNING_RECOVER_n81i";
|
||||||
|
}
|
||||||
33
src/com/nms/server/common/MissionConstants.java
Normal file
33
src/com/nms/server/common/MissionConstants.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
public class MissionConstants {
|
||||||
|
|
||||||
|
public final static int MISSION_STATE_CREATE = 1;
|
||||||
|
public final static int MISSION_STATE_RUNNING_OK = 2;
|
||||||
|
public final static int MISSION_STATE_FINISHING = 3;
|
||||||
|
public final static int MISSION_STATE_RUNNING_FAIL = 4;
|
||||||
|
public final static int MISSION_STATE_CANCEL = 5;
|
||||||
|
public final static int MISSION_STATE_CANCEL_RUNNING_OK = 6;
|
||||||
|
public final static int MISSION_STATE_CANCEL_FINISHING = 7;
|
||||||
|
|
||||||
|
// public final static String ERROR_TASK_PARAMS = "参数错误,任务无法执行;";
|
||||||
|
// public final static String ERROR_TASK_NO_FILE = "无推送文件,任务无法执行;";
|
||||||
|
// public final static String ERROR_TASK_NO_USED_NODE = "无有效服务器节点,任务无法执行;";
|
||||||
|
// public final static String ERROR_TASK_RUND_NO_USED_NODE = "无有效服务器节点,当前周期无法执行;";
|
||||||
|
// public final static String WARN_TASK_UN_MANAGEMENT_NODE = "存在DC管理外节点;";
|
||||||
|
// public final static String NOTICE_TASK_RUNNING = "任务开始执行";
|
||||||
|
// public final static String ERROR_RESULT_NOT_SERVER = "该节点不是服务器";
|
||||||
|
// public final static String ERROR_RESULT_UN_MANAGEMENT_NODE = "该节点不在DC管理范围内";
|
||||||
|
// public final static String ERROR_RESULT_FILE_DOWNLOAD_FAIL = "DC文件下载失败";
|
||||||
|
// public final static String ERROR_RESULT_EXEC_TIMEOUT = "周期任务执行超时,结果置为失败";//endTime<当前时间
|
||||||
|
public final static String ERROR_TASK_PARAMS = "i18n_server.MissionConstants.ERROR_TASK_PARAMS_n81i;";
|
||||||
|
public final static String ERROR_TASK_NO_FILE = "i18n_server.MissionConstants.ERROR_TASK_NO_FILE_n81i;";
|
||||||
|
public final static String ERROR_TASK_NO_USED_NODE = "i18n_server.MissionConstants.ERROR_TASK_NO_USED_NODE_n81i;";
|
||||||
|
public final static String ERROR_TASK_RUND_NO_USED_NODE = "i18n_server.MissionConstants.ERROR_TASK_RUND_NO_USED_NODE_n81i;";
|
||||||
|
public final static String WARN_TASK_UN_MANAGEMENT_NODE = "i18n_server.MissionConstants.WARN_TASK_UN_MANAGEMENT_NODE_n81i;";
|
||||||
|
public final static String NOTICE_TASK_RUNNING = "i18n_server.MissionConstants.NOTICE_TASK_RUNNING_n81i";
|
||||||
|
public final static String ERROR_RESULT_NOT_SERVER = "i18n_server.MissionConstants.ERROR_RESULT_NOT_SERVER_n81i";
|
||||||
|
public final static String ERROR_RESULT_UN_MANAGEMENT_NODE = "i18n_server.MissionConstants.ERROR_RESULT_UN_MANAGEMENT_NODE_n81i";
|
||||||
|
public final static String ERROR_RESULT_FILE_DOWNLOAD_FAIL = "i18n_server.MissionConstants.ERROR_RESULT_FILE_DOWNLOAD_FAIL_n81i";
|
||||||
|
public final static String ERROR_RESULT_EXEC_TIMEOUT = "i18n_server.MissionConstants.ERROR_RESULT_EXEC_TIMEOUT_n81i";//endTime<当前时间
|
||||||
|
}
|
||||||
40
src/com/nms/server/common/UpdateParams.java
Normal file
40
src/com/nms/server/common/UpdateParams.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.nms.server.common;
|
||||||
|
|
||||||
|
public class UpdateParams extends java.util.ListResourceBundle {
|
||||||
|
public static String CONFIG_UPDATE_FLAG = "config.update.flag"; //更新标示 固定 判断配置文件指定值更新 建议自增1操作
|
||||||
|
public static String CONFIG_UPDATE_FLAG_VALUE = "12"; //更新标示 该值 缺省值为0 每次修改都要
|
||||||
|
static final String[][] contents = new String[][]{
|
||||||
|
{CONFIG_UPDATE_FLAG,CONFIG_UPDATE_FLAG_VALUE}, //更新标示 固定 判断配置文件指定值更新 建议自增1操作
|
||||||
|
{"detec.switch.str","switchport"}, // 更新switch 监测类别
|
||||||
|
{"detec.systeminfo.str","systeminfo"}, // 更新systeminfo 监测类别
|
||||||
|
{"detec.systemdate.str","systemdate"}, // 更新systemdate 监测类别
|
||||||
|
{"detec.system.str","system"}, // 更新systeminfo 监测类别
|
||||||
|
{"detec.ifxtable.str","ifXTable"},// 更新ifXTable 监测类别
|
||||||
|
{"error.info.flag","1"}, // 更新systeminfo 监测类别
|
||||||
|
{"data.files.reader.flag","1"}, // 数据保存暂存硬盘标示
|
||||||
|
{"systemdate.flag","1"}, // systemdate主动监测监测标示
|
||||||
|
{"email.start.flag","1"}, // 邮件发送功能启用标识
|
||||||
|
|
||||||
|
{"delete.files.flag","1"}, // delete log/error/download files flag
|
||||||
|
{"keep.file.days","7"}, // keep log/error/download files days
|
||||||
|
{"delete.files.period","24"}, // 删除log等临时文件的时间间隔,unit:hour
|
||||||
|
{"mailing.period","120"}, // 邮件发送周期,unit:S
|
||||||
|
|
||||||
|
//2014-1-2 hyx add
|
||||||
|
{"detect.fail.nmsc.police.level","0"},//握手监测失败时(state=-1),默认的告警级别:0级
|
||||||
|
{"detect.fail.nmsc.police.emergent","0"},//握手监测失败时(state=-1),默认的紧急状态:0紧急;1非紧急
|
||||||
|
{"detect.fail.non.nmsc.police.level","1"},//非握手监测失败时(state=-1),默认的告警级别:1-5级
|
||||||
|
{"detect.fail.non.nmsc.police.emergent","1"},//非握手监测失败时(state=-1),默认的紧急状态:0紧急;1非紧急
|
||||||
|
|
||||||
|
{"port.alarm.level","5"},//端口异常(流量为0,设置状态和实际状态不符)时,默认的告警级别:1-5级
|
||||||
|
{"port.alarm.emergent","1"},//端口异常(流量为0,设置状态和实际状态不符)时,默认的紧急状态:0紧急;1非紧急
|
||||||
|
|
||||||
|
{"nc.alarm.police.level","0"},//NC主动告警(默认为紧急),state=-2时,默认的告警级别:0级
|
||||||
|
{"single.node.detect.timeout","180"}//DC端主动监测,单节点超时时间
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
public Object[][] getContents() {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
254
src/com/nms/server/dao/CommonDao.java
Normal file
254
src/com/nms/server/dao/CommonDao.java
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
package com.nms.server.dao;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.util.ConnectionOracle;
|
||||||
|
import com.nms.server.util.DateUtil;
|
||||||
|
import com.nms.server.util.SQLExecuteTimeoutException;
|
||||||
|
|
||||||
|
public class CommonDao extends ConnectionOracle {
|
||||||
|
|
||||||
|
public CommonDao() throws SQLException {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(CommonDao.class);
|
||||||
|
/**
|
||||||
|
* 插入数据 封装方法
|
||||||
|
*
|
||||||
|
* @time Jul 27, 2011-4:00:44 PM
|
||||||
|
* @param tableName
|
||||||
|
* 插入表 表名
|
||||||
|
* @param info
|
||||||
|
* 字段和值集合
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public boolean insertObj(String tableName, Map<String, String> info)
|
||||||
|
throws SQLExecuteTimeoutException,SQLException {
|
||||||
|
StringBuffer values_0 =new StringBuffer();
|
||||||
|
StringBuffer infoSQL = new StringBuffer("insert into " + tableName
|
||||||
|
+ " ("); // SQL
|
||||||
|
StringBuffer values = new StringBuffer(); // values
|
||||||
|
// SQL拼写
|
||||||
|
Iterator<Entry<String, String>> ite = info.entrySet().iterator();
|
||||||
|
ArrayList<String> params = new ArrayList<String>();
|
||||||
|
|
||||||
|
while (ite.hasNext()) {
|
||||||
|
Entry<String, String> entry = ite.next();
|
||||||
|
//logger.debug(entry.getKey() +": \""+entry.getValue()+"\"" );
|
||||||
|
if (StringUtils.isBlank(entry.getValue()))
|
||||||
|
continue; // 跳过无效数据
|
||||||
|
infoSQL.append(entry.getKey() + ",");
|
||||||
|
params.add(entry.getValue());
|
||||||
|
if (DateUtil.isDate(entry.getValue(), Constants.COMMON_DATE_FORMAT)) { // 日期类型
|
||||||
|
values.append(" to_date(?,'" + Constants.DB_DATE_FORMAT
|
||||||
|
+ "'),");
|
||||||
|
} else { // 其他类型
|
||||||
|
values.append("?,");
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
if (DateUtil.isDate(entry.getValue(), Constants.COMMON_DATE_FORMAT)) { // 日期类型
|
||||||
|
values_0.append(" to_date('"+entry.getValue()+"','" + Constants.DB_DATE_FORMAT
|
||||||
|
+ "'),");
|
||||||
|
} else { // 其他类型
|
||||||
|
values_0.append("'"+entry.getValue()+"',");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
infoSQL = infoSQL.deleteCharAt(infoSQL.length() - 1);
|
||||||
|
values = values.deleteCharAt(values.length() - 1);
|
||||||
|
values_0 = values_0.deleteCharAt(values_0.length() - 1);
|
||||||
|
logger.debug(infoSQL+") values ("+values_0+")");
|
||||||
|
infoSQL.append(") values (" + values + ")");
|
||||||
|
return this.dbUpdate(infoSQL.toString(), params.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入数据 封装方法
|
||||||
|
*
|
||||||
|
* @time Jul 27, 2011-4:00:44 PM
|
||||||
|
* @param tableName
|
||||||
|
* 插入表 表名
|
||||||
|
* @param info
|
||||||
|
* 字段和值集合
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public boolean insertObjByBatch(String tableName, List<Map<String, String>> infoList)
|
||||||
|
throws SQLExecuteTimeoutException,SQLException {
|
||||||
|
if(infoList!=null && infoList.size()>0){
|
||||||
|
List<String> sqList = new LinkedList<String>();
|
||||||
|
for(Map<String, String> info : infoList){
|
||||||
|
StringBuffer values_0 =new StringBuffer();
|
||||||
|
StringBuffer infoSQL = new StringBuffer("insert into " + tableName
|
||||||
|
+ " ("); // SQL
|
||||||
|
// SQL拼写
|
||||||
|
Iterator<Entry<String, String>> ite = info.entrySet().iterator();
|
||||||
|
ArrayList<String> params = new ArrayList<String>();
|
||||||
|
|
||||||
|
while (ite.hasNext()) {
|
||||||
|
Entry<String, String> entry = ite.next();
|
||||||
|
//logger.debug(entry.getKey() +": \""+entry.getValue()+"\"" );
|
||||||
|
if (StringUtils.isBlank(entry.getValue()))
|
||||||
|
continue; // 跳过无效数据
|
||||||
|
infoSQL.append(entry.getKey() + ",");
|
||||||
|
params.add(entry.getValue());
|
||||||
|
|
||||||
|
//--
|
||||||
|
if (DateUtil.isDate(entry.getValue(), Constants.COMMON_DATE_FORMAT)) { // 日期类型
|
||||||
|
values_0
|
||||||
|
.append(" to_date('"+entry.getValue()+"','" + Constants.DB_DATE_FORMAT
|
||||||
|
+ "'),");
|
||||||
|
} else { // 其他类型
|
||||||
|
values_0.append("'"+entry.getValue()+"',");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
infoSQL = infoSQL.deleteCharAt(infoSQL.length() - 1);
|
||||||
|
values_0 = values_0.deleteCharAt(values_0.length() - 1);
|
||||||
|
logger.debug(infoSQL+") values ("+values_0+")");
|
||||||
|
infoSQL.append(") values (" + values_0 + ")");
|
||||||
|
sqList.add(infoSQL.toString());
|
||||||
|
}
|
||||||
|
return this.dbUpdateByBatch(sqList);
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入数据 封装方法
|
||||||
|
*
|
||||||
|
* @time Jul 27, 2011-4:00:44 PM
|
||||||
|
* @param tableName
|
||||||
|
* 插入表 表名
|
||||||
|
* @param info
|
||||||
|
* 字段和值集合
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
/*public boolean insertSimpleObjByBatch(String tableName,List<Map<String, String>> infoList)
|
||||||
|
throws SQLExecuteTimeoutException,SQLException {
|
||||||
|
|
||||||
|
//固定 字段名
|
||||||
|
List<Object> columnList = null;
|
||||||
|
//固定 sql
|
||||||
|
StringBuffer infoSQL = new StringBuffer("insert into " + tableName
|
||||||
|
+ " ("); // SQL
|
||||||
|
StringBuffer values = new StringBuffer(); // values
|
||||||
|
if(infoList!=null && infoList.size()>0){
|
||||||
|
Map<String, String> map = infoList.get(0);
|
||||||
|
|
||||||
|
columnList = Arrays.asList(map.keySet().toArray());
|
||||||
|
|
||||||
|
for(Object obj : columnList){
|
||||||
|
|
||||||
|
if(obj == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = obj.toString();
|
||||||
|
String value = map.get(key);
|
||||||
|
|
||||||
|
logger.debug(key +": \""+value+"\"" );
|
||||||
|
infoSQL.append(key + ",");
|
||||||
|
|
||||||
|
if (DateUtil.isDate(value, Constants.COMMON_DATE_FORMAT)) { // 日期类型
|
||||||
|
values
|
||||||
|
.append(" to_date(?,'" + Constants.DB_DATE_FORMAT
|
||||||
|
+ "'),");
|
||||||
|
} else { // 其他类型
|
||||||
|
values.append("?,");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
infoSQL = infoSQL.deleteCharAt(infoSQL.length() - 1);
|
||||||
|
values = values.deleteCharAt(values.length() - 1);
|
||||||
|
infoSQL.append(") values (" + values + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//整理值
|
||||||
|
if(infoList!=null && infoList.size()>0){
|
||||||
|
List<String[]> paramsList = new LinkedList<String[]>();
|
||||||
|
|
||||||
|
for(Map<String, String> info : infoList){
|
||||||
|
|
||||||
|
for(Object obj : columnList){
|
||||||
|
if(obj == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String> params = new ArrayList<String>();
|
||||||
|
String value = info.get(obj);
|
||||||
|
if(StringUtils.isBlank(value)){
|
||||||
|
params.add("");
|
||||||
|
}else{
|
||||||
|
params.add(info.get(obj));
|
||||||
|
}
|
||||||
|
System.out.println(""+Arrays.toString(params.toArray(new String[0])));
|
||||||
|
paramsList.add(params.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return this.dbUpdateByBatch(infoSQL.toString(),paramsList);
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据 封装方法
|
||||||
|
*
|
||||||
|
* @time Jul 27, 2011-4:08:38 PM
|
||||||
|
* @param attributes
|
||||||
|
* @param fields{
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
/*private ArrayList<Map<String, String>> selectObjs(ArrayList<String> fields,
|
||||||
|
String tableName, Map<String, String> info) throws Exception {
|
||||||
|
StringBuffer seachInfoSQL = new StringBuffer(); // 查询SQL
|
||||||
|
if (fields == null || fields.size() == 0) { // 全部字段查询
|
||||||
|
seachInfoSQL.append("select * from " + tableName + " where 1=1 ");
|
||||||
|
} else { // 指定字段查询
|
||||||
|
seachInfoSQL.append("select ");
|
||||||
|
for (String attribute : fields) {
|
||||||
|
seachInfoSQL.append(attribute + ",");
|
||||||
|
}
|
||||||
|
seachInfoSQL.deleteCharAt(seachInfoSQL.length() - 1);
|
||||||
|
seachInfoSQL.append(" from " + tableName + " where 1=1 ");
|
||||||
|
}
|
||||||
|
// SQL拼写
|
||||||
|
Iterator<Entry<String, String>> ite = info.entrySet().iterator();
|
||||||
|
ArrayList<String> params = new ArrayList<String>();
|
||||||
|
|
||||||
|
while (ite.hasNext()) {
|
||||||
|
Entry<String, String> entry = ite.next();
|
||||||
|
if (StringUtils.isEmpty(entry.getValue()))
|
||||||
|
continue;
|
||||||
|
params.add(entry.getValue());
|
||||||
|
if (Common.isDate(entry.getValue(), Constants.COMMON_DATE_FORMAT)) {
|
||||||
|
seachInfoSQL.append(" and to_char(" + entry.getKey() + ",'"
|
||||||
|
+ Constants.DB_DATE_FORMAT + "') = ?");
|
||||||
|
} else {
|
||||||
|
seachInfoSQL.append(" and " + entry.getKey() + "=?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.dbSelect(seachInfoSQL.toString(), fields, params.toArray());
|
||||||
|
}*/
|
||||||
|
}
|
||||||
473
src/com/nms/server/dao/OracleToMysql.java
Normal file
473
src/com/nms/server/dao/OracleToMysql.java
Normal file
@@ -0,0 +1,473 @@
|
|||||||
|
package com.nms.server.dao;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle 特殊函数 适配 mysql 数据库 sql 转换工具
|
||||||
|
* @author fang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OracleToMysql {
|
||||||
|
static final Logger logger = Logger.getLogger(OracleToMysql.class);
|
||||||
|
/**
|
||||||
|
* decode函数正则匹配,不支持括号嵌套
|
||||||
|
*/
|
||||||
|
static final Pattern DECODE_PATTERN = Pattern.compile("([^\\w]+)decode\\s*\\(([^\\(\\)]*)\\)",Pattern.CASE_INSENSITIVE);
|
||||||
|
/**
|
||||||
|
* nvl函数正则匹配
|
||||||
|
*/
|
||||||
|
static final Pattern NVL_PATTERN = Pattern.compile("[^\\w]+(nvl)\\s*\\(",Pattern.CASE_INSENSITIVE);
|
||||||
|
/**
|
||||||
|
* sysdate
|
||||||
|
*/
|
||||||
|
static final Pattern SYSDATE_PATTERN = Pattern.compile("[^\\w]+(sysdate)[^\\w]+",Pattern.CASE_INSENSITIVE);
|
||||||
|
/**
|
||||||
|
* sysdate-1 oracle 日期加减
|
||||||
|
* ([^\\w]+)(sysdate\\s*([-+])\\s*(\\w+))([^\\w]+)
|
||||||
|
*/
|
||||||
|
static final Pattern DATE_CAL_PATTERN = Pattern.compile("([^\\w]+)(sysdate\\s*([-+])\\s*([0-9/]+))([^\\w]+|$)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nextval
|
||||||
|
*/
|
||||||
|
static final Pattern NEXTVAL_PATTERN = Pattern.compile("([^\\w]+)([\\w]+)\\s*\\.\\s*nextval([^\\w]+)",Pattern.CASE_INSENSITIVE);
|
||||||
|
/**
|
||||||
|
* currval
|
||||||
|
*/
|
||||||
|
static final Pattern CURRVAL_PATTERN = Pattern.compile("([^\\w]+)([\\w]+)\\s*\\.\\s*currval([^\\w]+)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to_date
|
||||||
|
*/
|
||||||
|
static final Pattern TO_DATE_PATTERN = Pattern.compile("([\\W])to_date\\s*\\(([^\\)]+),([^\\)]+)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to_char
|
||||||
|
*/
|
||||||
|
static final Pattern TO_CHAR_PATTERN = Pattern.compile("([\\W])to_char\\s*\\(([^\\)]+),([^\\)]+)",Pattern.CASE_INSENSITIVE);
|
||||||
|
/**
|
||||||
|
* 数字 转字符
|
||||||
|
*/
|
||||||
|
static final Pattern TO_CHAR_CAST_PATTERN = Pattern.compile("([\\W])to_char\\s*\\(([^\\),]+)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trunc 函数截取日期 只匹配 sysdate 转换成 date_add 的语句
|
||||||
|
*/
|
||||||
|
static final Pattern TRUNC_DATE_PATTERN = Pattern.compile("[^\\w]+(trunc)\\s*\\(\\s*date_add",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* instr函数
|
||||||
|
*/
|
||||||
|
static final Pattern INSTR_PATTERN = Pattern.compile("([^\\w]+)(instr)\\s*\\(([^\\)]+)\\)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* where 条件中的rownum
|
||||||
|
*/
|
||||||
|
//static final Pattern WHERE_ROWNUM_PATTERN = Pattern.compile("([^\\w]+)where([^\\)]+)rownum\\s*(<?=?)\\s*(\\d+)([^\\)]*)",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有些函数参数会出现如下情况 '1,' ,无法正常通过逗号分割
|
||||||
|
*/
|
||||||
|
static final Pattern DYH_PATTERN = Pattern.compile("('.+')",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static final LinkedHashMap<String, String> DATEFORMAT_MAPPING = new LinkedHashMap<String, String>();
|
||||||
|
static{
|
||||||
|
/*DATEFORMAT_MAPPING.put("","%a");//工作日的缩写名称 (Sun..Sat)
|
||||||
|
DATEFORMAT_MAPPING.put("","%b");//月份的缩写名称 (Jan..Dec)
|
||||||
|
DATEFORMAT_MAPPING.put("","%c");//月份,数字形式(0..12)
|
||||||
|
DATEFORMAT_MAPPING.put("","%D");//带有英语后缀的该月日期 (0th, 1st, 2nd, 3rd, ...)
|
||||||
|
DATEFORMAT_MAPPING.put("","%d");//该月日期, 数字形式 (00..31)
|
||||||
|
DATEFORMAT_MAPPING.put("","%e");//该月日期, 数字形式(0..31)
|
||||||
|
DATEFORMAT_MAPPING.put("","%f");//微秒 (000000..999999)
|
||||||
|
DATEFORMAT_MAPPING.put("","%H");//小时(00..23)
|
||||||
|
DATEFORMAT_MAPPING.put("","%h");//小时(01..12)
|
||||||
|
DATEFORMAT_MAPPING.put("","%I");//小时 (01..12)
|
||||||
|
DATEFORMAT_MAPPING.put("","%i");//分钟,数字形式 (00..59)
|
||||||
|
DATEFORMAT_MAPPING.put("","%j");//一年中的天数 (001..366)
|
||||||
|
DATEFORMAT_MAPPING.put("","%k");//小时 (0..23)
|
||||||
|
DATEFORMAT_MAPPING.put("","%l");//小时 (1..12)
|
||||||
|
DATEFORMAT_MAPPING.put("","%M");//月份名称 (January..December)
|
||||||
|
DATEFORMAT_MAPPING.put("","%m");//月份, 数字形式 (00..12)
|
||||||
|
DATEFORMAT_MAPPING.put("","%p");//上午(AM)或下午( PM)
|
||||||
|
DATEFORMAT_MAPPING.put("","%r");//时间 , 12小时制 (小时hh:分钟mm:秒数ss 后加 AM或PM)
|
||||||
|
DATEFORMAT_MAPPING.put("","%S");//秒 (00..59)
|
||||||
|
DATEFORMAT_MAPPING.put("","%s");//秒 (00..59)
|
||||||
|
DATEFORMAT_MAPPING.put("","%T");//时间 , 24小时制 (小时hh:分钟mm:秒数ss)
|
||||||
|
DATEFORMAT_MAPPING.put("","%U");//周 (00..53), 其中周日为每周的第一天
|
||||||
|
DATEFORMAT_MAPPING.put("","%u");//周 (00..53), 其中周一为每周的第一天
|
||||||
|
DATEFORMAT_MAPPING.put("","%V");//周 (01..53), 其中周日为每周的第一天 ; 和 %X同时使用
|
||||||
|
DATEFORMAT_MAPPING.put("","%v");//周 (01..53), 其中周一为每周的第一天 ; 和 %x同时使用
|
||||||
|
DATEFORMAT_MAPPING.put("","%W");//工作日名称 (周日..周六)
|
||||||
|
DATEFORMAT_MAPPING.put("","%w");//一周中的每日 (0=周日..6=周六)
|
||||||
|
DATEFORMAT_MAPPING.put("","%X");//该周的年份,其中周日为每周的第一天, 数字形式,4位数;和%V同时使用
|
||||||
|
DATEFORMAT_MAPPING.put("","%x");//该周的年份,其中周一为每周的第一天, 数字形式,4位数;和%v同时使用
|
||||||
|
DATEFORMAT_MAPPING.put("","%Y");//年份, 数字形式,4位数
|
||||||
|
DATEFORMAT_MAPPING.put("","%y");//年份, 数字形式 (2位数)
|
||||||
|
*/
|
||||||
|
DATEFORMAT_MAPPING.put("YYYY-MM-DD HH24:MI:SS","%Y-%m-%d %H:%i:%s");
|
||||||
|
DATEFORMAT_MAPPING.put("YYYY-MM-DD HH24:MI","%Y-%m-%d %H:%i");
|
||||||
|
DATEFORMAT_MAPPING.put("YYYY-MM-DD","%Y-%m-%d");
|
||||||
|
DATEFORMAT_MAPPING.put("HH24:MI:SS","%H:%i:%s");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle sql 转换 成 mysql
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String trans(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
logger.debug("before sql -> :" + sql);
|
||||||
|
if(Constants.IS_MYSQL){
|
||||||
|
sql = decodeToCaseWhen(sql);
|
||||||
|
sql = nextvalToFunction(sql);
|
||||||
|
sql = currvalToFunction(sql);
|
||||||
|
sql = toCharToDateFormat(sql);
|
||||||
|
sql = toDateToStrtodate(sql);
|
||||||
|
sql = nvlToIfnull(sql);
|
||||||
|
sql = sysdateCal(sql);
|
||||||
|
sql = sysdateToNow(sql);
|
||||||
|
sql = truncSysdate(sql);
|
||||||
|
//sql = instr(sql); //@2018年4月19日15:46:47 直接修改 sql 语句,将 第3,4个参数删除,都是默认 :1
|
||||||
|
sql = toChar(sql);
|
||||||
|
logger.debug("after sql -> :" + sql);
|
||||||
|
}
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle decode函数 转换为 case when 语句
|
||||||
|
* @param decode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String decodeToCaseWhen(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = DECODE_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
String group = m.group(2);
|
||||||
|
String[] split = group.split(",");
|
||||||
|
int len = split.length;
|
||||||
|
StringBuilder caseWhen = new StringBuilder(m.group(1));
|
||||||
|
caseWhen.append(" ( case ");
|
||||||
|
caseWhen.append(split[0]);
|
||||||
|
for(int i = 1;i<len-1;i=i+2){
|
||||||
|
caseWhen.append(" when ");
|
||||||
|
caseWhen.append(split[i]);
|
||||||
|
caseWhen.append(" then ");
|
||||||
|
caseWhen.append(split[i+1]);
|
||||||
|
}
|
||||||
|
if(len%2 == 0){
|
||||||
|
caseWhen.append(" else ");
|
||||||
|
caseWhen.append(split[len-1]);
|
||||||
|
}
|
||||||
|
caseWhen.append(" end ) ");
|
||||||
|
logger.debug(m.group() +" --> "+caseWhen.toString());
|
||||||
|
m.appendReplacement(sb, caseWhen.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle nvl 转成 mysql ifNull
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String nvlToIfnull(String sql){
|
||||||
|
return regexReplace(sql, NVL_PATTERN, "IFNULL" ,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysdate 转成 now()
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String sysdateToNow(String sql){
|
||||||
|
return regexReplace(sql, SYSDATE_PATTERN, "now()" ,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trunc 函数截取日期 只匹配 sysdate 转换成 date_add 的语句
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String truncSysdate(String sql){
|
||||||
|
return regexReplace(sql, TRUNC_DATE_PATTERN, "date" ,1);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* sysdate 日期加减
|
||||||
|
* ([^\\w]+)(sysdate\\s*([-+])\\s*((\\d+/)*\\d+))([^\\w]+)
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String sysdateCal(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = DATE_CAL_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String signal = m.group(3);//signal - +
|
||||||
|
String number = m.group(4);// \\d+
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append("date_add(now(),interval ");
|
||||||
|
temp.append(signal);
|
||||||
|
temp.append(number);
|
||||||
|
temp.append("*24*60*60 second)");
|
||||||
|
temp.append(m.group(5));
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle 序列 转成 mysql 自定义函数 nextval('')
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String nextvalToFunction(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = NEXTVAL_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String seqName = m.group(2);//seq name
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append(Constants.NEXTVAL_FUNCTION_NAME);
|
||||||
|
temp.append("('");
|
||||||
|
temp.append(seqName);
|
||||||
|
temp.append("')");
|
||||||
|
temp.append(m.group(3));
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle 序列 转成 mysql 自定义函数 currval('')
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String currvalToFunction(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = CURRVAL_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String seqName = m.group(2);//seq name
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append(Constants.CURRVAL_FUNCTION_NAME);
|
||||||
|
temp.append("('");
|
||||||
|
temp.append(seqName);
|
||||||
|
temp.append("')");
|
||||||
|
temp.append(m.group(3));
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle to_date 函数 转换为 str_to_date
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String toDateToStrtodate(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = TO_DATE_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String fm = m.group(3);//seq name
|
||||||
|
String mfm = DATEFORMAT_MAPPING.get(fm.replaceAll("'", "").trim().toUpperCase());
|
||||||
|
// Objects.requireNonNull(mfm, fm + " 没有mysql格式化映射");
|
||||||
|
Objects.requireNonNull(mfm, fm + " No MySQL formatting mappings");
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append("str_to_date(");
|
||||||
|
temp.append(m.group(2));
|
||||||
|
temp.append(",'");
|
||||||
|
temp.append(mfm);
|
||||||
|
temp.append("'");
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oracle to_char 函数 转换为 date_format
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String toCharToDateFormat(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = TO_CHAR_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String fm = m.group(3);//seq name
|
||||||
|
String mfm = DATEFORMAT_MAPPING.get(fm.replaceAll("'", "").trim().toUpperCase());
|
||||||
|
// Objects.requireNonNull(mfm, m.group() + " 没有mysql格式化映射");
|
||||||
|
Objects.requireNonNull(mfm, m.group() + " No MySQL formatting mappings");
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append("date_format(");
|
||||||
|
temp.append(m.group(2));
|
||||||
|
temp.append(",'");
|
||||||
|
temp.append(mfm);
|
||||||
|
temp.append("'");
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字转字符,只匹配 to_char 有一个参数的
|
||||||
|
* ([\\W]+)to_char\\s*\\(([^\\),]+))
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String toChar(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = TO_CHAR_CAST_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append(" convert(");
|
||||||
|
temp.append(m.group(2));
|
||||||
|
temp.append(" , CHAR ");
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* instr mysql 只有两个参数
|
||||||
|
* 查遍所有 instr 函数,第三四个参数都为 1可以省略,若不为 1 则不能使用此函数
|
||||||
|
* ([^\\w]+)(instr)\\s*\\(([^\\)]+)\\)
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String instr(String sql){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = INSTR_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String param = m.group(3);//seq name
|
||||||
|
Matcher dyh = DYH_PATTERN.matcher(param);
|
||||||
|
StringBuffer ss = new StringBuffer();
|
||||||
|
while(dyh.find()){
|
||||||
|
String group = dyh.group(1);
|
||||||
|
group = group.replaceAll(",", "@@@");
|
||||||
|
dyh.appendReplacement(ss, group);
|
||||||
|
}
|
||||||
|
dyh.appendTail(ss);
|
||||||
|
String[] params = ss.toString().split(",");
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append("instr(");
|
||||||
|
temp.append(params[0].replaceAll("@@@", ","));
|
||||||
|
temp.append(",");
|
||||||
|
temp.append(params[1].replaceAll("@@@", ","));
|
||||||
|
temp.append(")");
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换 rownum -> limit
|
||||||
|
* ([^\\w]+)where([^\\)]+)rownum\\s*(<?=?)\\s*(\\d+)([^\\)]*)
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
/*public static String whereRownum(String sql){
|
||||||
|
Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Matcher m = WHERE_ROWNUM_PATTERN.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
StringBuilder temp = new StringBuilder();
|
||||||
|
String signal = m.group(3);
|
||||||
|
int num = Integer.valueOf(m.group(4).trim());
|
||||||
|
if(!signal.contains("=")){
|
||||||
|
num = num -1;
|
||||||
|
}
|
||||||
|
temp.append(m.group(1));
|
||||||
|
temp.append("where");
|
||||||
|
temp.append(m.group(2));
|
||||||
|
temp.append(" 1=1 ");
|
||||||
|
temp.append(m.group(5));
|
||||||
|
temp.append(" limit ");
|
||||||
|
temp.append(num);
|
||||||
|
logger.debug(m.group() +" --> "+temp.toString());
|
||||||
|
m.appendReplacement(sb, temp.toString());
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正则替换
|
||||||
|
* @param sql
|
||||||
|
* @param p
|
||||||
|
* @param replace
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String regexReplace(String sql,Pattern p,String replace,Integer groupNum){
|
||||||
|
// Objects.requireNonNull(sql, "sql语句不能为空");
|
||||||
|
Objects.requireNonNull(sql, "The SQL statement cannot be empty");
|
||||||
|
Matcher m = p.matcher(sql);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while(m.find()){
|
||||||
|
String group = m.group();
|
||||||
|
if(groupNum != null && groupNum > 0){
|
||||||
|
String gn = m.group(groupNum);
|
||||||
|
group = group.replace(gn, replace);
|
||||||
|
}
|
||||||
|
logger.debug(m.group() +" --> "+group);
|
||||||
|
m.appendReplacement(sb, group);
|
||||||
|
}
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String sql = "delete event_record_library where create_time < sysdate-4 and sysdate -4 > now()";
|
||||||
|
sql = trans(sql);
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
290
src/com/nms/server/service/ChangeService.java
Normal file
290
src/com/nms/server/service/ChangeService.java
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
package com.nms.server.service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.bean.EventRecordLibrary;
|
||||||
|
import com.nms.server.bean.ServerIpSegment;
|
||||||
|
import com.nms.server.bean.ServerTable;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>变更操作</p>
|
||||||
|
* <p>针对操作变更未及时下发到指定Client,而进行的后续操作</p>
|
||||||
|
* @date Mar 6, 2012 8:33:40 AM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ChangeService extends CommonService{
|
||||||
|
private Logger logger = Logger.getLogger(ChangeService.class);
|
||||||
|
public ChangeService(CommonDao dao){
|
||||||
|
super(dao);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EventRecordLibrary> getNewEventRecordList() {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(Constants.COMMON_DATE_FORMAT);
|
||||||
|
List<EventRecordLibrary> erlList = new LinkedList<EventRecordLibrary>();
|
||||||
|
|
||||||
|
StringBuffer sql = new StringBuffer();
|
||||||
|
sql.append("select ");
|
||||||
|
sql.append("erl.id, ");
|
||||||
|
sql.append("erl.record_type, ");
|
||||||
|
sql.append("erl.record_content, ");
|
||||||
|
sql.append("erl.seq_ids, ");
|
||||||
|
sql.append("erl.record_command, ");
|
||||||
|
sql.append("to_char(erl.create_time,'"+Constants.DB_DATE_FORMAT+"') create_time, ");
|
||||||
|
sql.append("erl.state ");
|
||||||
|
sql.append("from event_record_library erl ");
|
||||||
|
sql.append("where erl.state = 1 ");
|
||||||
|
sql.append("and erl.NMSSERVER_ID = "+Common.getServerTable().getId());
|
||||||
|
sql.append(" order by erl.create_time asc");
|
||||||
|
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("id");
|
||||||
|
fields.add("state");
|
||||||
|
fields.add("record_type");
|
||||||
|
fields.add("record_command");
|
||||||
|
fields.add("record_content");
|
||||||
|
fields.add("seq_ids");
|
||||||
|
fields.add("create_time");
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Map<String, String>> maps = dao.dbSelect(sql.toString(), fields);
|
||||||
|
if (maps!=null && maps.size()>0) {
|
||||||
|
for (Map<String, String> map : maps) {
|
||||||
|
EventRecordLibrary erl = new EventRecordLibrary();
|
||||||
|
erl.setId(StringUtils.isEmpty(map.get("id"))?null:Long.parseLong(map.get("id")));
|
||||||
|
erl.setState(StringUtils.isEmpty(map.get("state"))?null:Long.parseLong(map.get("state")));
|
||||||
|
erl.setRecordType(map.get("record_type"));
|
||||||
|
erl.setRecordCommand(map.get("record_command"));
|
||||||
|
erl.setRecordContent(map.get("record_content"));
|
||||||
|
erl.setSeqId(StringUtils.isEmpty(map.get("seq_ids"))?null:Long.parseLong(map.get("seq_ids")));
|
||||||
|
erl.setCreateTime(StringUtils.isEmpty(map.get("create_time"))?null:format.parse(map.get("create_time")));
|
||||||
|
erlList.add(erl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("EventRecordLibrary encapsulates ERROR",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
return erlList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveEventRecordLibrary(String cmd,String seq_id,String type, String content) {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(Constants.COMMON_DATE_FORMAT);
|
||||||
|
try {
|
||||||
|
Map<String, String> library = new HashMap<String, String>();
|
||||||
|
library.put("record_command", cmd);
|
||||||
|
library.put("record_content", content);
|
||||||
|
library.put("record_type", type);
|
||||||
|
library.put("seq_ids", seq_id);
|
||||||
|
library.put("state", "1");
|
||||||
|
library.put("NMSSERVER_ID", ""+Common.getServerTable().getId());
|
||||||
|
library.put("create_time", format.format(System.currentTimeMillis()));
|
||||||
|
// System.out.println("record_command"+ cmd);
|
||||||
|
// System.out.println("record_content"+ content);
|
||||||
|
// System.out.println("record_type"+ type);
|
||||||
|
// System.out.println("seq_ids"+ seq_id);
|
||||||
|
// System.out.println("state"+ "1");
|
||||||
|
// System.out.println("NMSSERVER_ID"+ ""+Common.getServerTable().getId());
|
||||||
|
// System.out.println("create_time"+ format.format(System.currentTimeMillis()));
|
||||||
|
dao.insertObj("event_record_library",library);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Change record save failure", e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void updateEventRecordLibrary(EventRecordLibrary event,String createTime,String content) {
|
||||||
|
if(event.getId() == null){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String sql = "update event_record_library erl set RECORD_CONTENT='"+content+"' ,CREATE_TIME=to_date('"+createTime+"','yyyy-MM-dd HH24:mi:ss' ) where id="+event.getId();
|
||||||
|
try {
|
||||||
|
dao.dbUpdate(sql);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Update the event_record_library exception: Record ID="+event.getId(),e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEventRecordBySeqId(Long id) {
|
||||||
|
if(id == null ){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String sql = "delete from event_record_library where lower(RECORD_TYPE)=lower('S2C') and SEQ_IDS = '"+id.longValue()+"'";
|
||||||
|
try {
|
||||||
|
dao.dbUpdate(sql);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEventRecordByIds(String ids) {
|
||||||
|
if(StringUtils.isEmpty(ids)){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String sql = "delete from event_record_library where id in ("+ids+")";
|
||||||
|
try {
|
||||||
|
dao.dbUpdate(sql);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEventRecordOldInfo() {
|
||||||
|
// String sql = "delete event_record_library t where sysdate - t.create_time > 4";
|
||||||
|
String sql = "delete from event_record_library where create_time < sysdate-4 ";
|
||||||
|
try {
|
||||||
|
dao.dbUpdate(sql);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public EventRecordLibrary selectEventRecordInfo(String recordType,String recordCommand,String seqId) {
|
||||||
|
EventRecordLibrary event = null;
|
||||||
|
try {
|
||||||
|
if(StringUtils.isBlank(seqId)) {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
ArrayList<Map<String,String>> mapList = null;
|
||||||
|
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.clear();
|
||||||
|
fields.add("id");
|
||||||
|
fields.add("RECORD_TYPE");
|
||||||
|
fields.add("RECORD_CONTENT");
|
||||||
|
fields.add("SEQ_IDS");
|
||||||
|
fields.add("RECORD_COMMAND");
|
||||||
|
fields.add("CREATE_TIME");
|
||||||
|
fields.add("NMSSERVER_ID");
|
||||||
|
|
||||||
|
mapList = dao.dbSelect(" select ID,RECORD_TYPE,RECORD_CONTENT,SEQ_IDS,RECORD_COMMAND,CREATE_TIME,NMSSERVER_ID " +
|
||||||
|
" from event_record_library erl " +
|
||||||
|
" where erl.RECORD_TYPE='"+recordType+"' and erl.RECORD_COMMAND='"+recordCommand+"' and erl.SEQ_IDS=" + Long.parseLong(seqId.trim()) +
|
||||||
|
" order by erl.CREATE_TIME desc",fields);
|
||||||
|
|
||||||
|
if(mapList!=null && mapList.size()>0){
|
||||||
|
Map<String,String> map = mapList.get(0);
|
||||||
|
if(StringUtils.isNotBlank(map.get("id")) ) {
|
||||||
|
event = new EventRecordLibrary();
|
||||||
|
event.setId(Long.valueOf(map.get("id")));
|
||||||
|
event.setRecordType(map.get("RECORD_TYPE"));
|
||||||
|
event.setRecordContent(map.get("RECORD_CONTENT"));
|
||||||
|
event.setSeqId(StringUtils.isBlank(map.get("SEQ_IDS"))? null:Long.valueOf(map.get("SEQ_IDS")));
|
||||||
|
event.setRecordCommand(map.get("RECORD_COMMAND"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e1) {
|
||||||
|
logger.error("Query the event_record_library table exception",e1);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
/*public static void main(String [] args) {
|
||||||
|
CommonDao dao = null;
|
||||||
|
ChangeService service = null;
|
||||||
|
try {
|
||||||
|
dao = new CommonDao();
|
||||||
|
service = new ChangeService(new CommonDao());
|
||||||
|
Common.setServerTable(service.getNMSServerParams("10.0.6.242"));
|
||||||
|
List<EventRecordLibrary> list = service.getNewEventRecordList();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
EventRecordLibrary library = list.get(i);
|
||||||
|
pl(library.getId()+" "+library.getSeqId()+" "+library.getRecordType()+" "+library.getState());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally{
|
||||||
|
if(dao!=null)dao.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public ServerTable getNMSServerParams(String ip) throws Exception{
|
||||||
|
ServerTable serverTable = null;
|
||||||
|
try {
|
||||||
|
//查询server 信息
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("id");
|
||||||
|
fields.add("server_name");
|
||||||
|
fields.add("server_state");
|
||||||
|
fields.add("server_ip");
|
||||||
|
fields.add("server_ipn");
|
||||||
|
ArrayList<Map<String, String>> mapsList = dao.dbSelect("select st.id,st.server_name,st.server_state, st.server_ip,st.server_ipn from server_table st where st.server_ip='" + ip + "'", fields);
|
||||||
|
// pl(""+mapsList.size());
|
||||||
|
if(mapsList!=null && mapsList.size()>0){
|
||||||
|
serverTable = new ServerTable();
|
||||||
|
Map<String, String> map = mapsList.get(0);
|
||||||
|
serverTable.setId(StringUtils.isEmpty(map.get(fields.get(0))) ? null : Long.parseLong(map.get(fields.get(0))));
|
||||||
|
serverTable.setServerName(StringUtils.isEmpty(map.get(fields.get(1))) ? null : map.get(fields.get(1)));
|
||||||
|
serverTable.setServerState(StringUtils.isEmpty(map.get(fields.get(2))) ? null : Long.parseLong(map.get(fields.get(2))));
|
||||||
|
serverTable.setServerIp(StringUtils.isEmpty(map.get(fields.get(3))) ? null : map.get(fields.get(3)));
|
||||||
|
serverTable.setServerIpn(StringUtils.isEmpty(map.get(fields.get(4))) ? null : Long.parseLong(map.get(fields.get(4))));
|
||||||
|
}else{
|
||||||
|
// throw new Exception("IP为 "+ip+" 的DataController信息 数据库中不存在,请检查网络设置或进行人工DataController配置");
|
||||||
|
throw new Exception("IP does not exist in the DataController information database for "+ip+" Check the network settings or manual DataController configuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询server 的管理IP段信息
|
||||||
|
if(serverTable!= null && serverTable.getId()!=null){
|
||||||
|
serverTable.setIpSegList(new LinkedList<ServerIpSegment>());
|
||||||
|
fields.clear();
|
||||||
|
fields.add("start_ip");
|
||||||
|
fields.add("start_ipn");
|
||||||
|
fields.add("end_ip");
|
||||||
|
fields.add("end_ipn");
|
||||||
|
mapsList = dao.dbSelect("select sis.start_ip,sis.start_ipn,sis.end_ip,sis.end_ipn from server_ip_segment sis where sis.server_id='" + serverTable.getId().longValue() + "'", fields);
|
||||||
|
// pl(""+mapsList.size());
|
||||||
|
if(mapsList!=null && mapsList.size()>0){
|
||||||
|
for(Map<String, String> map : mapsList){
|
||||||
|
ServerIpSegment segment = new ServerIpSegment();
|
||||||
|
segment.setStartIp(StringUtils.isEmpty(map.get(fields.get(0))) ? null : map.get(fields.get(0)));
|
||||||
|
segment.setStartIpn(StringUtils.isEmpty(map.get(fields.get(1))) ? null : Long.parseLong(map.get(fields.get(1))));
|
||||||
|
segment.setEndIp(StringUtils.isEmpty(map.get(fields.get(2))) ? null : map.get(fields.get(2)));
|
||||||
|
segment.setEndIpn(StringUtils.isEmpty(map.get(fields.get(3))) ? null : Long.parseLong(map.get(fields.get(3))));
|
||||||
|
serverTable.getIpSegList().add(segment);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// throw new Exception("IP为 "+ip+" 的DataController的IP段信息 数据库中不存在 请进行人工配置");
|
||||||
|
throw new Exception("IP does not exist in the "+ip+" segment information database of DataController for IP. Please configure manually");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// throw new Exception("IP为 "+ip+" 的DataController信息 查询异常 无法查询出ID");
|
||||||
|
throw new Exception("DataController information with IP "+ip+" query exception Unable to query ID");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("By parameter:"+ ip+" to get node information failure",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
return serverTable;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
6656
src/com/nms/server/service/CommonService.java
Normal file
6656
src/com/nms/server/service/CommonService.java
Normal file
File diff suppressed because it is too large
Load Diff
707
src/com/nms/server/service/EmailService.java
Normal file
707
src/com/nms/server/service/EmailService.java
Normal file
@@ -0,0 +1,707 @@
|
|||||||
|
package com.nms.server.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.bean.ContactSetInfo;
|
||||||
|
import com.nms.server.bean.EmailInfo;
|
||||||
|
import com.nms.server.common.CommonResources;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.common.EmailTypeConstants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
import com.nms.server.util.SQLExecuteTimeoutException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并保存邮件信息
|
||||||
|
* 查询邮件信息并将邮件信息整理成单一邮件进行查询
|
||||||
|
* @date Feb 6, 2012 10:17:56 AM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EmailService {
|
||||||
|
private final Logger logger = Logger.getLogger(EmailService.class);
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(Constants.COMMON_DATE_FORMAT);
|
||||||
|
private CommonDao dao = null;
|
||||||
|
|
||||||
|
public EmailService(CommonDao dao){
|
||||||
|
this.dao = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EmailInfo> getEmailInfoList(){
|
||||||
|
String selectSql = "select et.id , et.to_address ,et.action_type ,et.action_desc ,et.action_ip ,to_char(et.action_date,'"+Constants.DB_DATE_FORMAT+"') action_date,et.content from email_table et where et.send_flag = ? order by et.to_address asc,et.action_type asc,et.action_desc asc,et.action_ip asc,et.action_date asc";
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("id");
|
||||||
|
fields.add("to_address");
|
||||||
|
fields.add("action_type");
|
||||||
|
fields.add("action_desc");
|
||||||
|
fields.add("action_ip");
|
||||||
|
fields.add("action_date");
|
||||||
|
fields.add("content");
|
||||||
|
|
||||||
|
Object [] params = new Object[]{EmailTypeConstants.FLAG_SEND_LATER};
|
||||||
|
List<EmailInfo> eiList = new LinkedList<EmailInfo>();
|
||||||
|
try {
|
||||||
|
ArrayList<Map<String, String>> mapsList = dao.dbSelect(selectSql, fields, EmailTypeConstants.FLAG_SEND_LATER);
|
||||||
|
if(mapsList!=null && mapsList.size()>0){
|
||||||
|
for(Map<String, String> maps : mapsList){
|
||||||
|
EmailInfo ei = new EmailInfo();
|
||||||
|
ei.setId(StringUtils.isEmpty(maps.get("id"))?null:Long.parseLong(maps.get("id")));
|
||||||
|
ei.setToAddress(maps.get("to_address"));
|
||||||
|
ei.setActionType(StringUtils.isEmpty(maps.get("action_type"))?null:Integer.parseInt(maps.get("action_type")));
|
||||||
|
ei.setActionDesc(maps.get("action_desc"));
|
||||||
|
ei.setActionIp(maps.get("action_ip"));
|
||||||
|
ei.setActionDate(maps.get("action_date"));
|
||||||
|
ei.setContent(maps.get("content"));
|
||||||
|
eiList.add(ei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("Failure of mail information query", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return eiList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmailTypeDescByTypeValue(int type){
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case EmailTypeConstants.TYPE_DETECTION_INFO_RECOVER:
|
||||||
|
return EmailTypeConstants.DESC_DETECTION_INFO_RECOVER;
|
||||||
|
case EmailTypeConstants.TYPE_DETECTION_INFO_EXCEPTION:
|
||||||
|
return EmailTypeConstants.DESC_DETECTION_INFO_EXCEPTION;
|
||||||
|
case EmailTypeConstants.TYPE_DETECTION_INFO_TIMEOUT:
|
||||||
|
return EmailTypeConstants.DESC_DETECTION_INFO_TIMEOUT;
|
||||||
|
|
||||||
|
case EmailTypeConstants.TYPE_ALARM_INFO_EXCEPTION:
|
||||||
|
return EmailTypeConstants.DESC_ALARM_INFO_EXCEPTION;
|
||||||
|
case EmailTypeConstants.TYPE_ALARM_INFO_RECOVER:
|
||||||
|
return EmailTypeConstants.DESC_ALARM_INFO_RECOVER;
|
||||||
|
|
||||||
|
case EmailTypeConstants.TYPE_TASK_NODE_RESULT_ERROR:
|
||||||
|
return EmailTypeConstants.DESC_TASK_NODE_RESULT_ERROR;
|
||||||
|
case EmailTypeConstants.TYPE_TASK_STATE_CHANGE:
|
||||||
|
return EmailTypeConstants.DESC_TASK_STATE_CHANGE;
|
||||||
|
|
||||||
|
case EmailTypeConstants.TYPE_SYSTEM_RUNNING_EXCEPTION:
|
||||||
|
return EmailTypeConstants.DESC_SYSTEM_RUNNING_EXCEPTION;
|
||||||
|
case EmailTypeConstants.TYPE_SYSTEM_RUNNING_RECOVER:
|
||||||
|
return EmailTypeConstants.DESC_SYSTEM_RUNNING_RECOVER;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void sendEmailForDetectionBySeqId(Long dId,Long seqId,EmailInfo emailInfo){
|
||||||
|
|
||||||
|
//-- 邮件功能是否开启
|
||||||
|
if(Constants.flag_email != 1){
|
||||||
|
logger.info("邮件功能已关闭");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- 数据校验 无效返回
|
||||||
|
if(dId==null || dId.longValue() == 0l || seqId==null || seqId.longValue() == 0l){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- 查询联系人设置信息
|
||||||
|
ContactSetInfo contactSetInfo = this.getContactSetInfoByDetecId(dId);
|
||||||
|
|
||||||
|
//-- 获取联系人列表
|
||||||
|
List<EmailInfo> eiList = new LinkedList<EmailInfo>();
|
||||||
|
List<String> emaiList = this.getEmailList(contactSetInfo, seqId);
|
||||||
|
logger.debug("邮件数量 "+(emaiList==null?null:emaiList.size()));
|
||||||
|
if(emaiList!=null && emaiList.size()>0){
|
||||||
|
|
||||||
|
for (Iterator emailIte = emaiList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue; //邮件地址不为空
|
||||||
|
EmailInfo emailInfo2 = new EmailInfo(emailInfo);
|
||||||
|
emailInfo2.setToAddress(addr);
|
||||||
|
eiList.add(emailInfo2);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
saveEmailInfoList(eiList);
|
||||||
|
} catch (SQLExecuteTimeoutException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendEmailForMissionBySeqId(Long mId,int missionType,Long seqId,EmailInfo emailInfo){
|
||||||
|
//-- 邮件功能是否开启
|
||||||
|
if(Constants.flag_email != 1){
|
||||||
|
logger.info("邮件功能已关闭");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- 数据校验 无效返回
|
||||||
|
if(mId==null || mId.longValue() == 0l || missionType==0 || seqId==null || seqId.longValue() == 0l){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- 查询联系人设置信息
|
||||||
|
ContactSetInfo contactSetInfo = this.getContactSetInfoByMissionId(mId);
|
||||||
|
|
||||||
|
//-- 获取联系人列表
|
||||||
|
List<EmailInfo> eiList = new LinkedList<EmailInfo>();
|
||||||
|
List<String> emaiList = this.getEmailList(contactSetInfo, seqId);
|
||||||
|
logger.debug("邮件数量 "+(emaiList==null?null:emaiList.size()));
|
||||||
|
|
||||||
|
//-- 发邮件
|
||||||
|
if(emaiList!=null && emaiList.size()>0){
|
||||||
|
|
||||||
|
for (Iterator emailIte = emaiList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue;
|
||||||
|
EmailInfo emailInfo2 = new EmailInfo(emailInfo);
|
||||||
|
emailInfo2.setToAddress(addr);
|
||||||
|
eiList.add(emailInfo2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
saveEmailInfoList(eiList);
|
||||||
|
} catch (SQLExecuteTimeoutException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
//-结束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行邮件通知方法
|
||||||
|
* 任务类型 1 根据 系统 用户组 指定用户处理
|
||||||
|
* 任务类型 4 根据 系统 用户组 指定用户处理
|
||||||
|
* 任务类型 6 根据 下发机器 的管理用户发送通知
|
||||||
|
* @time Mar 28, 2012-1:53:56 PM
|
||||||
|
* @param mission 任务信息
|
||||||
|
* @param emaiTitle 主题
|
||||||
|
* @param emailContext 内容
|
||||||
|
*/
|
||||||
|
public void sendEmailForMission(Long missionId,String emaiTitle,String emailContext){
|
||||||
|
//-- 邮件功能是否开启
|
||||||
|
if(Constants.flag_email != 1){
|
||||||
|
logger.info("邮件功能已关闭");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- 参数校验
|
||||||
|
if(missionId==null || StringUtils.isEmpty(emaiTitle) || StringUtils.isEmpty(emailContext)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContactSetInfo info = this.getContactSetInfoByMissionId(missionId);
|
||||||
|
LinkedList<String> emailList = null;
|
||||||
|
|
||||||
|
ResourceBundle res = ResourceBundle.getBundle(CommonResources.class.getName());
|
||||||
|
// ContactSetInfo info = getContactSetInfoByMissionId(mId,mType);
|
||||||
|
String startTime = "";
|
||||||
|
String endTime = "";
|
||||||
|
if(info.getStartTime()!=null){
|
||||||
|
startTime = format.format(info.getStartTime());
|
||||||
|
}
|
||||||
|
if(info.getEndTime()!=null){
|
||||||
|
endTime = format.format(info.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
String sendInfo = "";
|
||||||
|
|
||||||
|
if(info.getMissionType().longValue()==4l){
|
||||||
|
// sendInfo += " \n周期任务:" +(info.getIsLoop()==null?"否":(info.getIsLoop().longValue()==1l?"是":"否"));
|
||||||
|
// sendInfo += " \n计划执行时间:" + startTime+" -- "+endTime;
|
||||||
|
// sendInfo += " \nPeriodic Task:" +(info.getIsLoop()==null?"No":(info.getIsLoop().longValue()==1l?"Yes":"No"));
|
||||||
|
// sendInfo += " \nPlan Execution Time:" + startTime+" -- "+endTime;
|
||||||
|
sendInfo += " \ni18n_server.EmailService.loopMission_n81i:" +(info.getIsLoop()==null?"i18n_server.EmailService.no_n81i":(info.getIsLoop().longValue()==1l?"i18n_server.EmailService.yes_n81i":"i18n_server.EmailService.no_n81i"));
|
||||||
|
sendInfo += " \ni18n_server.EmailService.plantime_n81i:" + startTime+" -- "+endTime;
|
||||||
|
}
|
||||||
|
// sendInfo += " \n任务状态:" + res.getObject("ms_"+info.getMissionState().intValue())
|
||||||
|
// + " \n节点组:" + info.getNodeGroupName()
|
||||||
|
// + " \n节点:" + info.getNodeIpsName()
|
||||||
|
// + " \n" + emailContext;
|
||||||
|
// sendInfo += " \nTask state:" + res.getObject("ms_"+info.getMissionState().intValue())
|
||||||
|
// + " \nNode Group:" + info.getNodeGroupName()
|
||||||
|
// + " \nNode:" + info.getNodeIpsName()
|
||||||
|
// + " \n" + emailContext;
|
||||||
|
sendInfo += " \ni18n_server.EmailService.missionState_n81i:" + res.getObject("ms_"+info.getMissionState().intValue())
|
||||||
|
+ " \ni18n_server.EmailService.nodegroup_n81i:" + info.getNodeGroupName()
|
||||||
|
+ " \ni18n_server.EmailService.node_n81i:" + info.getNodeIpsName()
|
||||||
|
+ " \n" + emailContext;
|
||||||
|
|
||||||
|
EmailInfo emailInfo = new EmailInfo();
|
||||||
|
emailInfo.setActionDesc(info.getMissionName()+"("+res.getObject("mt_"+info.getMissionType().longValue())+")");
|
||||||
|
emailInfo.setActionDate(new SimpleDateFormat(Constants.COMMON_DATE_FORMAT).format(new Date()));
|
||||||
|
emailInfo.setActionType(EmailTypeConstants.TYPE_TASK_STATE_CHANGE);
|
||||||
|
emailInfo.setSendFlag(EmailTypeConstants.FLAG_SEND_LATER);
|
||||||
|
emailInfo.setContent(sendInfo);
|
||||||
|
emailInfo.setSendLevel(EmailTypeConstants.URGENT_IMMEDIATELY);//2013-6-24 hyx 任务状态改变由不紧急修改为紧急
|
||||||
|
//- 发送邮件业务
|
||||||
|
try {
|
||||||
|
//-- 查询联系人参数过滤
|
||||||
|
switch (info.getMissionType().intValue()) {
|
||||||
|
case 6:
|
||||||
|
info.setViewLevel(3l); // 升级部署 通知均为系统内通知
|
||||||
|
emailList = getEmailList(info, null);
|
||||||
|
break;
|
||||||
|
default: //任务1 任务4 均按原有业务发送邮件
|
||||||
|
emailList = getEmailList(info, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
logger.debug("邮件数量 "+(emailList==null?null:emailList.size()));
|
||||||
|
|
||||||
|
//-- 发送邮件
|
||||||
|
List<EmailInfo> eiList = new LinkedList<EmailInfo>();
|
||||||
|
if(emailList !=null && emailList.size()>0){
|
||||||
|
for (Iterator emailIte = emailList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue;
|
||||||
|
EmailInfo emailInfo2 = new EmailInfo(emailInfo);
|
||||||
|
emailInfo2.setToAddress(addr);
|
||||||
|
eiList.add(emailInfo2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
saveEmailInfoList(eiList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
logger.info("任务下发 邮件通知 发送完成");
|
||||||
|
|
||||||
|
//-结束
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean saveEmailInfoList(List<EmailInfo> eiList) throws SQLExecuteTimeoutException,SQLException {
|
||||||
|
|
||||||
|
String insertSql = " insert into email_table (to_address,action_type,content,send_flag,action_ip,action_date,action_desc,send_level,CREATE_TIME)" +
|
||||||
|
" values(?,?,?,?,?,to_date(?,'"+Constants.DB_DATE_FORMAT+"'),?,?,to_date(?,'"+Constants.DB_DATE_FORMAT+"'))" ;
|
||||||
|
List<String[]> paramsList = new LinkedList<String[]>();
|
||||||
|
if(eiList != null && eiList.size()>0){
|
||||||
|
String createTime = format.format(new Date());
|
||||||
|
for(EmailInfo ei :eiList){
|
||||||
|
paramsList.add(new String[]{ei.getToAddress(),ei.getActionType()+"",ei.getContent(),ei.getSendFlag()+"",ei.getActionIp(),ei.getActionDate(),ei.getActionDesc(),/*ei.getActionDesc2(),*/ei.getSendLevel()==null?EmailTypeConstants.URGENT_LATER+"":ei.getSendLevel()+"",createTime});
|
||||||
|
}
|
||||||
|
return dao.dbUpdateByBatch(insertSql, paramsList);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*private void sendEmailForDetectionBySeqId(Long dId,Long seqId,String emaiTitle,String emailContext){
|
||||||
|
|
||||||
|
//-- 数据校验 无效返回
|
||||||
|
if(dId==null || dId.longValue() == 0l || seqId==null || seqId.longValue() == 0l){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//-- 查询联系人设置信息
|
||||||
|
ContactSetInfo contactSetInfo = this.getContactSetInfoByDetecId(dId);
|
||||||
|
//-- 获取联系人列表
|
||||||
|
List<String> emaiList = this.getEmailList(contactSetInfo, seqId);
|
||||||
|
logger.debug("邮件数量 "+(emaiList==null?null:emaiList.size()));
|
||||||
|
//-- 发邮件
|
||||||
|
if(emaiList!=null && emaiList.size()>0){
|
||||||
|
SendMail cn = new SendMail();
|
||||||
|
for (Iterator emailIte = emaiList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue;
|
||||||
|
logger.debug("邮件 To "+(addr));
|
||||||
|
// 设置发件人地址、收件人地址和邮件标题
|
||||||
|
cn.setAddress(Constants.EMAIL_ADDRESS, addr, emaiTitle);
|
||||||
|
cn.send(emailContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-结束
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*private void sendEmailForMissionBySeqId(Long mId,int missionType,Long seqId,String emaiTitle,String emailContext){
|
||||||
|
|
||||||
|
//-- 数据校验 无效返回
|
||||||
|
if(mId==null || mId.longValue() == 0l || missionType==0 || seqId==null || seqId.longValue() == 0l){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//-- 查询联系人设置信息
|
||||||
|
ContactSetInfo contactSetInfo = this.getContactSetInfoByMissionId(mId);
|
||||||
|
//-- 获取联系人列表
|
||||||
|
List<String> emaiList = this.getEmailList(contactSetInfo, seqId);
|
||||||
|
logger.debug("邮件数量 "+(emaiList==null?null:emaiList.size()));
|
||||||
|
//-- 发邮件
|
||||||
|
if(emaiList!=null && emaiList.size()>0){
|
||||||
|
SendMail cn = new SendMail();
|
||||||
|
for (Iterator emailIte = emaiList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue;
|
||||||
|
logger.debug("邮件 To "+(addr));
|
||||||
|
// 设置发件人地址、收件人地址和邮件标题
|
||||||
|
cn.setAddress(Constants.EMAIL_ADDRESS, addr, emaiTitle);
|
||||||
|
cn.send(emailContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-结束
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行邮件通知方法
|
||||||
|
* 任务类型 1 根据 系统 用户组 指定用户处理
|
||||||
|
* 任务类型 4 根据 系统 用户组 指定用户处理
|
||||||
|
* 任务类型 6 根据 下发机器 的管理用户发送通知
|
||||||
|
* @time Mar 28, 2012-1:53:56 PM
|
||||||
|
* @param mission 任务信息
|
||||||
|
* @param emaiTitle 主题
|
||||||
|
* @param emailContext 内容
|
||||||
|
*/
|
||||||
|
/*private void sendEmailForMission(Long missionId,String emaiTitle,String emailContext){
|
||||||
|
|
||||||
|
//-- 参数校验
|
||||||
|
if(missionId==null || StringUtils.isEmpty(emaiTitle) || StringUtils.isEmpty(emailContext)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ContactSetInfo info = this.getContactSetInfoByMissionId(missionId);
|
||||||
|
LinkedList<String> emailList = null;
|
||||||
|
|
||||||
|
ResourceBundle res = ResourceBundle.getBundle(CommonResources.class.getName());
|
||||||
|
// ContactSetInfo info = getContactSetInfoByMissionId(mId,mType);
|
||||||
|
String startTime = "";
|
||||||
|
String endTime = "";
|
||||||
|
if(info.getStartTime()!=null){
|
||||||
|
startTime = format.format(info.getStartTime());
|
||||||
|
}
|
||||||
|
if(info.getEndTime()!=null){
|
||||||
|
endTime = format.format(info.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
String sendInfo = "任务名称:"+info.getMissionName()
|
||||||
|
+ " \n任务类型:" + res.getObject("mt_"+info.getMissionType().longValue());
|
||||||
|
|
||||||
|
if(info.getMissionType().longValue()==4l){
|
||||||
|
sendInfo += " \n周期任务:" +(info.getIsLoop()==null?"否":(info.getIsLoop().longValue()==1l?"是":"否"));
|
||||||
|
}
|
||||||
|
sendInfo += " \n任务状态:" + res.getObject("ms_"+info.getMissionState().intValue());
|
||||||
|
sendInfo += " \n计划执行时间:" + startTime+" -- "+endTime
|
||||||
|
+ " \n节点组:" + info.getNodeGroupName()
|
||||||
|
+ " \n节点:" + info.getNodeIpsName()
|
||||||
|
+ " \n" + emailContext;
|
||||||
|
|
||||||
|
//- 发送邮件业务
|
||||||
|
try {
|
||||||
|
//-- 查询联系人参数过滤
|
||||||
|
switch (info.getMissionType().intValue()) {
|
||||||
|
case 6:
|
||||||
|
info.setViewLevel(3l); // 升级部署 通知均为系统内通知
|
||||||
|
emailList = getEmailList(info, null);
|
||||||
|
break;
|
||||||
|
default: //任务1 任务4 均按原有业务发送邮件
|
||||||
|
emailList = getEmailList(info, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
logger.debug("邮件数量 "+(emailList==null?null:emailList.size()));
|
||||||
|
|
||||||
|
//-- 发送邮件
|
||||||
|
if(emailList !=null && emailList.size()>0){
|
||||||
|
SendMail cn = new SendMail();
|
||||||
|
for (Iterator emailIte = emailList.iterator(); emailIte.hasNext();) {
|
||||||
|
String addr = (String) emailIte.next();
|
||||||
|
if(StringUtils.isEmpty(addr))continue;
|
||||||
|
logger.debug("邮件 To "+(addr));
|
||||||
|
// 设置发件人地址、收件人地址和邮件标题
|
||||||
|
cn.setAddress(Constants.EMAIL_ADDRESS, addr, emaiTitle);
|
||||||
|
cn.send(sendInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
logger.info("任务下发 邮件通知 发送完成");
|
||||||
|
|
||||||
|
//-结束
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private LinkedList<String> getEmailList(ContactSetInfo contactSetInfo,Long seqId) {
|
||||||
|
LinkedList<String> emailList = new LinkedList<String>();
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("email");
|
||||||
|
if(contactSetInfo!=null && contactSetInfo.getViewLevel()!=null){
|
||||||
|
try {
|
||||||
|
if(contactSetInfo.getViewLevel().intValue()==1){ //个人查看 邮件发送给 创建者
|
||||||
|
String sql1 = "select distinct xyj.email from xt_yh_jbxx xyj where xyj.yhid = '"+contactSetInfo.getCreateUserId()+"' and xyj.is_receiveemail='0' ";
|
||||||
|
List<Map<String, String>> map1 = (List<Map<String, String>>)dao.dbSelect(sql1, fields);
|
||||||
|
if(map1 != null && map1.size()>0){
|
||||||
|
emailList.add(map1.get(0).get("email"));
|
||||||
|
}
|
||||||
|
}else { //非个人
|
||||||
|
//-- 无限制 或 未指定联系人情况
|
||||||
|
if(contactSetInfo.getViewLevel().intValue()==4 || (contactSetInfo.getContactUserIds()==null || contactSetInfo.getContactUserIds().length()==0)){
|
||||||
|
/**
|
||||||
|
* 查询seqId所在的系统
|
||||||
|
* 系统关联的用户维护组的有效维护人员接收邮件信息
|
||||||
|
* */
|
||||||
|
StringBuffer selectSql = new StringBuffer();
|
||||||
|
selectSql.append("select distinct xyj.email ");
|
||||||
|
selectSql.append("from xt_yh_jbxx xyj ");
|
||||||
|
selectSql.append("left join xt_yh_js_index xyji on xyji.yhid = xyj.yhid ");
|
||||||
|
selectSql.append("left join xt_js_jbxx xjj on xjj.jsbh = xyji.jsbh ");
|
||||||
|
selectSql.append("left join gorup_system_table gst on gst.user_group_id = xjj.jsbh ");
|
||||||
|
selectSql.append("left join system_table st on st.system_id = gst.system_id ");
|
||||||
|
selectSql.append("left join node_table nt on nt.system_id = gst.system_id ");
|
||||||
|
selectSql.append("left join nodegroup_table ngt on ngt.group_id = nt.node_group_id ");
|
||||||
|
selectSql.append("where xyj.is_receiveemail='0' ");
|
||||||
|
|
||||||
|
selectSql.append("and nt.node_state = 0 "); // 节点有效状态 0有效
|
||||||
|
selectSql.append("and ngt.is_valid = 1 "); // 节点组有效状态 1有效
|
||||||
|
selectSql.append("and st.system_state = 0 "); // 系统有效状态 0有效
|
||||||
|
selectSql.append("and xjj.zxbz = 0 "); // 用户组有效状态 0有效
|
||||||
|
selectSql.append("and xjj.type = 1 "); // 组类别状态 1是用户组 0是角色
|
||||||
|
selectSql.append("and xyj.zxbz = 0 "); // 用户有效状态 0 有效
|
||||||
|
if(seqId != null && seqId.longValue() != 0){
|
||||||
|
selectSql.append("and nt.seq_id = "+seqId);
|
||||||
|
}
|
||||||
|
//-- 无限制 情况
|
||||||
|
if(contactSetInfo.getViewLevel().intValue()==4){
|
||||||
|
|
||||||
|
}else
|
||||||
|
//-- 系统内 情况
|
||||||
|
if(contactSetInfo.getViewLevel().intValue()==3){
|
||||||
|
selectSql.append("and nt.system_id = '"+contactSetInfo.getSystemId()+"' ");
|
||||||
|
}else
|
||||||
|
//-- 组内 情况
|
||||||
|
if(contactSetInfo.getViewLevel().intValue()==2){
|
||||||
|
selectSql.append("and xjj.jsbh = '"+contactSetInfo.getCreateUserGroupId()+"' ");
|
||||||
|
}
|
||||||
|
List<Map<String, String>> mapList = (List<Map<String, String>>) dao.dbSelect(selectSql.toString(), fields);
|
||||||
|
if(mapList != null && mapList.size()>0){
|
||||||
|
for (Iterator<Map<String,String>> mapIte = mapList.iterator(); mapIte.hasNext();) {
|
||||||
|
Map<String,String> map = mapIte.next();
|
||||||
|
emailList.add(map.get("email"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-- 组或系统内指定联系人情况
|
||||||
|
else{
|
||||||
|
String sql0 = "select distinct xyj.email from xt_yh_jbxx xyj where xyj.yhid in ("+contactSetInfo.getContactUserIds()+") ";
|
||||||
|
List<Map<String, String>> map0List = (List<Map<String, String>>)dao.dbSelect(sql0, fields);
|
||||||
|
if(map0List != null && map0List.size()>0){
|
||||||
|
for (Iterator<Map<String,String>> map0Ite = map0List.iterator(); map0Ite.hasNext();) {
|
||||||
|
Map<String,String> map0 = map0Ite.next();
|
||||||
|
emailList.add(map0.get("email"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(" Fail to query the list of email addresses to be sent to failure",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return emailList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContactSetInfo getContactSetInfoByDetecId(Long dId){
|
||||||
|
ContactSetInfo contactSetInfo = null;
|
||||||
|
StringBuffer selectSql = new StringBuffer();
|
||||||
|
selectSql.append("select ");
|
||||||
|
selectSql.append("dsi.view_level, ");
|
||||||
|
selectSql.append("dsi.create_user_id, ");
|
||||||
|
selectSql.append("dsi.create_usergroup_id, ");
|
||||||
|
selectSql.append("dsi.system_id, ");
|
||||||
|
selectSql.append("dsi.contact_user_ids ");
|
||||||
|
selectSql.append("from detection_set_info dsi where dsi.id= '"+dId+"' ");
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("view_level");
|
||||||
|
fields.add("create_user_id");
|
||||||
|
fields.add("create_usergroup_id");
|
||||||
|
fields.add("system_id");
|
||||||
|
fields.add("contact_user_ids");
|
||||||
|
try {
|
||||||
|
ArrayList<Map<String, String>> mapList = dao.dbSelect(selectSql.toString(), fields);
|
||||||
|
if(mapList!=null && mapList.size()>0){
|
||||||
|
Map<String, String> map0 = mapList.get(0);
|
||||||
|
contactSetInfo = new ContactSetInfo();
|
||||||
|
contactSetInfo.setViewLevel(map0.get("view_level")==null?null:Long.parseLong(map0.get("view_level")));
|
||||||
|
contactSetInfo.setCreateUserId(map0.get("create_user_id")==null?null:Long.parseLong(map0.get("create_user_id")));
|
||||||
|
contactSetInfo.setCreateUserGroupId(map0.get("create_usergroup_id")==null?null:Long.parseLong(map0.get("create_usergroup_id")));
|
||||||
|
contactSetInfo.setSystemId(map0.get("system_id")==null?null:Long.parseLong(map0.get("system_id")));
|
||||||
|
contactSetInfo.setContactUserIds(map0.get("contact_user_ids"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
return contactSetInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContactSetInfo getContactSetInfoByMissionId(Long mId){
|
||||||
|
ContactSetInfo contactSetInfo = null;
|
||||||
|
StringBuffer selectSql = new StringBuffer();
|
||||||
|
selectSql.append("select ");
|
||||||
|
selectSql.append("mst.mission_id, ");
|
||||||
|
selectSql.append("mst.mission_name, ");
|
||||||
|
// selectSql.append("ngt.group_name node_group_name, ");
|
||||||
|
// selectSql.append("mpt.node_groups_id, ");
|
||||||
|
// selectSql.append("mpt.node_ips_id, ");
|
||||||
|
selectSql.append("mst.mission_type, ");
|
||||||
|
selectSql.append("mst.mission_state, ");
|
||||||
|
selectSql.append("mst.is_loop , ");
|
||||||
|
selectSql.append("to_char(mst.start_time,'"+Constants.DB_DATE_FORMAT+"' ) start_time, ");
|
||||||
|
selectSql.append("to_char(mst.end_time,'"+Constants.DB_DATE_FORMAT+"' ) end_time, ");
|
||||||
|
selectSql.append("mst.view_level, ");
|
||||||
|
selectSql.append("mst.user_id, ");
|
||||||
|
selectSql.append("mst.group_id, ");
|
||||||
|
selectSql.append("mst.system_id, ");
|
||||||
|
selectSql.append("mst.contact_user_ids ");
|
||||||
|
selectSql.append("from mission_state_table mst ");
|
||||||
|
// selectSql.append("left join mission_parameter_table"+missionType+" mpt on mpt.mission_id = mst.mission_id ");
|
||||||
|
// selectSql.append("left join nodegroup_table ngt on ngt.group_id = mpt.node_groups_id ");
|
||||||
|
selectSql.append("where mst.mission_id= '"+mId+"' ");
|
||||||
|
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("mission_id");
|
||||||
|
fields.add("mission_name");
|
||||||
|
// fields.add("node_groups_id");
|
||||||
|
// fields.add("node_ips_id");
|
||||||
|
fields.add("mission_type");
|
||||||
|
fields.add("mission_state");
|
||||||
|
fields.add("is_loop");
|
||||||
|
fields.add("start_time");
|
||||||
|
fields.add("end_time");
|
||||||
|
fields.add("view_level");
|
||||||
|
fields.add("user_id");
|
||||||
|
fields.add("group_id");
|
||||||
|
fields.add("system_id");
|
||||||
|
fields.add("contact_user_ids");
|
||||||
|
try {
|
||||||
|
ArrayList<Map<String, String>> mapList = dao.dbSelect(selectSql.toString(), fields);
|
||||||
|
if(mapList!=null && mapList.size()>0){
|
||||||
|
Map<String, String> map = mapList.get(0);
|
||||||
|
contactSetInfo = new ContactSetInfo();
|
||||||
|
contactSetInfo.setMissionId(map.get("mission_id")==null?null:Long.parseLong(map.get("mission_id")));
|
||||||
|
contactSetInfo.setMissionName(map.get("mission_name"));
|
||||||
|
contactSetInfo.setMissionType(map.get("mission_type")==null?null:Long.parseLong(map.get("mission_type")));
|
||||||
|
contactSetInfo.setMissionState(map.get("mission_state")==null?null:Long.parseLong(map.get("mission_state")));
|
||||||
|
contactSetInfo.setIsLoop(map.get("is_loop")==null?null:Long.parseLong(map.get("is_loop")));
|
||||||
|
contactSetInfo.setStartTime(map.get("start_time")==null?null:format.parse(map.get("start_time")));
|
||||||
|
contactSetInfo.setEndTime(map.get("end_time")==null?null:format.parse(map.get("end_time")));
|
||||||
|
contactSetInfo.setViewLevel(map.get("view_level")==null?null:Long.parseLong(map.get("view_level")));
|
||||||
|
contactSetInfo.setCreateUserId(map.get("user_id")==null?null:Long.parseLong(map.get("user_id")));
|
||||||
|
contactSetInfo.setCreateUserGroupId(map.get("group_id")==null?null:Long.parseLong(map.get("group_id")));
|
||||||
|
contactSetInfo.setSystemId(map.get("system_id")==null?null:Long.parseLong(map.get("system_id")));
|
||||||
|
contactSetInfo.setContactUserIds(map.get("contact_user_ids"));
|
||||||
|
|
||||||
|
ArrayList<String> paramsFields = new ArrayList<String>();
|
||||||
|
paramsFields.add("node_groups_id");
|
||||||
|
paramsFields.add("node_ips_id");
|
||||||
|
String paramsSql = "select mpt.node_groups_id,mpt.node_ips_id from mission_parameter_table"+contactSetInfo.getMissionType().intValue()+" mpt where mpt.mission_id=?";
|
||||||
|
ArrayList<Map<String, String>> paramsMapList = dao.dbSelect(paramsSql.toString(), paramsFields,mId);
|
||||||
|
|
||||||
|
if(paramsMapList!= null && paramsMapList.size()>0){
|
||||||
|
Map<String, String> map0 = paramsMapList.get(0);
|
||||||
|
contactSetInfo.setNodeGroupsId(map0.get("node_groups_id"));
|
||||||
|
contactSetInfo.setNodeIpsId(map0.get("node_ips_id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//节点组和节点名称填写
|
||||||
|
if(contactSetInfo!= null){
|
||||||
|
if(contactSetInfo.getNodeGroupsId()!= null){
|
||||||
|
//查询节点组名称
|
||||||
|
ArrayList<String> ngnFields = new ArrayList<String>();
|
||||||
|
ngnFields.add("group_name");
|
||||||
|
String ngNameSql = "select ngt.group_name from nodegroup_table ngt where ngt.group_id in ("+contactSetInfo.getNodeGroupsId()+")";
|
||||||
|
ArrayList<Map<String, String>> ngnMapList = dao.dbSelect(ngNameSql.toString(), ngnFields);
|
||||||
|
if(ngnMapList != null && ngnMapList.size()>0){
|
||||||
|
StringBuffer ngnsb = new StringBuffer();
|
||||||
|
for(Map<String, String> map : ngnMapList){
|
||||||
|
ngnsb.append(","+map.get(ngnFields.get(0)));
|
||||||
|
}
|
||||||
|
if(ngnsb.length()>0){
|
||||||
|
ngnsb.deleteCharAt(0);
|
||||||
|
}
|
||||||
|
contactSetInfo.setNodeGroupName(ngnsb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询节点名称
|
||||||
|
ArrayList<String> nnFields = new ArrayList<String>();
|
||||||
|
nnFields.add("node_name");
|
||||||
|
String nnNameSql = null;
|
||||||
|
ArrayList<Map<String, String>> nnMapList = null;
|
||||||
|
if(contactSetInfo.getNodeIpsId()!= null){
|
||||||
|
nnNameSql = "select nt.node_name from node_table nt where nt.node_id in ("+contactSetInfo.getNodeIpsId()+")";
|
||||||
|
nnMapList = dao.dbSelect(nnNameSql.toString(), nnFields);
|
||||||
|
}else{
|
||||||
|
nnNameSql = "select nt.node_name from node_table nt where nt.node_group_id in ("+contactSetInfo.getNodeGroupsId()+") ";
|
||||||
|
if(contactSetInfo.getIsLoop()==null || contactSetInfo.getIsLoop()==0){ //非周期任务
|
||||||
|
nnNameSql += "and nt.seq_id in (select mrt.seq_id from mission_result_table"+contactSetInfo.getMissionType()+" mrt where mrt.mission_id=?)";
|
||||||
|
}else{ //周期任务
|
||||||
|
nnNameSql += "and nt.seq_id in (select distinct mrt.seq_id from mission_result_table4 mrt where mrt.mission_id in (select lmst.cur_mission_id from loopmission_state_table lmst where lmst.mission_id=?))";
|
||||||
|
}
|
||||||
|
nnMapList = dao.dbSelect(nnNameSql.toString(), nnFields,mId);
|
||||||
|
}
|
||||||
|
if(nnMapList != null && nnMapList.size()>0){
|
||||||
|
StringBuffer nnsb = new StringBuffer();
|
||||||
|
for(Map<String, String> map : nnMapList){
|
||||||
|
nnsb.append(","+map.get(nnFields.get(0)));
|
||||||
|
}
|
||||||
|
if(nnsb.length()>0){
|
||||||
|
nnsb.deleteCharAt(0);
|
||||||
|
}
|
||||||
|
contactSetInfo.setNodeIpsName(nnsb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally{
|
||||||
|
dao.clearConn();
|
||||||
|
}
|
||||||
|
return contactSetInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String [] args){
|
||||||
|
CommonDao dao = null;
|
||||||
|
try {
|
||||||
|
dao = new CommonDao();
|
||||||
|
EmailService emailService = new EmailService(dao);
|
||||||
|
EmailInfo emailInfo = new EmailInfo(11,"测试名称","10.0.6.113",new SimpleDateFormat(Constants.COMMON_DATE_FORMAT).format(new Date()),"这是一条关于监测设置的测试信息",EmailTypeConstants.FLAG_SEND_LATER,EmailTypeConstants.URGENT_LATER);
|
||||||
|
//113监测邮件测试
|
||||||
|
Constants.flag_email = 1;
|
||||||
|
// emailService.sendEmailForDetectionBySeqId(2570l, 85l, emailInfo);
|
||||||
|
// EmailInfo emailInfo2 = new EmailInfo(31,"任务XXX","10.0.6.113",new SimpleDateFormat(Constants.COMMON_DATE_FORMAT).format(new Date()),"这是一条关于任务结果的测试信息",0);
|
||||||
|
// emailService.sendEmailForMissionBySeqId(2570l, 6, 85l, emailInfo2);
|
||||||
|
emailService.sendEmailForMission(2570l, "任务XXX", "这是一条关于任务状态的测试信息");
|
||||||
|
|
||||||
|
pl("测试邮件入库完毕");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private static void pl(Object object) {
|
||||||
|
System.out.println(object==null?null:object.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/com/nms/server/service/ThreadService.java
Normal file
68
src/com/nms/server/service/ThreadService.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package com.nms.server.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.bean.SetInfo;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.thread.monitor.MonitorManagerThread;
|
||||||
|
|
||||||
|
public class ThreadService{
|
||||||
|
private static Logger logger = Logger.getLogger(ThreadService.class);
|
||||||
|
public ThreadService(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新主动监测线程操作
|
||||||
|
* 关闭旧线程,创建新线程
|
||||||
|
* @time Sep 12, 2012-4:44:03 PM
|
||||||
|
* @param nm
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
|
public void updateThread(SetInfo info) {
|
||||||
|
|
||||||
|
//- 计算启动后第一次检测时间 默认即时启动
|
||||||
|
long initialDelay = Constants.HANDSHANK_DELAY_TIME;
|
||||||
|
if(info.getPlanCheckTime()!=null){
|
||||||
|
initialDelay = info.getPlanCheckTime().longValue() - (new Date().getTime());
|
||||||
|
initialDelay = initialDelay > 0l ? initialDelay : 0l;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 设置名称
|
||||||
|
String processIden = StringUtils.isEmpty(info.getProcessIden())?"":info.getProcessIden();
|
||||||
|
|
||||||
|
//-线程名称
|
||||||
|
String runnableName = info.getCheckTypeName()+"_"+processIden;
|
||||||
|
|
||||||
|
//- 撤销旧监测线程
|
||||||
|
Common.cancelRunnableAtOnce(runnableName); //撤销 旧任务
|
||||||
|
|
||||||
|
//- 监测设置状态无效 结束操作--对于变更,如果修改为无效,则不再启动新监测
|
||||||
|
if(StringUtils.isEmpty(info.getCheckState()) || "0".equals(info.getCheckState())){//0无效;1有效
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 监测方式 非主动 结束操作--为了严谨
|
||||||
|
if(StringUtils.isEmpty(info.getCheckWay()) || "1".equals(info.getCheckWay())){//0主动,1被动
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.info("主动监测设置启动 "+runnableName);
|
||||||
|
|
||||||
|
//- 创建线程
|
||||||
|
Runnable runnable = new MonitorManagerThread(runnableName,info);
|
||||||
|
|
||||||
|
//- 添加到 定时线程池
|
||||||
|
ScheduledFuture<?> future = Common.scheduled.scheduleAtFixedRate(runnable, initialDelay/1000, info.getCheckGap()*60, TimeUnit.SECONDS);
|
||||||
|
//- 注册线程
|
||||||
|
Common.registRunnable(runnableName, future);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
3470
src/com/nms/server/service/UpgradeService.java
Normal file
3470
src/com/nms/server/service/UpgradeService.java
Normal file
File diff suppressed because it is too large
Load Diff
375
src/com/nms/server/snmp/trap/TrapServer.java
Normal file
375
src/com/nms/server/snmp/trap/TrapServer.java
Normal file
@@ -0,0 +1,375 @@
|
|||||||
|
package com.nms.server.snmp.trap;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.snmp4j.CommandResponder;
|
||||||
|
import org.snmp4j.CommandResponderEvent;
|
||||||
|
import org.snmp4j.MessageDispatcherImpl;
|
||||||
|
import org.snmp4j.PDU;
|
||||||
|
import org.snmp4j.PDUv1;
|
||||||
|
import org.snmp4j.Snmp;
|
||||||
|
import org.snmp4j.TransportMapping;
|
||||||
|
import org.snmp4j.mp.MPv1;
|
||||||
|
import org.snmp4j.mp.MPv2c;
|
||||||
|
import org.snmp4j.mp.MPv3;
|
||||||
|
import org.snmp4j.mp.SnmpConstants;
|
||||||
|
import org.snmp4j.security.AuthMD5;
|
||||||
|
import org.snmp4j.security.AuthSHA;
|
||||||
|
import org.snmp4j.security.PrivAES128;
|
||||||
|
import org.snmp4j.security.PrivAES192;
|
||||||
|
import org.snmp4j.security.PrivAES256;
|
||||||
|
import org.snmp4j.security.PrivDES;
|
||||||
|
import org.snmp4j.security.SecurityModels;
|
||||||
|
import org.snmp4j.security.SecurityProtocols;
|
||||||
|
import org.snmp4j.security.USM;
|
||||||
|
import org.snmp4j.smi.Address;
|
||||||
|
import org.snmp4j.smi.GenericAddress;
|
||||||
|
import org.snmp4j.smi.OID;
|
||||||
|
import org.snmp4j.smi.OctetString;
|
||||||
|
import org.snmp4j.smi.TcpAddress;
|
||||||
|
import org.snmp4j.smi.UdpAddress;
|
||||||
|
import org.snmp4j.smi.Variable;
|
||||||
|
import org.snmp4j.smi.VariableBinding;
|
||||||
|
import org.snmp4j.transport.DefaultTcpTransportMapping;
|
||||||
|
import org.snmp4j.transport.DefaultUdpTransportMapping;
|
||||||
|
import org.snmp4j.util.MultiThreadedMessageDispatcher;
|
||||||
|
import org.snmp4j.util.ThreadPool;
|
||||||
|
|
||||||
|
import com.nms.server.bean.SetInfo;
|
||||||
|
import com.nms.server.bean.TrapMessageInfo;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
import com.nms.server.service.CommonService;
|
||||||
|
import com.nms.server.util.SNMP4JUtils;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本类用于监听代理进程的Trap信息
|
||||||
|
*
|
||||||
|
* @author YJS
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TrapServer /**extends Service*/
|
||||||
|
implements CommandResponder{// implements CommandResponder, extends Service
|
||||||
|
private static Logger logger = Logger.getLogger(TrapServer.class);
|
||||||
|
private static TrapServer ts = null;
|
||||||
|
public static TrapServer getInstance() throws IOException{
|
||||||
|
if(ts == null){
|
||||||
|
ts = new TrapServer();
|
||||||
|
logger.info("SNMP Trap Server 启动成功");
|
||||||
|
}else{
|
||||||
|
logger.info("SNMP TrapServer 已启动");
|
||||||
|
}
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrapServer() throws IOException{
|
||||||
|
ThreadPool threadPool = ThreadPool.create("Trap", Constants.SNMP_TRAP_THREAD_POOL_SIZE);
|
||||||
|
MultiThreadedMessageDispatcher dispatcher = new MultiThreadedMessageDispatcher(threadPool, new MessageDispatcherImpl());
|
||||||
|
Address listenAddress = GenericAddress.parse(System.getProperty("snmp4j.listenAddress", "udp:" + Common.getLocalIp() + "/" + Constants.SNMP_TRAP_PORT)); // 本地IP与监听端口
|
||||||
|
TransportMapping transport = null;
|
||||||
|
|
||||||
|
// 对TCP与UDP协议进行处理
|
||||||
|
if (listenAddress instanceof UdpAddress) {
|
||||||
|
transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
|
||||||
|
} else {
|
||||||
|
transport = new DefaultTcpTransportMapping((TcpAddress) listenAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
Snmp snmp = new Snmp(dispatcher, transport);
|
||||||
|
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
|
||||||
|
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
|
||||||
|
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3());
|
||||||
|
USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
|
||||||
|
SecurityModels.getInstance().addSecurityModel(usm);
|
||||||
|
snmp.listen();
|
||||||
|
snmp.addCommandResponder(this);
|
||||||
|
// OID authProtocol = getAuthProtocol(Constants.SNMP_V3_AUTH_PROTOCOL); //认证协议
|
||||||
|
// OID privProtocol = getPrivProtocol(Constants.SNMP_V3_PRIV_PROTOCOL); //加密协议
|
||||||
|
// OctetString securityName = new OctetString(Constants.SNMP_V3_SECURITY_NAME); //认证用户
|
||||||
|
// OctetString authPassphrase = new OctetString(Constants.SNMP_V3_AUTH_PASSPHRASE); //认证密码明文
|
||||||
|
// OctetString privPassphrase = new OctetString(Constants.SNMP_V3_PRIV_PASSPHRASE); //加密密码明文
|
||||||
|
// snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase,privProtocol, privPassphrase));
|
||||||
|
}
|
||||||
|
|
||||||
|
private OID getAuthProtocol(String auth){
|
||||||
|
if (auth.equals("MD5")) {
|
||||||
|
return AuthMD5.ID;
|
||||||
|
} else if (auth.equals("SHA")) {
|
||||||
|
return AuthSHA.ID;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OID getPrivProtocol(String priv){
|
||||||
|
if (priv.equals("DES")) {
|
||||||
|
return PrivDES.ID;
|
||||||
|
} else if ((priv.equals("AES128"))
|
||||||
|
|| (priv.equals("AES"))) {
|
||||||
|
return PrivAES128.ID;
|
||||||
|
} else if (priv.equals("AES192")) {
|
||||||
|
return PrivAES192.ID;
|
||||||
|
} else if (priv.equals("AES256")) {
|
||||||
|
return PrivAES256.ID;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现CommandResponder的processPdu方法, 用于处理传入的请求、PDU等信息 当接收到trap时,会自动进入这个方法
|
||||||
|
*
|
||||||
|
* @param respEvnt
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void processPdu(CommandResponderEvent commandresponderevent)
|
||||||
|
{
|
||||||
|
CommonDao dao = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dao = new CommonDao();
|
||||||
|
logger.debug((new StringBuilder("接收到snmp event:")).append(commandresponderevent.getPDU()).toString());
|
||||||
|
UdpAddress udpaddress = (UdpAddress)commandresponderevent.getPeerAddress();
|
||||||
|
String s = udpaddress.getInetAddress().getHostAddress();
|
||||||
|
PDU pdu = commandresponderevent.getPDU();
|
||||||
|
logger.debug((new StringBuilder("接收到TRap:")).append(pdu).toString());
|
||||||
|
TrapMessageInfo trapmessageinfo = new TrapMessageInfo();
|
||||||
|
trapmessageinfo.setAgentSendIP(s);
|
||||||
|
setOIDList(trapmessageinfo, pdu);
|
||||||
|
setValueList(trapmessageinfo, pdu);
|
||||||
|
trapmessageinfo.setOriginalPDU(pdu);
|
||||||
|
if (pdu instanceof PDUv1)
|
||||||
|
{
|
||||||
|
PDUv1 pduv1 = (PDUv1)pdu;
|
||||||
|
trapmessageinfo.setTrapVersion(1);
|
||||||
|
String s1 = pduv1.getEnterprise().toString();
|
||||||
|
trapmessageinfo.setTrapOID(s1);
|
||||||
|
String s2 = pduv1.getAgentAddress().toString();
|
||||||
|
trapmessageinfo.setPduAgentIP(s);
|
||||||
|
trapmessageinfo.setTrapV1SpecificType(pduv1.getSpecificTrap());
|
||||||
|
trapmessageinfo.setTrapV1GenericType(pduv1.getGenericTrap());
|
||||||
|
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
||||||
|
switch (pduv1.getGenericTrap())
|
||||||
|
{
|
||||||
|
case 0: // '\0'
|
||||||
|
// trapmessageinfo.setTrapName("设备冷启动");
|
||||||
|
// trapmessageinfo.setTrapName("Device Cold Start");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // '\001'
|
||||||
|
// trapmessageinfo.setTrapName("设备热启动");
|
||||||
|
// trapmessageinfo.setTrapName("Device Hot Start");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // '\002'
|
||||||
|
// trapmessageinfo.setTrapName("接口关闭");
|
||||||
|
// trapmessageinfo.setTrapName("The Interface Is Closed");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // '\003'
|
||||||
|
// trapmessageinfo.setTrapName("接口启用");
|
||||||
|
// trapmessageinfo.setTrapName("Interface Enabled");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4: // '\004'
|
||||||
|
// trapmessageinfo.setTrapName("SNMP认证失败");
|
||||||
|
// trapmessageinfo.setTrapName("SNMP Authentication Failed");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5: // '\005'
|
||||||
|
// trapmessageinfo.setTrapName("EGP邻居丢失");
|
||||||
|
// trapmessageinfo.setTrapName("EGP Neighbor Lost");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.egp_n81i");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
trapmessageinfo.setTrapVersion(2);
|
||||||
|
Variable variable = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapAddress.toString());
|
||||||
|
logger.debug("pdu.snmpTrapAddress() =-=-= "+variable);
|
||||||
|
if (variable != null)
|
||||||
|
trapmessageinfo.setPduAgentIP(variable.toString());
|
||||||
|
Variable variable1 = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapOID.toString());
|
||||||
|
if (variable1 != null)
|
||||||
|
trapmessageinfo.setTrapOID(variable1.toString());
|
||||||
|
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
||||||
|
if (variable1 != null)
|
||||||
|
if (variable1.equals(SnmpConstants.coldStart))
|
||||||
|
// trapmessageinfo.setTrapName("设备冷启动");
|
||||||
|
// trapmessageinfo.setTrapName("Device Cold Start");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
||||||
|
else
|
||||||
|
if (variable1.equals(SnmpConstants.warmStart))
|
||||||
|
// trapmessageinfo.setTrapName("设备热启动");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
||||||
|
else
|
||||||
|
if (variable1.equals(SnmpConstants.linkDown))
|
||||||
|
// trapmessageinfo.setTrapName("接口关闭");
|
||||||
|
// trapmessageinfo.setTrapName("The Interface Is Closed");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
||||||
|
else
|
||||||
|
if (variable1.equals(SnmpConstants.linkUp))
|
||||||
|
// trapmessageinfo.setTrapName("接口启用");
|
||||||
|
// trapmessageinfo.setTrapName("Interface Enabled");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
||||||
|
else
|
||||||
|
if (variable1.equals(SnmpConstants.authenticationFailure))
|
||||||
|
// trapmessageinfo.setTrapName("SNMP认证失败");
|
||||||
|
// trapmessageinfo.setTrapName("SNMP Authentication Failed");
|
||||||
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
||||||
|
else //系统默认的类别不能匹配时,再使用自定义的trap信息库。是否需要分别自定义snmpV1和snmpValue2的trap信息库(定义到文件或者定义到数据库,必须体统重新加载的界面接口)
|
||||||
|
if(getTrapName(variable1)!=null &&!variable1.equals("")){
|
||||||
|
trapmessageinfo.setTrapName(getTrapName(variable1));
|
||||||
|
}else{
|
||||||
|
// throw new Exception("未被定义的SNMPTRAP类型!");
|
||||||
|
throw new Exception("Undefined SNMPTRAP type!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuffer trapInfo = new StringBuffer();
|
||||||
|
trapInfo.append("trapmessageinfo.getTrapName():"+trapmessageinfo.getTrapName());
|
||||||
|
trapInfo.append(";trapmessageinfo.getAgentSendIP():"+trapmessageinfo.getAgentSendIP());
|
||||||
|
trapInfo.append(";trapmessageinfo.getOriginalPDU():"+trapmessageinfo.getOriginalPDU());
|
||||||
|
trapInfo.append(";trapmessageinfo.getTrapVersion():"+trapmessageinfo.getTrapVersion());
|
||||||
|
trapInfo.append(";trapmessageinfo.getTrapOID():"+trapmessageinfo.getTrapOID());
|
||||||
|
trapInfo.append(";trapmessageinfo.getPduAgentIP():"+trapmessageinfo.getPduAgentIP());
|
||||||
|
trapInfo.append(";trapmessageinfo.getTrapV1GenericType():"+trapmessageinfo.getTrapV1GenericType());
|
||||||
|
trapInfo.append(";trapmessageinfo.getTrapV1SpecificType():"+trapmessageinfo.getTrapV1SpecificType());
|
||||||
|
logger.debug("agent IP:"+s+" trap信息:"+trapInfo.toString());
|
||||||
|
new CommonService(dao).newClientCheck(s,trapmessageinfo.getTrapVersion());
|
||||||
|
SetInfo info = Common.getSnmpTrapSetInfo();
|
||||||
|
String [] dsb = Common.alarmExceptionInfo(info.getId(), s, info.getCheckTypeName(), info.getProcessIden(), trapmessageinfo.getReceiverTime().getTime(), 1,Constants.DETECTION_INFO_ALARM_WRONG, trapInfo.toString());
|
||||||
|
Common.addAlarmData(dsb);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
logger.debug((new StringBuilder("解析UDP TRAP发生错误:")).append(exception.getMessage()).toString());
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrapName(Variable variable1){
|
||||||
|
String trapName = "";
|
||||||
|
Map allTrapTypeDefine = new HashMap();
|
||||||
|
trapName = allTrapTypeDefine.get(variable1.toString()).toString();
|
||||||
|
return trapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setOIDList(TrapMessageInfo trapmessageinfo, PDU pdu)
|
||||||
|
{
|
||||||
|
Vector vector = pdu.getVariableBindings();
|
||||||
|
String s;
|
||||||
|
// for(int i=0;i<vector.size();i++){
|
||||||
|
// VariableBinding vbing = (VariableBinding)vector.elementAt(i);
|
||||||
|
// s = vbing.getOid().toString();
|
||||||
|
// trapmessageinfo.getTrapPDUOIDs().add(s);
|
||||||
|
// }
|
||||||
|
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDs().add(s))
|
||||||
|
{
|
||||||
|
VariableBinding variablebinding = (VariableBinding)iterator.next();
|
||||||
|
s = variablebinding.getOid().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValueList(TrapMessageInfo trapmessageinfo, PDU pdu)
|
||||||
|
{
|
||||||
|
Vector vector = pdu.getVariableBindings();
|
||||||
|
Variable variable;
|
||||||
|
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDValues().add(variable))
|
||||||
|
{
|
||||||
|
VariableBinding variablebinding = (VariableBinding)iterator.next();
|
||||||
|
variable = variablebinding.getVariable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public static void main(String[] args) {
|
||||||
|
TrapServer multithreadedtrapreceiver = new TrapServer();
|
||||||
|
multithreadedtrapreceiver.run();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
/**
|
||||||
|
* 解决snmp4j中文乱码问题
|
||||||
|
*/
|
||||||
|
public static String getChinese(String octetString) {
|
||||||
|
try {
|
||||||
|
String[] temps = octetString.split(":");
|
||||||
|
byte[] bs = new byte[temps.length];
|
||||||
|
for (int i = 0; i < temps.length; i++)
|
||||||
|
bs[i] = (byte) Integer.parseInt(temps[i], 16);
|
||||||
|
|
||||||
|
return new String(bs, "GB2312");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将十进六制转换成为中文
|
||||||
|
*//*
|
||||||
|
private static String hexString = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
public static String toStringHex(String bytes) {
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(
|
||||||
|
bytes.length() / 2);
|
||||||
|
//将每2位16进制整数组装成一个字节
|
||||||
|
for (int i = 0; i < bytes.length(); i += 2) {
|
||||||
|
baos.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString
|
||||||
|
.indexOf(bytes.charAt(i + 1))));
|
||||||
|
}
|
||||||
|
return new String(baos.toByteArray());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
protected static String printVariableBindings(PDU response) {
|
||||||
|
String strCom = "";
|
||||||
|
for (int i = 0; i < response.size(); i++) {
|
||||||
|
VariableBinding vb = response.get(i);
|
||||||
|
String[] str = vb.getVariable().toString().toUpperCase().split(":");
|
||||||
|
|
||||||
|
String strOut = "";
|
||||||
|
int intLength = str.length;
|
||||||
|
logger.debug("长度==> " + intLength);
|
||||||
|
for (int j = 0; j < intLength; j++) {
|
||||||
|
strOut += str[j];
|
||||||
|
}
|
||||||
|
strCom += vb.getVariable();
|
||||||
|
if (str.length != 1) {
|
||||||
|
logger.debug("==第行=vb.getVariable()=" + SNMP4JUtils.toStringHex(strOut));//显示中文
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strCom;
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void main(String [] args) {
|
||||||
|
try {
|
||||||
|
TrapServer.getInstance();
|
||||||
|
TrapServer.getInstance();
|
||||||
|
TrapServer.getInstance();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/com/nms/server/thread/DBTestThread.java
Normal file
40
src/com/nms/server/thread/DBTestThread.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时检查数据库连接是否可用
|
||||||
|
* @date May 7, 2013 2:31:50 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DBTestThread implements Runnable{
|
||||||
|
private Logger logger = Logger.getLogger(DBTestThread.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Thread.currentThread().setName("数据库连接监听线程");
|
||||||
|
Thread.currentThread().setName("Database Connection Listening Thread");
|
||||||
|
CommonDao dao = null;
|
||||||
|
try {
|
||||||
|
dao = new CommonDao();
|
||||||
|
Common.setDbConnectedFlag(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
/* 告警 */
|
||||||
|
Common.setDbConnectedFlag(false);
|
||||||
|
logger.error("Try to get a database connection failure", e);
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public static void main (String [] args) {
|
||||||
|
new Thread(new DBTestThread()).start();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
148
src/com/nms/server/thread/DetecDataCollectThread.java
Normal file
148
src/com/nms/server/thread/DetecDataCollectThread.java
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
import com.nms.server.service.CommonService;
|
||||||
|
import com.nms.server.thread.dataCollect.DataCollectManagerThread;
|
||||||
|
import com.nms.server.util.BoneCPPool;
|
||||||
|
|
||||||
|
public class DetecDataCollectThread implements Runnable{
|
||||||
|
private Logger logger = Logger.getLogger(DetecDataCollectThread.class);
|
||||||
|
|
||||||
|
public DetecDataCollectThread(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Thread.currentThread().setName("DC 数据收集管理线程 监测线程");
|
||||||
|
Thread.currentThread().setName("DC Data Collection And Management Thread Monitoring Thread");
|
||||||
|
|
||||||
|
Object rlt = null;
|
||||||
|
boolean isDone = false;
|
||||||
|
boolean isCancel = false;
|
||||||
|
Future<?> future = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
Thread.sleep(5000);
|
||||||
|
future = Common.getFutureMap().get(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
if(future!=null) {
|
||||||
|
isDone = future.isDone();
|
||||||
|
isCancel = future.isCancelled();
|
||||||
|
logger.info("DC已注册数据收集管理线程,isDone="+isDone+",isCancel="+isCancel);
|
||||||
|
rlt = future.get();
|
||||||
|
logger.info("DC数据收集管理线程执行完毕,结果:"+rlt);
|
||||||
|
}else {
|
||||||
|
logger.info("DC 未注册 数据收集管理 线程,开始注册。。。");
|
||||||
|
Common.addErrorInfoForMySelf(Constants.ERROR_CODE_DATA_COLLECT,Constants.ERROR_INFO_SATAE_ERROR,Constants.ERROR_DESC_DATA_COLLECT_NO_RUN);
|
||||||
|
|
||||||
|
//- DC端主动收集数据(监测数据、任务结果、回传文件)管理线程
|
||||||
|
if(Constants.FLAG_DATA_COLLECT==1) {
|
||||||
|
Thread.sleep(60000);
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DataCollectManagerThread(),0, Constants.DATA_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DATA_COLLECT_MANAGER, fcFuture);
|
||||||
|
logger.info("DC 数据收集管理 线程 注册成功");
|
||||||
|
Common.addErrorInfoForMySelf(Constants.ERROR_CODE_DATA_COLLECT,Constants.ERROR_INFO_SATAE_RIGHT_AUTO,Constants.ERROR_DESC_DATA_COLLECT_NO_RUN);
|
||||||
|
|
||||||
|
//单独起一个线程,监督数据收集线程是否运行
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECTI_DATA_COLLECT_THREAD_NAME);//取消其实是不起作用的?
|
||||||
|
Future<?> detecDataCollectFuture = Common.service.submit(new DetecDataCollectThread());
|
||||||
|
Common.registRunnable(Constants.DETECTI_DATA_COLLECT_THREAD_NAME, detecDataCollectFuture);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("DC data collection management thread monitoring thread exceptions, result:"+rlt,e);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Common.addErrorInfoForMySelf(Constants.ERROR_CODE_DATA_COLLECT,Constants.ERROR_INFO_SATAE_ERROR,Constants.ERROR_DESC_DATA_COLLECT);
|
||||||
|
|
||||||
|
//- DC端主动收集数据(监测数据、任务结果、回传文件)管理线程
|
||||||
|
if(future!=null) {
|
||||||
|
isDone = future.isDone();
|
||||||
|
isCancel = future.isCancelled();
|
||||||
|
logger.info("DC 数据收集管理线程 运行状态:isDone="+isDone+",isCancel="+isCancel);
|
||||||
|
}
|
||||||
|
if(Constants.FLAG_DATA_COLLECT==1 && future!=null && future.isDone()) {//已执行完毕
|
||||||
|
Thread.sleep(60000);
|
||||||
|
//注销线程
|
||||||
|
logger.info("DC 数据收集管理 线程 已执行完毕(异常导致),再次注册。。。");
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DataCollectManagerThread(),0, Constants.DATA_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DATA_COLLECT_MANAGER, fcFuture);
|
||||||
|
logger.info("DC 数据收集管理 线程 注册成功");
|
||||||
|
Common.addErrorInfoForMySelf(Constants.ERROR_CODE_DATA_COLLECT,Constants.ERROR_INFO_SATAE_RIGHT_AUTO,Constants.ERROR_DESC_DATA_COLLECT);
|
||||||
|
|
||||||
|
|
||||||
|
//单独起一个线程,监督数据收集线程是否运行
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECTI_DATA_COLLECT_THREAD_NAME);
|
||||||
|
Future<?> detecDataCollectFuture = Common.service.submit(new DetecDataCollectThread());
|
||||||
|
Common.registRunnable(Constants.DETECTI_DATA_COLLECT_THREAD_NAME, detecDataCollectFuture);
|
||||||
|
}
|
||||||
|
}catch(Exception ee) {
|
||||||
|
logger.error("DC data collection management thread is abnormal when registered again",ee);
|
||||||
|
}
|
||||||
|
|
||||||
|
}finally{
|
||||||
|
// try{
|
||||||
|
// //单独起一个线程,监督数据收集线程是否运行
|
||||||
|
// Common.cancelRunnableAtOnce(Constants.DETECTI_DATA_COLLECT_THREAD_NAME);
|
||||||
|
// Future<?> detecDataCollectFuture = Common.service.submit(new DetecDataCollectThread());
|
||||||
|
// Common.registRunnable(Constants.DETECTI_DATA_COLLECT_THREAD_NAME, detecDataCollectFuture);
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// logger.error("DC 数据收集管理线程 监测线程 注销 异常", e);
|
||||||
|
// }
|
||||||
|
logger.debug("DC 数据收集管理线程 监测线程 结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main (String []args){
|
||||||
|
try {
|
||||||
|
|
||||||
|
System.out.println(Long.MAX_VALUE/1000/60/60/24);
|
||||||
|
|
||||||
|
BoneCPPool.initPool();
|
||||||
|
CommonDao dao = new CommonDao();
|
||||||
|
CommonService service = new CommonService(dao);
|
||||||
|
|
||||||
|
// 初始化自身信息(失败情况下会由Web唤醒)
|
||||||
|
if(!service.initServerParams()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// //- DC端主动收集数据(监测数据、任务结果、回传文件)管理线程
|
||||||
|
if(Constants.FLAG_DATA_COLLECT==1) {
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DataCollectManagerThread(),0, Constants.DATA_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DATA_COLLECT_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// new Thread(new DetecDataCollectThread()).start();
|
||||||
|
//
|
||||||
|
// //- 错误信息(DC程序运行异常捕获报警)解析管理线程
|
||||||
|
// if(Constants.FLAG_ERROR_INFO==1){
|
||||||
|
// //注销线程
|
||||||
|
// Common.cancelRunnableAtOnce(Constants.ERROR_INFO_RESOVE_MANAGER);
|
||||||
|
// ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new ErrorInfoResoveManagerThread(), 0, 30, TimeUnit.SECONDS);
|
||||||
|
// //注册 管理线程
|
||||||
|
// Common.registRunnable(Constants.ERROR_INFO_RESOVE_MANAGER, fcFuture);
|
||||||
|
// }
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
115
src/com/nms/server/thread/DetecSelfThread.java
Normal file
115
src/com/nms/server/thread/DetecSelfThread.java
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
|
||||||
|
public class DetecSelfThread implements Runnable{
|
||||||
|
private Logger logger = Logger.getLogger(DetecSelfThread.class);
|
||||||
|
|
||||||
|
public DetecSelfThread(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Thread.currentThread().setName("DC 性能监测线程");
|
||||||
|
Thread.currentThread().setName("DC Performance Monitoring Thread");
|
||||||
|
|
||||||
|
CommonDao dao = null;
|
||||||
|
try {
|
||||||
|
// dao = new CommonDao();
|
||||||
|
if(Constants.sslServer==null) {
|
||||||
|
logger.info("DC监听端口状况(60702):sslServer=null");
|
||||||
|
}else {
|
||||||
|
logger.info("DC监听端口状况(60702):isBind="+Constants.sslServer.isBound());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<?> future = Common.getFutureMap().get(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
Future<?> futureDetect = Common.getFutureMap().get(Constants.DETECTI_DATA_COLLECT_THREAD_NAME);
|
||||||
|
if(future!=null) {
|
||||||
|
boolean isDone = future.isDone();
|
||||||
|
boolean isCancel = future.isCancelled();
|
||||||
|
logger.info("DC已注册数据收集管理线程,isDone="+isDone+",isCancel="+isCancel);
|
||||||
|
}else {
|
||||||
|
logger.info("DC未注册数据收集管理线程");
|
||||||
|
}
|
||||||
|
if(futureDetect!=null) {
|
||||||
|
logger.info("DC 数据收集管理线程 监测线程 运行中,isDone="+futureDetect.isDone()+",isCancel="+futureDetect.isCancelled());
|
||||||
|
}else {
|
||||||
|
logger.info("DC 数据收集管理线程 监测线程 未启动");
|
||||||
|
}
|
||||||
|
long freeMemory = Runtime.getRuntime().freeMemory()/1024/1024;
|
||||||
|
long totalMemory = Runtime.getRuntime().totalMemory()/1024/1024;
|
||||||
|
long maxMemory = Runtime.getRuntime().maxMemory()/1024/1024;
|
||||||
|
long usedMemory = totalMemory - freeMemory;
|
||||||
|
int activeCount = Thread.activeCount();//活跃线程数
|
||||||
|
logger.debug("内存使用情况:total-> " + totalMemory +" MB, used -> "+ usedMemory +" MB, max -> " + maxMemory+" MB, free -> " + freeMemory+" MB \r\n 活跃线程数: "+ activeCount);
|
||||||
|
Common.detecSelf();
|
||||||
|
if(logger.isDebugEnabled() && "druid".equalsIgnoreCase(Constants.DB_POOL_TYPE)){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// int [] links = getDBLinkSize(dao);
|
||||||
|
/* 查询当前DC,数据库连接数 */
|
||||||
|
// logger.debug("当前数据库连接数:"+links[0]+" 活动连接数:"+links[1]);
|
||||||
|
// System.gc();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Monitoring their own thread abnormality",e);
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
logger.debug("结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main (String []args){
|
||||||
|
new Thread(new DetecSelfThread()).start();
|
||||||
|
/*Map<String, String> map = System.getenv();
|
||||||
|
pl("用户名称"+map.get("USERNAME"));
|
||||||
|
pl("计算机名称"+map.get("COMPUTERNAME"));
|
||||||
|
pl(""+map.get("USEROOMAIN"));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前DC的数据库连接数
|
||||||
|
* @time Jan 13, 2013-4:25:03 PM
|
||||||
|
* @param dao
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int[] getDBLinkSize(CommonDao dao) throws Exception{
|
||||||
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
|
fields.add("dbLinks");
|
||||||
|
fields.add("activeLinks");
|
||||||
|
// Map<String, String> map = System.getenv();
|
||||||
|
String dbLinkSizeSql = "select count(1) dbLinks,count(decode(status,'ACTIVE',1,0,0)) activeLinks from v$session t where lower(username) =lower(?) and lower(t.MACHINE) = lower(?)";
|
||||||
|
String dbUserName = Constants.DB_USER_NAME;
|
||||||
|
// String computerName = map.get("COMPUTERNAME");
|
||||||
|
String computerName = InetAddress.getLocalHost().getHostName();
|
||||||
|
logger.debug("计算机名称:"+computerName);
|
||||||
|
// logger.debug("计算机名称:"+name);
|
||||||
|
ArrayList<Map<String, String>> data = dao.dbSelect(dbLinkSizeSql, fields,dbUserName,computerName);
|
||||||
|
if(data!= null && data.size()>0){
|
||||||
|
String val = data.get(0).get("dbLinks");
|
||||||
|
String val2 = data.get(0).get("activeLinks");
|
||||||
|
return new int[]{val == null ? -1 : Integer.parseInt(val),val2 == null ? -1 : Integer.parseInt(val2)};
|
||||||
|
}else{
|
||||||
|
return new int[]{-1,-1};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pl(Object obj) {
|
||||||
|
System.out.println(obj==null?null:obj.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/com/nms/server/thread/GetLocalIpFromWeb.java
Normal file
25
src/com/nms/server/thread/GetLocalIpFromWeb.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import com.nms.server.util.socket.SSLSocketCallable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过通讯获取本机IP(暂未使用)
|
||||||
|
* @date Mar 14, 2013 5:23:58 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GetLocalIpFromWeb extends SSLSocketCallable{
|
||||||
|
|
||||||
|
|
||||||
|
public GetLocalIpFromWeb(String ip, Integer port) throws Exception {
|
||||||
|
super(ip, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object toDo() throws Exception {
|
||||||
|
Thread.currentThread().setName("Get The IP Thread");
|
||||||
|
this.sendMessage("char:getLocalIp");
|
||||||
|
String lIp = this.receiveMessage();
|
||||||
|
this.sendMessage(SUCCESS);
|
||||||
|
return lIp;
|
||||||
|
}
|
||||||
|
}
|
||||||
491
src/com/nms/server/thread/InitServerThread.java
Normal file
491
src/com/nms/server/thread/InitServerThread.java
Normal file
@@ -0,0 +1,491 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.bean.ServerTable;
|
||||||
|
import com.nms.server.bean.SetInfo;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
import com.nms.server.service.CommonService;
|
||||||
|
import com.nms.server.service.ThreadService;
|
||||||
|
import com.nms.server.service.UpgradeService;
|
||||||
|
import com.nms.server.snmp.trap.TrapServer;
|
||||||
|
import com.nms.server.thread.alarmData.AlarmDataResoveManagerThread;
|
||||||
|
import com.nms.server.thread.change.ChangeManagerThread;
|
||||||
|
import com.nms.server.thread.dataCollect.DataCollectManagerThread;
|
||||||
|
import com.nms.server.thread.dataCollect.NoDetectDataCollectManagerThread;
|
||||||
|
import com.nms.server.thread.dataCollect.NonRltTaskResultCollectManagerThread;
|
||||||
|
import com.nms.server.thread.deleteFiles.DeleteFilesManagerThread;
|
||||||
|
import com.nms.server.thread.detecData.DetecDataResoveManagerThread;
|
||||||
|
import com.nms.server.thread.detectDataHandler.DataInsertManagerThread;
|
||||||
|
import com.nms.server.thread.detectDataHandler.DataResolveThread;
|
||||||
|
import com.nms.server.thread.detectDataHandler.DetectInfoInsertThread;
|
||||||
|
import com.nms.server.thread.email.RefreshEmailFlagThread;
|
||||||
|
import com.nms.server.thread.errorinfo.ErrorInfoResoveManagerThread;
|
||||||
|
import com.nms.server.thread.file.UnZipManagerThread;
|
||||||
|
import com.nms.server.thread.file.upload.FileUploadManagerThread;
|
||||||
|
import com.nms.server.thread.mission.InitRunningMissionThread;
|
||||||
|
import com.nms.server.thread.mission.LoadNewMissionThread;
|
||||||
|
import com.nms.server.thread.mission.MissionResultManagerThread;
|
||||||
|
import com.nms.server.thread.overrunData.DataFileReaderManagerThread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DC初始化启动线程
|
||||||
|
* 初始化流程
|
||||||
|
* 1、初始化数据库连接,加载DC自身信息
|
||||||
|
* 2、初始化本地目录信息,公共缓存信息
|
||||||
|
* 3、启动各解析线程
|
||||||
|
* 4、启动任务和主动监测现成
|
||||||
|
* 5、启动SNMP TRAP端口
|
||||||
|
* 6、变更启动标示
|
||||||
|
* @date Mar 27, 2013 2:47:31 PM
|
||||||
|
* @author ZhangGang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class InitServerThread implements Runnable{
|
||||||
|
private Logger logger = Logger.getLogger(InitServerThread.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
// Thread.currentThread().setName("初始化线程");
|
||||||
|
Thread.currentThread().setName("Initialization thread");
|
||||||
|
|
||||||
|
CommonDao dao = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 连接数据库
|
||||||
|
dao = new CommonDao();
|
||||||
|
CommonService service = new CommonService(dao);
|
||||||
|
|
||||||
|
// 初始化自身信息(失败情况下会由Web唤醒)
|
||||||
|
if(!service.initServerParams()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据初始化成功标示,初始化DC实际操作信息
|
||||||
|
if(!Constants.flag_init){
|
||||||
|
|
||||||
|
//- 目录及缓存信息(监测类型和表、数据字段、告警、ip主机映射等)
|
||||||
|
initCommonInfo(dao);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//- 启动SNMP监测服务端口
|
||||||
|
Common.getSnmp().addCommandResponder(TrapServer.getInstance());
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.error("Start the SNMP monitoring service port exception", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 监测数据解析
|
||||||
|
if(Constants.FLAG_DETEC_RESOVE==1){
|
||||||
|
if(Constants.DETECT_INSERT_THREAD_MODE == 1){//单线程
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETEC_DATA_RESOVE_MANAGER);
|
||||||
|
int delay = 0;//管理线程延时多久启动
|
||||||
|
Date dbNow = service.getDbTime();
|
||||||
|
long dbLong = dbNow.getTime();
|
||||||
|
int period = Constants.DETEC_DATA_RESOLVE_PERIOD*1000;//周期:ms
|
||||||
|
ServerTable st = Common.getServerTable();
|
||||||
|
int count = st.getConut();
|
||||||
|
int index = st.getIndex();
|
||||||
|
int cst = (index-1) *period/count;//当前dc 的时间窗口 开始时间
|
||||||
|
int pass = (int) (dbLong%period);
|
||||||
|
|
||||||
|
if(cst >= pass){
|
||||||
|
delay = cst - pass;
|
||||||
|
}else{
|
||||||
|
delay = period -pass + cst;
|
||||||
|
}
|
||||||
|
logger.debug("共 "+count+" 个 有效DC,当前DC index : "+ index+", 数据库当前时间 :" + dbNow.toLocaleString() +" ,DETEC_DATA_RESOLVE_PERIOD :" + Constants.DETEC_DATA_RESOLVE_PERIOD +" s , 监测数据解析入库管理线程延迟:" + delay +" ms 启动");
|
||||||
|
/**
|
||||||
|
* 解析线程scheduleWithFixedDelay不能修改为scheduleAtFixedRate是因为:解析管理线程很快就会执行完毕,不会像收集线程,需要等待节点收集完毕,
|
||||||
|
* 而且解析线程会尝试5次,如果都在解析,则会将数据存入硬盘,如果改了,那么解析的周期就更短了,因为管理线程几乎用不了1秒就执行完了,
|
||||||
|
* 这样解析线程就只有5秒左右的执行时间,会有大问题的(解析线程需要延长时间,收集线程需要缩短时间)
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 2018年6月14日14:34:49 修改 根据dc 个数固定 管理线层启动 时间窗口,分散一下dc 入库时间,固定周期时间启动
|
||||||
|
*/
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleAtFixedRate(new DetecDataResoveManagerThread(), delay, period, TimeUnit.MILLISECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DETEC_DATA_RESOVE_MANAGER, fcFuture);
|
||||||
|
}else if(Constants.DETECT_INSERT_THREAD_MODE == 2){//多线程,info表一个线程,其它每个监测详细信息表一个线程共用一个线程池
|
||||||
|
int im = Constants.DETECT_INFO_THREAD_MODE;
|
||||||
|
int it = Constants.DETECT_INFO_THREAD_TIME;
|
||||||
|
int id = Constants.DETECT_INFO_THREAD_DELAY;
|
||||||
|
int dm = Constants.DETECT_DETAIL_THREAD_MODE;
|
||||||
|
int dt = Constants.DETECT_DETAIL_THREAD_TIME;
|
||||||
|
int dd = Constants.DETECT_DETAIL_THREAD_DELAY;
|
||||||
|
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECT_INFO_THREAD_KEY);
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECT_DETAIL_THREAD_KEY);
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECT_RESOVE_THREAD_KEY);
|
||||||
|
|
||||||
|
//info入库线程运行模式,1:每隔 n秒 运行一次,2:间隔 n 秒运行一次
|
||||||
|
if(im == 1){
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleAtFixedRate(new DetectInfoInsertThread(), id, it, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DETECT_INFO_THREAD_KEY, fcFuture);
|
||||||
|
}else{
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DetectInfoInsertThread(), id, it, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DETECT_INFO_THREAD_KEY, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dm == 1){
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleAtFixedRate(new DataInsertManagerThread(), dd, dt, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DETECT_DETAIL_THREAD_KEY, fcFuture);
|
||||||
|
}else{
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DataInsertManagerThread(), dd, dt, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DETECT_DETAIL_THREAD_KEY, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<?> future = Common.service.submit(new DataResolveThread());
|
||||||
|
Common.registRunnable(Constants.DETECT_RESOVE_THREAD_KEY, future);
|
||||||
|
}else{
|
||||||
|
logger.error("detect.insert.thread.mode = " + Constants.DETECT_INSERT_THREAD_MODE +" is error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 错误信息(DC程序运行异常捕获报警)解析管理线程
|
||||||
|
if(Constants.FLAG_ERROR_INFO==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.ERROR_INFO_RESOVE_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new ErrorInfoResoveManagerThread(), 0, Constants.ERROR_INFO_RESOVE_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.ERROR_INFO_RESOVE_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 告警数据解析管理线程
|
||||||
|
if(Constants.FLAG_ALARM_RESOVE==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.ALARM_DATA_RESOVE_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new AlarmDataResoveManagerThread(), 0, Constants.DETEC_DATA_RESOLVE_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.ALARM_DATA_RESOVE_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-硬盘数据(监测数据、告警数据、任务结果:由于数据量过大,暂时无法入库,而存放在硬盘上的数据)解析入库管理线程
|
||||||
|
if(Constants.FLAG_FILES_READER_RESOVE==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.OVERRUN_DATA_RESOVE_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DataFileReaderManagerThread(), 0, Constants.DISK_DATA_RESOLVE_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.OVERRUN_DATA_RESOVE_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- DC端主动收集数据(监测数据、任务结果、回传文件)管理线程
|
||||||
|
if(Constants.FLAG_DATA_COLLECT==1) {
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DATA_COLLECT_MANAGER);
|
||||||
|
/**
|
||||||
|
* 收集线程scheduleWithFixedDelay修改为scheduleAtFixedRate是因为:
|
||||||
|
* scheduleWithFixedDelay:等待线程执行完毕,还会再等待指定的周期时间
|
||||||
|
* scheduleAtFixedRate:为了节省时间,且线程执行完毕
|
||||||
|
* 1.线程执行时间大于周期间隔,则直接执行下一周期
|
||||||
|
* 2.线程执行时间小于周期间隔,则两次线程开始执行时间点的间隔就是设定的周期
|
||||||
|
*
|
||||||
|
* (解析线程需要延长时间,收集线程需要缩短时间)
|
||||||
|
*/
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleAtFixedRate(new DataCollectManagerThread(),0, Constants.DATA_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DATA_COLLECT_MANAGER, fcFuture);
|
||||||
|
|
||||||
|
Common.cancelRunnableAtOnce(Constants.NO_DETECT_DATA_NODE_DATA_COLLECT_MANAGER);
|
||||||
|
ScheduledFuture<?> enFuture = Common.scheduled.scheduleAtFixedRate(new NoDetectDataCollectManagerThread(),0, Constants.ERROR_NODE_DATA_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
Common.registRunnable(Constants.NO_DETECT_DATA_NODE_DATA_COLLECT_MANAGER, enFuture);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 定时的刷新是否启用邮件发送功能:从数据库读取配置
|
||||||
|
if(Constants.FLAG_EMAIL_START==1) {
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.EMAIL_START_THREAD);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new RefreshEmailFlagThread(),0, Constants.REFRESH_EMAIL_FLAG_PEROID, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.EMAIL_START_THREAD, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
//定时删除log线程
|
||||||
|
if(Constants.FLAG_DELETE_TMP_FILES==1) {
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DELETE_TMP_FILES_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new DeleteFilesManagerThread(),0, Constants.DELETE_TMP_FILES_PERIOD, TimeUnit.HOURS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.DELETE_TMP_FILES_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//DC端定时的去收集执行完成但无任务结果返回的任务的结果信息
|
||||||
|
if(Constants.FLAG_NONRLTTASK_RESULT_COLLECT==1) {
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new NonRltTaskResultCollectManagerThread(),0, Constants.NONRLTTASK_RESULT_COLLECT_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.NONRLTTASK_RESULT_COLLECT_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- 文件上传管理线程
|
||||||
|
if(Constants.FLAG_FILE_UPLOAD==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.MISSION_FILE_UPLOAD);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new FileUploadManagerThread(), 0, Constants.MISSION_FILE_UPLOAD_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.MISSION_FILE_UPLOAD, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 变更操作管理线程
|
||||||
|
if(Constants.FLAG_CHANGE_OPERATIONS==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.CHANGE_OPERATIONS_MANAGER);
|
||||||
|
ScheduledFuture<?> fcFuture = Common.scheduled.scheduleWithFixedDelay(new ChangeManagerThread(), 0, Constants.CHANGE_OPERATIONS_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.CHANGE_OPERATIONS_MANAGER, fcFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- 任务初始化分配和任务线程启动
|
||||||
|
if(Constants.FLAG_MISSION==1){
|
||||||
|
//-- 启动已执行任务加载线程
|
||||||
|
Common.scheduled.schedule(new InitRunningMissionThread(null),Constants.MISSION_FIRST_START, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
//-- 启动已创建任务加载线程
|
||||||
|
Common.scheduled.scheduleWithFixedDelay(new LoadNewMissionThread(null), Constants.MISSION_CHECK_NEW_START, Constants.MISSION_CHECK_NEW_PERIOD, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
//启动任务结果管理线程
|
||||||
|
if(Constants.FLAG_MISSION_RESULT==1){
|
||||||
|
//注销线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.MISSION_RESULT_RESOVE_MANAGER);
|
||||||
|
//logger.debug(Constants.MISSION_RESULTS_SAVE_START+" -- "+Constants.MISSION_RESULTS_SAVE_PERIOD);
|
||||||
|
ScheduledFuture<?> mrFuture = Common.scheduled.scheduleWithFixedDelay(new MissionResultManagerThread(),Constants.MISSION_RESULTS_SAVE_START, Constants.MISSION_RESULTS_SAVE_PERIOD, TimeUnit.SECONDS);
|
||||||
|
//注册 管理线程
|
||||||
|
Common.registRunnable(Constants.MISSION_RESULT_RESOVE_MANAGER, mrFuture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//服务端NMSC监测任务添加--一种监测--此处的握手监测仅为非服务器的握手监测
|
||||||
|
if(Constants.FLAG_NMSC==1){
|
||||||
|
initDrivingDetectionThread(dao,Constants.DETEC_NMSC_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//服务端SNMP监测任务添加-system,snmp4j,objectsnmp:特设的电源、风扇、网元系统信息等?---snmp类型的监测,多个
|
||||||
|
if(Constants.FLAG_SNMP==1){
|
||||||
|
initDrivingDetectionThread(dao,Constants.DETEC_SNMP_STR);
|
||||||
|
}
|
||||||
|
//服务端PING监测任务添加--一种监测
|
||||||
|
if(Constants.FLAG_PING==1){
|
||||||
|
initDrivingDetectionThread(dao,Constants.DETEC_PING_STR);
|
||||||
|
}
|
||||||
|
//服务端SWITCH监测任务添加-交换机、特种设备:端口流量监测等--一种监测
|
||||||
|
if(Constants.FLAG_SWITCH==1){
|
||||||
|
initDrivingDetectionThread(dao,Constants.DETEC_SWITCH_STR);
|
||||||
|
}
|
||||||
|
//服务端SYSTEMDATE监测任务添加--一种监测
|
||||||
|
if(Constants.FLAG_SYSTEMDATE==1){
|
||||||
|
initDrivingDetectionThread(dao,Constants.DETEC_SYSTEMDATE_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//压缩文件解压操作
|
||||||
|
if(Constants.FLAG_ZIP==1){
|
||||||
|
//启动时,执行一次压缩文件解压操作
|
||||||
|
Common.service.submit(new UnZipManagerThread());
|
||||||
|
}
|
||||||
|
if(Constants.DETECSELFTHREAD_FLAG){
|
||||||
|
//缓存数据量监测线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECTI_SELF_THREAD_NAME);
|
||||||
|
ScheduledFuture<?> dsFuture = Common.dcPrivScheduled.scheduleAtFixedRate(new DetecSelfThread(),Constants.DETECSELFTHREAD_INITIALDELAY,Constants.DETECSELFTHREAD_PERIOD,TimeUnit.SECONDS);
|
||||||
|
Common.registRunnable(Constants.DETECTI_SELF_THREAD_NAME, dsFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//单独起一个线程,监督数据收集线程是否运行:放在收集数据线程之后即可
|
||||||
|
if(Constants.FLAG_DATA_COLLECT==1) {
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DETECTI_DATA_COLLECT_THREAD_NAME);
|
||||||
|
Future<?> detecDataCollectFuture = Common.service.submit(new DetecDataCollectThread());
|
||||||
|
Common.registRunnable(Constants.DETECTI_DATA_COLLECT_THREAD_NAME, detecDataCollectFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//DC缓存信息定时刷新功能
|
||||||
|
Common.cancelRunnableAtOnce(Constants.RESET_SERVER_THREAD_NAME);
|
||||||
|
ScheduledFuture<?> rsFuture = Common.dcPrivScheduled.scheduleAtFixedRate(new ResetServerThread(-1),8,8,TimeUnit.HOURS);
|
||||||
|
Common.registRunnable(Constants.RESET_SERVER_THREAD_NAME, rsFuture);
|
||||||
|
|
||||||
|
//数据库连接监听线程
|
||||||
|
Common.cancelRunnableAtOnce(Constants.DB_CONNECTION_THREAD_NAME);
|
||||||
|
ScheduledFuture<?> dbcFuture = Common.dcPrivScheduled.scheduleAtFixedRate(new DBTestThread(),3,3,TimeUnit.MINUTES);
|
||||||
|
Common.registRunnable(Constants.DB_CONNECTION_THREAD_NAME, dbcFuture);
|
||||||
|
|
||||||
|
logger.info("------- DataController Start Success------------");
|
||||||
|
Constants.flag_init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("Failed to get database connection, execute again in 5 minutes"+ e.getMessage());
|
||||||
|
Common.scheduled.schedule(this, 5, TimeUnit.MINUTES);
|
||||||
|
Common.addErrorInfoForMySelf(Constants.ERROR_CODE_DB_CONNECT,Constants.ERROR_INFO_SATAE_ERROR,"");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("DataController initialization failure",e);
|
||||||
|
Common.scheduled.schedule(this, 5, TimeUnit.MINUTES);
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
logger.debug("启动程序dao已关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化主动监测线程
|
||||||
|
* @time Sep 20, 2011-7:07:36 PM
|
||||||
|
* @param dao
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean initDrivingDetectionThread(CommonDao dao,String checkType){
|
||||||
|
|
||||||
|
boolean isSuccess = true;
|
||||||
|
CommonService commonService = new CommonService(dao);
|
||||||
|
ThreadService service = new ThreadService();
|
||||||
|
//--获取checkType 监测配置并启动监测任务
|
||||||
|
List<SetInfo> setList = commonService.getDrivingSetInfo(checkType);//获得checkType类型的所有监测设置
|
||||||
|
logger.info("检查主动监测类别:"+checkType+" 关联监测设置:"+(setList==null?0:setList.size())+"个");
|
||||||
|
//-- checkType 监测任务启动 和 客户端启动监测任务启动
|
||||||
|
if(setList!=null && setList.size()>0){
|
||||||
|
for (Iterator setIte = setList.iterator(); setIte.hasNext();) {
|
||||||
|
SetInfo si = (SetInfo) setIte.next();
|
||||||
|
if(Constants.DETEC_SNMP_STR.equalsIgnoreCase(checkType)){
|
||||||
|
if(Constants.DETEC_SWITCH_STR.equalsIgnoreCase(si.getCheckTypeName())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service.updateThread(si);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化公共信息方法
|
||||||
|
* <p>Common类中的公共数据集合,在此方法中进行数据初始化</p>
|
||||||
|
* Init server
|
||||||
|
* @time Aug 24, 2011-9:55:44 AM
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean initCommonInfo(CommonDao dao) {
|
||||||
|
initCheck();
|
||||||
|
boolean flag = true;
|
||||||
|
|
||||||
|
CommonService service = new CommonService(dao);
|
||||||
|
UpgradeService upService = new UpgradeService(dao);
|
||||||
|
try{
|
||||||
|
//-- 从数据库中查询邮件创建信息
|
||||||
|
Constants.flag_email = service.getFlagEmail();
|
||||||
|
//-- checkTypeName TableModel Map Init(监测类别名称 与 检测类别信息)
|
||||||
|
service.updateCheckTableInfo(Common.getInsertTable(), null);
|
||||||
|
service.updateSetInfoName(Common.getSetInfoNameMape(), null);
|
||||||
|
//-- Table Columns Map Init(数据库表结构信息)
|
||||||
|
service.updateTableColumnsMap(Common.getTableMap(), null);
|
||||||
|
|
||||||
|
//alarm Ping Init(告警数据结构信息)
|
||||||
|
service.updateAlarmInfo(Common.getAlarmInfoMap(),null);
|
||||||
|
|
||||||
|
//-- LoginIp nodeip Init(seq_id-物理节点信息)
|
||||||
|
service.updateSimpleNodeByUUID(null);
|
||||||
|
|
||||||
|
//--(ClientIP-seq_id信息)
|
||||||
|
service.updateSeqIdByNodeIp(Common.getIpSeqIdMap(),null);
|
||||||
|
|
||||||
|
service.updateUserPwdByNodeIp(Common.getIpUserPwdMap(),null);
|
||||||
|
|
||||||
|
// init loop Mission info
|
||||||
|
upService.updateLoopMissionInfo(Common.getLoopMissionInfoMap(), null);
|
||||||
|
upService.updateLoopMissionRoundInfo(Common.getLoopMissionRoundInfoList(), null);
|
||||||
|
|
||||||
|
// init detection info
|
||||||
|
List<SetInfo> siList = service.getDrivingSetInfo(Constants.ALARM_SNMP_TRAP_STR);
|
||||||
|
if(siList !=null && siList.size()>0){
|
||||||
|
Common.setSnmpTrapSetInfo(siList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.debug("NMSServer参数初始化失败", e);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 程序启动时校验操作
|
||||||
|
* <p>必要文件目录的存在校验操作、及相关必要存在校验操作</p>
|
||||||
|
* @time Aug 24, 2011-10:14:35 AM
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void initCheck() {
|
||||||
|
|
||||||
|
File file = new File(Constants.MISSION_FILE_UPLOAD_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.MISSION_FILE_DOWNLOAD_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_FILE_DETECT_DATA_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_FILE_TASK_RESULT_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_FILE_TASK_RETURN_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_RESOVE_DETECT_DATA_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_RESOVE_TASK_RESULT_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
file = new File(Constants.ZIP_RESOVE_TASK_RESULT_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new File(Constants.ZIP_RESOVE_TASK_RETURN_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
file = new File(Constants.ERROR_DETEC_FILE_DIR);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/com/nms/server/thread/ResetServerThread.java
Normal file
106
src/com/nms/server/thread/ResetServerThread.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package com.nms.server.thread;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.nms.server.common.Common;
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
import com.nms.server.dao.CommonDao;
|
||||||
|
import com.nms.server.service.ChangeService;
|
||||||
|
import com.nms.server.util.CommandExecUtil;
|
||||||
|
|
||||||
|
public class ResetServerThread implements Runnable{
|
||||||
|
private Logger logger = Logger.getLogger(ResetServerThread.class);
|
||||||
|
private Integer model = -1; //缺省为-1
|
||||||
|
|
||||||
|
public ResetServerThread(Integer model){
|
||||||
|
this.model = model==null?this.model:model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
// Thread.currentThread().setName("程序整理线程");
|
||||||
|
Thread.currentThread().setName("Program Manage Thread");
|
||||||
|
CommonDao dao = null;
|
||||||
|
try {
|
||||||
|
dao = new CommonDao();
|
||||||
|
ChangeService service = new ChangeService(dao);
|
||||||
|
switch (model) {
|
||||||
|
case 1: //更新自身参数信息
|
||||||
|
//NMSServer参数获取失败后,结束程序初始化
|
||||||
|
|
||||||
|
//- 系统信息初始化(监测类型和表、数据字段、告警、ip主机映射等)
|
||||||
|
if(!Constants.flag_init){//新安装DC:DC没在web的管理范围内,初始化失败
|
||||||
|
logger.info("启动失败,再次启动");
|
||||||
|
Common.service.submit(new InitServerThread());
|
||||||
|
}else{
|
||||||
|
logger.info("启动成功,仅更新参数");
|
||||||
|
service.initServerParams();//web端修改DC信息(管理范围修改)时执行
|
||||||
|
new InitServerThread().initCommonInfo(dao);
|
||||||
|
logger.info("参数更新完成");
|
||||||
|
}
|
||||||
|
/*业务重新梳理
|
||||||
|
* List<NodeModel> list = service.getAllEffectiveNodeInfo();
|
||||||
|
if(list!= null && list.size()>0){
|
||||||
|
Iterator<NodeModel> ite = list.iterator();
|
||||||
|
while(ite.hasNext()){
|
||||||
|
NodeModel model = ite.next();
|
||||||
|
Common.runChangeRunnable(new SSLClient(model.getNodeIp(), Constants.SSL_CLIENT_PORT,"char:reInit","init"));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
break;
|
||||||
|
// case 2://重启DC
|
||||||
|
// String os = System.getProperty("os.name");
|
||||||
|
// if (os.startsWith("Windows")) {//重启服务
|
||||||
|
//// String path = new File(Constants.SYSTEM_PATH).getParent()+File.separator+Constants.COMMON_TEMP_DIR+File.separator+Constants.COMMON_RUNTIME_PID_FILE;
|
||||||
|
//// String processName = "DataController.exe";
|
||||||
|
//// String path = System.getProperty("user.dir")+"/"+processName;
|
||||||
|
//// String serverName = "DataController";
|
||||||
|
//
|
||||||
|
// logger.info("web端超周期无监测数据,开始开始重启DC。。。");
|
||||||
|
//
|
||||||
|
// //不行------自己把自己杀了,就没法把自己重启了
|
||||||
|
//// if(!CommandExecUtil.killProcess(processName)){/* 删除已存在的进程 */
|
||||||
|
//// logger.info("程序停止失败");
|
||||||
|
//// }else if(CommandExecUtil.processRunningCheck(processName)){/* 校验程序是否已停止 */
|
||||||
|
//// logger.info("程序停止失败,请手动关闭进程["+processName+"]");
|
||||||
|
//// }else if(!CommandExecUtil.startNetService(serverName)){/* 启动进程 */
|
||||||
|
//// logger.info("程序启动失败");
|
||||||
|
//// }else if(CommandExecUtil.processRunningCheck(processName)){/* 校验程序是否已启动 */
|
||||||
|
//// logger.info("程序启动成功");
|
||||||
|
//// }else{
|
||||||
|
//// logger.info("程序启动失败");
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// } else if (os.startsWith("Linux")) {//执行restart.sh脚本
|
||||||
|
// String path = new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath()+"/shell/restart.sh";
|
||||||
|
// logger.info("linux下,重启DC的restart.sh脚本路径为:"+path+",开始重启DC。。。");
|
||||||
|
// CommandExecUtil.execLinuxCmd(path);
|
||||||
|
// } else {
|
||||||
|
// throw new IOException("unknown operating system: " + os);
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
case -1: //预留操作
|
||||||
|
//执行系统清理 (监测结果集合、任务结果集合、重启线程池,重启通讯)
|
||||||
|
System.gc();
|
||||||
|
service.deleteEventRecordOldInfo();//超过4天的变更就删除:NC没启动,就一直执行不成功;(或者给服务器节点发送只有交换机才有的)
|
||||||
|
logger.info("执行gc操作");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.warn("Indeterminate mode parameter, no operation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("NmsServer initialization failure",e);
|
||||||
|
}finally{
|
||||||
|
if(dao!=null){
|
||||||
|
dao.close();
|
||||||
|
dao=null;
|
||||||
|
}
|
||||||
|
logger.debug("启动程序dao已关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user