From 569c9423b7842668ec55bf345301ab6b78ddd6a0 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Wed, 24 Jan 2018 18:26:53 +0800 Subject: [PATCH 01/97] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E7=89=88=E6=9C=ACHM=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bin/start_hm_apmserver.sh | 2 + .../bin/start_hm_apphubmgr.sh | 2 + .../bin/start_hm_hbserver.sh | 2 + .../bin/start_hm_logserver.sh | 2 + .../bin/start_hm_moserver.sh | 2 + .../bin/start_hm_nodeserver.sh | 2 + .../bin/start_hm_pfntfyserver.sh | 2 + .../bin/start_hm_pnhbserver.sh | 2 + .../bin/start_hm_pro_apmserver.sh | 2 - .../bin/start_hm_pro_apphubmgr.sh | 2 - .../bin/start_hm_pro_hbserver.sh | 2 - .../bin/start_hm_pro_logserver.sh | 2 - .../bin/start_hm_pro_moserver.sh | 2 - .../bin/start_hm_pro_nodeserver.sh | 2 - .../bin/start_hm_pro_pfntfyserver.sh | 2 - .../bin/start_hm_pro_rtserver.sh | 2 - .../bin/start_hm_rtserver.sh | 2 + .../bin/start_hm_test_apmserver.sh | 2 - .../bin/start_hm_test_logserver.sh | 2 - .../bin/start_hm_test_moserver.sh | 2 - .../bin/start_hm_test_nodeserver.sh | 2 - .../bin/start_hm_test_pnhbserver.sh | 2 - .../bin/start_hm_test_rtserver.sh | 2 - .../bin/stop_hm_apmserver.sh | 2 + .../bin/stop_hm_apphubmgr.sh | 2 + .../bin/stop_hm_hbserver.sh | 2 + .../bin/stop_hm_logserver.sh | 2 + .../bin/stop_hm_moserver.sh | 2 + .../bin/stop_hm_nodeserver.sh | 2 + .../bin/stop_hm_pfntfyserver.sh | 2 + .../bin/stop_hm_pnhbserver.sh | 2 + .../bin/stop_hm_pro_apmserver.sh | 2 - .../bin/stop_hm_pro_apphubmgr.sh | 2 - .../bin/stop_hm_pro_hbserver.sh | 2 - .../bin/stop_hm_pro_logserver.sh | 2 - .../bin/stop_hm_pro_moserver.sh | 2 - .../bin/stop_hm_pro_nodeserver.sh | 2 - .../bin/stop_hm_pro_pfntfyserver.sh | 2 - .../bin/stop_hm_pro_rtserver.sh | 2 - .../bin/stop_hm_rtserver.sh | 2 + .../bin/stop_hm_test_apmserver.sh | 2 - .../bin/stop_hm_test_logserver.sh | 2 - .../bin/stop_hm_test_moserver.sh | 2 - .../bin/stop_hm_test_nodeserver.sh | 2 - .../bin/stop_hm_test_pnhbserver.sh | 2 - .../bin/stop_hm_test_rtserver.sh | 2 - .../config/agent.properties | 865 ++++++++-------- ...ver.properties => hm_apmserver.properties} | 274 ++--- ...mgr.properties => hm_apphubmgr.properties} | 501 ++++----- ...rver.properties => hm_hbserver.properties} | 312 +++--- ...ver.properties => hm_logserver.properties} | 212 ++-- ...rver.properties => hm_moserver.properties} | 310 +++--- ...er.properties => hm_nodeserver.properties} | 322 +++--- ....properties => hm_pfntfyserver.properties} | 420 ++++---- ...er.properties => hm_pnhbserver.properties} | 623 ++++++------ .../config/hm_pro_logserver.properties | 223 ---- ...rver.properties => hm_rtserver.properties} | 232 ++--- .../config/hm_test_apmserver.properties | 137 --- .../config/hm_test_logserver.properties | 226 ----- .../config/hm_test_moserver.properties | 155 --- .../config/hm_test_nodeserver.properties | 169 ---- .../creditease/uav/feature/HealthManager.java | 949 +++++++++--------- 62 files changed, 2515 insertions(+), 3507 deletions(-) create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_apmserver.properties => hm_apmserver.properties} (97%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_apphubmgr.properties => hm_apphubmgr.properties} (90%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_hbserver.properties => hm_hbserver.properties} (94%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_test_rtserver.properties => hm_logserver.properties} (50%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_moserver.properties => hm_moserver.properties} (86%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_nodeserver.properties => hm_nodeserver.properties} (87%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_pfntfyserver.properties => hm_pfntfyserver.properties} (89%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_test_pnhbserver.properties => hm_pnhbserver.properties} (93%) delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pro_rtserver.properties => hm_rtserver.properties} (97%) delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh new file mode 100644 index 00000000..d6426e65 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh APMServer hm_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh new file mode 100644 index 00000000..3dabe1b5 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh AppHubManager hm_apphubmgr -Xmx1024m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh new file mode 100644 index 00000000..54fae549 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh HeartBeatServer hm_hbserver -Xmx768m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh new file mode 100644 index 00000000..3fe60e29 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh LogDataServer hm_logserver -Xmx1280m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh new file mode 100644 index 00000000..1f994d43 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh MonitorDataServer hm_moserver -Xmx1536m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh new file mode 100644 index 00000000..02b649d9 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh NodeDataServer hm_nodeserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh new file mode 100644 index 00000000..e2fefb06 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh Profile_NotifyDataServer hm_pfntfyserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh new file mode 100644 index 00000000..941201be --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh Profile_Notify_HBServer hm_pnhbserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh deleted file mode 100644 index b6c31040..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh APMServer hm_pro_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh deleted file mode 100644 index 320b0473..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh AppHubManager hm_pro_apphubmgr -Xmx1024m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh deleted file mode 100644 index 4c6e7130..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh HeartBeatServer hm_pro_hbserver -Xmx768m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh deleted file mode 100644 index 778af771..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh LogDataServer hm_pro_logserver -Xmx1280m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh deleted file mode 100644 index c2ebc586..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh MonitorDataServer hm_pro_moserver -Xmx1536m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh deleted file mode 100644 index f255168a..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh NodeDataServer hm_pro_nodeserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh deleted file mode 100644 index c9b5da97..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh Profile_NotifyDataServer hm_pro_pfntfyserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh deleted file mode 100644 index 8fef1c8f..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh RuntimeServer hm_pro_rtserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh new file mode 100644 index 00000000..64dac3c6 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh RuntimeServer hm_rtserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh deleted file mode 100644 index 9fa24bc0..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh APMServer hm_test_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh deleted file mode 100644 index 90dacc25..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh LogServer hm_test_logserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh deleted file mode 100644 index cf7739b5..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh MonitorServer hm_test_moserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh deleted file mode 100644 index ed92082b..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh NodeDataServer hm_test_nodeserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh deleted file mode 100644 index 16667006..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh Profile_Notify_HBServer hm_test_pnhbserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh deleted file mode 100644 index c92a783e..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh RuntimeServer hm_test_rtserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh new file mode 100644 index 00000000..87663f14 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh new file mode 100644 index 00000000..f4723bfb --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_apphubmgr \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh new file mode 100644 index 00000000..baeaf1c6 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_hbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh new file mode 100644 index 00000000..2edf4bf4 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh new file mode 100644 index 00000000..e14fd98d --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh new file mode 100644 index 00000000..3f7abd0b --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh new file mode 100644 index 00000000..58e0ce86 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pfntfyserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh new file mode 100644 index 00000000..f9d86ee0 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pnhbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh deleted file mode 100644 index f5708796..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh deleted file mode 100644 index 7451371c..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_apphubmgr \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh deleted file mode 100644 index 684f18b2..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_hbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh deleted file mode 100644 index bbaa392d..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh deleted file mode 100644 index 12637ed0..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh deleted file mode 100644 index 30aba5c5..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh deleted file mode 100644 index 541c8714..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_pfntfyserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh deleted file mode 100644 index a7b17b54..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pro_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh new file mode 100644 index 00000000..795b2efc --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh deleted file mode 100644 index fdf146e0..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh deleted file mode 100644 index f1c66251..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh deleted file mode 100644 index ebdddd79..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh deleted file mode 100644 index 037c96d6..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh deleted file mode 100644 index d8ed84a7..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_pnhbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh deleted file mode 100644 index 9567f7b0..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_test_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index 6812feea..eb300fc2 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -1,438 +1,429 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5065\u5EB7\u7BA1\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10102 - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=10 -feature.notifycenter.inqw.bQueueSize=1000 -feature.notifycenter.inqw.keepAliveTimeout=10000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username=system -feature.notifycenter.nc.notify.mail.cemail.password=manager -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=8766 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services=dhandsonrobot-DHandsonRobot-Server-/hit/xrobot:monitor/ntfpush - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8765 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=10 -feature.healthmanager.store.concurrent.max=20 -feature.healthmanager.store.concurrent.bqsize=10 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -feature.healthmanager.MT_Monitor.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeinfoDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010 - -feature.hbclientagent.interval=15000 - -#Proc Detect Agent Feature -feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar -feature.procscan.enable=false -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8011 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:27017 -feature.apphubmanager.ds.db=apphubDataStore -#feature.apphubmanager.ds.power=admin -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#IssueDiagnoseAssitAgent -feature.ida.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.ida.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.ida.components=com.creditease.uav.feature.IssueDiagnoseAssitAgent -feature.ida.properties= -#tools -feature.ida.dwhhandlers=com.creditease.uav.feature.ida.tools.ContainerPerfCatcher -#ContainerPerfCatcher configuration -feature.ida.ContainerPerfCatcher.enable=true -feature.ida.ContainerPerfCatcher.threshold=cpu=0.8 -feature.ida.ContainerPerfCatcher.root=d:/UAVTEST - -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#runtime consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=10 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=true -#1n worker -feature.runtimenotify.qworker.coresize=10 -feature.runtimenotify.qworker.maxsize=20 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=10000 -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=10 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=50 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=5 -#timernotifyworker -feature.runtimenotify.timernotify.enable=true -feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9000 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=30000 -#in seconds -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} - -# Data Collect Feature -feature.collectserver.loader=com.creditease.uav.collect.jar -feature.collectserver.enable=true -feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager -feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM -feature.collectserver.messagingnameserver=127.0.0.1:9876 -# for topic consumer performance tuning -#feature.collectserver..consumethreadmax=10 -#feature.collectserver..consumestopinterval=0 -#feature.collectserver..enable=true -feature.collectserver.JQ_IVC.consumethreadmax=10 -feature.collectserver.JQ_IVC.consumestopinterval=0 -feature.collectserver.JQ_IVC.enable=true - -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - -feature.collectserver.JQ_SLW.consumethreadmax=10 -feature.collectserver.JQ_SLW.consumestopinterval=0 -feature.collectserver.JQ_SLW.enable=true - -feature.collectserver.JQ_JTA.consumethreadmax=5 -feature.collectserver.JQ_JTA.consumestopinterval=0 -feature.collectserver.JQ_JTA.enable=true - -#InvokeChain Process Server Feature -feature.invokechainserver.loader=com.creditease.uav.invokechain.jar -feature.invokechainserver.enable=true -feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer -feature.invokechainserver.properties= -#cache -feature.invokechainserver.store.addr=127.0.0.1:6379 -feature.invokechainserver.store.concurrent.min=10 -feature.invokechainserver.store.concurrent.max=50 -feature.invokechainserver.store.concurrent.bqsize=5 -feature.invokechainserver.store.concurrent.pwd= -#elastic-search -feature.invokechainserver.es.addr=127.0.0.1:9300 -feature.invokechainserver.es.clustername= -feature.invokechainserver.es.query.timeout=5000 -#query http service -feature.invokechainserver.http.enable=true -feature.invokechainserver.http.port=7799 -feature.invokechainserver.http.core=10 -feature.invokechainserver.http.max=100 -feature.invokechainserver.http.backlog=10 -feature.invokechainserver.http.bqsize=10 -feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=com.creditease.uav.invokechain.jar -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=false -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300 -feature.newlogservice.es.clustername= -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=10 -feature.newlogservice.http.max=100 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 -feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler - - -#Thread Analysis Server Feature -feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar -feature.threadanalysisserver.enable=true -feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer -#elastic-search -feature.threadanalysisserver.es.addr=127.0.0.1:9300 -feature.threadanalysisserver.es.clustername= -feature.threadanalysisserver.es.query.timeout=5000 -#query http service -feature.threadanalysisserver.http.enable=true -feature.threadanalysisserver.http.port=5566 -feature.threadanalysisserver.http.core=10 -feature.threadanalysisserver.http.max=100 -feature.threadanalysisserver.http.backlog=10 -feature.threadanalysisserver.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5065\u5EB7\u7BA1\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10102 + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=10 +feature.notifycenter.inqw.bQueueSize=1000 +feature.notifycenter.inqw.keepAliveTimeout=10000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username=system +feature.notifycenter.nc.notify.mail.cemail.password=manager +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=8766 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services=dhandsonrobot-DHandsonRobot-Server-/hit/xrobot:monitor/ntfpush + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8765 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=10 +feature.healthmanager.store.concurrent.max=20 +feature.healthmanager.store.concurrent.bqsize=10 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeinfoDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010 + +feature.hbclientagent.interval=15000 + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=false +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8011 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:27017 +feature.apphubmanager.ds.db=apphubDataStore +#feature.apphubmanager.ds.power=admin +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#IssueDiagnoseAssitAgent +feature.ida.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.ida.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.ida.components=com.creditease.uav.feature.IssueDiagnoseAssitAgent +feature.ida.properties= +#tools +feature.ida.dwhhandlers=com.creditease.uav.feature.ida.tools.ContainerPerfCatcher +#ContainerPerfCatcher configuration +feature.ida.ContainerPerfCatcher.enable=true +feature.ida.ContainerPerfCatcher.threshold=cpu=0.8 +feature.ida.ContainerPerfCatcher.root=d:/UAVTEST + +#feature runtimenotify +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#runtime consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=10 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=true +#1n worker +feature.runtimenotify.qworker.coresize=10 +feature.runtimenotify.qworker.maxsize=20 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=10000 +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=10 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=50 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=5 +#timernotifyworker +feature.runtimenotify.timernotify.enable=true +feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9000 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=10 +feature.runtimenotify.http.max=50 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=30000 +#in seconds +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} + +# Data Collect Feature +feature.collectserver.loader=com.creditease.uav.collect.jar +feature.collectserver.enable=true +feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager +feature.collectserver.properties= +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.messagingnameserver=127.0.0.1:9876 +# for topic consumer performance tuning +#feature.collectserver..consumethreadmax=10 +#feature.collectserver..consumestopinterval=0 +#feature.collectserver..enable=true +feature.collectserver.JQ_IVC.consumethreadmax=10 +feature.collectserver.JQ_IVC.consumestopinterval=0 +feature.collectserver.JQ_IVC.enable=true + +feature.collectserver.JQ_UEM.consumethreadmax=10 +feature.collectserver.JQ_UEM.consumestopinterval=0 +feature.collectserver.JQ_UEM.enable=true + +feature.collectserver.JQ_SLW.consumethreadmax=10 +feature.collectserver.JQ_SLW.consumestopinterval=0 +feature.collectserver.JQ_SLW.enable=true + +feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumestopinterval=0 +feature.collectserver.JQ_JTA.enable=true + +#InvokeChain Process Server Feature +feature.invokechainserver.loader=com.creditease.uav.invokechain.jar +feature.invokechainserver.enable=true +feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer +feature.invokechainserver.properties= +#cache +feature.invokechainserver.store.addr=127.0.0.1:6379 +feature.invokechainserver.store.concurrent.min=10 +feature.invokechainserver.store.concurrent.max=50 +feature.invokechainserver.store.concurrent.bqsize=5 +feature.invokechainserver.store.concurrent.pwd= +#elastic-search +feature.invokechainserver.es.addr=127.0.0.1:9300 +feature.invokechainserver.es.clustername= +feature.invokechainserver.es.query.timeout=5000 +#query http service +feature.invokechainserver.http.enable=true +feature.invokechainserver.http.port=7799 +feature.invokechainserver.http.core=10 +feature.invokechainserver.http.max=100 +feature.invokechainserver.http.backlog=10 +feature.invokechainserver.http.bqsize=10 +feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler + + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=false +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300 +feature.newlogservice.es.clustername= +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=10 +feature.newlogservice.http.max=100 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 +feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler + + +#Thread Analysis Server Feature +feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar +feature.threadanalysisserver.enable=true +feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer +#elastic-search +feature.threadanalysisserver.es.addr=127.0.0.1:9300 +feature.threadanalysisserver.es.clustername= +feature.threadanalysisserver.es.query.timeout=5000 +#query http service +feature.threadanalysisserver.http.enable=true +feature.threadanalysisserver.http.port=5566 +feature.threadanalysisserver.http.core=10 +feature.threadanalysisserver.http.max=100 +feature.threadanalysisserver.http.backlog=10 +feature.threadanalysisserver.http.bqsize=10 feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties similarity index 97% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties index a138079c..42e3b5e0 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties @@ -1,138 +1,138 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10146 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -# Data Collect Feature -feature.collectserver.loader=default -feature.collectserver.enable=true -feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager -feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM -feature.collectserver.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -# for topic consumer performance tuning -#feature.collectserver..consumethreadmax=10 -#feature.collectserver..consumestopinterval=0 -#feature.collectserver..enable=true -feature.collectserver.JQ_IVC.consumethreadmax=10 -feature.collectserver.JQ_IVC.consumestopinterval=0 -feature.collectserver.JQ_IVC.enable=true - -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - -feature.collectserver.JQ_SLW.consumethreadmax=10 -feature.collectserver.JQ_SLW.consumestopinterval=0 -feature.collectserver.JQ_SLW.enable=true - -feature.collectserver.JQ_JTA.consumethreadmax=5 -feature.collectserver.JQ_JTA.consumestopinterval=0 -feature.collectserver.JQ_JTA.enable=true - -#InvokeChain Process Server Feature -feature.invokechainserver.loader=default -feature.invokechainserver.enable=true -feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer -feature.invokechainserver.properties= -#cache -feature.invokechainserver.store.addr=127.0.0.1:26379 -feature.invokechainserver.store.concurrent.min=10 -feature.invokechainserver.store.concurrent.max=50 -feature.invokechainserver.store.concurrent.bqsize=5 -feature.invokechainserver.store.concurrent.pwd= -#elastic-search -feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.invokechainserver.es.clustername=edp-es -feature.invokechainserver.es.query.timeout=5000 -#query http service -feature.invokechainserver.http.enable=true -feature.invokechainserver.http.port=7799 -feature.invokechainserver.http.core=30 -feature.invokechainserver.http.max=200 -feature.invokechainserver.http.backlog=10 -feature.invokechainserver.http.bqsize=10 -feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler - - -#Thread Analysis Server Feature -feature.threadanalysisserver.loader=default -feature.threadanalysisserver.enable=true -feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer -#elastic-search -feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.threadanalysisserver.es.clustername=edp-es -feature.threadanalysisserver.es.query.timeout=5000 -#query http service -feature.threadanalysisserver.http.enable=true -feature.threadanalysisserver.http.port=5566 -feature.threadanalysisserver.http.core=10 -feature.threadanalysisserver.http.max=100 -feature.threadanalysisserver.http.backlog=10 -feature.threadanalysisserver.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10146 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +# Data Collect Feature +feature.collectserver.loader=default +feature.collectserver.enable=true +feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager +feature.collectserver.properties= +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +# for topic consumer performance tuning +#feature.collectserver..consumethreadmax=10 +#feature.collectserver..consumestopinterval=0 +#feature.collectserver..enable=true +feature.collectserver.JQ_IVC.consumethreadmax=10 +feature.collectserver.JQ_IVC.consumestopinterval=0 +feature.collectserver.JQ_IVC.enable=true + +feature.collectserver.JQ_UEM.consumethreadmax=10 +feature.collectserver.JQ_UEM.consumestopinterval=0 +feature.collectserver.JQ_UEM.enable=true + +feature.collectserver.JQ_SLW.consumethreadmax=10 +feature.collectserver.JQ_SLW.consumestopinterval=0 +feature.collectserver.JQ_SLW.enable=true + +feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumestopinterval=0 +feature.collectserver.JQ_JTA.enable=true + +#InvokeChain Process Server Feature +feature.invokechainserver.loader=default +feature.invokechainserver.enable=true +feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer +feature.invokechainserver.properties= +#cache +feature.invokechainserver.store.addr=127.0.0.1:26379 +feature.invokechainserver.store.concurrent.min=10 +feature.invokechainserver.store.concurrent.max=50 +feature.invokechainserver.store.concurrent.bqsize=5 +feature.invokechainserver.store.concurrent.pwd= +#elastic-search +feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.invokechainserver.es.clustername=edp-es +feature.invokechainserver.es.query.timeout=5000 +#query http service +feature.invokechainserver.http.enable=true +feature.invokechainserver.http.port=7799 +feature.invokechainserver.http.core=30 +feature.invokechainserver.http.max=200 +feature.invokechainserver.http.backlog=10 +feature.invokechainserver.http.bqsize=10 +feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler + + +#Thread Analysis Server Feature +feature.threadanalysisserver.loader=default +feature.threadanalysisserver.enable=true +feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer +#elastic-search +feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.threadanalysisserver.es.clustername=edp-es +feature.threadanalysisserver.es.query.timeout=5000 +#query http service +feature.threadanalysisserver.http.enable=true +feature.threadanalysisserver.http.port=5566 +feature.threadanalysisserver.http.core=10 +feature.threadanalysisserver.http.max=100 +feature.threadanalysisserver.http.backlog=10 +feature.threadanalysisserver.http.bqsize=10 feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties similarity index 90% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties index 87d8f50b..b1344b01 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties @@ -1,250 +1,251 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10120 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#feature apphubmanager BEGIN------------------------------------------------------------------ -feature.apphubmanager.loader=default -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=20 -feature.apphubmanager.http.max=100 -feature.apphubmanager.http.bqsize=20 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=uav.db.jishu.idc:25000 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#HealthManager------------------------------------------------------------------ -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=20 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=30 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=50 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-------------------------------HBServer Query-------------------------- -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8012 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8022 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=20 -feature.hbserveragent.http.max=150 -feature.hbserveragent.http.bqsize=5 -feature.hbserveragent.store.addr=127.0.0.1:26379 -feature.hbserveragent.store.concurrent.min=30 -feature.hbserveragent.store.concurrent.max=150 -feature.hbserveragent.store.concurrent.bqsize=5 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=30000 - -#-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.storecm.server=127.0.0.1:26379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=60 -feature.runtimenotify.storecm.qsize=20 -#qworker -feature.runtimenotify.qworker.coresize=10 -feature.runtimenotify.qworker.maxsize=30 -feature.runtimenotify.qworker.bqsize=50 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9004 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=20 -feature.runtimenotify.http.max=100 -feature.runtimenotify.http.bqsize=5 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10120 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#feature apphubmanager BEGIN------------------------------------------------------------------ +feature.apphubmanager.loader=default +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=20 +feature.apphubmanager.http.max=100 +feature.apphubmanager.http.bqsize=20 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:27017 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#HealthManager------------------------------------------------------------------ +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8044 +feature.healthmanager.http.backlog=20 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=30 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=50 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 +#-------------------------------HBServer Query-------------------------- +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8012 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8022 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=20 +feature.hbserveragent.http.max=150 +feature.hbserveragent.http.bqsize=5 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=30 +feature.hbserveragent.store.concurrent.max=150 +feature.hbserveragent.store.concurrent.bqsize=5 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=30000 + +#-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=30 +feature.runtimenotify.storecm.maxsize=60 +feature.runtimenotify.storecm.qsize=20 +#qworker +feature.runtimenotify.qworker.coresize=10 +feature.runtimenotify.qworker.maxsize=30 +feature.runtimenotify.qworker.bqsize=50 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9004 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=20 +feature.runtimenotify.http.max=100 +feature.runtimenotify.http.bqsize=5 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties similarity index 94% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties index fe53e907..fb1aa0e7 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties @@ -1,160 +1,152 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -#heart beat server poll self -feature.hbclientagent.hbservers=127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#Proc Detect Agent Feature -feature.procscan.loader=default -feature.procscan.enable=false -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8011 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8021 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=30 -feature.hbserveragent.http.max=150 -feature.hbserveragent.http.bqsize=5 -feature.hbserveragent.store.addr=127.0.0.1:26379 -feature.hbserveragent.store.concurrent.min=40 -feature.hbserveragent.store.concurrent.max=200 -feature.hbserveragent.store.concurrent.bqsize=5 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=30000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=10 -feature.runtimenotify.cm.maxsize=30 -feature.runtimenotify.cm.qsize=5 -feature.runtimenotify.storecm.server=127.0.0.1:26379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=150 -feature.runtimenotify.storecm.qsize=5 -#qworker -feature.runtimenotify.qworker.coresize=20 -feature.runtimenotify.qworker.maxsize=100 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9003 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +#heart beat server poll self +feature.hbclientagent.hbservers=127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8011 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8021 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=30 +feature.hbserveragent.http.max=150 +feature.hbserveragent.http.bqsize=5 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=40 +feature.hbserveragent.store.concurrent.max=200 +feature.hbserveragent.store.concurrent.bqsize=5 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=30000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#-------------------------------------------RUNTIME NOTIFY------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=10 +feature.runtimenotify.cm.maxsize=30 +feature.runtimenotify.cm.qsize=5 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=30 +feature.runtimenotify.storecm.maxsize=150 +feature.runtimenotify.storecm.qsize=5 +#qworker +feature.runtimenotify.qworker.coresize=20 +feature.runtimenotify.qworker.maxsize=100 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9003 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=10 +feature.runtimenotify.http.max=50 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties similarity index 50% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties index 1a6e7659..8a9a4da3 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties @@ -1,118 +1,94 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10113 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data comsumer -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=true -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=100 -feature.runtimenotify.storecm.maxsize=300 -feature.runtimenotify.storecm.qsize=10 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=20 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#timernotifyworker -feature.runtimenotify.timernotify.enable=true -feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9003 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10130 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager NewLogService Feature +feature.newlogservice.loader=default +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=edp-es +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=50 +feature.newlogservice.http.max=300 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 +feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties similarity index 86% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties index 7bed4cb7..a03bb3c6 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties @@ -1,154 +1,156 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=50 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.buffersize=150 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10140 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=50 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8042 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=500 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=500 +feature.healthmanager.MT_Monitor.ds.retry=1 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties similarity index 87% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties index bf812b15..d851fc89 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties @@ -1,168 +1,156 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10145 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=false -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=false -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=false -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.buffersize=150 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10145 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8042 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=500 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=500 +feature.healthmanager.MT_Monitor.ds.retry=1 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties similarity index 89% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties index ab40d611..7796935f 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties @@ -1,209 +1,211 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10150 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=15 -feature.healthmanager.MT_Profile.consumethreadmax=25 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=150 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-----------------------------NOTIFICATION CENTER--------------------------------------------------- - -#notifcenter -feature.notifycenter.loader=default -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=50 -feature.notifycenter.inqw.bQueueSize=5 -feature.notifycenter.inqw.keepAliveTimeout=30000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:26379 -feature.notifycenter.nc.cache.concurrent.min=30 -feature.notifycenter.nc.cache.concurrent.max=100 -feature.notifycenter.nc.cache.concurrent.bqsize=5 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=30 -feature.notifycenter.http.max=150 -feature.notifycenter.http.bqsize=5 -#push to other services -feature.notifycenter.push.services= - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10150 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=15 +feature.healthmanager.MT_Profile.consumethreadmax=25 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=20 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=150 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 + +#-----------------------------NOTIFICATION CENTER--------------------------------------------------- + +#notifcenter +feature.notifycenter.loader=default +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=50 +feature.notifycenter.inqw.bQueueSize=5 +feature.notifycenter.inqw.keepAliveTimeout=30000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=30 +feature.notifycenter.nc.cache.concurrent.max=100 +feature.notifycenter.nc.cache.concurrent.bqsize=5 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=30 +feature.notifycenter.http.max=150 +feature.notifycenter.http.bqsize=5 +#push to other services +feature.notifycenter.push.services= + diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties similarity index 93% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties index 54d67f84..7f88d43f 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties @@ -1,311 +1,314 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=default -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:26000 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#notifcenter -feature.notifycenter.loader=default -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=20 -feature.notifycenter.inqw.bQueueSize=50 -feature.notifycenter.inqw.keepAliveTimeout=60000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services= - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=100 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=200 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#------------------------------------------------------------------------------------------------- - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=40 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=10 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=default +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:27017 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#notifcenter +feature.notifycenter.loader=default +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=20 +feature.notifycenter.inqw.bQueueSize=50 +feature.notifycenter.inqw.keepAliveTimeout=60000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services= + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8041 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=100 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=200 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 + + +#------------------------------------------------------------------------------------------------- + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=40 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=10 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9001 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties deleted file mode 100644 index ad29351d..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties +++ /dev/null @@ -1,223 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10130 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=5 -feature.healthmanager.MT_Notify.consumethreadmax=5 -feature.healthmanager.MT_Profile.consumethreadmax=5 -feature.healthmanager.MT_Log.consumethreadmax=20 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=5 -feature.healthmanager.store.concurrent.max=10 -feature.healthmanager.store.concurrent.bqsize=20 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=false -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.storecm.server=127.0.0.1:26379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=60 -feature.runtimenotify.storecm.qsize=20 -#qworker -feature.runtimenotify.qworker.coresize=20 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=20 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=default -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=edp-es -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=50 -feature.newlogservice.http.max=300 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 -feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties similarity index 97% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties index c6f567c7..4da6def3 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties @@ -1,116 +1,116 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=true -#1n worker -feature.runtimenotify.qworker.coresize=50 -feature.runtimenotify.qworker.maxsize=100 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout610000 -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=15 -feature.runtimenotify.cm.maxsize=30 -feature.runtimenotify.cm.qsize=5 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=100 -feature.runtimenotify.storecm.maxsize=300 -feature.runtimenotify.storecm.qsize=5 -#timernotifyworker -feature.runtimenotify.timernotify.enable=true -feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9002 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=30 -feature.runtimenotify.http.max=60 -feature.runtimenotify.http.bqsize=5 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"60000"}} +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10140 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#-------------------------------------------RUNTIME NOTIFY------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=true +#1n worker +feature.runtimenotify.qworker.coresize=50 +feature.runtimenotify.qworker.maxsize=100 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout610000 +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=15 +feature.runtimenotify.cm.maxsize=30 +feature.runtimenotify.cm.qsize=5 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=100 +feature.runtimenotify.storecm.maxsize=300 +feature.runtimenotify.storecm.qsize=5 +#timernotifyworker +feature.runtimenotify.timernotify.enable=true +feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9002 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=30 +feature.runtimenotify.http.max=60 +feature.runtimenotify.http.bqsize=5 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"60000"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties deleted file mode 100644 index f3acf99c..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties +++ /dev/null @@ -1,137 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10116 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- -# Data Collect Feature -feature.collectserver.loader=default -feature.collectserver.enable=true -feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager -feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM -feature.collectserver.messagingnameserver=127.0.0.1:9876 -# for topic consumer performance tuning -#feature.collectserver..consumethreadmax=10 -#feature.collectserver..consumestopinterval=0 -#feature.collectserver..enable=true -feature.collectserver.JQ_IVC.consumethreadmax=10 -feature.collectserver.JQ_IVC.consumestopinterval=0 -feature.collectserver.JQ_IVC.enable=true - -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - -feature.collectserver.JQ_SLW.consumethreadmax=10 -feature.collectserver.JQ_SLW.consumestopinterval=0 -feature.collectserver.JQ_SLW.enable=true - -feature.collectserver.JQ_JTA.consumethreadmax=5 -feature.collectserver.JQ_JTA.consumestopinterval=0 -feature.collectserver.JQ_JTA.enable=true - -#InvokeChain Process Server Feature -feature.invokechainserver.loader=default -feature.invokechainserver.enable=true -feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer -feature.invokechainserver.properties= -#cache -feature.invokechainserver.store.addr=127.0.0.1:6379 -feature.invokechainserver.store.concurrent.min=10 -feature.invokechainserver.store.concurrent.max=50 -feature.invokechainserver.store.concurrent.bqsize=5 -feature.invokechainserver.store.concurrent.pwd= -#elastic-search -feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300 -feature.invokechainserver.es.clustername=uav-es5.4.1 -feature.invokechainserver.es.query.timeout=5000 -#query http service -feature.invokechainserver.http.enable=true -feature.invokechainserver.http.port=7799 -feature.invokechainserver.http.core=30 -feature.invokechainserver.http.max=150 -feature.invokechainserver.http.backlog=10 -feature.invokechainserver.http.bqsize=10 -feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler -#Thread Analysis Server Feature - - -feature.threadanalysisserver.loader=default -feature.threadanalysisserver.enable=true -feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer -#elastic-search -feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300 -feature.threadanalysisserver.es.clustername=uav-es5.4.1 -feature.threadanalysisserver.es.query.timeout=5000 -#query http service -feature.threadanalysisserver.http.enable=true -feature.threadanalysisserver.http.port=5566 -feature.threadanalysisserver.http.core=10 -feature.threadanalysisserver.http.max=100 -feature.threadanalysisserver.http.backlog=10 -feature.threadanalysisserver.http.bqsize=10 -feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties deleted file mode 100644 index 16aeb53e..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties +++ /dev/null @@ -1,226 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10111 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=5 -feature.healthmanager.MT_Notify.consumethreadmax=5 -feature.healthmanager.MT_Profile.consumethreadmax=5 -feature.healthmanager.MT_Log.consumethreadmax=20 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=10 -feature.healthmanager.store.concurrent.max=20 -feature.healthmanager.store.concurrent.bqsize=10 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=false -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=100 -feature.runtimenotify.storecm.maxsize=300 -feature.runtimenotify.storecm.qsize=5 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9002 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=default -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=uav-es5.4.1 -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=30 -feature.newlogservice.http.max=200 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 -feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties deleted file mode 100644 index fd792739..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties +++ /dev/null @@ -1,155 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10112 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=35 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties deleted file mode 100644 index d0fc078c..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties +++ /dev/null @@ -1,169 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10115 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=false -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=false -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=false -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java index 5feb9db5..5283323e 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java @@ -1,483 +1,466 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.uavstack.resources.common.messaging.StandardMessagingBuilder; - -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.monitor.api.MonitorDataFrame; -import com.creditease.agent.profile.api.StandardProfileModeler; -import com.creditease.agent.spi.AgentFeatureComponent; -import com.creditease.agent.spi.IActionEngine; -import com.creditease.agent.spi.IConfigurationManager; -import com.creditease.uav.cache.api.CacheManager; -import com.creditease.uav.cache.api.CacheManagerFactory; -import com.creditease.uav.datastore.api.DataStoreAdapter; -import com.creditease.uav.datastore.api.DataStoreConnection; -import com.creditease.uav.datastore.api.DataStoreFactory; -import com.creditease.uav.datastore.api.DataStoreFactory.DataStoreType; -import com.creditease.uav.datastore.api.DataStoreMsg; -import com.creditease.uav.datastore.api.DataStoreProtocol; -import com.creditease.uav.datastore.core.AbstractDataStore; -import com.creditease.uav.feature.healthmanager.HealthManagerConstants; -import com.creditease.uav.feature.healthmanager.HealthManagerProfileDataLifeKeeper; -import com.creditease.uav.feature.healthmanager.HealthManagerServerWorker; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater; -import com.creditease.uav.messaging.api.MessageConsumer; - -public class HealthManager extends AgentFeatureComponent { - - private MessageConsumer monitorDataConsumer; - - private MessageConsumer notificationConsumer; - - private MessageConsumer profileDataConsumer; - - private MessageConsumer logDataConsumer; - - private MessageConsumer nodeinfoDataConsumer; - - private HealthManagerServerWorker healthServerListenWorker; - - private boolean isStartLifeKeeper = false; - - public HealthManager(String cName, String feature) { - super(cName, feature); - } - - @Override - public void start() { - - // init cache manager - String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr"); - int minConcurrent = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min")); - int maxConcurrent = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max")); - int queueSize = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize")); - String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd"); - - CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, - password); - - this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm); - - // start HealthManagerProfileDataLifeKeeper - isStartLifeKeeper = Boolean - .parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable")); - - if (isStartLifeKeeper == true) { - - // init HealthManagerProfileDataLifeKeeper - HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper( - "HealthManagerProfileDataLifeKeeper", this.feature); - - long interval = Long - .parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval")); - - long randomDely = new Random().nextInt(3) + 3; - - this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", - profileDataLifeKeepWorker, randomDely * 1000, interval); - - if (log.isTraceEnable()) { - log.info(this, "HealthManagerProfileDataLifeKeeper started"); - } - } - - /** - * Start the DBStore service NOTE: this must be the first to start - */ - buildDataStores(this.getConfigManager()); - - // start all datastores - DataStoreFactory.getInstance().startAll(this.feature); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore Factory started"); - } - - /** - * Start the HealthManger Http service - */ - int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port")); - int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog")); - int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core")); - int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max")); - int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize")); - - healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, - "healthMangerHandlers"); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue(bqsize)); - - healthServerListenWorker.start(exe, port, backlog); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore HttpServer started"); - } - - StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature); - - try { - smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers"); - } - catch (IOException e) { - log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e); - return; - } - - monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString()); - - notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString()); - - profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString()); - - logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString()); - - nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString()); - - // start monitorDataConsumer - if (monitorDataConsumer != null) { - - monitorDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, - monitorDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager MDFConsumer started"); - } - } - - // start notificationConsumer - if (this.notificationConsumer != null) { - notificationConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, - notificationConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager NotifyConsumer started"); - } - } - - // start profileDataConsumer - if (this.profileDataConsumer != null) { - - /** - * INIT StandardProfileModelingEngine & StandardProfileModeler - */ - IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature); - - new StandardProfileModeler("StandardProfileModeler", feature, engine); - - // start profile consumer - profileDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, - profileDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager ProfileConsumer started"); - } - } - - // start logDataConsumer - if (this.logDataConsumer != null) { - logDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, - logDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager LogConsumer started"); - } - } - - // start nodeinfoDataConsumer - if (nodeinfoDataConsumer != null) { - - nodeinfoDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, - nodeinfoDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager NodeInfoConsumer started"); - } - } - } - - @Override - public void stop() { - - // stop monitorDataConsumer - if (this.monitorDataConsumer != null) { - monitorDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR); - if (log.isTraceEnable()) { - log.info(this, "HealthManager MdfConsumer shutdown"); - } - } - - // stop notificationConsumer - if (this.notificationConsumer != null) { - notificationConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY); - if (log.isTraceEnable()) { - log.info(this, "HealthManager NotifyConsumer shutdown"); - } - } - - // stop profileDataConsumer - if (this.profileDataConsumer != null) { - - // shut down StandardProfileModelingEngine - this.getActionEngineMgr().shutdown("StandardProfileModelingEngine"); - - profileDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE); - if (log.isTraceEnable()) { - log.info(this, "HealthManager ProfileConsumer shutdown"); - } - } - - // stop logDataConsumer - if (this.logDataConsumer != null) { - logDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_LOG); - if (log.isTraceEnable()) { - log.info(this, "HealthManager LogConsumer shutdown"); - } - } - - // stop nodeinfoDataConsumer - if (this.nodeinfoDataConsumer != null) { - nodeinfoDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NODE); - if (log.isTraceEnable()) { - log.info(this, "HealthManager NodeInfoConsumer shutdown"); - } - } - // stop healthServerListenWorker - healthServerListenWorker.stop(); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore HttpServer shutdown"); - } - - // NOTE: this should be the last to stop - DataStoreFactory.getInstance().stopAll(this.feature); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore Factory shutdown"); - } - - if (isStartLifeKeeper == true) { - - // stop HealthManagerProfileDataLifeKeeper - this.getTimerWorkManager().cancel("HealthManagerProfileDataLifeKeeper"); - - if (log.isTraceEnable()) { - log.info(this, "HealthManagerProfileDataLifeKeeper stopped"); - } - } - - // shutdown CacheManager - CacheManager HMCacheManager = (CacheManager) this.getConfigManager().getComponent(this.feature, - "HMCacheManager"); - HMCacheManager.shutdown(); - - super.stop(); - } - - private void buildDataStores(IConfigurationManager icm) { - - // log - String logKey = MonitorDataFrame.MessageType.Log.toString(); - // monitor - String monitorKey = MonitorDataFrame.MessageType.Monitor.toString(); - - // profile - String profileKey = MonitorDataFrame.MessageType.Profile.toString(); - - // notification - String notifyKey = MonitorDataFrame.MessageType.Notification.toString(); - - // nodeinfo - String nodeinfoKey = MonitorDataFrame.MessageType.NodeInfo.toString(); - - String caching = icm.getFeatureConfiguration(this.feature, logKey + ".ds.cache"); - String maxResultSize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.maxResultSize"); - String reverse = icm.getFeatureConfiguration(this.feature, logKey + ".ds.reverse"); - String psize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.pagesize"); - - Map lctx = new HashMap(); - lctx.put(DataStoreProtocol.HBASE_QUERY_CACHING, caching); - lctx.put(DataStoreProtocol.HBASE_QUERY_MAXRESULTSIZE, maxResultSize); - lctx.put(DataStoreProtocol.HBASE_QUERY_REVERSE, DataConvertHelper.toBoolean(Boolean.valueOf(reverse), true)); - lctx.put(DataStoreProtocol.HBASE_QUERY_PAGESIZE, DataConvertHelper.toLong(Long.valueOf(psize), 3000)); - // build log ds - buildDataStore(icm, logKey, DataStoreType.HBASE, new LogDataAdapter(), lctx); - - Map mctx = new HashMap(); - - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxPerRoute"), 10)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxRoute"), 50)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.soTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.connTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.reqTimeout"), 5000)); - - // build monitor ds - buildDataStore(icm, monitorKey, DataStoreType.OPENTSDB, new MonitorDataAdapter(), mctx); - - // build profile ds - buildDataStore(icm, profileKey, DataStoreType.MONGODB, new ProfileDataAdpater(), null); - - // build notify ds - buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null); - - Map nctx = new HashMap(); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000)); - - // build nodeinfo ds - buildDataStore(icm, nodeinfoKey, DataStoreType.OPENTSDB, new NodeInfoDataAdapter(), nctx); - - } - - /** - * buildDataStore - * - * @param icm - * @param dsName - * @param type - * @param adaptor - * @param context - */ - private void buildDataStore(IConfigurationManager icm, String dsName, DataStoreType type, DataStoreAdapter adaptor, - Map context) { - - boolean enable = false; - - enable = Boolean.parseBoolean(icm.getFeatureConfiguration(this.feature, dsName + ".ds.enable")); - - if (enable) { - - String serverlist = icm.getFeatureConfiguration(this.feature, dsName + ".ds.servers"); - - if (serverlist == null) { - log.warn(this, "Config[ds.servers] of DataStore[" + dsName + "] is NULL."); - return; - } - - String dbName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.db"); - - String dbPower = icm.getFeatureConfiguration(this.feature, dsName + ".ds.power"); - - String userName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.usr"); - - String password = icm.getFeatureConfiguration(this.feature, dsName + ".ds.pwd"); - - int retry = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.retry"), 3); - - int expire = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.expire"), 3); - - List servers = DataConvertHelper.toList(serverlist, ","); - - DataStoreConnection conn = new DataStoreConnection(userName, password, dbName, dbPower, servers, type); - - conn.setRetryTimes(retry); - - conn.setBlackExpireTime(expire); - - if (context != null) { - conn.putContextAll(context); - } - - DataStoreFactory.getInstance().build(dsName, conn, adaptor, this.feature); - } - } - - @SuppressWarnings("rawtypes") - @Override - public Object exchange(String eventKey, Object... data) { - - log.info(this, "HM got exchange event"); - - if (null == data) { - log.err(this, "the exchange data is empty"); - return null; - } - DataStoreMsg msg = (DataStoreMsg) data[0]; - - AbstractDataStore dataStore = DataStoreFactory.getInstance() - .get((String) msg.get(DataStoreProtocol.DATASTORE_NAME)); - - Object rst = null; - - switch (eventKey) { - case HealthManagerConstants.QUERY: - - rst = dataStore.doQuery(msg); - return rst; - case HealthManagerConstants.INSERT: - - rst = dataStore.doUpdate(msg); - return rst; - case HealthManagerConstants.UPDATE: - - rst = dataStore.doUpdate(msg); - return rst; - } - throw new RuntimeException("Exchange Event [" + eventKey + "] handle FAIL: data=" + data); - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.uavstack.resources.common.messaging.StandardMessagingBuilder; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.monitor.api.MonitorDataFrame; +import com.creditease.agent.profile.api.StandardProfileModeler; +import com.creditease.agent.spi.AgentFeatureComponent; +import com.creditease.agent.spi.IActionEngine; +import com.creditease.agent.spi.IConfigurationManager; +import com.creditease.uav.cache.api.CacheManager; +import com.creditease.uav.cache.api.CacheManagerFactory; +import com.creditease.uav.datastore.api.DataStoreAdapter; +import com.creditease.uav.datastore.api.DataStoreConnection; +import com.creditease.uav.datastore.api.DataStoreFactory; +import com.creditease.uav.datastore.api.DataStoreFactory.DataStoreType; +import com.creditease.uav.datastore.api.DataStoreMsg; +import com.creditease.uav.datastore.api.DataStoreProtocol; +import com.creditease.uav.datastore.core.AbstractDataStore; +import com.creditease.uav.feature.healthmanager.HealthManagerConstants; +import com.creditease.uav.feature.healthmanager.HealthManagerProfileDataLifeKeeper; +import com.creditease.uav.feature.healthmanager.HealthManagerServerWorker; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater; +import com.creditease.uav.messaging.api.MessageConsumer; + +public class HealthManager extends AgentFeatureComponent { + + private MessageConsumer monitorDataConsumer; + + private MessageConsumer notificationConsumer; + + private MessageConsumer profileDataConsumer; + + private MessageConsumer logDataConsumer; + + private MessageConsumer nodeinfoDataConsumer; + + private HealthManagerServerWorker healthServerListenWorker; + + private boolean isStartLifeKeeper = false; + + public HealthManager(String cName, String feature) { + super(cName, feature); + } + + @Override + public void start() { + + // init cache manager + String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr"); + int minConcurrent = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min")); + int maxConcurrent = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max")); + int queueSize = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize")); + String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd"); + + CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, + password); + + this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm); + + // start HealthManagerProfileDataLifeKeeper + isStartLifeKeeper = Boolean + .parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable")); + + if (isStartLifeKeeper == true) { + + // init HealthManagerProfileDataLifeKeeper + HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper( + "HealthManagerProfileDataLifeKeeper", this.feature); + + long interval = Long + .parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval")); + + long randomDely = new Random().nextInt(3) + 3; + + this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", + profileDataLifeKeepWorker, randomDely * 1000, interval); + + if (log.isTraceEnable()) { + log.info(this, "HealthManagerProfileDataLifeKeeper started"); + } + } + + /** + * Start the DBStore service NOTE: this must be the first to start + */ + buildDataStores(this.getConfigManager()); + + // start all datastores + DataStoreFactory.getInstance().startAll(this.feature); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore Factory started"); + } + + /** + * Start the HealthManger Http service + */ + int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port")); + int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog")); + int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core")); + int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max")); + int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize")); + + healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, + "healthMangerHandlers"); + + @SuppressWarnings({ "rawtypes", "unchecked" }) + ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, + new ArrayBlockingQueue(bqsize)); + + healthServerListenWorker.start(exe, port, backlog); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore HttpServer started"); + } + + StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature); + + try { + smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers"); + } + catch (IOException e) { + log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e); + return; + } + + monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString()); + + notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString()); + + profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString()); + + logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString()); + + nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString()); + + // start monitorDataConsumer + if (monitorDataConsumer != null) { + + monitorDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, + monitorDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager MDFConsumer started"); + } + } + + // start notificationConsumer + if (this.notificationConsumer != null) { + notificationConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, + notificationConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager NotifyConsumer started"); + } + } + + // start profileDataConsumer + if (this.profileDataConsumer != null) { + + /** + * INIT StandardProfileModelingEngine & StandardProfileModeler + */ + IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature); + + new StandardProfileModeler("StandardProfileModeler", feature, engine); + + // start profile consumer + profileDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, + profileDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager ProfileConsumer started"); + } + } + + // start logDataConsumer + if (this.logDataConsumer != null) { + logDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, + logDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager LogConsumer started"); + } + } + + // start nodeinfoDataConsumer + if (nodeinfoDataConsumer != null) { + + nodeinfoDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, + nodeinfoDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager NodeInfoConsumer started"); + } + } + } + + @Override + public void stop() { + + // stop monitorDataConsumer + if (this.monitorDataConsumer != null) { + monitorDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR); + if (log.isTraceEnable()) { + log.info(this, "HealthManager MdfConsumer shutdown"); + } + } + + // stop notificationConsumer + if (this.notificationConsumer != null) { + notificationConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY); + if (log.isTraceEnable()) { + log.info(this, "HealthManager NotifyConsumer shutdown"); + } + } + + // stop profileDataConsumer + if (this.profileDataConsumer != null) { + + // shut down StandardProfileModelingEngine + this.getActionEngineMgr().shutdown("StandardProfileModelingEngine"); + + profileDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE); + if (log.isTraceEnable()) { + log.info(this, "HealthManager ProfileConsumer shutdown"); + } + } + + // stop logDataConsumer + if (this.logDataConsumer != null) { + logDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_LOG); + if (log.isTraceEnable()) { + log.info(this, "HealthManager LogConsumer shutdown"); + } + } + + // stop nodeinfoDataConsumer + if (this.nodeinfoDataConsumer != null) { + nodeinfoDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NODE); + if (log.isTraceEnable()) { + log.info(this, "HealthManager NodeInfoConsumer shutdown"); + } + } + // stop healthServerListenWorker + healthServerListenWorker.stop(); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore HttpServer shutdown"); + } + + // NOTE: this should be the last to stop + DataStoreFactory.getInstance().stopAll(this.feature); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore Factory shutdown"); + } + + if (isStartLifeKeeper == true) { + + // stop HealthManagerProfileDataLifeKeeper + this.getTimerWorkManager().cancel("HealthManagerProfileDataLifeKeeper"); + + if (log.isTraceEnable()) { + log.info(this, "HealthManagerProfileDataLifeKeeper stopped"); + } + } + + // shutdown CacheManager + CacheManager HMCacheManager = (CacheManager) this.getConfigManager().getComponent(this.feature, + "HMCacheManager"); + HMCacheManager.shutdown(); + + super.stop(); + } + + private void buildDataStores(IConfigurationManager icm) { + + // monitor + String monitorKey = MonitorDataFrame.MessageType.Monitor.toString(); + + // profile + String profileKey = MonitorDataFrame.MessageType.Profile.toString(); + + // notification + String notifyKey = MonitorDataFrame.MessageType.Notification.toString(); + + // nodeinfo + String nodeinfoKey = MonitorDataFrame.MessageType.NodeInfo.toString(); + + Map mctx = new HashMap(); + + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxPerRoute"), 10)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxRoute"), 50)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.soTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.connTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.reqTimeout"), 5000)); + + // build monitor ds + buildDataStore(icm, monitorKey, DataStoreType.OPENTSDB, new MonitorDataAdapter(), mctx); + + // build profile ds + buildDataStore(icm, profileKey, DataStoreType.MONGODB, new ProfileDataAdpater(), null); + + // build notify ds + buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null); + + Map nctx = new HashMap(); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000)); + + // build nodeinfo ds + buildDataStore(icm, nodeinfoKey, DataStoreType.OPENTSDB, new NodeInfoDataAdapter(), nctx); + + } + + /** + * buildDataStore + * + * @param icm + * @param dsName + * @param type + * @param adaptor + * @param context + */ + private void buildDataStore(IConfigurationManager icm, String dsName, DataStoreType type, DataStoreAdapter adaptor, + Map context) { + + boolean enable = DataConvertHelper.toBoolean(icm.getFeatureConfiguration(this.feature, dsName + ".ds.enable"),false); + + if (enable) { + + String serverlist = icm.getFeatureConfiguration(this.feature, dsName + ".ds.servers"); + + if (serverlist == null) { + log.warn(this, "Config[ds.servers] of DataStore[" + dsName + "] is NULL."); + return; + } + + String dbName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.db"); + + String dbPower = icm.getFeatureConfiguration(this.feature, dsName + ".ds.power"); + + String userName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.usr"); + + String password = icm.getFeatureConfiguration(this.feature, dsName + ".ds.pwd"); + + int retry = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.retry"), 3); + + int expire = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.expire"), 3); + + List servers = DataConvertHelper.toList(serverlist, ","); + + DataStoreConnection conn = new DataStoreConnection(userName, password, dbName, dbPower, servers, type); + + conn.setRetryTimes(retry); + + conn.setBlackExpireTime(expire); + + if (context != null) { + conn.putContextAll(context); + } + + DataStoreFactory.getInstance().build(dsName, conn, adaptor, this.feature); + } + } + + @SuppressWarnings("rawtypes") + @Override + public Object exchange(String eventKey, Object... data) { + + log.info(this, "HM got exchange event"); + + if (null == data) { + log.err(this, "the exchange data is empty"); + return null; + } + DataStoreMsg msg = (DataStoreMsg) data[0]; + + AbstractDataStore dataStore = DataStoreFactory.getInstance() + .get((String) msg.get(DataStoreProtocol.DATASTORE_NAME)); + + Object rst = null; + + switch (eventKey) { + case HealthManagerConstants.QUERY: + + rst = dataStore.doQuery(msg); + return rst; + case HealthManagerConstants.INSERT: + + rst = dataStore.doUpdate(msg); + return rst; + case HealthManagerConstants.UPDATE: + + rst = dataStore.doUpdate(msg); + return rst; + } + throw new RuntimeException("Exchange Event [" + eventKey + "] handle FAIL: data=" + data); + } +} From 825898eb267a5a01078a7d9d753fe1d2bef07318 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 25 Jan 2018 16:51:37 +0800 Subject: [PATCH 02/97] =?UTF-8?q?=E4=BF=AE=E6=AD=A3HM=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/hm_apmserver.properties | 16 +++++++-------- .../config/hm_apphubmgr.properties | 18 ++++++++--------- .../config/hm_hbserver.properties | 12 +++++------ .../config/hm_logserver.properties | 12 +++++------ .../config/hm_moserver.properties | 12 +++++------ .../config/hm_nodeserver.properties | 14 ++++++------- .../config/hm_pfntfyserver.properties | 14 ++++++------- .../config/hm_pnhbserver.properties | 20 +++++++++---------- .../config/hm_rtserver.properties | 12 +++++------ 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties index 42e3b5e0..b2683734 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10146 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- # Data Collect Feature -feature.collectserver.loader=default +feature.collectserver.loader=com.creditease.uav.collect.jar feature.collectserver.enable=true feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager feature.collectserver.properties= @@ -96,7 +96,7 @@ feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true #InvokeChain Process Server Feature -feature.invokechainserver.loader=default +feature.invokechainserver.loader=com.creditease.uav.invokechain.jar feature.invokechainserver.enable=true feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer feature.invokechainserver.properties= @@ -121,7 +121,7 @@ feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeCh #Thread Analysis Server Feature -feature.threadanalysisserver.loader=default +feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar feature.threadanalysisserver.enable=true feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer #elastic-search diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties index b1344b01..c9c2bb84 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties @@ -15,7 +15,7 @@ meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10120 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- #feature apphubmanager BEGIN------------------------------------------------------------------ -feature.apphubmanager.loader=default +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar feature.apphubmanager.enable=true feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler @@ -89,7 +89,7 @@ feature.apphubmanager.ds.pwd= #HealthManager------------------------------------------------------------------ #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -175,7 +175,7 @@ feature.healthmanager.MT_Node.ds.expire=30000 #-------------------------------HBServer Query-------------------------- #heartbeatserveragent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbserveragent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -208,7 +208,7 @@ feature.hbserveragent.lifekeeper.nodetimeout=30000 #-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties index fb1aa0e7..aa917e13 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -40,7 +40,7 @@ feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10110 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #heartbeatserveragent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbserveragent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -106,7 +106,7 @@ feature.hbserveragent.ntp.enable=false #-------------------------------------------RUNTIME NOTIFY------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties index 8a9a4da3..9df2793a 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10130 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- #HealthManager NewLogService Feature -feature.newlogservice.loader=default +feature.newlogservice.loader=com.creditease.uav.invokechain.jar feature.newlogservice.enable=true feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService feature.newlogservice.properties= diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties index a03bb3c6..9cd8b3f6 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties @@ -16,7 +16,7 @@ meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -25,7 +25,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -34,14 +34,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10140 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -56,7 +56,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #HealthManager #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties index d851fc89..48766390 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties @@ -16,7 +16,7 @@ meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -25,7 +25,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -34,14 +34,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10145 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -56,7 +56,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #HealthManager #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -94,7 +94,7 @@ feature.healthmanager.MT_Profile.enable=false feature.healthmanager.MT_Node.enable=true #feature.healthmanager.healthmanger handlers feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 +feature.healthmanager.http.port=8045 feature.healthmanager.http.backlog=10 feature.healthmanager.http.core=10 feature.healthmanager.http.max=200 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties index 7796935f..70ad37e5 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10150 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #HealthManager #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -158,7 +158,7 @@ feature.healthmanager.MT_Node.ds.expire=30000 #-----------------------------NOTIFICATION CENTER--------------------------------------------------- #notifcenter -feature.notifycenter.loader=default +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar #feature.xxx.enable should enable this feature feature.notifycenter.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties index 7f88d43f..95bfa89d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties @@ -14,7 +14,7 @@ meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -23,7 +23,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -32,14 +32,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10110 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -54,7 +54,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #----------------------------------------------------------------------------------------------------- #feature apphubmanager BEGIN -feature.apphubmanager.loader=default +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar feature.apphubmanager.enable=true feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler @@ -88,7 +88,7 @@ feature.apphubmanager.ds.pwd= #feature apphubmanager END #notifcenter -feature.notifycenter.loader=default +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar #feature.xxx.enable should enable this feature feature.notifycenter.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -142,7 +142,7 @@ feature.notifycenter.push.services= #agent feature configuration #Monitor Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -231,7 +231,7 @@ feature.healthmanager.MT_Node.ds.expire=30000 #heartbeatserveragent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbserveragent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -266,7 +266,7 @@ feature.hbserveragent.ntp.enable=false #------------------------------------------------------------------------------------ #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties index 4da6def3..c62990b2 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10140 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -70,7 +70,7 @@ feature.hbclientagent.interval=15000 #-------------------------------------------RUNTIME NOTIFY------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler From 26a98b03a984b88567ed7e223062062587f220ed Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Tue, 30 Jan 2018 16:53:20 +0800 Subject: [PATCH 03/97] https://github.com/uavorg/uavstack/issues/176 openTsdb Configuration modification modify hm_test configuration file parameters; modify NodeInfoDataAdapter bug; --- .../config/agent.properties | 6 +++--- .../config/hm_pro_logserver.properties | 6 +++--- .../config/hm_pro_pfntfyserver.properties | 6 +++--- .../config/hm_test_logserver.properties | 6 +++--- .../config/hm_test_moserver.properties | 6 +++--- .../config/hm_test_nodeserver.properties | 6 +++--- .../config/hm_test_pnhbserver.properties | 6 +++--- .../com/creditease/uav/feature/HealthManager.java | 11 ++++++----- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index 6812feea..3f9b1f4c 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -169,9 +169,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 feature.healthmanager.MT_Monitor.ds.retry=3 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=50 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties index ad29351d..b266eabd 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties @@ -133,9 +133,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=50 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties index ab40d611..50edb9de 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties @@ -134,9 +134,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=50 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties index 16aeb53e..c0950810 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties @@ -134,9 +134,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=50 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties index fd792739..92efa704 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties @@ -135,9 +135,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=300 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties index d0fc078c..7337af99 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties @@ -135,9 +135,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=300 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties index 54d67f84..7764a0e6 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties @@ -205,9 +205,9 @@ feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 #opentsdb batch size feature.healthmanager.MT_Monitor.ds.batchsize=50 feature.healthmanager.MT_Monitor.ds.retry=3 diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java index 5feb9db5..87865e94 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java @@ -73,6 +73,7 @@ public class HealthManager extends AgentFeatureComponent { private boolean isStartLifeKeeper = false; public HealthManager(String cName, String feature) { + super(cName, feature); } @@ -378,15 +379,15 @@ private void buildDataStores(IConfigurationManager icm) { buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null); Map nctx = new HashMap(); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper + nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, + nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper + nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper + nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper + nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000)); // build nodeinfo ds From 34821e6636445f43afd8b4a76382e19f5ab3ea3a Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Thu, 1 Feb 2018 10:45:12 +0800 Subject: [PATCH 04/97] https://github.com/uavorg/uavstack/issues/178 The judgment and processing of the return state code in the completed method; NotifyDataAdpater add notifyType column; --- .../nodeopagent/actions/MOFCtrlAction.java | 25 ++++++++++++++----- .../datastore/adaptors/NotifyDataAdpater.java | 10 ++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFCtrlAction.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFCtrlAction.java index 8ccc6231..32a7995e 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFCtrlAction.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFCtrlAction.java @@ -86,13 +86,26 @@ public void completed(HttpClientCallbackResult result) { String res = result.getReplyDataAsString(); - log.info(this, "MOFCtrlAction Success: url=" + url + ", res=" + res); - - if (!StringHelper.isEmpty(res)) { - isSuccess.set(true); + if (result.getRetCode() >= 400) { + log.err(this, + "MOFCtrlAction FAIL: retcode=" + result.getRetCode() + ", url=" + url + ", err=" + res); + if (result.getRetCode() >= 500) { + response.append("请求" + url + "完成时的状态码为【" + result.getRetCode() + "】, 服务器遇到错误而不能完成该请求."); + } + else { + response.append("请求" + url + "完成时的状态码为【" + result.getRetCode() + "】, 请求客户端错误."); + } + + isSuccess.set(false); + } + else { + response.append(res); + log.info(this, + "MOFCtrlAction Success: retcode=" + result.getRetCode() + ", url=" + url + ", res=" + res); + if (!StringHelper.isEmpty(res)) { + isSuccess.set(true); + } } - - response.append(res); cdl.countDown(); } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/datastore/adaptors/NotifyDataAdpater.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/datastore/adaptors/NotifyDataAdpater.java index 955d6bf8..48d5e241 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/datastore/adaptors/NotifyDataAdpater.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/datastore/adaptors/NotifyDataAdpater.java @@ -79,6 +79,7 @@ public Object prepareInsertObj(DataStoreMsg msg, DataStoreConnection NotifyDataA document.put("ip", ne.getIP()); document.put("appgroup", args.get("appgroup")); document.put("createtime", System.currentTimeMillis()); + document.put("notifyType", getNotifyType(ne.getTitle())); documents.add(document); } @@ -119,4 +120,13 @@ public String getKeyfromNTFE(NotificationEvent data) { return key; } + public static String getNotifyType(String title) { + String[] titleArray = title.split("@"); + if (titleArray.length > 2) { + return titleArray[1]; + } + else { + return "UNKNOWN"; + } + } } From f064668bb9e7e9b7c70f000a45d7bbc241c45cca Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 1 Feb 2018 18:06:12 +0800 Subject: [PATCH 05/97] resolve conflict --- .../config/hm_apphubmgr.properties | 255 +----------------- .../config/hm_moserver.properties | 159 +---------- .../config/hm_nodeserver.properties | 170 ------------ 3 files changed, 2 insertions(+), 582 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties index 3469362f..7933decc 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD:com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties #log configuration #log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL log.level=INFO @@ -249,256 +248,4 @@ feature.runtimenotify.crash.timeout=300000 #sync interval from cache feature.runtimenotify.strategy.interval=60000 #in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} -======= -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10120 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#feature apphubmanager BEGIN------------------------------------------------------------------ -feature.apphubmanager.loader=default -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=20 -feature.apphubmanager.http.max=100 -feature.apphubmanager.http.bqsize=20 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=uav.db.jishu.idc:25000 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#HealthManager------------------------------------------------------------------ -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=20 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=30 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=50 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-------------------------------HBServer Query-------------------------- -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8012 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8022 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=20 -feature.hbserveragent.http.max=150 -feature.hbserveragent.http.bqsize=5 -feature.hbserveragent.store.addr=127.0.0.1:26379 -feature.hbserveragent.store.concurrent.min=30 -feature.hbserveragent.store.concurrent.max=150 -feature.hbserveragent.store.concurrent.bqsize=5 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=30000 - -#-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.storecm.server=127.0.0.1:26379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=60 -feature.runtimenotify.storecm.qsize=20 -#qworker -feature.runtimenotify.qworker.coresize=10 -feature.runtimenotify.qworker.maxsize=30 -feature.runtimenotify.qworker.bqsize=50 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9004 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=20 -feature.runtimenotify.http.max=100 -feature.runtimenotify.http.bqsize=5 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} ->>>>>>> master:com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties index 27dbdf58..9cd8b3f6 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD:com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties #log configuration #log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL log.level=INFO @@ -154,160 +153,4 @@ feature.healthmanager.MT_Node.ds.reqTimeout=3000 feature.healthmanager.MT_Node.ds.retry=3 #opentsdb batch size feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 -======= -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=50 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 ->>>>>>> master:com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties +feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties index 3070e0fb..48766390 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD:com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties #log configuration #log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL log.level=INFO @@ -154,173 +153,4 @@ feature.healthmanager.MT_Node.ds.reqTimeout=3000 feature.healthmanager.MT_Node.ds.retry=3 #opentsdb batch size feature.healthmanager.MT_Node.ds.batchsize=50 -======= -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10145 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=false -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=false -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=false -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 ->>>>>>> master:com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file From 20f7f5bd66d5d8464df567252fb4f19edb4e65de Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 1 Feb 2018 18:45:04 +0800 Subject: [PATCH 06/97] https://github.com/uavorg/uavstack/issues/181 https://github.com/uavorg/uavstack/issues/182 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #181 springboot2.0 support #182 deploy inner uav app in springboot 1.move hook point onSpringBeanRegist、onSpringFinishRefresh to AbstractApplicationContext's refresh method in springboot. 2.move InstallMOF hook point to SpringApplication's prepareEnvironment method 2.add deployUAVApp hook point before Embed-Tomcat start. --- .../adaptors/SpringBootTomcatAdaptor.java | 782 ++++++----- com.creditease.uav.tomcat.plus.core/pom.xml | 100 +- .../interceptor/SpringBootTomcatPlusIT.java | 893 +++++++------ .../tomcat/plus/interceptor/TomcatPlusIT.java | 1163 +++++++++-------- 4 files changed, 1502 insertions(+), 1436 deletions(-) diff --git a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java index 2c823600..6d85b5d8 100644 --- a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java +++ b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java @@ -1,396 +1,386 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.monitorframework.adaptors; - -import javassist.ClassPool; -import javassist.CtMethod; - -public class SpringBootTomcatAdaptor extends AbstractAdaptor { - - @Override - public byte[] onStartup(ClassLoader clsLoader, String uavMofRoot, String className) { - - System.out.println("MOF.ApplicationContainer=SpringBoot.Tomcat"); - - if (pool == null) { - pool = ClassPool.getDefault(); - } - - final AbstractAdaptor aa = this; - - final String mofRoot = uavMofRoot; - - if ("org.springframework.boot.loader.Launcher".equals(className)) { - return this.inject("org.springframework.boot.loader.Launcher", - new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", - "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); - m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + "\"); mObj.installMOF($_);}"); - } - - @Override - public String getMethodName() { - - return "createClassLoader"; - } - - }); - } - else if ("org.springframework.boot.SpringApplication".equals(className)) { - return this.inject("org.springframework.boot.SpringApplication", - new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", - "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); - m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot - + "\"); mObj.installMOF(getClassLoader());}"); - } - - @Override - public String getMethodName() { - - return "initialize"; - } - - }); - } - return null; - } - - @Override - public byte[] onLoadClass(ClassLoader clsLoader, String uavMofRoot, String className) { - - this.addClassPath(clsLoader); - - final AbstractAdaptor aa = this; - - // log4j劫持 - if (className.equals("org.apache.log4j.helpers.QuietWriter")) { - try { - String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; - aa.installJar(clsLoader, logJarPath, true); - // 兼容在ide环境下启动 - String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; - aa.installJar(clsLoader, mofJarPath, true); - aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", - "org.apache.log4j.helpers.QuietWriter", "new LogIT()"); - aa.defineField("uavLogHookLineSep", "java.lang.String", "org.apache.log4j.helpers.QuietWriter", - "System.getProperty(\"line.separator\")"); - } - catch (Exception e) { - System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); - e.printStackTrace(); - } - return this.inject(className, new String[] { "com.creditease.uav.log.hook.interceptors" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - m.insertBefore("{if(!$1.equals(uavLogHookLineSep)){$1=uavLogHook.formatLog($1);}}"); - } - - @Override - public String getMethodName() { - - return "write"; - } - - }); - } - - // 进行logback的劫持 - else if (className.equals("ch.qos.logback.core.encoder.LayoutWrappingEncoder")) { - try { - String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; - aa.installJar(clsLoader, logJarPath, true); - // 兼容在ide环境下启动 - String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; - aa.installJar(clsLoader, mofJarPath, true); - aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", - "ch.qos.logback.core.encoder.LayoutWrappingEncoder", "new LogIT()"); - } - catch (Exception e) { - System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); - e.printStackTrace(); - } - return this.inject(className, - new String[] { "com.creditease.uav.log.hook", "com.creditease.uav.log.hook.interceptors" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - m.insertBefore("{$1=uavLogHook.formatLog($1);}"); - } - - @Override - public String getMethodName() { - - return "convertToBytes"; - } - - }); - } - - else if (className.equals("org.springframework.context.support.AbstractApplicationContext")) - - { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor() { - - /** - * we need startServer before ApplicationContext's refresh cause some hook operation could - * happen when refresh. - */ - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.startServer(this.getEnvironment().getProperty(\"server.port\"),this.getEnvironment().getProperty(\"server.context-path\"),this.getEnvironment().getProperty(\"spring.application.name\"),this);}"); - } - - @Override - public String getMethodName() { - - return "refresh"; - } - - }); - } - - else if (className.equals("org.apache.catalina.core.StandardEngineValve")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServiceStart(new Object[]{this});}"); - m.insertAfter("{mObj.onServiceEnd(new Object[]{$1,$2});}"); - } - - @Override - public String getMethodName() { - - return "invoke"; - } - - }); - } - - else if (className.equals("org.apache.catalina.core.StandardContext")) { - - return this.inject(className, - new String[] { "com.creditease.tomcat.plus.interceptor", "org.apache.catalina.deploy", - "org.apache.catalina.core", "org.apache.tomcat.util.descriptor.web" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();mObj.onAppStarting(new Object[]{this}); }"); - } - - @Override - public String getMethodName() { - - return "mergeParameters"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore("{mObj=new SpringBootTomcatPlusIT();mObj.onAppInit(new Object[]{this});}"); - String sb = "{mObj.onAppStart(new Object[]{this});" + "FilterDef fd=new FilterDef();" - + "fd.setFilterClass(\"com.creditease.monitor.jee.filters.GlobalFilter\");" - + "fd.setDisplayName(\"UAV_Global_Filter\");" - + "fd.setFilterName(\"UAV_Global_Filter\");" - + "ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(this, fd);" - + "this.filterConfigs.put(\"UAV_Global_Filter\", filterConfig);" - + "FilterMap filterMap=new FilterMap();" - + "filterMap.setFilterName(\"UAV_Global_Filter\");" - + "filterMap.addURLPattern(\"/*\");" + "this.filterMaps.addBefore(filterMap);" - + "}"; - - m.insertAfter(sb); - } - - @Override - public String getMethodName() { - - return "startInternal"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter("{mObj=new SpringBootTomcatPlusIT();mObj.onAppStop(new Object[]{this});}"); - } - - @Override - public String getMethodName() { - - return "stopInternal"; - } - - } }); - } - else if (className.equals("org.apache.catalina.core.ApplicationContext")) { - - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();return mObj.onServletRegist(new Object[]{$_});}"); - } - - @Override - public String getMethodName() { - - return "getFacade"; - } - - } }); - } - else if (className.equals("org.apache.catalina.core.StandardWrapper")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStart(new Object[]{this,$_});}"); - } - - @Override - public String getMethodName() { - - return "loadServlet"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStop(new Object[]{this,this.instance});}"); - } - - @Override - public String getMethodName() { - - return "unload"; - } - - } }); - } - else if ( - // after Tomcat 8 - className.equals("org.apache.naming.factory.FactoryBase") || - // before Tomcat 7 - className.equals("org.apache.naming.factory.ResourceFactory")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public String getMethodName() { - - return "getObjectInstance"; - } - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onResourceInit(new Object[]{$1});}"); - m.insertAfter("{$_=mObj.onResourceCreate(new Object[]{$_,$1});}"); - } - - } }); - } - else if (className.equals("org.springframework.boot.context.embedded.EmbeddedWebApplicationContext")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public String getMethodName() { - - return "finishRefresh"; - } - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter("{mObj=new SpringBootTomcatPlusIT();mObj.onSpringFinishRefresh();}"); - } - - }, new AdaptorProcessor() { - - @Override - public String getMethodName() { - - return "postProcessBeanFactory"; - } - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onSpringBeanRegist(this.getEnvironment().getProperty(\"server.context-path\"));}"); - } - - } }); - } - - return null; - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.monitorframework.adaptors; + +import javassist.ClassPool; +import javassist.CtMethod; + +public class SpringBootTomcatAdaptor extends AbstractAdaptor { + + @Override + public byte[] onStartup(ClassLoader clsLoader, String uavMofRoot, String className) { + + System.out.println("MOF.ApplicationContainer=SpringBoot.Tomcat"); + + if (pool == null) { + pool = ClassPool.getDefault(); + } + + final AbstractAdaptor aa = this; + + final String mofRoot = uavMofRoot; + + if ("org.springframework.boot.loader.Launcher".equals(className)) { + return this.inject("org.springframework.boot.loader.Launcher", + new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", + "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); + m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + "\"); mObj.installMOF($_);}"); + } + + @Override + public String getMethodName() { + + return "createClassLoader"; + } + + }); + } + else if ("org.springframework.boot.SpringApplication".equals(className)) { + return this.inject("org.springframework.boot.SpringApplication", + new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", + "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); + m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + + "\"); mObj.installMOF(getClassLoader());}"); + } + + @Override + public String getMethodName() { + + return "prepareEnvironment"; + } + + }); + } + return null; + } + + @Override + public byte[] onLoadClass(ClassLoader clsLoader, final String uavMofRoot, String className) { + + this.addClassPath(clsLoader); + + final AbstractAdaptor aa = this; + + // log4j劫持 + if (className.equals("org.apache.log4j.helpers.QuietWriter")) { + try { + String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; + aa.installJar(clsLoader, logJarPath, true); + // 兼容在ide环境下启动 + String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; + aa.installJar(clsLoader, mofJarPath, true); + aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", + "org.apache.log4j.helpers.QuietWriter", "new LogIT()"); + aa.defineField("uavLogHookLineSep", "java.lang.String", "org.apache.log4j.helpers.QuietWriter", + "System.getProperty(\"line.separator\")"); + } + catch (Exception e) { + System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); + e.printStackTrace(); + } + return this.inject(className, new String[] { "com.creditease.uav.log.hook.interceptors" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + m.insertBefore("{if(!$1.equals(uavLogHookLineSep)){$1=uavLogHook.formatLog($1);}}"); + } + + @Override + public String getMethodName() { + + return "write"; + } + + }); + } + + // 进行logback的劫持 + else if (className.equals("ch.qos.logback.core.encoder.LayoutWrappingEncoder")) { + try { + String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; + aa.installJar(clsLoader, logJarPath, true); + // 兼容在ide环境下启动 + String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; + aa.installJar(clsLoader, mofJarPath, true); + aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", + "ch.qos.logback.core.encoder.LayoutWrappingEncoder", "new LogIT()"); + } + catch (Exception e) { + System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); + e.printStackTrace(); + } + return this.inject(className, + new String[] { "com.creditease.uav.log.hook", "com.creditease.uav.log.hook.interceptors" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + m.insertBefore("{$1=uavLogHook.formatLog($1);}"); + } + + @Override + public String getMethodName() { + + return "convertToBytes"; + } + + }); + } + + else if (className.equals("org.springframework.context.support.AbstractApplicationContext")) + + { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor() { + + /** + * we need startServer before ApplicationContext's refresh cause some hook operation could + * happen when refresh. the hook is done after startServer before refresh, and profiling will be done after refresh + */ + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.startServer(this.getEnvironment().getProperty(\"server.port\"),this.getEnvironment().getProperty(\"server.context-path\"),this.getEnvironment().getProperty(\"spring.application.name\"),this);mObj.onSpringBeanRegist(new Object[]{this,this.getEnvironment().getProperty(\"server.context-path\")});}"); + m.insertAfter("{mObj.onSpringFinishRefresh(this);}"); + + } + + @Override + public String getMethodName() { + + return "refresh"; + } + + }); + } + + else if (className.equals("org.apache.catalina.core.StandardEngineValve")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServiceStart(new Object[]{this});}"); + m.insertAfter("{mObj.onServiceEnd(new Object[]{$1,$2});}"); + } + + @Override + public String getMethodName() { + + return "invoke"; + } + + }); + } + + else if (className.equals("org.apache.catalina.core.StandardContext")) { + + return this.inject(className, + new String[] { "com.creditease.tomcat.plus.interceptor", "org.apache.catalina.deploy", + "org.apache.catalina.core", "org.apache.tomcat.util.descriptor.web" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();mObj.onAppStarting(new Object[]{this}); }"); + } + + @Override + public String getMethodName() { + + return "mergeParameters"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore("{mObj=new SpringBootTomcatPlusIT();mObj.onAppInit(new Object[]{this});}"); + String sb = "{mObj.onAppStart(new Object[]{this});" + "FilterDef fd=new FilterDef();" + + "fd.setFilterClass(\"com.creditease.monitor.jee.filters.GlobalFilter\");" + + "fd.setDisplayName(\"UAV_Global_Filter\");" + + "fd.setFilterName(\"UAV_Global_Filter\");" + + "ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(this, fd);" + + "this.filterConfigs.put(\"UAV_Global_Filter\", filterConfig);" + + "FilterMap filterMap=new FilterMap();" + + "filterMap.setFilterName(\"UAV_Global_Filter\");" + + "filterMap.addURLPattern(\"/*\");" + "this.filterMaps.addBefore(filterMap);" + + "}"; + + m.insertAfter(sb); + } + + @Override + public String getMethodName() { + + return "startInternal"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter("{mObj=new SpringBootTomcatPlusIT();mObj.onAppStop(new Object[]{this});}"); + } + + @Override + public String getMethodName() { + + return "stopInternal"; + } + + } }); + } + else if (className.equals("org.apache.catalina.core.ApplicationContext")) { + + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();return mObj.onServletRegist(new Object[]{$_});}"); + } + + @Override + public String getMethodName() { + + return "getFacade"; + } + + } }); + } + else if (className.equals("org.apache.catalina.core.StandardWrapper")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStart(new Object[]{this,$_});}"); + } + + @Override + public String getMethodName() { + + return "loadServlet"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStop(new Object[]{this,this.instance});}"); + } + + @Override + public String getMethodName() { + + return "unload"; + } + + } }); + } + else if ( + // after Tomcat 8 + className.equals("org.apache.naming.factory.FactoryBase") || + // before Tomcat 7 + className.equals("org.apache.naming.factory.ResourceFactory")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public String getMethodName() { + + return "getObjectInstance"; + } + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onResourceInit(new Object[]{$1});}"); + m.insertAfter("{$_=mObj.onResourceCreate(new Object[]{$_,$1});}"); + } + + } }); + } + // onDeployUAVApp + else if (className.equals("org.apache.catalina.startup.Tomcat")) { + + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public String getMethodName() { + + return "start"; + } + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onDeployUAVApp(new Object[]{this,\"" + + uavMofRoot + "\"});}"); + } + + } }); + } + + return null; + } + +} diff --git a/com.creditease.uav.tomcat.plus.core/pom.xml b/com.creditease.uav.tomcat.plus.core/pom.xml index 248d31de..499eb88d 100644 --- a/com.creditease.uav.tomcat.plus.core/pom.xml +++ b/com.creditease.uav.tomcat.plus.core/pom.xml @@ -1,48 +1,54 @@ - - - - ce-datamonitorsystem - com.creditease.moniter - 1.0 - ../com.creditease.uav.superpom - - 4.0.0 - - com.creditease.uav.tomcat.plus.core - - - - com.creditease.moniter - com.creditease.uav.monitorframework - - - celocaljar - tomcat-juli - 1.0 - system - ${basedir}/CompileLib/tomcat-juli.jar - - - celocaljar - catalina - 1.0 - system - ${basedir}/CompileLib/catalina.jar - - - celocaljar - tomcat-coyote - 1.0 - system - ${basedir}/CompileLib/tomcat-coyote.jar - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - + + + + ce-datamonitorsystem + com.creditease.moniter + 1.0 + ../com.creditease.uav.superpom + + 4.0.0 + + com.creditease.uav.tomcat.plus.core + + + + com.creditease.moniter + com.creditease.uav.monitorframework + + + celocaljar + tomcat-juli + 1.0 + system + ${basedir}/CompileLib/tomcat-juli.jar + + + celocaljar + catalina + 1.0 + system + ${basedir}/CompileLib/catalina.jar + + + celocaljar + tomcat-coyote + 1.0 + system + ${basedir}/CompileLib/tomcat-coyote.jar + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + org.apache.tomcat.embed + tomcat-embed-core + 8.5.0 + provided + + \ No newline at end of file diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java index 1125f799..27076324 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java @@ -1,414 +1,479 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.tomcat.plus.interceptor; - -import javax.servlet.Servlet; -import javax.servlet.ServletContext; - -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardWrapper; -import org.apache.catalina.loader.WebappClassLoader; - -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.helpers.ReflectionHelper; -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.interceptframework.InterceptSupport; -import com.creditease.monitor.interceptframework.spi.InterceptConstants; -import com.creditease.monitor.interceptframework.spi.InterceptContext; -import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; -import com.creditease.tomcat.plus.util.TomcatLog; -import com.creditease.uav.util.MonitorServerUtil; - -public class SpringBootTomcatPlusIT extends TomcatPlusIT { - - /** - * startUAVServer - */ - public void startServer(String port, String contextPath, String appName, Object arg) { - - if (!"AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())) { - return; - } - - // integrate Tomcat log - UAVServer.instance().setLog(new TomcatLog("MonitorServer")); - // start Monitor Server when server starts - UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.SPRINGBOOT }); - // set appid - setAppid(contextPath); - // set the connector port - UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, - DataConvertHelper.toInt(port, 8080)); - InterceptSupport iSupport = InterceptSupport.instance(); - // this context will be transmited from springboot mainThread to webcontainerInit thread then back to mainThread - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - context.put(InterceptConstants.APPNAME, appName); - } - - /** - * setAppid - * - * @param contextPath - */ - public void setAppid(String contextPath) { - - if (contextPath == null || "/".equals(contextPath)) { - contextPath = ""; - } - - System.setProperty("com.creditease.uav.appid", MonitorServerUtil.getApplicationId(contextPath, "")); - - } - - /** - * onAppStarting - * - * @param args - */ - @Override - public void onAppStarting(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - iSupport.doIntercept(context); - } - - @Override - public void onAppInit(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - /** - * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for - * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object - * - * for example, the DataSource related injection - */ - ic.put(InterceptConstants.CONTEXTOBJ, sc); - ic2.put(InterceptConstants.CONTEXTOBJ, sc); - } - - @Override - public void onResourceInit(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return; - } - - /** - * for Application Starting's Resource Init - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - iSupport.doIntercept(context); - } - - @Override - public Object onResourceCreate(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return args[0]; - } - - /** - * for Application Starting's Resource Create - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - context.put(InterceptConstants.RESOURCEOBJ, args[0]); - context.put(InterceptConstants.RESOURCECFG, args[1]); - - iSupport.doIntercept(context); - - return context.get(InterceptConstants.RESOURCEOBJ); - } - - /** - * onAppStart - * - * @param args - */ - @Override - public void onAppStart(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - if (context.get(InterceptConstants.APPNAME) == null) { - context.put(InterceptConstants.APPNAME, - ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - } - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - // we don't doIntercept here cause some pre-profile(like dubbo) not happen yet, profile will be done after - // finishRefresh - - } - - /** - * onAppStop - * - * @param args - */ - @Override - public void onAppStop(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); - - if (null == context || null == sc) { - return; - } - - /** - * NOTE: spring boot will reset tomcat webappclassloader to null when shutdown, we may use the currentThread's - * classloader as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - context.put(InterceptConstants.SERVLET_CONTEXT, - ReflectionHelper.getField(StandardContext.class, sc, "context", true)); - - iSupport.doIntercept(context); - } - - /** - * onServletStart - * - * @param args - */ - @Override - public void onServletStart(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - - iSupport.doIntercept(context); - } - - /** - * onServletStop - * - * @param args - */ - @Override - public void onServletStop(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - iSupport.doIntercept(context); - } - - /** - * springboot load beans before web container start, hook opr should be done before beanRegist in case of duplicate - * definition ,so we define SPRING_BEAN_REGIST event to trigger hook - */ - public void onSpringBeanRegist(String contextPath) { - - if (contextPath == null || "/".equals(contextPath)) { - contextPath = ""; - } - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.SPRING_BEAN_REGIST); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - context.put(InterceptConstants.BASEPATH, ""); - iSupport.doIntercept(context); - } - - /** - * ComponentProfile will be done after springboot finish it's context's refresh, cause every pre-profile(like dubbo) - * is ready. - * - */ - public void onSpringFinishRefresh() { - - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - - iSupport.doIntercept(context); - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.tomcat.plus.interceptor; + +import javax.servlet.Servlet; +import javax.servlet.ServletContext; + +import org.apache.catalina.Wrapper; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardWrapper; +import org.apache.catalina.loader.WebappClassLoader; +import org.apache.catalina.loader.WebappLoader; +import org.apache.catalina.startup.Tomcat; +import org.apache.tomcat.JarScanner; +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.interceptframework.InterceptSupport; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.tomcat.plus.util.TomcatLog; +import com.creditease.uav.util.MonitorServerUtil; + +public class SpringBootTomcatPlusIT extends TomcatPlusIT { + + /** + * startUAVServer + */ + public void startServer(String port, String contextPath, String appName, Object arg) { + + if(!isWebServerContext(arg)) { + return; + } + + // integrate Tomcat log + UAVServer.instance().setLog(new TomcatLog("MonitorServer")); + // start Monitor Server when server starts + UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.SPRINGBOOT }); + // set appid + setAppid(contextPath); + // set the connector port + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, + DataConvertHelper.toInt(port, 8080)); + InterceptSupport iSupport = InterceptSupport.instance(); + // this context will be transmited from springboot mainThread to webcontainerInit thread then back to mainThread + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + context.put(InterceptConstants.APPNAME, appName); + } + + /** + * setAppid + * + * @param contextPath + */ + public void setAppid(String contextPath) { + + if (contextPath == null || "/".equals(contextPath)) { + contextPath = ""; + } + + System.setProperty("com.creditease.uav.appid", MonitorServerUtil.getApplicationId(contextPath, "")); + + } + + /** + * onAppStarting + * + * @param args + */ + @Override + public void onAppStarting(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + iSupport.doIntercept(context); + } + + @Override + public void onAppInit(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + /** + * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for + * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object + * + * for example, the DataSource related injection + */ + ic.put(InterceptConstants.CONTEXTOBJ, sc); + ic2.put(InterceptConstants.CONTEXTOBJ, sc); + } + + @Override + public void onResourceInit(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return; + } + + /** + * for Application Starting's Resource Init + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + iSupport.doIntercept(context); + } + + @Override + public Object onResourceCreate(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return args[0]; + } + + /** + * for Application Starting's Resource Create + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + context.put(InterceptConstants.RESOURCEOBJ, args[0]); + context.put(InterceptConstants.RESOURCECFG, args[1]); + + iSupport.doIntercept(context); + + return context.get(InterceptConstants.RESOURCEOBJ); + } + + /** + * onAppStart + * + * @param args + */ + @Override + public void onAppStart(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + //springboot use threadlocalContext to store the WEBCONTAINER_STARTED Event context, just return when it's uav's inner app in case of rewriting the real app's context + if("/com.creditease.uav".equals(contextPath)) { + return; + } + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + if (context.get(InterceptConstants.APPNAME) == null) { + context.put(InterceptConstants.APPNAME, + ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + } + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + // we don't doIntercept here cause some pre-profile(like dubbo) not happen yet, profile will be done after + // finishRefresh + + } + + /** + * onAppStop + * + * @param args + */ + @Override + public void onAppStop(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); + + if (null == context || null == sc) { + return; + } + + /** + * NOTE: spring boot will reset tomcat webappclassloader to null when shutdown, we may use the currentThread's + * classloader as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + context.put(InterceptConstants.SERVLET_CONTEXT, + ReflectionHelper.getField(StandardContext.class, sc, "context", true)); + + iSupport.doIntercept(context); + } + + /** + * onServletStart + * + * @param args + */ + @Override + public void onServletStart(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + + iSupport.doIntercept(context); + } + + /** + * onServletStop + * + * @param args + */ + @Override + public void onServletStop(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + iSupport.doIntercept(context); + } + + /** + * springboot load beans before web container start, hook opr should be done before beanRegist in case of duplicate + * definition ,so we define SPRING_BEAN_REGIST event to trigger hook + */ + public void onSpringBeanRegist(Object... args) { + + if(!isWebServerContext(args[0])) { + return; + } + + String contextPath=(String) args[1]; + + if (contextPath == null || "/".equals(contextPath)) { + contextPath = ""; + } + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.SPRING_BEAN_REGIST); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + context.put(InterceptConstants.BASEPATH, ""); + iSupport.doIntercept(context); + } + + /** + * ComponentProfile will be done after springboot finish it's context's refresh, cause every pre-profile(like dubbo) + * is ready. + * + */ + public void onSpringFinishRefresh(Object arg) { + + if(!isWebServerContext(arg)) { + return; + } + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + + iSupport.doIntercept(context); + } + + public void onDeployUAVApp(Object... args) { + + if(UAVServer.ServerVendor.SPRINGBOOT!=UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) { + return; + } + + Tomcat tomcat=(Tomcat) args[0]; + String mofRoot=(String) args[1]; + + //add uavApp + StandardContext context=new StandardContext(); + context.setName("com.creditease.uav"); + context.setPath("/com.creditease.uav"); + context.setDocBase(mofRoot + "/com.creditease.uav"); + context.addLifecycleListener(new Tomcat.FixContextListener()); + tomcat.getHost().addChild(context); + + //add default servlet + Wrapper servlet = context.createWrapper(); + servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet"); + servlet.setName("default"); + context.addChild(servlet); + servlet.setOverridable(true); + context.addServletMapping("/", "default"); + + //init webapp classloader + context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); + context.setDelegate(true); + + //after tomcat8, skip jarscan + Object obj=ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader()); + if(obj!=null) { + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + + context.setJarScanner((JarScanner) obj); + } + } + + /** + * judge if the AbstractApplicationContext is WebServerContext,cause we only hook the WebServerContext's lifecycle + * + */ + private boolean isWebServerContext(Object arg) { + //before SpringBoot 2.0.0, the WebServerContext class is 'AnnotationConfigEmbeddedWebApplicationContext',after SpringBoot 2.0.0(include) change to 'AnnotationConfigServletWebServerApplicationContext' + return ("AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())||"AnnotationConfigServletWebServerApplicationContext".equals(arg.getClass().getSimpleName())); + } +} diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java index 6c405984..1f81db7e 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java @@ -1,579 +1,584 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.tomcat.plus.interceptor; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.servlet.Servlet; -import javax.servlet.ServletContext; - -import org.apache.catalina.Host; -import org.apache.catalina.connector.Connector; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardWrapper; -import org.apache.catalina.loader.WebappClassLoader; -import org.apache.catalina.startup.HostConfig; -import org.apache.catalina.util.ContextName; - -import com.creditease.agent.helpers.ReflectionHelper; -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.captureframework.spi.Monitor; -import com.creditease.monitor.interceptframework.InterceptSupport; -import com.creditease.monitor.interceptframework.StandardInterceptContextHelper; -import com.creditease.monitor.interceptframework.spi.InterceptConstants; -import com.creditease.monitor.interceptframework.spi.InterceptContext; -import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; -import com.creditease.monitor.jee.servlet30.DynamicServletContextProcessor; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; -import com.creditease.tomcat.plus.util.TomcatLog; -import com.creditease.uav.util.JDKProxyInvokeUtil; - -public class TomcatPlusIT { - - /** - * startUAVServer - */ - public void startServer() { - - // integrate Tomcat log - UAVServer.instance().setLog(new TomcatLog("MonitorServer")); - // start Monitor Server when server starts - UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.TOMCAT }); - } - - /** - * onServiceInit - * - * @param args - */ - public void onServiceInit(Object... args) { - - // get server port - if (UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT) == null) { - Connector connector = (Connector) args[0]; - - String protocol = connector.getProtocol(); - - if (protocol.toLowerCase().indexOf("http") >= 0) { - UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, connector.getPort()); - } - } - - } - - /** - * onServiceStart - * - * @param ca - */ - public void onServiceStart(Object... args) { - - // on service start pre-cap - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, - Monitor.CapturePhase.PRECAP, null); - } - - /** - * onServiceEnd - * - * @param args - */ - @SuppressWarnings("deprecation") - public void onServiceEnd(Object... args) { - - Request request = (Request) args[0]; - Response response = (Response) args[1]; - - Map params = new HashMap(); - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, request.getRequestURL().toString()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_SERVLET, request.getServletPath()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT, request.getContextPath()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, - request.getServletContext().getRealPath("")); - } - catch (NoSuchMethodError er) { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, request.getRealPath("")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE, response.getStatus()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR, request.getHeader("X-Forwarded-For")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT, request.getLocalPort()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT, request.getHeader("User-Agent")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG, request.getHeader("UAV-Client-Src")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_PROXY_HOST, request.getHeader("Host")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR, request.getRemoteAddr()); - } - catch (Exception e) { - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, - Monitor.CapturePhase.DOCAP, params); - - } - - /** - * onAppInit - * - * @param args - */ - public void onAppInit(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - /** - * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for - * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object - * - * for example, the DataSource related injection - */ - ic.put(InterceptConstants.CONTEXTOBJ, sc); - ic2.put(InterceptConstants.CONTEXTOBJ, sc); - } - - /** - * on Resource Init - * - * @param args - */ - public void onResourceInit(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - try { - /** - * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's - * classloader, both of them are extends WebappClassLoaderBase - */ - Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); - if (!cls.isAssignableFrom(cl.getClass())) { - return; - } - } - catch (ClassNotFoundException e) { - /** - * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist - */ - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return; - } - } - - /** - * for Application Starting's Resource Init - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - if (context == null) { - return; - } - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - if (sc == null) { - return; - } - - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - - ic.put(InterceptConstants.CONTEXTOBJ, sc); - } - - /** - * on Resource Create - */ - public Object onResourceCreate(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - /** - * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's - * classloader, both of them are extends WebappClassLoaderBase - */ - Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); - if (!cls.isAssignableFrom(cl.getClass())) { - return args[0]; - } - } - catch (ClassNotFoundException e) { - /** - * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist - */ - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return args[0]; - } - } - - /** - * for Application Starting's Resource Create - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE, false); - if (context == null) { - return args[0]; - } - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - if (sc == null) { - return args[0]; - } - - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - context.put(InterceptConstants.RESOURCEOBJ, args[0]); - context.put(InterceptConstants.RESOURCECFG, args[1]); - - iSupport.doIntercept(context); - - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - ic.put(InterceptConstants.CONTEXTOBJ, sc); - - return context.get(InterceptConstants.RESOURCEOBJ); - } - - /** - * onAppStarting - * - * @param args - */ - public void onAppStarting(Object... args) { - - // release the left contexts - StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT); - StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - /** - * onAppStart - * - * @param args - */ - public void onAppStart(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - private void getBasePath(InterceptContext context, ServletContext sContext) { - - String basePath = sContext.getRealPath(""); - - if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - } - - /** - * onAppStop - * - * @param args - */ - public void onAppStop(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - /** - * onServletStart - * - * @param args - */ - public void onServletStart(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - - iSupport.doIntercept(context); - } - - /** - * - * onServletRegist - * - * @param args - * @return - */ - public ServletContext onServletRegist(Object... args) { - - ServletContext servletContext = (ServletContext) args[0]; - - ServletContext scProxy = (ServletContext) servletContext - .getAttribute("com.creditease.uav.mof.tomcat.servletcontext"); - - if (scProxy == null) { - scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), - new Class[] { ServletContext.class }, - new JDKProxyInvokeHandler(servletContext, new DynamicServletContextProcessor())); - - servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy); - } - - return scProxy; - } - - /** - * onServletStop - * - * @param args - */ - public void onServletStop(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - iSupport.doIntercept(context); - } - - /** - * on Deploy UAV Application - * - * @param args - */ - @SuppressWarnings("unused") - public void onDeployUAVApp(Object... args) { - - if (System.getProperty("com.creditease.uav.iapp.install") != null) { - return; - } - - final HostConfig hc = (HostConfig) args[0]; - Host host = (Host) args[1]; - final File appBase = (File) args[2]; - final String mofRoot = (String) args[3]; - String curVersion = (String) args[4]; - String currentVersionDetailed = (String) args[5]; - String[] versions = currentVersionDetailed.split("\\."); - - int action = 0; - - if (curVersion.equals("6")) { - /** - * tomcat6 - */ - action = 0; - } - else if (curVersion.equals("7") && versions[1].equals("0") - && (Integer.parseInt(versions[2].substring(0, 1)) < 3)) { - /** - * tomcat7.并且小版本0.30.0 (不包含)以下。小版本号使用substring是因为存在beta版本,取第一位即可。 - */ - action = 0; - } - else { - action = 1; - } - - switch (action) { - case 0: - File dir = new File(mofRoot + "/com.creditease.uav"); - - ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", - new Class[] { String.class, File.class, String.class }, - new Object[] { "/com.creditease.uav", dir, mofRoot + "/com.creditease.uav" }, - hc.getClass().getClassLoader()); - break; - case 1: - ExecutorService es = host.getStartStopExecutor(); - - Future f = es.submit(new Runnable() { - - @Override - public void run() { - - ContextName cn = new ContextName("com.creditease.uav", ""); - - ReflectionHelper.setField(ContextName.class, cn, "baseName", mofRoot + "/com.creditease.uav"); - - File dir = new File(mofRoot + "/com.creditease.uav"); - - ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", - new Class[] { ContextName.class, File.class }, new Object[] { cn, dir }, - hc.getClass().getClassLoader()); - - } - - }); - - try { - f.get(); - } - catch (Exception e) { - // ignore - } - break; - } - - System.setProperty("com.creditease.uav.iapp.install", "true"); - } - - /** - * when use embeddedTomcat and the webappclassloader is undefined, the webappclassloader will use systemclassloader as it's parentclassloader which coundn't load mof jars. - * we chg it's parentclassloader to currentThread's contextclassloader(normally it counld load uavmof jars). - */ - public ClassLoader chgParentClassloader(Object... args) { - - ClassLoader cl = (ClassLoader) args[0]; - - StandardContext sc = (StandardContext) args[1]; - if (cl != ClassLoader.getSystemClassLoader()) { - return cl; - } - else { - sc.setDelegate(true); - return Thread.currentThread().getContextClassLoader(); - } - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.tomcat.plus.interceptor; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.servlet.Servlet; +import javax.servlet.ServletContext; + +import org.apache.catalina.Host; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardWrapper; +import org.apache.catalina.loader.WebappClassLoader; +import org.apache.catalina.startup.HostConfig; +import org.apache.catalina.util.ContextName; + +import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.interceptframework.InterceptSupport; +import com.creditease.monitor.interceptframework.StandardInterceptContextHelper; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.monitor.jee.servlet30.DynamicServletContextProcessor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.tomcat.plus.util.TomcatLog; +import com.creditease.uav.util.JDKProxyInvokeUtil; + +public class TomcatPlusIT { + + /** + * startUAVServer + */ + public void startServer() { + + // integrate Tomcat log + UAVServer.instance().setLog(new TomcatLog("MonitorServer")); + // start Monitor Server when server starts + UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.TOMCAT }); + } + + /** + * onServiceInit + * + * @param args + */ + public void onServiceInit(Object... args) { + + // get server port + if (UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT) == null) { + Connector connector = (Connector) args[0]; + + String protocol = connector.getProtocol(); + + if (protocol.toLowerCase().indexOf("http") >= 0) { + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, connector.getPort()); + } + } + + } + + /** + * onServiceStart + * + * @param ca + */ + public void onServiceStart(Object... args) { + + // on service start pre-cap + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, + Monitor.CapturePhase.PRECAP, null); + } + + /** + * onServiceEnd + * + * @param args + */ + @SuppressWarnings("deprecation") + public void onServiceEnd(Object... args) { + + Request request = (Request) args[0]; + Response response = (Response) args[1]; + + Map params = new HashMap(); + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, request.getRequestURL().toString()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_SERVLET, request.getServletPath()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT, request.getContextPath()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, + request.getServletContext().getRealPath("")); + } + catch (NoSuchMethodError er) { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, request.getRealPath("")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE, response.getStatus()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR, request.getHeader("X-Forwarded-For")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT, request.getLocalPort()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT, request.getHeader("User-Agent")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG, request.getHeader("UAV-Client-Src")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_PROXY_HOST, request.getHeader("Host")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR, request.getRemoteAddr()); + } + catch (Exception e) { + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, + Monitor.CapturePhase.DOCAP, params); + + } + + /** + * onAppInit + * + * @param args + */ + public void onAppInit(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + /** + * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for + * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object + * + * for example, the DataSource related injection + */ + ic.put(InterceptConstants.CONTEXTOBJ, sc); + ic2.put(InterceptConstants.CONTEXTOBJ, sc); + } + + /** + * on Resource Init + * + * @param args + */ + public void onResourceInit(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + try { + /** + * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's + * classloader, both of them are extends WebappClassLoaderBase + */ + Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); + if (!cls.isAssignableFrom(cl.getClass())) { + return; + } + } + catch (ClassNotFoundException e) { + /** + * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist + */ + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return; + } + } + + /** + * for Application Starting's Resource Init + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + if (context == null) { + return; + } + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + if (sc == null) { + return; + } + + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + + ic.put(InterceptConstants.CONTEXTOBJ, sc); + } + + /** + * on Resource Create + */ + public Object onResourceCreate(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + try { + /** + * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's + * classloader, both of them are extends WebappClassLoaderBase + */ + Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); + if (!cls.isAssignableFrom(cl.getClass())) { + return args[0]; + } + } + catch (ClassNotFoundException e) { + /** + * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist + */ + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return args[0]; + } + } + + /** + * for Application Starting's Resource Create + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE, false); + if (context == null) { + return args[0]; + } + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + if (sc == null) { + return args[0]; + } + + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + context.put(InterceptConstants.RESOURCEOBJ, args[0]); + context.put(InterceptConstants.RESOURCECFG, args[1]); + + iSupport.doIntercept(context); + + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + ic.put(InterceptConstants.CONTEXTOBJ, sc); + + return context.get(InterceptConstants.RESOURCEOBJ); + } + + /** + * onAppStarting + * + * @param args + */ + public void onAppStarting(Object... args) { + + // release the left contexts + StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT); + StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + /** + * onAppStart + * + * @param args + */ + public void onAppStart(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + private void getBasePath(InterceptContext context, ServletContext sContext) { + + String basePath = sContext.getRealPath(""); + + if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + } + + /** + * onAppStop + * + * @param args + */ + public void onAppStop(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + /** + * onServletStart + * + * @param args + */ + public void onServletStart(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + + iSupport.doIntercept(context); + } + + /** + * + * onServletRegist + * + * @param args + * @return + */ + public ServletContext onServletRegist(Object... args) { + + ServletContext servletContext = (ServletContext) args[0]; + + //uav's inner app doesn't need Profiling,just return origin servletContext here. + if("/com.creditease.uav".equals(servletContext.getContextPath())) { + return servletContext; + } + + ServletContext scProxy = (ServletContext) servletContext + .getAttribute("com.creditease.uav.mof.tomcat.servletcontext"); + + if (scProxy == null) { + scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), + new Class[] { ServletContext.class }, + new JDKProxyInvokeHandler(servletContext, new DynamicServletContextProcessor())); + + servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy); + } + + return scProxy; + } + + /** + * onServletStop + * + * @param args + */ + public void onServletStop(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + iSupport.doIntercept(context); + } + + /** + * on Deploy UAV Application + * + * @param args + */ + @SuppressWarnings("unused") + public void onDeployUAVApp(Object... args) { + + if (System.getProperty("com.creditease.uav.iapp.install") != null) { + return; + } + + final HostConfig hc = (HostConfig) args[0]; + Host host = (Host) args[1]; + final File appBase = (File) args[2]; + final String mofRoot = (String) args[3]; + String curVersion = (String) args[4]; + String currentVersionDetailed = (String) args[5]; + String[] versions = currentVersionDetailed.split("\\."); + + int action = 0; + + if (curVersion.equals("6")) { + /** + * tomcat6 + */ + action = 0; + } + else if (curVersion.equals("7") && versions[1].equals("0") + && (Integer.parseInt(versions[2].substring(0, 1)) < 3)) { + /** + * tomcat7.并且小版本0.30.0 (不包含)以下。小版本号使用substring是因为存在beta版本,取第一位即可。 + */ + action = 0; + } + else { + action = 1; + } + + switch (action) { + case 0: + File dir = new File(mofRoot + "/com.creditease.uav"); + + ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", + new Class[] { String.class, File.class, String.class }, + new Object[] { "/com.creditease.uav", dir, mofRoot + "/com.creditease.uav" }, + hc.getClass().getClassLoader()); + break; + case 1: + ExecutorService es = host.getStartStopExecutor(); + + Future f = es.submit(new Runnable() { + + @Override + public void run() { + + ContextName cn = new ContextName("com.creditease.uav", ""); + + ReflectionHelper.setField(ContextName.class, cn, "baseName", mofRoot + "/com.creditease.uav"); + + File dir = new File(mofRoot + "/com.creditease.uav"); + + ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", + new Class[] { ContextName.class, File.class }, new Object[] { cn, dir }, + hc.getClass().getClassLoader()); + + } + + }); + + try { + f.get(); + } + catch (Exception e) { + // ignore + } + break; + } + + System.setProperty("com.creditease.uav.iapp.install", "true"); + } + + /** + * when use embeddedTomcat and the webappclassloader is undefined, the webappclassloader will use systemclassloader as it's parentclassloader which coundn't load mof jars. + * we chg it's parentclassloader to currentThread's contextclassloader(normally it counld load uavmof jars). + */ + public ClassLoader chgParentClassloader(Object... args) { + + ClassLoader cl = (ClassLoader) args[0]; + + StandardContext sc = (StandardContext) args[1]; + if (cl != ClassLoader.getSystemClassLoader()) { + return cl; + } + else { + sc.setDelegate(true); + return Thread.currentThread().getContextClassLoader(); + } + } +} From 300a7795a6535260369c5bbabe008280c065e8b8 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 1 Feb 2018 19:02:52 +0800 Subject: [PATCH 07/97] #181 #182 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文件格式修改 --- .../adaptors/SpringBootTomcatAdaptor.java | 772 +++++------ com.creditease.uav.tomcat.plus.core/pom.xml | 106 +- .../interceptor/SpringBootTomcatPlusIT.java | 960 +++++++------- .../tomcat/plus/interceptor/TomcatPlusIT.java | 1168 ++++++++--------- 4 files changed, 1504 insertions(+), 1502 deletions(-) diff --git a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java index 6d85b5d8..4c73f189 100644 --- a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java +++ b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors/SpringBootTomcatAdaptor.java @@ -1,386 +1,386 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.monitorframework.adaptors; - -import javassist.ClassPool; -import javassist.CtMethod; - -public class SpringBootTomcatAdaptor extends AbstractAdaptor { - - @Override - public byte[] onStartup(ClassLoader clsLoader, String uavMofRoot, String className) { - - System.out.println("MOF.ApplicationContainer=SpringBoot.Tomcat"); - - if (pool == null) { - pool = ClassPool.getDefault(); - } - - final AbstractAdaptor aa = this; - - final String mofRoot = uavMofRoot; - - if ("org.springframework.boot.loader.Launcher".equals(className)) { - return this.inject("org.springframework.boot.loader.Launcher", - new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", - "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); - m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + "\"); mObj.installMOF($_);}"); - } - - @Override - public String getMethodName() { - - return "createClassLoader"; - } - - }); - } - else if ("org.springframework.boot.SpringApplication".equals(className)) { - return this.inject("org.springframework.boot.SpringApplication", - new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", - "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); - m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot - + "\"); mObj.installMOF(getClassLoader());}"); - } - - @Override - public String getMethodName() { - - return "prepareEnvironment"; - } - - }); - } - return null; - } - - @Override - public byte[] onLoadClass(ClassLoader clsLoader, final String uavMofRoot, String className) { - - this.addClassPath(clsLoader); - - final AbstractAdaptor aa = this; - - // log4j劫持 - if (className.equals("org.apache.log4j.helpers.QuietWriter")) { - try { - String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; - aa.installJar(clsLoader, logJarPath, true); - // 兼容在ide环境下启动 - String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; - aa.installJar(clsLoader, mofJarPath, true); - aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", - "org.apache.log4j.helpers.QuietWriter", "new LogIT()"); - aa.defineField("uavLogHookLineSep", "java.lang.String", "org.apache.log4j.helpers.QuietWriter", - "System.getProperty(\"line.separator\")"); - } - catch (Exception e) { - System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); - e.printStackTrace(); - } - return this.inject(className, new String[] { "com.creditease.uav.log.hook.interceptors" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - m.insertBefore("{if(!$1.equals(uavLogHookLineSep)){$1=uavLogHook.formatLog($1);}}"); - } - - @Override - public String getMethodName() { - - return "write"; - } - - }); - } - - // 进行logback的劫持 - else if (className.equals("ch.qos.logback.core.encoder.LayoutWrappingEncoder")) { - try { - String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; - aa.installJar(clsLoader, logJarPath, true); - // 兼容在ide环境下启动 - String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; - aa.installJar(clsLoader, mofJarPath, true); - aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", - "ch.qos.logback.core.encoder.LayoutWrappingEncoder", "new LogIT()"); - } - catch (Exception e) { - System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); - e.printStackTrace(); - } - return this.inject(className, - new String[] { "com.creditease.uav.log.hook", "com.creditease.uav.log.hook.interceptors" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - m.insertBefore("{$1=uavLogHook.formatLog($1);}"); - } - - @Override - public String getMethodName() { - - return "convertToBytes"; - } - - }); - } - - else if (className.equals("org.springframework.context.support.AbstractApplicationContext")) - - { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor() { - - /** - * we need startServer before ApplicationContext's refresh cause some hook operation could - * happen when refresh. the hook is done after startServer before refresh, and profiling will be done after refresh - */ - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.startServer(this.getEnvironment().getProperty(\"server.port\"),this.getEnvironment().getProperty(\"server.context-path\"),this.getEnvironment().getProperty(\"spring.application.name\"),this);mObj.onSpringBeanRegist(new Object[]{this,this.getEnvironment().getProperty(\"server.context-path\")});}"); - m.insertAfter("{mObj.onSpringFinishRefresh(this);}"); - - } - - @Override - public String getMethodName() { - - return "refresh"; - } - - }); - } - - else if (className.equals("org.apache.catalina.core.StandardEngineValve")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServiceStart(new Object[]{this});}"); - m.insertAfter("{mObj.onServiceEnd(new Object[]{$1,$2});}"); - } - - @Override - public String getMethodName() { - - return "invoke"; - } - - }); - } - - else if (className.equals("org.apache.catalina.core.StandardContext")) { - - return this.inject(className, - new String[] { "com.creditease.tomcat.plus.interceptor", "org.apache.catalina.deploy", - "org.apache.catalina.core", "org.apache.tomcat.util.descriptor.web" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();mObj.onAppStarting(new Object[]{this}); }"); - } - - @Override - public String getMethodName() { - - return "mergeParameters"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore("{mObj=new SpringBootTomcatPlusIT();mObj.onAppInit(new Object[]{this});}"); - String sb = "{mObj.onAppStart(new Object[]{this});" + "FilterDef fd=new FilterDef();" - + "fd.setFilterClass(\"com.creditease.monitor.jee.filters.GlobalFilter\");" - + "fd.setDisplayName(\"UAV_Global_Filter\");" - + "fd.setFilterName(\"UAV_Global_Filter\");" - + "ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(this, fd);" - + "this.filterConfigs.put(\"UAV_Global_Filter\", filterConfig);" - + "FilterMap filterMap=new FilterMap();" - + "filterMap.setFilterName(\"UAV_Global_Filter\");" - + "filterMap.addURLPattern(\"/*\");" + "this.filterMaps.addBefore(filterMap);" - + "}"; - - m.insertAfter(sb); - } - - @Override - public String getMethodName() { - - return "startInternal"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter("{mObj=new SpringBootTomcatPlusIT();mObj.onAppStop(new Object[]{this});}"); - } - - @Override - public String getMethodName() { - - return "stopInternal"; - } - - } }); - } - else if (className.equals("org.apache.catalina.core.ApplicationContext")) { - - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();return mObj.onServletRegist(new Object[]{$_});}"); - } - - @Override - public String getMethodName() { - - return "getFacade"; - } - - } }); - } - else if (className.equals("org.apache.catalina.core.StandardWrapper")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertAfter( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStart(new Object[]{this,$_});}"); - } - - @Override - public String getMethodName() { - - return "loadServlet"; - } - - }, new AdaptorProcessor() { - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStop(new Object[]{this,this.instance});}"); - } - - @Override - public String getMethodName() { - - return "unload"; - } - - } }); - } - else if ( - // after Tomcat 8 - className.equals("org.apache.naming.factory.FactoryBase") || - // before Tomcat 7 - className.equals("org.apache.naming.factory.ResourceFactory")) { - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public String getMethodName() { - - return "getObjectInstance"; - } - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onResourceInit(new Object[]{$1});}"); - m.insertAfter("{$_=mObj.onResourceCreate(new Object[]{$_,$1});}"); - } - - } }); - } - // onDeployUAVApp - else if (className.equals("org.apache.catalina.startup.Tomcat")) { - - return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, - new AdaptorProcessor[] { new AdaptorProcessor() { - - @Override - public String getMethodName() { - - return "start"; - } - - @Override - public void process(CtMethod m) throws Exception { - - aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); - m.insertBefore( - "{mObj=new SpringBootTomcatPlusIT();mObj.onDeployUAVApp(new Object[]{this,\"" - + uavMofRoot + "\"});}"); - } - - } }); - } - - return null; - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.monitorframework.adaptors; + +import javassist.ClassPool; +import javassist.CtMethod; + +public class SpringBootTomcatAdaptor extends AbstractAdaptor { + + @Override + public byte[] onStartup(ClassLoader clsLoader, String uavMofRoot, String className) { + + System.out.println("MOF.ApplicationContainer=SpringBoot.Tomcat"); + + if (pool == null) { + pool = ClassPool.getDefault(); + } + + final AbstractAdaptor aa = this; + + final String mofRoot = uavMofRoot; + + if ("org.springframework.boot.loader.Launcher".equals(className)) { + return this.inject("org.springframework.boot.loader.Launcher", + new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", + "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); + m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + "\"); mObj.installMOF($_);}"); + } + + @Override + public String getMethodName() { + + return "createClassLoader"; + } + + }); + } + else if ("org.springframework.boot.SpringApplication".equals(className)) { + return this.inject("org.springframework.boot.SpringApplication", + new String[] { "com.creditease.uav.monitorframework.agent.interceptor" }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", + "com.creditease.uav.monitorframework.agent.interceptor.SpringBootTomcatIT"); + m.insertAfter("{mObj=new SpringBootTomcatIT(\"" + mofRoot + + "\"); mObj.installMOF(getClassLoader());}"); + } + + @Override + public String getMethodName() { + + return "prepareEnvironment"; + } + + }); + } + return null; + } + + @Override + public byte[] onLoadClass(ClassLoader clsLoader, final String uavMofRoot, String className) { + + this.addClassPath(clsLoader); + + final AbstractAdaptor aa = this; + + // log4j劫持 + if (className.equals("org.apache.log4j.helpers.QuietWriter")) { + try { + String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; + aa.installJar(clsLoader, logJarPath, true); + // 兼容在ide环境下启动 + String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; + aa.installJar(clsLoader, mofJarPath, true); + aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", + "org.apache.log4j.helpers.QuietWriter", "new LogIT()"); + aa.defineField("uavLogHookLineSep", "java.lang.String", "org.apache.log4j.helpers.QuietWriter", + "System.getProperty(\"line.separator\")"); + } + catch (Exception e) { + System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); + e.printStackTrace(); + } + return this.inject(className, new String[] { "com.creditease.uav.log.hook.interceptors" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + m.insertBefore("{if(!$1.equals(uavLogHookLineSep)){$1=uavLogHook.formatLog($1);}}"); + } + + @Override + public String getMethodName() { + + return "write"; + } + + }); + } + + // 进行logback的劫持 + else if (className.equals("ch.qos.logback.core.encoder.LayoutWrappingEncoder")) { + try { + String logJarPath = uavMofRoot + "/com.creditease.uav.appfrk/com.creditease.uav.loghook-1.0.jar"; + aa.installJar(clsLoader, logJarPath, true); + // 兼容在ide环境下启动 + String mofJarPath = uavMofRoot + "/com.creditease.uav/com.creditease.uav.monitorframework-1.0.jar"; + aa.installJar(clsLoader, mofJarPath, true); + aa.defineField("uavLogHook", "com.creditease.uav.log.hook.interceptors.LogIT", + "ch.qos.logback.core.encoder.LayoutWrappingEncoder", "new LogIT()"); + } + catch (Exception e) { + System.out.println("MOF.Interceptor[\" springboot \"] Install MonitorFramework Jars FAIL."); + e.printStackTrace(); + } + return this.inject(className, + new String[] { "com.creditease.uav.log.hook", "com.creditease.uav.log.hook.interceptors" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + m.insertBefore("{$1=uavLogHook.formatLog($1);}"); + } + + @Override + public String getMethodName() { + + return "convertToBytes"; + } + + }); + } + + else if (className.equals("org.springframework.context.support.AbstractApplicationContext")) + + { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor() { + + /** + * we need startServer before ApplicationContext's refresh cause some hook operation could + * happen when refresh. the hook is done after startServer before refresh, and profiling will be done after refresh + */ + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.startServer(this.getEnvironment().getProperty(\"server.port\"),this.getEnvironment().getProperty(\"server.context-path\"),this.getEnvironment().getProperty(\"spring.application.name\"),this);mObj.onSpringBeanRegist(new Object[]{this,this.getEnvironment().getProperty(\"server.context-path\")});}"); + m.insertAfter("{mObj.onSpringFinishRefresh(this);}"); + + } + + @Override + public String getMethodName() { + + return "refresh"; + } + + }); + } + + else if (className.equals("org.apache.catalina.core.StandardEngineValve")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServiceStart(new Object[]{this});}"); + m.insertAfter("{mObj.onServiceEnd(new Object[]{$1,$2});}"); + } + + @Override + public String getMethodName() { + + return "invoke"; + } + + }); + } + + else if (className.equals("org.apache.catalina.core.StandardContext")) { + + return this.inject(className, + new String[] { "com.creditease.tomcat.plus.interceptor", "org.apache.catalina.deploy", + "org.apache.catalina.core", "org.apache.tomcat.util.descriptor.web" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();mObj.onAppStarting(new Object[]{this}); }"); + } + + @Override + public String getMethodName() { + + return "mergeParameters"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore("{mObj=new SpringBootTomcatPlusIT();mObj.onAppInit(new Object[]{this});}"); + String sb = "{mObj.onAppStart(new Object[]{this});" + "FilterDef fd=new FilterDef();" + + "fd.setFilterClass(\"com.creditease.monitor.jee.filters.GlobalFilter\");" + + "fd.setDisplayName(\"UAV_Global_Filter\");" + + "fd.setFilterName(\"UAV_Global_Filter\");" + + "ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(this, fd);" + + "this.filterConfigs.put(\"UAV_Global_Filter\", filterConfig);" + + "FilterMap filterMap=new FilterMap();" + + "filterMap.setFilterName(\"UAV_Global_Filter\");" + + "filterMap.addURLPattern(\"/*\");" + "this.filterMaps.addBefore(filterMap);" + + "}"; + + m.insertAfter(sb); + } + + @Override + public String getMethodName() { + + return "startInternal"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter("{mObj=new SpringBootTomcatPlusIT();mObj.onAppStop(new Object[]{this});}"); + } + + @Override + public String getMethodName() { + + return "stopInternal"; + } + + } }); + } + else if (className.equals("org.apache.catalina.core.ApplicationContext")) { + + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();return mObj.onServletRegist(new Object[]{$_});}"); + } + + @Override + public String getMethodName() { + + return "getFacade"; + } + + } }); + } + else if (className.equals("org.apache.catalina.core.StandardWrapper")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertAfter( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStart(new Object[]{this,$_});}"); + } + + @Override + public String getMethodName() { + + return "loadServlet"; + } + + }, new AdaptorProcessor() { + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onServletStop(new Object[]{this,this.instance});}"); + } + + @Override + public String getMethodName() { + + return "unload"; + } + + } }); + } + else if ( + // after Tomcat 8 + className.equals("org.apache.naming.factory.FactoryBase") || + // before Tomcat 7 + className.equals("org.apache.naming.factory.ResourceFactory")) { + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public String getMethodName() { + + return "getObjectInstance"; + } + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onResourceInit(new Object[]{$1});}"); + m.insertAfter("{$_=mObj.onResourceCreate(new Object[]{$_,$1});}"); + } + + } }); + } + // onDeployUAVApp + else if (className.equals("org.apache.catalina.startup.Tomcat")) { + + return this.inject(className, new String[] { "com.creditease.tomcat.plus.interceptor" }, + new AdaptorProcessor[] { new AdaptorProcessor() { + + @Override + public String getMethodName() { + + return "start"; + } + + @Override + public void process(CtMethod m) throws Exception { + + aa.addLocalVar(m, "mObj", "com.creditease.tomcat.plus.interceptor.SpringBootTomcatPlusIT"); + m.insertBefore( + "{mObj=new SpringBootTomcatPlusIT();mObj.onDeployUAVApp(new Object[]{this,\"" + + uavMofRoot + "\"});}"); + } + + } }); + } + + return null; + } + +} diff --git a/com.creditease.uav.tomcat.plus.core/pom.xml b/com.creditease.uav.tomcat.plus.core/pom.xml index 499eb88d..f4e08c3d 100644 --- a/com.creditease.uav.tomcat.plus.core/pom.xml +++ b/com.creditease.uav.tomcat.plus.core/pom.xml @@ -1,54 +1,54 @@ - - - - ce-datamonitorsystem - com.creditease.moniter - 1.0 - ../com.creditease.uav.superpom - - 4.0.0 - - com.creditease.uav.tomcat.plus.core - - - - com.creditease.moniter - com.creditease.uav.monitorframework - - - celocaljar - tomcat-juli - 1.0 - system - ${basedir}/CompileLib/tomcat-juli.jar - - - celocaljar - catalina - 1.0 - system - ${basedir}/CompileLib/catalina.jar - - - celocaljar - tomcat-coyote - 1.0 - system - ${basedir}/CompileLib/tomcat-coyote.jar - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - org.apache.tomcat.embed - tomcat-embed-core - 8.5.0 - provided - - + + + + ce-datamonitorsystem + com.creditease.moniter + 1.0 + ../com.creditease.uav.superpom + + 4.0.0 + + com.creditease.uav.tomcat.plus.core + + + + com.creditease.moniter + com.creditease.uav.monitorframework + + + celocaljar + tomcat-juli + 1.0 + system + ${basedir}/CompileLib/tomcat-juli.jar + + + celocaljar + catalina + 1.0 + system + ${basedir}/CompileLib/catalina.jar + + + celocaljar + tomcat-coyote + 1.0 + system + ${basedir}/CompileLib/tomcat-coyote.jar + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + org.apache.tomcat.embed + tomcat-embed-core + 8.5.0 + provided + + \ No newline at end of file diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java index 27076324..3fc02d5f 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java @@ -1,479 +1,481 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.tomcat.plus.interceptor; - -import javax.servlet.Servlet; -import javax.servlet.ServletContext; - -import org.apache.catalina.Wrapper; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardWrapper; -import org.apache.catalina.loader.WebappClassLoader; -import org.apache.catalina.loader.WebappLoader; -import org.apache.catalina.startup.Tomcat; -import org.apache.tomcat.JarScanner; -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.helpers.ReflectionHelper; -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.interceptframework.InterceptSupport; -import com.creditease.monitor.interceptframework.spi.InterceptConstants; -import com.creditease.monitor.interceptframework.spi.InterceptContext; -import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; -import com.creditease.tomcat.plus.util.TomcatLog; -import com.creditease.uav.util.MonitorServerUtil; - -public class SpringBootTomcatPlusIT extends TomcatPlusIT { - - /** - * startUAVServer - */ - public void startServer(String port, String contextPath, String appName, Object arg) { - - if(!isWebServerContext(arg)) { - return; - } - - // integrate Tomcat log - UAVServer.instance().setLog(new TomcatLog("MonitorServer")); - // start Monitor Server when server starts - UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.SPRINGBOOT }); - // set appid - setAppid(contextPath); - // set the connector port - UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, - DataConvertHelper.toInt(port, 8080)); - InterceptSupport iSupport = InterceptSupport.instance(); - // this context will be transmited from springboot mainThread to webcontainerInit thread then back to mainThread - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - context.put(InterceptConstants.APPNAME, appName); - } - - /** - * setAppid - * - * @param contextPath - */ - public void setAppid(String contextPath) { - - if (contextPath == null || "/".equals(contextPath)) { - contextPath = ""; - } - - System.setProperty("com.creditease.uav.appid", MonitorServerUtil.getApplicationId(contextPath, "")); - - } - - /** - * onAppStarting - * - * @param args - */ - @Override - public void onAppStarting(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - iSupport.doIntercept(context); - } - - @Override - public void onAppInit(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - /** - * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for - * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object - * - * for example, the DataSource related injection - */ - ic.put(InterceptConstants.CONTEXTOBJ, sc); - ic2.put(InterceptConstants.CONTEXTOBJ, sc); - } - - @Override - public void onResourceInit(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return; - } - - /** - * for Application Starting's Resource Init - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - iSupport.doIntercept(context); - } - - @Override - public Object onResourceCreate(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return args[0]; - } - - /** - * for Application Starting's Resource Create - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - - context.put(InterceptConstants.RESOURCEOBJ, args[0]); - context.put(InterceptConstants.RESOURCECFG, args[1]); - - iSupport.doIntercept(context); - - return context.get(InterceptConstants.RESOURCEOBJ); - } - - /** - * onAppStart - * - * @param args - */ - @Override - public void onAppStart(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - //springboot use threadlocalContext to store the WEBCONTAINER_STARTED Event context, just return when it's uav's inner app in case of rewriting the real app's context - if("/com.creditease.uav".equals(contextPath)) { - return; - } - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - if (context.get(InterceptConstants.APPNAME) == null) { - context.put(InterceptConstants.APPNAME, - ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - } - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - String basePath = sContext.getRealPath(""); - - /* - * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process - */ - if (basePath == null) { - basePath = ""; - } - else if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - // we don't doIntercept here cause some pre-profile(like dubbo) not happen yet, profile will be done after - // finishRefresh - - } - - /** - * onAppStop - * - * @param args - */ - @Override - public void onAppStop(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); - - if (null == context || null == sc) { - return; - } - - /** - * NOTE: spring boot will reset tomcat webappclassloader to null when shutdown, we may use the currentThread's - * classloader as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - - String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - context.put(InterceptConstants.SERVLET_CONTEXT, - ReflectionHelper.getField(StandardContext.class, sc, "context", true)); - - iSupport.doIntercept(context); - } - - /** - * onServletStart - * - * @param args - */ - @Override - public void onServletStart(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - - iSupport.doIntercept(context); - } - - /** - * onServletStop - * - * @param args - */ - @Override - public void onServletStop(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - /** - * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do - * anything on this we may use its webappclassloader's parent as the classloader - */ - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - iSupport.doIntercept(context); - } - - /** - * springboot load beans before web container start, hook opr should be done before beanRegist in case of duplicate - * definition ,so we define SPRING_BEAN_REGIST event to trigger hook - */ - public void onSpringBeanRegist(Object... args) { - - if(!isWebServerContext(args[0])) { - return; - } - - String contextPath=(String) args[1]; - - if (contextPath == null || "/".equals(contextPath)) { - contextPath = ""; - } - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.SPRING_BEAN_REGIST); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.CONTEXTPATH, contextPath); - context.put(InterceptConstants.BASEPATH, ""); - iSupport.doIntercept(context); - } - - /** - * ComponentProfile will be done after springboot finish it's context's refresh, cause every pre-profile(like dubbo) - * is ready. - * - */ - public void onSpringFinishRefresh(Object arg) { - - if(!isWebServerContext(arg)) { - return; - } - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); - - iSupport.doIntercept(context); - } - - public void onDeployUAVApp(Object... args) { - - if(UAVServer.ServerVendor.SPRINGBOOT!=UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) { - return; - } - - Tomcat tomcat=(Tomcat) args[0]; - String mofRoot=(String) args[1]; - - //add uavApp - StandardContext context=new StandardContext(); - context.setName("com.creditease.uav"); - context.setPath("/com.creditease.uav"); - context.setDocBase(mofRoot + "/com.creditease.uav"); - context.addLifecycleListener(new Tomcat.FixContextListener()); - tomcat.getHost().addChild(context); - - //add default servlet - Wrapper servlet = context.createWrapper(); - servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet"); - servlet.setName("default"); - context.addChild(servlet); - servlet.setOverridable(true); - context.addServletMapping("/", "default"); - - //init webapp classloader - context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); - context.setDelegate(true); - - //after tomcat8, skip jarscan - Object obj=ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader()); - if(obj!=null) { - ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); - ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); - ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); - - context.setJarScanner((JarScanner) obj); - } - } - - /** - * judge if the AbstractApplicationContext is WebServerContext,cause we only hook the WebServerContext's lifecycle - * - */ - private boolean isWebServerContext(Object arg) { - //before SpringBoot 2.0.0, the WebServerContext class is 'AnnotationConfigEmbeddedWebApplicationContext',after SpringBoot 2.0.0(include) change to 'AnnotationConfigServletWebServerApplicationContext' - return ("AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())||"AnnotationConfigServletWebServerApplicationContext".equals(arg.getClass().getSimpleName())); - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.tomcat.plus.interceptor; + +import javax.servlet.Servlet; +import javax.servlet.ServletContext; + +import org.apache.catalina.Wrapper; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardWrapper; +import org.apache.catalina.loader.WebappClassLoader; +import org.apache.catalina.loader.WebappLoader; +import org.apache.catalina.startup.Tomcat; +import org.apache.tomcat.JarScanner; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.interceptframework.InterceptSupport; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.tomcat.plus.util.TomcatLog; +import com.creditease.uav.util.MonitorServerUtil; + +public class SpringBootTomcatPlusIT extends TomcatPlusIT { + + /** + * startUAVServer + */ + public void startServer(String port, String contextPath, String appName, Object arg) { + + if (!"AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())) { + return; + } + + // integrate Tomcat log + UAVServer.instance().setLog(new TomcatLog("MonitorServer")); + // start Monitor Server when server starts + UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.SPRINGBOOT }); + // set appid + setAppid(contextPath); + // set the connector port + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, + DataConvertHelper.toInt(port, 8080)); + InterceptSupport iSupport = InterceptSupport.instance(); + // this context will be transmited from springboot mainThread to webcontainerInit thread then back to mainThread + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + context.put(InterceptConstants.APPNAME, appName); + } + + /** + * setAppid + * + * @param contextPath + */ + public void setAppid(String contextPath) { + + if (contextPath == null || "/".equals(contextPath)) { + contextPath = ""; + } + + System.setProperty("com.creditease.uav.appid", MonitorServerUtil.getApplicationId(contextPath, "")); + + } + + /** + * onAppStarting + * + * @param args + */ + @Override + public void onAppStarting(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + iSupport.doIntercept(context); + } + + @Override + public void onAppInit(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + /** + * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for + * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object + * + * for example, the DataSource related injection + */ + ic.put(InterceptConstants.CONTEXTOBJ, sc); + ic2.put(InterceptConstants.CONTEXTOBJ, sc); + } + + @Override + public void onResourceInit(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return; + } + + /** + * for Application Starting's Resource Init + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + iSupport.doIntercept(context); + } + + @Override + public Object onResourceCreate(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return args[0]; + } + + /** + * for Application Starting's Resource Create + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + + context.put(InterceptConstants.RESOURCEOBJ, args[0]); + context.put(InterceptConstants.RESOURCECFG, args[1]); + + iSupport.doIntercept(context); + + return context.get(InterceptConstants.RESOURCEOBJ); + } + + /** + * onAppStart + * + * @param args + */ + @Override + public void onAppStart(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + //springboot use threadlocalContext to store the WEBCONTAINER_STARTED Event context, just return when it's uav's inner app in case of rewriting the real app's context + if("/com.creditease.uav".equals(contextPath)) { + return; + } + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + if (context.get(InterceptConstants.APPNAME) == null) { + context.put(InterceptConstants.APPNAME, + ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + } + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + String basePath = sContext.getRealPath(""); + + /* + * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process + */ + if (basePath == null) { + basePath = ""; + } + else if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + // we don't doIntercept here cause some pre-profile(like dubbo) not happen yet, profile will be done after + // finishRefresh + + } + + /** + * onAppStop + * + * @param args + */ + @Override + public void onAppStop(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); + + if (null == context || null == sc) { + return; + } + + /** + * NOTE: spring boot will reset tomcat webappclassloader to null when shutdown, we may use the currentThread's + * classloader as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + + String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + context.put(InterceptConstants.SERVLET_CONTEXT, + ReflectionHelper.getField(StandardContext.class, sc, "context", true)); + + iSupport.doIntercept(context); + } + + /** + * onServletStart + * + * @param args + */ + @Override + public void onServletStart(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + + iSupport.doIntercept(context); + } + + /** + * onServletStop + * + * @param args + */ + @Override + public void onServletStop(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + /** + * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do + * anything on this we may use its webappclassloader's parent as the classloader + */ + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + iSupport.doIntercept(context); + } + + /** + * springboot load beans before web container start, hook opr should be done before beanRegist in case of duplicate + * definition ,so we define SPRING_BEAN_REGIST event to trigger hook + */ + public void onSpringBeanRegist(Object... args) { + + if(!isWebServerContext(args[0])) { + return; + } + + String contextPath=(String) args[1]; + + if (contextPath == null || "/".equals(contextPath)) { + contextPath = ""; + } + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.SPRING_BEAN_REGIST); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.CONTEXTPATH, contextPath); + context.put(InterceptConstants.BASEPATH, ""); + iSupport.doIntercept(context); + } + + /** + * ComponentProfile will be done after springboot finish it's context's refresh, cause every pre-profile(like dubbo) + * is ready. + * + */ + public void onSpringFinishRefresh(Object arg) { + + if(!isWebServerContext(arg)) { + return; + } + + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED); + + iSupport.doIntercept(context); + } + + public void onDeployUAVApp(Object... args) { + + if(UAVServer.ServerVendor.SPRINGBOOT!=UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) { + return; + } + + Tomcat tomcat=(Tomcat) args[0]; + String mofRoot=(String) args[1]; + + //add uavApp + StandardContext context=new StandardContext(); + context.setName("com.creditease.uav"); + context.setPath("/com.creditease.uav"); + context.setDocBase(mofRoot + "/com.creditease.uav"); + context.addLifecycleListener(new Tomcat.FixContextListener()); + tomcat.getHost().addChild(context); + + //add default servlet + Wrapper servlet = context.createWrapper(); + servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet"); + servlet.setName("default"); + context.addChild(servlet); + servlet.setOverridable(true); + context.addServletMapping("/", "default"); + + //init webapp classloader + context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); + context.setDelegate(true); + + //after tomcat8, skip jarscan + Object obj=ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader()); + if(obj!=null) { + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class[]{Boolean.class}, new Object[] { false}, Thread.currentThread().getContextClassLoader()); + + context.setJarScanner((JarScanner) obj); + } + } + + /** + * judge if the AbstractApplicationContext is WebServerContext,cause we only hook the WebServerContext's lifecycle + * + */ + private boolean isWebServerContext(Object arg) { + //before SpringBoot 2.0.0, the WebServerContext class is 'AnnotationConfigEmbeddedWebApplicationContext',after SpringBoot 2.0.0(include) change to 'AnnotationConfigServletWebServerApplicationContext' + return ("AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())||"AnnotationConfigServletWebServerApplicationContext".equals(arg.getClass().getSimpleName())); + } +} diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java index 1f81db7e..48c8fbaa 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/TomcatPlusIT.java @@ -1,584 +1,584 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.tomcat.plus.interceptor; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.servlet.Servlet; -import javax.servlet.ServletContext; - -import org.apache.catalina.Host; -import org.apache.catalina.connector.Connector; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardWrapper; -import org.apache.catalina.loader.WebappClassLoader; -import org.apache.catalina.startup.HostConfig; -import org.apache.catalina.util.ContextName; - -import com.creditease.agent.helpers.ReflectionHelper; -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.captureframework.spi.Monitor; -import com.creditease.monitor.interceptframework.InterceptSupport; -import com.creditease.monitor.interceptframework.StandardInterceptContextHelper; -import com.creditease.monitor.interceptframework.spi.InterceptConstants; -import com.creditease.monitor.interceptframework.spi.InterceptContext; -import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; -import com.creditease.monitor.jee.servlet30.DynamicServletContextProcessor; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; -import com.creditease.tomcat.plus.util.TomcatLog; -import com.creditease.uav.util.JDKProxyInvokeUtil; - -public class TomcatPlusIT { - - /** - * startUAVServer - */ - public void startServer() { - - // integrate Tomcat log - UAVServer.instance().setLog(new TomcatLog("MonitorServer")); - // start Monitor Server when server starts - UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.TOMCAT }); - } - - /** - * onServiceInit - * - * @param args - */ - public void onServiceInit(Object... args) { - - // get server port - if (UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT) == null) { - Connector connector = (Connector) args[0]; - - String protocol = connector.getProtocol(); - - if (protocol.toLowerCase().indexOf("http") >= 0) { - UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, connector.getPort()); - } - } - - } - - /** - * onServiceStart - * - * @param ca - */ - public void onServiceStart(Object... args) { - - // on service start pre-cap - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, - Monitor.CapturePhase.PRECAP, null); - } - - /** - * onServiceEnd - * - * @param args - */ - @SuppressWarnings("deprecation") - public void onServiceEnd(Object... args) { - - Request request = (Request) args[0]; - Response response = (Response) args[1]; - - Map params = new HashMap(); - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, request.getRequestURL().toString()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_SERVLET, request.getServletPath()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT, request.getContextPath()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, - request.getServletContext().getRealPath("")); - } - catch (NoSuchMethodError er) { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, request.getRealPath("")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE, response.getStatus()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR, request.getHeader("X-Forwarded-For")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT, request.getLocalPort()); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT, request.getHeader("User-Agent")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG, request.getHeader("UAV-Client-Src")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_PROXY_HOST, request.getHeader("Host")); - } - catch (Exception e) { - } - try { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR, request.getRemoteAddr()); - } - catch (Exception e) { - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, - Monitor.CapturePhase.DOCAP, params); - - } - - /** - * onAppInit - * - * @param args - */ - public void onAppInit(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - /** - * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for - * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object - * - * for example, the DataSource related injection - */ - ic.put(InterceptConstants.CONTEXTOBJ, sc); - ic2.put(InterceptConstants.CONTEXTOBJ, sc); - } - - /** - * on Resource Init - * - * @param args - */ - public void onResourceInit(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - try { - /** - * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's - * classloader, both of them are extends WebappClassLoaderBase - */ - Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); - if (!cls.isAssignableFrom(cl.getClass())) { - return; - } - } - catch (ClassNotFoundException e) { - /** - * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist - */ - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return; - } - } - - /** - * for Application Starting's Resource Init - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - if (context == null) { - return; - } - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - if (sc == null) { - return; - } - - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); - - ic.put(InterceptConstants.CONTEXTOBJ, sc); - } - - /** - * on Resource Create - */ - public Object onResourceCreate(Object... args) { - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - /** - * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's - * classloader, both of them are extends WebappClassLoaderBase - */ - Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); - if (!cls.isAssignableFrom(cl.getClass())) { - return args[0]; - } - } - catch (ClassNotFoundException e) { - /** - * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist - */ - if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { - return args[0]; - } - } - - /** - * for Application Starting's Resource Create - */ - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE, false); - if (context == null) { - return args[0]; - } - - StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); - - if (sc == null) { - return args[0]; - } - - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - context.put(InterceptConstants.RESOURCEOBJ, args[0]); - context.put(InterceptConstants.RESOURCECFG, args[1]); - - iSupport.doIntercept(context); - - InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - ic.put(InterceptConstants.CONTEXTOBJ, sc); - - return context.get(InterceptConstants.RESOURCEOBJ); - } - - /** - * onAppStarting - * - * @param args - */ - public void onAppStarting(Object... args) { - - // release the left contexts - StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT); - StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE); - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - /** - * onAppStart - * - * @param args - */ - public void onAppStart(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - private void getBasePath(InterceptContext context, ServletContext sContext) { - - String basePath = sContext.getRealPath(""); - - if (basePath.lastIndexOf("/") == (basePath.length() - 1) - || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { - basePath = basePath.substring(0, basePath.length() - 1); - } - - context.put(InterceptConstants.BASEPATH, basePath); - } - - /** - * onAppStop - * - * @param args - */ - public void onAppStop(Object... args) { - - StandardContext sc = (StandardContext) args[0]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); - context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); - context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); - context.put(InterceptConstants.CONTEXTPATH, - ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); - context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); - - ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); - - context.put(InterceptConstants.SERVLET_CONTEXT, sContext); - - getBasePath(context, sContext); - - iSupport.doIntercept(context); - } - - /** - * onServletStart - * - * @param args - */ - public void onServletStart(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - - iSupport.doIntercept(context); - } - - /** - * - * onServletRegist - * - * @param args - * @return - */ - public ServletContext onServletRegist(Object... args) { - - ServletContext servletContext = (ServletContext) args[0]; - - //uav's inner app doesn't need Profiling,just return origin servletContext here. - if("/com.creditease.uav".equals(servletContext.getContextPath())) { - return servletContext; - } - - ServletContext scProxy = (ServletContext) servletContext - .getAttribute("com.creditease.uav.mof.tomcat.servletcontext"); - - if (scProxy == null) { - scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), - new Class[] { ServletContext.class }, - new JDKProxyInvokeHandler(servletContext, new DynamicServletContextProcessor())); - - servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy); - } - - return scProxy; - } - - /** - * onServletStop - * - * @param args - */ - public void onServletStop(Object... args) { - - StandardWrapper sw = (StandardWrapper) args[0]; - Servlet servlet = (Servlet) args[1]; - InterceptSupport iSupport = InterceptSupport.instance(); - InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); - context.put(InterceptConstants.SERVLET_INSTANCE, servlet); - context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); - context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); - iSupport.doIntercept(context); - } - - /** - * on Deploy UAV Application - * - * @param args - */ - @SuppressWarnings("unused") - public void onDeployUAVApp(Object... args) { - - if (System.getProperty("com.creditease.uav.iapp.install") != null) { - return; - } - - final HostConfig hc = (HostConfig) args[0]; - Host host = (Host) args[1]; - final File appBase = (File) args[2]; - final String mofRoot = (String) args[3]; - String curVersion = (String) args[4]; - String currentVersionDetailed = (String) args[5]; - String[] versions = currentVersionDetailed.split("\\."); - - int action = 0; - - if (curVersion.equals("6")) { - /** - * tomcat6 - */ - action = 0; - } - else if (curVersion.equals("7") && versions[1].equals("0") - && (Integer.parseInt(versions[2].substring(0, 1)) < 3)) { - /** - * tomcat7.并且小版本0.30.0 (不包含)以下。小版本号使用substring是因为存在beta版本,取第一位即可。 - */ - action = 0; - } - else { - action = 1; - } - - switch (action) { - case 0: - File dir = new File(mofRoot + "/com.creditease.uav"); - - ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", - new Class[] { String.class, File.class, String.class }, - new Object[] { "/com.creditease.uav", dir, mofRoot + "/com.creditease.uav" }, - hc.getClass().getClassLoader()); - break; - case 1: - ExecutorService es = host.getStartStopExecutor(); - - Future f = es.submit(new Runnable() { - - @Override - public void run() { - - ContextName cn = new ContextName("com.creditease.uav", ""); - - ReflectionHelper.setField(ContextName.class, cn, "baseName", mofRoot + "/com.creditease.uav"); - - File dir = new File(mofRoot + "/com.creditease.uav"); - - ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", - new Class[] { ContextName.class, File.class }, new Object[] { cn, dir }, - hc.getClass().getClassLoader()); - - } - - }); - - try { - f.get(); - } - catch (Exception e) { - // ignore - } - break; - } - - System.setProperty("com.creditease.uav.iapp.install", "true"); - } - - /** - * when use embeddedTomcat and the webappclassloader is undefined, the webappclassloader will use systemclassloader as it's parentclassloader which coundn't load mof jars. - * we chg it's parentclassloader to currentThread's contextclassloader(normally it counld load uavmof jars). - */ - public ClassLoader chgParentClassloader(Object... args) { - - ClassLoader cl = (ClassLoader) args[0]; - - StandardContext sc = (StandardContext) args[1]; - if (cl != ClassLoader.getSystemClassLoader()) { - return cl; - } - else { - sc.setDelegate(true); - return Thread.currentThread().getContextClassLoader(); - } - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.tomcat.plus.interceptor; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.servlet.Servlet; +import javax.servlet.ServletContext; + +import org.apache.catalina.Host; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardWrapper; +import org.apache.catalina.loader.WebappClassLoader; +import org.apache.catalina.startup.HostConfig; +import org.apache.catalina.util.ContextName; + +import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.interceptframework.InterceptSupport; +import com.creditease.monitor.interceptframework.StandardInterceptContextHelper; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.monitor.jee.servlet30.DynamicServletContextProcessor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.tomcat.plus.util.TomcatLog; +import com.creditease.uav.util.JDKProxyInvokeUtil; + +public class TomcatPlusIT { + + /** + * startUAVServer + */ + public void startServer() { + + // integrate Tomcat log + UAVServer.instance().setLog(new TomcatLog("MonitorServer")); + // start Monitor Server when server starts + UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.TOMCAT }); + } + + /** + * onServiceInit + * + * @param args + */ + public void onServiceInit(Object... args) { + + // get server port + if (UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT) == null) { + Connector connector = (Connector) args[0]; + + String protocol = connector.getProtocol(); + + if (protocol.toLowerCase().indexOf("http") >= 0) { + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, connector.getPort()); + } + } + + } + + /** + * onServiceStart + * + * @param ca + */ + public void onServiceStart(Object... args) { + + // on service start pre-cap + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, + Monitor.CapturePhase.PRECAP, null); + } + + /** + * onServiceEnd + * + * @param args + */ + @SuppressWarnings("deprecation") + public void onServiceEnd(Object... args) { + + Request request = (Request) args[0]; + Response response = (Response) args[1]; + + Map params = new HashMap(); + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, request.getRequestURL().toString()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_SERVLET, request.getServletPath()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT, request.getContextPath()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, + request.getServletContext().getRealPath("")); + } + catch (NoSuchMethodError er) { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, request.getRealPath("")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE, response.getStatus()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR, request.getHeader("X-Forwarded-For")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT, request.getLocalPort()); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT, request.getHeader("User-Agent")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG, request.getHeader("UAV-Client-Src")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_PROXY_HOST, request.getHeader("Host")); + } + catch (Exception e) { + } + try { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR, request.getRemoteAddr()); + } + catch (Exception e) { + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, + Monitor.CapturePhase.DOCAP, params); + + } + + /** + * onAppInit + * + * @param args + */ + public void onAppInit(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + /** + * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for + * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object + * + * for example, the DataSource related injection + */ + ic.put(InterceptConstants.CONTEXTOBJ, sc); + ic2.put(InterceptConstants.CONTEXTOBJ, sc); + } + + /** + * on Resource Init + * + * @param args + */ + public void onResourceInit(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + try { + /** + * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's + * classloader, both of them are extends WebappClassLoaderBase + */ + Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); + if (!cls.isAssignableFrom(cl.getClass())) { + return; + } + } + catch (ClassNotFoundException e) { + /** + * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist + */ + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return; + } + } + + /** + * for Application Starting's Resource Init + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + if (context == null) { + return; + } + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + if (sc == null) { + return; + } + + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT); + + ic.put(InterceptConstants.CONTEXTOBJ, sc); + } + + /** + * on Resource Create + */ + public Object onResourceCreate(Object... args) { + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + try { + /** + * after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's + * classloader, both of them are extends WebappClassLoaderBase + */ + Class cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase"); + if (!cls.isAssignableFrom(cl.getClass())) { + return args[0]; + } + } + catch (ClassNotFoundException e) { + /** + * before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist + */ + if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) { + return args[0]; + } + } + + /** + * for Application Starting's Resource Create + */ + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE, false); + if (context == null) { + return args[0]; + } + + StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ); + + if (sc == null) { + return args[0]; + } + + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + context.put(InterceptConstants.RESOURCEOBJ, args[0]); + context.put(InterceptConstants.RESOURCECFG, args[1]); + + iSupport.doIntercept(context); + + InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + ic.put(InterceptConstants.CONTEXTOBJ, sc); + + return context.get(InterceptConstants.RESOURCEOBJ); + } + + /** + * onAppStarting + * + * @param args + */ + public void onAppStarting(Object... args) { + + // release the left contexts + StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT); + StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE); + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + /** + * onAppStart + * + * @param args + */ + public void onAppStart(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + private void getBasePath(InterceptContext context, ServletContext sContext) { + + String basePath = sContext.getRealPath(""); + + if (basePath.lastIndexOf("/") == (basePath.length() - 1) + || basePath.lastIndexOf("\\") == (basePath.length() - 1)) { + basePath = basePath.substring(0, basePath.length() - 1); + } + + context.put(InterceptConstants.BASEPATH, basePath); + } + + /** + * onAppStop + * + * @param args + */ + public void onAppStop(Object... args) { + + StandardContext sc = (StandardContext) args[0]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED); + context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader()); + context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath()); + context.put(InterceptConstants.CONTEXTPATH, + ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true)); + context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true)); + + ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true); + + context.put(InterceptConstants.SERVLET_CONTEXT, sContext); + + getBasePath(context, sContext); + + iSupport.doIntercept(context); + } + + /** + * onServletStart + * + * @param args + */ + public void onServletStart(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + + iSupport.doIntercept(context); + } + + /** + * + * onServletRegist + * + * @param args + * @return + */ + public ServletContext onServletRegist(Object... args) { + + ServletContext servletContext = (ServletContext) args[0]; + + //uav's inner app doesn't need Profiling,just return origin servletContext here. + if("/com.creditease.uav".equals(servletContext.getContextPath())) { + return servletContext; + } + + ServletContext scProxy = (ServletContext) servletContext + .getAttribute("com.creditease.uav.mof.tomcat.servletcontext"); + + if (scProxy == null) { + scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), + new Class[] { ServletContext.class }, + new JDKProxyInvokeHandler(servletContext, new DynamicServletContextProcessor())); + + servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy); + } + + return scProxy; + } + + /** + * onServletStop + * + * @param args + */ + public void onServletStop(Object... args) { + + StandardWrapper sw = (StandardWrapper) args[0]; + Servlet servlet = (Servlet) args[1]; + InterceptSupport iSupport = InterceptSupport.instance(); + InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY); + context.put(InterceptConstants.SERVLET_INSTANCE, servlet); + context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader()); + context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath()); + iSupport.doIntercept(context); + } + + /** + * on Deploy UAV Application + * + * @param args + */ + @SuppressWarnings("unused") + public void onDeployUAVApp(Object... args) { + + if (System.getProperty("com.creditease.uav.iapp.install") != null) { + return; + } + + final HostConfig hc = (HostConfig) args[0]; + Host host = (Host) args[1]; + final File appBase = (File) args[2]; + final String mofRoot = (String) args[3]; + String curVersion = (String) args[4]; + String currentVersionDetailed = (String) args[5]; + String[] versions = currentVersionDetailed.split("\\."); + + int action = 0; + + if (curVersion.equals("6")) { + /** + * tomcat6 + */ + action = 0; + } + else if (curVersion.equals("7") && versions[1].equals("0") + && (Integer.parseInt(versions[2].substring(0, 1)) < 3)) { + /** + * tomcat7.并且小版本0.30.0 (不包含)以下。小版本号使用substring是因为存在beta版本,取第一位即可。 + */ + action = 0; + } + else { + action = 1; + } + + switch (action) { + case 0: + File dir = new File(mofRoot + "/com.creditease.uav"); + + ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", + new Class[] { String.class, File.class, String.class }, + new Object[] { "/com.creditease.uav", dir, mofRoot + "/com.creditease.uav" }, + hc.getClass().getClassLoader()); + break; + case 1: + ExecutorService es = host.getStartStopExecutor(); + + Future f = es.submit(new Runnable() { + + @Override + public void run() { + + ContextName cn = new ContextName("com.creditease.uav", ""); + + ReflectionHelper.setField(ContextName.class, cn, "baseName", mofRoot + "/com.creditease.uav"); + + File dir = new File(mofRoot + "/com.creditease.uav"); + + ReflectionHelper.invoke("org.apache.catalina.startup.HostConfig", hc, "deployDirectory", + new Class[] { ContextName.class, File.class }, new Object[] { cn, dir }, + hc.getClass().getClassLoader()); + + } + + }); + + try { + f.get(); + } + catch (Exception e) { + // ignore + } + break; + } + + System.setProperty("com.creditease.uav.iapp.install", "true"); + } + + /** + * when use embeddedTomcat and the webappclassloader is undefined, the webappclassloader will use systemclassloader as it's parentclassloader which coundn't load mof jars. + * we chg it's parentclassloader to currentThread's contextclassloader(normally it counld load uavmof jars). + */ + public ClassLoader chgParentClassloader(Object... args) { + + ClassLoader cl = (ClassLoader) args[0]; + + StandardContext sc = (StandardContext) args[1]; + if (cl != ClassLoader.getSystemClassLoader()) { + return cl; + } + else { + sc.setDelegate(true); + return Thread.currentThread().getContextClassLoader(); + } + } +} From bd9e3dbacc9f657f7fa33a6856040e0de636ef5a Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 2 Feb 2018 14:54:39 +0800 Subject: [PATCH 08/97] #181 springboot2.0 support 1.commit missing code --- .../tomcat/plus/interceptor/SpringBootTomcatPlusIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java index 3fc02d5f..f1b80e85 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java @@ -49,9 +49,9 @@ public class SpringBootTomcatPlusIT extends TomcatPlusIT { */ public void startServer(String port, String contextPath, String appName, Object arg) { - if (!"AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())) { + if(!isWebServerContext(arg)) { return; - } + } // integrate Tomcat log UAVServer.instance().setLog(new TomcatLog("MonitorServer")); From f4a360175ddb9587926abd28f4de212ace83da56 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 2 Feb 2018 15:07:07 +0800 Subject: [PATCH 09/97] merge from master --- .../bin/start_hm_apmserver.sh | 2 - .../bin/start_hm_apphubmgr.sh | 2 - .../bin/start_hm_hbserver.sh | 2 - .../bin/start_hm_logserver.sh | 2 - .../bin/start_hm_moserver.sh | 2 - .../bin/start_hm_nodeserver.sh | 2 - .../bin/start_hm_pfntfyserver.sh | 2 - .../bin/start_hm_pnhbserver.sh | 2 - .../bin/start_hm_pro_apmserver.sh | 2 + .../bin/start_hm_pro_apphubmgr.sh | 2 + .../bin/start_hm_pro_hbserver.sh | 2 + .../bin/start_hm_pro_logserver.sh | 2 + .../bin/start_hm_pro_moserver.sh | 2 + .../bin/start_hm_pro_nodeserver.sh | 2 + .../bin/start_hm_pro_pfntfyserver.sh | 2 + .../bin/start_hm_pro_rtserver.sh | 2 + .../bin/start_hm_rtserver.sh | 2 - .../bin/start_hm_test_apmserver.sh | 2 + .../bin/start_hm_test_logserver.sh | 2 + .../bin/start_hm_test_moserver.sh | 2 + .../bin/start_hm_test_nodeserver.sh | 2 + .../bin/start_hm_test_pnhbserver.sh | 2 + .../bin/start_hm_test_rtserver.sh | 2 + .../bin/stop_hm_apmserver.sh | 2 - .../bin/stop_hm_apphubmgr.sh | 2 - .../bin/stop_hm_hbserver.sh | 2 - .../bin/stop_hm_logserver.sh | 2 - .../bin/stop_hm_moserver.sh | 2 - .../bin/stop_hm_nodeserver.sh | 2 - .../bin/stop_hm_pfntfyserver.sh | 2 - .../bin/stop_hm_pnhbserver.sh | 2 - .../bin/stop_hm_pro_apmserver.sh | 2 + .../bin/stop_hm_pro_apphubmgr.sh | 2 + .../bin/stop_hm_pro_hbserver.sh | 2 + .../bin/stop_hm_pro_logserver.sh | 2 + .../bin/stop_hm_pro_moserver.sh | 2 + .../bin/stop_hm_pro_nodeserver.sh | 2 + .../bin/stop_hm_pro_pfntfyserver.sh | 2 + .../bin/stop_hm_pro_rtserver.sh | 2 + .../bin/stop_hm_rtserver.sh | 2 - .../bin/stop_hm_test_apmserver.sh | 2 + .../bin/stop_hm_test_logserver.sh | 2 + .../bin/stop_hm_test_moserver.sh | 2 + .../bin/stop_hm_test_nodeserver.sh | 2 + .../bin/stop_hm_test_pnhbserver.sh | 2 + .../bin/stop_hm_test_rtserver.sh | 2 + .../config/agent.properties | 865 ++++++++-------- .../config/hm_logserver.properties | 94 -- ...properties => hm_pro_apmserver.properties} | 274 ++--- ...properties => hm_pro_apphubmgr.properties} | 501 +++++---- ....properties => hm_pro_hbserver.properties} | 312 +++--- .../config/hm_pro_logserver.properties | 223 ++++ ....properties => hm_pro_moserver.properties} | 310 +++--- ...roperties => hm_pro_nodeserver.properties} | 322 +++--- ...perties => hm_pro_pfntfyserver.properties} | 420 ++++---- ....properties => hm_pro_rtserver.properties} | 232 ++--- .../config/hm_test_apmserver.properties | 137 +++ .../config/hm_test_logserver.properties | 226 +++++ .../config/hm_test_moserver.properties | 155 +++ .../config/hm_test_nodeserver.properties | 169 ++++ ...operties => hm_test_pnhbserver.properties} | 623 ++++++------ .../config/hm_test_rtserver.properties | 118 +++ .../creditease/uav/feature/HealthManager.java | 949 +++++++++--------- .../interceptor/SpringBootTomcatPlusIT.java | 4 +- 64 files changed, 3509 insertions(+), 2517 deletions(-) delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh create mode 100644 com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh delete mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties rename com.creditease.uav.healthmanager.buildComponent/config/{hm_apmserver.properties => hm_pro_apmserver.properties} (88%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_apphubmgr.properties => hm_pro_apphubmgr.properties} (83%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_hbserver.properties => hm_pro_hbserver.properties} (89%) create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties rename com.creditease.uav.healthmanager.buildComponent/config/{hm_moserver.properties => hm_pro_moserver.properties} (78%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_nodeserver.properties => hm_pro_nodeserver.properties} (80%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pfntfyserver.properties => hm_pro_pfntfyserver.properties} (84%) rename com.creditease.uav.healthmanager.buildComponent/config/{hm_rtserver.properties => hm_pro_rtserver.properties} (89%) create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties rename com.creditease.uav.healthmanager.buildComponent/config/{hm_pnhbserver.properties => hm_test_pnhbserver.properties} (88%) create mode 100644 com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh deleted file mode 100644 index d6426e65..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh APMServer hm_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh deleted file mode 100644 index 3dabe1b5..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_apphubmgr.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh AppHubManager hm_apphubmgr -Xmx1024m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh deleted file mode 100644 index 54fae549..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_hbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh HeartBeatServer hm_hbserver -Xmx768m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh deleted file mode 100644 index 3fe60e29..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh LogDataServer hm_logserver -Xmx1280m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh deleted file mode 100644 index 1f994d43..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh MonitorDataServer hm_moserver -Xmx1536m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh deleted file mode 100644 index 02b649d9..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh NodeDataServer hm_nodeserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh deleted file mode 100644 index e2fefb06..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pfntfyserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh Profile_NotifyDataServer hm_pfntfyserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh deleted file mode 100644 index 941201be..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pnhbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh Profile_Notify_HBServer hm_pnhbserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh new file mode 100644 index 00000000..b6c31040 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh APMServer hm_pro_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh new file mode 100644 index 00000000..320b0473 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_apphubmgr.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh AppHubManager hm_pro_apphubmgr -Xmx1024m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh new file mode 100644 index 00000000..4c6e7130 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_hbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh HeartBeatServer hm_pro_hbserver -Xmx768m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh new file mode 100644 index 00000000..778af771 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh LogDataServer hm_pro_logserver -Xmx1280m >/dev/null 2>&1 & diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh new file mode 100644 index 00000000..c2ebc586 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh MonitorDataServer hm_pro_moserver -Xmx1536m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh new file mode 100644 index 00000000..f255168a --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh NodeDataServer hm_pro_nodeserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh new file mode 100644 index 00000000..c9b5da97 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_pfntfyserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh Profile_NotifyDataServer hm_pro_pfntfyserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh new file mode 100644 index 00000000..8fef1c8f --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_pro_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh RuntimeServer hm_pro_rtserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh deleted file mode 100644 index 64dac3c6..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nohup ./run.sh RuntimeServer hm_rtserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh new file mode 100644 index 00000000..9fa24bc0 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh APMServer hm_test_apmserver -Xmx1024m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh new file mode 100644 index 00000000..90dacc25 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh LogServer hm_test_logserver -Xmx768m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh new file mode 100644 index 00000000..cf7739b5 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh MonitorServer hm_test_moserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh new file mode 100644 index 00000000..ed92082b --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh NodeDataServer hm_test_nodeserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh new file mode 100644 index 00000000..16667006 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_pnhbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh Profile_Notify_HBServer hm_test_pnhbserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh new file mode 100644 index 00000000..c92a783e --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/start_hm_test_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nohup ./run.sh RuntimeServer hm_test_rtserver -Xmx512m >/dev/null 2>&1 & \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh deleted file mode 100644 index 87663f14..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apmserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh deleted file mode 100644 index f4723bfb..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_apphubmgr.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_apphubmgr \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh deleted file mode 100644 index baeaf1c6..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_hbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_hbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh deleted file mode 100644 index 2edf4bf4..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_logserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh deleted file mode 100644 index e14fd98d..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_moserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh deleted file mode 100644 index 3f7abd0b..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_nodeserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh deleted file mode 100644 index 58e0ce86..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pfntfyserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pfntfyserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh deleted file mode 100644 index f9d86ee0..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pnhbserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_pnhbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh new file mode 100644 index 00000000..f5708796 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh new file mode 100644 index 00000000..7451371c --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_apphubmgr.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_apphubmgr \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh new file mode 100644 index 00000000..684f18b2 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_hbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_hbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh new file mode 100644 index 00000000..bbaa392d --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh new file mode 100644 index 00000000..12637ed0 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh new file mode 100644 index 00000000..30aba5c5 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh new file mode 100644 index 00000000..541c8714 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_pfntfyserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_pfntfyserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh new file mode 100644 index 00000000..a7b17b54 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_pro_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_pro_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh deleted file mode 100644 index 795b2efc..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_rtserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./stop.sh hm_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh new file mode 100644 index 00000000..fdf146e0 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_apmserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_apmserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh new file mode 100644 index 00000000..f1c66251 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_logserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_logserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh new file mode 100644 index 00000000..ebdddd79 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_moserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_moserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh new file mode 100644 index 00000000..037c96d6 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_nodeserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_nodeserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh new file mode 100644 index 00000000..d8ed84a7 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_pnhbserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_pnhbserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh new file mode 100644 index 00000000..9567f7b0 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/bin/stop_hm_test_rtserver.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./stop.sh hm_test_rtserver \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index eb300fc2..6812feea 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -1,429 +1,438 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5065\u5EB7\u7BA1\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10102 - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=10 -feature.notifycenter.inqw.bQueueSize=1000 -feature.notifycenter.inqw.keepAliveTimeout=10000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username=system -feature.notifycenter.nc.notify.mail.cemail.password=manager -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=8766 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services=dhandsonrobot-DHandsonRobot-Server-/hit/xrobot:monitor/ntfpush - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8765 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=10 -feature.healthmanager.store.concurrent.max=20 -feature.healthmanager.store.concurrent.bqsize=10 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -feature.healthmanager.MT_Monitor.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeinfoDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010 - -feature.hbclientagent.interval=15000 - -#Proc Detect Agent Feature -feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar -feature.procscan.enable=false -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8011 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:27017 -feature.apphubmanager.ds.db=apphubDataStore -#feature.apphubmanager.ds.power=admin -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#IssueDiagnoseAssitAgent -feature.ida.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.ida.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.ida.components=com.creditease.uav.feature.IssueDiagnoseAssitAgent -feature.ida.properties= -#tools -feature.ida.dwhhandlers=com.creditease.uav.feature.ida.tools.ContainerPerfCatcher -#ContainerPerfCatcher configuration -feature.ida.ContainerPerfCatcher.enable=true -feature.ida.ContainerPerfCatcher.threshold=cpu=0.8 -feature.ida.ContainerPerfCatcher.root=d:/UAVTEST - -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#runtime consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=10 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=true -#1n worker -feature.runtimenotify.qworker.coresize=10 -feature.runtimenotify.qworker.maxsize=20 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=10000 -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=10 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=50 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=5 -#timernotifyworker -feature.runtimenotify.timernotify.enable=true -feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9000 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=30000 -#in seconds -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} - -# Data Collect Feature -feature.collectserver.loader=com.creditease.uav.collect.jar -feature.collectserver.enable=true -feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager -feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM -feature.collectserver.messagingnameserver=127.0.0.1:9876 -# for topic consumer performance tuning -#feature.collectserver..consumethreadmax=10 -#feature.collectserver..consumestopinterval=0 -#feature.collectserver..enable=true -feature.collectserver.JQ_IVC.consumethreadmax=10 -feature.collectserver.JQ_IVC.consumestopinterval=0 -feature.collectserver.JQ_IVC.enable=true - -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - -feature.collectserver.JQ_SLW.consumethreadmax=10 -feature.collectserver.JQ_SLW.consumestopinterval=0 -feature.collectserver.JQ_SLW.enable=true - -feature.collectserver.JQ_JTA.consumethreadmax=5 -feature.collectserver.JQ_JTA.consumestopinterval=0 -feature.collectserver.JQ_JTA.enable=true - -#InvokeChain Process Server Feature -feature.invokechainserver.loader=com.creditease.uav.invokechain.jar -feature.invokechainserver.enable=true -feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer -feature.invokechainserver.properties= -#cache -feature.invokechainserver.store.addr=127.0.0.1:6379 -feature.invokechainserver.store.concurrent.min=10 -feature.invokechainserver.store.concurrent.max=50 -feature.invokechainserver.store.concurrent.bqsize=5 -feature.invokechainserver.store.concurrent.pwd= -#elastic-search -feature.invokechainserver.es.addr=127.0.0.1:9300 -feature.invokechainserver.es.clustername= -feature.invokechainserver.es.query.timeout=5000 -#query http service -feature.invokechainserver.http.enable=true -feature.invokechainserver.http.port=7799 -feature.invokechainserver.http.core=10 -feature.invokechainserver.http.max=100 -feature.invokechainserver.http.backlog=10 -feature.invokechainserver.http.bqsize=10 -feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=com.creditease.uav.invokechain.jar -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=false -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300 -feature.newlogservice.es.clustername= -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=10 -feature.newlogservice.http.max=100 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 -feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler - - -#Thread Analysis Server Feature -feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar -feature.threadanalysisserver.enable=true -feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer -#elastic-search -feature.threadanalysisserver.es.addr=127.0.0.1:9300 -feature.threadanalysisserver.es.clustername= -feature.threadanalysisserver.es.query.timeout=5000 -#query http service -feature.threadanalysisserver.http.enable=true -feature.threadanalysisserver.http.port=5566 -feature.threadanalysisserver.http.core=10 -feature.threadanalysisserver.http.max=100 -feature.threadanalysisserver.http.backlog=10 -feature.threadanalysisserver.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5065\u5EB7\u7BA1\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10102 + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=10 +feature.notifycenter.inqw.bQueueSize=1000 +feature.notifycenter.inqw.keepAliveTimeout=10000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username=system +feature.notifycenter.nc.notify.mail.cemail.password=manager +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=8766 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services=dhandsonrobot-DHandsonRobot-Server-/hit/xrobot:monitor/ntfpush + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8765 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=10 +feature.healthmanager.store.concurrent.max=20 +feature.healthmanager.store.concurrent.bqsize=10 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +feature.healthmanager.MT_Monitor.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeinfoDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010 + +feature.hbclientagent.interval=15000 + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=false +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8011 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:27017 +feature.apphubmanager.ds.db=apphubDataStore +#feature.apphubmanager.ds.power=admin +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#IssueDiagnoseAssitAgent +feature.ida.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.ida.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.ida.components=com.creditease.uav.feature.IssueDiagnoseAssitAgent +feature.ida.properties= +#tools +feature.ida.dwhhandlers=com.creditease.uav.feature.ida.tools.ContainerPerfCatcher +#ContainerPerfCatcher configuration +feature.ida.ContainerPerfCatcher.enable=true +feature.ida.ContainerPerfCatcher.threshold=cpu=0.8 +feature.ida.ContainerPerfCatcher.root=d:/UAVTEST + +#feature runtimenotify +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#runtime consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=10 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=true +#1n worker +feature.runtimenotify.qworker.coresize=10 +feature.runtimenotify.qworker.maxsize=20 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=10000 +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=10 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=50 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=5 +#timernotifyworker +feature.runtimenotify.timernotify.enable=true +feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9000 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=10 +feature.runtimenotify.http.max=50 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=30000 +#in seconds +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} + +# Data Collect Feature +feature.collectserver.loader=com.creditease.uav.collect.jar +feature.collectserver.enable=true +feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager +feature.collectserver.properties= +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.messagingnameserver=127.0.0.1:9876 +# for topic consumer performance tuning +#feature.collectserver..consumethreadmax=10 +#feature.collectserver..consumestopinterval=0 +#feature.collectserver..enable=true +feature.collectserver.JQ_IVC.consumethreadmax=10 +feature.collectserver.JQ_IVC.consumestopinterval=0 +feature.collectserver.JQ_IVC.enable=true + +feature.collectserver.JQ_UEM.consumethreadmax=10 +feature.collectserver.JQ_UEM.consumestopinterval=0 +feature.collectserver.JQ_UEM.enable=true + +feature.collectserver.JQ_SLW.consumethreadmax=10 +feature.collectserver.JQ_SLW.consumestopinterval=0 +feature.collectserver.JQ_SLW.enable=true + +feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumestopinterval=0 +feature.collectserver.JQ_JTA.enable=true + +#InvokeChain Process Server Feature +feature.invokechainserver.loader=com.creditease.uav.invokechain.jar +feature.invokechainserver.enable=true +feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer +feature.invokechainserver.properties= +#cache +feature.invokechainserver.store.addr=127.0.0.1:6379 +feature.invokechainserver.store.concurrent.min=10 +feature.invokechainserver.store.concurrent.max=50 +feature.invokechainserver.store.concurrent.bqsize=5 +feature.invokechainserver.store.concurrent.pwd= +#elastic-search +feature.invokechainserver.es.addr=127.0.0.1:9300 +feature.invokechainserver.es.clustername= +feature.invokechainserver.es.query.timeout=5000 +#query http service +feature.invokechainserver.http.enable=true +feature.invokechainserver.http.port=7799 +feature.invokechainserver.http.core=10 +feature.invokechainserver.http.max=100 +feature.invokechainserver.http.backlog=10 +feature.invokechainserver.http.bqsize=10 +feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler + + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=false +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300 +feature.newlogservice.es.clustername= +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=10 +feature.newlogservice.http.max=100 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 +feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler + + +#Thread Analysis Server Feature +feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar +feature.threadanalysisserver.enable=true +feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer +#elastic-search +feature.threadanalysisserver.es.addr=127.0.0.1:9300 +feature.threadanalysisserver.es.clustername= +feature.threadanalysisserver.es.query.timeout=5000 +#query http service +feature.threadanalysisserver.http.enable=true +feature.threadanalysisserver.http.port=5566 +feature.threadanalysisserver.http.core=10 +feature.threadanalysisserver.http.max=100 +feature.threadanalysisserver.http.backlog=10 +feature.threadanalysisserver.http.bqsize=10 feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties deleted file mode 100644 index 9df2793a..00000000 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_logserver.properties +++ /dev/null @@ -1,94 +0,0 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10130 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager NewLogService Feature -feature.newlogservice.loader=com.creditease.uav.invokechain.jar -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=edp-es -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=50 -feature.newlogservice.http.max=300 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 -feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties similarity index 88% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties index b2683734..a138079c 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties @@ -1,138 +1,138 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10146 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -# Data Collect Feature -feature.collectserver.loader=com.creditease.uav.collect.jar -feature.collectserver.enable=true -feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager -feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM -feature.collectserver.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -# for topic consumer performance tuning -#feature.collectserver..consumethreadmax=10 -#feature.collectserver..consumestopinterval=0 -#feature.collectserver..enable=true -feature.collectserver.JQ_IVC.consumethreadmax=10 -feature.collectserver.JQ_IVC.consumestopinterval=0 -feature.collectserver.JQ_IVC.enable=true - -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - -feature.collectserver.JQ_SLW.consumethreadmax=10 -feature.collectserver.JQ_SLW.consumestopinterval=0 -feature.collectserver.JQ_SLW.enable=true - -feature.collectserver.JQ_JTA.consumethreadmax=5 -feature.collectserver.JQ_JTA.consumestopinterval=0 -feature.collectserver.JQ_JTA.enable=true - -#InvokeChain Process Server Feature -feature.invokechainserver.loader=com.creditease.uav.invokechain.jar -feature.invokechainserver.enable=true -feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer -feature.invokechainserver.properties= -#cache -feature.invokechainserver.store.addr=127.0.0.1:26379 -feature.invokechainserver.store.concurrent.min=10 -feature.invokechainserver.store.concurrent.max=50 -feature.invokechainserver.store.concurrent.bqsize=5 -feature.invokechainserver.store.concurrent.pwd= -#elastic-search -feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.invokechainserver.es.clustername=edp-es -feature.invokechainserver.es.query.timeout=5000 -#query http service -feature.invokechainserver.http.enable=true -feature.invokechainserver.http.port=7799 -feature.invokechainserver.http.core=30 -feature.invokechainserver.http.max=200 -feature.invokechainserver.http.backlog=10 -feature.invokechainserver.http.bqsize=10 -feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler - - -#Thread Analysis Server Feature -feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar -feature.threadanalysisserver.enable=true -feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer -#elastic-search -feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.threadanalysisserver.es.clustername=edp-es -feature.threadanalysisserver.es.query.timeout=5000 -#query http service -feature.threadanalysisserver.http.enable=true -feature.threadanalysisserver.http.port=5566 -feature.threadanalysisserver.http.core=10 -feature.threadanalysisserver.http.max=100 -feature.threadanalysisserver.http.backlog=10 -feature.threadanalysisserver.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10146 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +# Data Collect Feature +feature.collectserver.loader=default +feature.collectserver.enable=true +feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager +feature.collectserver.properties= +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +# for topic consumer performance tuning +#feature.collectserver..consumethreadmax=10 +#feature.collectserver..consumestopinterval=0 +#feature.collectserver..enable=true +feature.collectserver.JQ_IVC.consumethreadmax=10 +feature.collectserver.JQ_IVC.consumestopinterval=0 +feature.collectserver.JQ_IVC.enable=true + +feature.collectserver.JQ_UEM.consumethreadmax=10 +feature.collectserver.JQ_UEM.consumestopinterval=0 +feature.collectserver.JQ_UEM.enable=true + +feature.collectserver.JQ_SLW.consumethreadmax=10 +feature.collectserver.JQ_SLW.consumestopinterval=0 +feature.collectserver.JQ_SLW.enable=true + +feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumestopinterval=0 +feature.collectserver.JQ_JTA.enable=true + +#InvokeChain Process Server Feature +feature.invokechainserver.loader=default +feature.invokechainserver.enable=true +feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer +feature.invokechainserver.properties= +#cache +feature.invokechainserver.store.addr=127.0.0.1:26379 +feature.invokechainserver.store.concurrent.min=10 +feature.invokechainserver.store.concurrent.max=50 +feature.invokechainserver.store.concurrent.bqsize=5 +feature.invokechainserver.store.concurrent.pwd= +#elastic-search +feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.invokechainserver.es.clustername=edp-es +feature.invokechainserver.es.query.timeout=5000 +#query http service +feature.invokechainserver.http.enable=true +feature.invokechainserver.http.port=7799 +feature.invokechainserver.http.core=30 +feature.invokechainserver.http.max=200 +feature.invokechainserver.http.backlog=10 +feature.invokechainserver.http.bqsize=10 +feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler + + +#Thread Analysis Server Feature +feature.threadanalysisserver.loader=default +feature.threadanalysisserver.enable=true +feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer +#elastic-search +feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.threadanalysisserver.es.clustername=edp-es +feature.threadanalysisserver.es.query.timeout=5000 +#query http service +feature.threadanalysisserver.http.enable=true +feature.threadanalysisserver.http.port=5566 +feature.threadanalysisserver.http.core=10 +feature.threadanalysisserver.http.max=100 +feature.threadanalysisserver.http.backlog=10 +feature.threadanalysisserver.http.bqsize=10 feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties similarity index 83% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties index 7933decc..8be6816a 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_apphubmgr.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties @@ -1,251 +1,250 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10120 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#feature apphubmanager BEGIN------------------------------------------------------------------ -feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=20 -feature.apphubmanager.http.max=100 -feature.apphubmanager.http.bqsize=20 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:27017 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#HealthManager------------------------------------------------------------------ -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=20 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=30 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=50 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 -#-------------------------------HBServer Query-------------------------- -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8012 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8022 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=20 -feature.hbserveragent.http.max=150 -feature.hbserveragent.http.bqsize=5 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=30 -feature.hbserveragent.store.concurrent.max=150 -feature.hbserveragent.store.concurrent.bqsize=5 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=30000 - -#-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=60 -feature.runtimenotify.storecm.qsize=20 -#qworker -feature.runtimenotify.qworker.coresize=10 -feature.runtimenotify.qworker.maxsize=30 -feature.runtimenotify.qworker.bqsize=50 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9004 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=20 -feature.runtimenotify.http.max=100 -feature.runtimenotify.http.bqsize=5 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} \ No newline at end of file +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10120 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#feature apphubmanager BEGIN------------------------------------------------------------------ +feature.apphubmanager.loader=default +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=20 +feature.apphubmanager.http.max=100 +feature.apphubmanager.http.bqsize=20 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=uav.db.jishu.idc:25000 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#HealthManager------------------------------------------------------------------ +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8044 +feature.healthmanager.http.backlog=20 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=30 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=50 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#-------------------------------HBServer Query-------------------------- +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8012 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8022 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=20 +feature.hbserveragent.http.max=150 +feature.hbserveragent.http.bqsize=5 +feature.hbserveragent.store.addr=127.0.0.1:26379 +feature.hbserveragent.store.concurrent.min=30 +feature.hbserveragent.store.concurrent.max=150 +feature.hbserveragent.store.concurrent.bqsize=5 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=30000 + +#-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:26379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.storecm.server=127.0.0.1:26379 +feature.runtimenotify.storecm.minsize=30 +feature.runtimenotify.storecm.maxsize=60 +feature.runtimenotify.storecm.qsize=20 +#qworker +feature.runtimenotify.qworker.coresize=10 +feature.runtimenotify.qworker.maxsize=30 +feature.runtimenotify.qworker.bqsize=50 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9004 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=20 +feature.runtimenotify.http.max=100 +feature.runtimenotify.http.bqsize=5 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties similarity index 89% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties index aa917e13..fe53e907 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_hbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties @@ -1,152 +1,160 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -#heart beat server poll self -feature.hbclientagent.hbservers=127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8011 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8021 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=30 -feature.hbserveragent.http.max=150 -feature.hbserveragent.http.bqsize=5 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=40 -feature.hbserveragent.store.concurrent.max=200 -feature.hbserveragent.store.concurrent.bqsize=5 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=30000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=10 -feature.runtimenotify.cm.maxsize=30 -feature.runtimenotify.cm.qsize=5 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=150 -feature.runtimenotify.storecm.qsize=5 -#qworker -feature.runtimenotify.qworker.coresize=20 -feature.runtimenotify.qworker.maxsize=100 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9003 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +#heart beat server poll self +feature.hbclientagent.hbservers=127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#Proc Detect Agent Feature +feature.procscan.loader=default +feature.procscan.enable=false +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8011 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8021 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=30 +feature.hbserveragent.http.max=150 +feature.hbserveragent.http.bqsize=5 +feature.hbserveragent.store.addr=127.0.0.1:26379 +feature.hbserveragent.store.concurrent.min=40 +feature.hbserveragent.store.concurrent.max=200 +feature.hbserveragent.store.concurrent.bqsize=5 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=30000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#-------------------------------------------RUNTIME NOTIFY------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:26379 +feature.runtimenotify.cm.minsize=10 +feature.runtimenotify.cm.maxsize=30 +feature.runtimenotify.cm.qsize=5 +feature.runtimenotify.storecm.server=127.0.0.1:26379 +feature.runtimenotify.storecm.minsize=30 +feature.runtimenotify.storecm.maxsize=150 +feature.runtimenotify.storecm.qsize=5 +#qworker +feature.runtimenotify.qworker.coresize=20 +feature.runtimenotify.qworker.maxsize=100 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9003 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=10 +feature.runtimenotify.http.max=50 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties new file mode 100644 index 00000000..ad29351d --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties @@ -0,0 +1,223 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10130 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=5 +feature.healthmanager.MT_Notify.consumethreadmax=5 +feature.healthmanager.MT_Profile.consumethreadmax=5 +feature.healthmanager.MT_Log.consumethreadmax=20 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=true +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8041 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=20 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=5 +feature.healthmanager.store.concurrent.max=10 +feature.healthmanager.store.concurrent.bqsize=20 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#-------------------------------------------RUNTIME NOTIFY------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=false +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:26379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.storecm.server=127.0.0.1:26379 +feature.runtimenotify.storecm.minsize=30 +feature.runtimenotify.storecm.maxsize=60 +feature.runtimenotify.storecm.qsize=20 +#qworker +feature.runtimenotify.qworker.coresize=20 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=20 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9001 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=10 +feature.runtimenotify.http.max=50 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} + + +#HealthManager NewLogService Feature +feature.newlogservice.loader=default +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=edp-es +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=50 +feature.newlogservice.http.max=300 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 +feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties similarity index 78% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties index 9cd8b3f6..bd06ec0d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties @@ -1,156 +1,154 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=50 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.buffersize=150 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10140 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=50 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8042 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=500 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=500 +feature.healthmanager.MT_Monitor.ds.retry=1 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties similarity index 80% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties index 48766390..fde2b44e 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties @@ -1,156 +1,168 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.buffersize=150 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10145 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8045 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=500 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 -feature.healthmanager.MT_Monitor.ds.maxRoute=500 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=5000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=500 -feature.healthmanager.MT_Monitor.ds.retry=1 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.buffersize=150 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10145 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8042 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=500 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=false +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=false +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=false +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 +feature.healthmanager.MT_Monitor.ds.maxRoute=500 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=500 +feature.healthmanager.MT_Monitor.ds.retry=1 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties similarity index 84% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties index 70ad37e5..ab40d611 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties @@ -1,211 +1,209 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10150 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=15 -feature.healthmanager.MT_Profile.consumethreadmax=25 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=150 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 - -#-----------------------------NOTIFICATION CENTER--------------------------------------------------- - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=50 -feature.notifycenter.inqw.bQueueSize=5 -feature.notifycenter.inqw.keepAliveTimeout=30000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=30 -feature.notifycenter.nc.cache.concurrent.max=100 -feature.notifycenter.nc.cache.concurrent.bqsize=5 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=30 -feature.notifycenter.http.max=150 -feature.notifycenter.http.bqsize=5 -#push to other services -feature.notifycenter.push.services= - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10150 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=15 +feature.healthmanager.MT_Profile.consumethreadmax=25 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=20 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=150 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#-----------------------------NOTIFICATION CENTER--------------------------------------------------- + +#notifcenter +feature.notifycenter.loader=default +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=50 +feature.notifycenter.inqw.bQueueSize=5 +feature.notifycenter.inqw.keepAliveTimeout=30000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:26379 +feature.notifycenter.nc.cache.concurrent.min=30 +feature.notifycenter.nc.cache.concurrent.max=100 +feature.notifycenter.nc.cache.concurrent.bqsize=5 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=30 +feature.notifycenter.http.max=150 +feature.notifycenter.http.bqsize=5 +#push to other services +feature.notifycenter.push.services= + diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties similarity index 89% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties index c62990b2..c6f567c7 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties @@ -1,116 +1,116 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=true -#1n worker -feature.runtimenotify.qworker.coresize=50 -feature.runtimenotify.qworker.maxsize=100 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout610000 -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=15 -feature.runtimenotify.cm.maxsize=30 -feature.runtimenotify.cm.qsize=5 -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=100 -feature.runtimenotify.storecm.maxsize=300 -feature.runtimenotify.storecm.qsize=5 -#timernotifyworker -feature.runtimenotify.timernotify.enable=true -feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9002 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=30 -feature.runtimenotify.http.max=60 -feature.runtimenotify.http.bqsize=5 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"60000"}} +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10140 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#-------------------------------------------RUNTIME NOTIFY------------------------------------------- +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=true +#1n worker +feature.runtimenotify.qworker.coresize=50 +feature.runtimenotify.qworker.maxsize=100 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout610000 +#cache +feature.runtimenotify.cm.server=127.0.0.1:26379 +feature.runtimenotify.cm.minsize=15 +feature.runtimenotify.cm.maxsize=30 +feature.runtimenotify.cm.qsize=5 +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=100 +feature.runtimenotify.storecm.maxsize=300 +feature.runtimenotify.storecm.qsize=5 +#timernotifyworker +feature.runtimenotify.timernotify.enable=true +feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9002 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=30 +feature.runtimenotify.http.max=60 +feature.runtimenotify.http.bqsize=5 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"60000"}} diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties new file mode 100644 index 00000000..f3acf99c --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties @@ -0,0 +1,137 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10116 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- +# Data Collect Feature +feature.collectserver.loader=default +feature.collectserver.enable=true +feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager +feature.collectserver.properties= +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.messagingnameserver=127.0.0.1:9876 +# for topic consumer performance tuning +#feature.collectserver..consumethreadmax=10 +#feature.collectserver..consumestopinterval=0 +#feature.collectserver..enable=true +feature.collectserver.JQ_IVC.consumethreadmax=10 +feature.collectserver.JQ_IVC.consumestopinterval=0 +feature.collectserver.JQ_IVC.enable=true + +feature.collectserver.JQ_UEM.consumethreadmax=10 +feature.collectserver.JQ_UEM.consumestopinterval=0 +feature.collectserver.JQ_UEM.enable=true + +feature.collectserver.JQ_SLW.consumethreadmax=10 +feature.collectserver.JQ_SLW.consumestopinterval=0 +feature.collectserver.JQ_SLW.enable=true + +feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumestopinterval=0 +feature.collectserver.JQ_JTA.enable=true + +#InvokeChain Process Server Feature +feature.invokechainserver.loader=default +feature.invokechainserver.enable=true +feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer +feature.invokechainserver.properties= +#cache +feature.invokechainserver.store.addr=127.0.0.1:6379 +feature.invokechainserver.store.concurrent.min=10 +feature.invokechainserver.store.concurrent.max=50 +feature.invokechainserver.store.concurrent.bqsize=5 +feature.invokechainserver.store.concurrent.pwd= +#elastic-search +feature.invokechainserver.es.addr=127.0.0.1:9300,127.0.0.1:9300 +feature.invokechainserver.es.clustername=uav-es5.4.1 +feature.invokechainserver.es.query.timeout=5000 +#query http service +feature.invokechainserver.http.enable=true +feature.invokechainserver.http.port=7799 +feature.invokechainserver.http.core=30 +feature.invokechainserver.http.max=150 +feature.invokechainserver.http.backlog=10 +feature.invokechainserver.http.bqsize=10 +feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeChainQueryHandler,com.creditease.uav.invokechain.http.SlowOperQueryHandler +#Thread Analysis Server Feature + + +feature.threadanalysisserver.loader=default +feature.threadanalysisserver.enable=true +feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer +#elastic-search +feature.threadanalysisserver.es.addr=127.0.0.1:9300,127.0.0.1:9300 +feature.threadanalysisserver.es.clustername=uav-es5.4.1 +feature.threadanalysisserver.es.query.timeout=5000 +#query http service +feature.threadanalysisserver.http.enable=true +feature.threadanalysisserver.http.port=5566 +feature.threadanalysisserver.http.core=10 +feature.threadanalysisserver.http.max=100 +feature.threadanalysisserver.http.backlog=10 +feature.threadanalysisserver.http.bqsize=10 +feature.threadanalysisserver.qhandlers=com.creditease.uav.threadanalysis.http.ThreadAnalysisQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties new file mode 100644 index 00000000..16aeb53e --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties @@ -0,0 +1,226 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10111 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=5 +feature.healthmanager.MT_Notify.consumethreadmax=5 +feature.healthmanager.MT_Profile.consumethreadmax=5 +feature.healthmanager.MT_Log.consumethreadmax=20 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=true +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8042 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=10 +feature.healthmanager.store.concurrent.max=20 +feature.healthmanager.store.concurrent.bqsize=10 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=false +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=100 +feature.runtimenotify.storecm.maxsize=300 +feature.runtimenotify.storecm.qsize=5 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9002 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} + + +#HealthManager NewLogService Feature +feature.newlogservice.loader=default +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=uav-es5.4.1 +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=30 +feature.newlogservice.http.max=200 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 +feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties new file mode 100644 index 00000000..fd792739 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties @@ -0,0 +1,155 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10112 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=35 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties new file mode 100644 index 00000000..d0fc078c --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties @@ -0,0 +1,169 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10115 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8044 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=false +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=false +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=false +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties similarity index 88% rename from com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties rename to com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties index 95bfa89d..54d67f84 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties @@ -1,314 +1,311 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:27017 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=20 -feature.notifycenter.inqw.bQueueSize=50 -feature.notifycenter.inqw.keepAliveTimeout=60000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services= - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=100 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=200 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:27017 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=10000 -feature.healthmanager.MT_Monitor.ds.connTimeout=5000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243,127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 - - -#------------------------------------------------------------------------------------------------- - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=40 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=10 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=default +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:26000 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#notifcenter +feature.notifycenter.loader=default +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=20 +feature.notifycenter.inqw.bQueueSize=50 +feature.notifycenter.inqw.keepAliveTimeout=60000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services= + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=default +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8041 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=100 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=200 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=10000 +feature.healthmanager.MT_Monitor.ds.connTimeout=5000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=3000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#------------------------------------------------------------------------------------------------- + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=default +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=40 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=10 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9001 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties new file mode 100644 index 00000000..1a6e7659 --- /dev/null +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties @@ -0,0 +1,118 @@ +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=default +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10113 + +#notifyagent +feature.notifyagent.loader=default +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=default +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=default +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data comsumer +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=true +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=100 +feature.runtimenotify.storecm.maxsize=300 +feature.runtimenotify.storecm.qsize=10 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=20 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#timernotifyworker +feature.runtimenotify.timernotify.enable=true +feature.runtimenotify.queryservice=healthmanager-HealthMangerServerWorker-/hm/query +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=false +feature.runtimenotify.nodeinfotimer.period=15000 +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9003 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms +feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java index 5283323e..5feb9db5 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/HealthManager.java @@ -1,466 +1,483 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.uavstack.resources.common.messaging.StandardMessagingBuilder; - -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.monitor.api.MonitorDataFrame; -import com.creditease.agent.profile.api.StandardProfileModeler; -import com.creditease.agent.spi.AgentFeatureComponent; -import com.creditease.agent.spi.IActionEngine; -import com.creditease.agent.spi.IConfigurationManager; -import com.creditease.uav.cache.api.CacheManager; -import com.creditease.uav.cache.api.CacheManagerFactory; -import com.creditease.uav.datastore.api.DataStoreAdapter; -import com.creditease.uav.datastore.api.DataStoreConnection; -import com.creditease.uav.datastore.api.DataStoreFactory; -import com.creditease.uav.datastore.api.DataStoreFactory.DataStoreType; -import com.creditease.uav.datastore.api.DataStoreMsg; -import com.creditease.uav.datastore.api.DataStoreProtocol; -import com.creditease.uav.datastore.core.AbstractDataStore; -import com.creditease.uav.feature.healthmanager.HealthManagerConstants; -import com.creditease.uav.feature.healthmanager.HealthManagerProfileDataLifeKeeper; -import com.creditease.uav.feature.healthmanager.HealthManagerServerWorker; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater; -import com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater; -import com.creditease.uav.messaging.api.MessageConsumer; - -public class HealthManager extends AgentFeatureComponent { - - private MessageConsumer monitorDataConsumer; - - private MessageConsumer notificationConsumer; - - private MessageConsumer profileDataConsumer; - - private MessageConsumer logDataConsumer; - - private MessageConsumer nodeinfoDataConsumer; - - private HealthManagerServerWorker healthServerListenWorker; - - private boolean isStartLifeKeeper = false; - - public HealthManager(String cName, String feature) { - super(cName, feature); - } - - @Override - public void start() { - - // init cache manager - String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr"); - int minConcurrent = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min")); - int maxConcurrent = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max")); - int queueSize = Integer - .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize")); - String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd"); - - CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, - password); - - this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm); - - // start HealthManagerProfileDataLifeKeeper - isStartLifeKeeper = Boolean - .parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable")); - - if (isStartLifeKeeper == true) { - - // init HealthManagerProfileDataLifeKeeper - HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper( - "HealthManagerProfileDataLifeKeeper", this.feature); - - long interval = Long - .parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval")); - - long randomDely = new Random().nextInt(3) + 3; - - this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", - profileDataLifeKeepWorker, randomDely * 1000, interval); - - if (log.isTraceEnable()) { - log.info(this, "HealthManagerProfileDataLifeKeeper started"); - } - } - - /** - * Start the DBStore service NOTE: this must be the first to start - */ - buildDataStores(this.getConfigManager()); - - // start all datastores - DataStoreFactory.getInstance().startAll(this.feature); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore Factory started"); - } - - /** - * Start the HealthManger Http service - */ - int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port")); - int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog")); - int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core")); - int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max")); - int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize")); - - healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, - "healthMangerHandlers"); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue(bqsize)); - - healthServerListenWorker.start(exe, port, backlog); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore HttpServer started"); - } - - StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature); - - try { - smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers"); - } - catch (IOException e) { - log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e); - return; - } - - monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString()); - - notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString()); - - profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString()); - - logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString()); - - nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString()); - - // start monitorDataConsumer - if (monitorDataConsumer != null) { - - monitorDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, - monitorDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager MDFConsumer started"); - } - } - - // start notificationConsumer - if (this.notificationConsumer != null) { - notificationConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, - notificationConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager NotifyConsumer started"); - } - } - - // start profileDataConsumer - if (this.profileDataConsumer != null) { - - /** - * INIT StandardProfileModelingEngine & StandardProfileModeler - */ - IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature); - - new StandardProfileModeler("StandardProfileModeler", feature, engine); - - // start profile consumer - profileDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, - profileDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager ProfileConsumer started"); - } - } - - // start logDataConsumer - if (this.logDataConsumer != null) { - logDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, - logDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager LogConsumer started"); - } - } - - // start nodeinfoDataConsumer - if (nodeinfoDataConsumer != null) { - - nodeinfoDataConsumer.start(); - - this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, - nodeinfoDataConsumer); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager NodeInfoConsumer started"); - } - } - } - - @Override - public void stop() { - - // stop monitorDataConsumer - if (this.monitorDataConsumer != null) { - monitorDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR); - if (log.isTraceEnable()) { - log.info(this, "HealthManager MdfConsumer shutdown"); - } - } - - // stop notificationConsumer - if (this.notificationConsumer != null) { - notificationConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY); - if (log.isTraceEnable()) { - log.info(this, "HealthManager NotifyConsumer shutdown"); - } - } - - // stop profileDataConsumer - if (this.profileDataConsumer != null) { - - // shut down StandardProfileModelingEngine - this.getActionEngineMgr().shutdown("StandardProfileModelingEngine"); - - profileDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE); - if (log.isTraceEnable()) { - log.info(this, "HealthManager ProfileConsumer shutdown"); - } - } - - // stop logDataConsumer - if (this.logDataConsumer != null) { - logDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_LOG); - if (log.isTraceEnable()) { - log.info(this, "HealthManager LogConsumer shutdown"); - } - } - - // stop nodeinfoDataConsumer - if (this.nodeinfoDataConsumer != null) { - nodeinfoDataConsumer.shutdown(); - this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NODE); - if (log.isTraceEnable()) { - log.info(this, "HealthManager NodeInfoConsumer shutdown"); - } - } - // stop healthServerListenWorker - healthServerListenWorker.stop(); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore HttpServer shutdown"); - } - - // NOTE: this should be the last to stop - DataStoreFactory.getInstance().stopAll(this.feature); - - if (log.isTraceEnable()) { - log.info(this, "HealthManager DataStore Factory shutdown"); - } - - if (isStartLifeKeeper == true) { - - // stop HealthManagerProfileDataLifeKeeper - this.getTimerWorkManager().cancel("HealthManagerProfileDataLifeKeeper"); - - if (log.isTraceEnable()) { - log.info(this, "HealthManagerProfileDataLifeKeeper stopped"); - } - } - - // shutdown CacheManager - CacheManager HMCacheManager = (CacheManager) this.getConfigManager().getComponent(this.feature, - "HMCacheManager"); - HMCacheManager.shutdown(); - - super.stop(); - } - - private void buildDataStores(IConfigurationManager icm) { - - // monitor - String monitorKey = MonitorDataFrame.MessageType.Monitor.toString(); - - // profile - String profileKey = MonitorDataFrame.MessageType.Profile.toString(); - - // notification - String notifyKey = MonitorDataFrame.MessageType.Notification.toString(); - - // nodeinfo - String nodeinfoKey = MonitorDataFrame.MessageType.NodeInfo.toString(); - - Map mctx = new HashMap(); - - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxPerRoute"), 10)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxRoute"), 50)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.soTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.connTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.reqTimeout"), 5000)); - - // build monitor ds - buildDataStore(icm, monitorKey, DataStoreType.OPENTSDB, new MonitorDataAdapter(), mctx); - - // build profile ds - buildDataStore(icm, profileKey, DataStoreType.MONGODB, new ProfileDataAdpater(), null); - - // build notify ds - buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null); - - Map nctx = new HashMap(); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, - DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000)); - mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper - .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000)); - - // build nodeinfo ds - buildDataStore(icm, nodeinfoKey, DataStoreType.OPENTSDB, new NodeInfoDataAdapter(), nctx); - - } - - /** - * buildDataStore - * - * @param icm - * @param dsName - * @param type - * @param adaptor - * @param context - */ - private void buildDataStore(IConfigurationManager icm, String dsName, DataStoreType type, DataStoreAdapter adaptor, - Map context) { - - boolean enable = DataConvertHelper.toBoolean(icm.getFeatureConfiguration(this.feature, dsName + ".ds.enable"),false); - - if (enable) { - - String serverlist = icm.getFeatureConfiguration(this.feature, dsName + ".ds.servers"); - - if (serverlist == null) { - log.warn(this, "Config[ds.servers] of DataStore[" + dsName + "] is NULL."); - return; - } - - String dbName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.db"); - - String dbPower = icm.getFeatureConfiguration(this.feature, dsName + ".ds.power"); - - String userName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.usr"); - - String password = icm.getFeatureConfiguration(this.feature, dsName + ".ds.pwd"); - - int retry = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.retry"), 3); - - int expire = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.expire"), 3); - - List servers = DataConvertHelper.toList(serverlist, ","); - - DataStoreConnection conn = new DataStoreConnection(userName, password, dbName, dbPower, servers, type); - - conn.setRetryTimes(retry); - - conn.setBlackExpireTime(expire); - - if (context != null) { - conn.putContextAll(context); - } - - DataStoreFactory.getInstance().build(dsName, conn, adaptor, this.feature); - } - } - - @SuppressWarnings("rawtypes") - @Override - public Object exchange(String eventKey, Object... data) { - - log.info(this, "HM got exchange event"); - - if (null == data) { - log.err(this, "the exchange data is empty"); - return null; - } - DataStoreMsg msg = (DataStoreMsg) data[0]; - - AbstractDataStore dataStore = DataStoreFactory.getInstance() - .get((String) msg.get(DataStoreProtocol.DATASTORE_NAME)); - - Object rst = null; - - switch (eventKey) { - case HealthManagerConstants.QUERY: - - rst = dataStore.doQuery(msg); - return rst; - case HealthManagerConstants.INSERT: - - rst = dataStore.doUpdate(msg); - return rst; - case HealthManagerConstants.UPDATE: - - rst = dataStore.doUpdate(msg); - return rst; - } - throw new RuntimeException("Exchange Event [" + eventKey + "] handle FAIL: data=" + data); - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.uavstack.resources.common.messaging.StandardMessagingBuilder; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.monitor.api.MonitorDataFrame; +import com.creditease.agent.profile.api.StandardProfileModeler; +import com.creditease.agent.spi.AgentFeatureComponent; +import com.creditease.agent.spi.IActionEngine; +import com.creditease.agent.spi.IConfigurationManager; +import com.creditease.uav.cache.api.CacheManager; +import com.creditease.uav.cache.api.CacheManagerFactory; +import com.creditease.uav.datastore.api.DataStoreAdapter; +import com.creditease.uav.datastore.api.DataStoreConnection; +import com.creditease.uav.datastore.api.DataStoreFactory; +import com.creditease.uav.datastore.api.DataStoreFactory.DataStoreType; +import com.creditease.uav.datastore.api.DataStoreMsg; +import com.creditease.uav.datastore.api.DataStoreProtocol; +import com.creditease.uav.datastore.core.AbstractDataStore; +import com.creditease.uav.feature.healthmanager.HealthManagerConstants; +import com.creditease.uav.feature.healthmanager.HealthManagerProfileDataLifeKeeper; +import com.creditease.uav.feature.healthmanager.HealthManagerServerWorker; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater; +import com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater; +import com.creditease.uav.messaging.api.MessageConsumer; + +public class HealthManager extends AgentFeatureComponent { + + private MessageConsumer monitorDataConsumer; + + private MessageConsumer notificationConsumer; + + private MessageConsumer profileDataConsumer; + + private MessageConsumer logDataConsumer; + + private MessageConsumer nodeinfoDataConsumer; + + private HealthManagerServerWorker healthServerListenWorker; + + private boolean isStartLifeKeeper = false; + + public HealthManager(String cName, String feature) { + super(cName, feature); + } + + @Override + public void start() { + + // init cache manager + String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr"); + int minConcurrent = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min")); + int maxConcurrent = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max")); + int queueSize = Integer + .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize")); + String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd"); + + CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, + password); + + this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm); + + // start HealthManagerProfileDataLifeKeeper + isStartLifeKeeper = Boolean + .parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable")); + + if (isStartLifeKeeper == true) { + + // init HealthManagerProfileDataLifeKeeper + HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper( + "HealthManagerProfileDataLifeKeeper", this.feature); + + long interval = Long + .parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval")); + + long randomDely = new Random().nextInt(3) + 3; + + this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", + profileDataLifeKeepWorker, randomDely * 1000, interval); + + if (log.isTraceEnable()) { + log.info(this, "HealthManagerProfileDataLifeKeeper started"); + } + } + + /** + * Start the DBStore service NOTE: this must be the first to start + */ + buildDataStores(this.getConfigManager()); + + // start all datastores + DataStoreFactory.getInstance().startAll(this.feature); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore Factory started"); + } + + /** + * Start the HealthManger Http service + */ + int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port")); + int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog")); + int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core")); + int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max")); + int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize")); + + healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, + "healthMangerHandlers"); + + @SuppressWarnings({ "rawtypes", "unchecked" }) + ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, + new ArrayBlockingQueue(bqsize)); + + healthServerListenWorker.start(exe, port, backlog); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore HttpServer started"); + } + + StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature); + + try { + smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers"); + } + catch (IOException e) { + log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e); + return; + } + + monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString()); + + notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString()); + + profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString()); + + logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString()); + + nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString()); + + // start monitorDataConsumer + if (monitorDataConsumer != null) { + + monitorDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, + monitorDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager MDFConsumer started"); + } + } + + // start notificationConsumer + if (this.notificationConsumer != null) { + notificationConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, + notificationConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager NotifyConsumer started"); + } + } + + // start profileDataConsumer + if (this.profileDataConsumer != null) { + + /** + * INIT StandardProfileModelingEngine & StandardProfileModeler + */ + IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature); + + new StandardProfileModeler("StandardProfileModeler", feature, engine); + + // start profile consumer + profileDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, + profileDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager ProfileConsumer started"); + } + } + + // start logDataConsumer + if (this.logDataConsumer != null) { + logDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, + logDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager LogConsumer started"); + } + } + + // start nodeinfoDataConsumer + if (nodeinfoDataConsumer != null) { + + nodeinfoDataConsumer.start(); + + this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, + nodeinfoDataConsumer); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager NodeInfoConsumer started"); + } + } + } + + @Override + public void stop() { + + // stop monitorDataConsumer + if (this.monitorDataConsumer != null) { + monitorDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR); + if (log.isTraceEnable()) { + log.info(this, "HealthManager MdfConsumer shutdown"); + } + } + + // stop notificationConsumer + if (this.notificationConsumer != null) { + notificationConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY); + if (log.isTraceEnable()) { + log.info(this, "HealthManager NotifyConsumer shutdown"); + } + } + + // stop profileDataConsumer + if (this.profileDataConsumer != null) { + + // shut down StandardProfileModelingEngine + this.getActionEngineMgr().shutdown("StandardProfileModelingEngine"); + + profileDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE); + if (log.isTraceEnable()) { + log.info(this, "HealthManager ProfileConsumer shutdown"); + } + } + + // stop logDataConsumer + if (this.logDataConsumer != null) { + logDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_LOG); + if (log.isTraceEnable()) { + log.info(this, "HealthManager LogConsumer shutdown"); + } + } + + // stop nodeinfoDataConsumer + if (this.nodeinfoDataConsumer != null) { + nodeinfoDataConsumer.shutdown(); + this.getConfigManager().unregisterComponent(this.feature, HealthManagerConstants.COMSUMER_NODE); + if (log.isTraceEnable()) { + log.info(this, "HealthManager NodeInfoConsumer shutdown"); + } + } + // stop healthServerListenWorker + healthServerListenWorker.stop(); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore HttpServer shutdown"); + } + + // NOTE: this should be the last to stop + DataStoreFactory.getInstance().stopAll(this.feature); + + if (log.isTraceEnable()) { + log.info(this, "HealthManager DataStore Factory shutdown"); + } + + if (isStartLifeKeeper == true) { + + // stop HealthManagerProfileDataLifeKeeper + this.getTimerWorkManager().cancel("HealthManagerProfileDataLifeKeeper"); + + if (log.isTraceEnable()) { + log.info(this, "HealthManagerProfileDataLifeKeeper stopped"); + } + } + + // shutdown CacheManager + CacheManager HMCacheManager = (CacheManager) this.getConfigManager().getComponent(this.feature, + "HMCacheManager"); + HMCacheManager.shutdown(); + + super.stop(); + } + + private void buildDataStores(IConfigurationManager icm) { + + // log + String logKey = MonitorDataFrame.MessageType.Log.toString(); + // monitor + String monitorKey = MonitorDataFrame.MessageType.Monitor.toString(); + + // profile + String profileKey = MonitorDataFrame.MessageType.Profile.toString(); + + // notification + String notifyKey = MonitorDataFrame.MessageType.Notification.toString(); + + // nodeinfo + String nodeinfoKey = MonitorDataFrame.MessageType.NodeInfo.toString(); + + String caching = icm.getFeatureConfiguration(this.feature, logKey + ".ds.cache"); + String maxResultSize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.maxResultSize"); + String reverse = icm.getFeatureConfiguration(this.feature, logKey + ".ds.reverse"); + String psize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.pagesize"); + + Map lctx = new HashMap(); + lctx.put(DataStoreProtocol.HBASE_QUERY_CACHING, caching); + lctx.put(DataStoreProtocol.HBASE_QUERY_MAXRESULTSIZE, maxResultSize); + lctx.put(DataStoreProtocol.HBASE_QUERY_REVERSE, DataConvertHelper.toBoolean(Boolean.valueOf(reverse), true)); + lctx.put(DataStoreProtocol.HBASE_QUERY_PAGESIZE, DataConvertHelper.toLong(Long.valueOf(psize), 3000)); + // build log ds + buildDataStore(icm, logKey, DataStoreType.HBASE, new LogDataAdapter(), lctx); + + Map mctx = new HashMap(); + + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxPerRoute"), 10)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxRoute"), 50)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.soTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.connTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.reqTimeout"), 5000)); + + // build monitor ds + buildDataStore(icm, monitorKey, DataStoreType.OPENTSDB, new MonitorDataAdapter(), mctx); + + // build profile ds + buildDataStore(icm, profileKey, DataStoreType.MONGODB, new ProfileDataAdpater(), null); + + // build notify ds + buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null); + + Map nctx = new HashMap(); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, + DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000)); + mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper + .toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000)); + + // build nodeinfo ds + buildDataStore(icm, nodeinfoKey, DataStoreType.OPENTSDB, new NodeInfoDataAdapter(), nctx); + + } + + /** + * buildDataStore + * + * @param icm + * @param dsName + * @param type + * @param adaptor + * @param context + */ + private void buildDataStore(IConfigurationManager icm, String dsName, DataStoreType type, DataStoreAdapter adaptor, + Map context) { + + boolean enable = false; + + enable = Boolean.parseBoolean(icm.getFeatureConfiguration(this.feature, dsName + ".ds.enable")); + + if (enable) { + + String serverlist = icm.getFeatureConfiguration(this.feature, dsName + ".ds.servers"); + + if (serverlist == null) { + log.warn(this, "Config[ds.servers] of DataStore[" + dsName + "] is NULL."); + return; + } + + String dbName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.db"); + + String dbPower = icm.getFeatureConfiguration(this.feature, dsName + ".ds.power"); + + String userName = icm.getFeatureConfiguration(this.feature, dsName + ".ds.usr"); + + String password = icm.getFeatureConfiguration(this.feature, dsName + ".ds.pwd"); + + int retry = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.retry"), 3); + + int expire = DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, dsName + ".ds.expire"), 3); + + List servers = DataConvertHelper.toList(serverlist, ","); + + DataStoreConnection conn = new DataStoreConnection(userName, password, dbName, dbPower, servers, type); + + conn.setRetryTimes(retry); + + conn.setBlackExpireTime(expire); + + if (context != null) { + conn.putContextAll(context); + } + + DataStoreFactory.getInstance().build(dsName, conn, adaptor, this.feature); + } + } + + @SuppressWarnings("rawtypes") + @Override + public Object exchange(String eventKey, Object... data) { + + log.info(this, "HM got exchange event"); + + if (null == data) { + log.err(this, "the exchange data is empty"); + return null; + } + DataStoreMsg msg = (DataStoreMsg) data[0]; + + AbstractDataStore dataStore = DataStoreFactory.getInstance() + .get((String) msg.get(DataStoreProtocol.DATASTORE_NAME)); + + Object rst = null; + + switch (eventKey) { + case HealthManagerConstants.QUERY: + + rst = dataStore.doQuery(msg); + return rst; + case HealthManagerConstants.INSERT: + + rst = dataStore.doUpdate(msg); + return rst; + case HealthManagerConstants.UPDATE: + + rst = dataStore.doUpdate(msg); + return rst; + } + throw new RuntimeException("Exchange Event [" + eventKey + "] handle FAIL: data=" + data); + } +} diff --git a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java index 3fc02d5f..f1b80e85 100644 --- a/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java +++ b/com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor/SpringBootTomcatPlusIT.java @@ -49,9 +49,9 @@ public class SpringBootTomcatPlusIT extends TomcatPlusIT { */ public void startServer(String port, String contextPath, String appName, Object arg) { - if (!"AnnotationConfigEmbeddedWebApplicationContext".equals(arg.getClass().getSimpleName())) { + if(!isWebServerContext(arg)) { return; - } + } // integrate Tomcat log UAVServer.instance().setLog(new TomcatLog("MonitorServer")); From 94ffc9d4f25825c1b8484decc5e4784fbb9f98fc Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Tue, 6 Feb 2018 14:20:52 +0800 Subject: [PATCH 10/97] https://github.com/uavorg/uavstack/issues/184 install mof fail:modify CATALINA_OPTS failed --- .../feature/nodeopagent/actions/MOFInstallMgtAction.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFInstallMgtAction.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFInstallMgtAction.java index ea46d723..f3760cc8 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFInstallMgtAction.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/actions/MOFInstallMgtAction.java @@ -20,6 +20,7 @@ package com.creditease.agent.feature.nodeopagent.actions; +import java.io.File; import java.util.LinkedList; import java.util.List; @@ -192,6 +193,14 @@ private void installMOFforTomcat(String shellParentPath, String agentArgs) throw for (String filePath : filePaths) { + if (!IOHelper.exists(filePath)) { + try { + new File(filePath).createNewFile(); + } + catch (Exception e) { + log.err(this, "UNInstall UAVMOF FAIL:filePath=" + filePath + " not exits and create file fail", e); + } + } String content = IOHelper.readTxtFile(filePath, "UTF-8"); String[] lines = content.split("\n"); From 6080a67a1330c497081824b938e0e51e5e700ddf Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 8 Feb 2018 19:06:08 +0800 Subject: [PATCH 11/97] https://github.com/uavorg/uavstack/issues/186 #186 refine HM's microservice deploy properties&&fix http-invoke failed problem --- .../config/ma_pro.properties | 344 +++++----- .../config/ma_test.properties | 342 +++++----- .../config/hm_pro_apmserver.properties | 16 +- .../config/hm_pro_apphubmgr.properties | 35 +- .../config/hm_pro_hbserver.properties | 16 +- .../config/hm_pro_logserver.properties | 314 +++------ .../config/hm_pro_moserver.properties | 30 +- .../config/hm_pro_nodeserver.properties | 22 +- .../config/hm_pro_pfntfyserver.properties | 431 ++++++------ .../config/hm_pro_rtserver.properties | 12 +- .../config/hm_test_apmserver.properties | 16 +- .../config/hm_test_logserver.properties | 318 +++------ .../config/hm_test_moserver.properties | 324 ++++----- .../config/hm_test_nodeserver.properties | 336 +++++----- .../config/hm_test_pnhbserver.properties | 633 +++++++++--------- .../config/hm_test_rtserver.properties | 12 +- .../config/upgrade_pro.properties | 92 +-- .../config/upgrade_server.properties | 112 ++-- .../config/upgrade_server_pro.properties | 112 ++-- .../config/upgrade_server_test.properties | 112 ++-- .../config/upgrade_test.properties | 92 +-- 21 files changed, 1763 insertions(+), 1958 deletions(-) diff --git a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties index edea2c33..286afbf9 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties @@ -1,172 +1,172 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= -log.path= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 -#message size limit. unit is Byte -resource.messageproducer.messagesizelimit=262000 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10101 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.monitoragent.loader=default -#feature.xxx.enable should enable this feature -feature.monitoragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.monitoragent.properties= -#feature.xxx. -#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes -feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler -#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes -feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler -#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes -feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler -#app server keep alive -feature.monitoragent.keepalive.enable=false -#mdf listen server -feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler -feature.monitoragent.http.port=9111 -feature.monitoragent.http.backlog=10 -feature.monitoragent.http.core=10 -feature.monitoragent.http.max=50 -feature.monitoragent.http.bqsize=1 -feature.monitoragent.http.enable=false -#monitoragent jvm filters -feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient -#monitoragent detect interval default is 30000 -feature.monitoragent.detector.interval=30000 -#enable local scan by jvm tool and jmx -feature.monitoragent.detector.local.scan.enable=true -#enable container scan by http -feature.monitoragent.detector.container.scan.enable=false -#container ports -feature.monitoragent.detector.container.ports= -#monitoragent detect interval default is 15000 -feature.monitoragent.monitor.interval=15000 -#agent process limitation for exit -#default memory limit is 300M -feature.monitoragent.limit.mem=300000 -#default cpu limit is over 30% during 120 seconds -feature.monitoragent.limit.cpu.value=30 -feature.monitoragent.limit.cpu.timerange=120000 - -#Log Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.logagent.loader=default -#feature.xxx.enable should enable this feature -feature.logagent.enable=true -#feature.xxx.enable should enable the self Log collection feature -feature.logagent.selfLog.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.logagent.components=com.creditease.agent.feature.LogAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.logagent.properties= -#log pos file root -feature.logagent.posfileroot=./ -#catch log interval (ms) -feature.logagent.LogDataFrame.enable=false -feature.logagent.interval=2000 -feature.logagent.MutiThread.enable=true -feature.logagent.MutiThread.thread.max=2 -#default filter -feature.logagent.defrule.filter= - -#Proc Detect Agent Feature -feature.procscan.loader=default -feature.procscan.enable=true -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 -feature.procscan.networkDetect.interval=15000 -feature.procscan.networkDetect.collectTime=2000 - -# Process Watch Feature -feature.procwatch.loader=default -feature.procwatch.enable=true -feature.procwatch.interval=15000 -feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent - -# Data Collect Feature -feature.collectclient.loader=default -feature.collectclient.enable=true -feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent -feature.collectclient.properties= -feature.collectclient.readlinesize=100 -feature.collectclient.MutiThread.enable=true -feature.collectclient.MutiThread.thread.max=2 -feature.collectclient.interval=2000 -feature.collectclient.writeposdelay=5000 -feature.collectclient.writeposinterval=3000 -feature.collectclient.idlecheckerdelay=12000 -feature.collectclient.idlecheckerinterval=5000 -# Thread Analysis Feature -feature.threadanalysis.loader=default -feature.threadanalysis.enable=true -feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= +log.path= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 +#message size limit. unit is Byte +resource.messageproducer.messagesizelimit=262000 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10101 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.monitoragent.loader=default +#feature.xxx.enable should enable this feature +feature.monitoragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.monitoragent.properties= +#feature.xxx. +#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes +feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler +#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes +feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler +#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes +feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler +#app server keep alive +feature.monitoragent.keepalive.enable=false +#mdf listen server +feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler +feature.monitoragent.http.port=9111 +feature.monitoragent.http.backlog=10 +feature.monitoragent.http.core=10 +feature.monitoragent.http.max=50 +feature.monitoragent.http.bqsize=1 +feature.monitoragent.http.enable=false +#monitoragent jvm filters +feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient +#monitoragent detect interval default is 30000 +feature.monitoragent.detector.interval=30000 +#enable local scan by jvm tool and jmx +feature.monitoragent.detector.local.scan.enable=true +#enable container scan by http +feature.monitoragent.detector.container.scan.enable=false +#container ports +feature.monitoragent.detector.container.ports= +#monitoragent detect interval default is 15000 +feature.monitoragent.monitor.interval=15000 +#agent process limitation for exit +#default memory limit is 300M +feature.monitoragent.limit.mem=300000 +#default cpu limit is over 30% during 120 seconds +feature.monitoragent.limit.cpu.value=30 +feature.monitoragent.limit.cpu.timerange=120000 + +#Log Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.logagent.loader=default +#feature.xxx.enable should enable this feature +feature.logagent.enable=true +#feature.xxx.enable should enable the self Log collection feature +feature.logagent.selfLog.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.logagent.components=com.creditease.agent.feature.LogAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.logagent.properties= +#log pos file root +feature.logagent.posfileroot=./ +#catch log interval (ms) +feature.logagent.LogDataFrame.enable=false +feature.logagent.interval=2000 +feature.logagent.MutiThread.enable=true +feature.logagent.MutiThread.thread.max=2 +#default filter +feature.logagent.defrule.filter= + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=true +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 +feature.procscan.networkDetect.interval=15000 +feature.procscan.networkDetect.collectTime=2000 + +# Process Watch Feature +feature.procwatch.loader=default +feature.procwatch.enable=true +feature.procwatch.interval=15000 +feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent + +# Data Collect Feature +feature.collectclient.loader=default +feature.collectclient.enable=true +feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent +feature.collectclient.properties= +feature.collectclient.readlinesize=100 +feature.collectclient.MutiThread.enable=true +feature.collectclient.MutiThread.thread.max=2 +feature.collectclient.interval=2000 +feature.collectclient.writeposdelay=5000 +feature.collectclient.writeposinterval=3000 +feature.collectclient.idlecheckerdelay=12000 +feature.collectclient.idlecheckerinterval=5000 +# Thread Analysis Feature +feature.threadanalysis.loader=default +feature.threadanalysis.enable=true +feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent diff --git a/com.creditease.uav.agent.buildComponent/config/ma_test.properties b/com.creditease.uav.agent.buildComponent/config/ma_test.properties index 26fbb398..853823b1 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_test.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_test.properties @@ -1,172 +1,172 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= -log.path= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 -#message size limit. unit is Byte -resource.messageproducer.messagesizelimit=262000 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10101 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.monitoragent.loader=default -#feature.xxx.enable should enable this feature -feature.monitoragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.monitoragent.properties= -#feature.xxx. -#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes -feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler -#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes -feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler -#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes -feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler -#app server keep alive -feature.monitoragent.keepalive.enable=false -#mdf listen server -feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler -feature.monitoragent.http.port=8099 -feature.monitoragent.http.backlog=10 -feature.monitoragent.http.core=10 -feature.monitoragent.http.max=50 -feature.monitoragent.http.bqsize=1 -feature.monitoragent.http.enable=false -#monitoragent jvm filters -feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient -#monitoragent detect interval default is 30000 -feature.monitoragent.detector.interval=30000 -#enable local scan by jvm tool and jmx -feature.monitoragent.detector.local.scan.enable=true -#enable container scan by http -feature.monitoragent.detector.container.scan.enable=false -#container ports -feature.monitoragent.detector.container.ports= -#monitoragent detect interval default is 15000 -feature.monitoragent.monitor.interval=15000 -#agent process limitation for exit -#default memory limit is 300M -feature.monitoragent.limit.mem=300000 -#default cpu limit is over 30% during 120 seconds -feature.monitoragent.limit.cpu.value=30 -feature.monitoragent.limit.cpu.timerange=120000 - -#Log Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.logagent.loader=default -#feature.xxx.enable should enable this feature -feature.logagent.enable=true -#feature.xxx.enable should enable the self Log collection feature -feature.logagent.selfLog.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.logagent.components=com.creditease.agent.feature.LogAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.logagent.properties= -#log pos file root -feature.logagent.posfileroot=./ -#catch log interval (ms) -feature.logagent.LogDataFrame.enable=false -feature.logagent.interval=2000 -feature.logagent.MutiThread.enable=true -feature.logagent.MutiThread.thread.max=2 -#default filter -feature.logagent.defrule.filter= - -#Proc Detect Agent Feature -feature.procscan.loader=default -feature.procscan.enable=true -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 -feature.procscan.networkDetect.interval=15000 -feature.procscan.networkDetect.collectTime=2000 - -# Process Watch Feature -feature.procwatch.loader=default -feature.procwatch.enable=true -feature.procwatch.interval=15000 -feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent - -# Data Collect Feature -feature.collectclient.loader=default -feature.collectclient.enable=true -feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent -feature.collectclient.properties= -feature.collectclient.readlinesize=100 -feature.collectclient.MutiThread.enable=true -feature.collectclient.MutiThread.thread.max=2 -feature.collectclient.interval=2000 -feature.collectclient.writeposdelay=5000 -feature.collectclient.writeposinterval=3000 -feature.collectclient.idlecheckerdelay=12000 -feature.collectclient.idlecheckerinterval=5000 -# Thread Analysis Feature -feature.threadanalysis.loader=default -feature.threadanalysis.enable=true +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= +log.path= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 +#message size limit. unit is Byte +resource.messageproducer.messagesizelimit=262000 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10101 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.monitoragent.loader=default +#feature.xxx.enable should enable this feature +feature.monitoragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.monitoragent.properties= +#feature.xxx. +#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes +feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler +#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes +feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler +#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes +feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler +#app server keep alive +feature.monitoragent.keepalive.enable=false +#mdf listen server +feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler +feature.monitoragent.http.port=8099 +feature.monitoragent.http.backlog=10 +feature.monitoragent.http.core=10 +feature.monitoragent.http.max=50 +feature.monitoragent.http.bqsize=1 +feature.monitoragent.http.enable=false +#monitoragent jvm filters +feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient +#monitoragent detect interval default is 30000 +feature.monitoragent.detector.interval=30000 +#enable local scan by jvm tool and jmx +feature.monitoragent.detector.local.scan.enable=true +#enable container scan by http +feature.monitoragent.detector.container.scan.enable=false +#container ports +feature.monitoragent.detector.container.ports= +#monitoragent detect interval default is 15000 +feature.monitoragent.monitor.interval=15000 +#agent process limitation for exit +#default memory limit is 300M +feature.monitoragent.limit.mem=300000 +#default cpu limit is over 30% during 120 seconds +feature.monitoragent.limit.cpu.value=30 +feature.monitoragent.limit.cpu.timerange=120000 + +#Log Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.logagent.loader=default +#feature.xxx.enable should enable this feature +feature.logagent.enable=true +#feature.xxx.enable should enable the self Log collection feature +feature.logagent.selfLog.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.logagent.components=com.creditease.agent.feature.LogAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.logagent.properties= +#log pos file root +feature.logagent.posfileroot=./ +#catch log interval (ms) +feature.logagent.LogDataFrame.enable=false +feature.logagent.interval=2000 +feature.logagent.MutiThread.enable=true +feature.logagent.MutiThread.thread.max=2 +#default filter +feature.logagent.defrule.filter= + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=true +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 +feature.procscan.networkDetect.interval=15000 +feature.procscan.networkDetect.collectTime=2000 + +# Process Watch Feature +feature.procwatch.loader=default +feature.procwatch.enable=true +feature.procwatch.interval=15000 +feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent + +# Data Collect Feature +feature.collectclient.loader=default +feature.collectclient.enable=true +feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent +feature.collectclient.properties= +feature.collectclient.readlinesize=100 +feature.collectclient.MutiThread.enable=true +feature.collectclient.MutiThread.thread.max=2 +feature.collectclient.interval=2000 +feature.collectclient.writeposdelay=5000 +feature.collectclient.writeposinterval=3000 +feature.collectclient.idlecheckerdelay=12000 +feature.collectclient.idlecheckerinterval=5000 +# Thread Analysis Feature +feature.threadanalysis.loader=default +feature.threadanalysis.enable=true feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties index a138079c..03eef29c 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10146 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- # Data Collect Feature -feature.collectserver.loader=default +feature.collectserver.loader=com.creditease.uav.collect.jar feature.collectserver.enable=true feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager feature.collectserver.properties= @@ -96,7 +96,7 @@ feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true #InvokeChain Process Server Feature -feature.invokechainserver.loader=default +feature.invokechainserver.loader=com.creditease.uav.invokechain.jar feature.invokechainserver.enable=true feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer feature.invokechainserver.properties= @@ -121,7 +121,7 @@ feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeCh #Thread Analysis Server Feature -feature.threadanalysisserver.loader=default +feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar feature.threadanalysisserver.enable=true feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer #elastic-search diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties index 8be6816a..c73f45ed 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apphubmgr.properties @@ -15,7 +15,7 @@ meta.nodetype=AppHub\u7BA1\u7406\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10120 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -69,7 +69,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- #feature apphubmanager BEGIN------------------------------------------------------------------ -feature.apphubmanager.loader=default +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar feature.apphubmanager.enable=true feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler @@ -89,7 +89,7 @@ feature.apphubmanager.ds.pwd= #HealthManager------------------------------------------------------------------ #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -146,7 +146,7 @@ feature.healthmanager.MT_Notify.ds.power=notifyDataStore feature.healthmanager.MT_Notify.ds.usr= feature.healthmanager.MT_Notify.ds.pwd= -#feature.DBSource.OpenTSDB +#feature.DBSource.OpenTSDB4Monitor feature.healthmanager.MT_Monitor.ds.enable=true feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore @@ -163,7 +163,7 @@ feature.healthmanager.MT_Monitor.ds.expire=30000 feature.healthmanager.MT_Monitor.ds.cachetime=5 #feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.enable=false feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 feature.healthmanager.MT_Log.ds.db=logDataStore feature.healthmanager.MT_Log.ds.cache=1000 @@ -171,10 +171,23 @@ feature.healthmanager.MT_Log.ds.maxResultSize=2097152 feature.healthmanager.MT_Log.ds.reverse=true feature.healthmanager.MT_Log.ds.pagesize=3000 +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 #-------------------------------HBServer Query-------------------------- #heartbeatserveragent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbserveragent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -207,7 +220,7 @@ feature.hbserveragent.lifekeeper.nodetimeout=30000 #-------------------------------------------RUNTIME NOTIFY Strategy Update------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties index fe53e907..bd138491 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_hbserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5FC3\u8DF3\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10110 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -70,7 +70,7 @@ feature.hbclientagent.interval=15000 #-----------------------------COMMON FEATURES END--------------------------------------------------- #Proc Detect Agent Feature -feature.procscan.loader=default +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar feature.procscan.enable=false feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent feature.procscan.properties= @@ -79,7 +79,7 @@ feature.procscan.scan.interval=15000 #heartbeatserveragent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbserveragent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -114,7 +114,7 @@ feature.hbserveragent.ntp.enable=false #-------------------------------------------RUNTIME NOTIFY------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties index b266eabd..c91bdc81 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties @@ -1,223 +1,93 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10130 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=5 -feature.healthmanager.MT_Notify.consumethreadmax=5 -feature.healthmanager.MT_Profile.consumethreadmax=5 -feature.healthmanager.MT_Log.consumethreadmax=20 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=5 -feature.healthmanager.store.concurrent.max=10 -feature.healthmanager.store.concurrent.bqsize=20 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-------------------------------------------RUNTIME NOTIFY------------------------------------------- -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=false -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:26379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.storecm.server=127.0.0.1:26379 -feature.runtimenotify.storecm.minsize=30 -feature.runtimenotify.storecm.maxsize=60 -feature.runtimenotify.storecm.qsize=20 -#qworker -feature.runtimenotify.qworker.coresize=20 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=20 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=10 -feature.runtimenotify.http.max=50 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"600000","expire":"0"}} - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=default -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=edp-es -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=50 -feature.newlogservice.http.max=300 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10130 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=edp-es +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=50 +feature.newlogservice.http.max=300 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties index bd06ec0d..00651607 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_moserver.properties @@ -16,7 +16,7 @@ meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -25,7 +25,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -34,14 +34,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10140 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -56,7 +56,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #HealthManager #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -128,7 +128,7 @@ feature.healthmanager.MT_Notify.ds.power=notifyDataStore feature.healthmanager.MT_Notify.ds.usr= feature.healthmanager.MT_Notify.ds.pwd= -#feature.DBSource.OpenTSDB +#feature.DBSource.OpenTSDB4Monitor feature.healthmanager.MT_Monitor.ds.enable=true feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore @@ -145,10 +145,24 @@ feature.healthmanager.MT_Monitor.ds.expire=30000 feature.healthmanager.MT_Monitor.ds.cachetime=5 #feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.enable=false feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 feature.healthmanager.MT_Log.ds.db=logDataStore feature.healthmanager.MT_Log.ds.cache=1000 feature.healthmanager.MT_Log.ds.maxResultSize=2097152 feature.healthmanager.MT_Log.ds.reverse=true feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties index fde2b44e..f8fa024d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_nodeserver.properties @@ -16,7 +16,7 @@ meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -25,7 +25,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -34,14 +34,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10145 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -56,7 +56,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -71,7 +71,7 @@ feature.hbclientagent.interval=15000 #HealthManager #feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar #feature.xxx.enable should enable this feature feature.healthmanager.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -113,7 +113,7 @@ feature.healthmanager.store.concurrent.bqsize=5 feature.healthmanager.store.concurrent.pwd= #feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=false +feature.healthmanager.MT_Profile.ds.enable=true feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 feature.healthmanager.MT_Profile.ds.db=profileDataStore feature.healthmanager.MT_Profile.ds.power=profileDataStore @@ -121,15 +121,15 @@ feature.healthmanager.MT_Profile.ds.usr= feature.healthmanager.MT_Profile.ds.pwd= #feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=false +feature.healthmanager.MT_Notify.ds.enable=true feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 feature.healthmanager.MT_Notify.ds.db=notifyDataStore feature.healthmanager.MT_Notify.ds.power=notifyDataStore feature.healthmanager.MT_Notify.ds.usr= feature.healthmanager.MT_Notify.ds.pwd= -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=false +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore feature.healthmanager.MT_Monitor.ds.maxPerRoute=100 @@ -153,7 +153,7 @@ feature.healthmanager.MT_Log.ds.maxResultSize=2097152 feature.healthmanager.MT_Log.ds.reverse=true feature.healthmanager.MT_Log.ds.pagesize=3000 -#feature.DBSource.OpenTSDB +#feature.DBSource.OpenTSDB4Node feature.healthmanager.MT_Node.ds.enable=true feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 feature.healthmanager.MT_Node.ds.db=nodeDataStore diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties index 50edb9de..f461b026 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties @@ -1,209 +1,222 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10150 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=15 -feature.healthmanager.MT_Profile.consumethreadmax=25 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=150 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#-----------------------------NOTIFICATION CENTER--------------------------------------------------- - -#notifcenter -feature.notifycenter.loader=default -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=50 -feature.notifycenter.inqw.bQueueSize=5 -feature.notifycenter.inqw.keepAliveTimeout=30000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:26379 -feature.notifycenter.nc.cache.concurrent.min=30 -feature.notifycenter.nc.cache.concurrent.max=100 -feature.notifycenter.nc.cache.concurrent.bqsize=5 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=30 -feature.notifycenter.http.max=150 -feature.notifycenter.http.bqsize=5 -#push to other services -feature.notifycenter.push.services= - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10150 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=15 +feature.healthmanager.MT_Profile.consumethreadmax=25 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=20 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=150 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 +#-----------------------------NOTIFICATION CENTER--------------------------------------------------- + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=50 +feature.notifycenter.inqw.bQueueSize=5 +feature.notifycenter.inqw.keepAliveTimeout=30000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:26379 +feature.notifycenter.nc.cache.concurrent.min=30 +feature.notifycenter.nc.cache.concurrent.max=100 +feature.notifycenter.nc.cache.concurrent.bqsize=5 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=30 +feature.notifycenter.http.max=150 +feature.notifycenter.http.bqsize=5 +#push to other services +feature.notifycenter.push.services= + diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties index c6f567c7..91dfa36a 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties @@ -15,7 +15,7 @@ meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 #-----------------------------COMMON FEATURES START--------------------------------------------------- #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -24,7 +24,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -33,14 +33,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10140 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -55,7 +55,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -70,7 +70,7 @@ feature.hbclientagent.interval=15000 #-------------------------------------------RUNTIME NOTIFY------------------------------------------- #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties index f3acf99c..d88227d9 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties @@ -14,7 +14,7 @@ meta.nodetype=\u5E94\u7528\u6027\u80FD\u7BA1\u7406\u670D\u52A1 #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -23,7 +23,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -32,14 +32,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10116 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -54,7 +54,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -68,7 +68,7 @@ feature.hbclientagent.interval=15000 #----------------------------------------------------------------------------------------------------- # Data Collect Feature -feature.collectserver.loader=default +feature.collectserver.loader=com.creditease.uav.collect.jar feature.collectserver.enable=true feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager feature.collectserver.properties= @@ -95,7 +95,7 @@ feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true #InvokeChain Process Server Feature -feature.invokechainserver.loader=default +feature.invokechainserver.loader=com.creditease.uav.invokechain.jar feature.invokechainserver.enable=true feature.invokechainserver.components=com.creditease.uav.invokechain.InvokeChainProcessServer feature.invokechainserver.properties= @@ -120,7 +120,7 @@ feature.invokechainserver.qhandlers=com.creditease.uav.invokechain.http.InvokeCh #Thread Analysis Server Feature -feature.threadanalysisserver.loader=default +feature.threadanalysisserver.loader=com.creditease.uav.threadanalysis.jar feature.threadanalysisserver.enable=true feature.threadanalysisserver.components=com.creditease.uav.threadanalysis.server.ThreadAnalysisServer #elastic-search diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties index c0950810..1bad7383 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties @@ -1,226 +1,94 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10111 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=5 -feature.healthmanager.MT_Notify.consumethreadmax=5 -feature.healthmanager.MT_Profile.consumethreadmax=5 -feature.healthmanager.MT_Log.consumethreadmax=20 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=true -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8042 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=10 -feature.healthmanager.store.concurrent.max=20 -feature.healthmanager.store.concurrent.bqsize=10 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=false -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=100 -feature.runtimenotify.storecm.maxsize=300 -feature.runtimenotify.storecm.qsize=5 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=false -feature.runtimenotify.nodeinfotimer.period=15000 -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9002 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms -feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} - - -#HealthManager NewLogService Feature -feature.newlogservice.loader=default -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=uav-es5.4.1 -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=30 -feature.newlogservice.http.max=200 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10111 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=uav-es5.4.1 +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=30 +feature.newlogservice.http.max=200 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties index 92efa704..84b9e5ad 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties @@ -1,155 +1,169 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10112 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=35 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 \ No newline at end of file +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10112 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=35 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties index 7337af99..bcb47b91 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties @@ -1,169 +1,169 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10115 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=false -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=false -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=false -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10115 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8044 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties index 7764a0e6..cbbd3d29 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties @@ -1,311 +1,324 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=default -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=default -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:26000 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#notifcenter -feature.notifycenter.loader=default -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=20 -feature.notifycenter.inqw.bQueueSize=50 -feature.notifycenter.inqw.keepAliveTimeout=60000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services= - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=default -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=100 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=200 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=true -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#------------------------------------------------------------------------------------------------- - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=default -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=default -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=40 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=10 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:26000 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=20 +feature.notifycenter.inqw.bQueueSize=50 +feature.notifycenter.inqw.keepAliveTimeout=60000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services= + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8041 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=100 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=200 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 +#------------------------------------------------------------------------------------------------- + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=40 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=10 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9001 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties index 1a6e7659..d63a7584 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_rtserver.properties @@ -14,7 +14,7 @@ meta.nodetype=\u5B9E\u65F6\u9884\u8B66\u670D\u52A1 #resource components #resource.xxxx -resource.messageproducer.class=com.creditease.agent.feature.common.MessageProducerResourceComponent +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent #resource.xxxx.properties, for example: =,=,... resource.messageproducer.properties= #resource.xxxx. @@ -23,7 +23,7 @@ resource.messageproducer.messagingnameserver=127.0.0.1:9876 resource.messageproducer.messagingthreshold=30 #System Http Invoker -resource.httpinvoke.class=com.creditease.agent.feature.common.HttpInvokerResourceComponent +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent resource.httpinvoke.properties= resource.httpinvoke.http.client.maxperroute=20 resource.httpinvoke.http.client.maxtotal=100 @@ -32,14 +32,14 @@ resource.httpinvoke.http.client.conntimeout=10000 resource.httpinvoke.http.client.reqtimeout=10000 #nodeoperagent -feature.nodeoperagent.loader=default +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent feature.nodeoperagent.http.port=10113 #notifyagent -feature.notifyagent.loader=default +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar #feature.xxx.enable should enable this feature feature.notifyagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -54,7 +54,7 @@ feature.notifyagent.frozenTime=300 #heartbeatclientagent Agent Feature xxx #feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.hbclientagent.enable=true #feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes @@ -70,7 +70,7 @@ feature.hbclientagent.interval=15000 #------------------------------------------------------------------------------------ #feature runtimenotify -feature.runtimenotify.loader=default +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar feature.runtimenotify.enable=true feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler diff --git a/com.creditease.uav.upgrade/config/upgrade_pro.properties b/com.creditease.uav.upgrade/config/upgrade_pro.properties index 4544fab5..efdac43d 100644 --- a/com.creditease.uav.upgrade/config/upgrade_pro.properties +++ b/com.creditease.uav.upgrade/config/upgrade_pro.properties @@ -1,47 +1,47 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10409 - -#upgrade -feature.upgradeagent.loader=default -feature.upgradeagent.enable=true -feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent -# the address of download server -feature.upgradeagent.http.server.host=127.0.0.1 -feature.upgradeagent.http.server.port=8888 -feature.upgradeagent.backup.count=3 -#when download request was refused by download center, try to retry sending request -feature.upgradeagent.download.retry.count=20 -#tell client that retry sending download request after x seconds +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10409 + +#upgrade +feature.upgradeagent.loader=default +feature.upgradeagent.enable=true +feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent +# the address of download server +feature.upgradeagent.http.server.host=127.0.0.1 +feature.upgradeagent.http.server.port=8888 +feature.upgradeagent.backup.count=3 +#when download request was refused by download center, try to retry sending request +feature.upgradeagent.download.retry.count=20 +#tell client that retry sending download request after x seconds feature.upgradeagent.download.retry.after=30 \ No newline at end of file diff --git a/com.creditease.uav.upgrade/config/upgrade_server.properties b/com.creditease.uav.upgrade/config/upgrade_server.properties index d4fbb3de..b4758663 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=D:/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=D:/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_server_pro.properties b/com.creditease.uav.upgrade/config/upgrade_server_pro.properties index cdf0d16c..52b7ab4f 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server_pro.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server_pro.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_server_test.properties b/com.creditease.uav.upgrade/config/upgrade_server_test.properties index 23e7657d..22eec421 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server_test.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server_test.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_test.properties b/com.creditease.uav.upgrade/config/upgrade_test.properties index e148d9a8..fd56531d 100644 --- a/com.creditease.uav.upgrade/config/upgrade_test.properties +++ b/com.creditease.uav.upgrade/config/upgrade_test.properties @@ -1,47 +1,47 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=default -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=default -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10409 - -#upgrade -feature.upgradeagent.loader=default -feature.upgradeagent.enable=true -feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent -# the address of download server -feature.upgradeagent.http.server.host=127.0.0.1 -feature.upgradeagent.http.server.port=8888 -feature.upgradeagent.backup.count=3 -#when download request was refused by download center, try to retry sending request -feature.upgradeagent.download.retry.count=20 -#tell client that retry sending download request after x seconds +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10409 + +#upgrade +feature.upgradeagent.loader=default +feature.upgradeagent.enable=true +feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent +# the address of download server +feature.upgradeagent.http.server.host=127.0.0.1 +feature.upgradeagent.http.server.port=8888 +feature.upgradeagent.backup.count=3 +#when download request was refused by download center, try to retry sending request +feature.upgradeagent.download.retry.count=20 +#tell client that retry sending download request after x seconds feature.upgradeagent.download.retry.after=30 \ No newline at end of file From 421e729ba95ee711dcc29ebd837a4d967341faaf Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 8 Feb 2018 19:38:00 +0800 Subject: [PATCH 12/97] https://github.com/uavorg/uavstack/issues/186 reset some unexpected change --- .../config/ma_pro.properties | 344 +++++----- .../config/ma_test.properties | 342 +++++----- .../config/agent.properties | 4 +- .../config/hm_pro_logserver.properties | 185 ++--- .../config/hm_pro_pfntfyserver.properties | 444 ++++++------ .../config/hm_test_logserver.properties | 186 ++--- .../config/hm_test_moserver.properties | 336 ++++----- .../config/hm_test_nodeserver.properties | 336 ++++----- .../config/hm_test_pnhbserver.properties | 646 +++++++++--------- .../config/upgrade_pro.properties | 92 +-- .../config/upgrade_server.properties | 112 +-- .../config/upgrade_server_pro.properties | 112 +-- .../config/upgrade_server_test.properties | 112 +-- .../config/upgrade_test.properties | 92 +-- 14 files changed, 1672 insertions(+), 1671 deletions(-) diff --git a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties index 286afbf9..53e0c3d9 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties @@ -1,172 +1,172 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= -log.path= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 -#message size limit. unit is Byte -resource.messageproducer.messagesizelimit=262000 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10101 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.monitoragent.loader=default -#feature.xxx.enable should enable this feature -feature.monitoragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.monitoragent.properties= -#feature.xxx. -#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes -feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler -#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes -feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler -#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes -feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler -#app server keep alive -feature.monitoragent.keepalive.enable=false -#mdf listen server -feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler -feature.monitoragent.http.port=9111 -feature.monitoragent.http.backlog=10 -feature.monitoragent.http.core=10 -feature.monitoragent.http.max=50 -feature.monitoragent.http.bqsize=1 -feature.monitoragent.http.enable=false -#monitoragent jvm filters -feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient -#monitoragent detect interval default is 30000 -feature.monitoragent.detector.interval=30000 -#enable local scan by jvm tool and jmx -feature.monitoragent.detector.local.scan.enable=true -#enable container scan by http -feature.monitoragent.detector.container.scan.enable=false -#container ports -feature.monitoragent.detector.container.ports= -#monitoragent detect interval default is 15000 -feature.monitoragent.monitor.interval=15000 -#agent process limitation for exit -#default memory limit is 300M -feature.monitoragent.limit.mem=300000 -#default cpu limit is over 30% during 120 seconds -feature.monitoragent.limit.cpu.value=30 -feature.monitoragent.limit.cpu.timerange=120000 - -#Log Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.logagent.loader=default -#feature.xxx.enable should enable this feature -feature.logagent.enable=true -#feature.xxx.enable should enable the self Log collection feature -feature.logagent.selfLog.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.logagent.components=com.creditease.agent.feature.LogAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.logagent.properties= -#log pos file root -feature.logagent.posfileroot=./ -#catch log interval (ms) -feature.logagent.LogDataFrame.enable=false -feature.logagent.interval=2000 -feature.logagent.MutiThread.enable=true -feature.logagent.MutiThread.thread.max=2 -#default filter -feature.logagent.defrule.filter= - -#Proc Detect Agent Feature -feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar -feature.procscan.enable=true -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 -feature.procscan.networkDetect.interval=15000 -feature.procscan.networkDetect.collectTime=2000 - -# Process Watch Feature -feature.procwatch.loader=default -feature.procwatch.enable=true -feature.procwatch.interval=15000 -feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent - -# Data Collect Feature -feature.collectclient.loader=default -feature.collectclient.enable=true -feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent -feature.collectclient.properties= -feature.collectclient.readlinesize=100 -feature.collectclient.MutiThread.enable=true -feature.collectclient.MutiThread.thread.max=2 -feature.collectclient.interval=2000 -feature.collectclient.writeposdelay=5000 -feature.collectclient.writeposinterval=3000 -feature.collectclient.idlecheckerdelay=12000 -feature.collectclient.idlecheckerinterval=5000 -# Thread Analysis Feature -feature.threadanalysis.loader=default -feature.threadanalysis.enable=true -feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= +log.path= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 +#message size limit. unit is Byte +resource.messageproducer.messagesizelimit=262000 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10101 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.monitoragent.loader=com.creditease.uav.agent-1.0.jar +#feature.xxx.enable should enable this feature +feature.monitoragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.monitoragent.properties= +#feature.xxx. +#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes +feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler +#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes +feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler +#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes +feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler +#app server keep alive +feature.monitoragent.keepalive.enable=false +#mdf listen server +feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler +feature.monitoragent.http.port=9111 +feature.monitoragent.http.backlog=10 +feature.monitoragent.http.core=10 +feature.monitoragent.http.max=50 +feature.monitoragent.http.bqsize=1 +feature.monitoragent.http.enable=false +#monitoragent jvm filters +feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient +#monitoragent detect interval default is 30000 +feature.monitoragent.detector.interval=30000 +#enable local scan by jvm tool and jmx +feature.monitoragent.detector.local.scan.enable=true +#enable container scan by http +feature.monitoragent.detector.container.scan.enable=false +#container ports +feature.monitoragent.detector.container.ports= +#monitoragent detect interval default is 15000 +feature.monitoragent.monitor.interval=15000 +#agent process limitation for exit +#default memory limit is 300M +feature.monitoragent.limit.mem=300000 +#default cpu limit is over 30% during 120 seconds +feature.monitoragent.limit.cpu.value=30 +feature.monitoragent.limit.cpu.timerange=120000 + +#Log Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.logagent.loader=com.creditease.uav.agent-1.0.jar +#feature.xxx.enable should enable this feature +feature.logagent.enable=true +#feature.xxx.enable should enable the self Log collection feature +feature.logagent.selfLog.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.logagent.components=com.creditease.agent.feature.LogAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.logagent.properties= +#log pos file root +feature.logagent.posfileroot=./ +#catch log interval (ms) +feature.logagent.LogDataFrame.enable=false +feature.logagent.interval=2000 +feature.logagent.MutiThread.enable=true +feature.logagent.MutiThread.thread.max=2 +#default filter +feature.logagent.defrule.filter= + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=true +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 +feature.procscan.networkDetect.interval=15000 +feature.procscan.networkDetect.collectTime=2000 + +# Process Watch Feature +feature.procwatch.loader=com.creditease.uav.agent.heartbeat.jar +feature.procwatch.enable=true +feature.procwatch.interval=15000 +feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent + +# Data Collect Feature +feature.collectclient.loader=com.creditease.uav.collect.jar +feature.collectclient.enable=true +feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent +feature.collectclient.properties= +feature.collectclient.readlinesize=100 +feature.collectclient.MutiThread.enable=true +feature.collectclient.MutiThread.thread.max=2 +feature.collectclient.interval=2000 +feature.collectclient.writeposdelay=5000 +feature.collectclient.writeposinterval=3000 +feature.collectclient.idlecheckerdelay=12000 +feature.collectclient.idlecheckerinterval=5000 +# Thread Analysis Feature +feature.threadanalysis.loader=com.creditease.uav.threadanalysis.jar +feature.threadanalysis.enable=true +feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent diff --git a/com.creditease.uav.agent.buildComponent/config/ma_test.properties b/com.creditease.uav.agent.buildComponent/config/ma_test.properties index 853823b1..4dbffb7b 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_test.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_test.properties @@ -1,172 +1,172 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= -log.path= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 -#message size limit. unit is Byte -resource.messageproducer.messagesizelimit=262000 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10101 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.monitoragent.loader=default -#feature.xxx.enable should enable this feature -feature.monitoragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.monitoragent.properties= -#feature.xxx. -#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes -feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler -#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes -feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler -#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes -feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler -#app server keep alive -feature.monitoragent.keepalive.enable=false -#mdf listen server -feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler -feature.monitoragent.http.port=8099 -feature.monitoragent.http.backlog=10 -feature.monitoragent.http.core=10 -feature.monitoragent.http.max=50 -feature.monitoragent.http.bqsize=1 -feature.monitoragent.http.enable=false -#monitoragent jvm filters -feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient -#monitoragent detect interval default is 30000 -feature.monitoragent.detector.interval=30000 -#enable local scan by jvm tool and jmx -feature.monitoragent.detector.local.scan.enable=true -#enable container scan by http -feature.monitoragent.detector.container.scan.enable=false -#container ports -feature.monitoragent.detector.container.ports= -#monitoragent detect interval default is 15000 -feature.monitoragent.monitor.interval=15000 -#agent process limitation for exit -#default memory limit is 300M -feature.monitoragent.limit.mem=300000 -#default cpu limit is over 30% during 120 seconds -feature.monitoragent.limit.cpu.value=30 -feature.monitoragent.limit.cpu.timerange=120000 - -#Log Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.logagent.loader=default -#feature.xxx.enable should enable this feature -feature.logagent.enable=true -#feature.xxx.enable should enable the self Log collection feature -feature.logagent.selfLog.enable=false -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.logagent.components=com.creditease.agent.feature.LogAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.logagent.properties= -#log pos file root -feature.logagent.posfileroot=./ -#catch log interval (ms) -feature.logagent.LogDataFrame.enable=false -feature.logagent.interval=2000 -feature.logagent.MutiThread.enable=true -feature.logagent.MutiThread.thread.max=2 -#default filter -feature.logagent.defrule.filter= - -#Proc Detect Agent Feature -feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar -feature.procscan.enable=true -feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent -feature.procscan.properties= -#scanning interval -feature.procscan.scan.interval=15000 -feature.procscan.networkDetect.interval=15000 -feature.procscan.networkDetect.collectTime=2000 - -# Process Watch Feature -feature.procwatch.loader=default -feature.procwatch.enable=true -feature.procwatch.interval=15000 -feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent - -# Data Collect Feature -feature.collectclient.loader=default -feature.collectclient.enable=true -feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent -feature.collectclient.properties= -feature.collectclient.readlinesize=100 -feature.collectclient.MutiThread.enable=true -feature.collectclient.MutiThread.thread.max=2 -feature.collectclient.interval=2000 -feature.collectclient.writeposdelay=5000 -feature.collectclient.writeposinterval=3000 -feature.collectclient.idlecheckerdelay=12000 -feature.collectclient.idlecheckerinterval=5000 -# Thread Analysis Feature -feature.threadanalysis.loader=default -feature.threadanalysis.enable=true +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= +log.path= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u76D1\u63A7\u4EE3\u7406\u7A0B\u5E8F + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 +#message size limit. unit is Byte +resource.messageproducer.messagesizelimit=262000 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10101 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.monitoragent.loader=com.creditease.uav.agent-1.0.jar +#feature.xxx.enable should enable this feature +feature.monitoragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.monitoragent.components=com.creditease.agent.feature.MonitorAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.monitoragent.properties= +#feature.xxx. +#feature.monitoragent.notifyhandlers are handlers for Notification Event, separator "," for multiply classes +feature.monitoragent.notifyhandlers=com.creditease.agent.feature.monitoragent.handlers.DefaultNotificationEventHandler +#feature.monitoragent.modatahandlers are handlers for Monitor Data, separator "," for multiply classes +feature.monitoragent.modatahandlers=com.creditease.agent.feature.monitoragent.handlers.MonitorDataPublishHandler +#feature.monitoragent.prodatahandlers are handlers for Profile Data, separator "," for multiply classes +feature.monitoragent.prodatahandlers=com.creditease.agent.feature.monitoragent.handlers.ProfileDataPublishHandler,com.creditease.agent.feature.monitoragent.handlers.LogProfileDataNotifyHandler,com.creditease.agent.feature.monitoragent.handlers.ProfileDataContainerTagsHandler +#app server keep alive +feature.monitoragent.keepalive.enable=false +#mdf listen server +feature.monitoragent.mdfhandlers=com.creditease.agent.feature.monitoragent.handlers.MDFListenServerHandler +feature.monitoragent.http.port=8099 +feature.monitoragent.http.backlog=10 +feature.monitoragent.http.core=10 +feature.monitoragent.http.max=50 +feature.monitoragent.http.bqsize=1 +feature.monitoragent.http.enable=false +#monitoragent jvm filters +feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient +#monitoragent detect interval default is 30000 +feature.monitoragent.detector.interval=30000 +#enable local scan by jvm tool and jmx +feature.monitoragent.detector.local.scan.enable=true +#enable container scan by http +feature.monitoragent.detector.container.scan.enable=false +#container ports +feature.monitoragent.detector.container.ports= +#monitoragent detect interval default is 15000 +feature.monitoragent.monitor.interval=15000 +#agent process limitation for exit +#default memory limit is 300M +feature.monitoragent.limit.mem=300000 +#default cpu limit is over 30% during 120 seconds +feature.monitoragent.limit.cpu.value=30 +feature.monitoragent.limit.cpu.timerange=120000 + +#Log Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.logagent.loader=com.creditease.uav.agent-1.0.jar +#feature.xxx.enable should enable this feature +feature.logagent.enable=true +#feature.xxx.enable should enable the self Log collection feature +feature.logagent.selfLog.enable=false +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.logagent.components=com.creditease.agent.feature.LogAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.logagent.properties= +#log pos file root +feature.logagent.posfileroot=./ +#catch log interval (ms) +feature.logagent.LogDataFrame.enable=false +feature.logagent.interval=2000 +feature.logagent.MutiThread.enable=true +feature.logagent.MutiThread.thread.max=2 +#default filter +feature.logagent.defrule.filter= + +#Proc Detect Agent Feature +feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar +feature.procscan.enable=true +feature.procscan.components=com.creditease.agent.feature.ProcDetectAgent +feature.procscan.properties= +#scanning interval +feature.procscan.scan.interval=15000 +feature.procscan.networkDetect.interval=15000 +feature.procscan.networkDetect.collectTime=2000 + +# Process Watch Feature +feature.procwatch.loader=com.creditease.uav.agent.heartbeat.jar +feature.procwatch.enable=true +feature.procwatch.interval=15000 +feature.procwatch.components=com.creditease.agent.feature.ProcWatchAgent + +# Data Collect Feature +feature.collectclient.loader=com.creditease.uav.collect.jar +feature.collectclient.enable=true +feature.collectclient.components=com.creditease.uav.collect.client.CollectDataAgent +feature.collectclient.properties= +feature.collectclient.readlinesize=100 +feature.collectclient.MutiThread.enable=true +feature.collectclient.MutiThread.thread.max=2 +feature.collectclient.interval=2000 +feature.collectclient.writeposdelay=5000 +feature.collectclient.writeposinterval=3000 +feature.collectclient.idlecheckerdelay=12000 +feature.collectclient.idlecheckerinterval=5000 +# Thread Analysis Feature +feature.threadanalysis.loader=com.creditease.uav.threadanalysis.jar +feature.threadanalysis.enable=true feature.threadanalysis.components=com.creditease.uav.threadanalysis.client.ThreadAnalysisAgent \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index 3f9b1f4c..7ef7965d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -163,7 +163,7 @@ feature.healthmanager.MT_Notify.ds.db=notifyDataStore feature.healthmanager.MT_Notify.ds.usr= feature.healthmanager.MT_Notify.ds.pwd= -#feature.DBSource.OpenTSDB +#feature.DBSource.OpenTSDB4Monitor feature.healthmanager.MT_Monitor.ds.enable=true feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Monitor.ds.db=monitorDataStore @@ -179,7 +179,7 @@ feature.healthmanager.MT_Monitor.ds.expire=30000 #new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min feature.healthmanager.MT_Monitor.ds.cachetime=5 -#feature.DBSource.OpenTSDB +#feature.DBSource.OpenTSDB4Node feature.healthmanager.MT_Node.ds.enable=true feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 feature.healthmanager.MT_Node.ds.db=nodeinfoDataStore diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties index c91bdc81..e32296c4 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_logserver.properties @@ -1,93 +1,94 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10130 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#HealthManager NewLogService Feature -feature.newlogservice.loader=com.creditease.uav.invokechain.jar -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=edp-es -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=50 -feature.newlogservice.http.max=300 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10130 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=edp-es +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=50 +feature.newlogservice.http.max=300 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties index f461b026..3575d2d7 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties @@ -1,222 +1,222 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=INFO -log.debug=false -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 - -#-----------------------------COMMON FEATURES START--------------------------------------------------- -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10150 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 -#-----------------------------COMMON FEATURES END--------------------------------------------------- - - -#HealthManager -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=15 -feature.healthmanager.MT_Profile.consumethreadmax=25 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=200 -feature.healthmanager.http.bqsize=20 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:26379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=150 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB4Monitor -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB4Node -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 -#-----------------------------NOTIFICATION CENTER--------------------------------------------------- - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=50 -feature.notifycenter.inqw.bQueueSize=5 -feature.notifycenter.inqw.keepAliveTimeout=30000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:26379 -feature.notifycenter.nc.cache.concurrent.min=30 -feature.notifycenter.nc.cache.concurrent.max=100 -feature.notifycenter.nc.cache.concurrent.bqsize=5 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=30 -feature.notifycenter.http.max=150 -feature.notifycenter.http.bqsize=5 -#push to other services -feature.notifycenter.push.services= - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=INFO +log.debug=false +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF\u4E0E\u9884\u8B66\u670D\u52A1 + +#-----------------------------COMMON FEATURES START--------------------------------------------------- +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10150 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 +#-----------------------------COMMON FEATURES END--------------------------------------------------- + + +#HealthManager +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=15 +feature.healthmanager.MT_Profile.consumethreadmax=25 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=200 +feature.healthmanager.http.bqsize=20 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:26379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=150 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=uav.db.jishu.idc:25000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4242,127.0.0.1:4242 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 +#-----------------------------NOTIFICATION CENTER--------------------------------------------------- + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jarfeature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=50 +feature.notifycenter.inqw.bQueueSize=5 +feature.notifycenter.inqw.keepAliveTimeout=30000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:26379 +feature.notifycenter.nc.cache.concurrent.min=30 +feature.notifycenter.nc.cache.concurrent.max=100 +feature.notifycenter.nc.cache.concurrent.bqsize=5 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=30 +feature.notifycenter.http.max=150 +feature.notifycenter.http.bqsize=5 +#push to other services +feature.notifycenter.push.services= + diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties index 1bad7383..0c59b11d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_logserver.properties @@ -1,94 +1,94 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10111 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#HealthManager NewLogService Feature -feature.newlogservice.loader=com.creditease.uav.invokechain.jar -feature.newlogservice.enable=true -feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService -feature.newlogservice.properties= -#fly to runtime notify -feature.newlogservice.to.runtimentf=true -#MQ -feature.newlogservice.messagingnameserver=127.0.0.1:9876 -feature.newlogservice.MT_Log.consumethreadmax=10 -feature.newlogservice.MT_Log.consumestopinterval=0 -feature.newlogservice.MT_Log.enable=true -#elastic-search -feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 -feature.newlogservice.es.clustername=uav-es5.4.1 -feature.newlogservice.es.query.timeout=5000 -#query http service -feature.newlogservice.http.enable=true -feature.newlogservice.http.port=7899 -feature.newlogservice.http.core=30 -feature.newlogservice.http.max=200 -feature.newlogservice.http.backlog=10 -feature.newlogservice.http.bqsize=10 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u65E5\u5FD7\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10111 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#HealthManager NewLogService Feature +feature.newlogservice.loader=com.creditease.uav.invokechain.jar +feature.newlogservice.enable=true +feature.newlogservice.components=com.creditease.uav.healthmanager.newlog.HMNewLogService +feature.newlogservice.properties= +#fly to runtime notify +feature.newlogservice.to.runtimentf=true +#MQ +feature.newlogservice.messagingnameserver=127.0.0.1:9876 +feature.newlogservice.MT_Log.consumethreadmax=10 +feature.newlogservice.MT_Log.consumestopinterval=0 +feature.newlogservice.MT_Log.enable=true +#elastic-search +feature.newlogservice.es.addr=127.0.0.1:9300,127.0.0.1:9300 +feature.newlogservice.es.clustername=uav-es5.4.1 +feature.newlogservice.es.query.timeout=5000 +#query http service +feature.newlogservice.http.enable=true +feature.newlogservice.http.port=7899 +feature.newlogservice.http.core=30 +feature.newlogservice.http.max=200 +feature.newlogservice.http.backlog=10 +feature.newlogservice.http.bqsize=10 feature.newlogservice.qhandlers=com.creditease.uav.healthmanager.newlog.http.NewLogQueryHandler \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties index 84b9e5ad..e333d984 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_moserver.properties @@ -1,169 +1,169 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10112 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=35 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=true -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8043 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB4Monitor -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB4Node -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5B9E\u65F6\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10112 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=35 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=true +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8043 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties index bcb47b91..7b00ea4e 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_nodeserver.properties @@ -1,169 +1,169 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10115 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=false -feature.healthmanager.MT_Profile.enable=false -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=true -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8044 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=10 -feature.healthmanager.http.max=50 -feature.healthmanager.http.bqsize=10 - -#profile data cache -feature.healthmanager.lifekeeper.enable=false -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=100 -feature.healthmanager.store.concurrent.max=300 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=300 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=5 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB4Node -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5E94\u7528\u5BB9\u5668\u6570\u636E\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10115 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=false +feature.healthmanager.MT_Profile.enable=false +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=true +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8044 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=10 +feature.healthmanager.http.max=50 +feature.healthmanager.http.bqsize=10 + +#profile data cache +feature.healthmanager.lifekeeper.enable=false +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=100 +feature.healthmanager.store.concurrent.max=300 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=false +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=false +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=false +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=300 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=5 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=false +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 feature.healthmanager.MT_Node.ds.expire=30000 \ No newline at end of file diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties index cbbd3d29..11e250a9 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties @@ -1,324 +1,324 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -log.level=DEBUG -log.debug=true -log.fsize=10 -log.collectEnable=false -log.collectMatch= - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 - -#resource components -#resource.xxxx -resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent -#resource.xxxx.properties, for example: =,=,... -resource.messageproducer.properties= -#resource.xxxx. -resource.messageproducer.messagingnameserver=127.0.0.1:9876 -#message threshold's unit is kb -resource.messageproducer.messagingthreshold=30 - -#System Http Invoker -resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent -resource.httpinvoke.properties= -resource.httpinvoke.http.client.maxperroute=20 -resource.httpinvoke.http.client.maxtotal=100 -resource.httpinvoke.http.client.sotimeout=10000 -resource.httpinvoke.http.client.conntimeout=10000 -resource.httpinvoke.http.client.reqtimeout=10000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10110 - -#notifyagent -feature.notifyagent.loader=com.creditease.uav.notifymanager.jar -#feature.xxx.enable should enable this feature -feature.notifyagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifyagent.properties= -feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler -#event expire in seconds, 4 hour by default -feature.notifyagent.expireTime=14400 -#event send forzen interval in seconds, 5 min by default -feature.notifyagent.frozenTime=300 - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#----------------------------------------------------------------------------------------------------- - -#feature apphubmanager BEGIN -feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar -feature.apphubmanager.enable=true -feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager -feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler -feature.apphubmanager.http.port=8031 -feature.apphubmanager.http.backlog=10 -feature.apphubmanager.http.core=10 -feature.apphubmanager.http.max=50 -feature.apphubmanager.http.bqsize=10 -#feature.DBSource.AppHubMgt -feature.apphubmanager.ds.enable=true -feature.apphubmanager.ds.servers=127.0.0.1:26000 -feature.apphubmanager.ds.db=apphubDataStore -feature.apphubmanager.ds.power=apphubDataStore -feature.apphubmanager.ds.usr= -feature.apphubmanager.ds.pwd= -#feature apphubmanager END - -#notifcenter -feature.notifycenter.loader=com.creditease.uav.notifycenter.jar -#feature.xxx.enable should enable this feature -feature.notifycenter.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter -#feature.xxx.properties for the feature, for example: =,=,... -feature.notifycenter.properties= -feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler -feature.notifycenter.inqw.coreSize=10 -feature.notifycenter.inqw.maxSize=20 -feature.notifycenter.inqw.bQueueSize=50 -feature.notifycenter.inqw.keepAliveTimeout=60000 -#notification Center SMS&Mail enable flag -feature.notifycenter.nc.notify.mail.provider=JavaMail -feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html -feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ -#CEMail -feature.notifycenter.nc.notify.mail.cemail.username= -feature.notifycenter.nc.notify.mail.cemail.password= -feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 -feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 -feature.notifycenter.nc.notify.mail.cemail.systemsign=1 -#JavaMail -feature.notifycenter.nc.notify.mail.javamail.smtphost= -feature.notifycenter.nc.notify.mail.javamail.smtpport=25 -feature.notifycenter.nc.notify.mail.javamail.smtpauth=true -feature.notifycenter.nc.notify.mail.javamail.username= -feature.notifycenter.nc.notify.mail.javamail.password= -#CESMS -feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ -feature.notifycenter.nc.notify.retry=3 -#event ttl time, 4hours by default -feature.notifycenter.nc.notify.ttl=4 -#event send forzen interval in seconds, 1 hour by default -feature.notifycenter.nc.notify.frozenTime=3600 -#notifyCenter redis configuration -feature.notifycenter.nc.cache.addr=127.0.0.1:6379 -feature.notifycenter.nc.cache.concurrent.min=10 -feature.notifycenter.nc.cache.concurrent.max=20 -feature.notifycenter.nc.cache.concurrent.bqsize=10 -feature.notifycenter.nc.cache.concurrent.pwd= -#notifyCenter http service configuration -feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler -feature.notifycenter.http.port=9011 -feature.notifycenter.http.backlog=10 -feature.notifycenter.http.core=10 -feature.notifycenter.http.max=50 -feature.notifycenter.http.bqsize=10 -#push to other services -feature.notifycenter.push.services= - -#agent feature configuration -#Monitor Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar -#feature.xxx.enable should enable this feature -feature.healthmanager.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.healthmanager.components=com.creditease.uav.feature.HealthManager -#feature.xxx.properties for the feature, for example: =,=,... -feature.healthmanager.properties= -#feature.xxx. -feature.healthmanager.messagingnameserver=127.0.0.1:9876 -feature.healthmanager.MT_Monitor.consumethreadmax=10 -feature.healthmanager.MT_Notify.consumethreadmax=10 -feature.healthmanager.MT_Profile.consumethreadmax=10 -feature.healthmanager.MT_Log.consumethreadmax=10 -feature.healthmanager.MT_Node.consumethreadmax=10 -feature.healthmanager.MT_Monitorconsumestopinterval=0 -feature.healthmanager.MT_Notify.consumestopinterval=0 -feature.healthmanager.MT_Profile.consumestopinterval=0 -feature.healthmanager.MT_Log.consumestopinterval=0 -feature.healthmanager.MT_Node.consumestopinterval=0 -feature.healthmanager.MT_Monitor.enable=false -feature.healthmanager.MT_Notify.enable=true -feature.healthmanager.MT_Profile.enable=true -feature.healthmanager.MT_Log.enable=false -feature.healthmanager.MT_Node.enable=false -#feature.healthmanager.healthmanger handlers -feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler -feature.healthmanager.http.port=8041 -feature.healthmanager.http.backlog=10 -feature.healthmanager.http.core=20 -feature.healthmanager.http.max=100 -feature.healthmanager.http.bqsize=5 - -#profile data cache -feature.healthmanager.lifekeeper.enable=true -feature.healthmanager.lifekeeper.interval=60000 -feature.healthmanager.store.addr=127.0.0.1:6379 -feature.healthmanager.store.concurrent.min=50 -feature.healthmanager.store.concurrent.max=200 -feature.healthmanager.store.concurrent.bqsize=5 -feature.healthmanager.store.concurrent.pwd= - -#feature.DBSource.MongoDB4Profile -feature.healthmanager.MT_Profile.ds.enable=true -feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Profile.ds.db=profileDataStore -feature.healthmanager.MT_Profile.ds.power=profileDataStore -feature.healthmanager.MT_Profile.ds.usr= -feature.healthmanager.MT_Profile.ds.pwd= - -#feature.DBSource.MongoDB4Notification -feature.healthmanager.MT_Notify.ds.enable=true -feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 -feature.healthmanager.MT_Notify.ds.db=notifyDataStore -feature.healthmanager.MT_Notify.ds.power=notifyDataStore -feature.healthmanager.MT_Notify.ds.usr= -feature.healthmanager.MT_Notify.ds.pwd= - -#feature.DBSource.OpenTSDB4Monitor -feature.healthmanager.MT_Monitor.ds.enable=true -feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Monitor.ds.db=monitorDataStore -feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 -feature.healthmanager.MT_Monitor.ds.maxRoute=50 -feature.healthmanager.MT_Monitor.ds.soTimeout=30000 -feature.healthmanager.MT_Monitor.ds.connTimeout=30000 -feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 -#opentsdb batch size -feature.healthmanager.MT_Monitor.ds.batchsize=50 -feature.healthmanager.MT_Monitor.ds.retry=3 -feature.healthmanager.MT_Monitor.ds.expire=30000 -#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min -feature.healthmanager.MT_Monitor.ds.cachetime=1 - -#feature.DBSource.HBase -feature.healthmanager.MT_Log.ds.enable=false -feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 -feature.healthmanager.MT_Log.ds.db=logDataStore -feature.healthmanager.MT_Log.ds.cache=1000 -feature.healthmanager.MT_Log.ds.maxResultSize=2097152 -feature.healthmanager.MT_Log.ds.reverse=true -feature.healthmanager.MT_Log.ds.pagesize=3000 - -#feature.DBSource.OpenTSDB4Node -feature.healthmanager.MT_Node.ds.enable=true -feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 -feature.healthmanager.MT_Node.ds.db=nodeDataStore -feature.healthmanager.MT_Node.ds.maxPerRoute=10 -feature.healthmanager.MT_Node.ds.maxRoute=50 -feature.healthmanager.MT_Node.ds.soTimeout=10000 -feature.healthmanager.MT_Node.ds.connTimeout=5000 -feature.healthmanager.MT_Node.ds.reqTimeout=3000 -feature.healthmanager.MT_Node.ds.retry=3 -#opentsdb batch size -feature.healthmanager.MT_Node.ds.batchsize=50 -feature.healthmanager.MT_Node.ds.expire=30000 -#------------------------------------------------------------------------------------------------- - -#heartbeatserveragent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbserveragent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbserveragent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler -#feature.hbserveragent.http.port for heartbeat -feature.hbserveragent.http.port=8010 -#feature.hbserveragent.http.qport for query -feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler -feature.hbserveragent.http.qport=8020 -feature.hbserveragent.http.backlog=10 -feature.hbserveragent.http.core=10 -feature.hbserveragent.http.max=50 -feature.hbserveragent.http.bqsize=10 -feature.hbserveragent.store.addr=127.0.0.1:6379 -feature.hbserveragent.store.concurrent.min=10 -feature.hbserveragent.store.concurrent.max=20 -feature.hbserveragent.store.concurrent.bqsize=10 -feature.hbserveragent.store.concurrent.pwd= -#if is master server node, then store node info into cache system -#if is not master server node, just pass the node to the target master server node. -feature.hbserveragent.ismaster=true -feature.hbserveragent.lifekeeper.enable=true -feature.hbserveragent.lifekeeper.interval=15000 -feature.hbserveragent.lifekeeper.locktimeout=60000 -feature.hbserveragent.lifekeeper.nodetimeout=20000 -#enable ntp serivce -feature.hbserveragent.ntp.enable=false - -#------------------------------------------------------------------------------------ -#feature runtimenotify -feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar -feature.runtimenotify.enable=true -feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher -feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler -#data consumer -feature.runtimenotify.messagingnameserver=127.0.0.1:9876 -feature.runtimenotify.MT_Runtime.consumethreadmax=30 -feature.runtimenotify.MT_Runtime.consumestopinterval=0 -feature.runtimenotify.MT_Runtime.enable=false -#cache -feature.runtimenotify.cm.server=127.0.0.1:6379 -feature.runtimenotify.cm.minsize=5 -feature.runtimenotify.cm.maxsize=10 -feature.runtimenotify.cm.qsize=20 -feature.runtimenotify.cm.pwd= -feature.runtimenotify.storecm.server=127.0.0.1:6379 -feature.runtimenotify.storecm.minsize=40 -feature.runtimenotify.storecm.maxsize=100 -feature.runtimenotify.storecm.qsize=10 -feature.runtimenotify.storecm.pwd= -#qworker -feature.runtimenotify.qworker.coresize=25 -feature.runtimenotify.qworker.maxsize=50 -feature.runtimenotify.qworker.bqsize=5 -feature.runtimenotify.qworker.keepalivetimeout=60000 -#nodeinfotimer -feature.runtimenotify.nodeinfotimer.enable=true -feature.runtimenotify.nodeinfotimer.period=15000 -#nodeinfoprocess -feature.runtimenotify.nodeinfoprocess.sendmq=true -feature.runtimenotify.nodeinfoprocess.exchange=false -#http service -feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler -feature.runtimenotify.http.port=9001 -feature.runtimenotify.http.backlog=10 -feature.runtimenotify.http.core=5 -feature.runtimenotify.http.max=10 -feature.runtimenotify.http.bqsize=10 -#crash process timeout -feature.runtimenotify.crash.timeout=300000 -#in seconds, this is only for development now, the production is read from cache, see the above cache setting -#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} -#sync interval from cache -feature.runtimenotify.strategy.interval=60000 -#in ms +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +log.level=DEBUG +log.debug=true +log.fsize=10 +log.collectEnable=false +log.collectMatch= + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u753B\u50CF&\u9884\u8B66&\u5FC3\u8DF3\u670D\u52A1 + +#resource components +#resource.xxxx +resource.messageproducer.class=org.uavstack.resources.common.messaging.MessageProducerResourceComponent +#resource.xxxx.properties, for example: =,=,... +resource.messageproducer.properties= +#resource.xxxx. +resource.messageproducer.messagingnameserver=127.0.0.1:9876 +#message threshold's unit is kb +resource.messageproducer.messagingthreshold=30 + +#System Http Invoker +resource.httpinvoke.class=org.uavstack.resources.common.invoker.HttpInvokerResourceComponent +resource.httpinvoke.properties= +resource.httpinvoke.http.client.maxperroute=20 +resource.httpinvoke.http.client.maxtotal=100 +resource.httpinvoke.http.client.sotimeout=10000 +resource.httpinvoke.http.client.conntimeout=10000 +resource.httpinvoke.http.client.reqtimeout=10000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10110 + +#notifyagent +feature.notifyagent.loader=com.creditease.uav.notifymanager.jar +#feature.xxx.enable should enable this feature +feature.notifyagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifyagent.components=com.creditease.agent.feature.GlobalNotificationAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifyagent.properties= +feature.notifyagent.notifyhandlers=com.creditease.agent.feature.globalnotify.handlers.NotificationEventPublishHandler +#event expire in seconds, 4 hour by default +feature.notifyagent.expireTime=14400 +#event send forzen interval in seconds, 5 min by default +feature.notifyagent.frozenTime=300 + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#----------------------------------------------------------------------------------------------------- + +#feature apphubmanager BEGIN +feature.apphubmanager.loader=com.creditease.uav.healthmanager-1.0.jar +feature.apphubmanager.enable=true +feature.apphubmanager.components=com.creditease.uav.feature.AppHubManager +feature.apphubmanager.appHubManagerHandlers=com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreAppHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreGroupHandler,com.creditease.uav.feature.apphubmanager.http.handlers.AHDataStoreFeedbackHandler +feature.apphubmanager.http.port=8031 +feature.apphubmanager.http.backlog=10 +feature.apphubmanager.http.core=10 +feature.apphubmanager.http.max=50 +feature.apphubmanager.http.bqsize=10 +#feature.DBSource.AppHubMgt +feature.apphubmanager.ds.enable=true +feature.apphubmanager.ds.servers=127.0.0.1:26000 +feature.apphubmanager.ds.db=apphubDataStore +feature.apphubmanager.ds.power=apphubDataStore +feature.apphubmanager.ds.usr= +feature.apphubmanager.ds.pwd= +#feature apphubmanager END + +#notifcenter +feature.notifycenter.loader=com.creditease.uav.notifycenter.jarfeature.notifycenter.loader=com.creditease.uav.notifycenter.jar +#feature.xxx.enable should enable this feature +feature.notifycenter.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.notifycenter.components=com.creditease.agent.feature.NotificationCenter +#feature.xxx.properties for the feature, for example: =,=,... +feature.notifycenter.properties= +feature.notifycenter.notifycenterhandlers=com.creditease.agent.feature.notifycenter.handlers.NCJudgementHandler +feature.notifycenter.inqw.coreSize=10 +feature.notifycenter.inqw.maxSize=20 +feature.notifycenter.inqw.bQueueSize=50 +feature.notifycenter.inqw.keepAliveTimeout=60000 +#notification Center SMS&Mail enable flag +feature.notifycenter.nc.notify.mail.provider=JavaMail +feature.notifycenter.nc.notify.mail.msgurl=http://127.0.0.1:8080/apphub/uavapp_godeye/notifymgr/desc.html +feature.notifycenter.nc.notify.mail.uavurl=http://127.0.0.1:8080/apphub/ +#CEMail +feature.notifycenter.nc.notify.mail.cemail.username= +feature.notifycenter.nc.notify.mail.cemail.password= +feature.notifycenter.nc.notify.mail.cemail.brokerurl=tcp://127.0.0.1:61616 +feature.notifycenter.nc.notify.mail.cemail.activeid=ACTIVE-20160623-00001 +feature.notifycenter.nc.notify.mail.cemail.systemsign=1 +#JavaMail +feature.notifycenter.nc.notify.mail.javamail.smtphost= +feature.notifycenter.nc.notify.mail.javamail.smtpport=25 +feature.notifycenter.nc.notify.mail.javamail.smtpauth=true +feature.notifycenter.nc.notify.mail.javamail.username= +feature.notifycenter.nc.notify.mail.javamail.password= +#CESMS +feature.notifycenter.nc.notify.sms.baseurl=http://127.0.0.1:8080/smsgateway/services/MessageService3.0/sms/ +feature.notifycenter.nc.notify.retry=3 +#event ttl time, 4hours by default +feature.notifycenter.nc.notify.ttl=4 +#event send forzen interval in seconds, 1 hour by default +feature.notifycenter.nc.notify.frozenTime=3600 +#notifyCenter redis configuration +feature.notifycenter.nc.cache.addr=127.0.0.1:6379 +feature.notifycenter.nc.cache.concurrent.min=10 +feature.notifycenter.nc.cache.concurrent.max=20 +feature.notifycenter.nc.cache.concurrent.bqsize=10 +feature.notifycenter.nc.cache.concurrent.pwd= +#notifyCenter http service configuration +feature.notifycenter.nchttpHandler=com.creditease.agent.feature.notifycenter.handlers.NCHttpHandler +feature.notifycenter.http.port=9011 +feature.notifycenter.http.backlog=10 +feature.notifycenter.http.core=10 +feature.notifycenter.http.max=50 +feature.notifycenter.http.bqsize=10 +#push to other services +feature.notifycenter.push.services= + +#agent feature configuration +#Monitor Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.healthmanager.loader=com.creditease.uav.healthmanager-1.0.jar +#feature.xxx.enable should enable this feature +feature.healthmanager.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.healthmanager.components=com.creditease.uav.feature.HealthManager +#feature.xxx.properties for the feature, for example: =,=,... +feature.healthmanager.properties= +#feature.xxx. +feature.healthmanager.messagingnameserver=127.0.0.1:9876 +feature.healthmanager.MT_Monitor.consumethreadmax=10 +feature.healthmanager.MT_Notify.consumethreadmax=10 +feature.healthmanager.MT_Profile.consumethreadmax=10 +feature.healthmanager.MT_Log.consumethreadmax=10 +feature.healthmanager.MT_Node.consumethreadmax=10 +feature.healthmanager.MT_Monitorconsumestopinterval=0 +feature.healthmanager.MT_Notify.consumestopinterval=0 +feature.healthmanager.MT_Profile.consumestopinterval=0 +feature.healthmanager.MT_Log.consumestopinterval=0 +feature.healthmanager.MT_Node.consumestopinterval=0 +feature.healthmanager.MT_Monitor.enable=false +feature.healthmanager.MT_Notify.enable=true +feature.healthmanager.MT_Profile.enable=true +feature.healthmanager.MT_Log.enable=false +feature.healthmanager.MT_Node.enable=false +#feature.healthmanager.healthmanger handlers +feature.healthmanager.healthMangerHandlers=com.creditease.uav.feature.healthmanager.http.handlers.HMDataStoreQueryHandler,com.creditease.uav.feature.healthmanager.http.handlers.HMCacheQueryHandler +feature.healthmanager.http.port=8041 +feature.healthmanager.http.backlog=10 +feature.healthmanager.http.core=20 +feature.healthmanager.http.max=100 +feature.healthmanager.http.bqsize=5 + +#profile data cache +feature.healthmanager.lifekeeper.enable=true +feature.healthmanager.lifekeeper.interval=60000 +feature.healthmanager.store.addr=127.0.0.1:6379 +feature.healthmanager.store.concurrent.min=50 +feature.healthmanager.store.concurrent.max=200 +feature.healthmanager.store.concurrent.bqsize=5 +feature.healthmanager.store.concurrent.pwd= + +#feature.DBSource.MongoDB4Profile +feature.healthmanager.MT_Profile.ds.enable=true +feature.healthmanager.MT_Profile.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Profile.ds.db=profileDataStore +feature.healthmanager.MT_Profile.ds.power=profileDataStore +feature.healthmanager.MT_Profile.ds.usr= +feature.healthmanager.MT_Profile.ds.pwd= + +#feature.DBSource.MongoDB4Notification +feature.healthmanager.MT_Notify.ds.enable=true +feature.healthmanager.MT_Notify.ds.servers=127.0.0.1:26000 +feature.healthmanager.MT_Notify.ds.db=notifyDataStore +feature.healthmanager.MT_Notify.ds.power=notifyDataStore +feature.healthmanager.MT_Notify.ds.usr= +feature.healthmanager.MT_Notify.ds.pwd= + +#feature.DBSource.OpenTSDB4Monitor +feature.healthmanager.MT_Monitor.ds.enable=true +feature.healthmanager.MT_Monitor.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Monitor.ds.db=monitorDataStore +feature.healthmanager.MT_Monitor.ds.maxPerRoute=10 +feature.healthmanager.MT_Monitor.ds.maxRoute=50 +feature.healthmanager.MT_Monitor.ds.soTimeout=30000 +feature.healthmanager.MT_Monitor.ds.connTimeout=30000 +feature.healthmanager.MT_Monitor.ds.reqTimeout=30000 +#opentsdb batch size +feature.healthmanager.MT_Monitor.ds.batchsize=50 +feature.healthmanager.MT_Monitor.ds.retry=3 +feature.healthmanager.MT_Monitor.ds.expire=30000 +#new prop: in minutes, means how long to cache the monitor data,by defaul we only cache 1 min +feature.healthmanager.MT_Monitor.ds.cachetime=1 + +#feature.DBSource.HBase +feature.healthmanager.MT_Log.ds.enable=true +feature.healthmanager.MT_Log.ds.servers=127.0.0.1:2181,127.0.0.1:2181 +feature.healthmanager.MT_Log.ds.db=logDataStore +feature.healthmanager.MT_Log.ds.cache=1000 +feature.healthmanager.MT_Log.ds.maxResultSize=2097152 +feature.healthmanager.MT_Log.ds.reverse=true +feature.healthmanager.MT_Log.ds.pagesize=3000 + +#feature.DBSource.OpenTSDB4Node +feature.healthmanager.MT_Node.ds.enable=true +feature.healthmanager.MT_Node.ds.servers=127.0.0.1:4243 +feature.healthmanager.MT_Node.ds.db=nodeDataStore +feature.healthmanager.MT_Node.ds.maxPerRoute=10 +feature.healthmanager.MT_Node.ds.maxRoute=50 +feature.healthmanager.MT_Node.ds.soTimeout=10000 +feature.healthmanager.MT_Node.ds.connTimeout=5000 +feature.healthmanager.MT_Node.ds.reqTimeout=3000 +feature.healthmanager.MT_Node.ds.retry=3 +#opentsdb batch size +feature.healthmanager.MT_Node.ds.batchsize=50 +feature.healthmanager.MT_Node.ds.expire=30000 +#------------------------------------------------------------------------------------------------- + +#heartbeatserveragent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbserveragent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbserveragent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbserveragent.components=com.creditease.agent.feature.HeartBeatServerAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbserveragent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbserveragent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBServerDefaultHandler +#feature.hbserveragent.http.port for heartbeat +feature.hbserveragent.http.port=8010 +#feature.hbserveragent.http.qport for query +feature.hbserveragent.hbqueryhandlers=com.creditease.agent.feature.hbagent.handlers.HBQueryHandler +feature.hbserveragent.http.qport=8020 +feature.hbserveragent.http.backlog=10 +feature.hbserveragent.http.core=10 +feature.hbserveragent.http.max=50 +feature.hbserveragent.http.bqsize=10 +feature.hbserveragent.store.addr=127.0.0.1:6379 +feature.hbserveragent.store.concurrent.min=10 +feature.hbserveragent.store.concurrent.max=20 +feature.hbserveragent.store.concurrent.bqsize=10 +feature.hbserveragent.store.concurrent.pwd= +#if is master server node, then store node info into cache system +#if is not master server node, just pass the node to the target master server node. +feature.hbserveragent.ismaster=true +feature.hbserveragent.lifekeeper.enable=true +feature.hbserveragent.lifekeeper.interval=15000 +feature.hbserveragent.lifekeeper.locktimeout=60000 +feature.hbserveragent.lifekeeper.nodetimeout=20000 +#enable ntp serivce +feature.hbserveragent.ntp.enable=false + +#------------------------------------------------------------------------------------ +#feature runtimenotify +feature.runtimenotify.loader=com.creditease.uav.healthmanager-1.0.jar +feature.runtimenotify.enable=true +feature.runtimenotify.components=com.creditease.uav.feature.RuntimeNotifyCatcher +feature.runtimenotify.rnhandlers=com.creditease.uav.feature.runtimenotify.RuntimeNotifyDataHandler +#data consumer +feature.runtimenotify.messagingnameserver=127.0.0.1:9876 +feature.runtimenotify.MT_Runtime.consumethreadmax=30 +feature.runtimenotify.MT_Runtime.consumestopinterval=0 +feature.runtimenotify.MT_Runtime.enable=false +#cache +feature.runtimenotify.cm.server=127.0.0.1:6379 +feature.runtimenotify.cm.minsize=5 +feature.runtimenotify.cm.maxsize=10 +feature.runtimenotify.cm.qsize=20 +feature.runtimenotify.cm.pwd= +feature.runtimenotify.storecm.server=127.0.0.1:6379 +feature.runtimenotify.storecm.minsize=40 +feature.runtimenotify.storecm.maxsize=100 +feature.runtimenotify.storecm.qsize=10 +feature.runtimenotify.storecm.pwd= +#qworker +feature.runtimenotify.qworker.coresize=25 +feature.runtimenotify.qworker.maxsize=50 +feature.runtimenotify.qworker.bqsize=5 +feature.runtimenotify.qworker.keepalivetimeout=60000 +#nodeinfotimer +feature.runtimenotify.nodeinfotimer.enable=true +feature.runtimenotify.nodeinfotimer.period=15000 +#nodeinfoprocess +feature.runtimenotify.nodeinfoprocess.sendmq=true +feature.runtimenotify.nodeinfoprocess.exchange=false +#http service +feature.runtimenotify.rnswhandlers=com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerHandler +feature.runtimenotify.http.port=9001 +feature.runtimenotify.http.backlog=10 +feature.runtimenotify.http.core=5 +feature.runtimenotify.http.max=10 +feature.runtimenotify.http.bqsize=10 +#crash process timeout +feature.runtimenotify.crash.timeout=300000 +#in seconds, this is only for development now, the production is read from cache, see the above cache setting +#feature.runtimenotify.strategy.config={"server_hostState":{"conditions":[{"expr":"os.cpu.load>8",range:10,func:"avg"},{"expr":"os.cpu.load>5",range:10,func:"count>3"},"os.cpu.load>20"],scope:"M",context:[]},"server_procState":{"conditions":["cpu>5",{"expr":"cpu>2","range":2,"func":"avg"},{"expr":"memRate>5","range":10,"func":"avg"}],"scope":"M","context":[]}} +#sync interval from cache +feature.runtimenotify.strategy.interval=60000 +#in ms feature.runtimenotify.slice.config={"N":{"timerange":"600000","expire":"60000"},"M":{"timerange":"600000","expire":"60000"},"L":{"timerange":"60000","expire":"60000"}} \ No newline at end of file diff --git a/com.creditease.uav.upgrade/config/upgrade_pro.properties b/com.creditease.uav.upgrade/config/upgrade_pro.properties index efdac43d..d591b91f 100644 --- a/com.creditease.uav.upgrade/config/upgrade_pro.properties +++ b/com.creditease.uav.upgrade/config/upgrade_pro.properties @@ -1,47 +1,47 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10409 - -#upgrade -feature.upgradeagent.loader=default -feature.upgradeagent.enable=true -feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent -# the address of download server -feature.upgradeagent.http.server.host=127.0.0.1 -feature.upgradeagent.http.server.port=8888 -feature.upgradeagent.backup.count=3 -#when download request was refused by download center, try to retry sending request -feature.upgradeagent.download.retry.count=20 -#tell client that retry sending download request after x seconds +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10409 + +#upgrade +feature.upgradeagent.loader=default +feature.upgradeagent.enable=true +feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent +# the address of download server +feature.upgradeagent.http.server.host=127.0.0.1 +feature.upgradeagent.http.server.port=8888 +feature.upgradeagent.backup.count=3 +#when download request was refused by download center, try to retry sending request +feature.upgradeagent.download.retry.count=20 +#tell client that retry sending download request after x seconds feature.upgradeagent.download.retry.after=30 \ No newline at end of file diff --git a/com.creditease.uav.upgrade/config/upgrade_server.properties b/com.creditease.uav.upgrade/config/upgrade_server.properties index b4758663..3b781b56 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=D:/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=D:/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_server_pro.properties b/com.creditease.uav.upgrade/config/upgrade_server_pro.properties index 52b7ab4f..4400abac 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server_pro.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server_pro.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011,127.0.0.1:8011 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_server_test.properties b/com.creditease.uav.upgrade/config/upgrade_server_test.properties index 22eec421..45f4cd52 100644 --- a/com.creditease.uav.upgrade/config/upgrade_server_test.properties +++ b/com.creditease.uav.upgrade/config/upgrade_server_test.properties @@ -1,56 +1,56 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10500 - - -#upgrade server configuration -feature.upgradeserver.loader=default -feature.upgradeserver.enable=true -feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer -feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler -feature.upgradeserver.http.port=8888 -feature.upgradeserver.http.backlog=10 -feature.upgradeserver.http.bossgroup.size=2 -feature.upgradeserver.http.wokergroup.size=10 -feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages -#max count of download request can be handled at the same time -feature.upgradeserver.download.threshold=10 - -#upgrade server 1+n queue configuration -feature.upgradeserver.1nqworker.coresize=10 -feature.upgradeserver.1nqworker.maxsize=10 -feature.upgradeserver.1nqworker.bqsize=1 -feature.upgradeserver.1nqworker.keepalivetimeout=60000 - - +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u4e2d\u5fc3 + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10500 + + +#upgrade server configuration +feature.upgradeserver.loader=default +feature.upgradeserver.enable=true +feature.upgradeserver.components=com.creditease.uav.feature.upgrade.download.UpgradeDownloadServer +feature.upgradeserver.drhandlers=com.creditease.uav.feature.upgrade.download.UpgradeDownloadRequestHandler +feature.upgradeserver.http.port=8888 +feature.upgradeserver.http.backlog=10 +feature.upgradeserver.http.bossgroup.size=2 +feature.upgradeserver.http.wokergroup.size=10 +feature.upgradeserver.download.dir=/app/uav/uavupgrade/packages +#max count of download request can be handled at the same time +feature.upgradeserver.download.threshold=10 + +#upgrade server 1+n queue configuration +feature.upgradeserver.1nqworker.coresize=10 +feature.upgradeserver.1nqworker.maxsize=10 +feature.upgradeserver.1nqworker.bqsize=1 +feature.upgradeserver.1nqworker.keepalivetimeout=60000 + + diff --git a/com.creditease.uav.upgrade/config/upgrade_test.properties b/com.creditease.uav.upgrade/config/upgrade_test.properties index fd56531d..45ce71f2 100644 --- a/com.creditease.uav.upgrade/config/upgrade_test.properties +++ b/com.creditease.uav.upgrade/config/upgrade_test.properties @@ -1,47 +1,47 @@ -#log configuration -#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL -#log.fsize: Single Log File Size(MB) -log.level=DEBUG -log.debug=true -log.fsize=10 - -#config the datacenter id -meta.datacenterid=1 -#config the node type -#the node type means the deployed component name of UAV network -meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f - - -#heartbeatclientagent Agent Feature xxx -#feature.xxx.loader should be a jar file path or default -feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.hbclientagent.enable=true -#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes -feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent -#feature.xxx.properties for the feature, for example: =,=,... -feature.hbclientagent.properties= -#feature.monitoragent.hbhandlers for heartbeat handlers -feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler -feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 -feature.hbclientagent.interval=15000 - -#nodeoperagent -feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar -#feature.xxx.enable should enable this feature -feature.nodeoperagent.enable=true -feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10409 - -#upgrade -feature.upgradeagent.loader=default -feature.upgradeagent.enable=true -feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent -# the address of download server -feature.upgradeagent.http.server.host=127.0.0.1 -feature.upgradeagent.http.server.port=8888 -feature.upgradeagent.backup.count=3 -#when download request was refused by download center, try to retry sending request -feature.upgradeagent.download.retry.count=20 -#tell client that retry sending download request after x seconds +#log configuration +#log.level:INFO, ERR, WARNING, DEBUG, FINE, FINER, ALL +#log.fsize: Single Log File Size(MB) +log.level=DEBUG +log.debug=true +log.fsize=10 + +#config the datacenter id +meta.datacenterid=1 +#config the node type +#the node type means the deployed component name of UAV network +meta.nodetype=\u5347\u7ea7\u7a0b\u5e8f + + +#heartbeatclientagent Agent Feature xxx +#feature.xxx.loader should be a jar file path or default +feature.hbclientagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.hbclientagent.enable=true +#feature.xxx.components is the component classes (extends com.creditease.agent.spi.AgentFeatureComponent), separator "," for multiply classes +feature.hbclientagent.components=com.creditease.agent.feature.HeartBeatClientAgent +#feature.xxx.properties for the feature, for example: =,=,... +feature.hbclientagent.properties= +#feature.monitoragent.hbhandlers for heartbeat handlers +feature.hbclientagent.hbhandlers=com.creditease.agent.feature.hbagent.handlers.HBClientDefaultHandler +feature.hbclientagent.hbservers=127.0.0.1:8010,127.0.0.1:8010 +feature.hbclientagent.interval=15000 + +#nodeoperagent +feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar +#feature.xxx.enable should enable this feature +feature.nodeoperagent.enable=true +feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent +feature.nodeoperagent.http.port=10409 + +#upgrade +feature.upgradeagent.loader=default +feature.upgradeagent.enable=true +feature.upgradeagent.components=com.creditease.uav.feature.upgrade.UpgradeAgent +# the address of download server +feature.upgradeagent.http.server.host=127.0.0.1 +feature.upgradeagent.http.server.port=8888 +feature.upgradeagent.backup.count=3 +#when download request was refused by download center, try to retry sending request +feature.upgradeagent.download.retry.count=20 +#tell client that retry sending download request after x seconds feature.upgradeagent.download.retry.after=30 \ No newline at end of file From ea9c5969665c0ca36618d0aa4efc127bc8214489 Mon Sep 17 00:00:00 2001 From: xiaolong Date: Fri, 9 Feb 2018 12:58:42 +0800 Subject: [PATCH 13/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/190=201.scanWithConfigURLs=E6=B7=BB=E5=8A=A0=E5=AF=B9ip:port?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/monitoragent/detect/JVMContainerOSDetector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java index 172ae7e5..99279fee 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java @@ -211,7 +211,7 @@ private void scanWithConfigURLs() { for (String port : scanPorts) { - String baseurl = "http://127.0.0.1:" + port; + String baseurl = port.indexOf(":") == -1 ? "http://127.0.0.1:" + port : "http://" + port; client.doAsyncHttpGet(baseurl + UAV_MOF_ROOT + "jvm?action=ping", new ScanPingCallback(null, baseurl)); } From 720dda8ebb8fb80daf900625fd8af27f15f1c64c Mon Sep 17 00:00:00 2001 From: zhuang Date: Fri, 9 Feb 2018 13:00:41 +0800 Subject: [PATCH 14/97] support rocketmq invoke chain --- .../adapter/RocketMQProducerAdapter.java | 94 +++ .../adapter/RocketMQPullConsumerAdapter.java | 54 ++ .../adapter/RocketMQPushConsumerAdapter.java | 96 +++ .../rocketmq/interceptors/RocketmqIT.java | 795 ++++++++++-------- .../collect/SlowOperDataCollectHandler.java | 1 + .../slowoper/handlers/MQSlowOperHandler.java | 61 ++ .../apm/slowoper/spi/SlowOperConstants.java | 1 + .../uav/apm/supporters/SlowOperSupporter.java | 9 +- 8 files changed, 759 insertions(+), 352 deletions(-) create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQProducerAdapter.java create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPullConsumerAdapter.java create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPushConsumerAdapter.java create mode 100644 com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/MQSlowOperHandler.java diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQProducerAdapter.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQProducerAdapter.java new file mode 100644 index 00000000..8e11d113 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQProducerAdapter.java @@ -0,0 +1,94 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.rocketmq.adapter; + +import java.io.UnsupportedEncodingException; + +import com.alibaba.rocketmq.common.message.Message; +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.uav.apm.invokechain.span.Span; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; +import com.creditease.uav.apm.slowoper.spi.SlowOperConstants; +import com.creditease.uav.apm.slowoper.spi.SlowOperContext; + +/** + * RocketMQProducerAdapter description: RocketMQ Producer Adapter + * + */ +public class RocketMQProducerAdapter extends InvokeChainAdapter { + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + + context.put(InvokeChainConstants.CLIENT_IT_KEY, + DataConvertHelper.toInt(System.getProperty("com.creditease.uav.invokechain.code.mq.rocketmq.key"), 1)); + context.put(InvokeChainConstants.CLIENT_IT_CLASS, + System.getProperty("com.creditease.uav.invokechain.code.mq.rocketmq.class")); + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + + String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY); + Span span = this.spanFactory.getSpanFromContext(storeKey); + String spanMeta = this.spanFactory.getSpanMeta(span); + + Message msg = (Message) args[0]; + msg.putUserProperty(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, spanMeta); + + if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) { + SlowOperContext slowOperContext = new SlowOperContext(); + String content; + try { + content = new String(msg.getBody(), "UTF-8"); + } + catch (UnsupportedEncodingException e) { + content = "unsupported encoding,defalut is utf-8.try to set ContentEncoding to fit."; + } + slowOperContext.put(SlowOperConstants.PROTOCOL_MQ_RABBIT_BODY, content); + Object params[] = { span, slowOperContext }; + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", + span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params); + } + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + + if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) { + + Span span = (Span) context.get(InvokeChainConstants.PARAM_SPAN_KEY); + + Object params[] = { span }; + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", + span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.DOCAP, context, params); + } + } + +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPullConsumerAdapter.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPullConsumerAdapter.java new file mode 100644 index 00000000..68e4e929 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPullConsumerAdapter.java @@ -0,0 +1,54 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ +package com.creditease.uav.hook.rocketmq.adapter; + +import com.creditease.uav.apm.invokechain.span.Span; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; + +public class RocketMQPullConsumerAdapter extends InvokeChainAdapter { + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + + context.put(InvokeChainConstants.CLIENT_IT_KEY, 1); + context.put(InvokeChainConstants.CLIENT_IT_CLASS, "com.alibaba.rocketmq.client.consumer.Default*"); + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + + String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY); + Span span = this.spanFactory.getSpanFromContext(storeKey); + context.put(InvokeChainConstants.PARAM_SPAN_KEY, span); + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + + } + +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPushConsumerAdapter.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPushConsumerAdapter.java new file mode 100644 index 00000000..4de2474b --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/adapter/RocketMQPushConsumerAdapter.java @@ -0,0 +1,96 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ +package com.creditease.uav.hook.rocketmq.adapter; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +import com.alibaba.rocketmq.common.message.MessageExt; +import com.creditease.monitor.UAVServer; +import com.creditease.uav.apm.invokechain.span.Span; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; +import com.creditease.uav.apm.slowoper.spi.SlowOperConstants; +import com.creditease.uav.apm.slowoper.spi.SlowOperContext; + +public class RocketMQPushConsumerAdapter extends InvokeChainAdapter { + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + + if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) { + String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY); + Span span = this.spanFactory.getSpanFromContext(storeKey); + + if(span == null) { + return; + } + + @SuppressWarnings("unchecked") + List exts = (List) args[0]; + String content; + try { + content = new String(exts.get(0).getBody(), "UTF-8"); + } + catch (UnsupportedEncodingException e) { + content = "unsupported encoding,defalut is utf-8.try to set ContentEncoding to fit."; + } + SlowOperContext slowOperContext = new SlowOperContext(); + slowOperContext.put(SlowOperConstants.PROTOCOL_MQ_RABBIT_BODY, content); + Object params[] = { span, slowOperContext }; + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", + span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params); + } + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY); + Span span = this.spanFactory.getSpanFromContext(storeKey); + if (span != null) { + span.setClassName((String) context.get(InvokeChainConstants.CLIENT_IT_CLASS)); + span.setMethodName((String) context.get(InvokeChainConstants.CLIENT_IT_METHOD)); + } + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + + if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) { + + Span span = (Span) context.get(InvokeChainConstants.PARAM_SPAN_KEY); + + if(span == null) { + return; + } + + Object params[] = { span }; + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", + span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.DOCAP, context, params); + } + } +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java index 3b3e59aa..dec5f44c 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java @@ -1,348 +1,447 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.hook.rocketmq.interceptors; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; -import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer; -import com.alibaba.rocketmq.client.consumer.PullCallback; -import com.alibaba.rocketmq.client.consumer.listener.MessageListener; -import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently; -import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly; -import com.alibaba.rocketmq.client.producer.DefaultMQProducer; -import com.alibaba.rocketmq.common.message.Message; -import com.alibaba.rocketmq.common.message.MessageExt; -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.captureframework.spi.CaptureContext; -import com.creditease.monitor.captureframework.spi.Monitor; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; -import com.creditease.uav.common.BaseComponent; -import com.creditease.uav.util.JDKProxyInvokeUtil; - -public class RocketmqIT extends BaseComponent { - - private static final String targetServer = "rocketmq"; - - private Map ccMap; - - static final Map queueNameIndex = new HashMap(); - - static { - queueNameIndex.put("createTopic", 1); - queueNameIndex.put("fetchPublishMessageQueues", 0); - queueNameIndex.put("fetchMessageQueuesInBalance", 0); - queueNameIndex.put("queryMessage", 0); - queueNameIndex.put("subscribe", 0); - } - - private static ThreadLocal tl = new ThreadLocal(); - - private String applicationId; - - public RocketmqIT(String appid) { - this.applicationId = appid; - } - - public static Object start(String appid, Object mqClient, String methodName, Object[] args) { - - RocketmqIT m = new RocketmqIT(appid); - tl.set(m); - - // proxy the MessageListener - if ("registerMessageListener".equals(methodName)) { - - return messageListenerProxy(mqClient, args, m); - - } - return m.doBefore(mqClient, methodName, args); - - } - - public static void end(int rc, String methodName) { - - RocketmqIT m = tl.get(); - m.doAfter(rc); - tl.remove(); - } - - private static MessageListener messageListenerProxy(Object mqClient, Object[] args, RocketmqIT m) { - - MessageListener MessageListener = null; - if (MessageListenerConcurrently.class.isAssignableFrom(args[0].getClass())) { - MessageListener = JDKProxyInvokeUtil.newProxyInstance(MessageListenerConcurrently.class.getClassLoader(), - new Class[] { MessageListenerConcurrently.class }, - new JDKProxyInvokeHandler((MessageListenerConcurrently) args[0], - m.new MessageListenerConcurrentlyProxyProcessor(getServerAddr(mqClient)))); - } - else if (MessageListenerOrderly.class.isAssignableFrom(args[0].getClass())) { - MessageListener = JDKProxyInvokeUtil.newProxyInstance(MessageListenerOrderly.class.getClassLoader(), - new Class[] { MessageListenerOrderly.class }, - new JDKProxyInvokeHandler((MessageListenerOrderly) args[0], - m.new MessageListenerOrderlyProxyProcessor(getServerAddr(mqClient)))); - } - return MessageListener; - } - - public Object doBefore(Object mqClient, String methodName, Object args[]) { - - String address = getServerAddr(mqClient); - - String topic = getTopic(mqClient, methodName, args); - - String url = address + (null == topic ? "" : "/" + topic); - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, methodName); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client"); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=" + methodName, null); - } - - // proxy the PullCallback - if (methodName.equals("pull")) { - PullCallback callback = null; - - if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) { - callback = (PullCallback) args[args.length - 1]; - } - else if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) { - callback = (PullCallback) args[args.length - 2]; - } - if (null != callback) { - callback = JDKProxyInvokeUtil.newProxyInstance(PullCallback.class.getClassLoader(), - new Class[] { PullCallback.class }, - new JDKProxyInvokeHandler(callback, new PullCallbackProxyProcessor())); - ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint( - CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, ccMap); - return callback; - } - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - return null; - } - - private void doAfter(int rc) { - - if (rc != -1) { - doCap(rc, null); - } - } - - private void doCap(int rc, String contextTag) { - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (contextTag != null) { - params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, contextTag); - } - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params); - } - - private static String getServerAddr(Object mqClient) { - - String addr = "mq:rocket://"; - if (mqClient.getClass().getSimpleName().equals("DefaultMQProducer")) { - addr += ((DefaultMQProducer) mqClient).getNamesrvAddr(); - } - else if (mqClient.getClass().getSimpleName().equals("DefaultMQPushConsumer")) { - addr += ((DefaultMQPushConsumer) mqClient).getNamesrvAddr(); - } - else if (mqClient.getClass().getSimpleName().equals("DefaultMQPullConsumer")) { - addr += ((DefaultMQPullConsumer) mqClient).getNamesrvAddr(); - } - - return addr; - - } - - private String getTopic(Object mqClient, String methodName, Object args[]) { - - if ("send".equals(methodName)) { - Message message = (Message) args[0]; - return message.getTopic(); - } - else if (queueNameIndex.containsKey(methodName)) { - return (String) args[queueNameIndex.get(methodName)]; - } - return null; - } - - public class MessageListenerOrderlyProxyProcessor extends JDKProxyInvokeProcessor { - - private String address; - - public MessageListenerOrderlyProxyProcessor(String address) { - this.address = address; - } - - @SuppressWarnings("unchecked") - @Override - public void preProcess(MessageListenerOrderly t, Object proxy, Method method, Object[] args) { - - List msgs = (List) args[0]; - String url = address + "/" + msgs.get(0).getTopic(); - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); - params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, method.getName()); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - - } - - @Override - public void catchInvokeException(MessageListenerOrderly t, Object proxy, Method method, Object[] args, - Throwable e) { - - doCap(0, method.getName()); - - } - - @Override - public Object postProcess(Object res, MessageListenerOrderly t, Object proxy, Method method, Object[] args) { - - doCap(1, method.getName()); - return null; - } - - } - - public class MessageListenerConcurrentlyProxyProcessor - extends JDKProxyInvokeProcessor { - - private String address; - - public MessageListenerConcurrentlyProxyProcessor(String address) { - this.address = address; - } - - @SuppressWarnings("unchecked") - @Override - public void preProcess(MessageListenerConcurrently t, Object proxy, Method method, Object[] args) { - - List msgs = (List) args[0]; - String url = address + "/" + msgs.get(0).getTopic(); - - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client"); - params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, method.getName()); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - - } - - @Override - public void catchInvokeException(MessageListenerConcurrently t, Object proxy, Method method, Object[] args, - Throwable e) { - - doCap(0, method.getName()); - - } - - @Override - public Object postProcess(Object res, MessageListenerConcurrently t, Object proxy, Method method, - Object[] args) { - - doCap(1, method.getName()); - return null; - } - - } - - public class PullCallbackProxyProcessor extends JDKProxyInvokeProcessor { - - @Override - public void preProcess(PullCallback t, Object proxy, Method method, Object[] args) { - - } - - @Override - public void catchInvokeException(PullCallback t, Object proxy, Method method, Object[] args, Throwable e) { - - doAsyncCap(0); - - } - - @Override - public Object postProcess(Object res, PullCallback t, Object proxy, Method method, Object[] args) { - - if (method.getName().equals("onSuccess")) { - doAsyncCap(1); - } - else if (method.getName().equals("onException")) { - doAsyncCap(0); - } - - return null; - } - - public void doAsyncCap(int rc) { - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params, ccMap); - } - - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.rocketmq.interceptors; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; +import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer; +import com.alibaba.rocketmq.client.consumer.PullCallback; +import com.alibaba.rocketmq.client.consumer.listener.MessageListener; +import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly; +import com.alibaba.rocketmq.client.producer.DefaultMQProducer; +import com.alibaba.rocketmq.common.message.Message; +import com.alibaba.rocketmq.common.message.MessageExt; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.CaptureContext; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.hook.rocketmq.adapter.RocketMQProducerAdapter; +import com.creditease.uav.hook.rocketmq.adapter.RocketMQPullConsumerAdapter; +import com.creditease.uav.hook.rocketmq.adapter.RocketMQPushConsumerAdapter; +import com.creditease.uav.util.JDKProxyInvokeUtil; + +public class RocketmqIT extends BaseComponent { + + private static final String targetServer = "rocketmq"; + + private Map ccMap; + + static final Map queueNameIndex = new HashMap(); + + static { + queueNameIndex.put("createTopic", 1); + queueNameIndex.put("fetchPublishMessageQueues", 0); + queueNameIndex.put("fetchMessageQueuesInBalance", 0); + queueNameIndex.put("queryMessage", 0); + queueNameIndex.put("subscribe", 0); + } + + private static ThreadLocal tl = new ThreadLocal(); + + private String applicationId; + + private Map ivcContext; + + public RocketmqIT(String appid) { + + this.applicationId = appid; + } + + public static Object start(String appid, Object mqClient, String methodName, Object[] args) { + + RocketmqIT m = new RocketmqIT(appid); + tl.set(m); + + // proxy the MessageListener + if ("registerMessageListener".equals(methodName)) { + + return messageListenerProxy(mqClient, args, m); + + } + return m.doBefore(mqClient, methodName, args); + + } + + public static void end(int rc, String methodName) { + + RocketmqIT m = tl.get(); + m.doAfter(rc, methodName); + tl.remove(); + } + + private static MessageListener messageListenerProxy(Object mqClient, Object[] args, RocketmqIT m) { + + MessageListener MessageListener = null; + if (MessageListenerConcurrently.class.isAssignableFrom(args[0].getClass())) { + MessageListener = JDKProxyInvokeUtil.newProxyInstance(MessageListenerConcurrently.class.getClassLoader(), + new Class[] { MessageListenerConcurrently.class }, + new JDKProxyInvokeHandler((MessageListenerConcurrently) args[0], + m.new MessageListenerConcurrentlyProxyProcessor(getServerAddr(mqClient)))); + } + else if (MessageListenerOrderly.class.isAssignableFrom(args[0].getClass())) { + MessageListener = JDKProxyInvokeUtil.newProxyInstance(MessageListenerOrderly.class.getClassLoader(), + new Class[] { MessageListenerOrderly.class }, + new JDKProxyInvokeHandler((MessageListenerOrderly) args[0], + m.new MessageListenerOrderlyProxyProcessor(getServerAddr(mqClient)))); + } + return MessageListener; + } + + public Object doBefore(Object mqClient, String methodName, Object args[]) { + + String address = getServerAddr(mqClient); + + String topic = getTopic(mqClient, methodName, args); + + String url = address + (null == topic ? "" : "/" + topic); + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, methodName); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client"); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=" + methodName, null); + } + + // proxy the PullCallback + if (methodName.equals("pull")) { + PullCallback callback = null; + + if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) { + callback = (PullCallback) args[args.length - 1]; + } + else if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) { + callback = (PullCallback) args[args.length - 2]; + } + if (null != callback) { + callback = JDKProxyInvokeUtil.newProxyInstance(PullCallback.class.getClassLoader(), + new Class[] { PullCallback.class }, + new JDKProxyInvokeHandler(callback, new PullCallbackProxyProcessor())); + ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint( + CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, ccMap); + + // ivc + ivcContext = captureInvokeChain(RocketMQPullConsumerAdapter.class, + InvokeChainConstants.CapturePhase.PRECAP, params, args); + + return callback; + } + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + if (methodName.startsWith("send")) { + // ivc + ivcContext = captureInvokeChain(RocketMQProducerAdapter.class, InvokeChainConstants.CapturePhase.PRECAP, + params, args); + } + + return null; + } + + private void doAfter(int rc, String methodName) { + + if (rc != -1) { + doCap(rc, null); + + if (ivcContext != null) { + ivcContext.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + ivcContext.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if ("pull".equals(methodName)) { + captureInvokeChain(RocketMQPullConsumerAdapter.class, InvokeChainConstants.CapturePhase.DOCAP, + ivcContext, null); + } + else { + captureInvokeChain(RocketMQProducerAdapter.class, InvokeChainConstants.CapturePhase.DOCAP, + ivcContext, null); + } + + } + } + } + + private void doCap(int rc, String contextTag) { + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (contextTag != null) { + params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, contextTag); + } + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + } + + private static String getServerAddr(Object mqClient) { + + String addr = "mq:rocket://"; + if (mqClient.getClass().getSimpleName().equals("DefaultMQProducer")) { + addr += ((DefaultMQProducer) mqClient).getNamesrvAddr(); + } + else if (mqClient.getClass().getSimpleName().equals("DefaultMQPushConsumer")) { + addr += ((DefaultMQPushConsumer) mqClient).getNamesrvAddr(); + } + else if (mqClient.getClass().getSimpleName().equals("DefaultMQPullConsumer")) { + addr += ((DefaultMQPullConsumer) mqClient).getNamesrvAddr(); + } + + return addr; + + } + + private String getTopic(Object mqClient, String methodName, Object args[]) { + + if ("send".equals(methodName)) { + Message message = (Message) args[0]; + return message.getTopic(); + } + else if (queueNameIndex.containsKey(methodName)) { + return (String) args[queueNameIndex.get(methodName)]; + } + return null; + } + + public class MessageListenerOrderlyProxyProcessor extends JDKProxyInvokeProcessor { + + private String address; + + private Map ivcInnerContext; + + public MessageListenerOrderlyProxyProcessor(String address) { + + this.address = address; + } + + @SuppressWarnings("unchecked") + @Override + public void preProcess(MessageListenerOrderly t, Object proxy, Method method, Object[] args) { + + List msgs = (List) args[0]; + String url = address + "/" + msgs.get(0).getTopic(); + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); + params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, method.getName()); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + String ivcHeader = msgs.get(0).getProperty(InvokeChainConstants.PARAM_MQHEAD_SPANINFO); + if (ivcHeader != null) { + params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, ivcHeader); + } + ivcInnerContext = captureInvokeChain(RocketMQPushConsumerAdapter.class, + InvokeChainConstants.CapturePhase.PRECAP, params, args); + } + + @Override + public void catchInvokeException(MessageListenerOrderly t, Object proxy, Method method, Object[] args, + Throwable e) { + + doCap(0, method.getName()); + docapPushConsumerInvokeChain(ivcInnerContext, t.getClass().getName(), method.getName(), 0); + } + + @Override + public Object postProcess(Object res, MessageListenerOrderly t, Object proxy, Method method, Object[] args) { + + doCap(1, method.getName()); + docapPushConsumerInvokeChain(ivcInnerContext, t.getClass().getName(), method.getName(), 1); + return res; + } + + } + + public class MessageListenerConcurrentlyProxyProcessor + extends JDKProxyInvokeProcessor { + + private String address; + + private Map ivcInnerContext; + + public MessageListenerConcurrentlyProxyProcessor(String address) { + + this.address = address; + } + + @SuppressWarnings("unchecked") + @Override + public void preProcess(MessageListenerConcurrently t, Object proxy, Method method, Object[] args) { + + List msgs = (List) args[0]; + String url = address + "/" + msgs.get(0).getTopic(); + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client"); + params.put(CaptureConstants.INFO_CAPCONTEXT_TAG, method.getName()); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + String ivcHeader = msgs.get(0).getProperty(InvokeChainConstants.PARAM_MQHEAD_SPANINFO); + if (ivcHeader != null) { + params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, ivcHeader); + } + ivcInnerContext = captureInvokeChain(RocketMQPushConsumerAdapter.class, + InvokeChainConstants.CapturePhase.PRECAP, params, args); + } + + @Override + public void catchInvokeException(MessageListenerConcurrently t, Object proxy, Method method, Object[] args, + Throwable e) { + + doCap(0, method.getName()); + docapPushConsumerInvokeChain(ivcInnerContext, t.getClass().getName(), method.getName(), 0); + } + + @Override + public Object postProcess(Object res, MessageListenerConcurrently t, Object proxy, Method method, + Object[] args) { + + doCap(1, method.getName()); + docapPushConsumerInvokeChain(ivcInnerContext, t.getClass().getName(), method.getName(), 1); + return res; + } + + } + + public class PullCallbackProxyProcessor extends JDKProxyInvokeProcessor { + + @Override + public void preProcess(PullCallback t, Object proxy, Method method, Object[] args) { + + } + + @Override + public void catchInvokeException(PullCallback t, Object proxy, Method method, Object[] args, Throwable e) { + + doAsyncCap(0, t, method); + + } + + @Override + public Object postProcess(Object res, PullCallback t, Object proxy, Method method, Object[] args) { + + if (method.getName().equals("onSuccess")) { + doAsyncCap(1, t, method); + } + else if (method.getName().equals("onException")) { + doAsyncCap(0, t, method); + } + + return res; + } + + public void doAsyncCap(int rc, PullCallback target, Method method) { + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params, ccMap); + + if (ivcContext != null) { + ivcContext.putAll(params); + } + captureInvokeChain(RocketMQPullConsumerAdapter.class, InvokeChainConstants.CapturePhase.DOCAP, ivcContext, + null); + } + + } + + private void docapPushConsumerInvokeChain(Map ivcInnerContext, String className, String methodName, + int rc) { + + if (ivcInnerContext != null) { + ivcInnerContext.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + ivcInnerContext.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + ivcInnerContext.put(InvokeChainConstants.CLIENT_IT_CLASS, className); + ivcInnerContext.put(InvokeChainConstants.CLIENT_IT_METHOD, methodName); + } + captureInvokeChain(RocketMQPushConsumerAdapter.class, InvokeChainConstants.CapturePhase.DOCAP, ivcInnerContext, + null); + } + + @SuppressWarnings("unchecked") + private Map captureInvokeChain(Class adapter, + InvokeChainConstants.CapturePhase phase, Map ivcParams, Object[] args) { + + if (phase == InvokeChainConstants.CapturePhase.PRECAP) { + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", + "registerAdapter", adapter); + + return (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, phase, ivcParams, adapter, args); + } + else { + + if (ivcParams == null) { + return null; + } + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, phase, ivcParams, adapter, null); + } + + return null; + } + +} diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/SlowOperDataCollectHandler.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/SlowOperDataCollectHandler.java index 8ba18ec9..b030a5e2 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/SlowOperDataCollectHandler.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/SlowOperDataCollectHandler.java @@ -65,6 +65,7 @@ public SlowOperDataCollectHandler(String cName, String feature) { new SlowOperRpcAction("apache.http.AsyncClient", feature, engine); new SlowOperMQConsumerAction("mq.service", feature, engine); new SlowOperMQProducerAction("rabbitmq.client", feature, engine); + new SlowOperMQProducerAction("rocketmq.client", feature, engine); new SlowOperMethodAction("method", feature, engine); new SlowOperJdbcAction("jdbc.client", feature, engine); new SlowOperMethodAction("dubbo.provider", feature, engine, "dubbo"); diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/MQSlowOperHandler.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/MQSlowOperHandler.java new file mode 100644 index 00000000..ec23be44 --- /dev/null +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/MQSlowOperHandler.java @@ -0,0 +1,61 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.apm.slowoper.handlers; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.monitor.log.DataLogger; +import com.creditease.uav.apm.invokechain.span.Span; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; +import com.creditease.uav.apm.slowoper.span.SlowOperSpan; +import com.creditease.uav.apm.slowoper.spi.SlowOperConstants; +import com.creditease.uav.apm.slowoper.spi.SlowOperContext; + +/** + * MQSlowOperHandler description: MQ common slow operation handler + * + */ +public class MQSlowOperHandler extends AbstractSlowOperHandler { + + @Override + public void doCap(InvokeChainContext context, Object[] args) { + + Span span = (Span) args[0]; + DataLogger invokeChainLogger = this.getAppInvokeChainLogger(span.getAppid()); + if (invokeChainLogger == null) { + return; + } + SlowOperSpan slowOperSpan = this.spanFactory.getRemoveSlowOperSpanFromContext(this.getSlowOperSpanKey(span)); + if (slowOperSpan == null) { + return; + } + invokeChainLogger.logData(slowOperSpan.toString()); + } + + @Override + public void buildSpanContent(SlowOperContext slowOperContext, SlowOperSpan slowOperSpan) { + + String body = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_MQ_RABBIT_BODY); + // 限定采集的协议体的大小 + int bodyLength = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.mq.body"), 2000); + slowOperSpan.appendContent(body, bodyLength, true); + } + +} diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/spi/SlowOperConstants.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/spi/SlowOperConstants.java index f63624cf..e9a6ffbe 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/spi/SlowOperConstants.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/spi/SlowOperConstants.java @@ -36,6 +36,7 @@ private SlowOperConstants() { public static final String SLOW_OPER_HTTP_ASY_CLIENT = "apache.http.AsyncClient"; public static final String SLOW_OPER_MQ_RABBIT_CONSUMER = "mq.service"; public static final String SLOW_OPER_MQ_RABBIT_PRODUCER = "rabbitmq.client"; + public static final String SLOW_OPER_MQ_ROCKET = "rocketmq.client"; public static final String SLOW_OPER_JDBC_CLIENT = "jdbc.client"; public static final String SLOW_OPER_METHOD = "method"; public static final String SLOW_OPER_DUBBO_CONSUMER = "dubbo.consumer"; diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/supporters/SlowOperSupporter.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/supporters/SlowOperSupporter.java index a86f4573..69479325 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/supporters/SlowOperSupporter.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/supporters/SlowOperSupporter.java @@ -29,9 +29,8 @@ import com.creditease.uav.apm.slowoper.handlers.HttpClientSlowOperHandler; import com.creditease.uav.apm.slowoper.handlers.HttpServerSlowOperHandler; import com.creditease.uav.apm.slowoper.handlers.JdbcSlowOperHandler; +import com.creditease.uav.apm.slowoper.handlers.MQSlowOperHandler; import com.creditease.uav.apm.slowoper.handlers.MethodSlowOperHandler; -import com.creditease.uav.apm.slowoper.handlers.MqRabbitConsumerSlowOperHandler; -import com.creditease.uav.apm.slowoper.handlers.MqRabbitProducerSlowOperHandler; import com.creditease.uav.apm.slowoper.spi.SlowOperCapHandler; import com.creditease.uav.apm.slowoper.spi.SlowOperConstants; import com.creditease.uav.common.Supporter; @@ -68,10 +67,10 @@ public void start() { handlerMap.put(SlowOperConstants.SLOW_OPER_HTTP_ASY_CLIENT, new HttpClientSlowOperHandler()); // register 处理rabbit mq协议的consumer类型的handler - handlerMap.put(SlowOperConstants.SLOW_OPER_MQ_RABBIT_CONSUMER, new MqRabbitConsumerSlowOperHandler()); + handlerMap.put(SlowOperConstants.SLOW_OPER_MQ_RABBIT_CONSUMER, new MQSlowOperHandler()); // register 处理rabbit mq协议的producer类型的handler - handlerMap.put(SlowOperConstants.SLOW_OPER_MQ_RABBIT_PRODUCER, new MqRabbitProducerSlowOperHandler()); + handlerMap.put(SlowOperConstants.SLOW_OPER_MQ_RABBIT_PRODUCER, new MQSlowOperHandler()); // register 处理jdbc协议类型的handler handlerMap.put(SlowOperConstants.SLOW_OPER_JDBC_CLIENT, new JdbcSlowOperHandler()); @@ -84,6 +83,8 @@ public void start() { // register 处理dubbo provider类型的handler handlerMap.put(SlowOperConstants.SLOW_OPER_DUBBO_PROVIDER, new MethodSlowOperHandler()); + + handlerMap.put(SlowOperConstants.SLOW_OPER_MQ_ROCKET, new MQSlowOperHandler()); } @Override From e19ac75410e67dce52850b9d2a5c9054c9c811d6 Mon Sep 17 00:00:00 2001 From: zhuang Date: Fri, 9 Feb 2018 13:04:11 +0800 Subject: [PATCH 15/97] support rocketmq invoke chain --- .../creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java index dec5f44c..b7e0f0cd 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java @@ -444,4 +444,5 @@ private Map captureInvokeChain(Class Date: Fri, 9 Feb 2018 13:08:25 +0800 Subject: [PATCH 16/97] support rocketmq invoke chain --- .../creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java index b7e0f0cd..dec5f44c 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rocketmq/interceptors/RocketmqIT.java @@ -444,5 +444,4 @@ private Map captureInvokeChain(Class Date: Fri, 9 Feb 2018 14:21:49 +0800 Subject: [PATCH 17/97] https://github.com/uavorg/uavstack/issues/188 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apphub Related function add 1、Apphub添加log打点,,便于统计完整性:每隔5分钟输出一个点,这样日志归集到es后,通过查询可以分析出一天输出了多少了个点,以此来衡量完整性 2、添加Apphub数据透传,提供此功能,并且对数据经行AES CBC模式加密。当app应用菜单是跳转菜单时(非apphub自己的应用),会将加密后的码追加到url上,便于跳转的应用可选获取使用(使用需要对应的解密)。 3、Apphub节点操作限制时间调整:1分钟限制下降为3秒 --- .../nodeopagent/NodeOperCtrlHandler.java | 4 +- .../config/web_pro.xml | 13 +- .../config/web_test.xml | 13 +- .../uav/apphub/rest/GUIService.java | 39 ++++ .../uav/godeye/rest/GodEyeRestService.java | 4 +- .../creditease/uav/timer/TimerServlet.java | 90 ++++++++ .../src/main/webapp/WEB-INF/web.xml | 14 +- .../src/main/webapp/apphub/js/app.temp.js | 33 ++- .../webapp/apphub/js/uav.restful.client.js | 25 +++ .../agent/helpers/EncryptionHelper.java | 195 ++++++++++++++++++ 10 files changed, 406 insertions(+), 24 deletions(-) create mode 100644 com.creditease.uav.console/src/main/java/com/creditease/uav/timer/TimerServlet.java create mode 100644 com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/EncryptionHelper.java diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/NodeOperCtrlHandler.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/NodeOperCtrlHandler.java index 0f82a4f8..03c69617 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/NodeOperCtrlHandler.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/nodeopagent/NodeOperCtrlHandler.java @@ -66,9 +66,9 @@ public void handle(UAVHttpMessage data) { Long ts = actionLimits.get(intent); - if (ts != null && curTS - ts < 60000 + if (ts != null && curTS - ts < 1000 && (!"loadnodepro".equalsIgnoreCase(intent) && !"chgsyspro".equalsIgnoreCase(intent))) { - data.putResponse("rs", "该节点上的操作[" + intent + "]1分钟内只能进行一次"); + data.putResponse("rs", "该节点上的操作[" + intent + "]1秒内只能进行一次"); return; } diff --git a/com.creditease.uav.console.buildComponent/config/web_pro.xml b/com.creditease.uav.console.buildComponent/config/web_pro.xml index 0ac9f88c..86401c52 100644 --- a/com.creditease.uav.console.buildComponent/config/web_pro.xml +++ b/com.creditease.uav.console.buildComponent/config/web_pro.xml @@ -24,7 +24,15 @@ jersey-serlvet /rs/* + + + + apphubTimer + com.creditease.uav.timer.TimerServlet + 2 + + es-serlvet @@ -33,7 +41,7 @@ es.info {"forwar.url":"http://127.0.0.1:9200,http://127.0.0.1:9200"} - 2 + 3 true @@ -45,7 +53,7 @@ opentsdb-agent-servlet com.creditease.uav.opentsdb.OpenTSDBRestAgentServlet - 3 + 4 true @@ -62,7 +70,6 @@ /db2/ /db2/aggregators - diff --git a/com.creditease.uav.console.buildComponent/config/web_test.xml b/com.creditease.uav.console.buildComponent/config/web_test.xml index 1635f791..5ce34c6e 100644 --- a/com.creditease.uav.console.buildComponent/config/web_test.xml +++ b/com.creditease.uav.console.buildComponent/config/web_test.xml @@ -24,7 +24,15 @@ jersey-serlvet /rs/* + + + + apphubTimer + com.creditease.uav.timer.TimerServlet + 2 + + es-serlvet @@ -33,7 +41,7 @@ es.info {"forwar.url":"http://127.0.0.1:9200,http://127.0.0.1:9200"} - 2 + 3 true @@ -45,7 +53,7 @@ opentsdb-agent-servlet com.creditease.uav.opentsdb.OpenTSDBRestAgentServlet - 3 + 4 true @@ -62,7 +70,6 @@ /db2/ /db2/aggregators - diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java index 930f8e4d..bd5b0a59 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java @@ -50,6 +50,7 @@ import javax.ws.rs.container.Suspended; import javax.ws.rs.core.MediaType; +import com.creditease.agent.helpers.EncryptionHelper; import com.creditease.agent.helpers.IOHelper; import com.creditease.agent.helpers.JSONHelper; import com.creditease.agent.helpers.NetworkHelper; @@ -366,7 +367,45 @@ public void createValidataCode() throws Exception { CaptchaTools vcTools = new CaptchaTools(); vcTools.newVC(request.getSession(), response.getOutputStream()); } + + /** + * 获取apphub相关信息,并且经行AES CBC加密 + * + * 目前封装信息有:用户信息 + * + * @return + */ + @GET + @Path("loadApphubInfoByAES") + @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") + public String loadApphubInfoByAES() throws IOException { + HttpSession session = request.getSession(false); + Object userId = null == session ? null : session.getAttribute("apphub.gui.session.login.user.id"); + Map apphubInfo = new HashMap(); + if (null != userId) { + Object userGroup = null == session ? null : session.getAttribute("apphub.gui.session.login.user.group"); + Object emailList = null == session ? null : session.getAttribute("apphub.gui.session.login.user.emailList"); + Object emailAuthList = null == session ? null + : session.getAttribute("apphub.gui.session.login.user.authorize.emailList"); + Object systemAuthList = null == session ? null + : session.getAttribute("apphub.gui.session.login.user.authorize.systems"); + + apphubInfo.put("userId", String.valueOf(userId)); + apphubInfo.put("groupId", String.valueOf(userGroup)); + apphubInfo.put("emailList", String.valueOf(emailList)); + apphubInfo.put("emailAuthList", String.valueOf(emailAuthList)); + apphubInfo.put("systemAuthList", String.valueOf(systemAuthList)); + apphubInfo.put("timeStamp", String.valueOf(new Date().getTime())); + + } + + String strMsg = JSONHelper.toString(apphubInfo); + String resultStr = EncryptionHelper.encryptByAesCBC(strMsg, "UavappHubaEs_keY", false, "UavappHubaEs_keY", + "utf-8"); + return createResponeJson(RespCode.SUCCESS, "", resultStr); + } + // ------------------------------------------------以下为api支持-----------------------------------------------------------> /** diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java index 3710dad8..c000d1d9 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java @@ -2130,9 +2130,9 @@ public void doNodeCtrlOperation(String data, @Suspended AsyncResponse response) if (isCheckNodeOperSecurity == true) { Long ts = (Long) session.getAttribute("apphub.godeye.node.oper." + nodeUrl + ".timeout"); - if (ts != null && timeStamp - ts < 60000 && (!"loadnodepro".equalsIgnoreCase(msg.getIntent()) + if (ts != null && timeStamp - ts < 3000 && (!"loadnodepro".equalsIgnoreCase(msg.getIntent()) && !"chgsyspro".equalsIgnoreCase(msg.getIntent()))) { - response.resume("{\"rs\":\"ERR\",\"msg\":\"该节点操作1分钟内只能操作一次\"}"); + response.resume("{\"rs\":\"ERR\",\"msg\":\"该节点操作3秒内只能操作一次\"}"); return; } diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/timer/TimerServlet.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/timer/TimerServlet.java new file mode 100644 index 00000000..ef6ffaa9 --- /dev/null +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/timer/TimerServlet.java @@ -0,0 +1,90 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ +package com.creditease.uav.timer; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; + +import javax.servlet.http.HttpServlet; + +import com.creditease.agent.helpers.JSONHelper; +import com.creditease.agent.helpers.NetworkHelper; +import com.creditease.agent.log.SystemLogger; +import com.creditease.agent.log.api.ISystemLogger; + +/** + * TimerServlet description: apphub的任务调度 + */ +public class TimerServlet extends HttpServlet { + + private static final long serialVersionUID = 8252474547216672145L; + private ISystemLogger logger = null; + private Timer timer = null; + + @Override + public void init() { + + if (null == logger) { + logger = SystemLogger.getLogger(TimerServlet.class); + } + + if (null == timer) { + timer = new Timer(); + } + + timer.schedule(new LoggerPointTask(), 0, 1000 * 60);// 0秒后开始, 每次间隔1分钟 + + } + + @Override + public void destroy() { + + super.destroy(); + if (null != timer) { + timer.cancel(); + } + + } + + private class LoggerPointTask extends TimerTask { + + @Override + public void run() { + + SimpleDateFormat format = new SimpleDateFormat("mm"); + int minute = Integer.parseInt(format.format(new Date())); + int diff = minute % 5; + if (0 == diff) { + /** + * 当前分钟为5,10,15,20....55,60才会计数:1小时只有12条log打印 + */ + Map info = new HashMap(); + info.put("key", "apphubLogPoint"); + info.put("localIp", NetworkHelper.getLocalIP()); + logger.info(this, JSONHelper.toString(info)); + + } + } + } +} diff --git a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml index 97d26832..ab9a18ee 100644 --- a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml +++ b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml @@ -24,6 +24,15 @@ jersey-serlvet /rs/* + + + + + apphubTimer + com.creditease.uav.timer.TimerServlet + 2 + + es-serlvet @@ -32,7 +41,7 @@ es.info {"forwar.url":"http://localhost:9200"} - 2 + 3 true @@ -44,7 +53,7 @@ opentsdb-agent-servlet com.creditease.uav.opentsdb.OpenTSDBRestAgentServlet - 3 + 4 true @@ -61,7 +70,6 @@ /db2/ /db2/aggregators - diff --git a/com.creditease.uav.console/src/main/webapp/apphub/js/app.temp.js b/com.creditease.uav.console/src/main/webapp/apphub/js/app.temp.js index 319cc470..1231ef2a 100644 --- a/com.creditease.uav.console/src/main/webapp/apphub/js/app.temp.js +++ b/com.creditease.uav.console/src/main/webapp/apphub/js/app.temp.js @@ -24,6 +24,8 @@ function LoadSidebarMenu(appInfo){ var key = "jumpurl@"; var begin = clickUrl.indexOf(key)+key.length; clickUrl = clickUrl.substring(begin); + + window["sidebarMenuType"] = "jumpurl"; } paraA.setAttribute("onclick","javascript:sidebarMenuOnclick(this,'"+clickUrl+"','"+appInfo.menu[j].functions+"')"); @@ -54,7 +56,6 @@ function LoadNavbarMenu(appInfo){ function jumpUrl(url,desc){ guiPing_RSClient(jumpUrlCallBack(url),"menuclick",url,desc); - //jumpUrlCallBack(url); } function jumpUrlCallBack(url){ @@ -75,19 +76,29 @@ function jumpUrlCallBack(url){ */ setContentHeight(); - if(url.indexOf("?")==-1) { - url += "?r="+uavRandom(9999,1); /*刷新,处理缓存*/ - } - else { - url +="&r="+uavRandom(9999,1); /*刷新,处理缓存*/ - } - console.log(document.getElementById("appContent").contentWindow.document.body.innerText); + /** + * 用户数据穿透 begin + * + * 是跳转菜单,则获取apphub信息 ,因为跳转表示不是apphub自应用。 + * 如果是apphub自应用,不需要透传信息,因为都可以在自应用拿到。 + */ + if(window["sidebarMenuType"] && "jumpurl"==window["sidebarMenuType"] ){ + loadApphubInfoByAES_RSClient(); + if(url.indexOf("?")==-1) { + url += "?apphubkey="+window["apphubAesInfo"]; + } + else { + url +="&apphubkey="+window["apphubAesInfo"]; + } + } + /** + * 用户数据穿透 end + * @returns + */ document.getElementById("appContent").contentWindow.document.body.innerText = ""; - - console.log(document.getElementById("appContent").contentWindow.document.body.innerText); - + $("#appContent").attr("src",url); $("#navbar").removeClass("in"); diff --git a/com.creditease.uav.console/src/main/webapp/apphub/js/uav.restful.client.js b/com.creditease.uav.console/src/main/webapp/apphub/js/uav.restful.client.js index 5f5a3e3d..ea998488 100644 --- a/com.creditease.uav.console/src/main/webapp/apphub/js/uav.restful.client.js +++ b/com.creditease.uav.console/src/main/webapp/apphub/js/uav.restful.client.js @@ -227,6 +227,31 @@ function guiPing_RSClient(func,type,url,desc) { } +/** + * 获取apphub信息(信息经过加密) + * 同步方法,调用后会将结果写在window + */ +function loadApphubInfoByAES_RSClient() { + + AjaxHelper.call({ + url: restfulUrl +"loadApphubInfoByAES" , + data: {}, + async: false, + cache: false, + type: "GET", + dataType: "html", + success: function (result) { + var resultObj = eval("(" + result + ")"); + if (resultObj.CODE == "SUCCESS") { + window["apphubAesInfo"] = resultObj.DATA; + } + }, + error: function (result) { + reloadErrorContent("loadApphubInfoByAES_RSClient",result); + }, + }); +} + function loginOut_RSClient(){ AjaxHelper.call({ url: restfulUrl +"loginOut", diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/EncryptionHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/EncryptionHelper.java new file mode 100644 index 00000000..ae01d22b --- /dev/null +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/EncryptionHelper.java @@ -0,0 +1,195 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ +package com.creditease.agent.helpers; + +import java.security.SecureRandom; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +/** + * EncryptionHelper description: JAVA 加密工具类 + * + * 在线测试工具:http://tool.chacuo.net/cryptaes + */ +public class EncryptionHelper { + + /** + * + * AES CBC加密 + * + * 数据块:128位 + * + * @param strMsg + * : 需要加密的字符串 + * @param sKey + * :加密key(16位) + * @param sKeyFormat + * :skey是否格式处理 + * @param ivParameter + * :偏移量(16位)使用CBC模式,需要一个向量iv,可增加加密算法的强度 + * @param encoding + * :编码 + * @return :16进制的加密字符串 + */ + public static String encryptByAesCBC(String strMsg, String sKey, boolean sKeyFormat, String ivParameter, + String encoding) { + + try { + byte[] keyByte = null; + if (sKeyFormat) { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128, new SecureRandom(sKey.getBytes())); + SecretKey secretKey = kgen.generateKey(); + keyByte = secretKey.getEncoded(); + + } + else { + keyByte = sKey.getBytes(encoding); + } + + SecretKeySpec skeySpec = new SecretKeySpec(keyByte, "AES"); + IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes()); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");// 算法/模式/补码方式 + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); + byte[] resultByte = cipher.doFinal(strMsg.getBytes(encoding)); + + // 传输过程,转成16进制 + String resultStr = parseByte2HexStr(resultByte); + return resultStr; + } + catch (Exception ex) { + ex.printStackTrace(); + return ""; + } + } + + /** + * + * AES CBC解密 + * + * 数据块:128位 + * + * @param hexadecimalMsg + * :16进制的加密字符串 + * @param sKey + * :加密key(16位) + * @param sKeyFormat + * :skey是否格式处理 + * @param ivParameter + * :偏移量(16位)使用CBC模式,需要一个向量iv,可增加加密算法的强度 + * @param encoding + * :编码 + * @return :解密后字符串 + */ + public static String decryptByAesCBC(String hexadecimalMsg, String sKey, boolean sKeyFormat, String ivParameter, + String encoding) { + + try { + + byte[] keyByte = null; + if (sKeyFormat) { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128, new SecureRandom(sKey.getBytes())); + SecretKey secretKey = kgen.generateKey(); + keyByte = secretKey.getEncoded(); + } + else { + keyByte = sKey.getBytes(encoding); + } + + SecretKeySpec skeySpec = new SecretKeySpec(keyByte, "AES"); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");// 算法/模式/补码方式 + IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes()); + cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); + + byte[] msgByte = parseHexStr2Byte(hexadecimalMsg); + byte[] resultByte = cipher.doFinal(msgByte); + + return new String(resultByte, encoding); + } + catch (Exception ex) { + ex.printStackTrace(); + return ""; + } + } + + /** + * 将二进制转换成16进制 + * + * @param buf + * @return + */ + public static String parseByte2HexStr(byte buf[]) { + + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < buf.length; i++) { + String hex = Integer.toHexString(buf[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + sb.append(hex.toUpperCase()); + } + return sb.toString(); + } + + /** + * 将16进制转换为二进制 + * + * @param hexStr + * @return + */ + public static byte[] parseHexStr2Byte(String hexStr) { + + if (hexStr.length() < 1) + return null; + byte[] result = new byte[hexStr.length() / 2]; + for (int i = 0; i < hexStr.length() / 2; i++) { + int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); + int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); + result[i] = (byte) (high * 16 + low); + } + return result; + } + + public static void main(String[] args) throws Exception { + + String sKey = "UavappHubaEs_keY"; + boolean sKeyFormat = false; + String ivParameter = "UavappHubaEs_keY"; + String encoding = "utf-8"; + + // 需要加密的字串 + String str = "uavtestmsg测试信息:123456"; + System.out.println("\r\n加密前的字串:\r\n" + str); + // 加密 + String encryptStr = encryptByAesCBC(str, sKey, sKeyFormat, ivParameter, encoding); + System.out.println("\r\n加密后的字串:\r\n" + encryptStr); + + // 解密 + System.out.println("\r\n解密后的字串:\r\n" + decryptByAesCBC(encryptStr, sKey, sKeyFormat, ivParameter, encoding)); + } + +} From e3e2a6ed06c0216f4d2aebcef1401eb3535fde7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 9 Feb 2018 14:24:12 +0800 Subject: [PATCH 18/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/193=20=E5=8E=9F=E5=9B=A0=EF=BC=9AUAV=20Classloader=E9=9A=94?= =?UTF-8?q?=E7=A6=BB=E6=97=B6=E5=B0=86key=E4=B8=BA"org.uavstack.mof.ext.cl?= =?UTF-8?q?sloader"value=E4=B8=BAobject=E6=94=BE=E5=85=A5System.Properties?= =?UTF-8?q?=EF=BC=8Cstruts2=E9=83=A8=E5=88=86=E7=89=88=E6=9C=AC=EF=BC=88st?= =?UTF-8?q?ruts2-2.5.8=E7=AD=89=EF=BC=89=E5=9C=A8getProperties=E6=97=B6?= =?UTF-8?q?=E5=9B=A0value=E9=9D=9EString=E8=80=8Cget=E5=88=B0null=EF=BC=8C?= =?UTF-8?q?setProperty=E6=97=B6=E5=9B=A0null=E5=AF=BC=E8=87=B4=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=80=E5=87=BA=EF=BC=8C=E7=9B=AE=E5=89=8Dstruts?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=E5=B7=B2=E7=BB=8F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=AF=A5bug=E3=80=82=20=E4=BF=AE=E6=94=B9=EF=BC=9A=20?= =?UTF-8?q?=E5=9C=A8MOFAgent=E5=A2=9E=E5=8A=A0final=20static=E6=88=90?= =?UTF-8?q?=E5=91=98=EF=BC=9AmofContext=EF=BC=8C=E5=B0=86"org.uavstack.mof?= =?UTF-8?q?.ext.clsloader"=20put=E5=88=B0=E8=AF=A5=E6=88=90=E5=91=98?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=85=B6=E4=BD=99=E4=BD=BF=E7=94=A8=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E4=BB=8EmofContext=20get=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=B9=8B=E5=89=8Dsetproperties=E5=90=8Eget?= =?UTF-8?q?=E6=97=B6=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/creditease/uav/monitorframework/agent/MOFAgent.java | 4 ++++ .../uav/monitorframework/agent/interceptor/AbstractIT.java | 2 +- com.creditease.uav.monitorframework.dproxy/pom.xml | 4 ++++ .../uav/monitorframework/dproxy/DynamicProxyInstaller.java | 3 ++- .../uav/monitorframework/dproxy/bytecode/DPClass.java | 3 ++- .../uav/monitorframework/dproxy/bytecode/DPMethod.java | 3 ++- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/MOFAgent.java b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/MOFAgent.java index 83491dfd..b7dbb7fe 100644 --- a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/MOFAgent.java +++ b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/MOFAgent.java @@ -25,6 +25,8 @@ import java.lang.instrument.Instrumentation; import java.net.URL; import java.net.URLClassLoader; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarFile; import com.creditease.uav.monitorframework.agent.trans.MOFClsTransformer; @@ -38,6 +40,8 @@ * */ public class MOFAgent { + + public final static Map mofContext = new ConcurrentHashMap(); public static void premain(String agentArgs, Instrumentation inst) { diff --git a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/interceptor/AbstractIT.java b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/interceptor/AbstractIT.java index c02a94fa..1924e72e 100644 --- a/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/interceptor/AbstractIT.java +++ b/com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/agent/interceptor/AbstractIT.java @@ -141,7 +141,7 @@ protected void installMOFJars(ClassLoader clsLoader, String appSeverVendorName) + url.toString() + "]"); } - System.getProperties().put("org.uavstack.mof.ext.clsloader", mofExtClassloader); + MOFAgent.mofContext.put("org.uavstack.mof.ext.clsloader", mofExtClassloader); System.out.println("MOF.Interceptor[" + appSeverVendorName + "] Install MonitorFramework Jars End."); diff --git a/com.creditease.uav.monitorframework.dproxy/pom.xml b/com.creditease.uav.monitorframework.dproxy/pom.xml index 6f2b9663..601893ee 100644 --- a/com.creditease.uav.monitorframework.dproxy/pom.xml +++ b/com.creditease.uav.monitorframework.dproxy/pom.xml @@ -17,6 +17,10 @@ com.creditease.moniter com.creditease.uav.monitorframework + + com.creditease.moniter + com.creditease.uav.monitorframework.agent + org.javassist javassist diff --git a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/DynamicProxyInstaller.java b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/DynamicProxyInstaller.java index f22e334a..34a6929a 100644 --- a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/DynamicProxyInstaller.java +++ b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/DynamicProxyInstaller.java @@ -32,6 +32,7 @@ import com.creditease.agent.helpers.StringHelper; import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.monitorframework.agent.MOFAgent; import com.creditease.uav.monitorframework.dproxy.bytecode.DPClass; import com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod; @@ -81,7 +82,7 @@ public DynamicProxyInstaller() { /** * source code: pool = ClassPool.getDefault(); */ - mofExtClassLoader = (URLClassLoader) System.getProperties().get("org.uavstack.mof.ext.clsloader"); + mofExtClassLoader = (URLClassLoader) MOFAgent.mofContext.get("org.uavstack.mof.ext.clsloader"); pool = ReflectionHelper.invokeStatic("javassist.ClassPool", "getDefault", null, null, mofExtClassLoader); diff --git a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPClass.java b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPClass.java index ab0485c5..0f455b9c 100644 --- a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPClass.java +++ b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPClass.java @@ -42,6 +42,7 @@ import java.net.URLClassLoader; import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.uav.monitorframework.agent.MOFAgent; /** * DPClass description: ??? @@ -55,7 +56,7 @@ public class DPClass { public DPClass(Object ctClass) { - mofExtClassLoader = (URLClassLoader) System.getProperties().get("org.uavstack.mof.ext.clsloader"); + mofExtClassLoader = (URLClassLoader) MOFAgent.mofContext.get("org.uavstack.mof.ext.clsloader"); this.ctClass = ctClass; } diff --git a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPMethod.java b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPMethod.java index ada2e734..a831f5f9 100644 --- a/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPMethod.java +++ b/com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/dproxy/bytecode/DPMethod.java @@ -42,6 +42,7 @@ import java.net.URLClassLoader; import com.creditease.agent.helpers.ReflectionHelper; +import com.creditease.uav.monitorframework.agent.MOFAgent; /** * CtMethod description: deletegate class for Javassit CtMethod @@ -55,7 +56,7 @@ public class DPMethod { public DPMethod(Object ctMethod) { - mofExtClassLoader = (URLClassLoader) System.getProperties().get("org.uavstack.mof.ext.clsloader"); + mofExtClassLoader = (URLClassLoader) MOFAgent.mofContext.get("org.uavstack.mof.ext.clsloader"); this.ctMethod = ctMethod; } From ed3a8988b328f175b3bc79b2f81eabee0da8e457 Mon Sep 17 00:00:00 2001 From: chongli8 Date: Fri, 9 Feb 2018 17:49:20 +0800 Subject: [PATCH 19/97] invokechain support rocketmq. --- .../src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js | 2 +- .../creditease/uav/invokechain/http/SlowOperQueryHandler.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js index 8f545fa9..2a0dcac0 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js @@ -862,7 +862,7 @@ function APMTool(app) { var errMsg = "无数据,请刷新重试"; var epinfo = sObj["epinfo"].split(",")[0]; //当前支持的类型 - var epinfos = ["http.service","apache.http.Client","apache.http.AsyncClient","mq.service","rabbitmq.client","jdbc.client","method","dubbo.provider","dubbo.consumer"]; + var epinfos = ["http.service","apache.http.Client","apache.http.AsyncClient","mq.service","rabbitmq.client","jdbc.client","method","dubbo.provider","dubbo.consumer","rocketmq.client"]; if($.inArray(epinfo, epinfos)==-1){ errMsg = "不支持的数据类型"; } diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/SlowOperQueryHandler.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/SlowOperQueryHandler.java index 11c9389f..dbacd5b2 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/SlowOperQueryHandler.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/SlowOperQueryHandler.java @@ -64,6 +64,7 @@ public class SlowOperQueryHandler extends AbstractHttpHandler { typeMap.put("apache.http.AsyncClient", "rpc"); typeMap.put("mq.service", "mq"); typeMap.put("rabbitmq.client", "mq"); + typeMap.put("rocketmq.client", "mq"); typeMap.put("jdbc.client", "jdbc"); typeMap.put("method", "method"); typeMap.put("dubbo.provider", "dubbo"); @@ -77,6 +78,7 @@ public class SlowOperQueryHandler extends AbstractHttpHandler { } public SlowOperQueryHandler(String cName, String feature) { + super(cName, feature); client = (ESClient) this.getConfigManager().getComponent(this.feature, "ESClient"); From 8d3cd87d3d5fa9269b34b12e1a5cca092f0c1f64 Mon Sep 17 00:00:00 2001 From: chongli8 Date: Thu, 8 Mar 2018 10:37:08 +0800 Subject: [PATCH 20/97] support springboot method invoke chain --- .../apm/invokechain/listeners/InvokeChainClsInjectListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/listeners/InvokeChainClsInjectListener.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/listeners/InvokeChainClsInjectListener.java index 830c64fe..4085abe6 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/listeners/InvokeChainClsInjectListener.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/listeners/InvokeChainClsInjectListener.java @@ -260,6 +260,7 @@ public InvokeChainClsInjectListener() { public boolean isEventListener(Event event) { switch (event) { + case SPRING_BEAN_REGIST: case WEBCONTAINER_RESOURCE_INIT: case WEBCONTAINER_INIT: return true; From b53bd7997707a12357aff334cf8e393419f9bf0c Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 8 Mar 2018 10:52:00 +0800 Subject: [PATCH 21/97] https://github.com/uavorg/uavstack/issues/197 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #197 target jvm output dump when MA attach other user's jvm 1.modify method getAllVMsInfo,do not attch the jvm which is not started by the same user as ma. --- .../agent/helpers/JVMToolHelper.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java index a2254ac0..3b5a074c 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java @@ -34,6 +34,8 @@ import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Paths; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; @@ -59,6 +61,7 @@ public class JVMToolHelper { public static final String osname = System.getProperty("os.name").toLowerCase(); + public static final String username = System.getProperty("user.name"); public static final String JMX_CONNECTOR_ADDRESS = "com.sun.management.jmxremote.localConnectorAddress"; private static ClassLoader JVMToolClassloader = null; @@ -188,7 +191,12 @@ private static void getAllVMsInfo(JVMPropertyFilter filter, boolean needLocalAtt */ try { String id = (String) method_VMId.invoke(vmInstance, (Object[]) null); - + + //if the jvm is not started by the same user as MA, do not attach it (just in case of linux) + if(isLinux() && !username.equals(Files.getOwner(Paths.get(("/proc/"+id))).getName())) { + continue; + } + Object vm = method_AttachToVM.invoke(null, id); if (vm == null) { @@ -389,7 +397,17 @@ public static boolean isWindows() { return (osname.indexOf("win") > -1) ? true : false; } + + /** + * isLinux + * + * @return + */ + public static boolean isLinux() { + return (osname.indexOf("linux") > -1) ? true : false; + } + /** * getLineSeperator * From 123984806656b011dd99ab03ecff895613994210 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 8 Mar 2018 10:58:35 +0800 Subject: [PATCH 22/97] tab change to space --- .../main/java/com/creditease/agent/helpers/JVMToolHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java index 3b5a074c..8364a9cb 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java @@ -61,7 +61,7 @@ public class JVMToolHelper { public static final String osname = System.getProperty("os.name").toLowerCase(); - public static final String username = System.getProperty("user.name"); + public static final String username = System.getProperty("user.name"); public static final String JMX_CONNECTOR_ADDRESS = "com.sun.management.jmxremote.localConnectorAddress"; private static ClassLoader JVMToolClassloader = null; From 3726754ae02b8f0c81e52d437cbcf2ae6e016048 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Thu, 8 Mar 2018 10:59:41 +0800 Subject: [PATCH 23/97] tab change to space --- .../main/java/com/creditease/agent/helpers/JVMToolHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java index 8364a9cb..08fc45c1 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/JVMToolHelper.java @@ -192,7 +192,7 @@ private static void getAllVMsInfo(JVMPropertyFilter filter, boolean needLocalAtt try { String id = (String) method_VMId.invoke(vmInstance, (Object[]) null); - //if the jvm is not started by the same user as MA, do not attach it (just in case of linux) + //if the jvm is not started by the same user as MA, do not attach it (just in case of linux) if(isLinux() && !username.equals(Files.getOwner(Paths.get(("/proc/"+id))).getName())) { continue; } From 7c1b514fa10cc8c781314ebe3312d9c7d7fd610e Mon Sep 17 00:00:00 2001 From: duandehua Date: Fri, 9 Mar 2018 17:15:26 +0800 Subject: [PATCH 24/97] https://github.com/uavorg/uavstack/issues/202 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JpcapCaptor.openDevice()长时间采集,打开网卡设备过多; 解决方案: 及时关闭设备 --- .../procdetectagent/NetworkIoDetector.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java index f11c9fd9..8c0936cf 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java @@ -61,18 +61,19 @@ public void run() { // windows if (JVMToolHelper.isWindows()) { + JpcapCaptor jpcap =null; try { String Local_ip = "/" + ip; - // ˿ + // ��˿����� HashMap counter = new HashMap(); String[] split_ProtList = portList.split(" "); for (String str : split_ProtList) { counter.put("in_" + str, 0); counter.put("out_" + str, 0); } - // ȡ豸б + // ��ȡ�����豸�б� NetworkInterface[] devices = JpcapCaptor.getDeviceList(); - // ȷ豸ӿ + // ȷ�������豸�ӿ� boolean true_devices = false; int i = 0; for (; i < devices.length; i++) { @@ -88,17 +89,23 @@ public void run() { } } NetworkInterface nc = devices[i]; - // 豸 ijϵץȡ,Ϊ65535 - JpcapCaptor jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); - jpcap.setFilter("tcp", true);// ù + // �������豸 ������ij�������ϵ�ץȡ����,���Ϊ65535�� + jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); + jpcap.setFilter("tcp", true);// ���ù����� - // ץ ͳ + // ץ�� ͳ������ result = portFlux(jpcap, counter, nc, networkdetectTime, Local_ip); } catch (Exception e) { log.err(this, "NetworkIo Monitor runs FAIL.", e); } + finally { + if(jpcap!=null) { + // 关闭 + jpcap.close(); + } + } } @@ -157,16 +164,16 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw long time = Long.parseLong(networkdetectTime); long startTime = System.currentTimeMillis(); while (startTime + time >= System.currentTimeMillis()) { - // ץ + // ץ�� packet = jpcap.getPacket(); if (null == packet) { continue; } TCPPacket p = (TCPPacket) packet; - // ˿ڲprotList + // �˿ڲ���protList ���� String dst_ip = p.dst_ip.toString(); String src_ip = p.src_ip.toString(); - // ͳ + // ͳ��������� if (dst_ip.equals(Local_ip)) { String in_port = "in_" + p.dst_port; if (counter.containsKey(in_port)) { @@ -174,7 +181,7 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw counter.put(in_port, in_value); } } - // ͳƳ + // ͳ�Ƴ������� if (src_ip.equals(Local_ip)) { String out_port = "out_" + p.src_port; if (counter.containsKey(out_port)) { @@ -185,13 +192,13 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw } HashMap counterValueIntToString = new HashMap(); - // ֽתkb/s + // �ֽ�תkb/s for (String key : counter.keySet()) { DecimalFormat df = new DecimalFormat("#0.00"); Double value = Double.valueOf(df.format(counter.get(key) / int_networkdetectTime * 1.0)); counterValueIntToString.put(key, value.toString()); } - // hashmap תΪjson + // ��hashmap תΪjson ���� return JSONHelper.toString(counterValueIntToString); } From 6736ef144dfb55f14850d4a3601ca1adb7ac659f Mon Sep 17 00:00:00 2001 From: duandehua Date: Fri, 9 Mar 2018 17:35:04 +0800 Subject: [PATCH 25/97] =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../procdetectagent/NetworkIoDetector.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java index 8c0936cf..b3cec439 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java @@ -64,16 +64,16 @@ public void run() { JpcapCaptor jpcap =null; try { String Local_ip = "/" + ip; - // ��˿����� + // 存端口流量 HashMap counter = new HashMap(); String[] split_ProtList = portList.split(" "); for (String str : split_ProtList) { counter.put("in_" + str, 0); counter.put("out_" + str, 0); } - // ��ȡ�����豸�б� + // 获取网卡设备列表 NetworkInterface[] devices = JpcapCaptor.getDeviceList(); - // ȷ�������豸�ӿ� + // 确定网卡设备接口 boolean true_devices = false; int i = 0; for (; i < devices.length; i++) { @@ -89,11 +89,11 @@ public void run() { } } NetworkInterface nc = devices[i]; - // �������豸 ������ij�������ϵ�ץȡ����,���Ϊ65535�� + // 打开网卡设备 ,创建某个卡口上的抓取对象,最大为65535个 jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); - jpcap.setFilter("tcp", true);// ���ù����� + jpcap.setFilter("tcp", true);// 设置过滤器 - // ץ�� ͳ������ + // 抓包 统计流量 result = portFlux(jpcap, counter, nc, networkdetectTime, Local_ip); } @@ -101,11 +101,11 @@ public void run() { log.err(this, "NetworkIo Monitor runs FAIL.", e); } finally { - if(jpcap!=null) { + if (jpcap != null) { // 关闭 jpcap.close(); } - } + } } @@ -164,16 +164,16 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw long time = Long.parseLong(networkdetectTime); long startTime = System.currentTimeMillis(); while (startTime + time >= System.currentTimeMillis()) { - // ץ�� + // 抓包 packet = jpcap.getPacket(); if (null == packet) { continue; } TCPPacket p = (TCPPacket) packet; - // �˿ڲ���protList ���� + // 端口不在protList 忽略 String dst_ip = p.dst_ip.toString(); String src_ip = p.src_ip.toString(); - // ͳ��������� + // 统计入口流量 if (dst_ip.equals(Local_ip)) { String in_port = "in_" + p.dst_port; if (counter.containsKey(in_port)) { @@ -181,7 +181,7 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw counter.put(in_port, in_value); } } - // ͳ�Ƴ������� + // 统计出口流量 if (src_ip.equals(Local_ip)) { String out_port = "out_" + p.src_port; if (counter.containsKey(out_port)) { @@ -192,13 +192,13 @@ public String portFlux(JpcapCaptor jpcap, HashMap counter, Netw } HashMap counterValueIntToString = new HashMap(); - // �ֽ�תkb/s + // 字节转kb/s for (String key : counter.keySet()) { DecimalFormat df = new DecimalFormat("#0.00"); Double value = Double.valueOf(df.format(counter.get(key) / int_networkdetectTime * 1.0)); counterValueIntToString.put(key, value.toString()); } - // ��hashmap תΪjson ���� + // 将hashmap 转为json 返回 return JSONHelper.toString(counterValueIntToString); } From 381c5a6666f1a216a9cbce5d855ce526815a9d99 Mon Sep 17 00:00:00 2001 From: duandehua Date: Fri, 9 Mar 2018 18:13:05 +0800 Subject: [PATCH 26/97] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/feature/procdetectagent/NetworkIoDetector.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java index b3cec439..c33cf580 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java @@ -61,7 +61,6 @@ public void run() { // windows if (JVMToolHelper.isWindows()) { - JpcapCaptor jpcap =null; try { String Local_ip = "/" + ip; // 存端口流量 @@ -90,7 +89,7 @@ public void run() { } NetworkInterface nc = devices[i]; // 打开网卡设备 ,创建某个卡口上的抓取对象,最大为65535个 - jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); + JpcapCaptor jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); jpcap.setFilter("tcp", true);// 设置过滤器 // 抓包 统计流量 @@ -100,12 +99,6 @@ public void run() { catch (Exception e) { log.err(this, "NetworkIo Monitor runs FAIL.", e); } - finally { - if (jpcap != null) { - // 关闭 - jpcap.close(); - } - } } From 14372b15f3d12d0ed537e8d808524dbf487d1648 Mon Sep 17 00:00:00 2001 From: duandehua Date: Fri, 16 Mar 2018 10:00:55 +0800 Subject: [PATCH 27/97] https://github.com/uavorg/uavstack/issues/202 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JpcapCaptor.openDevice()长时间采集,打开网卡设备过多; 报错如下: com.creditease.agent.feature.procdetectagent.NetworkIoDetector.run(100) NetworkIo Monitor runs FAIL.java.io.IOException: Unable to open a device: 255 devices are already opened. at jpcap.JpcapCaptor.(JpcapCaptor.java:32) at jpcap.JpcapCaptor.openDevice(JpcapCaptor.java:61) at com.creditease.agent.feature.procdetectagent.NetworkIoDetector.run(NetworkIoDetector.java:92) at com.creditease.agent.workqueue.SystemTimerWorkMgr$1.run(SystemTimerWorkMgr.java:107) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) --- .../feature/procdetectagent/NetworkIoDetector.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java index c33cf580..dd90c00b 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procdetectagent/NetworkIoDetector.java @@ -60,7 +60,8 @@ public void run() { // windows if (JVMToolHelper.isWindows()) { - + + JpcapCaptor jpcap =null; try { String Local_ip = "/" + ip; // 存端口流量 @@ -89,7 +90,7 @@ public void run() { } NetworkInterface nc = devices[i]; // 打开网卡设备 ,创建某个卡口上的抓取对象,最大为65535个 - JpcapCaptor jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); + jpcap = JpcapCaptor.openDevice(nc, 65535, false, 20); jpcap.setFilter("tcp", true);// 设置过滤器 // 抓包 统计流量 @@ -99,6 +100,12 @@ public void run() { catch (Exception e) { log.err(this, "NetworkIo Monitor runs FAIL.", e); } + finally { + if(jpcap!=null) { + // 关闭 + jpcap.close(); + } + } } From cad236c478bab981aea3be6ed71e4cb9233df927 Mon Sep 17 00:00:00 2001 From: zwq0317 <1065009602@qq.com> Date: Fri, 16 Mar 2018 10:22:15 +0800 Subject: [PATCH 28/97] #206 fix NPE --- .../creditease/agent/profile/api/StandardProfileModeler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java b/com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java index 234d1114..04523219 100644 --- a/com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java +++ b/com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java @@ -1005,6 +1005,10 @@ private void getJAXRSURLs(String jaxrsBaseUrl, Map> compServ Map compDesInfo = (Map) compInfo.get("anno"); Map annoWebService = (Map) compDesInfo.get("javax.ws.rs.Path"); + + if (annoWebService == null) { + continue; + } String resourceClassRelativePath = (String) annoWebService.get("value"); From 341e9b12f428a5742852b54043bee260e7776c24 Mon Sep 17 00:00:00 2001 From: liceng9 Date: Fri, 16 Mar 2018 11:49:11 +0800 Subject: [PATCH 29/97] https://github.com/uavorg/uavstack/issues/208 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复方式:ReflectionHelper反射调用时传入webClassLoader 1. c3p0、hikari、mybatis、dbcp获取数据库线程池时数据时,传入WebClassLoader 2. buildFat添加mybatis测试代码 --- .../hook/jdbc/pools/c3p0/C3P0HookProxy.java | 5 +- .../hook/jdbc/pools/dbcp/DBCPHookProxy.java | 6 +- .../jdbc/pools/hikari/HikariHookProxy.java | 6 +- .../jdbc/pools/mybatis/MybatisHookProxy.java | 14 ++-- .../pom.xml | 8 +- .../monitorframework/fat/TestRestService.java | 45 +++++++++- .../monitorframework/fat/mybatis/User.java | 82 +++++++++++++++++++ .../fat/mybatis/UserMapper.xml | 15 ++++ .../fat/mybatis/mybatis-config.xml | 20 +++++ 9 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/User.java create mode 100644 com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/UserMapper.xml create mode 100644 com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/mybatis-config.xml diff --git a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/c3p0/C3P0HookProxy.java b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/c3p0/C3P0HookProxy.java index 5ee86f33..f7422158 100644 --- a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/c3p0/C3P0HookProxy.java +++ b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/c3p0/C3P0HookProxy.java @@ -96,8 +96,9 @@ private void collectDataSourceStat(MonitorElementInstance inst, ComboPooledDataS String prefix = "get"; for (int i = 0; i < collectMtrx.length; i++) { - inst.setValue(MTRX_PREFIX + collectMtrx[i], ReflectionHelper.invoke(ComboPooledDataSource.class.getName(), pds, - prefix + collectMtrx[i], null, null)); + Object obj = ReflectionHelper.invoke(ComboPooledDataSource.class.getName(), pds, + prefix + collectMtrx[i], null, null, this.getClass().getClassLoader()); + inst.setValue(MTRX_PREFIX + collectMtrx[i], obj); } } diff --git a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/dbcp/DBCPHookProxy.java b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/dbcp/DBCPHookProxy.java index ae1e65a4..c6faa58c 100644 --- a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/dbcp/DBCPHookProxy.java +++ b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/dbcp/DBCPHookProxy.java @@ -170,7 +170,7 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { cp.getClass().getClassLoader()); /** - * 匹配客户端应用 + * ƥͻӦ */ MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL); @@ -183,7 +183,7 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { } /** - * 收集DataSource性能指标 + * ռDataSourceָ * * @param inst * @param pds @@ -208,7 +208,7 @@ else if (className.indexOf("tomcat") > -1) { for (int i = 0; i < collectMtrx.length; i++) { - Object val = ReflectionHelper.invoke(className, pds, prefix + collectMtrx[i], null, null); + Object val = ReflectionHelper.invoke(className, pds, prefix + collectMtrx[i], null, null,this.getClass().getClassLoader()); if (val == null) { continue; diff --git a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/hikari/HikariHookProxy.java b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/hikari/HikariHookProxy.java index 4f9d0fd2..17c3bd2d 100644 --- a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/hikari/HikariHookProxy.java +++ b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/hikari/HikariHookProxy.java @@ -137,7 +137,7 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { cp.getClass().getClassLoader()); /** - * 匹配客户端应用 + * ƥͻӦ */ MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL); @@ -151,7 +151,7 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { } /** - * 收集DataSource指标 + * ռDataSourceָ * * @param inst * @param pds @@ -173,7 +173,7 @@ private void collectDataSourceStat(MonitorElementInstance inst, DataSource pds) for (int i = 0; i < collectMtrx.length; i++) { - Object val = ReflectionHelper.invoke(className, pool, prefix + collectMtrx[i], null, null); + Object val = ReflectionHelper.invoke(className, pool, prefix + collectMtrx[i], null, null,this.getClass().getClassLoader()); if (val == null) { continue; diff --git a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/mybatis/MybatisHookProxy.java b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/mybatis/MybatisHookProxy.java index c241214c..bdd6f718 100644 --- a/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/mybatis/MybatisHookProxy.java +++ b/com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/mybatis/MybatisHookProxy.java @@ -47,10 +47,9 @@ public class MybatisHookProxy extends AbsDBPoolHookProxy { protected DynamicProxyInstaller dpInstall; - private ClassLoader webapploaderForMybatis = null; - @SuppressWarnings("rawtypes") public MybatisHookProxy(String id, Map config) { + super(id, config); dpInstall = new DynamicProxyInstaller(); @@ -60,7 +59,6 @@ public MybatisHookProxy(String id, Map config) { public void start(HookContext context, ClassLoader webapploader) { super.start(context, webapploader); - webapploaderForMybatis = webapploader; Event event = context.get(Event.class); switch (event) { case SPRING_BEAN_REGIST: @@ -104,7 +102,7 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { continue; } - collectDataSourceStat(inst, cp, webapploaderForMybatis); + collectDataSourceStat(inst, cp); } } @@ -140,7 +138,7 @@ public void process(DPMethod m) throws Exception { dpInstall.releaseTargetClassLoader(); } - private void collectDataSourceStat(MonitorElementInstance inst, DataSource pds, ClassLoader webapploader) { + private void collectDataSourceStat(MonitorElementInstance inst, DataSource pds) { String[] collectMtrx = new String[] { "PoolMaximumActiveConnections", "PoolMaximumIdleConnections", "PoolMaximumCheckoutTime", "PoolTimeToWait", "ActiveConnections", "IdleConnections", "RequestCount", @@ -151,15 +149,15 @@ private void collectDataSourceStat(MonitorElementInstance inst, DataSource pds, int i; for (i = 0; i < 4; i++) { inst.setValue(MTRX_PREFIX + collectMtrx[i], - ReflectionHelper.invoke(className, pds, prefix + collectMtrx[i], null, null, webapploader)); + ReflectionHelper.invoke(className, pds, prefix + collectMtrx[i], null, null, this.getClass().getClassLoader())); } - Object poolState = ReflectionHelper.invoke(className, pds, "getPoolState", null, null, webapploader); + Object poolState = ReflectionHelper.invoke(className, pds, "getPoolState", null, null, this.getClass().getClassLoader()); for (; i < collectMtrx.length; i++) { inst.setValue(MTRX_PREFIX + collectMtrx[i], ReflectionHelper.invoke(PoolState.class.getName(), poolState, - prefix + collectMtrx[i], null, null, webapploader)); + prefix + collectMtrx[i], null, null, this.getClass().getClassLoader())); } } diff --git a/com.creditease.uav.monitorframework.buildFat/pom.xml b/com.creditease.uav.monitorframework.buildFat/pom.xml index f9fc1898..238974ae 100644 --- a/com.creditease.uav.monitorframework.buildFat/pom.xml +++ b/com.creditease.uav.monitorframework.buildFat/pom.xml @@ -63,6 +63,12 @@ 2.4.11 compile + + + org.mybatis + mybatis + 3.2.8 + org.glassfish.jersey.containers @@ -264,7 +270,7 @@ commons-httpclient 3.0.1 - + org.apache.struts struts2-core diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/TestRestService.java b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/TestRestService.java index c369fe07..37ef1bfb 100644 --- a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/TestRestService.java +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/TestRestService.java @@ -21,6 +21,7 @@ package com.creditease.monitorframework.fat; import java.io.IOException; +import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -47,6 +48,10 @@ import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.bson.Document; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -71,6 +76,7 @@ import com.creditease.monitorframework.fat.dbconnpool.DAOFactory.QueryHelper; import com.creditease.monitorframework.fat.dubbo.IMyDubboService; import com.creditease.monitorframework.fat.ivc.MyTestInjectObj; +import com.creditease.monitorframework.fat.mybatis.User; import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.cache.api.CacheManagerFactory; import com.creditease.uav.httpasync.HttpAsyncClient; @@ -837,6 +843,41 @@ public void testHikari() { } } + + SqlSession session; + + @GET + @Path("testMybatis") + public void testMybatis() { + + try{ + if (session == null) { + + String resource = "com/creditease/monitorframework/fat/mybatis/mybatis-config.xml"; + InputStream inputStream = Resources.getResourceAsStream(resource); + SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); + session = sqlSessionFactory.openSession(); + } + + User test = new User(); + test.setId(1); + test.setName("test"); + test.setAge(23); + + session.insert("com.creditease.monitorframework.fat.mybatis.UserMapper.insertUser", test); + + User blog = session.selectOne("com.creditease.monitorframework.fat.mybatis.UserMapper.selectUser", 1); + + session.delete("com.creditease.monitorframework.fat.mybatis.UserMapper.selectUser", 1); + + session.close(); + + }catch(Exception e) { + + e.printStackTrace(); + } + } + @POST @Path("testInjectClass") @@ -872,7 +913,7 @@ public void testInjectClass() { } - // 进行服务之间交互 + // з֮佻 CloseableHttpClient client = HttpClients.createDefault(); HttpUriRequest http = new HttpGet( "http://localhost:8080/com.creditease.uav.monitorframework.buildFat/rs/http/httpclienttest"); @@ -909,7 +950,7 @@ public void testInjectClass() { mongoClient.close(); - // 进行服务之间交互 + // з֮佻 CloseableHttpClient client2 = HttpClients.createDefault(); HttpUriRequest http2 = new HttpGet( diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/User.java b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/User.java new file mode 100644 index 00000000..ec151af6 --- /dev/null +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/User.java @@ -0,0 +1,82 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.monitorframework.fat.mybatis; + + +/** + * User description: ??? + * + */ +public class User { + + private int id; + private String name; + private int age; + + /** + * @return the id + */ + public int getId() { + + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + + this.name = name; + } + + /** + * @return the age + */ + public int getAge() { + + return age; + } + + /** + * @param age the age to set + */ + public void setAge(int age) { + + this.age = age; + } + +} diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/UserMapper.xml b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/UserMapper.xml new file mode 100644 index 00000000..c213fb94 --- /dev/null +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/UserMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/mybatis-config.xml b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/mybatis-config.xml new file mode 100644 index 00000000..ca1c1e55 --- /dev/null +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/mybatis/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file From 0a564a5b17d4539978a769dbaba385a8af362259 Mon Sep 17 00:00:00 2001 From: chongli8 Date: Fri, 16 Mar 2018 14:20:47 +0800 Subject: [PATCH 30/97] ttl support multiple interfaces --- .../java/com/alibaba/ttl/TtlRunnable.java | 160 ++++++++--- .../com/alibaba/ttl/TtlRunnableProxy.java | 58 ++++ .../ttl/MultipleInterfaceCallable.java | 59 ++++ .../ttl/MultipleInterfaceRunnable.java | 56 ++++ .../java/com/alibaba/ttl/SimpleCallable.java | 48 ++++ .../java/com/alibaba/ttl/SimpleThread.java | 2 +- .../java/com/alibaba/ttl/SimpleThread2.java | 7 +- .../src/test/java/com/alibaba/ttl/Test.java | 157 ----------- .../test/java/com/alibaba/ttl/TtlCase.java | 260 ++++++++++++++++++ 9 files changed, 611 insertions(+), 196 deletions(-) create mode 100644 com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnableProxy.java create mode 100644 com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceCallable.java create mode 100644 com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceRunnable.java create mode 100644 com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleCallable.java delete mode 100644 com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/Test.java create mode 100644 com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/TtlCase.java diff --git a/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnable.java b/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnable.java index c7a3a080..605d147a 100644 --- a/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnable.java +++ b/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnable.java @@ -20,16 +20,20 @@ package com.alibaba.ttl; +import java.lang.reflect.Proxy; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; -import java.util.Collections; /** - * {@link TtlRunnable} decorate {@link Runnable}, so as to get {@link TransmittableThreadLocal} - * and transmit it to the time of {@link Runnable} execution, needed when use {@link Runnable} to thread pool. + * {@link TtlRunnable} decorate {@link Runnable}, so as to get {@link TransmittableThreadLocal} and transmit it to the + * time of {@link Runnable} execution, needed when use {@link Runnable} to thread pool. *

* Use factory methods {@link #get} / {@link #gets} to create instance. * @@ -42,11 +46,13 @@ * @since 0.9.0 */ public final class TtlRunnable implements Runnable { + private final AtomicReference, Object>> copiedRef; private final Runnable runnable; private final boolean releaseTtlValueReferenceAfterRun; private TtlRunnable(Runnable runnable, boolean releaseTtlValueReferenceAfterRun) { + this.copiedRef = new AtomicReference, Object>>(TransmittableThreadLocal.copy()); this.runnable = runnable; this.releaseTtlValueReferenceAfterRun = releaseTtlValueReferenceAfterRun; @@ -57,6 +63,7 @@ private TtlRunnable(Runnable runnable, boolean releaseTtlValueReferenceAfterRun) */ @Override public void run() { + Map, Object> copied = copiedRef.get(); if (copied == null || releaseTtlValueReferenceAfterRun && !copiedRef.compareAndSet(copied, null)) { throw new IllegalStateException("TTL value reference is released after run!"); @@ -65,7 +72,8 @@ public void run() { Map, Object> backup = TransmittableThreadLocal.backupAndSetToCopied(copied); try { runnable.run(); - } finally { + } + finally { TransmittableThreadLocal.restoreBackup(backup); } } @@ -74,44 +82,57 @@ public void run() { * return original/unwrapped {@link Runnable}. */ public Runnable getRunnable() { + return runnable; } /** * Factory method, wrapper input {@link Runnable} to {@link TtlRunnable}. * - * @param runnable input {@link Runnable}. if input is {@code null}, return {@code null}. + * @param runnable + * input {@link Runnable}. if input is {@code null}, return {@code null}. * @return Wrapped {@link Runnable} - * @throws IllegalStateException when input is {@link TtlRunnable} already. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already. */ - public static TtlRunnable get(Runnable runnable) { + public static Runnable get(Runnable runnable) { + return get(runnable, false, false); } /** * Factory method, wrapper input {@link Runnable} to {@link TtlRunnable}. * - * @param runnable input {@link Runnable}. if input is {@code null}, return {@code null}. - * @param releaseTtlValueReferenceAfterRun release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. + * @param runnable + * input {@link Runnable}. if input is {@code null}, return {@code null}. + * @param releaseTtlValueReferenceAfterRun + * release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. * @return Wrapped {@link Runnable} - * @throws IllegalStateException when input is {@link TtlRunnable} already. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already. */ - public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun) { + public static Runnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun) { + return get(runnable, releaseTtlValueReferenceAfterRun, false); } /** * Factory method, wrapper input {@link Runnable} to {@link TtlRunnable}. * - * @param runnable input {@link Runnable}. if input is {@code null}, return {@code null}. - * @param releaseTtlValueReferenceAfterRun release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. - * @param idempotent is idempotent mode or not. if {@code true}, just return input {@link Runnable} when it's {@link TtlRunnable}, - * otherwise throw {@link IllegalStateException}. - * Caution: {@code true} will cover up bugs! DO NOT set, only when you know why. + * @param runnable + * input {@link Runnable}. if input is {@code null}, return {@code null}. + * @param releaseTtlValueReferenceAfterRun + * release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. + * @param idempotent + * is idempotent mode or not. if {@code true}, just return input {@link Runnable} when it's + * {@link TtlRunnable}, otherwise throw {@link IllegalStateException}. Caution: + * {@code true} will cover up bugs! DO NOT set, only when you know why. * @return Wrapped {@link Runnable} - * @throws IllegalStateException when input is {@link TtlRunnable} already and not idempotent. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already and not idempotent. */ - public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun, boolean idempotent) { + public static Runnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun, boolean idempotent) { + if (null == runnable) { return null; } @@ -120,55 +141,124 @@ public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenc if (idempotent) { // avoid redundant decoration, and ensure idempotency return (TtlRunnable) runnable; - } else { + } + else { throw new IllegalStateException("Already TtlRunnable!"); } } - return new TtlRunnable(runnable, releaseTtlValueReferenceAfterRun); + // 如果runnable的具体实现为java.util.concurrent.FutureTask,则认为是通过submit调用的execute + if (runnable.getClass().getName().equals("java.util.concurrent.FutureTask")) { + return new TtlRunnable(runnable, releaseTtlValueReferenceAfterRun); + } + // 如果runnable的具体实现类只实现了runnable接口,则无需使用代理 + Set> interfaces = getAllInterfaces(runnable.getClass(), true); + if (interfaces.size() == 1) { + return new TtlRunnable(runnable, releaseTtlValueReferenceAfterRun); + } + Class[] interfaceClass = new Class[interfaces.size()]; + int i = 0; + for (Class temp : interfaces) { + interfaceClass[i] = temp; + i++; + } + // 对于实现了除runnable接口以外的多接口现象的支持 + TtlRunnable ttlRunnable = new TtlRunnable(runnable, releaseTtlValueReferenceAfterRun); + return (Runnable) Proxy.newProxyInstance(runnable.getClass().getClassLoader(), interfaceClass, + new TtlRunnableProxy(ttlRunnable)); + } + + /** + * 获取当前类所有实现的接口 + * + * @param cls + * @param needSuper + * @return + */ + public static Set> getAllInterfaces(Class cls, boolean needSuper) { + + Set> ai = new HashSet>(); + + Class[] interfaces = cls.getInterfaces(); + + if (interfaces != null) { + ai.addAll(Arrays.asList(interfaces)); + } + + if (needSuper == false) { + return ai; + } + + Class superCls = cls.getSuperclass(); + while (superCls != null) { + + Class[] ifs = superCls.getInterfaces(); + + if (ifs != null) { + ai.addAll(Arrays.asList(ifs)); + } + + superCls = superCls.getSuperclass(); + } + + return ai; } /** * wrapper input {@link Runnable} Collection to {@link TtlRunnable} Collection. * - * @param tasks task to be wrapped. if input is {@code null}, return {@code null}. + * @param tasks + * task to be wrapped. if input is {@code null}, return {@code null}. * @return wrapped tasks - * @throws IllegalStateException when input is {@link TtlRunnable} already. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already. */ - public static List gets(Collection tasks) { + public static List gets(Collection tasks) { + return gets(tasks, false, false); } /** * wrapper input {@link Runnable} Collection to {@link TtlRunnable} Collection. * - * @param tasks task to be wrapped. if input is {@code null}, return {@code null}. - * @param releaseTtlValueReferenceAfterRun release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. + * @param tasks + * task to be wrapped. if input is {@code null}, return {@code null}. + * @param releaseTtlValueReferenceAfterRun + * release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. * @return wrapped tasks - * @throws IllegalStateException when input is {@link TtlRunnable} already. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already. */ - public static List gets(Collection tasks, boolean releaseTtlValueReferenceAfterRun) { + public static List gets(Collection tasks, boolean releaseTtlValueReferenceAfterRun) { + return gets(tasks, releaseTtlValueReferenceAfterRun, false); } /** * wrapper input {@link Runnable} Collection to {@link TtlRunnable} Collection. * - * @param tasks task to be wrapped. if input is {@code null}, return {@code null}. - * @param releaseTtlValueReferenceAfterRun release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. - * @param idempotent is idempotent mode or not. if {@code true}, just return input {@link Runnable} when it's {@link TtlRunnable}, - * otherwise throw {@link IllegalStateException}. - * Caution: {@code true} will cover up bugs! DO NOT set, only when you know why. + * @param tasks + * task to be wrapped. if input is {@code null}, return {@code null}. + * @param releaseTtlValueReferenceAfterRun + * release TTL value reference after run, avoid memory leak even if {@link TtlRunnable} is referred. + * @param idempotent + * is idempotent mode or not. if {@code true}, just return input {@link Runnable} when it's + * {@link TtlRunnable}, otherwise throw {@link IllegalStateException}. Caution: + * {@code true} will cover up bugs! DO NOT set, only when you know why. * @return wrapped tasks - * @throws IllegalStateException when input is {@link TtlRunnable} already and not idempotent. + * @throws IllegalStateException + * when input is {@link TtlRunnable} already and not idempotent. */ - public static List gets(Collection tasks, boolean releaseTtlValueReferenceAfterRun, boolean idempotent) { + public static List gets(Collection tasks, boolean releaseTtlValueReferenceAfterRun, + boolean idempotent) { + if (null == tasks) { return Collections.emptyList(); } - List copy = new ArrayList(); + List copy = new ArrayList(); for (Runnable task : tasks) { copy.add(TtlRunnable.get(task, releaseTtlValueReferenceAfterRun, idempotent)); } return copy; } + } diff --git a/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnableProxy.java b/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnableProxy.java new file mode 100644 index 00000000..482d2efe --- /dev/null +++ b/com.creditease.uav.ttl/src/main/java/com/alibaba/ttl/TtlRunnableProxy.java @@ -0,0 +1,58 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.alibaba.ttl; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * TtlRunnable动态代理类,适配当除实现runnable接口外其他接口情况 + * + */ +public class TtlRunnableProxy implements InvocationHandler { + + private TtlRunnable target; + + /** + * + */ + public TtlRunnableProxy(TtlRunnable target) { + + this.target = target; + } + + /* + * (non-Javadoc) + * + * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) + */ + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + + if (method.getName().equals("run")) { + return method.invoke(this.target, args); + } + else { + return method.invoke(this.target.getRunnable(), args); + } + } + +} diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceCallable.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceCallable.java new file mode 100644 index 00000000..e1ff7ca6 --- /dev/null +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceCallable.java @@ -0,0 +1,59 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.alibaba.ttl; + +import java.util.concurrent.Callable; + +public class MultipleInterfaceCallable implements Callable, Comparable { + + /* + * (non-Javadoc) + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(Runnable o) { + + return 0; + } + + private int id; + + public MultipleInterfaceCallable(int i) { + + this.id = i; + } + + /* + * (non-Javadoc) + * + * @see java.util.concurrent.Callable#call() + */ + @Override + public String call() throws Exception { + + System.out.println("before" + id + "---" + TtlCase.THREAD_LOCAL.get()); + TtlCase.THREAD_LOCAL.set(id + ""); + System.out.println("after" + id + "---" + TtlCase.THREAD_LOCAL.get()); + return "success"; + } + +} diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceRunnable.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceRunnable.java new file mode 100644 index 00000000..6ecc9b34 --- /dev/null +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/MultipleInterfaceRunnable.java @@ -0,0 +1,56 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.alibaba.ttl; + +public class MultipleInterfaceRunnable implements Runnable, Comparable { + + /* + * (non-Javadoc) + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(Runnable o) { + + return 0; + } + + private int id; + + public MultipleInterfaceRunnable(int i) { + + this.id = i; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Runnable#run() + */ + @Override + public void run() { + + System.out.println("before" + id + "---" + TtlCase.THREAD_LOCAL.get()); + TtlCase.THREAD_LOCAL.set(id + ""); + System.out.println("after" + id + "---" + TtlCase.THREAD_LOCAL.get()); + } + +} diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleCallable.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleCallable.java new file mode 100644 index 00000000..a89bea83 --- /dev/null +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleCallable.java @@ -0,0 +1,48 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.alibaba.ttl; + +import java.util.concurrent.Callable; + +public class SimpleCallable implements Callable { + + private int id; + + public SimpleCallable(int i) { + + this.id = i; + } + + /* + * (non-Javadoc) + * + * @see java.util.concurrent.Callable#call() + */ + @Override + public String call() throws Exception { + + System.out.println("before" + id + "---" + TtlCase.THREAD_LOCAL.get()); + TtlCase.THREAD_LOCAL.set(id + ""); + System.out.println("after" + id + "---" + TtlCase.THREAD_LOCAL.get()); + return "success"; + } + +} diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread.java index 249f02d3..a557781e 100644 --- a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread.java +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread.java @@ -26,7 +26,7 @@ public class SimpleThread implements Runnable { public void run() { // TODO Auto-generated method stub - System.out.println(Test.THREAD_LOCAL.get()); + System.out.println(TtlCase.THREAD_LOCAL.get()); } } diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread2.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread2.java index b540251c..a878115e 100644 --- a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread2.java +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/SimpleThread2.java @@ -25,15 +25,16 @@ public class SimpleThread2 implements Runnable { private int id; public SimpleThread2(int i) { + this.id = i; } @Override public void run() { - System.out.println("before" + id + "---" + Test.THREAD_LOCAL.get()); - Test.THREAD_LOCAL.set(id + ""); - System.out.println("after" + id + "---" + Test.THREAD_LOCAL.get()); + System.out.println("before" + id + "---" + TtlCase.THREAD_LOCAL.get()); + TtlCase.THREAD_LOCAL.set(id + ""); + System.out.println("after" + id + "---" + TtlCase.THREAD_LOCAL.get()); } } diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/Test.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/Test.java deleted file mode 100644 index 8a414271..00000000 --- a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/Test.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.alibaba.ttl; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class Test { - - public static final InheritableThreadLocal THREAD_LOCAL = new InheritableThreadLocal(); - - // public static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); - - // public static final TransmittableThreadLocal THREAD_LOCAL = new TransmittableThreadLocal(); - - public static void main(String[] args) { - - Test test = new Test(); - // Test.THREAD_LOCAL.set("lichong"); - // System.out.println(Test.THREAD_LOCAL.get()); - // test.testSimpleThread(); - // test.testThreadPool(); - // Test.THREAD_LOCAL.set("lichong2"); - // System.out.println(Test.THREAD_LOCAL.get()); - // test.testSimpleThread(); - // test.testThreadPool(); - // - // test.testThreadPool2(); - // System.out.println(Test.THREAD_LOCAL.get()); - // - // test.testThreadPool3(); - // System.out.println(Test.THREAD_LOCAL.get()); - - test.testThreadPool4(); - System.out.println(Test.THREAD_LOCAL.get()); - } - - public void testSimpleThread() { - - System.out.println(); - Thread thread = new Thread(new SimpleThread()); - thread.start(); - } - - public void testThreadPool() { - - System.out.println(); - ExecutorService service = Executors.newFixedThreadPool(2); - for (int i = 0; i < 10; i++) { - service.submit(new SimpleThread()); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - service.shutdown(); - - } - - public void testThreadPool2() { - - System.out.println(); - ExecutorService service = Executors.newFixedThreadPool(2); - for (int i = 0; i < 10; i++) { - service.submit(new SimpleThread2(i)); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - service.shutdown(); - } - - public void testThreadPool3() { - - System.out.println(); - ExecutorService service = Executors.newFixedThreadPool(2); - for (int i = 0; i < 10; i++) { - service.submit(new SimpleThread2(i)); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Test.THREAD_LOCAL.set("success"); - System.out.println("当前的threadlocal是" + Test.THREAD_LOCAL.get()); - for (int i = 0; i < 10; i++) { - Test.THREAD_LOCAL.set("success" + i); - service.submit(TtlRunnable.get(new SimpleThread2(i))); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - service.shutdown(); - } - - public void testThreadPool4() { - - System.out.println(); - ExecutorService service = Executors.newFixedThreadPool(2); - for (int i = 0; i < 10; i++) { - service.submit(new SimpleThread2(i)); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Test.THREAD_LOCAL.set("success"); - System.out.println("当前的threadlocal是" + Test.THREAD_LOCAL.get()); - for (int i = 0; i < 10; i++) { - Test.THREAD_LOCAL.set("success" + i); - service.submit(new SimpleThread2(i)); - } - try { - Thread.sleep(5 * 1000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - service.shutdown(); - } -} diff --git a/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/TtlCase.java b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/TtlCase.java new file mode 100644 index 00000000..261098bb --- /dev/null +++ b/com.creditease.uav.ttl/src/test/java/com/alibaba/ttl/TtlCase.java @@ -0,0 +1,260 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.alibaba.ttl; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.PriorityBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class TtlCase { + + // public static final InheritableThreadLocal THREAD_LOCAL = new InheritableThreadLocal(); + + // public static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); + + public static final TransmittableThreadLocal THREAD_LOCAL = new TransmittableThreadLocal(); + + public static void main(String[] args) { + + TtlCase test = new TtlCase(); + TtlCase.THREAD_LOCAL.set("test"); + System.out.println(TtlCase.THREAD_LOCAL.get()); + test.testSimpleThread(); + test.testThreadPool(); + TtlCase.THREAD_LOCAL.set("test2"); + System.out.println(TtlCase.THREAD_LOCAL.get()); + test.testSimpleThread(); + test.testThreadPool(); + + test.testThreadPool2(); + System.out.println(TtlCase.THREAD_LOCAL.get()); + + test.testThreadPool3(); + System.out.println(TtlCase.THREAD_LOCAL.get()); + + test.testThreadPool4(); + System.out.println(TtlCase.THREAD_LOCAL.get()); + + test.testMultipleRunnable(); + System.out.println(TtlCase.THREAD_LOCAL.get()); + + test.testSimpleCallable(); + System.out.println(TtlCase.THREAD_LOCAL.get()); + // 这种存在就是错误的 + // test.testMultipleCallable(); + // System.out.println(Test.THREAD_LOCAL.get()); + } + + public void testSimpleThread() { + + System.out.println(); + Thread thread = new Thread(new SimpleThread()); + thread.start(); + } + + public void testThreadPool() { + + System.out.println(); + ExecutorService service = Executors.newFixedThreadPool(2); + for (int i = 0; i < 10; i++) { + service.submit(new SimpleThread()); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + + } + + public void testThreadPool2() { + + System.out.println(); + ExecutorService service = Executors.newFixedThreadPool(2); + for (int i = 0; i < 10; i++) { + service.submit(new SimpleThread2(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + } + + public void testThreadPool3() { + + System.out.println(); + ExecutorService service = Executors.newFixedThreadPool(2); + for (int i = 0; i < 10; i++) { + service.submit(new SimpleThread2(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + TtlCase.THREAD_LOCAL.set("success"); + System.out.println("当前的threadlocal是" + TtlCase.THREAD_LOCAL.get()); + for (int i = 0; i < 10; i++) { + TtlCase.THREAD_LOCAL.set("success" + i); + service.submit(TtlRunnable.get(new SimpleThread2(i))); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + } + + public void testThreadPool4() { + + System.out.println(); + ExecutorService service = Executors.newFixedThreadPool(2); + for (int i = 0; i < 10; i++) { + service.submit(new SimpleThread2(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + TtlCase.THREAD_LOCAL.set("success"); + System.out.println("当前的threadlocal是" + TtlCase.THREAD_LOCAL.get()); + for (int i = 0; i < 10; i++) { + TtlCase.THREAD_LOCAL.set("success" + i); + service.submit(new SimpleThread2(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + } + + public void testMultipleRunnable() { + + ExecutorService service = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new PriorityBlockingQueue(100)); + + for (int i = 0; i < 10; i++) { + service.execute(new MultipleInterfaceRunnable(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + TtlCase.THREAD_LOCAL.set("success"); + System.out.println("当前的threadlocal是" + TtlCase.THREAD_LOCAL.get()); + for (int i = 0; i < 10; i++) { + TtlCase.THREAD_LOCAL.set("success" + i); + service.execute(new MultipleInterfaceRunnable(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + } + + public void testSimpleCallable() { + + System.out.println(); + ExecutorService service = Executors.newFixedThreadPool(5); + for (int i = 0; i < 10; i++) { + service.submit(new SimpleCallable(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + TtlCase.THREAD_LOCAL.set("success"); + System.out.println("当前的threadlocal是" + TtlCase.THREAD_LOCAL.get()); + for (int i = 0; i < 10; i++) { + TtlCase.THREAD_LOCAL.set("success" + i); + service.submit(new SimpleCallable(i)); + } + try { + Thread.sleep(5 * 1000); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + service.shutdown(); + } + + // 这种形式写法即为错误 + public void testMultipleCallable() { + + // ExecutorService service = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new PriorityBlockingQueue(100)); + // + // for (int i = 0; i < 10; i++) { + // service.submit(new MultipleInterfaceCallable(i)); + // } + // try { + // Thread.sleep(5 * 1000); + // } + // catch (InterruptedException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // Test.THREAD_LOCAL.set("success"); + // System.out.println("当前的threadlocal是" + Test.THREAD_LOCAL.get()); + // for (int i = 0; i < 10; i++) { + // Test.THREAD_LOCAL.set("success" + i); + // service.submit(new MultipleInterfaceCallable(i)); + // } + // try { + // Thread.sleep(5 * 1000); + // } + // catch (InterruptedException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // service.shutdown(); + } +} From 1e4aa7cd00de834cc0a459fe5d2a827266da231f Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 16 Mar 2018 14:53:00 +0800 Subject: [PATCH 31/97] https://github.com/uavorg/uavstack/issues/212 #212 issues occur when enable both http&&jmx detect 1.change MOF's default datastore mode to http 2.mscp default use jmx mode 3.http detector and jmx detector share a same detect worker pool --- .../config/ma_pro.properties | 2 +- .../config/ma_test.properties | 2 +- .../feature/monitoragent/detect/BaseDetector.java | 10 +++++++++- .../feature/monitoragent/detect/DetectorManager.java | 6 ++++++ .../config/uav.properties | 2 +- .../creditease/monitor/datastore/DataObserver.java | 11 +++++++++++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties index 53e0c3d9..5404aa36 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties @@ -104,7 +104,7 @@ feature.monitoragent.detector.interval=30000 #enable local scan by jvm tool and jmx feature.monitoragent.detector.local.scan.enable=true #enable container scan by http -feature.monitoragent.detector.container.scan.enable=false +feature.monitoragent.detector.container.scan.enable=true #container ports feature.monitoragent.detector.container.ports= #monitoragent detect interval default is 15000 diff --git a/com.creditease.uav.agent.buildComponent/config/ma_test.properties b/com.creditease.uav.agent.buildComponent/config/ma_test.properties index 4dbffb7b..7fba8958 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_test.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_test.properties @@ -104,7 +104,7 @@ feature.monitoragent.detector.interval=30000 #enable local scan by jvm tool and jmx feature.monitoragent.detector.local.scan.enable=true #enable container scan by http -feature.monitoragent.detector.container.scan.enable=false +feature.monitoragent.detector.container.scan.enable=true #container ports feature.monitoragent.detector.container.ports= #monitoragent detect interval default is 15000 diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java index 4fdb3672..5d8218a7 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java @@ -47,7 +47,7 @@ public abstract class BaseDetector protected final Map workerTypeClsMap = new ConcurrentHashMap(); - protected final Map workers = new ConcurrentHashMap(); + protected Map workers; protected final Map jvmAgentInfos = new ConcurrentHashMap(); @@ -262,5 +262,13 @@ protected String matchJVMType(JVMAgentInfo appServerInfo) throws RuntimeExceptio } return jvmType; + } + + /** + * @param set the workers + */ + protected void setWorkers(Map workers) { + + this.workers = workers; } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/DetectorManager.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/DetectorManager.java index 2de7d9b3..0dba27f0 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/DetectorManager.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/DetectorManager.java @@ -22,7 +22,9 @@ import java.util.LinkedHashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker; import com.creditease.agent.helpers.DataConvertHelper; import com.creditease.agent.helpers.jvmtool.JVMAgentInfo; import com.creditease.agent.spi.AbstractTimerWork; @@ -32,6 +34,8 @@ public class DetectorManager extends AbstractTimerWork { protected final Map detectorMap = new LinkedHashMap(); + + protected final Map workers = new ConcurrentHashMap(); public DetectorManager(String cName, String feature) { super(cName, feature); @@ -43,6 +47,8 @@ public void installDetector(BaseDetector detector) { return; } + detector.setWorkers(workers); + detectorMap.put(detector.getName(), detector); } diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index af5c6ca6..68ba24b5 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -50,7 +50,7 @@ com.creditease.uav.profile.eleminst.limit=100 com.creditease.uav.profile.eleminst.client.urls.limit=500 #dataobserver workmodel -com.creditease.uav.dataobserver.workmodel=jmx +com.creditease.uav.dataobserver.workmodel=http #invokechain com.creditease.uav.invokechain.logroot=/data/uav/ivc diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java index 8d1b15e8..3c13a60d 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java @@ -25,6 +25,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.UAVServer.ServerVendor; +import com.creditease.monitor.captureframework.spi.CaptureConstants; import com.creditease.monitor.captureframework.spi.Monitor; import com.creditease.monitor.datastore.http.HttpDataObserverWorker; import com.creditease.monitor.datastore.jmx.JMXDataObserverWorker; @@ -65,6 +68,14 @@ public void start(WorkModel workModel) { default: break; } + + /** + * To Be Refined, MSCP now doesn't support HTTP mode + */ + if(UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR) == ServerVendor.MSCP){ + worker = new JMXDataObserverWorker(); + } + if (worker != null) { worker.start(); } From afe5f7c8786a713cd276957e57f05f1b7a2333a2 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 16 Mar 2018 14:55:36 +0800 Subject: [PATCH 32/97] refine format --- .../agent/feature/monitoragent/detect/BaseDetector.java | 2 +- .../java/com/creditease/monitor/datastore/DataObserver.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java index 5d8218a7..9e05b686 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java @@ -264,7 +264,7 @@ protected String matchJVMType(JVMAgentInfo appServerInfo) throws RuntimeExceptio return jvmType; } - /** + /** * @param set the workers */ protected void setWorkers(Map workers) { diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java index 3c13a60d..1a94695e 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/datastore/DataObserver.java @@ -69,7 +69,7 @@ public void start(WorkModel workModel) { break; } - /** + /** * To Be Refined, MSCP now doesn't support HTTP mode */ if(UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR) == ServerVendor.MSCP){ From 816cefe4f78ccc5e6171b3477bae90ffe42c583b Mon Sep 17 00:00:00 2001 From: xiaolong Date: Fri, 16 Mar 2018 15:21:32 +0800 Subject: [PATCH 33/97] https://github.com/uavorg/uavstack/issues/214 1.struts2 profile support filter define config parameter --- .../handlers/ComponentProfileHandler.java | 99 ++++++++++++++----- 1 file changed, 74 insertions(+), 25 deletions(-) diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java index 50d989a2..852a3912 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java @@ -1242,6 +1242,7 @@ public void loadInfo(String sKey, String sKeyRawValue, Map sInfo @Override protected List getDescriptorFileLocations(String webAppRoot) { + List retFiles = new ArrayList(); List files = new ArrayList(); Document doc = null; @@ -1249,43 +1250,91 @@ protected List getDescriptorFileLocations(String webAppRoot) { String webAppClasspath = webAppRoot + File.separator + "WEB-INF" + File.separator + "classes" + File.separator; - String fileName = "struts.xml"; - File file = new File(webAppClasspath + fileName); + String config = parseFilterParam(webAppRoot); + if (!StringHelper.isEmpty(config)) { - if (!file.exists()) { - return files; + String[] fileNames = config.split(","); + + for (String fileName : fileNames) { + files.add(webAppClasspath + fileName); + } } - files.add(webAppClasspath + fileName); + files.add(webAppClasspath + "struts.xml"); - try { - doc = this.getDocumentBuilder().parse(file); - nodes = (NodeList) this.xpath.evaluate("/struts/include/@file", doc, XPathConstants.NODESET); - } - catch (IOException e) { - if (this.logger.isLogEnabled()) { - this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + for (String fileName : files) { + + File file = new File(fileName); + + if (!file.exists()) { + continue; } - } - catch (SAXException e) { - if (this.logger.isLogEnabled()) { - this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + + retFiles.add(fileName); + + try { + doc = this.getDocumentBuilder().parse(file); + nodes = (NodeList) this.xpath.evaluate("/struts/include/@file", doc, XPathConstants.NODESET); } - } - catch (XPathExpressionException e) { - if (this.logger.isLogEnabled()) { - this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + catch (IOException e) { + if (this.logger.isLogEnabled()) { + this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + } + } + catch (SAXException e) { + if (this.logger.isLogEnabled()) { + this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + } + } + catch (XPathExpressionException e) { + if (this.logger.isLogEnabled()) { + this.logger.warn("Load DescriptorFile[" + file.getPath() + "] FAILs.", e); + } + } + + if (nodes != null) { + for (int i = 0; i < nodes.getLength(); i++) { + Node node = nodes.item(i); + retFiles.add(webAppClasspath + node.getTextContent()); + } } } - if (nodes != null) { - for (int i = 0; i < nodes.getLength(); i++) { - Node node = nodes.item(i); - files.add(webAppClasspath + node.getTextContent()); + return retFiles; + } + + private String parseFilterParam(String webAppRoot) { + + String[] xpaths = new String[] { + "/web-app/filter[filter-class='org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter']/init-param[param-name='config']/param-value", + "/web-app/filter[filter-class='org.apache.struts2.dispatcher.FilterDispatcher']/init-param[param-name='config']/param-value" }; + + WebXmlProcessor wxp = this.getContext().get(WebXmlProcessor.class); + + final String[] configs = new String[] { null }; + + for (String xpath : xpaths) { + + wxp.parse(webAppRoot, xpath, new XMLParseHandler() { + + @Override + public boolean parse(DescriptorCollector dc, Node node) { + + if (node != null) { + configs[0] = node.getTextContent(); + return true; + } + + return false; + } + }, XMLNodeType.ELEMENT_NODE); + + if (!StringHelper.isEmpty(configs[0])) { + break; } } - return files; + return configs[0]; } @Override From 320e2d2f16ed90f6fc03044e9510646cc1a23bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 16 Mar 2018 15:45:42 +0800 Subject: [PATCH 34/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/216=20=E5=A2=9E=E5=8A=A0=E6=A2=AF=E5=BA=A6=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E6=94=B6=E6=95=9B=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8A=A5=E8=AD=A6=E6=A2=AF=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=85=88=E7=BA=A7=E9=AB=98=E4=BA=8E=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8A=A5=E8=AD=A6=E6=94=B6=E6=95=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/feature/procwatch/ProcWatcher.java | 2 +- .../notifystgy/css/uav.notifystgy.css | 20 ++ .../notifystgy/js/notifystgy.add.js | 7 +- .../notifystgy/js/notifystgy.win.js | 30 +- .../feature/runtimenotify/NotifyStrategy.java | 13 +- .../scheduler/NodeInfoWatcher.java | 2 +- .../task/JudgeNotifyCommonTask.java | 66 +++++ .../runtimenotify/task/JudgeNotifyTask.java | 27 +- .../task/JudgeNotifyTimerTask.java | 28 +- .../agent/feature/NotificationCenter.java | 15 +- .../feature/notifycenter/NCConstant.java | 2 + .../notifycenter/NCEventStatusManager.java | 113 ++++++++ .../handlers/NCJudgementHandler.java | 271 +++++++++++++++--- .../notifycenter/task/PersistentTask.java | 27 +- 14 files changed, 538 insertions(+), 85 deletions(-) create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyCommonTask.java create mode 100644 com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/NCEventStatusManager.java diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procwatch/ProcWatcher.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procwatch/ProcWatcher.java index 5b275da4..89fa6559 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procwatch/ProcWatcher.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/procwatch/ProcWatcher.java @@ -260,7 +260,7 @@ private void notify(ProcInfo proc, String startedMsg) { String desc = "发现" + proc.getName() + "进程" + proc.getPid() + "停止,已重启。\n启动参数:" + proc.getCmd() + "\n启动信息:" + startedMsg; - NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_Tag_NoBlock, + NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_CRASH, "发现" + proc.getName() + "进程停止,已重启进程", desc); putNotificationEvent(event); } diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css index 6d992646..0539a3dc 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css @@ -299,6 +299,26 @@ body { color:darkgrey; } +.StgyDiv .edit-div-option{ + font-size: 14px; + height: 50px; + width: 95%; + min-width: 340px; + border-radius: 2px; + border-color:#000000; + margin: 0 auto; + text-align:left; + padding: 5px; + margin-top: 5px; + overflow-y:auto; + color:#000000; +} + +StgyDiv .edit-div-option:empty:before{ + content: attr(placeholder); + color:darkgrey; +} + .whereStgyEdit{ border-radius: 4px; } diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.add.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.add.js index 1f01aa7e..b1551727 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.add.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.add.js @@ -124,6 +124,7 @@ function saveNotify(checkIsExist){ */ //校验 var stgyExpHtmlObjs = document.getElementsByName("stgy_exp_html"),stgyExpCheck=true; + var stgyConvergences = document.getElementsByName("stgy_convergence_html"); if(stgyExpHtmlObjs.length==0 && mName != "procCrash"){ $("#addNotifyErrMSG").text("触发策略不能为空"); return false; @@ -140,7 +141,7 @@ function saveNotify(checkIsExist){ } //赋值 - var relations=[],relationsHtmls = []; + var relations=[],relationsHtmls = [],convergences=[]; $.each(stgyExpHtmlObjs,function(index,obj){ var relation = obj.innerText; var resultHtml = obj.innerHTML; @@ -152,6 +153,7 @@ function saveNotify(checkIsExist){ relations[index]= relation;//赋值表达式 relationsHtmls[index]= resultHtml;//赋值用户操作html + convergences[index] = stgyConvergences[index].innerText; }); /** @@ -187,7 +189,8 @@ function saveNotify(checkIsExist){ "action":actions, "owner":owner, "relations":relations, - "relationsHtmls":relationsHtmls + "relationsHtmls":relationsHtmls, + "convergences":convergences } commitInfo[fName]=result; saveKey = fName; diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 250f26d2..b0cd5c92 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -337,12 +337,18 @@ function showEditNotifyDiv(jsonObjParam) { if(jsonObj.relationsHtmls){ $.each(jsonObj.relationsHtmls,function(index,html){ + var convergenceVal = ""; + if(jsonObj.hasOwnProperty("convergences")){ + convergenceVal = jsonObj.convergences[index]; + } + var appendHtml = '

'+ '
'+ - '
'+html+'
'+ - '
'; - + '
'+html+'
'+ + '
'+convergenceVal+'
'+ + '
'; + if(isOwner){ appendHtml+=''; }else{ @@ -1276,6 +1282,17 @@ var StgyClass = { sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[0].innerHTML); } sb.append( '
'); + + if(isOwner=="true"){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + if(type=="edit"){ + sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[1].innerHTML); + } + sb.append( '
'); if(isOwner=="true"){ sb.append( '
'); @@ -1337,11 +1354,13 @@ var StgyClass = { * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 */ var html = document.getElementById("stgy_exp").innerHTML; + var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); if(html.length>0 && type=="add"){ html = '
'+ - '
'+html+'
'+ - '
'+ + '
'+html+'
'+ + '
'+htmlConvergence+'
'+ + '
'+ ''; '
'+ '
'; @@ -1352,6 +1371,7 @@ var StgyClass = { }else if(html.length>0 && type=="edit"){ actionConf.actionObj.parentNode.getElementsByTagName("div")[0].innerHTML = html; + actionConf.actionObj.parentNode.getElementsByTagName("div")[1].innerHTML = htmlConvergence; } StgyClass.closeStgyDiv(); diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java index 91c9d5d0..147218cc 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java @@ -64,6 +64,8 @@ public String toString() { private List condtions; + private List convergences; + private String msgTemplate; private Map action = Collections.emptyMap(); @@ -80,7 +82,7 @@ public NotifyStrategy() { } public NotifyStrategy(String name, String scope, List context, Map action, - List instances, String msgTemplate) { + List instances, String msgTemplate, List convergences) { this.name = name; this.scope = scope; if (context != null && context.size() != 0) { @@ -92,6 +94,7 @@ public NotifyStrategy(String name, String scope, List context, Map context = (List) m.get("context"); List conditions = (List) m.get("conditions"); List relations = (List) m.get("relations"); + List convergences = (List) m.get("convergences"); Map action = (Map) m.get("action"); String msgTemplate = (String) m.get("msgTemplate"); List instances = (List) m.get("instances"); - NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate); + NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); stra.setConditions(conditions, relations); @@ -262,6 +266,11 @@ public List getCondtions() { return condtions; } + + public List getConvergences() { + + return convergences; + } protected static class Expression { diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java index e3937154..10249365 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java @@ -352,7 +352,7 @@ private void judgeProcCrash() { continue; } - List portsBak = new ArrayList(Arrays.asList(procKeyBakArray[2].split(":"))); + List portsBak = new ArrayList(Arrays.asList(procKeyBakArray[2].split("#"))); for (String port : ports) { if (portsBak.contains(port)) { diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyCommonTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyCommonTask.java new file mode 100644 index 00000000..f750d85c --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyCommonTask.java @@ -0,0 +1,66 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.task; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import com.creditease.agent.spi.Abstract1NTask; + +public abstract class JudgeNotifyCommonTask extends Abstract1NTask { + + /** + * @param name + * @param feature + */ + public JudgeNotifyCommonTask(String name, String feature) { + + super(name, feature); + } + + /** + * + * @param causeConvergences convergences corresponding to trigger conditions + * @return the convergence which has the most gradient + */ + protected String obtainConvergenceForEvent(List convergences, List conditionIndex) { + + List causeConvergences = new ArrayList(); + for(String index : conditionIndex) { + causeConvergences.add(convergences.get(Integer.parseInt(index)-1)); + } + + Collections.sort(causeConvergences, new Comparator() { + + @Override + public int compare(String o1, String o2) { + + String[] strs1 = o1.split(","); + String[] strs2 = o2.split(","); + return strs1.length > strs2.length ? -1 : 1; + } + }); + return causeConvergences.get(0); + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java index dd972a23..461cede5 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java @@ -36,7 +36,6 @@ import com.creditease.agent.helpers.JSONHelper; import com.creditease.agent.helpers.StringHelper; import com.creditease.agent.monitor.api.NotificationEvent; -import com.creditease.agent.spi.Abstract1NTask; import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.feature.runtimenotify.NotifyStrategy; import com.creditease.uav.feature.runtimenotify.RuntimeNotifySliceMgr; @@ -44,7 +43,7 @@ import com.creditease.uav.feature.runtimenotify.StrategyJudgement; import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; -public class JudgeNotifyTask extends Abstract1NTask { +public class JudgeNotifyTask extends JudgeNotifyCommonTask { private static final String RNJUDGE_PREFIX = "RNJUDGE_"; @@ -134,7 +133,7 @@ public void run() { * Step 5: if fire the event, build notification event */ if (result != null && !result.isEmpty()) { - NotificationEvent event = this.newNotificationEvent(result); + NotificationEvent event = this.newNotificationEvent(result, stra.getConvergences()); // get context putContext(event); @@ -189,7 +188,7 @@ private void putContext(NotificationEvent event) { * * @return */ - private NotificationEvent newNotificationEvent(Map result) { + private NotificationEvent newNotificationEvent(Map result, List convergences) { String ip = this.curSlice.getMdf().getIP(); String host = this.curSlice.getMdf().getHost(); @@ -198,17 +197,17 @@ private NotificationEvent newNotificationEvent(Map result) { appgroup = (appgroup == null) ? "" : appgroup; StringBuilder desc = new StringBuilder(); - StringBuilder conditionIndex = new StringBuilder(); + List conditionIndex = new ArrayList(); for (Map.Entry cause : result.entrySet()) { // description desc.append("触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); // condition index - conditionIndex.append(" " + cause.getKey()); + conditionIndex.add(cause.getKey()); } - String title = ip + "[" + this.curSlice.getKey() + "]触发" + result.size() + "个报警(条件序号:" - + conditionIndex.toString() + ")"; + String title = ip + "[" + this.curSlice.getKey() + "]触发" + result.size() + "个报警(条件序号: " + + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; // fix  (\u00A0) can be shown in email String description = desc.toString().replace('\u00A0', ' '); @@ -219,6 +218,18 @@ private NotificationEvent newNotificationEvent(Map result) { // add appgroup ne.addArg("appgroup", appgroup); + // 兼容不存在convergences属性的旧预警策略 + if(convergences == null || convergences.size() == 0 ) { + return ne; + } + + // 同一个Event由多个策略触发时,梯度收敛以最长的为准 + String conv = obtainConvergenceForEvent(convergences, conditionIndex); + if(!StringHelper.isEmpty(conv)) { + ne.addArg("convergences", conv); + ne.addArg(NotificationEvent.EVENT_Tag_NoBlock, "true"); + } + return ne; } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java index 08931fb7..0a642bd6 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java @@ -20,13 +20,15 @@ package com.creditease.uav.feature.runtimenotify.task; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import com.creditease.agent.helpers.JSONHelper; import com.creditease.agent.helpers.NetworkHelper; +import com.creditease.agent.helpers.StringHelper; import com.creditease.agent.monitor.api.NotificationEvent; -import com.creditease.agent.spi.Abstract1NTask; import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.cache.api.CacheManager.CacheLock; import com.creditease.uav.feature.RuntimeNotifyCatcher; @@ -35,7 +37,7 @@ import com.creditease.uav.feature.runtimenotify.StrategyJudgement; import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; -public class JudgeNotifyTimerTask extends Abstract1NTask { +public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { private NotifyStrategy stra; private long taskStart = System.currentTimeMillis(); @@ -77,7 +79,7 @@ public void run() { * Step 3: if fire the event, build notification event */ if (result != null && !result.isEmpty()) { - NotificationEvent event = this.newNotificationEvent(instance, result); + NotificationEvent event = this.newNotificationEvent(instance, result, stra.getConvergences()); // get context putContext(event); @@ -128,7 +130,7 @@ private void putContext(NotificationEvent event) { * * @return */ - private NotificationEvent newNotificationEvent(String instance, Map result) { + private NotificationEvent newNotificationEvent(String instance, Map result, List convergences) { String ip = instance; String host = instance; @@ -144,16 +146,16 @@ private NotificationEvent newNotificationEvent(String instance, Map conditionIndex = new ArrayList(); for (Map.Entry cause : result.entrySet()) { // description desc.append(instance + "触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); // condition index - conditionIndex.append(" " + cause.getKey()); + conditionIndex.add(cause.getKey()); } - String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号:" + conditionIndex.toString() + ")"; + String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号: " + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; // fix  (\u00A0) can be shown in email String description = desc.toString().replace('\u00A0', ' '); @@ -164,6 +166,18 @@ private NotificationEvent newNotificationEvent(String instance, Map> + */ +package com.creditease.agent.feature.notifycenter; + +import java.util.Map; + +import com.creditease.agent.monitor.api.NotificationEvent; +import com.creditease.agent.spi.AbstractComponent; +import com.creditease.uav.cache.api.CacheManager; + +/** + * + * NCEventStatusManager description: package the CacheManager used in notification handler + * + */ +public class NCEventStatusManager extends AbstractComponent { + + private CacheManager cm; + + public NCEventStatusManager(String cName, String feature, CacheManager cm) { + + super(cName, feature); + this.cm = cm; + } + + /** + * check if there is SYNC atomic key on enevtKey + * @param eventKey + * @return + */ + public boolean checkSyncAtomicKey(String eventKey) { + int AtomicSych = cm.incre(NCConstant.STORE_REGION, eventKey); + + if (AtomicSych > 1) { + + String lock = cm.get(NCConstant.STORE_REGION, eventKey); + if (null != lock) { + int atomicLock = Integer.parseInt(lock); + + /** + * To prevent deadLock of event + */ + if (atomicLock > 3) { + cm.del(NCConstant.STORE_REGION, eventKey); + } + } + return true; + } + else { + cm.incre(NCConstant.STORE_REGION, eventKey); + return false; + } + } + + /** + * obtain the cache for the event + * @param eventKey + * @return + * @throws RuntimeException + */ + public Map obtainEventCache(String eventKey) throws RuntimeException{ + + try { + Map ntfvalue = cm.getHash(NCConstant.STORE_REGION, NCConstant.STORE_KEY_NCINFO, eventKey); + return ntfvalue; + } catch (RuntimeException e) { + cm.del(NCConstant.STORE_REGION, eventKey); + throw e; + } + + } + + /** + * update cache after the handle of event + * @param event + */ + public void updateCache(NotificationEvent event) { + + if (log.isDebugEnable()) { + log.debug(this, "NC Update Cache: " + event.getArg(NCConstant.NTFVALUE)); + } + + try { + cm.putHash(NCConstant.STORE_REGION, NCConstant.STORE_KEY_NCINFO, event.getArg(NCConstant.NTFKEY), + event.getArg(NCConstant.NTFVALUE)); + } + catch (Exception e) { + + log.err(this, "Error when updateCache", e); + } finally { + cm.del(NCConstant.STORE_REGION, event.getArg(NCConstant.NTFKEY)); + } + + } + +} diff --git a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java index 1656a9d7..814cc62f 100644 --- a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java +++ b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java @@ -20,6 +20,7 @@ package com.creditease.agent.feature.notifycenter.handlers; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -28,15 +29,19 @@ import com.creditease.agent.ConfigurationManager; import com.creditease.agent.feature.notifycenter.NCConstant; import com.creditease.agent.feature.notifycenter.NCConstant.StateFlag; +import com.creditease.agent.feature.notifycenter.NCEventStatusManager; import com.creditease.agent.feature.notifycenter.task.NotificationTask; import com.creditease.agent.feature.notifycenter.task.PersistentTask; import com.creditease.agent.helpers.DataConvertHelper; import com.creditease.agent.helpers.DataStoreHelper; import com.creditease.agent.helpers.JSONHelper; +import com.creditease.agent.helpers.StringHelper; import com.creditease.agent.monitor.api.NotificationEvent; +import com.creditease.agent.spi.AbstractBaseAction; import com.creditease.agent.spi.AbstractHandler; +import com.creditease.agent.spi.ActionContext; import com.creditease.agent.spi.I1NQueueWorker; -import com.creditease.uav.cache.api.CacheManager; +import com.creditease.agent.spi.IActionEngine; /** * @@ -59,9 +64,195 @@ */ public class NCJudgementHandler extends AbstractHandler { - - private CacheManager cm; - + + + private class NotificationConvergenceAction extends AbstractBaseAction { + + /** + * @param cName + * @param feature + * @param engine + */ + public NotificationConvergenceAction(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @SuppressWarnings("unchecked") + @Override + public void doAction(ActionContext context) throws Exception { + + String eventKey = (String) context.getParam("eventKey"); + NotificationEvent event = (NotificationEvent) context.getParam("event"); + String stateDataStr = (String) context.getParam("stateDataStr"); + + Map stateData = null; + + /** + * if none, take this event as the first event record + */ + if (null == stateDataStr) { + + if (log.isDebugEnable()) { + log.debug(this, "NC Convergence Event happens FIRST TIME: NTFKEY=" + eventKey + ",time=" + event.getTime()); + } + + Map statusSet = playAsFirstEventRecordConvergence(event, eventKey); + doNotificationConvergence(event, eventKey, statusSet); + return; + } + + stateData = JSONHelper.toObject(stateDataStr, Map.class); + + if (log.isDebugEnable()) { + log.debug(this, "NC Event happens with stateData: "+stateDataStr); + } + + long curTime = System.currentTimeMillis(); + + long viewTime = DataConvertHelper.toLong(stateData.get(NCConstant.COLUMN_VIEWTIME), -1); + + if (viewTime > -1) { + + if (log.isDebugEnable()) { + log.debug(this, "NC Convergence Event Check Result, Over View TTL: viewTTL=" + viewTTL + ",curTime - viewTime=" + + (curTime - viewTime)); + } + + /** + * if there is ViewTime and ViewTime exceeds ViewTTL, take this event as a newone + */ + if (curTime - viewTime > viewTTL) { + stateData = playAsFirstEventRecordConvergence(event, eventKey); + } + else { + int count = increEventCount(stateData); + stateData.put(NCConstant.EVENT_COUNT, count); + playAsReEntryRecordConvergence(event, eventKey, stateData, false); + if (log.isTraceEnable()) { + log.info(this, "NCJudgementHandler END: key=" + eventKey); + } + return; + } + + } else { + int count = increEventCount(stateData); + stateData.put(NCConstant.EVENT_COUNT, count); + } + + doNotificationConvergence(event, eventKey, stateData); + + } + + /** + * the logic of gradient convergence + * @param event + * @param eventKey + * @param stateData + */ + private void doNotificationConvergence(NotificationEvent event, String eventKey, Map stateData) { + + String convergence = event.getArg("convergences"); + List convs = Arrays.asList(convergence.split(",")); + String count = stateData.get(NCConstant.EVENT_COUNT) +""; + if (convs.contains(count)) { + + if (log.isDebugEnable()) { + log.debug(this, "NC Convergence Event Check Result, RE-Action Notify: current event=" + count); + } + playAsReEntryRecordConvergence(event, eventKey, stateData, true); + addNotficationTask(event, stateData); + + } else { + + playAsReEntryRecordConvergence(event, eventKey, stateData, false); + } + + if (log.isTraceEnable()) { + log.info(this, "NCJudgementHandler END: key=" + eventKey); + } + } + + @Override + public String getSuccessNextActionId() { + + return null; + } + + @Override + public String getFailureNextActionId() { + + return null; + } + + @Override + public String getExceptionNextActionId() { + + return null; + } + + private Map playAsFirstEventRecordConvergence(NotificationEvent event, String eventKey) { + + Map statusSet = new LinkedHashMap(); + + statusSet.put(NCConstant.COLUMN_STARTTIME, event.getTime()); + statusSet.put(NCConstant.COLUMN_STATE, NCConstant.StateFlag.NEWCOME.getStatFlag()); + statusSet.put(NCConstant.COLUMN_RETRY_COUNT, 0); + statusSet.put(NCConstant.COLUMN_LATESTIME, System.currentTimeMillis()); + + // First Time NTFE take priority as the "0" Priority. + statusSet.put(NCConstant.COLUMN_PRIORITY, 0); + statusSet.put(NCConstant.EVENT_COUNT, 1); + + String statusStr = JSONHelper.toString(statusSet); + + event.addArg(NCConstant.NCFirstEvent, "true"); + event.addArg(NCConstant.NTFKEY, eventKey); + event.addArg(NCConstant.NTFVALUE, statusStr); + + return statusSet; + } + + private void playAsReEntryRecordConvergence(NotificationEvent event, String eventKey, Map stateData, + boolean isRetry) { + + // NOTE: if the state is VIEW, the UPDATE should not be set as the latest state + int curState = (int) stateData.get(NCConstant.COLUMN_STATE); + + if (curState < StateFlag.UPDATE.getStatFlag() && !"true".equals(event.getArg(NCConstant.NCFirstEvent))) { + curState = StateFlag.UPDATE.getStatFlag(); + stateData.put(NCConstant.COLUMN_STATE, curState); + } + + // NOTE: if the state is VIEW, for this part that means VIEW & UPDATE + if (curState == StateFlag.VIEW.getStatFlag()) { + curState = StateFlag.VIEWUPDATE.getStatFlag(); + stateData.put(NCConstant.COLUMN_STATE, curState); + } + + if (isRetry == true) { + int curRetry = (Integer) stateData.get(NCConstant.COLUMN_RETRY_COUNT) + 1; + stateData.put(NCConstant.COLUMN_RETRY_COUNT, curRetry); + stateData.put(NCConstant.COLUMN_LATESTIME, System.currentTimeMillis()); + } + + stateData.put(NCConstant.COLUMN_LATESTRECORDTIME, event.getTime()); + + String statusStr = JSONHelper.toString(stateData); + + if (null == event.getArg(NCConstant.NCFirstEvent)) { + event.addArg(NCConstant.NCFirstEvent, "false"); + } + event.addArg(NCConstant.NTFKEY, eventKey); + event.addArg(NCConstant.NTFVALUE, statusStr); + + // 持久化操作 + addPersistentTask(event); + } + + } + + private int retryTime = 3; /** * NOTE: viewTTL is the time to give human to fix the issue, see we are nice as default is 4 hours @@ -69,13 +260,15 @@ public class NCJudgementHandler extends AbstractHandler { private int viewTTL = 4 * 3600 * 1000; private long frozenTime = 300000; private I1NQueueWorker qworker; + private IActionEngine engine; + private NCEventStatusManager eventStatusManager; public NCJudgementHandler(String cName, String feature) { super(cName, feature); - cm = (CacheManager) ConfigurationManager.getInstance().getComponent(this.feature, "NCCacheManager"); - + eventStatusManager = (NCEventStatusManager) ConfigurationManager.getInstance().getComponent(feature, "EventStatusManager"); + retryTime = DataConvertHelper .toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.retry"), 3); viewTTL = DataConvertHelper @@ -85,6 +278,8 @@ public NCJudgementHandler(String cName, String feature) { qworker = (I1NQueueWorker) ConfigurationManager.getInstance().getComponent(this.feature, NCConstant.NC1NQueueWorkerName); + engine = this.getActionEngineMgr().getActionEngine("NCJudgementEngine"); + new NotificationConvergenceAction(NotificationConvergenceAction.class.getSimpleName(), feature, engine); } /** @@ -109,61 +304,47 @@ public void handle(NotificationEvent event) { * */ - int AtomicSych = cm.incre(NCConstant.STORE_REGION, eventKey); - - if (AtomicSych > 1) { + boolean isSYNCAtomicKey = eventStatusManager.checkSyncAtomicKey(eventKey); + if (isSYNCAtomicKey) { if (log.isTraceEnable()) { log.info(this, "NCJudgementHandler event is locked:" + event.toJSONString()); } - String lock = cm.get(NCConstant.STORE_REGION, eventKey); - if (null != lock) { - int atomicLock = Integer.parseInt(lock); - - /** - * To prevent deadLock of event - */ - if (atomicLock > 3) { - cm.del(NCConstant.STORE_REGION, eventKey); - } - } - return; } - else { - cm.incre(NCConstant.STORE_REGION, eventKey); - } /** * Step 2 Check if there is a cache for current event **/ - Map ntfvalue = null; try { - ntfvalue = cm.getHash(NCConstant.STORE_REGION, NCConstant.STORE_KEY_NCINFO, eventKey); + Map ntfvalue = eventStatusManager.obtainEventCache(eventKey); + stateDataStr = ntfvalue.get(eventKey); } catch (RuntimeException e) { + if (log.isTraceEnable()) { log.info(this, "NCJudgementHandler exception got RuntimeException" + e.getMessage() + " The event is: " + event.toJSONString()); } - cm.del(NCConstant.STORE_REGION, eventKey); - return; } - catch (Exception e) { - + + /** + * notification convergence + */ + if(!StringHelper.isEmpty(event.getArg("convergences"))) { + + ActionContext ac = new ActionContext(); + ac.putParam("eventKey", eventKey); + ac.putParam("event", event); + ac.putParam("stateDataStr", stateDataStr); + engine.execute(NotificationConvergenceAction.class.getSimpleName(), ac); if (log.isTraceEnable()) { - log.info(this, "NCJudgementHandler exception got exception" + e.getMessage() + " The event is: " - + event.toJSONString()); + log.info(this, "NCJudgementHandler END: key=" + eventKey); } - - cm.del(NCConstant.STORE_REGION, eventKey); - return; } - stateDataStr = ntfvalue.get(eventKey); - /** * Step 2.1 if none, take this event as the first event record */ @@ -340,6 +521,9 @@ private void playAsReEntryRecord(NotificationEvent event, String eventKey, Map stateData) { } } -} + + private int increEventCount(Map stateData) { + Integer count = (Integer) stateData.get(NCConstant.EVENT_COUNT); + if (null == count) { + count = 0; + } + count = count + 1; + return count; + } + +} \ No newline at end of file diff --git a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/task/PersistentTask.java b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/task/PersistentTask.java index 5e37a739..44943657 100644 --- a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/task/PersistentTask.java +++ b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/task/PersistentTask.java @@ -25,12 +25,12 @@ import com.creditease.agent.ConfigurationManager; import com.creditease.agent.feature.notifycenter.NCConstant; +import com.creditease.agent.feature.notifycenter.NCEventStatusManager; import com.creditease.agent.helpers.JSONHelper; import com.creditease.agent.monitor.api.MonitorDataFrame; import com.creditease.agent.monitor.api.NotificationEvent; import com.creditease.agent.spi.Abstract1NTask; import com.creditease.agent.spi.AgentFeatureComponent; -import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.datastore.api.DataStoreMsg; import com.creditease.uav.datastore.api.DataStoreProtocol; @@ -41,12 +41,11 @@ */ public class PersistentTask extends Abstract1NTask { - CacheManager cm; + private NCEventStatusManager eventStatusManager; public PersistentTask(String name, String feature) { super(name, feature); - - cm = (CacheManager) this.getConfigManager().getComponent(this.feature, "NCCacheManager"); + eventStatusManager = (NCEventStatusManager) ConfigurationManager.getInstance().getComponent(feature, "EventStatusManager"); } @Override @@ -62,22 +61,7 @@ public void run() { public void updateCache(NotificationEvent event) { - if (log.isDebugEnable()) { - log.debug(this, "NC Update Cache: " + event.getArg(NCConstant.NTFVALUE)); - } - - try { - cm.putHash(NCConstant.STORE_REGION, NCConstant.STORE_KEY_NCINFO, event.getArg(NCConstant.NTFKEY), - event.getArg(NCConstant.NTFVALUE)); - } - catch (Exception e) { - - log.err(this, "Error when updateCache", e); - } - finally { - cm.del(NCConstant.STORE_REGION, event.getArg(NCConstant.NTFKEY)); - } - + eventStatusManager.updateCache(event); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -126,6 +110,9 @@ public void updateDatabase(NotificationEvent event) { if (ntfargs.get(NCConstant.COLUMN_LATESTRECORDTIME) != null) { set.put(NCConstant.COLUMN_LATESTRECORDTIME, ntfargs.get(NCConstant.COLUMN_LATESTRECORDTIME)); } + if (ntfargs.get(NCConstant.EVENT_COUNT) != null) { + set.put(NCConstant.EVENT_COUNT, ntfargs.get(NCConstant.EVENT_COUNT)); + } update.put("set", set); condition.put("where", where); From 4fceba20f4dfc818043397e94f19be06325f5357 Mon Sep 17 00:00:00 2001 From: zwq0317 <1065009602@qq.com> Date: Fri, 23 Mar 2018 14:42:26 +0800 Subject: [PATCH 35/97] fix #218 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当appurl中含有appname查询不到日志信息时,去除appname再次查询 --- .../uavapp_godeye/appmonitor/js/uav.apm.js | 79 ++++++++++++------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js index 2a0dcac0..ec5fd7d4 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js @@ -304,6 +304,54 @@ function APMTool(app) { if(params.appid=="ROOT"){ appurl = "http://"+params.ipport+"/"; } + + var results = _this.getProfileByAppurl(appurl); + //连接失败 + if(results == undefined){ + alert("获取日志文件失败"); + return; + } + //第一次没有获取到日志,把appurl中的appname去掉后再尝试获取一次 + if(results.rs == undefined){ + appurl = "http://"+params.ipport+"/"; + results = _this.getProfileByAppurl(appurl); + + //仍然没有获取到日志文件信息,此时profile中没有该appurl对应的信息,应该是由于应用停掉了 + if(results == undefined || results.rs == undefined){ + alert("获取日志文件失败,请检查应用是否处于运行状态"); + return; + } + } + + var res = results["rs"]; + var datas = StringHelper.str2obj(res); + + var data; + for(var key in datas){ + data = datas[key]; + } + var logdata = StringHelper.str2obj(data)["logs.log4j"]; + var logObj = StringHelper.str2obj(logdata); + for(var key in logObj){ + if(key.lastIndexOf("/") > 0){ + key = key.substring(key.lastIndexOf("/") + 1); + } + $("#logSelector").append(""); + } + if($("#logSelector option").size()>0){ + $("#selectLogWinfooter").append( ''); + }else{ + $("#logSelector").append(""); + } + $("#selectLogWinfooter").append( ''); + + + $("#selectLogWin").modal({backdrop:false}); + } + + + this.getProfileByAppurl = function(appurl){ + var results = undefined; AjaxHelper.call({ url: '../../rs/godeye/profile/q/cache', data: {"fkey":"appurl","fvalue":appurl}, @@ -311,36 +359,13 @@ function APMTool(app) { type: 'GET', dataType: 'html', timeout: 30000, + async: false, success: function(result){ - var obj = StringHelper.str2obj(result); - var res = obj["rs"]; - var datas = StringHelper.str2obj(res); - var data; - for(var key in datas){ - data = datas[key]; - } - var logdata = StringHelper.str2obj(data)["logs.log4j"]; - var logObj = StringHelper.str2obj(logdata); - for(var key in logObj){ - if(key.lastIndexOf("/") > 0){ - key = key.substring(key.lastIndexOf("/") + 1); - } - $("#logSelector").append(""); - } - if($("#logSelector option").size()>0){ - $("#selectLogWinfooter").append( ''); - }else{ - $("#logSelector").append(""); - } - $("#selectLogWinfooter").append( ''); - }, - error: function(result){ - $("#logSelector").append(""); - $("#selectLogWinfooter").append( ''); + results = StringHelper.str2obj(result); } - }); + }); - $("#selectLogWin").modal({backdrop:false}); + return results; } /** From 2f1f63c125b73f0c158e15a76b265715ba919d43 Mon Sep 17 00:00:00 2001 From: Zhuang Date: Fri, 23 Mar 2018 14:44:30 +0800 Subject: [PATCH 36/97] done for issue #220 --- .../src/main/webapp/apphub/js/common/mvc.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/apphub/js/common/mvc.js b/com.creditease.uav.console/src/main/webapp/apphub/js/common/mvc.js index 8d12f561..512d620c 100644 --- a/com.creditease.uav.console/src/main/webapp/apphub/js/common/mvc.js +++ b/com.creditease.uav.console/src/main/webapp/apphub/js/common/mvc.js @@ -113,6 +113,10 @@ function AppHubMVC(_mvcConfig) { var searchObj=mvcConfig["search"]; var searchKeyword=searchObj["keyword"]; + var hasSearchKey = undefined!=searchKeyword&&""!=searchKeyword&&"@ALL"!=searchKeyword; + if(hasSearchKey) { + var searchKeys = searchKeyword.split(" "); + } for(var i=0;i0) { - if (undefined!=searchKeyword&&""!=searchKeyword&&"@ALL"!=searchKeyword) { + if (hasSearchKey) { var ismeet=false; @@ -231,9 +235,11 @@ function AppHubMVC(_mvcConfig) { continue; } //meet the search condition - if (value.indexOf(searchKeyword)>-1) { - ismeet=true; - break; + for(var skIdx = 0; skIdx < searchKeys.length; skIdx++) { + if (searchKeys[skIdx] != undefined && searchKeys[skIdx] != "" && value.indexOf(searchKeys[skIdx])>-1) { + ismeet=true; + break; + } } } From 5abd8fa9978422f8686501e0550261475ef1b4f5 Mon Sep 17 00:00:00 2001 From: Zhuang Date: Fri, 23 Mar 2018 14:54:25 +0800 Subject: [PATCH 37/97] fixed issue #221 --- .../config/hm_pro_apmserver.properties | 8 +-- .../config/hm_pro_rtserver.properties | 2 +- .../runtimenotify/RuntimeNotifySliceMgr.java | 3 +- .../runtimenotify/StrategyJudgement.java | 30 +++++------ .../scheduler/NodeInfoWatcher.java | 52 +++++++++++-------- 5 files changed, 50 insertions(+), 45 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties index 03eef29c..66cf7507 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties @@ -37,7 +37,7 @@ feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10146 +feature.nodeoperagent.http.port=10160 #notifyagent feature.notifyagent.loader=com.creditease.uav.notifymanager.jar @@ -73,7 +73,7 @@ feature.collectserver.loader=com.creditease.uav.collect.jar feature.collectserver.enable=true feature.collectserver.components=com.creditease.uav.collect.server.GatherDataManager feature.collectserver.properties= -feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA,JQ_UEM +feature.collectserver.topics=JQ_IVC,JQ_SLW,JQ_JTA feature.collectserver.messagingnameserver=127.0.0.1:9876;127.0.0.1:9876;127.0.0.1:9876 # for topic consumer performance tuning #feature.collectserver..consumethreadmax=10 @@ -83,10 +83,6 @@ feature.collectserver.JQ_IVC.consumethreadmax=10 feature.collectserver.JQ_IVC.consumestopinterval=0 feature.collectserver.JQ_IVC.enable=true -feature.collectserver.JQ_UEM.consumethreadmax=10 -feature.collectserver.JQ_UEM.consumestopinterval=0 -feature.collectserver.JQ_UEM.enable=true - feature.collectserver.JQ_SLW.consumethreadmax=10 feature.collectserver.JQ_SLW.consumestopinterval=0 feature.collectserver.JQ_SLW.enable=true diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties index 91dfa36a..35476c63 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_rtserver.properties @@ -37,7 +37,7 @@ feature.nodeoperagent.loader=com.creditease.uav.agent.heartbeat.jar #feature.xxx.enable should enable this feature feature.nodeoperagent.enable=true feature.nodeoperagent.components=com.creditease.agent.feature.NodeOperAgent -feature.nodeoperagent.http.port=10140 +feature.nodeoperagent.http.port=10170 #notifyagent feature.notifyagent.loader=com.creditease.uav.notifymanager.jar diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/RuntimeNotifySliceMgr.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/RuntimeNotifySliceMgr.java index 968ec341..893ffa30 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/RuntimeNotifySliceMgr.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/RuntimeNotifySliceMgr.java @@ -308,9 +308,10 @@ public List getSlices(Slice cur, long range) { private List getPreRangePoint(Slice slice, long range) { int points = (int) Math.ceil(range / 1000 / 60.0); - List list = new ArrayList<>(points); + List list = new ArrayList<>(points + 1); @SuppressWarnings("deprecation") int pn = new Date(slice.getTime()).getMinutes(); + list.add(pn); for (int i = 0; i < points; i++) { pn = lastPointNum(pn); list.add(pn); diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java index d274a643..78542f67 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java @@ -73,6 +73,7 @@ public class StrategyJudgement extends AbstractComponent { private String queryServiceName; public StrategyJudgement(String cName, String feature) { + super(cName, feature); cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); invoker = this.getSystemInvokerMgr().getSystemInvoker(InvokerType.HTTP); @@ -198,6 +199,10 @@ else if (func.indexOf("percent") == 0) { * 2.3: if there is range function, run range function */ else { + if (samplingSlices == null || samplingSlices.isEmpty()) { + log.warn(this, "SamplingSlices is null! range=" + range + ", sliceSize=" + slices.size() + + ", SliceKey=" + cur.getKey() + ", expr=" + JSONHelper.toString(expr)); + } actualValue = Function.func(func, samplingSlices, exprArg, expr); } @@ -589,10 +594,6 @@ public Map buildReadableResult() { log.debug(this, "Judgement: FireSize=" + map.size() + ", conditions=" + JSONHelper.toString(crs)); } - if (log.isDebugEnable()) { - log.debug(this, "Judgement: FireSize=" + map.size() + ", conditions=" + JSONHelper.toString(crs)); - } - return map; } @@ -636,15 +637,13 @@ private String makeReadableString(Map m) { } else if (NotifyStrategy.Type.TIMER.toString().equals(m.get("type"))) { - description = ("true".equals(m.get("fire"))) - ? String.format("%s在%s至%s时间段的%s值%s比%s至%s%s超过%s,当前值:%s。上期值:%s,本期值:%s", m.get("metric"), - m.get("time_from"), m.get("time_to"), readable.get(m.get("func")), m.get("tag"), - m.get("last_time_from"), m.get("last_time_to"), - (m.get("actualValue").contains("-")) ? "降幅" : "增幅", - m.get("expectedValue"), (m.get("actualValue").contains("-")) - ? m.get("actualValue").substring(1) : m.get("actualValue"), - m.get("lastValue"), m.get("currentValue")) - : "false"; + description = ("true".equals(m.get("fire"))) ? String.format( + "%s在%s至%s时间段的%s值%s比%s至%s%s超过%s,当前值:%s。上期值:%s,本期值:%s", m.get("metric"), m.get("time_from"), + m.get("time_to"), readable.get(m.get("func")), m.get("tag"), m.get("last_time_from"), + m.get("last_time_to"), (m.get("actualValue").contains("-")) ? "降幅" : "增幅", + m.get("expectedValue"), + (m.get("actualValue").contains("-")) ? m.get("actualValue").substring(1) : m.get("actualValue"), + m.get("lastValue"), m.get("currentValue")) : "false"; } return description; @@ -661,6 +660,7 @@ private class ConditionResult { @SuppressWarnings("unchecked") private ConditionResult(NotifyStrategy.Condition cond) { + this.cond = cond; int count = cond.getExpressions().size(); condResult = new boolean[count]; @@ -757,8 +757,8 @@ public static Float func(String funcName, List slices, String targetArg, NotifyStrategy.Expression expr) { // valid - if (slices == null || slices.size() == 0) { - throw new RuntimeException("Slices is empty"); + if (slices == null || slices.isEmpty()) { + return null; } Float value = null; diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java index 10249365..2613e189 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java @@ -66,6 +66,7 @@ private static class CrashEventObj { private List deadProcNames = new ArrayList(); public CrashEventObj(String ip, String appgroup) { + this.ip = ip; this.appgroup = appgroup; } @@ -139,6 +140,7 @@ public String getDeadProcsInfoAsString() { private boolean isExchange; public NodeInfoWatcher(String cName, String feature) { + super(cName, feature); cm = (CacheManager) getConfigManager().getComponent(this.feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); @@ -213,7 +215,7 @@ public void run() { } if (isSendMq) { - sendToMq(JSONHelper.toString(mdflist)); + sendToMQ(mdflist); } @@ -686,40 +688,46 @@ private void freezeTime() { cm.put(UAV_CACHE_REGION, "rtnoitify.nodeinfotimer.hold", now + ""); } - private void sendToMq(String mdfs) { + private void exchangeToRuntimeNotify(String mdfs) { + + AgentFeatureComponent rn = (AgentFeatureComponent) this.getConfigManager().getComponent("runtimenotify", + "RuntimeNotifyCatcher"); + if (rn != null) { + rn.exchange("runtime.notify", mdfs, true); + } + + if (log.isTraceEnable()) { + log.info(this, "NodeInfoWatcher RUN END."); + } + + } + + private void sendToMQ(List> mdfList) { AgentResourceComponent arc = (AgentResourceComponent) ConfigurationManager.getInstance() .getComponent("messageproducer", "MessageProducerResourceComponent"); MessageProducer producer = (MessageProducer) arc.getResource(); + if (producer == null) { + log.debug(this, "MessageProducer is null!"); + return; + } - if (producer != null) { - + List> mdfMsg = null; + for (Map mdf : mdfList) { + mdfMsg = new ArrayList<>(1); + mdfMsg.add(mdf); String mesKey = MonitorDataFrame.MessageType.NodeInfo.toString(); Message msg = MessagingFactory.createMessage(mesKey); - msg.setParam(mesKey, mdfs); + msg.setParam(mesKey, JSONHelper.toString(mdfMsg)); + boolean check = producer.submit(msg); String sendState = mesKey + " Data Sent " + (check ? "SUCCESS" : "FAIL"); if (log.isDebugEnable()) { - log.debug(this, sendState + " " + mdfs); + String mdfDetail = check ? (mdf.get("ip") + "---" + mdf.get("time")) : JSONHelper.toString(mdfMsg); + log.debug(this, sendState + ". MDF:" + mdfDetail); } - - } - - } - - private void exchangeToRuntimeNotify(String mdfs) { - - AgentFeatureComponent rn = (AgentFeatureComponent) this.getConfigManager().getComponent("runtimenotify", - "RuntimeNotifyCatcher"); - if (rn != null) { - rn.exchange("runtime.notify", mdfs, true); } - - if (log.isTraceEnable()) { - log.info(this, "NodeInfoWatcher RUN END."); - } - } } From 9c849718fb041b0806ae992e8b85934c7748c167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 23 Mar 2018 15:12:24 +0800 Subject: [PATCH 38/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/219=20=E5=B0=86=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=E5=89=8D20000=E6=9D=A1=E4=B8=ADfirstrecord?= =?UTF-8?q?=3Dtrue=E7=9A=84=E6=9D=A1=E4=BB=B6=E6=94=B9=E4=B8=BAfirstrecord?= =?UTF-8?q?=3Dtrue=E4=B8=AD=E5=89=8D1000=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/web_pro.xml | 2 +- .../config/web_test.xml | 2 +- .../uav/godeye/rest/GodEyeRestService.java | 120 +++++++++--------- .../src/main/webapp/WEB-INF/web.xml | 2 +- 4 files changed, 65 insertions(+), 61 deletions(-) diff --git a/com.creditease.uav.console.buildComponent/config/web_pro.xml b/com.creditease.uav.console.buildComponent/config/web_pro.xml index 86401c52..1ff21462 100644 --- a/com.creditease.uav.console.buildComponent/config/web_pro.xml +++ b/com.creditease.uav.console.buildComponent/config/web_pro.xml @@ -211,7 +211,7 @@ uav.app.godeye.notify.mongodb.query.range - {"skip":0,"limit":20000} + {"skip":0,"limit":1000} uav.apphub.sso.admin.loginid diff --git a/com.creditease.uav.console.buildComponent/config/web_test.xml b/com.creditease.uav.console.buildComponent/config/web_test.xml index 5ce34c6e..eeb496e4 100644 --- a/com.creditease.uav.console.buildComponent/config/web_test.xml +++ b/com.creditease.uav.console.buildComponent/config/web_test.xml @@ -216,7 +216,7 @@ uav.app.godeye.notify.mongodb.query.range - {"skip":0,"limit":20000} + {"skip":0,"limit":1000} uav.apphub.sso.admin.loginid diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java index c000d1d9..f99f7b15 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java @@ -1441,14 +1441,11 @@ else if ("ALL".equals(groups)) { sortMap.put("sort", sort); list.add(sortMap); - HashMap skipMap = new HashMap(); - skipMap.put("skip", mongodbQueryRangeMap.get("skip")); - list.add(skipMap); - - HashMap limitMap = new HashMap(); - limitMap.put("limit", mongodbQueryRangeMap.get("limit")); - list.add(limitMap); - // 过滤数据,只查询最近的指定数据 end + HashMap firstRecord = new HashMap(); + firstRecord.put("firstrecord", "true"); + HashMap firstRecordMatch = new HashMap(); + firstRecordMatch.put("match", firstRecord); + list.add(firstRecordMatch); // 封装组合查询条件 if (jsonParam.containsKey("search")) { @@ -1469,11 +1466,14 @@ else if ("ALL".equals(groups)) { list.addAll(groupList); } - HashMap firstRecord = new HashMap(); - firstRecord.put("firstrecord", "true"); - HashMap firstRecordMatch = new HashMap(); - firstRecordMatch.put("match", firstRecord); - list.add(firstRecordMatch); + HashMap skipMap = new HashMap(); + skipMap.put("skip", mongodbQueryRangeMap.get("skip")); + list.add(skipMap); + + HashMap limitMap = new HashMap(); + limitMap.put("limit", mongodbQueryRangeMap.get("limit")); + list.add(limitMap); + // 过滤数据,只查询最近的指定数据 end HashMap pageIndex = new HashMap(); HashMap pageSize = new HashMap(); @@ -1553,13 +1553,13 @@ else if ("ALL".equals(groups)) { sortMap.put("sort", sort); list.add(sortMap); - HashMap skipMap = new HashMap(); - skipMap.put("skip", mongodbQueryRangeMap.get("skip")); - list.add(skipMap); + HashMap requestParam = new HashMap(); + HashMap firstRecord = new HashMap(); + HashMap firstRecordMatch = new HashMap(); + firstRecord.put("firstrecord", "true"); + firstRecordMatch.put("match", firstRecord); + list.add(firstRecordMatch); - HashMap limitMap = new HashMap(); - limitMap.put("limit", mongodbQueryRangeMap.get("limit")); - list.add(limitMap); // 过滤数据,只查询最近的指定数据 end // 封装组合查询条件 @@ -1581,13 +1581,15 @@ else if ("ALL".equals(groups)) { list.addAll(groupList); } - HashMap requestParam = new HashMap(); - HashMap firstRecord = new HashMap(); - HashMap firstRecordMatch = new HashMap(); - firstRecord.put("firstrecord", "true"); - firstRecordMatch.put("match", firstRecord); + HashMap skipMap = new HashMap(); + skipMap.put("skip", mongodbQueryRangeMap.get("skip")); + list.add(skipMap); + + HashMap limitMap = new HashMap(); + limitMap.put("limit", mongodbQueryRangeMap.get("limit")); + list.add(limitMap); + requestParam.put("count", "true"); - list.add(firstRecordMatch); list.add(requestParam); // 封装http请求数据 @@ -1667,6 +1669,14 @@ public void noitifyEvent(@Suspended AsyncResponse response) throws Exception { sort.put("sortorder", "-1"); sortMap.put("sort", sort); list.add(sortMap); + + // modify start : 只返回firstrecord为true的事件id + HashMap firstRecord = new HashMap(); + HashMap firstRecordMatch = new HashMap(); + firstRecord.put("firstrecord", "true"); + firstRecordMatch.put("match", firstRecord); + list.add(firstRecordMatch); + // modify end HashMap skipMap = new HashMap(); skipMap.put("skip", mongodbQueryRangeMap.get("skip")); @@ -1677,14 +1687,6 @@ public void noitifyEvent(@Suspended AsyncResponse response) throws Exception { list.add(limitMap); // 过滤数据,只查询最近的指定数据 end - // modify start : 只返回firstrecord为true的事件id - HashMap firstRecord = new HashMap(); - HashMap firstRecordMatch = new HashMap(); - firstRecord.put("firstrecord", "true"); - firstRecordMatch.put("match", firstRecord); - list.add(firstRecordMatch); - // modify end - list.add(requestParam); // 封装http请求数据 @@ -1753,13 +1755,12 @@ else if ("ALL".equals(groups)) { sortMap.put("sort", sort); list.add(sortMap); - HashMap skipMap = new HashMap(); - skipMap.put("skip", mongodbQueryRangeMap.get("skip")); - list.add(skipMap); + HashMap firstRecord = new HashMap(); + HashMap firstRecordMatch = new HashMap(); + firstRecord.put("firstrecord", "true"); + firstRecordMatch.put("match", firstRecord); + list.add(firstRecordMatch); - HashMap limitMap = new HashMap(); - limitMap.put("limit", mongodbQueryRangeMap.get("limit")); - list.add(limitMap); // 过滤数据,只查询最近的指定数据 end // 封装组合查询条件 list.add = and @@ -1829,18 +1830,19 @@ else if ("ALL".equals(groups)) { list.addAll(groupList); } - HashMap firstRecord = new HashMap(); - HashMap firstRecordMatch = new HashMap(); + HashMap skipMap = new HashMap(); + skipMap.put("skip", mongodbQueryRangeMap.get("skip")); + list.add(skipMap); + + HashMap limitMap = new HashMap(); + limitMap.put("limit", mongodbQueryRangeMap.get("limit")); + list.add(limitMap); + HashMap pageIndex = new HashMap(); HashMap pageSize = new HashMap(); HashMap pageSortOrder = new HashMap(); - firstRecord.put("firstrecord", "true"); - firstRecordMatch.put("match", firstRecord); pageIndex.put("pageindex", String.valueOf(jsonParam.get("pageindex"))); pageSize.put("pagesize", String.valueOf(jsonParam.get("pagesize"))); - - list.add(firstRecordMatch); - list.add(sortMap); list.add(pageIndex); list.add(pageSize); list.add(pageSortOrder); @@ -1912,13 +1914,13 @@ else if ("ALL".equals(groups)) { sortMap.put("sort", sort); list.add(sortMap); - HashMap skipMap = new HashMap(); - skipMap.put("skip", mongodbQueryRangeMap.get("skip")); - list.add(skipMap); + HashMap requestParam = new HashMap(); + HashMap firstRecord = new HashMap(); + HashMap firstRecordMatch = new HashMap(); + firstRecord.put("firstrecord", "true"); + firstRecordMatch.put("match", firstRecord); + list.add(firstRecordMatch); - HashMap limitMap = new HashMap(); - limitMap.put("limit", mongodbQueryRangeMap.get("limit")); - list.add(limitMap); // 过滤数据,只查询最近的指定数据 end // 封装组合查询条件 list.add = and @@ -1988,13 +1990,15 @@ else if ("ALL".equals(groups)) { list.addAll(groupList); } - HashMap requestParam = new HashMap(); - HashMap firstRecord = new HashMap(); - HashMap firstRecordMatch = new HashMap(); - firstRecord.put("firstrecord", "true"); - firstRecordMatch.put("match", firstRecord); + HashMap skipMap = new HashMap(); + skipMap.put("skip", mongodbQueryRangeMap.get("skip")); + list.add(skipMap); + + HashMap limitMap = new HashMap(); + limitMap.put("limit", mongodbQueryRangeMap.get("limit")); + list.add(limitMap); + requestParam.put("count", "true"); - list.add(firstRecordMatch); list.add(requestParam); // 封装http请求数据 diff --git a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml index ab9a18ee..6e300e01 100644 --- a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml +++ b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml @@ -223,7 +223,7 @@ uav.app.godeye.notify.mongodb.query.range - {"skip":0,"limit":20000} + {"skip":0,"limit":1000} uav.apphub.sso.admin.loginid From 4d44e7a30cf11e59eac79b4d42d25f58a8332ad5 Mon Sep 17 00:00:00 2001 From: xiaolong Date: Fri, 23 Mar 2018 15:27:20 +0800 Subject: [PATCH 39/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/225=201.fix=20HttpDataCatchWorker=20=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=85=B3=E9=97=ADhttpclient=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=202.=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9Btimeout=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/agent.properties | 1 + .../config/ma_pro.properties | 1 + .../config/ma_test.properties | 1 + .../hbagent/HeartBeatServerLifeKeeper.java | 8 +-- .../BaseHttpMonitorDataCatchWorker.java | 52 ++++++++++++++----- .../datacatch/BaseMonitorDataCatchWorker.java | 4 +- .../JMXAppServerMonitorDataCatchWorker.java | 9 +++- .../jmx/JMXJavaMonitorDataCatchWorker.java | 9 +++- .../monitoragent/detect/BaseDetector.java | 2 + .../detect/JVMContainerOSDetector.java | 5 +- .../appmonitor/js/uav.appmonitor.js | 27 ++++++++-- .../config/agent.properties | 4 +- .../config/hm_pro_apphubmgr.properties | 2 +- .../config/hm_pro_hbserver.properties | 2 +- .../config/hm_pro_pfntfyserver.properties | 4 +- .../config/hm_test_pnhbserver.properties | 4 +- .../HealthManagerProfileDataLifeKeeper.java | 10 ++-- 17 files changed, 109 insertions(+), 36 deletions(-) diff --git a/com.creditease.uav.agent.buildComponent/config/agent.properties b/com.creditease.uav.agent.buildComponent/config/agent.properties index d68680a1..0ecb6e9f 100644 --- a/com.creditease.uav.agent.buildComponent/config/agent.properties +++ b/com.creditease.uav.agent.buildComponent/config/agent.properties @@ -109,6 +109,7 @@ feature.monitoragent.http.enable=false feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient #monitoragent detect interval default is 30000 feature.monitoragent.detector.interval=30000 +feature.monitoragent.detector.profilehbtimeout=15000 #enable local scan by jvm tool and jmx feature.monitoragent.detector.local.scan.enable=true #enable container scan by http diff --git a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties index 5404aa36..a69b8cc1 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties @@ -101,6 +101,7 @@ feature.monitoragent.http.enable=false feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient #monitoragent detect interval default is 30000 feature.monitoragent.detector.interval=30000 +feature.monitoragent.detector.profilehbtimeout=15000 #enable local scan by jvm tool and jmx feature.monitoragent.detector.local.scan.enable=true #enable container scan by http diff --git a/com.creditease.uav.agent.buildComponent/config/ma_test.properties b/com.creditease.uav.agent.buildComponent/config/ma_test.properties index 7fba8958..32f05780 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_test.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_test.properties @@ -101,6 +101,7 @@ feature.monitoragent.http.enable=false feature.monitoragent.jvm.filters=com.sun.tools,sun.tools,jenkins-cli.jar,com.creditease.agent.feature.nodeopagent.NodeOperCtrlClient #monitoragent detect interval default is 30000 feature.monitoragent.detector.interval=30000 +feature.monitoragent.detector.profilehbtimeout=15000 #enable local scan by jvm tool and jmx feature.monitoragent.detector.local.scan.enable=true #enable container scan by http diff --git a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/hbagent/HeartBeatServerLifeKeeper.java b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/hbagent/HeartBeatServerLifeKeeper.java index 2fa79b8a..204035de 100644 --- a/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/hbagent/HeartBeatServerLifeKeeper.java +++ b/com.creditease.uav.agent.heartbeat/src/main/java/com/creditease/agent/feature/hbagent/HeartBeatServerLifeKeeper.java @@ -41,7 +41,7 @@ public class HeartBeatServerLifeKeeper extends AbstractTimerWork { private long lockTimeout = 60000; - private long nodeDyingTimeout = 40000; + private long nodeDyingTimeout = 15000; private CacheManager cacheManager; @@ -129,19 +129,19 @@ public void run() { } // node is in dying state - if (timeout >= this.nodeDyingTimeout && timeout < this.nodeDyingTimeout * 5) { + if (timeout >= this.nodeDyingTimeout && timeout < this.nodeDyingTimeout * 2) { nodeInfo.putInfo(InfoType.Node, "state", "0"); nodeInfoMap.put(nodeId, nodeInfo.toJSONString()); cm.putHash(HeartBeatProtocol.STORE_REGION_UAV, HeartBeatProtocol.STORE_KEY_NODEINFO, nodeInfoMap); } // node is in dead state - else if (timeout >= this.nodeDyingTimeout * 5 && timeout < this.nodeDyingTimeout * 10) { + else if (timeout >= this.nodeDyingTimeout * 2 && timeout < this.nodeDyingTimeout * 3) { nodeInfo.putInfo(InfoType.Node, "state", "-1"); nodeInfoMap.put(nodeId, nodeInfo.toJSONString()); cm.putHash(HeartBeatProtocol.STORE_REGION_UAV, HeartBeatProtocol.STORE_KEY_NODEINFO, nodeInfoMap); } // clean this node info - else if (timeout >= this.nodeDyingTimeout * 10) { + else if (timeout >= this.nodeDyingTimeout * 3) { cm.delHash(HeartBeatProtocol.STORE_REGION_UAV, HeartBeatProtocol.STORE_KEY_NODEINFO, nodeId); } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseHttpMonitorDataCatchWorker.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseHttpMonitorDataCatchWorker.java index e9f7f189..40a7928c 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseHttpMonitorDataCatchWorker.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseHttpMonitorDataCatchWorker.java @@ -77,11 +77,19 @@ public void setE(Throwable e) { protected HttpAsyncClient client; + private long profileHBTimeout; + public BaseHttpMonitorDataCatchWorker(String cName, String feature, JVMAgentInfo appServerInfo, BaseDetector detector) { + super(cName, feature, appServerInfo, detector); - client = HttpAsyncClientFactory.build(2, 5, 2, 2, 2); + client = HttpAsyncClientFactory.build(2, 5, 2000, 2000, 2000); + + String profileHBTimeoutStr = this.getConfigManager().getFeatureConfiguration(feature, + "detector.profilehbtimeout"); + profileHBTimeout = StringHelper.isEmpty(profileHBTimeoutStr) ? 15000 : Long.parseLong(profileHBTimeoutStr); + } @Override @@ -203,7 +211,7 @@ protected boolean doCaptureProfileData(long timeFlag, MonitorDataFrame pmdf) thr * this data is old, but need for profile heartbeat even the if Update = false, but we will still pass the * profile data as a heartbeat for profiledata the heart beat interval = 1 min */ - else if (isUpdate == false && curTime - state.getProfileTimestamp() > 60000) { + else if (isUpdate == false && curTime - state.getProfileTimestamp() > profileHBTimeout) { isRefreshTimestamp = true; pmdf.setTag("P:HB"); } @@ -237,16 +245,7 @@ else if (isUpdate == false && curTime - state.getProfileTimestamp() > 60000) { * * NOTE: if there is no special appgroup, use MonitorAgent appgroup */ - String uavMAAppGroup = System.getProperty("JAppGroup"); - - String appGroup = this.appServerInfo.getSystemProperties().getProperty("JAppGroup"); - - if (!StringHelper.isEmpty(appGroup)) { - webapp.put("appgroup", appGroup); - } - else if (!StringHelper.isEmpty(uavMAAppGroup)) { - webapp.put("appgroup", uavMAAppGroup); - } + webapp.put("appgroup", this.getAppGroup()); /** * 【2】自定义指标 @@ -384,10 +383,10 @@ public void failed(HttpClientCallbackResult result) { }; if (postData == null) { - client.doAsyncHttpGet(serviceURL, callback); + getHttpAsyncClient().doAsyncHttpGet(serviceURL, callback); } else { - client.doAsyncHttpPost(serviceURL, postData, callback); + getHttpAsyncClient().doAsyncHttpPost(serviceURL, postData, callback); } // timeout for response @@ -437,4 +436,29 @@ public int start() { return 1; } + @Override + public void cancel() { + + super.cancel(); + + if (client != null) { + client.shutdown(); + } + } + + /** + * get HttpAsyncClient unsafe + * + * @return HttpAsyncClient + */ + private HttpAsyncClient getHttpAsyncClient() { + + if (client != null) { + return client; + } + + client = HttpAsyncClientFactory.build(2, 5, 2000, 2000, 2000); + + return client; + } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java index e84f2a9d..2da86ac8 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java @@ -77,6 +77,7 @@ public void setProfileTimestamp(long t) { protected Map customizedMetrics = new HashMap<>(); public BaseMonitorDataCatchWorker(String cName, String feature, JVMAgentInfo appServerInfo, BaseDetector detector) { + super(cName, feature); this.detector = detector; this.appServerInfo = appServerInfo; @@ -155,7 +156,8 @@ protected String getAppGroup() { /** * NOTE: if there is no special appgroup, use MonitorAgent appgroup */ - if (!StringHelper.isEmpty(uavMAAppGroup) && StringHelper.isEmpty(appGroup)) { + if (!StringHelper.isEmpty(uavMAAppGroup) && (StringHelper.isEmpty(appGroup) + || "UNKNOWN".equalsIgnoreCase(appGroup))) { appGroup = uavMAAppGroup; } return appGroup; diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXAppServerMonitorDataCatchWorker.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXAppServerMonitorDataCatchWorker.java index 92a55d36..b3b44136 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXAppServerMonitorDataCatchWorker.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXAppServerMonitorDataCatchWorker.java @@ -45,9 +45,16 @@ public class JMXAppServerMonitorDataCatchWorker extends BaseJMXMonitorDataCatchWorker { + private long profileHBTimeout; + public JMXAppServerMonitorDataCatchWorker(String cName, String feature, JVMAgentInfo appServerInfo, BaseDetector detector) { + super(cName, feature, appServerInfo, detector); + + String profileHBTimeoutStr = this.getConfigManager().getFeatureConfiguration(feature, + "detector.profilehbtimeout"); + profileHBTimeout = StringHelper.isEmpty(profileHBTimeoutStr) ? 15000 : Long.parseLong(profileHBTimeoutStr); } @Override @@ -184,7 +191,7 @@ protected boolean doCaptureProfileData(MBeanServerConnection mbsc, long timeFlag * this data is old, but need for profile heartbeat even the if Update = false, but we will still pass * the profile data as a heartbeat for profiledata the heart beat interval = 1 min */ - else if (isUpdate == false && curTime - state.getProfileTimestamp() > 60000) { + else if (isUpdate == false && curTime - state.getProfileTimestamp() > profileHBTimeout) { isRefreshTimestamp = true; pmdf.setTag("P:HB"); } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXJavaMonitorDataCatchWorker.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXJavaMonitorDataCatchWorker.java index 4af36b73..84e5d723 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXJavaMonitorDataCatchWorker.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/jmx/JMXJavaMonitorDataCatchWorker.java @@ -159,11 +159,18 @@ public Map handle(ObjectInstance oi, MBeanServerConnection mbsc) // localIP protected String localIP; + private long profileHBTimeout; + public JMXJavaMonitorDataCatchWorker(String cName, String feature, JVMAgentInfo appServerInfo, BaseDetector detector) { + super(cName, feature, appServerInfo, detector); collectJavaProcRunInfo(appServerInfo); + + String profileHBTimeoutStr = this.getConfigManager().getFeatureConfiguration(feature, + "detector.profilehbtimeout"); + profileHBTimeout = StringHelper.isEmpty(profileHBTimeoutStr) ? 15000 : Long.parseLong(profileHBTimeoutStr); } /** @@ -271,7 +278,7 @@ private void doCaptureProfileData(long timeFlag) { else { long curTime = System.currentTimeMillis(); - if (curTime - state.getProfileTimestamp() < 60000) { + if (curTime - state.getProfileTimestamp() < profileHBTimeout) { return; } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java index 9e05b686..9621bcc1 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java @@ -117,6 +117,7 @@ protected void addWorker(JVMAgentInfo appServerInfo) { int res = worker.start(); if (res == -1) { + worker.cancel(); return; } @@ -127,6 +128,7 @@ protected void addWorker(JVMAgentInfo appServerInfo) { worker = newWoker(appServerInfo, workerName, "unknown"); if (worker.start() == -1) { + worker.cancel(); return; } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java index 99279fee..9e49d8bc 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java @@ -55,6 +55,7 @@ private class ScanPingCallback implements HttpClientCallback { private OSProcess proc; public ScanPingCallback(OSProcess proc, String url) { + this.url = url; this.proc = proc; } @@ -115,6 +116,7 @@ private class GetSystemInfoCallback implements HttpClientCallback { private String vendor; public GetSystemInfoCallback(OSProcess proc, String url, String vendor) { + this.url = url; this.proc = proc; this.vendor = vendor; @@ -187,13 +189,14 @@ public void failed(HttpClientCallbackResult result) { protected String[] scanPorts = new String[0]; public JVMContainerOSDetector(String cName, String feature, String initHandlerKey, long detectInterval) { + super(cName, feature, initHandlerKey, detectInterval); String ports = this.getConfigManager().getFeatureConfiguration(this.feature, "detector.container.ports"); configScanPorts(ports); - client = HttpAsyncClientFactory.build(5, 100, 1, 1, 1); + client = HttpAsyncClientFactory.build(5, 100, 1000, 1000, 1000); } @Override diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js index 465e506d..ab891838 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js @@ -1375,13 +1375,18 @@ var mvcObj={ nodeInfoObj["id"]=key; var appgroup=nodeInfoObj["appgroup"]; + var appid=nodeInfoObj["appid"]; if (appgroup==undefined||appgroup=="") { ungroupNodes[ungroupNodes.length]=nodeInfoObj; } else { var ip=nodeInfoObj["ip"]; - ipToAppGroup[ip]=appgroup; + if(ipToAppGroup[ip]==undefined){ + ipToAppGroup[ip]=[]; + } + + ipToAppGroup[ip][appid]=appgroup; } nodeArray[nodeArray.length]=nodeInfoObj; @@ -1391,8 +1396,8 @@ var mvcObj={ for(var i=0;i= this.nodeDyingTimeout && timeout < this.nodeDyingTimeout * 5) { + if (timeout >= this.nodeDyingTimeout && timeout < this.nodeDyingTimeout * 2) { appInstProfile.put("state", "0"); nodeInfoMap.put(nodeId, JSONHelper.toString(appInstProfile)); cm.putHash(HealthManagerConstants.STORE_REGION_UAV, HealthManagerConstants.STORE_KEY_PROFILEINFO, nodeInfoMap); } // node is in dead state - else if (timeout >= this.nodeDyingTimeout * 5 && timeout < this.nodeDyingTimeout * 10) { + else if (timeout >= this.nodeDyingTimeout * 2 && timeout < this.nodeDyingTimeout * 3) { appInstProfile.put("state", "-1"); nodeInfoMap.put(nodeId, JSONHelper.toString(appInstProfile)); cm.putHash(HealthManagerConstants.STORE_REGION_UAV, HealthManagerConstants.STORE_KEY_PROFILEINFO, nodeInfoMap); } // clean this node info - else if (timeout >= this.nodeDyingTimeout * 10) { + else if (timeout >= this.nodeDyingTimeout * 3) { // delete profile data cm.delHash(HealthManagerConstants.STORE_REGION_UAV, HealthManagerConstants.STORE_KEY_PROFILEINFO, nodeId); From 1f9e1f428cf8e661ed06ac6a4caed6ef307cf6c8 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 23 Mar 2018 18:26:03 +0800 Subject: [PATCH 40/97] https://github.com/uavorg/uavstack/issues/228 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.onAppClientUpdate方法中对携带tfilters的节点不做clientUpdate的缓存 --- .../main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js index ab6ab4a4..780b3bf3 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js @@ -991,7 +991,9 @@ function AppServiceStream(app) { var clientCache = acData["clientCache"]; if(clientCache[appInst["id"]]==true){ return; - }else{ + } + //do not cache the node generated by iplink, because the node will do several clientUpdate + else if(appInstNode["extattrs"]["tfilters"]==undefined){ clientCache[appInst["id"]]=true; } From 7dedca8d3dbc695dbc9881b163ea04db574771e6 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 23 Mar 2018 19:42:02 +0800 Subject: [PATCH 41/97] https://github.com/uavorg/uavstack/issues/229 #212 put HTTP Detector ahead of JMX Detector #229 filter the process and ports that has been detected --- .../agent/feature/MonitorAgent.java | 42 ++++----- .../datacatch/BaseMonitorDataCatchWorker.java | 5 ++ .../monitoragent/detect/BaseDetector.java | 4 +- .../detect/JVMContainerOSDetector.java | 86 +++++++++++++++---- 4 files changed, 98 insertions(+), 39 deletions(-) diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/MonitorAgent.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/MonitorAgent.java index 471d7c1c..5cd13bad 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/MonitorAgent.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/MonitorAgent.java @@ -111,8 +111,27 @@ private void startAppServerMonitorDetector() { // init DetectorManager DetectorManager appServerMonitorDetector_TimerWorker = new DetectorManager( - "AppServerMonitorDetector_TimerWorker", this.feature); + "AppServerMonitorDetector_TimerWorker", this.feature); + boolean isContainerDetectEnable = DataConvertHelper.toBoolean( + this.getConfigManager().getFeatureConfiguration(this.feature, "detector.container.scan.enable"), false); + + if (isContainerDetectEnable == true) { + // init JVMContainerOSDetector + JVMContainerOSDetector cosd = new JVMContainerOSDetector("JVMContainerOSDetector", this.feature, + "modatahandlers", detectInterval); + + cosd.register("appserver", + "com.creditease.agent.feature.monitoragent.datacatch.http.HttpAppServerMonitorDataCatchWorker"); + cosd.register("mscp", + "com.creditease.agent.feature.monitoragent.datacatch.http.HttpMSCPMonitorDataCatchWorker"); + cosd.register("springboot", + "com.creditease.agent.feature.monitoragent.datacatch.http.HttpSpringBootMonitorDataCatchWorker"); + + // install JVMContainerOSDetector + appServerMonitorDetector_TimerWorker.installDetector(cosd); + } + boolean isLocalOSDetectEnable = DataConvertHelper.toBoolean( this.getConfigManager().getFeatureConfiguration(this.feature, "detector.local.scan.enable"), true); @@ -133,26 +152,7 @@ private void startAppServerMonitorDetector() { // install JVMLocalOSDetector appServerMonitorDetector_TimerWorker.installDetector(asmd); } - - boolean isContainerDetectEnable = DataConvertHelper.toBoolean( - this.getConfigManager().getFeatureConfiguration(this.feature, "detector.container.scan.enable"), false); - - if (isContainerDetectEnable == true) { - // init JVMContainerOSDetector - JVMContainerOSDetector cosd = new JVMContainerOSDetector("JVMContainerOSDetector", this.feature, - "modatahandlers", detectInterval); - - cosd.register("appserver", - "com.creditease.agent.feature.monitoragent.datacatch.http.HttpAppServerMonitorDataCatchWorker"); - cosd.register("mscp", - "com.creditease.agent.feature.monitoragent.datacatch.http.HttpMSCPMonitorDataCatchWorker"); - cosd.register("springboot", - "com.creditease.agent.feature.monitoragent.datacatch.http.HttpSpringBootMonitorDataCatchWorker"); - - // install JVMContainerOSDetector - appServerMonitorDetector_TimerWorker.installDetector(cosd); - } - + // start ApplicationServerMonitorDetector this.getTimerWorkManager().scheduleWork("AppServerMonitorDetector_TimerWorker", appServerMonitorDetector_TimerWorker, 0, detectInterval); diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java index 2da86ac8..f45cf1b7 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/datacatch/BaseMonitorDataCatchWorker.java @@ -206,4 +206,9 @@ public String getWorkerIdFromSystemProForAppServer() { return workerid; } + + public String getDetectorName() { + + return detector.getName(); + } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java index 9621bcc1..056b31cf 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java @@ -93,7 +93,9 @@ protected void addWorker(JVMAgentInfo appServerInfo) { /** * If the worker exists, just update the appServerInfo this is the hyperspace dark tech, hehe, hehe, hehe :) */ - this.workers.get(workerName).setAppServerInfo(appServerInfo); + if(this.cName.equals(this.workers.get(workerName).getDetectorName())) { + this.workers.get(workerName).setAppServerInfo(appServerInfo); + } return; } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java index 9e49d8bc..40d75949 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java @@ -21,9 +21,12 @@ package com.creditease.agent.feature.monitoragent.detect; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Properties; +import com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker; import com.creditease.agent.helpers.JSONHelper; import com.creditease.agent.helpers.StringHelper; import com.creditease.agent.helpers.jvmtool.JVMAgentInfo; @@ -279,23 +282,11 @@ private void scanWithProcDetection() { continue; } - for (String port : proc.getPorts()) { - String baseurl; - - /** - * option 1:ip:port - */ - if (port.indexOf(":") > -1) { - baseurl = "http://" + port; - } - /** - * option 2: port only - */ - else { - baseurl = "http://127.0.0.1:" + port; - } - - client.doAsyncHttpGet(baseurl + UAV_MOF_ROOT + "jvm?action=ping", new ScanPingCallback(proc, baseurl)); + List needDectectUrls=getDetectUrls(proc); + + for(String url: needDectectUrls) { + + client.doAsyncHttpGet(url + UAV_MOF_ROOT + "jvm?action=ping", new ScanPingCallback(proc, url)); } } } @@ -319,5 +310,66 @@ public void onConfigUpdate(Properties updatedConfig) { configScanPorts(ports); } } + + /** + * get urls which need detect + */ + private List getDetectUrls(OSProcess proc) { + + List urlList=new LinkedList(); + + for (String port : proc.getPorts()) { + + String url; + + /** + * option 1:ip:port + */ + if (port.indexOf(":") > -1) { + url = "http://" + port; + } + /** + * option 2: port only + */ + else { + url = baseurl + ":" + port; + } + + if(workerExist(proc.getPid(),url,urlList)) { + return urlList; + } + } + + return urlList; + } + + /** + * check if the worker for this appServer exist + */ + public boolean workerExist(String pid,String url,List urlList) { + + String JVMAccessURL = url + UAV_MOF_ROOT; + + for(BaseMonitorDataCatchWorker worker:workers.values()) { + + JVMAgentInfo appServerInfo = jvmAgentInfos.get(worker.getWorkerId()); + + if(appServerInfo!=null && JVMAccessURL.equals((appServerInfo.getJVMAccessURL()))) { + + urlList.clear(); + + if(!pid.equals(appServerInfo.getId())) { + + // remove worker whose JVMAccessURL is the same but pid changes(usually restart) + removeWorker(worker.getName()); + + urlList.add(url); + } + return true; + } + } + urlList.add(url); + return false; + } } From 69ba991d283c44568c2e33a4b3a4a2886969d554 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 23 Mar 2018 20:06:45 +0800 Subject: [PATCH 42/97] https://github.com/uavorg/uavstack/issues/229 add leave out code --- .../feature/monitoragent/detect/JVMContainerOSDetector.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java index 40d75949..9cecaa4a 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java @@ -191,6 +191,8 @@ public void failed(HttpClientCallbackResult result) { protected String[] scanPorts = new String[0]; + protected String baseurl = "http://127.0.0.1"; + public JVMContainerOSDetector(String cName, String feature, String initHandlerKey, long detectInterval) { super(cName, feature, initHandlerKey, detectInterval); From 5be46f0a2dc4e47ac1a5a8d201c8eb08b469dd50 Mon Sep 17 00:00:00 2001 From: xinyuzhou1 Date: Tue, 27 Mar 2018 15:10:33 +0800 Subject: [PATCH 43/97] https://github.com/uavorg/uavstack/issues/232 Change admin's password --- com.creditease.uav.console.buildComponent/config/web_pro.xml | 2 +- com.creditease.uav.console.buildComponent/config/web_test.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.console.buildComponent/config/web_pro.xml b/com.creditease.uav.console.buildComponent/config/web_pro.xml index 1ff21462..8f294db8 100644 --- a/com.creditease.uav.console.buildComponent/config/web_pro.xml +++ b/com.creditease.uav.console.buildComponent/config/web_pro.xml @@ -219,7 +219,7 @@ uav.apphub.sso.admin.password - Uav!630admin + 123456 uav.apphub.sso.guest.loginid diff --git a/com.creditease.uav.console.buildComponent/config/web_test.xml b/com.creditease.uav.console.buildComponent/config/web_test.xml index eeb496e4..28d97594 100644 --- a/com.creditease.uav.console.buildComponent/config/web_test.xml +++ b/com.creditease.uav.console.buildComponent/config/web_test.xml @@ -224,7 +224,7 @@ uav.apphub.sso.admin.password - Uav!1227admin + 123456 uav.apphub.sso.guest.loginid From 736d32e9d3e8d78e5acadd7d39e6f4a496e30180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 30 Mar 2018 14:25:38 +0800 Subject: [PATCH 44/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/234=20FIX=20=E8=BF=9B=E7=A8=8B=E6=AD=BB=E4=BA=A1=E6=8A=A5?= =?UTF-8?q?=E8=AD=A6=E4=B8=ADip=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java index 2613e189..217b552e 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java @@ -460,7 +460,7 @@ private void fireEvent(Map> deadProcs) { + ceo.getDeadProcNamesAsString() + "可疑死掉"; String description = ceo.getDeadProcsInfoAsString(); - NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_CRASH, title, description); + NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_CRASH, title, description, System.currentTimeMillis(), ceo.getIp(), ""); /** * Notification Manager will not block the event, the frozen time has no effect to this event From 39832f2dccf32e16148a78126c5e2a4aa375b7f5 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Fri, 30 Mar 2018 14:26:35 +0800 Subject: [PATCH 45/97] https://github.com/uavorg/uavstack/issues/235 Apphub Ulog Client Ip Incorrect bug fix --- .../com/creditease/uav/apphub/filter/SessionAsyncFilter.java | 2 +- .../main/java/com/creditease/uav/apphub/rest/GUIService.java | 4 ++-- .../apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java index 62acaaf9..9f3b15c5 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java @@ -248,7 +248,7 @@ private void userLoggerInfo(HttpServletRequest request) { */ String ip = request.getRemoteAddr(); - String xip = request.getHeader("X-Forward-For"); + String xip = request.getHeader("X-Forwarded-For"); String time = sdf.format(new Date()); String userid = getUserIdBySession(request); diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java index bd5b0a59..13898971 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java @@ -215,7 +215,7 @@ else if (loginRegister(loginId, loginPwd, request)) { monitor.flushToSystemProperties(); String ip = request.getRemoteAddr(); - String xip = request.getHeader("X-Forward-For"); + String xip = request.getHeader("X-Forwarded-For"); String userip = getClientIP(ip, xip); Map userInfo = new HashMap(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -258,7 +258,7 @@ public void loginOut() { Object obj = request.getSession(false).getAttribute("apphub.gui.session.login.user.id"); String userId = null == obj ? "" : String.valueOf(obj); String ip = request.getRemoteAddr(); - String xip = request.getHeader("X-Forward-For"); + String xip = request.getHeader("X-Forwarded-For"); String userip = getClientIP(ip, xip); Map userInfo = new HashMap(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java index 444a045b..364896ca 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java @@ -126,7 +126,7 @@ protected void doRequest(HttpServletRequest request, HttpServletResponse respons } String clientip = MonitorServerUtil.getClientIP(httprequest.getRemoteAddr(), - httprequest.getHeader("X-Forward-For")); + httprequest.getHeader("X-Forwarded-For")); // put intercept context params.put(InvokeChainConstants.PARAM_INTECEPTCONTEXT, context); From 368f2fca79ae8226e8de41a4907eca008dd5b9be Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Fri, 30 Mar 2018 14:34:25 +0800 Subject: [PATCH 46/97] https://github.com/uavorg/uavstack/issues/235 Apphub Ulog Client Ip Incorrect bug fix --- .../java/com/creditease/uav/godeye/rest/GodEyeRestService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java index f99f7b15..3f3fedd8 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/GodEyeRestService.java @@ -2146,7 +2146,7 @@ public void doNodeCtrlOperation(String data, @Suspended AsyncResponse response) } String ip = request.getRemoteAddr(); - String xip = request.getHeader("X-Forward-For"); + String xip = request.getHeader("X-Forwarded-For"); ip = getClientIP(ip, xip); msg.getRequest().put("uid", uid); From 81c5e1b8fc7df2cd37cfcf9c1fccce7709131f00 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 30 Mar 2018 15:13:22 +0800 Subject: [PATCH 47/97] https://github.com/uavorg/uavstack/issues/238 1.PLogger add isEnableFileOutSus/isEnableConsoleOutSus to mark if the Logger could log into file/console. If could not,then do nothing 2.support start fail if DataLoggerManager could create log's rootdir. 3.UAVServer's startsupporter method return supporter's status,such as OK/Exist/Fail --- .../config/agent.properties | 2 +- .../config/hm_pro_pfntfyserver.properties | 2 +- .../config/hm_test_pnhbserver.properties | 2 +- .../com/creditease/agent/log/PLogger.java | 27 ++++++++++-- .../creditease/agent/log/api/IPLogger.java | 4 +- .../com/creditease/monitor/UAVServer.java | 25 +++++++---- .../jee/UAVServerJEEController.java | 7 ++- .../creditease/monitor/log/DataLogger.java | 13 ++++-- .../monitor/log/DataLoggerManager.java | 27 +++++++++++- .../handlers/ComponentProfileHandler.java | 43 ------------------- 10 files changed, 82 insertions(+), 70 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index e674c06f..dbb2d7c8 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -144,7 +144,7 @@ feature.healthmanager.http.bqsize=10 feature.healthmanager.lifekeeper.enable=true feature.healthmanager.lifekeeper.interval=15000 feature.healthmanager.lifekeeper.locktimeout=30000 -feature.healthmanager.lifekeeper.apptimeout=15000 +feature.healthmanager.lifekeeper.apptimeout=22000 feature.healthmanager.store.addr=127.0.0.1:6379 feature.healthmanager.store.concurrent.min=10 feature.healthmanager.store.concurrent.max=20 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties index 3daf833c..86909548 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_pfntfyserver.properties @@ -107,7 +107,7 @@ feature.healthmanager.http.bqsize=20 feature.healthmanager.lifekeeper.enable=true feature.healthmanager.lifekeeper.interval=15000 feature.healthmanager.lifekeeper.locktimeout=30000 -feature.healthmanager.lifekeeper.apptimeout=15000 +feature.healthmanager.lifekeeper.apptimeout=22000 feature.healthmanager.store.addr=127.0.0.1:26379 feature.healthmanager.store.concurrent.min=50 feature.healthmanager.store.concurrent.max=150 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties index 3614ac5b..9c31b55d 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_pnhbserver.properties @@ -178,7 +178,7 @@ feature.healthmanager.http.bqsize=5 feature.healthmanager.lifekeeper.enable=true feature.healthmanager.lifekeeper.interval=15000 feature.healthmanager.lifekeeper.locktimeout=30000 -feature.healthmanager.lifekeeper.apptimeout=15000 +feature.healthmanager.lifekeeper.apptimeout=22000 feature.healthmanager.store.addr=127.0.0.1:6379 feature.healthmanager.store.concurrent.min=50 feature.healthmanager.store.concurrent.max=200 diff --git a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java index a3fb1b6e..35f6fe25 100644 --- a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java +++ b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java @@ -120,8 +120,11 @@ private static Level getLevel(LogLevel level) { private FileHandler fileHandler = null; private MemoryHandler memHandler = null; private Level level = Level.INFO; - + private boolean isEnableFileOutSus = false; + private boolean isEnableConsoleOutSus = false; + public PLogger(String name) { + log = Logger.getLogger(name); log.setUseParentHandlers(false); } @@ -146,7 +149,15 @@ public void setLogLevel(LogLevel level) { @Override public void log(LogLevel level, String info, Object... objects) { + /** + * NOTE: only when enable is OK to record the log + */ + if (isEnableFileOutSus == false && isEnableConsoleOutSus == false) { + return; + } + Level l = getLevel(level); + log.log(l, info, objects); } @@ -187,7 +198,7 @@ public void finer(String info, Object... objects) { } @Override - public void enableConsoleOut(boolean check) { + public boolean enableConsoleOut(boolean check) { if (check == true) { if (this.consoleHandler == null) { @@ -196,16 +207,20 @@ public void enableConsoleOut(boolean check) { this.consoleHandler.setFormatter(new DefaultLogFormatter()); } log.addHandler(this.consoleHandler); + isEnableConsoleOutSus = true; } else { if (this.consoleHandler != null) { log.removeHandler(this.consoleHandler); } + isEnableConsoleOutSus = false; } + + return isEnableConsoleOutSus; } @Override - public void enableFileOut(String filepattern, boolean check, int bufferSize, int fileSize, int fileCount, + public boolean enableFileOut(String filepattern, boolean check, int bufferSize, int fileSize, int fileCount, boolean isAppend, Formatter format) { if (check == true) { @@ -222,16 +237,20 @@ public void enableFileOut(String filepattern, boolean check, int bufferSize, int /** * NOTE: we use async log buffer */ - if (this.memHandler == null) { + if (this.memHandler == null&& this.fileHandler != null) { this.memHandler = new MemoryHandler(this.fileHandler, bufferSize, this.level); this.log.addHandler(this.memHandler); + isEnableFileOutSus = true; } } else { if (this.memHandler != null) { log.removeHandler(this.memHandler); + isEnableFileOutSus = false; } } + + return isEnableFileOutSus; } /** diff --git a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/api/IPLogger.java b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/api/IPLogger.java index 3cea3771..2dc62b78 100644 --- a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/api/IPLogger.java +++ b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/api/IPLogger.java @@ -30,9 +30,9 @@ public enum LogLevel { public void setLogLevel(LogLevel level); - public void enableConsoleOut(boolean check); + public boolean enableConsoleOut(boolean check); - public void enableFileOut(String filepattern, boolean check, int bufferSize, int fileSize, int fileCount, + public boolean enableFileOut(String filepattern, boolean check, int bufferSize, int fileSize, int fileCount, boolean isAppend, Formatter format); public void log(LogLevel level, String info, Object... objects); diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/UAVServer.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/UAVServer.java index a307d61e..2b15686e 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/UAVServer.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/UAVServer.java @@ -23,10 +23,8 @@ import java.io.File; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Properties; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import com.creditease.agent.helpers.IOHelper; @@ -314,17 +312,19 @@ private void startDefaultSupporters() { * * @param supporterClasses * @param cl + * + * @return Supporter Status */ - public Set startSupporters(String[] supporterClasses, boolean needPersist) { + public Map startSupporters(String[] supporterClasses, boolean needPersist) { ClassLoader cl = this.getClass().getClassLoader(); - Set existSupporters = new HashSet(); + Map supportersStatus = new HashMap(); for (String supporterClass : supporterClasses) { if (supporters.containsKey(supporterClass)) { - existSupporters.add(supporterClass); + supportersStatus.put(supporterClass, "Exist"); continue; } @@ -346,21 +346,28 @@ public Set startSupporters(String[] supporterClasses, boolean needPersis if (log.isLogEnabled()) { log.info("Supporter[" + supporterClass + "] starts SUCCESS"); } + + supportersStatus.put(supporterClass, "OK"); + + if (needPersist) { + this.metaMgr.addSupporterMeta(supporterClasses); + } + } catch (Exception e) { supporters.remove(supporterClass); + + supportersStatus.put(supporterClass, "Fail:" + e.toString()); log.error("Supporter[" + supporterClass + "] starts FAIL", e); } } - if (needPersist) { - this.metaMgr.addSupporterMeta(supporterClasses); - } + - return existSupporters; + return supportersStatus; } public void stop() { diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/globalfilter/jee/UAVServerJEEController.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/globalfilter/jee/UAVServerJEEController.java index f586f2bb..78addd14 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/globalfilter/jee/UAVServerJEEController.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/globalfilter/jee/UAVServerJEEController.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -79,9 +78,9 @@ private void controlSupporters(HttpServletRequest request, HttpServletResponse r String retMsg = "OK"; if (isStart == true) { - Set existSupporters = UAVServer.instance().startSupporters(supporterClasses, true); - if (existSupporters.size() > 0) { - retMsg = "已启动功能:" + JSONHelper.toString(existSupporters); + Map supportersStatus = UAVServer.instance().startSupporters(supporterClasses, true); + if (supportersStatus.size() > 0) { + retMsg = JSONHelper.toString(supportersStatus); } String tag = request.getParameter("tag"); diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java index 9253e620..5793298a 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java @@ -69,15 +69,20 @@ public DataLogger(String name, String rootpath, String logFilePattern, int logBu this.logRoot = rootpath; if (!IOHelper.exists(logRoot)) { - IOHelper.createFolder(logRoot); + isInitSus = false; + return; } - log.enableFileOut(this.logRoot + "/" + this.filePattern, true, this.logBufferSize, this.fileSizeLimit, - this.fileCountLimit, true, new SimpleLogFormatter()); + isInitSus = log.enableFileOut(this.logRoot + "/" + this.filePattern, true, this.logBufferSize, + this.fileSizeLimit, this.fileCountLimit, true, new SimpleLogFormatter()); } public void logData(String info) { - + + if (isInitSus == false) { + return; + } + this.log.info(info); } diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLoggerManager.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLoggerManager.java index d76daf2a..3e997c98 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLoggerManager.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLoggerManager.java @@ -52,8 +52,33 @@ public class DataLoggerManager extends BaseComponent { * uav.properties里面该DataLoggerManager所有配置项的前缀 */ public DataLoggerManager(String logTypeName, String configPrefix) { + this.configPrefix = configPrefix; - this.logTypeName = logTypeName; + this.logTypeName = logTypeName; + + String rootPath = getRootPath(); + /** + * NOTE: check if DataLogger root path exists + * + * if not, try to create, if can't create, throw RuntimeException to stop Supporter + * + * This notify msg will be exposed to the user when he try to start this Supporter + */ + if (IOHelper.exists(rootPath)) { + return; + } + + try { + int res = IOHelper.createFolder(rootPath); + + if (res != 1) { + throw new RuntimeException("DataLogger RootPath No Auth to Create: rootpath=" + rootPath); + } + } + catch (Exception e) { + throw new RuntimeException(e); + } + } /** diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java index 852a3912..36c7005b 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java @@ -2981,8 +2981,6 @@ protected void loadCommonInfoFromWebXML(ProfileElement elem, Map metrics = new HashMap(); - // - // Enumeration enumeration = System.getProperties().propertyNames(); - // - // while (enumeration.hasMoreElements()) { - // - // String name = (String) enumeration.nextElement(); - // - // int moIndex = name.indexOf("mo@"); - // - // if (moIndex != 0) { - // continue; - // } - // - // try { - // String[] metricsArray = name.split("@"); - // - // // add metricName to customizedMetrics - // if (metricsArray.length == 3) { - // metrics.put(metricsArray[1], JSONHelper.toObject(metricsArray[2], Map.class)); - // } - // else { - // metrics.put(metricsArray[1], Collections.emptyMap()); - // } - // } - // catch (Exception e) { - // logger.error("Parsing Custom Metrics[" + name + "] FAIL.", e); - // continue; - // } - // } - // - // inst.setValue("appmetrics", JSONHelper.toString(metrics)); - // } private String getServiceURI(String contextpath) { From d3ff62ba257b5964fd8e4acfd40de7e68d707bef Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 30 Mar 2018 15:24:30 +0800 Subject: [PATCH 48/97] code format --- .../main/java/com/creditease/agent/log/PLogger.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java index 35f6fe25..962d079f 100644 --- a/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java +++ b/com.creditease.uav.logging/src/main/java/com/creditease/agent/log/PLogger.java @@ -207,16 +207,16 @@ public boolean enableConsoleOut(boolean check) { this.consoleHandler.setFormatter(new DefaultLogFormatter()); } log.addHandler(this.consoleHandler); - isEnableConsoleOutSus = true; + isEnableConsoleOutSus = true; } else { if (this.consoleHandler != null) { log.removeHandler(this.consoleHandler); } - isEnableConsoleOutSus = false; + isEnableConsoleOutSus = false; } - return isEnableConsoleOutSus; + return isEnableConsoleOutSus; } @Override @@ -240,17 +240,17 @@ public boolean enableFileOut(String filepattern, boolean check, int bufferSize, if (this.memHandler == null&& this.fileHandler != null) { this.memHandler = new MemoryHandler(this.fileHandler, bufferSize, this.level); this.log.addHandler(this.memHandler); - isEnableFileOutSus = true; + isEnableFileOutSus = true; } } else { if (this.memHandler != null) { log.removeHandler(this.memHandler); - isEnableFileOutSus = false; + isEnableFileOutSus = false; } } - return isEnableFileOutSus; + return isEnableFileOutSus; } /** From 8974cf3832d45be5feb97324e56e6cf20f8f5264 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 30 Mar 2018 15:40:46 +0800 Subject: [PATCH 49/97] add leave out code --- .../src/main/java/com/creditease/monitor/log/DataLogger.java | 1 + .../uav/profiling/handlers/ComponentProfileHandler.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java index 5793298a..01a084d6 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/log/DataLogger.java @@ -39,6 +39,7 @@ public class DataLogger { private int fileCountLimit = 10; private int logBufferSize = 200; private String logRoot = "."; + private boolean isInitSus = true; /** * diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java index 36c7005b..17db8b11 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java @@ -2981,6 +2981,8 @@ protected void loadCommonInfoFromWebXML(ProfileElement elem, Map Date: Tue, 10 Apr 2018 17:39:44 +0800 Subject: [PATCH 50/97] modify the url of HM distribution deployment --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a031069a..f6dcebe4 100644 --- a/README.md +++ b/README.md @@ -160,9 +160,9 @@ build结果 ## AllInOne开发演示版 AllInOne Install Downloads 开发演示版的健康管理服务(HM)仅适合开发环境,演示环境,小规模测试环境。 -生产环境推荐使用[分布式部署](https://uavorg.github.io/main/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) +生产环境推荐使用[分布式部署](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) -The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/main/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment +The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment * [Windows64位](https://pan.baidu.com/s/1jIF0wNs) * [Mac](https://pan.baidu.com/s/1mhCykp6) From 9638f15f0ad33ba1ddc16523538477d9f45e7c9e Mon Sep 17 00:00:00 2001 From: chongli8 Date: Thu, 12 Apr 2018 10:44:28 +0800 Subject: [PATCH 51/97] =?UTF-8?q?=E4=BC=98=E5=8C=96es=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uav/elasticsearch/client/ESClient.java | 81 ++++++++++++------- .../newlog/HMNewLogIndexMgr.java | 19 +++-- .../uav/invokechain/InvokeChainIndexMgr.java | 33 ++++---- .../uav/invokechain/SlowOperIndexMgr.java | 19 +++-- .../server/ThreadAnalysisIndexMgr.java | 33 ++++---- 5 files changed, 108 insertions(+), 77 deletions(-) diff --git a/com.creditease.uav.elasticsearch.client/src/main/java/com/creditease/uav/elasticsearch/client/ESClient.java b/com.creditease.uav.elasticsearch.client/src/main/java/com/creditease/uav/elasticsearch/client/ESClient.java index 40655776..fbc562a5 100644 --- a/com.creditease.uav.elasticsearch.client/src/main/java/com/creditease/uav/elasticsearch/client/ESClient.java +++ b/com.creditease.uav.elasticsearch.client/src/main/java/com/creditease/uav/elasticsearch/client/ESClient.java @@ -27,7 +27,7 @@ import java.util.Map; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; @@ -111,11 +111,24 @@ public boolean existIndex(String index) { * * @param index * @return + * @throws IOException */ - public boolean creatIndex(String index) { + public boolean creatIndex(String index) throws IOException { + + return creatIndex(index, null, null, null); + } + + public boolean creatIndex(String index, String type, Map set, + Map> mapping) throws IOException { - CreateIndexRequest cir = new CreateIndexRequest(index); - CreateIndexResponse resp = client.admin().indices().create(cir).actionGet(); + CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(index); + if (type != null && mapping != null) { + createIndexRequestBuilder.addMapping(type, createMapping(type, mapping)); + } + if (set != null) { + createIndexRequestBuilder.setSettings(createSetting(set)); + } + CreateIndexResponse resp = createIndexRequestBuilder.execute().actionGet(); if (resp.isAcknowledged()) { return true; @@ -124,6 +137,42 @@ public boolean creatIndex(String index) { return false; } + private Settings createSetting(Map set) { + + Settings settings = Settings.builder().put(set).build(); + + return settings; + } + + private XContentBuilder createMapping(String type, Map> properties) throws IOException { + + XContentBuilder mapping; + + mapping = jsonBuilder().startObject().startObject(type); + + mapping = mapping.startObject("properties"); + + for (String key : properties.keySet()) { + mapping = mapping.startObject(key); + + Map fv = properties.get(key); + + for (String field : fv.keySet()) { + mapping = mapping.field(field, fv.get(field)); + } + + mapping = mapping.endObject(); + } + + mapping = mapping.endObject(); + + mapping = mapping.endObject(); + + mapping = mapping.endObject(); + + return mapping; + } + /** * existType * @@ -173,29 +222,7 @@ public boolean updateIndexSetting(String index, Map set) { public boolean setIndexTypeMapping(String index, String type, Map> properties) throws IOException { - XContentBuilder mapping; - - mapping = jsonBuilder().startObject(); - - mapping = mapping.startObject("properties"); - - for (String key : properties.keySet()) { - mapping = mapping.startObject(key); - - Map fv = properties.get(key); - - for (String field : fv.keySet()) { - mapping = mapping.field(field, fv.get(field)); - } - - mapping = mapping.endObject(); - } - - mapping = mapping.endObject(); - - mapping = mapping.endObject(); - - PutMappingRequest pmp = Requests.putMappingRequest(index).type(type).source(mapping); + PutMappingRequest pmp = Requests.putMappingRequest(index).type(type).source(createMapping(type, properties)); PutMappingResponse resp = client.admin().indices().putMapping(pmp).actionGet(); return resp.isAcknowledged(); diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/healthmanager/newlog/HMNewLogIndexMgr.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/healthmanager/newlog/HMNewLogIndexMgr.java index 6d88149d..bbf3e151 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/healthmanager/newlog/HMNewLogIndexMgr.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/healthmanager/newlog/HMNewLogIndexMgr.java @@ -52,6 +52,7 @@ public class HMNewLogIndexMgr extends AbstractComponent { private ESClient client; public HMNewLogIndexMgr(String cName, String feature) { + super(cName, feature); client = (ESClient) this.getConfigManager().getComponent(this.feature, "ESClient"); @@ -141,11 +142,16 @@ public String prepareIndex(String appid) { return currentIndex; } - client.creatIndex(currentIndex); - Map set = new HashMap(); - set.put("index.number_of_shards", 2); - set.put("index.number_of_replicas", 0); - client.updateIndexSetting(currentIndex, set); + Map set = new HashMap(); + set.put("index.number_of_shards", "2"); + set.put("index.number_of_replicas", "0"); + + try { + client.creatIndex(currentIndex, null, set, null); + } + catch (Exception e) { + log.err(this, "create ES Index FAIL: ", e); + } String sappid = formatAppid(appid); @@ -188,8 +194,7 @@ public void prepareIndexType(String appid, String type) { // 设置 Map sfields = new HashMap<>(); - sfields.put("type", "string"); - sfields.put("index", "not_analyzed"); + sfields.put("type", "keyword"); mapping.put("ipport", sfields); diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/InvokeChainIndexMgr.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/InvokeChainIndexMgr.java index 059a4838..9efa18b3 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/InvokeChainIndexMgr.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/InvokeChainIndexMgr.java @@ -20,7 +20,6 @@ package com.creditease.uav.invokechain; -import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -53,6 +52,7 @@ public class InvokeChainIndexMgr extends AbstractComponent { private ESClient client; public InvokeChainIndexMgr(String cName, String feature) { + super(cName, feature); client = (ESClient) this.getConfigManager().getComponent(this.feature, "ESClient"); @@ -125,18 +125,9 @@ public String prepareIndex() { return currentIndex; } - client.creatIndex(currentIndex); - - Map set = new HashMap(); - set.put("index.number_of_shards", 5); - set.put("index.number_of_replicas", 0); - client.updateIndexSetting(currentIndex, set); - /** - * 变更别名到当前新的Index - */ - String previousIndex = this.getCurrentIndex(Calendar.getInstance(), -1); - client.addIndexAlias(currentIndex, IVC_DB); - client.removeIndexAlias(previousIndex, IVC_DB); + Map set = new HashMap(); + set.put("index.number_of_shards", "5"); + set.put("index.number_of_replicas", "0"); /** * 设置不需要分词的索引字段spanid,parentid,traceid,epinfo(方法级排序使用), appuuid(精确查找应用实例) @@ -145,8 +136,7 @@ public String prepareIndex() { Map fields = new HashMap<>(); - fields.put("type", "string"); - fields.put("index", "not_analyzed"); + fields.put("type", "keyword"); mapping.put("traceid", fields); mapping.put("spanid", fields); @@ -169,11 +159,18 @@ public String prepareIndex() { longType.put("type", "long"); try { - client.setIndexTypeMapping(currentIndex, IVC_Table, mapping); + client.creatIndex(currentIndex, IVC_Table, set, mapping); } - catch (IOException e) { - log.err(this, "Set ES Index Type Mapping FAIL: ", e); + catch (Exception e) { + log.err(this, "create ES Index FAIL: ", e); } + + /** + * 变更别名到当前新的Index + */ + String previousIndex = this.getCurrentIndex(Calendar.getInstance(), -1); + client.addIndexAlias(currentIndex, IVC_DB); + client.removeIndexAlias(previousIndex, IVC_DB); } return currentIndex; diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/SlowOperIndexMgr.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/SlowOperIndexMgr.java index 90c87b32..9833428f 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/SlowOperIndexMgr.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/SlowOperIndexMgr.java @@ -56,6 +56,7 @@ public class SlowOperIndexMgr extends AbstractComponent { } public SlowOperIndexMgr(String cName, String feature) { + super(cName, feature); client = (ESClient) this.getConfigManager().getComponent(this.feature, "ESClient"); @@ -145,11 +146,16 @@ public String prepareIndex(String appid) { return currentIndex; } - client.creatIndex(currentIndex); - Map set = new HashMap(); - set.put("index.number_of_shards", 5); - set.put("index.number_of_replicas", 0); - client.updateIndexSetting(currentIndex, set); + Map set = new HashMap(); + set.put("index.number_of_shards", "5"); + set.put("index.number_of_replicas", "0"); + + try { + client.creatIndex(currentIndex, null, set, null); + } + catch (Exception e) { + log.err(this, "create ES Index FAIL: ", e); + } String sappid = formatAppid(appid); @@ -192,8 +198,7 @@ public void prepareIndexType(String currentIndex, String type) { // 设置 Map sfields = new HashMap<>(); - sfields.put("type", "string"); - sfields.put("index", "not_analyzed"); + sfields.put("type", "keyword"); mapping.put("traceid", sfields); mapping.put("spanid", sfields); diff --git a/com.creditease.uav.threadanalysis/src/main/java/com/creditease/uav/threadanalysis/server/ThreadAnalysisIndexMgr.java b/com.creditease.uav.threadanalysis/src/main/java/com/creditease/uav/threadanalysis/server/ThreadAnalysisIndexMgr.java index 9923aa3b..43b37552 100644 --- a/com.creditease.uav.threadanalysis/src/main/java/com/creditease/uav/threadanalysis/server/ThreadAnalysisIndexMgr.java +++ b/com.creditease.uav.threadanalysis/src/main/java/com/creditease/uav/threadanalysis/server/ThreadAnalysisIndexMgr.java @@ -20,7 +20,6 @@ package com.creditease.uav.threadanalysis.server; -import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -44,6 +43,7 @@ public class ThreadAnalysisIndexMgr extends AbstractComponent { private ESClient client; public ThreadAnalysisIndexMgr(String cName, String feature) { + super(cName, feature); client = (ESClient) this.getConfigManager().getComponent(this.feature, "ESClient"); @@ -116,18 +116,9 @@ public String prepareIndex() { return currentIndex; } - client.creatIndex(currentIndex); - - Map set = new HashMap(); - set.put("index.number_of_shards", 5); - set.put("index.number_of_replicas", 0); - client.updateIndexSetting(currentIndex, set); - /** - * 变更别名到当前新的Index - */ - String previousIndex = this.getCurrentIndex(Calendar.getInstance(), -1); - client.addIndexAlias(currentIndex, JTA_DB); - client.removeIndexAlias(previousIndex, JTA_DB); + Map set = new HashMap(); + set.put("index.number_of_shards", "5"); + set.put("index.number_of_replicas", "0"); /** * 就只有pname、info做分词,其他属性不做分词 @@ -135,8 +126,7 @@ public String prepareIndex() { Map> mapping = new HashMap>(); Map stringFields = new HashMap(); - stringFields.put("type", "string"); - stringFields.put("index", "not_analyzed"); + stringFields.put("type", "keyword"); mapping.put("ipport", stringFields); mapping.put("pid", stringFields); @@ -181,11 +171,18 @@ public String prepareIndex() { mapping.put("time", timestamp); try { - client.setIndexTypeMapping(currentIndex, JTA_TABLE, mapping); + client.creatIndex(currentIndex, JTA_TABLE, set, mapping); } - catch (IOException e) { - log.err(this, "Set ES Index Type Mapping FAIL: ", e); + catch (Exception e) { + log.err(this, "create ES Index FAIL: ", e); } + + /** + * 变更别名到当前新的Index + */ + String previousIndex = this.getCurrentIndex(Calendar.getInstance(), -1); + client.addIndexAlias(currentIndex, JTA_DB); + client.removeIndexAlias(previousIndex, JTA_DB); } return currentIndex; From 79683cb02435e034bf8ff427306aa308cd12f030 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Thu, 12 Apr 2018 18:20:57 +0800 Subject: [PATCH 52/97] https://github.com/uavorg/uavstack/issues/244 1.modify log when openTSDB returns to the 200 state; 2.modify openTSDB insert data URI is /api/put?summary; 3.modify real time data view bug --- .../main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js | 2 +- .../com/creditease/uav/datastore/core/OpentsdbDataStore.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js index ab891838..5cb68794 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appmonitor.js @@ -2551,7 +2551,7 @@ var mvcObj={ var metric=metrics[i]; - if(mprefix=="clientResp"&&metric=="RC"||mprefix!="clientResp"&&metric=="AC"){ + if(mprefix=="clientResp"&&metric=="RC"||mprefix!="clientResp"&&metric=="AC"||mprefix!="clientResp"&&metric=="EXT"){ continue; } diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java index d31deaa9..0c36298b 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java @@ -193,7 +193,7 @@ public int getState() { private static final String HTTP_HEAD = "http://"; private static final String HTTP_QUERY = "/api/query"; - private static final String HTTP_PUT_PREFIX = "/api/put"; + private static final String HTTP_PUT_PREFIX = "/api/put?summary"; private static final int ACTIONOK = 2; private static final int ACTIONFAIL = 0; From 30f51c80d1f18947d921e17e0000f8193fba1ad1 Mon Sep 17 00:00:00 2001 From: zwq0317 <1065009602@qq.com> Date: Fri, 13 Apr 2018 13:27:48 +0800 Subject: [PATCH 53/97] 1.change '\' to '/',avoid '\' from origin string be replaced, 2.add try catch code. --- .../messaging/AbstractMessageHandler.java | 12 ++++++++++-- .../creditease/agent/helpers/DataStoreHelper.java | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/messaging/AbstractMessageHandler.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/messaging/AbstractMessageHandler.java index 19fac22d..9fe54b54 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/messaging/AbstractMessageHandler.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/healthmanager/messaging/AbstractMessageHandler.java @@ -79,8 +79,16 @@ public void handle(Message msg) { // pre insert to process DataStoreMsg preInsert(dsMsg); - // do insert - boolean insertR = store.doInsert(dsMsg); + boolean insertR = false; + + try { + // do insert + insertR = store.doInsert(dsMsg); + + } + catch (Exception e) { + log.err(this, "DataStore[" + msgKey + "] INSERT DATA FAIL!", e); + } if (log.isDebugEnable()) { diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DataStoreHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DataStoreHelper.java index 6ce67663..40f4a65e 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DataStoreHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DataStoreHelper.java @@ -57,13 +57,13 @@ public static String encodeForMongoDB(String s) { for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (chars[i] == '.' || chars[i] == '$') { - sb.append("\\u" + Integer.toHexString(c)); + sb.append("/u" + Integer.toHexString(c)); } else { sb.append(chars[i]); } } - return sb.toString().replace("\\", "/"); + return sb.toString(); } public static String encodeForOpenTSDB(String s) { From c32a5ca4a52724d780b32ca8aab5854496159969 Mon Sep 17 00:00:00 2001 From: xingshengli Date: Fri, 13 Apr 2018 15:55:24 +0800 Subject: [PATCH 54/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/249=20HM=E7=9A=84server=E7=AB=AF=E8=B0=83=E7=94=A8=E9=93=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AESpan=E6=8A=A5IllegalArgumentException?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=20=E5=AF=B9=E5=88=86=E5=8F=B7=E7=BC=96?= =?UTF-8?q?=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvokeChainDataCollectHandler.java | 19 ++++++++++++------- .../creditease/uav/invokechain/data/Span.java | 17 +++++++++++++---- .../uav/apm/invokechain/span/Span.java | 19 +++++++++++++++---- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/InvokeChainDataCollectHandler.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/InvokeChainDataCollectHandler.java index 1003fe03..5c85110b 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/InvokeChainDataCollectHandler.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/collect/InvokeChainDataCollectHandler.java @@ -65,13 +65,18 @@ public void handle(CollectDataFrame frame) { for (Line line : frame.getLines()) { - String content = line.getContent(); - - Span span = new Span(content); - - pushLatestIVCDataToCache(appUUID, span); - - pushSpanToBulkRequest(appUUID, frame.getAppgroup(), span, bulkRequest); + try { + String content = line.getContent(); + + Span span = new Span(content); + + pushLatestIVCDataToCache(appUUID, span); + + pushSpanToBulkRequest(appUUID, frame.getAppgroup(), span, bulkRequest); + } + catch (Exception e) { + this.log.err(this, "unsupported ivc content :" + line.getContent(), e); + } } // cm.submitBatch(); diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/data/Span.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/data/Span.java index 392c6146..315ed6b6 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/data/Span.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/data/Span.java @@ -92,7 +92,7 @@ public String toString() { private String methodName = ""; - private String endpointInfo; + private String endpointInfo = ""; private String state = ""; @@ -109,11 +109,11 @@ public Span(String ivcLogSpan) { this.startTime = DataConvertHelper.toLong(info[4], -1); this.cost = DataConvertHelper.toLong(info[5], -1); this.appHostPort = info[6]; - this.appid = info[7]; - this.endpointInfo = info[8]; + this.appid = decodeForIVC(info[7]); + this.endpointInfo = decodeForIVC(info[8]); this.className = info[9]; this.methodName = info[10]; - this.url = info[11]; + this.url = decodeForIVC(info[11]); this.state = EncodeHelper.urlDecode(info[12]); } @@ -289,5 +289,14 @@ public void setAppHostPort(String appHostPort) { this.appHostPort = appHostPort; } + private String decodeForIVC(String s) { + + if (!StringHelper.isEmpty(s) && s.contains("%3b")) { + return s.replace("%3b", ";"); + } + else { + return s; + } + } } diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/Span.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/Span.java index 1e0a6528..c9ec7207 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/Span.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/Span.java @@ -74,7 +74,7 @@ public String toString() { private String methodName = ""; - private String endpointInfo; + private String endpointInfo = ""; private String state = ""; @@ -122,7 +122,7 @@ public String getAppid() { public void setAppid(String appid) { - this.appid = appid; + this.appid = encodeForIVC(appid); } public String getEndpointType() { @@ -140,7 +140,7 @@ public void setEndpointInfo(String endpointInfo) { if (StringHelper.isEmpty(endpointInfo)) { return; } - this.endpointInfo = endpointInfo; + this.endpointInfo = encodeForIVC(endpointInfo); } public String getUrl() { @@ -154,7 +154,7 @@ public void setUrl(String url) { return; } - this.url = url; + this.url = encodeForIVC(url); } public long getStartTime() { @@ -279,4 +279,15 @@ public void end() { long endTime = System.currentTimeMillis(); this.cost = endTime - this.startTime; } + + private String encodeForIVC(String s) { + + if (!StringHelper.isEmpty(s) && s.contains(";")) { + return s.replace(";", "%3b"); + } + else { + return s; + } + } + } From 6aa19ef11fe198fe5b6577e263a1e916d2445bb1 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 13 Apr 2018 16:09:47 +0800 Subject: [PATCH 55/97] https://github.com/uavorg/uavstack/issues/251 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.base/link-relative notify support time_limit(day/time/weekday) 2.support metric's time aggregate value notify 3.support custom aggregate cross instance --- .../notifystgy/css/uav.notifystgy.css | 768 ++-- .../notifystgy/js/notifystgy.win.js | 3130 +++++++++-------- .../feature/runtimenotify/NotifyStrategy.java | 1073 +++--- .../runtimenotify/StrategyJudgement.java | 295 +- .../task/JudgeNotifyTimerTask.java | 500 +-- .../agent/helpers/DateTimeHelper.java | 2007 +++++------ .../rabbitmq/interceptors/RabbitmqIT.java | 730 ++-- 7 files changed, 4483 insertions(+), 4020 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css index 0539a3dc..d8110b54 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css @@ -1,375 +1,393 @@ -@CHARSET "UTF-8"; -/*原子布局 BEGINI*/ -html { - height: 100%; -} - -body { - font-size: 14px; - font-family: "微软雅黑"; - margin-top: 0px; - margin-left: 0px; - margin-right: 0px; - margin-bottom: 0px; - text-align: center; - height: 100%; -} - -.ListBG { - background: white; - color: black; - font-size: 14px; -} - -.ObjectBG { - background: white; - color: black; - font-size: 14px; -} - -.ObjectBG input,select,textarea,.selectDiv{ - width: 50%; - height: 34px; - border-radius: 2px; - min-width: 340px; - margin-top:1px; -} - -.selectDiv{ - display: inline-flex; -} - -.ObjectBG textarea{ - resize: none; - height:50px; -} - -.ObjectBG .well{ - width: 50%; - min-width: 340px; - border-radius: 2px; - margin: 0 auto; - padding:0px; - text-align:left; -} - -.well-title{ - float: left; - margin-top:3px; - margin-left:3px; - color: white; -} - -.well-title-div{ - background-color: #009ad6; - text-align: right; - width: 100%; - color: white; -} -.well-add{ - font-size: 18px; - margin-top:3px; - margin-right:7px; -} - -.well-add:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px white; -} - -.well-list{ - margin-top:2px; - margin-left:3px; - border-bottom: dotted 1px #999; -} -.well-list:hover{ - background: #cae4ff; -} -.well-del{ - font-size: 18px; - float: right; - margin-right:7px; -} -.well-del:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px #ff0000; -} -.well-edit{ - font-size: 18px; - float: right; - margin-right:20px; -} -.well-edit:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px #000000; -} -.icon-myout,.icon-myhelp { - float: right; - margin-top: 5px; - margin-right: 15px; - font-size: 2em; -} - -.icon-myout:hover { - border-radius: 3px; - box-shadow: 0 0 4px 4px #ffffff; -} - -.icon-myhelp{ - height: 31.4px; - width: 31.4px; - - } - -.icon-myhelp:hover{ - border-radius: 50px; - box-shadow: 0 0 4px 4px #ffffff; -} - -.titleDiv { - font-size: 16px; - color: #ffffff; - background-color: #009ad6; - height: 43px; - line-height:43px; -} - -.titleDiv-stgy-nodata{ - color: black; - margin-left: -85px; -} - -.conditions select{ - min-width: 200px; - width: 200px; -} - -.conditions input{ - width: 200px; - display: inline -} - - -/*下拉框按钮CSS*/ -.selBut{ - width: 90%; - text-align: left; - padding:0px; -} -.selBut_but{ - width: 10%; -} -.selBut_must{ - width: 90%; - text-align: left; - border:solid 1px red; -} - -.input_must{ - text-align: left; - border:solid 1px red; -} -.input_update{ - text-align: left; - border:solid 1px green; -} - -.input_must:focus{ - border:0px; -} -.defNone{ - display:none; -} - -.displayMsgInput{ - display: inline-block; - text-align: left; - background-color: #cde6c7; - padding-top: 4px; - padding-left: 2px; - border:0px; -} - -.displayMsgTitle{ - border:0px; - font-weight: 900; -} -.listIndex{ - color : black; - border-radius: 3px 3px 3px 3px; - background-color: #dddddd; -} -.listIndex > hr{ - margin:0px; - border-top: 1px solid #ffffff; - -} -.listIndex_server{ - color : #ffffff; - background-color: #0aaaaa; -} -.listIndex_client{ - color : #ffffff; - background-color: #a6c166; -} -.listIndex_log{ - color : #ffffff; - background-color: #c99f32; -} -.listIndex_appmetrics{ - color : #ffffff; - background-color: #970097; -} -/**重写CSS*/ -.table>tbody>tr>td{ - vertical-align:middle; -} - - -.titleMsgDiv{ - margin-top: -34px; - height: 34px; -} - -/**时间控件按钮样式**/ -.control-group { - margin-bottom: 10px; -} - -.control-group input { - background-color: #eeeeee; - border:1px solid #cccccc; - border-radius:4px 0 0 4px; - padding: 4px 6px; - color:#333333 -} -.control-group .add-on { - background-color: #eeeeee; - border:1px solid #cccccc; - border-radius:0 4px 4px 0; - padding: 4.5px 6px; - color:#333333 -} - -/** -*条件定义 -*/ -.btn-default.active:focus{ - color: #333; - background-color: #d4d4d4; - border-color: #8c8c8c; -} - -.btn-default.active, .btn-default:active{ - color: #333; - background-color: #d4d4d4; - border-color: #337ab7; -} - -/** -*触发策略 begin -*/ -.StgyDiv .edit-div-where{ - font-size: 14px; - width: 95%; - border-radius: 2px; - margin: 0 auto; - text-align:left; - padding: 5px; - margin-top: 5px; - margin-bottom: 5px; - border:solid 1px green; -} - -.StgyDiv .edit-div{ - font-size: 14px; - height: 130px; - width: 95%; - min-width: 340px; - border-radius: 2px; - margin: 0 auto; - text-align:left; - padding: 5px; - overflow-y:auto; - color:#000000; -} - -.StgyDiv .edit-div:empty:before{ - content: attr(placeholder); - color:darkgrey; -} - -.StgyDiv .edit-div-option{ - font-size: 14px; - height: 50px; - width: 95%; - min-width: 340px; - border-radius: 2px; - border-color:#000000; - margin: 0 auto; - text-align:left; - padding: 5px; - margin-top: 5px; - overflow-y:auto; - color:#000000; -} - -StgyDiv .edit-div-option:empty:before{ - content: attr(placeholder); - color:darkgrey; -} - -.whereStgyEdit{ - border-radius: 4px; -} -.whereStgyEdit-success{ - background-color: #dddddd; - color:#000000; - display: inline-block; - margin: 1px; -} -.whereStgyEdit-delete{ - text-decoration: line-through; - border: solid 1px red; - color: red; - display: inline-block; - margin: 1px; -} - -.btn-success { - margin: 5px; - color: #000000; - padding: 3px 10px; - background-color: #ffffff; - border-color: #3c763d; -} -.btn-success:hover { - color: #000000; - background-color: #dddddd; -} - -.well-list-display{ - display: -webkit-box; - padding-bottom: 5px; - padding-top: 5px; -} -.action-textarea-delete{ - display: inline-flex; - position: absolute; - margin-top: 17px; - margin-left: 5px; -} - -.action-textarea-delete span{ - border:solid 1px #ffffff; - font-size: 18px; -} -.action-textarea-delete span:hover{ - font-size: 18px; - border:solid 1px red; - border-radius: 2px; -} - -/** -*触发策略 end -*/ +@CHARSET "UTF-8"; +/*原子布局 BEGINI*/ +html { + height: 100%; +} + +body { + font-size: 14px; + font-family: "微软雅黑"; + margin-top: 0px; + margin-left: 0px; + margin-right: 0px; + margin-bottom: 0px; + text-align: center; + height: 100%; +} + +.ListBG { + background: white; + color: black; + font-size: 14px; +} + +.ObjectBG { + background: white; + color: black; + font-size: 14px; +} + +.ObjectBG input,select,textarea,.selectDiv{ + width: 50%; + height: 34px; + border-radius: 2px; + min-width: 340px; + margin-top:1px; +} + +.selectDiv{ + display: inline-flex; +} + +.ObjectBG textarea{ + resize: none; + height:50px; +} + +.ObjectBG .well{ + width: 50%; + min-width: 340px; + border-radius: 2px; + margin: 0 auto; + padding:0px; + text-align:left; +} + +.well-title{ + float: left; + margin-top:3px; + margin-left:3px; + color: white; +} + +.well-title-div{ + background-color: #009ad6; + text-align: right; + width: 100%; + color: white; +} +.well-add{ + font-size: 18px; + margin-top:3px; + margin-right:7px; +} + +.well-add:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px white; +} + +.well-list{ + margin-top:2px; + margin-left:3px; + border-bottom: dotted 1px #999; +} +.well-list:hover{ + background: #cae4ff; +} +.well-del{ + font-size: 18px; + float: right; + margin-right:7px; +} +.well-del:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px #ff0000; +} +.well-edit{ + font-size: 18px; + float: right; + margin-right:20px; +} +.well-edit:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px #000000; +} +.icon-myout,.icon-myhelp { + float: right; + margin-top: 5px; + margin-right: 15px; + font-size: 2em; +} + +.icon-myout:hover { + border-radius: 3px; + box-shadow: 0 0 4px 4px #ffffff; +} + +.icon-myhelp{ + height: 31.4px; + width: 31.4px; + + } + +.icon-myhelp:hover{ + border-radius: 50px; + box-shadow: 0 0 4px 4px #ffffff; +} + +.titleDiv { + font-size: 16px; + color: #ffffff; + background-color: #009ad6; + height: 43px; + line-height:43px; +} + +.titleDiv-stgy-nodata{ + color: black; + margin-left: -85px; +} + +.conditions select{ + min-width: 200px; + width: 200px; +} + +.conditions input{ + width: 200px; + display: inline +} + + +/*下拉框按钮CSS*/ +.selBut{ + width: 90%; + text-align: left; + padding:0px; +} +.selBut_but{ + width: 10%; +} +.selBut_must{ + width: 90%; + text-align: left; + border:solid 1px red; +} + +.input_must{ + text-align: left; + border:solid 1px red; +} +.input_update{ + text-align: left; + border:solid 1px green; +} + +.input_must:focus{ + border:0px; +} +.defNone{ + display:none; +} + +.displayMsgInput{ + display: inline-block; + text-align: left; + background-color: #cde6c7; + padding-top: 4px; + padding-left: 2px; + border:0px; +} + +.displayMsgTitle{ + border:0px; + font-weight: 900; +} +.listIndex{ + color : black; + border-radius: 3px 3px 3px 3px; + background-color: #dddddd; +} +.listIndex > hr{ + margin:0px; + border-top: 1px solid #ffffff; + +} +.listIndex_server{ + color : #ffffff; + background-color: #0aaaaa; +} +.listIndex_client{ + color : #ffffff; + background-color: #a6c166; +} +.listIndex_log{ + color : #ffffff; + background-color: #c99f32; +} +.listIndex_appmetrics{ + color : #ffffff; + background-color: #970097; +} +/**重写CSS*/ +.table>tbody>tr>td{ + vertical-align:middle; +} + + +.titleMsgDiv{ + margin-top: -34px; + height: 34px; +} + +/**时间控件按钮样式**/ +.control-group { + margin-bottom: 10px; +} + +.control-group input { + background-color: #eeeeee; + border:1px solid #cccccc; + border-radius:4px 0 0 4px; + padding: 4px 6px; + color:#333333 +} +.control-group .add-on { + background-color: #eeeeee; + border:1px solid #cccccc; + border-radius:0 4px 4px 0; + padding: 4.5px 6px; + color:#333333 +} + +/** +*条件定义 +*/ +.btn-default.active:focus{ + color: #333; + background-color: #d4d4d4; + border-color: #8c8c8c; +} + +.btn-default.active, .btn-default:active{ + color: #333; + background-color: #d4d4d4; + border-color: #337ab7; +} + +/** +*触发策略 begin +*/ +.StgyDiv .edit-div-where{ + font-size: 14px; + width: 95%; + border-radius: 2px; + margin: 0 auto; + text-align:left; + padding: 5px; + margin-top: 5px; + margin-bottom: 5px; + border:solid 1px green; +} + +.StgyDiv .edit-div{ + font-size: 14px; + height: 130px; + width: 95%; + min-width: 340px; + border-radius: 2px; + margin: 0 auto; + text-align:left; + padding: 5px; + overflow-y:auto; + color:#000000; +} + +.StgyDiv .edit-div:empty:before{ + content: attr(placeholder); + color:darkgrey; +} + +.StgyDiv .edit-div-option{ + font-size: 14px; + height: 50px; + width: 95%; + min-width: 340px; + border-radius: 2px; + border-color:#000000; + margin: 0 auto; + text-align:left; + padding: 5px; + margin-top: 5px; + overflow-y:auto; + color:#000000; +} + +StgyDiv .edit-div-option:empty:before{ + content: attr(placeholder); + color:darkgrey; +} + +.whereStgyEdit{ + border-radius: 4px; +} +.whereStgyEdit-success{ + background-color: #dddddd; + color:#000000; + display: inline-block; + margin: 1px; +} +.whereStgyEdit-delete{ + text-decoration: line-through; + border: solid 1px red; + color: red; + display: inline-block; + margin: 1px; +} + +.btn-success { + margin: 5px; + color: #000000; + padding: 3px 10px; + background-color: #ffffff; + border-color: #3c763d; +} +.btn-success:hover { + color: #000000; + background-color: #dddddd; +} + +.well-list-display{ + display: -webkit-box; + padding-bottom: 5px; + padding-top: 5px; +} +.action-textarea-delete{ + display: inline-flex; + position: absolute; + margin-top: 17px; + margin-left: 5px; +} + +.action-textarea-delete span{ + border:solid 1px #ffffff; + font-size: 18px; +} +.action-textarea-delete span:hover{ + font-size: 18px; + border:solid 1px red; + border-radius: 2px; +} + +/** +*触发策略 end +*/ + +.itemTitle { + text-align:left; + color:#333; + border-left:6px solid #57A69C; + padding-left:5px; + margin-bottom:2px; +} + +.itemTip { + color:gray; + font-size:14px; + text-align:left; +} + +.dateTimeInput { + width:120px; +} \ No newline at end of file diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index b0cd5c92..5671d8b0 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -1,1480 +1,1652 @@ -/** - * 窗体初始化 - */ -window.winmgr.build({ - id : "notifyList", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "ListBG" -}); -window.winmgr.build({ - id : "objectDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "ObjectBG" -}); -window.winmgr.build({ - id : "stgyDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "StgyDiv" -}); -window.winmgr.build({ - id : "condDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "condDiv" -}); -window.winmgr.show("notifyList"); - -/** - * 操作配置 - */ -var actionConf = { - actionObj:null //操作对象 -} -/** - * 下拉框UI - * */ -var selUiConf = { - keys:[ - - {"key":"server","value":"自定义指标"}, - {"key":"server","value":"服务端"}, - {"key":"client","value":"客户端"}, - {"key":"log","value":"日志"} - ], - "server":[ - ["procState","进程状态指标系"], - ["hostState","应用容器状态指标系"], - ["urlResp","服务状态指标系"], - ["appResp","应用状态指标系"], - ["serverResp","应用服务器状态指标系"], - ["procCrash","进程死亡指标系"] - ], - "client":[ - ["clientResp","调用状态指标系"] - ], - "log":[ - ["log","日志"] - ] - , - "userDef":[ - ["jvm","Java虚拟机状态指标系"] - ] - , - userInput:{ - "notifyNameF":"", - "notifyNameM":"", - "notifyNameI":"" - } - -} - -var supportJTA = ["服务状态指标系","应用状态指标系","应用服务器状态指标系","调用状态指标系"]; -/** - * 初始化头部 - */ -function initHeadDiv() { - var divContent = "" - + "
" - - + "" - - + "" - - + "" - - + "
" - + "" - - + "" - + "
" + "
" + ""; - HtmlHelper.id("notifyList").innerHTML += divContent; -} - -/** - * 显示添加策略 - */ -function showAddDiv() { - - var sb=new StringBuffer(); - sb.append( "
"); - sb.append( ""); - sb.append( ""); - sb.append( ""); - sb.append( "添加策略"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - - sb.append( '
'); - - - sb.append( '
'); - sb.append(''); - sb.append('
'); - sb.append(''); - sb.append(''); - sb.append(''); - sb.append('
'); - sb.append('
'); - - sb.append('
'); - sb.append('
'); - sb.append(''); - sb.append(''); - sb.append(''); - sb.append('
'); - sb.append( '
'); - sb.append('
'); - - sb.append( '
'); - sb.append( "
"); - - - sb.append( '
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
条件定义
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
触发策略
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
触发动作
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
'); - - sb.append( ''); - - HtmlHelper.id("objectDiv").innerHTML = sb.toString(); - window.winmgr.hide("notifyList"); - window.winmgr.show("objectDiv"); - initActionDiv($("#isOwner").val()); - -} - - -/** - * 显示编辑策略 - */ -function showEditNotifyDiv(jsonObjParam) { - - var key,jsonObj,isOwner=false;enableThreadAnalysis=false; - //因为只有一对 key:value 获取key(值为id) - $.each(jsonObjParam,function(index,obj){ - key = index; - jsonObj = obj; - }); - - if(jsonObj.owner == window.parent.loginUser.userId - || window.parent.loginUser.groupId == "uav_admin" - || window.parent.loginUser.groupId == "vipgroup" - ){ - isOwner = true; - } - - var names = key.split("@"); - var cssType = "displayMsgInput",cssRedOnly = "displayMsgInput listIndex"; - var sb=new StringBuffer(); - sb.append( "
"); - sb.append( ""); - sb.append( "编辑策略"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - /** - * 所有渲染内容 div begin - */ - sb.append( '
'); - - sb.append( '
'); - if(window.parent.loginUser.groupId == "uav_admin" - || window.parent.loginUser.groupId == "vipgroup" - ){ - sb.append( '
'); - }else{ - - sb.append( '
'); - } - - - sb.append( '
'); - - //1 - var existsIns = jsonObj.instances.length>0?true:false; - var showNameF = getSelUiConfKeysValue(names[0],names[1]); - if(showNameF=="自定义指标"){ - cssType = "displayMsgInput listIndex_appmetrics"; - }else if(names[1] == "log"){ - showNameF = "日志"; - cssType = "displayMsgInput listIndex_log"; - }else if(names[0] == "server"){ - cssType = "displayMsgInput listIndex_server"; - }else if(names[0] == "client"){ - cssType = "displayMsgInput listIndex_client"; - } - sb.append( '
'); - selUiConf["userInput"]["notifyNameF"]=names[0];//编辑赋值,准备修改数据 - //2 - if(showNameF=="自定义指标"){ - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - }else if(names[1] == "log"){ - sb.append( '
'); - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - }else if(names[1]){ - sb.append( '
'); - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - if($.inArray(getSelUiConfigValue(names[1]),supportJTA) >= 0){ - enableThreadAnalysis=true; - } - } - //3 - if(names[2] && names[1] == "log"){ - var nNameIShow = "指定日志:"+names[2]; - sb.append( '
'); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 - }else if(names[1] == "log"){ - sb.append( '
'); - }else if(names[2]){ - var nNameIShow = (existsIns?"实例组:":"实例:")+names[2]; - sb.append( '
'); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 - }else{ - sb.append( '
'); - } - - if(names[2] && isOwner){ - sb.append( "
'); - }else if(names[2] && !isOwner){ - sb.append( "
'); - }else if(isOwner){ - sb.append( "
'); - }else{ - sb.append( "
'); - } - - - sb.append( '
'); - if(isOwner){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - /** - * 初始化条件 begin - */ - sb.append( '
'); - sb.append( '
'); - sb.append( '条件定义'); - sb.append( '
'); - $.each(jsonObj.conditions,function(index,obj){ - if(obj.func && obj.func.indexOf("count>")>-1){ - obj.cparam = obj.func.substr(6); - obj.func = "count"; - } - - if(!obj.id){ - /** - * 兼容老数据 - */ - obj.id=StgyClass.randomId()+"_stgySpan"; - } - var html; - if(isOwner){ - html = '
'+StgyClass.formatShowWhere(obj)+'
'; - }else{ - html = '
'+StgyClass.formatShowWhere(obj)+'
'; - } - sb.append( html); - }); - sb.append( '
'); - sb.append( '
'); - /** - * 初始化条件 end - */ - - /** - * 初始化触发策略 begin - */ - sb.append( '
'); - - if(isOwner){ - sb.append( '
触发策略
'); - }else{ - sb.append( '
触发策略
'); - } - - if(jsonObj.relationsHtmls){ - $.each(jsonObj.relationsHtmls,function(index,html){ - var convergenceVal = ""; - if(jsonObj.hasOwnProperty("convergences")){ - convergenceVal = jsonObj.convergences[index]; - } - - var appendHtml = - '
'+ - '
'+ - '
'+html+'
'+ - '
'+convergenceVal+'
'+ - '
'; - - if(isOwner){ - appendHtml+=''; - }else{ - appendHtml+=''; - } - appendHtml+='
'+ - '
'+ - '
'; - sb.append(appendHtml); - }); - } - sb.append( '
'); - /** - * 初始化触发策略 begin - */ - - sb.append( '
'); - sb.append( '
触发动作
'); - var actionSum = 0; - initActionDiv(isOwner?"true":"false"); - if (jsonObj.action!=undefined) { - $.each(jsonObj.action,function(index,value){ - actionSum++; - var josnSpan ={ - "type":index, - "value":value - } - - var html ; - - if(isOwner){ - if("threadanalysis" == josnSpan.type){ - var html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - }else{ - html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - } - }else{ - html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - } - sb.append( '
'); - sb.append( html); - sb.append( '
'); - - /** - * 计算下拉选项 - */ - $("#actionTypeSel option[value="+josnSpan.type+"]").remove(); - - }); - } - sb.append( '
'); - /** - * 初始化触发动作 end - */ - - if(isOwner){ - //按钮 - sb.append( '
'); - sb.append( '
'); - } - - sb.append( '
'); - /** - * 所有渲染内容 div end - */ - sb.append( ""); - HtmlHelper.id("objectDiv").innerHTML = sb.toString(); - - /** - * 判断出发条件:不是归属者不能添加 - */ - if(!isOwner){ - $("#whereAddButton").attr("class","well-add"); - $("#whereAddButton").click(function(){}); - } - /** - * 判断触发动作按钮 begin(类型都已经存在值,则不能再添加) - * 不是归属者也不能添加 - */ - var selTypeSize = $("#actionTypeSel option").size(); - if(selTypeSize == 0 || !isOwner){ - $("#actionAddButton").attr("class","well-add"); - $("#actionAddButton").click(function(){}); - } - /** - * 判断触发动作按钮 end - */ - window.winmgr.hide("notifyList"); - window.winmgr.show("objectDiv"); - - hideShowConStgy(names[1]); -} - - - -/** - * 触发动作添加窗口 - */ -function initActionDiv(isOwner) { - - var old = document.getElementById("actionDiv"); - if(old){ - var node = old.parentNode; - node.removeChild(old); - } - - var sb=new StringBuffer(); - - sb.append(''); - var div = document.createElement('div'); - div.innerHTML = sb.toString(); - document.body.appendChild(div); -} - -/** - * 显示添加条件窗口 - * @param thisObj - * @param type - */ -function showCon(thisObj,type){ - actionConf.actionObj=thisObj.parentNode; - if(selUiConf["userInput"]["notifyNameM"]=="log"){ - $("#condType").attr("disabled","disabled"); - } - $("#pageType").val(type); - if("EDIT" == type){ - var jsonValue = JSON.parse(thisObj.parentNode.getElementsByTagName("span")[0].textContent); - $("#condType").attr("disabled","disabled"); - var isOwner = $("#isOwner").val(); - if(!jsonValue.type||jsonValue.type=="stream"){ - $("#condType").val("stream"); - $("#contExpr").val(jsonValue.expr); - $("#conRange").val(jsonValue.range); - $("#conFunc").val((null == jsonValue.func?0:jsonValue.func)); - if("count" == jsonValue.func){ - $("#conFuncParam").val(jsonValue.cparam); - $("#conFuncParam").show(); - } - //不是归属用户,则只读 - if(isOwner!="true"){ - $("#whereSaveButton").hide(); - $("#contExpr").attr("readonly","readonly"); - $("#conRange").attr("readonly","readonly"); - $("#conFunc").attr("disabled","disabled"); - $("#conFuncParam").attr("readonly","readonly"); - - //只读CSS - $("#contExpr").attr("class","form-control"); - $("#conRange").attr("class","form-control"); - $("#conFuncParam").attr("class","form-control"); - $("#whereSaveButton").hide(); - } - - }else{ - var type; - if(jsonValue.interval){ - type="link-relative"; - }else{ - type="base-relative"; - } - $("#condType").val(type); - typeChangeShow(type); - - var hour=jsonValue.time_from.split(':')[0]; - var min=jsonValue.time_from.split(':')[1]; - $('#time_start').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - hour=jsonValue.time_to.split(':')[0]; - min=jsonValue.time_to.split(':')[1]; - $('#time_end').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - - $("#conMetric").val(jsonValue.metric); - $("#conUpperLimit").val(jsonValue.upperLimit); - $("#conLowerLimit").val(jsonValue.lowerLimit); - $("#conAggr").val(jsonValue.aggr); - if(type=="link-relative"){ - $("#conInterval").val(jsonValue.interval); - showUnit(jsonValue.unit); - }else{ - showUnit(jsonValue.unit); - } - if(isOwner!="true"){ - $("#time_from").attr("readonly","readonly"); - $("#time_to").attr("readonly","readonly"); - $("#conMetric").attr("readonly","readonly"); - $("#conUpperLimit").attr("readonly","readonly"); - $("#conLowerLimit").attr("readonly","readonly"); - $("#conMetric").attr("class","form-control"); - $("#conUpperLimit").attr("class","form-control"); - $("#conLowerLimit").attr("class","form-control"); - $("#conAggr").attr("disabled","disabled"); - if(type=="link-relative"){ - $("#conInterval").attr("readonly","readonly"); - $("#conInterval").attr("class","form-control"); - } - $("#whereSaveButton").hide(); - } - } - - } - -} - -function showUnit(unit){ - $("#unit").val(unit); - $("#opt"+unit).attr("class","btn btn-default active"); -} -/** - * 条件定义页面 - */ -function showCondDiv(thisObj,type) { - - var isOwner = $("#isOwner").val(); - /** - * 显示条件定义(弹出新元素) - */ - actionConf.actionObj=thisObj.parentNode; - - var sb = new StringBuffer(); - sb.append("
"); - sb.append("条件定义"); - sb.append("
"); - sb.append("
"); - sb.append( "
'); - - sb.append( '
'); - /** - * 普通预警条件编辑 - */ - sb.append( '
'); - - sb.append( '
'); - sb.append( '
'); - sb.append( "
'); - sb.append( ')\" style="display:none" onkeyup="this.value=this.value.replace(\/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(\/\\D/g,\'\')">
'); - sb.append( '
'); - - /** - * 同环比预警条件编辑 - */ - sb.append( ''); - sb.append( ''); - - /** - * 保存按钮 - */ - sb.append( '
'); - sb.append( ''); - sb.append( ''); - sb.append( '
'); - - HtmlHelper.id("condDiv").innerHTML = sb.toString(); - initTimeControl(); - showCon(thisObj,type); - window.winmgr.hide("objectDiv"); - window.winmgr.show("condDiv"); - -} - -function funcChangeShow(thisObj,showId){ - if("count" == thisObj.value){ - $("#"+showId).show(); - }else{ - $("#"+showId).hide(); - } -} - -function typeChangeShow(type){ - var divs=["stream","timer","link-relative","base-relative"]; - divs.forEach(div=>{ - $("#"+div).hide(); - }) - if("stream"!=type){ - $("#timer").show(); - } - $("#"+type).show(); - -} -/** - * 初始化时间控件 - */ -function initTimeControl(){ - $('#time_start').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - - $('#time_end').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - -} - -function changeTimeUnit(value){ - $("#unit").val(value); -} - - - -function actionChangeShow(type){ - if("ADD" == type){ - if("threadanalysis" == $("#actionTypeSel").val()){ - $("textarea[name='actionValue']").val("10101").hide(); - $(".btn-addPriority").hide(); - }else{ - $("textarea[name='actionValue']").val("").show(); - $(".btn-addPriority").show(); - } - }else{ - $("textarea[name='actionValue']").show(); - $(".btn-addPriority").show(); - } -} - -function selServerChangeShow(type,value,text){ - var selId = type+"_notifyNameF"; - $("#"+selId).html(text); - $("#"+selId).css("padding-left","2px"); - $("#"+type+"_notifyNameF").css("color","black"); - - hideShowConStgy("show"); - - if(text == "自定义指标"){ - $("#"+type+"_appName_div").hide(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); - selUiConf["userInput"]["notifyNameF"]=value; - selUiConf["userInput"]["notifyNameM"]="jvm"; - $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - }else if(value=="log"){ - $("#"+type+"_appName_div").show(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); - $("#notifyNameI").attr("placeholder","输入指定日志"); - selUiConf["userInput"]["notifyNameF"]=""; - selUiConf["userInput"]["notifyNameM"]=value; - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - }else{ - $("#"+type+"_appName_div").hide(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv"); - $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); - $("#"+type+"_notifyNameM").css("color","darkgrey"); - $("#"+type+"_notifyNameM").html("选择监控组指标"); - document.getElementById(type+"_notifyNameM_body").innerHTML =""; - $.each(selUiConf[value],function(index,obj){ - var li = document.createElement("li"); - var a = document.createElement("a"); - a.innerHTML=obj[1]; - a.onclick=function(){selIndexChangeShow(type,obj[0],obj[1]);}; - a.href="#"; - li.appendChild(a); - document.getElementById(type+"_notifyNameM_body").appendChild(li); - }); - selUiConf["userInput"]["notifyNameF"]=value; - } - -} - -function removeChoosedJTA(){ - if(HtmlHelper.id("ChoosedJTA") != null){ - HtmlHelper.id("ChoosedJTA").remove(); - } -} - -function changeJTAStat(text){ - if($.inArray(text,supportJTA) >= 0){ - $("#enableThreadAnalysis").val(true); - if(HtmlHelper.id("ChoosedJTA") == null){ - $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); - $("#actionAddButton").click(function(){showAction(this,'ADD')}); - } - }else{ - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - } -} - -function hideShowConStgy(value){ - if(value == "procCrash"){ - $("#conFatDiv").hide(); - $("#stgyFatDiv").hide(); - } - else{ - $("#conFatDiv").show(); - $("#stgyFatDiv").show(); - } -} - -function selIndexChangeShow(type,value,text){ - changeJTAStat(text); - hideShowConStgy(value); - - $("#"+type+"_notifyNameM").html(text); - $("#"+type+"_notifyNameM").css("padding-left","2px"); - $("#"+type+"_notifyNameM").css("color","black"); - selUiConf["userInput"]["notifyNameM"]=value; -} - -function appNameChange(obj){ - selUiConf["userInput"]["notifyNameF"]=obj.value; -} -function getSelUiConfigValue(indexValue){ - var result =""; - $.each(selUiConf.keys,function(value,obj1){ - $.each(selUiConf[obj1.key],function(index,obj2){ - if(obj2[0]==indexValue){ - result=obj2[1]; - return false; - } - }); - if(result!==""){ - return false; - } - }); - - return result; -} -function getSelUiConfKeysValue(a, b) { - var result = ""; - if (b == "log") { - result="日志"; - } else if (a == "server" && b == "jvm") { - result="自定义指标"; - } else if (a == "server") { - result="服务端"; - } else if (a == "client") { - result="客户端"; - } - return result; -} -function conditionsAppend(){ - if(checkFunc()){ - var jsonObject; - if("stream"==$("#condType").val()){ - jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; - }else{ - jsonObject = {"type":"timer","time_from":HtmlHelper.inputXSSFilter($("#time_from").val()),"time_to":HtmlHelper.inputXSSFilter($("#time_to").val()),"metric":HtmlHelper.inputXSSFilter($("#conMetric").val()),"upperLimit":HtmlHelper.inputXSSFilter($("#conUpperLimit").val()),"lowerLimit":HtmlHelper.inputXSSFilter($("#conLowerLimit").val()),"aggr":HtmlHelper.inputXSSFilter($("#conAggr").val())}; - if("link-relative"==$("#condType").val()){ - jsonObject["interval"]=HtmlHelper.inputXSSFilter($("#conInterval").val()); - jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); - }else{ - jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); - } - } - appendConditions(jsonObject); - window.winmgr.hide("condDiv"); - window.winmgr.show("objectDiv"); - } -} - -function checkFunc(){ - - var result = true; - if("stream"==$("#condType").val()){ - if(!$("#contExpr").val()){ - result = false; - }else if("count" == $("#conFunc").val() && !$("#conFuncParam").val()){ - result = false; - } - }else{ - if(!$("#time_from").val()||!$("#time_to").val()||!$("#conMetric").val()||!$("#conUpperLimit").val()||!$("#conLowerLimit").val()||!$("#conAggr").val()){ - result = false; - } - if("link-relative"==$("#condType").val()){ - if(!$("#conInterval").val()||!$("#unit").val()){ - result = false; - } - }else{ - if(!$("#unit").val()){ - result = false; - } - } - } - - - if(result){ - $("#conditionsErrMsg").hide(); - }else{ - $("#conditionsErrMsg").show(); - } - - return result; -} -function appendConditions(jsonObj) { - var type = $("#pageType").val(); - if("ADD"==type){ - var newNode = document.createElement("div"); - var stgyDivId = StgyClass.randomId()+"_stgySpan"; - html = '
'+getHtmlAndSetId(stgyDivId)+'
'; - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - }else if("EDIT"==type){ - var oldId = actionConf.actionObj.getElementsByTagName("span")[0].id; - actionConf.actionObj.innerHTML= getHtmlAndSetId(oldId); - StgyClass.updateWhereToStgyAppend(jsonObj); - } - - function getHtmlAndSetId(stgyDivId){ - jsonObj.id = stgyDivId;//赋值id - var html = StgyClass.formatShowWhere(jsonObj)+''; - return html; - } -} -/** - * 条件窗口操作 end - */ - - -/** - * 触发动作操作 begin - */ -function showAction(thisObj,type){ - actionConf.actionObj=thisObj.parentNode; - checkJTAAction(); - $("#actiontype").val(type); - $.each($("textarea[name='actionValue']"),function(index,obj){ - if(index>0){ - removeActonTextarea(obj); - }else{ - obj.value=""; - } - }); - $("#actionDiv").modal({backdrop: 'static', keyboard: false}); - $("#actionDiv").modal(); - //还原只读 - $("#actionSaveButton").show(); - $("#actionValue").removeAttr("readonly"); - - - if("EDIT"==type){ - //不是归属用户,则只读 - var isOwner = $("#isOwner").val(); - $("#actionTypeSel").hide(); - var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].textContent); - - $.each(spanJson.value,function(index,value){ - /** - * 第一次循环:追加渲染 - */ - if(index>0){ - appendActionTextarea(); - } - }); - var actionTextValues = $("textarea[name='actionValue']"); - $.each(spanJson.value,function(index,value){ - /** - * 第二次循环:赋值 - */ - actionTextValues[index].value=value; - }); - - $("#actionEditType").val(spanJson.type); - - actionChangeShow("EDIT"); - if(isOwner!="true"){ - $("#actionSaveButton").hide(); - } - }else{ - $("#actionTypeSel").show(); - actionChangeShow("ADD"); - } -} - -function checkJTAAction(){ - if($("#enableThreadAnalysis").val() =="true"&& $("#actionTypeSel").find("option[value='threadanalysis']").size() == 0 && $("#ChoosedJTA").size() == 0){ - $("#actionTypeSel").append(""); - } - else if($("#enableThreadAnalysis").val() == "false" && $("#actionTypeSel").find("option[value='threadanalysis']").size() == 1){ - $("#actionTypeSel option[value=threadanalysis]").remove(); - } -} - -function actionAppend(){ - - $("#ActionErrMsg").hide(); - - if(checkAction()){ - appendActions(); - $("#actionDiv").modal('hide'); - }else{ - $("#ActionErrMsg").show(); - } -} - -function appendActionTextarea(thisObj){ - var isOwner = $("#isOwner").val(); - - var html = ''; - if(isOwner == "true"){ - html = ''; - html+= '
'; - }else{ - html = ''; - } - - var newNode = document.createElement("div"); - newNode.innerHTML = html; - document.getElementById("actionBodyDiv").appendChild(newNode); -} -function removeActonTextarea(thisObj){ - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); -} - -function checkAction(){ - var actionTextValues = $("textarea[name='actionValue']"); - - var checkValue = $.trim(actionTextValues[0].value); //只校验第一个必须输入 - var type = $("#actiontype").val(); - if("ADD"==type && !checkValue){ - return false; - }else if(!checkValue){ - return false; - } - - var result = false; - var actionValues = new Array(); - $.each(actionTextValues,function(index,obj){ - var values = format(obj.value); - obj.value = values; - if(values!=""){ - actionValues.push(values); - result = true; - } - }); - - if(!result){ - $("#ActionErrMsg").show(); - } - - return result; - - function format(_values){ - var result = new Array(); - var values = _values.split(","); - $.each(values,function(index,value){ - value = $.trim(value); - if(value!=""){ - result.push(value); - } - }); - - if(!result || result.length==0){ - return ""; - }else{ - return result.join(","); - } - } -} - -function appendActions() { - var type = $("#actiontype").val(); - var html = getAppendHtml(type); - - if("threadanalysis" == $("#actionTypeSel").val()){ - $("#enableThreadAnalysis").val(false); - } - if("ADD"==type){ - var newNode = document.createElement("div"); - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - - /** - * 计算下拉菜单:删除当前选项 - */ - $("#actionTypeSel option[value="+$("#actionTypeSel").val()+"]").remove(); - - /** - * 计算是否还有添加类型:添加按钮控制 - */ - var actionTypeSelect = document.getElementById("actionTypeSel"); - if(actionTypeSelect.length == 0){ - $("#actionAddButton").attr("class","well-add"); - $("#actionAddButton").click(function(){}); - } - - - }else if("EDIT"==type){ - actionConf.actionObj.parentNode.innerHTML = html; - } - - function getAppendHtml(){ - var result = new Array(); - var actionTextValues = $("textarea[name='actionValue']"); - $.each(actionTextValues,function(index,obj){ - result.push(obj.value); - }); - - var actionType =""; - if(type=="ADD"){ - actionType = $("#actionTypeSel").val(); - }else if(type=="EDIT"){ - actionType = $("#actionEditType").val(); - } - - var jsonObj = {type:HtmlHelper.inputXSSFilter(actionType),value:HtmlHelper.inputXSSFilter(result)}; - if("threadanalysis" == jsonObj.type){ - var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; - }else{ - var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; - } - return html; - } -} -/** - * 触发动作操作 end - */ - - -function delThisObj(thisObj) { - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); - StgyClass.deleteWhereToStgyAppend(thisObj); -} - -function delThisActionObj(thisObj) { - - /** - * 还原当前选项 - */ - var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].innerHTML); - if(spanJson.type == "threadanalysis"){ - $("#enableThreadAnalysis").val(true); - } - $('#actionTypeSel').append(""); - $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); - $("#actionAddButton").click(function(){showAction(this,'ADD')}); - /** - * 删除显示 - */ - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); -} - -function checkNameIShow(){ - if($("#notifyNameI").val()){ - $("#notifyInstances").show(); - }else{ - $("#notifyInstances").val(""); - $("#notifyInstances").hide(); - } - selUiConf["userInput"]["notifyNameI"] = $("#notifyNameI").val(); -} - -function closeObjectDiv() { - window.winmgr.hide("objectDiv"); - window.winmgr.show("notifyList"); -} - -function openHelpDiv() { - window.open("https://uavorg.github.io/documents/uavdoc_useroperation/28.html#%E5%88%9B%E5%BB%BA","apphub.help"); -} - - -/** - * 策略表达式处理类 - */ -var StgyClass = { - datas:{//数据原型 - where:new Array() - }, - initDatas:function(){//初始化数据原型 - StgyClass.datas.where = new Array(); - }, - checkWhereExists : function() { - /** - * 判断条件是否存在 - */ - StgyClass.initDatas(); - var conditions = new Array(), exists = false; - var div = document.getElementById("objectDiv"); - var spans = div.getElementsByTagName("span"); - $.each(spans, function(index, obj) { - if(obj.id && obj.id.indexOf("_stgySpan")>=0){ - exists=true - /** - * 同时将条件数据打包 - */ - StgyClass.datas.where.push(JSON.parse(obj.textContent)); - } - }); - - return exists; - }, - showStgyDiv : function(thisObj,type) { - - var isOwner = $("#isOwner").val(); - /** - * 显示策略编辑(弹出新元素) - */ - actionConf.actionObj=thisObj.parentNode; - - var sb = new StringBuffer(); - sb.append("
"); - sb.append("触发策略"); - sb.append("
"); - sb.append("
"); - - if(StgyClass.checkWhereExists()){ //渲染触发策略页面 - sb.append( '
'); - $.each(StgyClass.datas.where,function(index,data){ - - if(isOwner=="true"){ - sb.append( ''); - }else{ - sb.append( ''); - } - }); - sb.append( '
'); - - - if(isOwner=="true"){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - if(type=="edit"){ - sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[0].innerHTML); - } - sb.append( '
'); - - if(isOwner=="true"){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - if(type=="edit"){ - sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[1].innerHTML); - } - sb.append( '
'); - - if(isOwner=="true"){ - sb.append( '
'); - } - - }else{ - sb.append("
没有可用条件
"); - } - - HtmlHelper.id("stgyDiv").innerHTML = sb.toString(); - window.winmgr.hide("objectDiv"); - window.winmgr.show("stgyDiv"); - - }, - closeStgyDiv : function() { - /** - * 关闭策略编辑(关闭元素) - */ - window.winmgr.hide("stgyDiv"); - window.winmgr.show("objectDiv"); - }, - appendWhereToStgy:function(thisObj) { - /** - * 在策略编辑:将选中条件追加到策略表达式 - */ - var whereId = thisObj.id + "_exp"; - - var html = '  ' - + thisObj.innerText + '  '; - /** - * 必须要focus一下目标元素,不然会跟随光标而追加html内容。 - */ - document.getElementById("stgy_exp").focus(); - var sel = window.getSelection(); - if (sel.getRangeAt && sel.rangeCount) { - var range = sel.getRangeAt(0); - range.deleteContents(); - - var el = document.createElement("div"); - el.innerHTML = html; - var frag = document.createDocumentFragment(), node, lastNode; - while ((node = el.firstChild)) { - lastNode = frag.appendChild(node); - } - range.insertNode(frag); - - // Preserve the selection - if (lastNode) { - range = range.cloneRange(); - range.setStartAfter(lastNode); - range.collapse(true); - sel.removeAllRanges(); - sel.addRange(range); - } - } - }, - saveStgyToAppend : function(type){ - /** - * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 - */ - var html = document.getElementById("stgy_exp").innerHTML; - var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); - - if(html.length>0 && type=="add"){ - html = '
'+ - '
'+html+'
'+ - '
'+htmlConvergence+'
'+ - '
'+ - ''; - '
'+ - '
'; - - var newNode = document.createElement("div"); - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - - }else if(html.length>0 && type=="edit"){ - actionConf.actionObj.parentNode.getElementsByTagName("div")[0].innerHTML = html; - actionConf.actionObj.parentNode.getElementsByTagName("div")[1].innerHTML = htmlConvergence; - } - - StgyClass.closeStgyDiv(); - - }, - deleteStgyToAppend : function(thisObj){ - /** - * 删除策略结果 - */ - var node = thisObj.parentNode.parentNode.parentNode; - node.removeChild(thisObj.parentNode.parentNode); - }, - updateWhereToStgyAppend : function(json){ - /** - *修改策略结果 - */ - var updateId = json.id+"_exp"; - var stgys = $("span[name='"+updateId+"']"); - $.each(stgys,function(index,obj){ - obj.innerHTML = " "+StgyClass.formatShowWhere(json)+" "; - }); - }, - deleteWhereToStgyAppend : function(thisObj){ - /** - * 删除条件时: 给对应策略添加删除线 - */ - var divId = thisObj.parentNode.getElementsByTagName("span")[0].id+"_exp"; - var stgys = $("span[name='"+divId+"']"); - $.each(stgys,function(index,obj){ - obj.className = "whereStgyEdit whereStgyEdit-delete"; - }); - - }, - /** - * 格式化条件,显示格式(除去id不显示) - * - * @param json - * @returns {String} - */ - formatShowWhere : function(json) { - - if(!json){ - return ""; - } - - var result; - - if(!json.type||json.type=="stream"){ - result = json.expr; - - if(json.range && json.range!=""){ - result += ","+json.range; - } - - if(json.func && json.func!=0 && json.func=="count"){ - result += ","+json.func+">"+json.cparam; - }else if(json.func && json.func!=0){ - result += ","+json.func; - } - }else{ - result = json.metric+","+json.time_from+"-"+json.time_to+","+json.aggr+","; - if(json.interval){ - result+=json.interval+" "; - - } - switch(json.unit){ - case "6": - result+="min"; - break; - case "5": - result+="hour"; - break; - case "1": - result+="day"; - break; - case "2": - result+="week"; - break; - case "3": - result+="month"; - break; - case "4": - result+="year"; - break; - } - } - - return result; - }, - randomId : function(x, y) { - if (!x) { - x = 9999; - } - if (!y) { - y = 1; - } - var d = [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ]; - - var rand = parseInt(Math.random() * (x - y + 1) + y) - + d[parseInt(Math.random() * d.length + 0)] - + parseInt(Math.random() * 1000) - + d[parseInt(Math.random() * d.length + 0)] - + parseInt(Math.random() * 1000); - return rand; - } +/** + * 窗体初始化 + */ +window.winmgr.build({ + id : "notifyList", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "ListBG" +}); +window.winmgr.build({ + id : "objectDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "ObjectBG" +}); +window.winmgr.build({ + id : "stgyDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "StgyDiv" +}); +window.winmgr.build({ + id : "condDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "condDiv" +}); +window.winmgr.show("notifyList"); + +/** + * 操作配置 + */ +var actionConf = { + actionObj:null //操作对象 +} +/** + * 下拉框UI + * */ +var selUiConf = { + keys:[ + + {"key":"server","value":"自定义指标"}, + {"key":"server","value":"服务端"}, + {"key":"client","value":"客户端"}, + {"key":"log","value":"日志"} + ], + "server":[ + ["procState","进程状态指标系"], + ["hostState","应用容器状态指标系"], + ["urlResp","服务状态指标系"], + ["appResp","应用状态指标系"], + ["serverResp","应用服务器状态指标系"], + ["procCrash","进程死亡指标系"] + ], + "client":[ + ["clientResp","调用状态指标系"] + ], + "log":[ + ["log","日志"] + ] + , + "userDef":[ + ["jvm","Java虚拟机状态指标系"] + ] + , + userInput:{ + "notifyNameF":"", + "notifyNameM":"", + "notifyNameI":"" + } + +} + +var supportJTA = ["服务状态指标系","应用状态指标系","应用服务器状态指标系","调用状态指标系"]; +/** + * 初始化头部 + */ +function initHeadDiv() { + var divContent = "" + + "
" + + + "" + + + "" + + + "" + + + "
" + + "" + + + "" + + "
" + "
" + ""; + HtmlHelper.id("notifyList").innerHTML += divContent; +} + +/** + * 显示添加策略 + */ +function showAddDiv() { + + var sb=new StringBuffer(); + sb.append( "
"); + sb.append( ""); + sb.append( ""); + sb.append( ""); + sb.append( "添加策略"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + + sb.append( '
'); + + + sb.append( '
'); + sb.append(''); + sb.append('
'); + sb.append(''); + sb.append(''); + sb.append(''); + sb.append('
'); + sb.append('
'); + + sb.append('
'); + sb.append('
'); + sb.append(''); + sb.append(''); + sb.append(''); + sb.append('
'); + sb.append( '
'); + sb.append('
'); + + sb.append( '
'); + sb.append( "
"); + + + sb.append( '
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
条件定义
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
触发策略
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
触发动作
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
'); + sb.append( '
 
'); + + sb.append( '
'); + + HtmlHelper.id("objectDiv").innerHTML = sb.toString(); + window.winmgr.hide("notifyList"); + window.winmgr.show("objectDiv"); + initActionDiv($("#isOwner").val()); + +} + + +/** + * 显示编辑策略 + */ +function showEditNotifyDiv(jsonObjParam) { + + var key,jsonObj,isOwner=false;enableThreadAnalysis=false; + //因为只有一对 key:value 获取key(值为id) + $.each(jsonObjParam,function(index,obj){ + key = index; + jsonObj = obj; + }); + + if(jsonObj.owner == window.parent.loginUser.userId + || window.parent.loginUser.groupId == "uav_admin" + || window.parent.loginUser.groupId == "vipgroup" + ){ + isOwner = true; + } + + var names = key.split("@"); + var cssType = "displayMsgInput",cssRedOnly = "displayMsgInput listIndex"; + var sb=new StringBuffer(); + sb.append( "
"); + sb.append( ""); + sb.append( "编辑策略"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + /** + * 所有渲染内容 div begin + */ + sb.append( '
'); + + sb.append( '
'); + if(window.parent.loginUser.groupId == "uav_admin" + || window.parent.loginUser.groupId == "vipgroup" + ){ + sb.append( '
'); + }else{ + + sb.append( '
'); + } + + + sb.append( '
'); + + //1 + var existsIns = jsonObj.instances.length>0?true:false; + var showNameF = getSelUiConfKeysValue(names[0],names[1]); + if(showNameF=="自定义指标"){ + cssType = "displayMsgInput listIndex_appmetrics"; + }else if(names[1] == "log"){ + showNameF = "日志"; + cssType = "displayMsgInput listIndex_log"; + }else if(names[0] == "server"){ + cssType = "displayMsgInput listIndex_server"; + }else if(names[0] == "client"){ + cssType = "displayMsgInput listIndex_client"; + } + sb.append( '
'); + selUiConf["userInput"]["notifyNameF"]=names[0];//编辑赋值,准备修改数据 + //2 + if(showNameF=="自定义指标"){ + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + }else if(names[1] == "log"){ + sb.append( '
'); + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + }else if(names[1]){ + sb.append( '
'); + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + if($.inArray(getSelUiConfigValue(names[1]),supportJTA) >= 0){ + enableThreadAnalysis=true; + } + } + //3 + if(names[2] && names[1] == "log"){ + var nNameIShow = "指定日志:"+names[2]; + sb.append( '
'); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + }else if(names[1] == "log"){ + sb.append( '
'); + }else if(names[2]){ + var nNameIShow = (existsIns?"实例组:":"实例:")+names[2]; + sb.append( '
'); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + }else{ + sb.append( '
'); + } + + if(names[2] && isOwner){ + sb.append( "
'); + }else if(names[2] && !isOwner){ + sb.append( "
'); + }else if(isOwner){ + sb.append( "
'); + }else{ + sb.append( "
'); + } + + + sb.append( '
'); + if(isOwner){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + /** + * 初始化条件 begin + */ + sb.append( '
'); + sb.append( '
'); + sb.append( '条件定义'); + sb.append( '
'); + $.each(jsonObj.conditions,function(index,obj){ + if(obj.func && obj.func.indexOf("count>")>-1){ + obj.cparam = obj.func.substr(6); + obj.func = "count"; + } + + if(!obj.id){ + /** + * 兼容老数据 + */ + obj.id=StgyClass.randomId()+"_stgySpan"; + } + var html; + if(isOwner){ + html = '
'+StgyClass.formatShowWhere(obj)+'
'; + }else{ + html = '
'+StgyClass.formatShowWhere(obj)+'
'; + } + sb.append( html); + }); + sb.append( '
'); + sb.append( '
'); + /** + * 初始化条件 end + */ + + /** + * 初始化触发策略 begin + */ + sb.append( '
'); + + if(isOwner){ + sb.append( '
触发策略
'); + }else{ + sb.append( '
触发策略
'); + } + + if(jsonObj.relationsHtmls){ + $.each(jsonObj.relationsHtmls,function(index,html){ + var convergenceVal = ""; + if(jsonObj.hasOwnProperty("convergences")){ + convergenceVal = jsonObj.convergences[index]; + } + + var appendHtml = + '
'+ + '
'+ + '
'+html+'
'+ + '
'+convergenceVal+'
'+ + '
'; + + if(isOwner){ + appendHtml+=''; + }else{ + appendHtml+=''; + } + appendHtml+='
'+ + '
'+ + '
'; + sb.append(appendHtml); + }); + } + sb.append( '
'); + /** + * 初始化触发策略 begin + */ + + sb.append( '
'); + sb.append( '
触发动作
'); + var actionSum = 0; + initActionDiv(isOwner?"true":"false"); + if (jsonObj.action!=undefined) { + $.each(jsonObj.action,function(index,value){ + actionSum++; + var josnSpan ={ + "type":index, + "value":value + } + + var html ; + + if(isOwner){ + if("threadanalysis" == josnSpan.type){ + var html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + }else{ + html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + } + }else{ + html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + } + sb.append( '
'); + sb.append( html); + sb.append( '
'); + + /** + * 计算下拉选项 + */ + $("#actionTypeSel option[value="+josnSpan.type+"]").remove(); + + }); + } + sb.append( '
'); + /** + * 初始化触发动作 end + */ + + if(isOwner){ + //按钮 + sb.append( '
'); + sb.append( '
'); + sb.append( '
 
'); + } + + sb.append( '
'); + /** + * 所有渲染内容 div end + */ + sb.append( ""); + HtmlHelper.id("objectDiv").innerHTML = sb.toString(); + + /** + * 判断出发条件:不是归属者不能添加 + */ + if(!isOwner){ + $("#whereAddButton").attr("class","well-add"); + $("#whereAddButton").click(function(){}); + } + /** + * 判断触发动作按钮 begin(类型都已经存在值,则不能再添加) + * 不是归属者也不能添加 + */ + var selTypeSize = $("#actionTypeSel option").size(); + if(selTypeSize == 0 || !isOwner){ + $("#actionAddButton").attr("class","well-add"); + $("#actionAddButton").click(function(){}); + } + /** + * 判断触发动作按钮 end + */ + window.winmgr.hide("notifyList"); + window.winmgr.show("objectDiv"); + + hideShowConStgy(names[1]); +} + + + +/** + * 触发动作添加窗口 + */ +function initActionDiv(isOwner) { + + var old = document.getElementById("actionDiv"); + if(old){ + var node = old.parentNode; + node.removeChild(old); + } + + var sb=new StringBuffer(); + + sb.append(''); + var div = document.createElement('div'); + div.innerHTML = sb.toString(); + document.body.appendChild(div); +} + +/** + * 显示添加条件窗口 + * @param thisObj + * @param type + */ +function showCon(thisObj,type){ + actionConf.actionObj=thisObj.parentNode; + if(selUiConf["userInput"]["notifyNameM"]=="log"){ + $("#condType").attr("disabled","disabled"); + } + $("#pageType").val(type); + if("EDIT" == type){ + var jsonValue = JSON.parse(thisObj.parentNode.getElementsByTagName("span")[0].textContent); + $("#condType").attr("disabled","disabled"); + var isOwner = $("#isOwner").val(); + if(!jsonValue.type||jsonValue.type=="stream"){ + $("#condType").val("stream"); + $("#contExpr").val(jsonValue.expr); + $("#conRange").val(jsonValue.range); + $("#conFunc").val((null == jsonValue.func?0:jsonValue.func)); + if("count" == jsonValue.func){ + $("#conFuncParam").val(jsonValue.cparam); + $("#conFuncParam").show(); + } + //不是归属用户,则只读 + if(isOwner!="true"){ + $("#whereSaveButton").hide(); + $("#contExpr").attr("readonly","readonly"); + $("#conRange").attr("readonly","readonly"); + $("#conFunc").attr("disabled","disabled"); + $("#conFuncParam").attr("readonly","readonly"); + + //只读CSS + $("#contExpr").attr("class","form-control"); + $("#conRange").attr("class","form-control"); + $("#conFuncParam").attr("class","form-control"); + $("#whereSaveButton").hide(); + } + + }else{ + var type; + if(jsonValue.interval){ + type="link-relative"; + }else{ + type="base-relative"; + } + $("#condType").val(type); + typeChangeShow(type); + + var hour=jsonValue.time_from.split(':')[0]; + var min=jsonValue.time_from.split(':')[1]; + $('#time_from_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + hour=jsonValue.time_to.split(':')[0]; + min=jsonValue.time_to.split(':')[1]; + $('#time_to_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + + if(jsonValue.time_start!=undefined&&jsonValue.time_end!=undefined){ + hour=jsonValue.time_start.split(':')[0]; + min=jsonValue.time_start.split(':')[1]; + $('#time_start_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + hour=jsonValue.time_end.split(':')[0]; + min=jsonValue.time_end.split(':')[1]; + $('#time_end_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + } + + if(jsonValue.day_start!=undefined&&jsonValue.day_end!=undefined){ + var year=jsonValue.day_start.split('-')[0]; + var month=jsonValue.day_start.split('-')[1]; + var day=jsonValue.day_start.split('-')[2]; + $('#day_start_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); + year=jsonValue.day_end.split('-')[0]; + month=jsonValue.day_end.split('-')[1]; + day=jsonValue.day_end.split('-')[2]; + $('#day_end_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); + } + + showWeekDay(jsonValue.weekdayLimit); + + $("#conMetric").val(jsonValue.metric); + $("#conUpperLimit").val(jsonValue.upperLimit); + $("#conLowerLimit").val(jsonValue.lowerLimit); + $("#conAggr").val(jsonValue.aggr); + $("#conDownSample").val(jsonValue.downsample); + if(type=="link-relative"){ + $("#conInterval").val(jsonValue.interval); + } + showUnit(jsonValue.unit); + + if(isOwner!="true"){ + $("#time_from").attr("readonly","readonly"); + $("#time_to").attr("readonly","readonly"); + $("#time_start").attr("readonly","readonly"); + $("#time_end").attr("readonly","readonly"); + $("#day_start").attr("readonly","readonly"); + $("#day_end").attr("readonly","readonly"); + $("#conMetric").attr("readonly","readonly"); + $("#conUpperLimit").attr("readonly","readonly"); + $("#conLowerLimit").attr("readonly","readonly"); + $("#conMetric").attr("class","form-control"); + $("#conUpperLimit").attr("class","form-control"); + $("#conLowerLimit").attr("class","form-control"); + $("#conAggr").attr("disabled","disabled"); + $("#conDownSample").attr("disabled","disabled"); + if(type=="link-relative"){ + $("#conInterval").attr("readonly","readonly"); + $("#conInterval").attr("class","form-control"); + } + $("#whereSaveButton").hide(); + } + } + + } + +} + +function showUnit(unit){ + $("#unit").val(unit); + $("#opt"+unit).attr("class","btn btn-default active"); +} + +function showWeekDay(weekdayLimit){ + + for(var i=0;i"); + sb.append("条件定义"); + sb.append("
"); + sb.append("
"); + sb.append( "
'); + + sb.append( '
'); + /** + * 普通预警条件编辑 + */ + sb.append( '
'); + + sb.append( '
触发表达式

'); + sb.append( '
持续时间(秒)

'); + sb.append( "
聚集操作

'); + sb.append( ')\" style="display:none" onkeyup="this.value=this.value.replace(\/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(\/\\D/g,\'\')">
'); + sb.append( '
'); + + /** + * 同环比预警条件编辑 + */ + sb.append( ''); + sb.append( ''); + + /** + * 保存按钮 + */ + sb.append( '
'); + sb.append( ''); + sb.append( ''); + sb.append( '
'); + + HtmlHelper.id("condDiv").innerHTML = sb.toString(); + initTimeControl(); + showCon(thisObj,type); + window.winmgr.hide("objectDiv"); + window.winmgr.show("condDiv"); + +} + +function funcChangeShow(thisObj,showId){ + if("count" == thisObj.value){ + $("#"+showId).show(); + }else{ + $("#"+showId).hide(); + } +} + +function typeChangeShow(type){ + var divs=["stream","timer","link-relative","base-relative"]; + divs.forEach(div=>{ + $("#"+div).hide(); + }) + if("stream"!=type){ + $("#timer").show(); + } + $("#"+type).show(); + +} +/** + * 初始化时间控件 + */ +function initTimeControl(){ + $('#time_from_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + + $('#time_to_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + $('#time_start_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + + $('#time_end_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + $('#day_start_div').datetimepicker({ + pickHour: false, + pickMin: false, + pickSeconds: false + }); + + + $('#day_end_div').datetimepicker({ + pickHour: false, + pickMin: false, + pickSeconds: false + }); + + +} + +function changeTimeUnit(value){ + $("#unit").val(value); +} + + + +function actionChangeShow(type){ + if("ADD" == type){ + if("threadanalysis" == $("#actionTypeSel").val()){ + $("textarea[name='actionValue']").val("10101").hide(); + $(".btn-addPriority").hide(); + }else{ + $("textarea[name='actionValue']").val("").show(); + $(".btn-addPriority").show(); + } + }else{ + $("textarea[name='actionValue']").show(); + $(".btn-addPriority").show(); + } +} + +function selServerChangeShow(type,value,text){ + var selId = type+"_notifyNameF"; + $("#"+selId).html(text); + $("#"+selId).css("padding-left","2px"); + $("#"+type+"_notifyNameF").css("color","black"); + + hideShowConStgy("show"); + + if(text == "自定义指标"){ + $("#"+type+"_appName_div").hide(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); + selUiConf["userInput"]["notifyNameF"]=value; + selUiConf["userInput"]["notifyNameM"]="jvm"; + $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + }else if(value=="log"){ + $("#"+type+"_appName_div").show(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); + $("#notifyNameI").attr("placeholder","输入指定日志"); + selUiConf["userInput"]["notifyNameF"]=""; + selUiConf["userInput"]["notifyNameM"]=value; + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + }else{ + $("#"+type+"_appName_div").hide(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv"); + $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); + $("#"+type+"_notifyNameM").css("color","darkgrey"); + $("#"+type+"_notifyNameM").html("选择监控组指标"); + document.getElementById(type+"_notifyNameM_body").innerHTML =""; + $.each(selUiConf[value],function(index,obj){ + var li = document.createElement("li"); + var a = document.createElement("a"); + a.innerHTML=obj[1]; + a.onclick=function(){selIndexChangeShow(type,obj[0],obj[1]);}; + a.href="#"; + li.appendChild(a); + document.getElementById(type+"_notifyNameM_body").appendChild(li); + }); + selUiConf["userInput"]["notifyNameF"]=value; + } + +} + +function removeChoosedJTA(){ + if(HtmlHelper.id("ChoosedJTA") != null){ + HtmlHelper.id("ChoosedJTA").remove(); + } +} + +function changeJTAStat(text){ + if($.inArray(text,supportJTA) >= 0){ + $("#enableThreadAnalysis").val(true); + if(HtmlHelper.id("ChoosedJTA") == null){ + $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); + $("#actionAddButton").click(function(){showAction(this,'ADD')}); + } + }else{ + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + } +} + +function hideShowConStgy(value){ + if(value == "procCrash"){ + $("#conFatDiv").hide(); + $("#stgyFatDiv").hide(); + } + else{ + $("#conFatDiv").show(); + $("#stgyFatDiv").show(); + } +} + +function selIndexChangeShow(type,value,text){ + changeJTAStat(text); + hideShowConStgy(value); + + $("#"+type+"_notifyNameM").html(text); + $("#"+type+"_notifyNameM").css("padding-left","2px"); + $("#"+type+"_notifyNameM").css("color","black"); + selUiConf["userInput"]["notifyNameM"]=value; +} + +function appNameChange(obj){ + selUiConf["userInput"]["notifyNameF"]=obj.value; +} +function getSelUiConfigValue(indexValue){ + var result =""; + $.each(selUiConf.keys,function(value,obj1){ + $.each(selUiConf[obj1.key],function(index,obj2){ + if(obj2[0]==indexValue){ + result=obj2[1]; + return false; + } + }); + if(result!==""){ + return false; + } + }); + + return result; +} +function getSelUiConfKeysValue(a, b) { + var result = ""; + if (b == "log") { + result="日志"; + } else if (a == "server" && b == "jvm") { + result="自定义指标"; + } else if (a == "server") { + result="服务端"; + } else if (a == "client") { + result="客户端"; + } + return result; +} +function conditionsAppend(){ + if(checkFunc()){ + var jsonObject; + if("stream"==$("#condType").val()){ + jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; + }else{ + jsonObject = {"type":"timer","time_from":HtmlHelper.inputXSSFilter($("#time_from").val()),"time_to":HtmlHelper.inputXSSFilter($("#time_to").val()),"metric":HtmlHelper.inputXSSFilter($("#conMetric").val()),"upperLimit":HtmlHelper.inputXSSFilter($("#conUpperLimit").val()),"lowerLimit":HtmlHelper.inputXSSFilter($("#conLowerLimit").val())}; + + if(HtmlHelper.inputXSSFilter($("#conAggr").val())!="0"){ + jsonObject["aggr"]=HtmlHelper.inputXSSFilter($("#conAggr").val()); + }else{ + jsonObject["aggr"]="avg"; + } + + if(HtmlHelper.inputXSSFilter($("#conDownSample").val())!="0"){ + jsonObject["downsample"]=HtmlHelper.inputXSSFilter($("#conDownSample").val()); + }else{ + jsonObject["downsample"]="all-avg"; + } + + if("link-relative"==$("#condType").val()){ + jsonObject["interval"]=HtmlHelper.inputXSSFilter($("#conInterval").val()); + jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); + }else{ + jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); + } + + if($("#time_start").val()&&$("#time_end").val()){ + jsonObject["time_start"]=HtmlHelper.inputXSSFilter($("#time_start").val()); + jsonObject["time_end"]=HtmlHelper.inputXSSFilter($("#time_end").val()); + } + + if($("#day_start").val()&&$("#day_end").val()){ + jsonObject["day_start"]=HtmlHelper.inputXSSFilter($("#day_start").val()); + jsonObject["day_end"]=HtmlHelper.inputXSSFilter($("#day_end").val()); + } + + var weekdayLimit=[]; + for(var i=0;i<7;i++){ + weekdayLimit[i]=($("#weekday"+i).attr("class")=="btn btn-default active") + } + jsonObject["weekdayLimit"]=weekdayLimit; + + } + appendConditions(jsonObject); + window.winmgr.hide("condDiv"); + window.winmgr.show("objectDiv"); + } +} + +function checkFunc(){ + + var result = true; + if("stream"==$("#condType").val()){ + if(!$("#contExpr").val()){ + result = false; + }else if("count" == $("#conFunc").val() && !$("#conFuncParam").val()){ + result = false; + } + }else{ + if(!$("#time_from").val()||!$("#time_to").val()||!$("#conMetric").val()||!$("#conUpperLimit").val()||!$("#conLowerLimit").val()){ + result = false; + } + if("link-relative"==$("#condType").val()){ + if(!$("#conInterval").val()||!$("#unit").val()){ + result = false; + } + }else{ + if(!$("#unit").val()){ + result = false; + } + } + } + + + if(result){ + $("#conditionsErrMsg").hide(); + }else{ + $("#conditionsErrMsg").show(); + } + + return result; +} +function appendConditions(jsonObj) { + var type = $("#pageType").val(); + if("ADD"==type){ + var newNode = document.createElement("div"); + var stgyDivId = StgyClass.randomId()+"_stgySpan"; + html = '
'+getHtmlAndSetId(stgyDivId)+'
'; + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + }else if("EDIT"==type){ + var oldId = actionConf.actionObj.getElementsByTagName("span")[0].id; + actionConf.actionObj.innerHTML= getHtmlAndSetId(oldId); + StgyClass.updateWhereToStgyAppend(jsonObj); + } + + function getHtmlAndSetId(stgyDivId){ + jsonObj.id = stgyDivId;//赋值id + var html = StgyClass.formatShowWhere(jsonObj)+''; + return html; + } +} +/** + * 条件窗口操作 end + */ + + +/** + * 触发动作操作 begin + */ +function showAction(thisObj,type){ + actionConf.actionObj=thisObj.parentNode; + checkJTAAction(); + $("#actiontype").val(type); + $.each($("textarea[name='actionValue']"),function(index,obj){ + if(index>0){ + removeActonTextarea(obj); + }else{ + obj.value=""; + } + }); + $("#actionDiv").modal({backdrop: 'static', keyboard: false}); + $("#actionDiv").modal(); + //还原只读 + $("#actionSaveButton").show(); + $("#actionValue").removeAttr("readonly"); + + + if("EDIT"==type){ + //不是归属用户,则只读 + var isOwner = $("#isOwner").val(); + $("#actionTypeSel").hide(); + var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].textContent); + + $.each(spanJson.value,function(index,value){ + /** + * 第一次循环:追加渲染 + */ + if(index>0){ + appendActionTextarea(); + } + }); + var actionTextValues = $("textarea[name='actionValue']"); + $.each(spanJson.value,function(index,value){ + /** + * 第二次循环:赋值 + */ + actionTextValues[index].value=value; + }); + + $("#actionEditType").val(spanJson.type); + + actionChangeShow("EDIT"); + if(isOwner!="true"){ + $("#actionSaveButton").hide(); + } + }else{ + $("#actionTypeSel").show(); + actionChangeShow("ADD"); + } +} + +function checkJTAAction(){ + if($("#enableThreadAnalysis").val() =="true"&& $("#actionTypeSel").find("option[value='threadanalysis']").size() == 0 && $("#ChoosedJTA").size() == 0){ + $("#actionTypeSel").append(""); + } + else if($("#enableThreadAnalysis").val() == "false" && $("#actionTypeSel").find("option[value='threadanalysis']").size() == 1){ + $("#actionTypeSel option[value=threadanalysis]").remove(); + } +} + +function actionAppend(){ + + $("#ActionErrMsg").hide(); + + if(checkAction()){ + appendActions(); + $("#actionDiv").modal('hide'); + }else{ + $("#ActionErrMsg").show(); + } +} + +function appendActionTextarea(thisObj){ + var isOwner = $("#isOwner").val(); + + var html = ''; + if(isOwner == "true"){ + html = ''; + html+= '
'; + }else{ + html = ''; + } + + var newNode = document.createElement("div"); + newNode.innerHTML = html; + document.getElementById("actionBodyDiv").appendChild(newNode); +} +function removeActonTextarea(thisObj){ + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); +} + +function checkAction(){ + var actionTextValues = $("textarea[name='actionValue']"); + + var checkValue = $.trim(actionTextValues[0].value); //只校验第一个必须输入 + var type = $("#actiontype").val(); + if("ADD"==type && !checkValue){ + return false; + }else if(!checkValue){ + return false; + } + + var result = false; + var actionValues = new Array(); + $.each(actionTextValues,function(index,obj){ + var values = format(obj.value); + obj.value = values; + if(values!=""){ + actionValues.push(values); + result = true; + } + }); + + if(!result){ + $("#ActionErrMsg").show(); + } + + return result; + + function format(_values){ + var result = new Array(); + var values = _values.split(","); + $.each(values,function(index,value){ + value = $.trim(value); + if(value!=""){ + result.push(value); + } + }); + + if(!result || result.length==0){ + return ""; + }else{ + return result.join(","); + } + } +} + +function appendActions() { + var type = $("#actiontype").val(); + var html = getAppendHtml(type); + + if("threadanalysis" == $("#actionTypeSel").val()){ + $("#enableThreadAnalysis").val(false); + } + if("ADD"==type){ + var newNode = document.createElement("div"); + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + + /** + * 计算下拉菜单:删除当前选项 + */ + $("#actionTypeSel option[value="+$("#actionTypeSel").val()+"]").remove(); + + /** + * 计算是否还有添加类型:添加按钮控制 + */ + var actionTypeSelect = document.getElementById("actionTypeSel"); + if(actionTypeSelect.length == 0){ + $("#actionAddButton").attr("class","well-add"); + $("#actionAddButton").click(function(){}); + } + + + }else if("EDIT"==type){ + actionConf.actionObj.parentNode.innerHTML = html; + } + + function getAppendHtml(){ + var result = new Array(); + var actionTextValues = $("textarea[name='actionValue']"); + $.each(actionTextValues,function(index,obj){ + result.push(obj.value); + }); + + var actionType =""; + if(type=="ADD"){ + actionType = $("#actionTypeSel").val(); + }else if(type=="EDIT"){ + actionType = $("#actionEditType").val(); + } + + var jsonObj = {type:HtmlHelper.inputXSSFilter(actionType),value:HtmlHelper.inputXSSFilter(result)}; + if("threadanalysis" == jsonObj.type){ + var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; + }else{ + var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; + } + return html; + } +} +/** + * 触发动作操作 end + */ + + +function delThisObj(thisObj) { + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); + StgyClass.deleteWhereToStgyAppend(thisObj); +} + +function delThisActionObj(thisObj) { + + /** + * 还原当前选项 + */ + var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].innerHTML); + if(spanJson.type == "threadanalysis"){ + $("#enableThreadAnalysis").val(true); + } + $('#actionTypeSel').append(""); + $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); + $("#actionAddButton").click(function(){showAction(this,'ADD')}); + /** + * 删除显示 + */ + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); +} + +function checkNameIShow(){ + if($("#notifyNameI").val()){ + $("#notifyInstances").show(); + }else{ + $("#notifyInstances").val(""); + $("#notifyInstances").hide(); + } + selUiConf["userInput"]["notifyNameI"] = $("#notifyNameI").val(); +} + +function closeObjectDiv() { + window.winmgr.hide("objectDiv"); + window.winmgr.show("notifyList"); +} + +function openHelpDiv() { + window.open("https://uavorg.github.io/documents/uavdoc_useroperation/28.html#%E5%88%9B%E5%BB%BA","apphub.help"); +} + + +/** + * 策略表达式处理类 + */ +var StgyClass = { + datas:{//数据原型 + where:new Array() + }, + initDatas:function(){//初始化数据原型 + StgyClass.datas.where = new Array(); + }, + checkWhereExists : function() { + /** + * 判断条件是否存在 + */ + StgyClass.initDatas(); + var conditions = new Array(), exists = false; + var div = document.getElementById("objectDiv"); + var spans = div.getElementsByTagName("span"); + $.each(spans, function(index, obj) { + if(obj.id && obj.id.indexOf("_stgySpan")>=0){ + exists=true + /** + * 同时将条件数据打包 + */ + StgyClass.datas.where.push(JSON.parse(obj.textContent)); + } + }); + + return exists; + }, + showStgyDiv : function(thisObj,type) { + + var isOwner = $("#isOwner").val(); + /** + * 显示策略编辑(弹出新元素) + */ + actionConf.actionObj=thisObj.parentNode; + + var sb = new StringBuffer(); + sb.append("
"); + sb.append("触发策略"); + sb.append("
"); + sb.append("
"); + + if(StgyClass.checkWhereExists()){ //渲染触发策略页面 + sb.append( '
'); + $.each(StgyClass.datas.where,function(index,data){ + + if(isOwner=="true"){ + sb.append( ''); + }else{ + sb.append( ''); + } + }); + sb.append( '
'); + + + if(isOwner=="true"){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + if(type=="edit"){ + sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[0].innerHTML); + } + sb.append( '
'); + + if(isOwner=="true"){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + if(type=="edit"){ + sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[1].innerHTML); + } + sb.append( '
'); + + if(isOwner=="true"){ + sb.append( '
'); + } + + }else{ + sb.append("
没有可用条件
"); + } + + HtmlHelper.id("stgyDiv").innerHTML = sb.toString(); + window.winmgr.hide("objectDiv"); + window.winmgr.show("stgyDiv"); + + }, + closeStgyDiv : function() { + /** + * 关闭策略编辑(关闭元素) + */ + window.winmgr.hide("stgyDiv"); + window.winmgr.show("objectDiv"); + }, + appendWhereToStgy:function(thisObj) { + /** + * 在策略编辑:将选中条件追加到策略表达式 + */ + var whereId = thisObj.id + "_exp"; + + var html = '  ' + + thisObj.innerText + '  '; + /** + * 必须要focus一下目标元素,不然会跟随光标而追加html内容。 + */ + document.getElementById("stgy_exp").focus(); + var sel = window.getSelection(); + if (sel.getRangeAt && sel.rangeCount) { + var range = sel.getRangeAt(0); + range.deleteContents(); + + var el = document.createElement("div"); + el.innerHTML = html; + var frag = document.createDocumentFragment(), node, lastNode; + while ((node = el.firstChild)) { + lastNode = frag.appendChild(node); + } + range.insertNode(frag); + + // Preserve the selection + if (lastNode) { + range = range.cloneRange(); + range.setStartAfter(lastNode); + range.collapse(true); + sel.removeAllRanges(); + sel.addRange(range); + } + } + }, + saveStgyToAppend : function(type){ + /** + * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 + */ + var html = document.getElementById("stgy_exp").innerHTML; + var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); + + if(html.length>0 && type=="add"){ + html = '
'+ + '
'+html+'
'+ + '
'+htmlConvergence+'
'+ + '
'+ + ''; + '
'+ + '
'; + + var newNode = document.createElement("div"); + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + + }else if(html.length>0 && type=="edit"){ + actionConf.actionObj.parentNode.getElementsByTagName("div")[0].innerHTML = html; + actionConf.actionObj.parentNode.getElementsByTagName("div")[1].innerHTML = htmlConvergence; + } + + StgyClass.closeStgyDiv(); + + }, + deleteStgyToAppend : function(thisObj){ + /** + * 删除策略结果 + */ + var node = thisObj.parentNode.parentNode.parentNode; + node.removeChild(thisObj.parentNode.parentNode); + }, + updateWhereToStgyAppend : function(json){ + /** + *修改策略结果 + */ + var updateId = json.id+"_exp"; + var stgys = $("span[name='"+updateId+"']"); + $.each(stgys,function(index,obj){ + obj.innerHTML = " "+StgyClass.formatShowWhere(json)+" "; + }); + }, + deleteWhereToStgyAppend : function(thisObj){ + /** + * 删除条件时: 给对应策略添加删除线 + */ + var divId = thisObj.parentNode.getElementsByTagName("span")[0].id+"_exp"; + var stgys = $("span[name='"+divId+"']"); + $.each(stgys,function(index,obj){ + obj.className = "whereStgyEdit whereStgyEdit-delete"; + }); + + }, + /** + * 格式化条件,显示格式(除去id不显示) + * + * @param json + * @returns {String} + */ + formatShowWhere : function(json) { + + if(!json){ + return ""; + } + + var result; + + if(!json.type||json.type=="stream"){ + result = json.expr; + + if(json.range && json.range!=""){ + result += ","+json.range; + } + + if(json.func && json.func!=0 && json.func=="count"){ + result += ","+json.func+">"+json.cparam; + }else if(json.func && json.func!=0){ + result += ","+json.func; + } + }else{ + result = json.metric+","+json.time_from+"-"+json.time_to+","+json.downsample+","+json.aggr+","; + if(json.interval){ + result+=json.interval+" "; + + } + switch(json.unit){ + case "6": + result+="min"; + break; + case "5": + result+="hour"; + break; + case "1": + result+="day"; + break; + case "2": + result+="week"; + break; + case "3": + result+="month"; + break; + case "4": + result+="year"; + break; + } + if(json.time_start!=undefined&&json.time_end!=undefined){ + result+=","+json.time_start+"-"+json.time_end; + } + if(json.day_start!=undefined&&json.day_end!=undefined){ + result+=","+json.day_start+"-"+json.day_end; + } + } + + return result; + }, + randomId : function(x, y) { + if (!x) { + x = 9999; + } + if (!y) { + y = 1; + } + var d = [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ]; + + var rand = parseInt(Math.random() * (x - y + 1) + y) + + d[parseInt(Math.random() * d.length + 0)] + + parseInt(Math.random() * 1000) + + d[parseInt(Math.random() * d.length + 0)] + + parseInt(Math.random() * 1000); + return rand; + } } \ No newline at end of file diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java index 147218cc..f5b420c1 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java @@ -1,511 +1,562 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature.runtimenotify; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.creditease.agent.helpers.DateTimeHelper; -import com.creditease.agent.helpers.EncodeHelper; -import com.creditease.agent.helpers.JSONHelper; - -/** - * notify strategy ds - */ -public class NotifyStrategy { - - public enum Type { - STREAM("stream"), TIMER("timer"); - - private String name; - - Type(String name) { - this.name = name; - } - - @Override - public String toString() { - - return name; - } - } - - private static final String[] OPERATORS = { ":=", "!=", ">", "<", "=" }; - - private static final Pattern INDEX_PATTERN = Pattern.compile("\\[\\d+\\]"); - - private Type type; - - private String scope; - - private List condtions; - - private List convergences; - - private String msgTemplate; - - private Map action = Collections.emptyMap(); - - private List context = Collections.emptyList(); - - private List instances = Collections.emptyList(); - - private long maxRange = 0; - - private String name; - - public NotifyStrategy() { - } - - public NotifyStrategy(String name, String scope, List context, Map action, - List instances, String msgTemplate, List convergences) { - this.name = name; - this.scope = scope; - if (context != null && context.size() != 0) { - this.context = context; - } - if (action != null && action.size() != 0) { - this.action = action; - } - if (instances != null && instances.size() != 0) { - this.instances = instances; - } - this.convergences = convergences; - this.msgTemplate = msgTemplate; - } - - public void setConditions(List conditions, List relations) { - - int idx = 0; // expression count - List exprs = new ArrayList<>(); - for (Object o : conditions) { - - // condition is simple string: "arg>123" - if (String.class.isAssignableFrom(o.getClass())) { - Expression expression = new Expression((String) o); - expression.setIdx(idx++); - exprs.add(expression); - } - else { - @SuppressWarnings("unchecked") - Map cond = (Map) o; - Expression expression; - if (cond.get("type") == null || cond.get("type").equals(Type.STREAM.name)) { - String expr = (String) cond.get("expr"); - String func = (String) cond.get("func"); - Long range = cond.get("range") == null ? null : Long.valueOf(cond.get("range").toString()); - Float sampling = cond.get("sampling") == null ? null - : Float.valueOf(cond.get("sampling").toString()); - expression = new Expression(expr, func, range, sampling); - } - else { - String metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); - cond.put("metric", metricPrefix + "." + cond.get("metric")); - expression = new Expression(cond); - this.type = Type.TIMER; - } - expression.setIdx(idx++); - exprs.add(expression); - } - } - - idx = 1; // reuse for condition count, start from 1 - List conds = null; - if (relations == null || relations.isEmpty()) { - conds = new ArrayList<>(conditions.size()); - - for (Expression expr : exprs) { - conds.add(new Condition(idx++, expr)); - } - } - else { - conds = new ArrayList<>(relations.size()); - for (String relation : relations) { - - Matcher m = INDEX_PATTERN.matcher(relation); - Set set = new HashSet<>(); - while (m.find()) { - String idxHolder = m.group(); - int i = Integer.parseInt(idxHolder.substring(1, idxHolder.length() - 1)); - if (i >= exprs.size()) { // IndexOutOfBoundsException - continue; - } - set.add(exprs.get(i)); - relation = relation.replace(idxHolder, "{" + i + "}"); // temp i - } - - List list = new ArrayList<>(set); - for (int i = 0; i < list.size(); i++) { - relation = relation.replace("{" + list.get(i).getIdx() + "}", "[" + i + "]"); - } - conds.add(new Condition(idx++, list, relation)); - } - } - - this.condtions = conds; - - /** init max range */ - for (Condition cond : this.condtions) { - for (Expression expr : cond.expressions) { - maxRange = Math.max(maxRange, expr.range); - } - } - - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static NotifyStrategy parse(String name, String json) { - - Map m = JSONHelper.toObject(json, Map.class); - String scope = (String) m.get("scope"); - List context = (List) m.get("context"); - List conditions = (List) m.get("conditions"); - List relations = (List) m.get("relations"); - List convergences = (List) m.get("convergences"); - Map action = (Map) m.get("action"); - String msgTemplate = (String) m.get("msgTemplate"); - List instances = (List) m.get("instances"); - - NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); - - stra.setConditions(conditions, relations); - - return stra; - } - - public long getMaxRange() { - - return maxRange; - } - - public String getMsgTemplate() { - - return msgTemplate; - } - - public void setMsgTemplate(String msgTemplate) { - - this.msgTemplate = msgTemplate; - } - - public Map getAction() { - - return action; - } - - public void setAction(Map action) { - - this.action = action; - } - - public List getContext() { - - return context; - } - - public void setContext(List context) { - - this.context = context; - } - - public String getScope() { - - return scope; - } - - public void setScope(String scope) { - - this.scope = scope; - } - - public List getInstances() { - - return instances; - } - - public void setInstances(List instances) { - - this.instances = instances; - } - - public String getName() { - - return name; - } - - public Type getType() { - - return type; - } - - public List getCondtions() { - - return condtions; - } - - public List getConvergences() { - - return convergences; - } - - protected static class Expression { - - private int idx; - private Type type; - private String arg; - private String operator; - private String expectedValue; - private long range = 0; - private String func; - private float sampling = 1; - - private Set matchArgExpr = new HashSet(); - - private long time_from; - private long time_to; - private long interval; - private int unit; - private String upperLimit; - private String lowerLimit; - - public Expression(String exprStr) { - for (String op : OPERATORS) { - if (exprStr.contains(op)) { - String[] exprs = exprStr.split(op); - this.arg = exprs[0].trim(); - - // suport * as a match - initMatchArgExpr(); - - this.operator = op; - this.expectedValue = exprs[1]; - break; - } - } - this.type = Type.STREAM; - } - - public Expression(String exprStr, String func, Long range, Float sampling) { - this(exprStr); - if (range != null && range > 0) { - this.range = range * 1000; // second to ms - } - this.func = func; - if (sampling != null) { - this.sampling = sampling; - } - - } - - public Expression(Map cond) { - - this.arg = (String) cond.get("metric"); - this.unit = Integer.parseInt((String) cond.get("unit")); - this.time_from = DateTimeHelper - .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_from"), "yyyy-MM-dd HH:mm") - .getTime(); - this.time_to = DateTimeHelper - .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_to"), "yyyy-MM-dd HH:mm") - .getTime(); - if (cond.get("interval") != null) { - long interval = Long.parseLong((String) cond.get("interval")); - switch (unit) { - case DateTimeHelper.INTERVAL_DAY: - interval = interval * 24 * 3600 * 1000; - break; - case DateTimeHelper.INTERVAL_HOUR: - interval = interval * 3600 * 1000; - break; - case DateTimeHelper.INTERVAL_MINUTE: - interval = interval * 60000; - break; - } - this.interval = interval; - } - - this.upperLimit = (String) cond.get("upperLimit"); - this.lowerLimit = (String) cond.get("lowerLimit"); - this.func = (String) cond.get("aggr"); - this.type = Type.TIMER; - } - - private void initMatchArgExpr() { - - if (this.arg.indexOf("*") > -1) { - String[] tmps = this.arg.split("\\*"); - for (String tmp : tmps) { - matchArgExpr.add(tmp); - } - } - } - - public boolean isMatchExpr() { - - return matchArgExpr.size() > 0; - } - - public Set matchTargetArgs(Set srcArgs) { - - Set targetArgs = new HashSet(); - - for (String arg : srcArgs) { - - int matchCount = 0; - for (String matchField : this.matchArgExpr) { - - if (arg.indexOf(matchField) > -1) { - matchCount++; - } - } - - if (matchCount == this.matchArgExpr.size()) { - targetArgs.add(arg); - } - } - - return targetArgs; - } - - public String getHashCode() { - - return EncodeHelper.encodeMD5(arg + func + lowerLimit + upperLimit + time_from + time_to + interval + unit); - } - - public String getArg() { - - return arg; - } - - public String getOperator() { - - return operator; - } - - public String getExpectedValue() { - - return expectedValue; - } - - public long getRange() { - - return range; - } - - public String getFunc() { - - return func; - } - - public float getSampling() { - - return sampling; - } - - public int getIdx() { - - return idx; - } - - public Type getType() { - - return type; - } - - public long getTime_from() { - - return time_from; - } - - public long getTime_to() { - - return time_to; - } - - public long getInterval() { - - return interval; - } - - public String getUpperLimit() { - - return upperLimit; - } - - public String getLowerLimit() { - - return lowerLimit; - } - - public int getUnit() { - - return unit; - } - - public void setIdx(int idx) { - - this.idx = idx; - } - - } - - protected class Condition { - - private int index; - private List expressions; - private String relation; - - public Condition(int index, Expression expr) { - this.index = index; - List exprs = new ArrayList<>(1); - exprs.add(expr); - this.expressions = exprs; - } - - public Condition(int index, List exprs, String relation) { - this.index = index; - this.expressions = exprs; - this.relation = relation; - } - - public int getIndex() { - - return index; - } - - public List getExpressions() { - - return expressions; - } - - public String getRelation() { - - return relation; - } - - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.alibaba.fastjson.JSONArray; +import com.creditease.agent.helpers.DateTimeHelper; +import com.creditease.agent.helpers.EncodeHelper; +import com.creditease.agent.helpers.JSONHelper; + +/** + * notify strategy ds + */ +public class NotifyStrategy { + + public enum Type { + STREAM("stream"), TIMER("timer"); + + private String name; + + Type(String name) { + this.name = name; + } + + @Override + public String toString() { + + return name; + } + } + + private static final String[] OPERATORS = { ":=", "!=", ">", "<", "=" }; + + private static final Pattern INDEX_PATTERN = Pattern.compile("\\[\\d+\\]"); + + private Type type; + + private String scope; + + private List condtions; + + private List convergences; + + private String msgTemplate; + + private Map action = Collections.emptyMap(); + + private List context = Collections.emptyList(); + + private List instances = Collections.emptyList(); + + private long maxRange = 0; + + private String name; + + public NotifyStrategy() { + } + + public NotifyStrategy(String name, String scope, List context, Map action, + List instances, String msgTemplate, List convergences) { + this.name = name; + this.scope = scope; + if (context != null && context.size() != 0) { + this.context = context; + } + if (action != null && action.size() != 0) { + this.action = action; + } + if (instances != null && instances.size() != 0) { + this.instances = instances; + } + this.convergences = convergences; + this.msgTemplate = msgTemplate; + } + + public void setConditions(List conditions, List relations) { + + int idx = 0; // expression count + List exprs = new ArrayList<>(); + for (Object o : conditions) { + + // condition is simple string: "arg>123" + if (String.class.isAssignableFrom(o.getClass())) { + Expression expression = new Expression((String) o); + expression.setIdx(idx++); + exprs.add(expression); + } + else { + @SuppressWarnings("unchecked") + Map cond = (Map) o; + Expression expression; + if (cond.get("type") == null || cond.get("type").equals(Type.STREAM.name)) { + String expr = (String) cond.get("expr"); + String func = (String) cond.get("func"); + Long range = cond.get("range") == null ? null : Long.valueOf(cond.get("range").toString()); + Float sampling = cond.get("sampling") == null ? null + : Float.valueOf(cond.get("sampling").toString()); + expression = new Expression(expr, func, range, sampling); + } + else { + String metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); + cond.put("metric", metricPrefix + "." + cond.get("metric")); + expression = new Expression(cond); + this.type = Type.TIMER; + } + expression.setIdx(idx++); + exprs.add(expression); + } + } + + idx = 1; // reuse for condition count, start from 1 + List conds = null; + if (relations == null || relations.isEmpty()) { + conds = new ArrayList<>(conditions.size()); + + for (Expression expr : exprs) { + conds.add(new Condition(idx++, expr)); + } + } + else { + conds = new ArrayList<>(relations.size()); + for (String relation : relations) { + + Matcher m = INDEX_PATTERN.matcher(relation); + Set set = new HashSet<>(); + while (m.find()) { + String idxHolder = m.group(); + int i = Integer.parseInt(idxHolder.substring(1, idxHolder.length() - 1)); + if (i >= exprs.size()) { // IndexOutOfBoundsException + continue; + } + set.add(exprs.get(i)); + relation = relation.replace(idxHolder, "{" + i + "}"); // temp i + } + + List list = new ArrayList<>(set); + for (int i = 0; i < list.size(); i++) { + relation = relation.replace("{" + list.get(i).getIdx() + "}", "[" + i + "]"); + } + conds.add(new Condition(idx++, list, relation)); + } + } + + this.condtions = conds; + + /** init max range */ + for (Condition cond : this.condtions) { + for (Expression expr : cond.expressions) { + maxRange = Math.max(maxRange, expr.range); + } + } + + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static NotifyStrategy parse(String name, String json) { + + Map m = JSONHelper.toObject(json, Map.class); + String scope = (String) m.get("scope"); + List context = (List) m.get("context"); + List conditions = (List) m.get("conditions"); + List relations = (List) m.get("relations"); + List convergences = (List) m.get("convergences"); + Map action = (Map) m.get("action"); + String msgTemplate = (String) m.get("msgTemplate"); + List instances = (List) m.get("instances"); + + NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); + + stra.setConditions(conditions, relations); + + return stra; + } + + public long getMaxRange() { + + return maxRange; + } + + public String getMsgTemplate() { + + return msgTemplate; + } + + public void setMsgTemplate(String msgTemplate) { + + this.msgTemplate = msgTemplate; + } + + public Map getAction() { + + return action; + } + + public void setAction(Map action) { + + this.action = action; + } + + public List getContext() { + + return context; + } + + public void setContext(List context) { + + this.context = context; + } + + public String getScope() { + + return scope; + } + + public void setScope(String scope) { + + this.scope = scope; + } + + public List getInstances() { + + return instances; + } + + public void setInstances(List instances) { + + this.instances = instances; + } + + public String getName() { + + return name; + } + + public Type getType() { + + return type; + } + + public List getCondtions() { + + return condtions; + } + + public List getConvergences() { + + return convergences; + } + + protected static class Expression { + + private int idx; + private Type type; + private String arg; + private String operator; + private String expectedValue; + private long range = 0; + private String func; + private float sampling = 1; + private String downsample; + private Boolean[] weekdayLimit=new Boolean[] {true,true,true,true,true,true,true}; + + private Set matchArgExpr = new HashSet(); + + private long time_from; + private long time_to; + private long interval; + private int unit; + private String upperLimit; + private String lowerLimit; + private String time_end; + private String time_start; + private String day_start; + private String day_end; + + public Expression(String exprStr) { + for (String op : OPERATORS) { + if (exprStr.contains(op)) { + String[] exprs = exprStr.split(op); + this.arg = exprs[0].trim(); + + // suport * as a match + initMatchArgExpr(); + + this.operator = op; + this.expectedValue = exprs[1]; + break; + } + } + this.type = Type.STREAM; + } + + public Expression(String exprStr, String func, Long range, Float sampling) { + this(exprStr); + if (range != null && range > 0) { + this.range = range * 1000; // second to ms + } + this.func = func; + if (sampling != null) { + this.sampling = sampling; + } + + } + + public Expression(Map cond) { + + this.arg = (String) cond.get("metric"); + this.unit = Integer.parseInt((String) cond.get("unit")); + this.time_from = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_from"), "yyyy-MM-dd HH:mm") + .getTime(); + this.time_to = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_to"), "yyyy-MM-dd HH:mm") + .getTime(); + + this.time_start=(String) cond.get("time_start"); + + this.time_end= (String) cond.get("time_end"); + + this.day_start=(String) cond.get("day_start"); + + this.day_end= (String) cond.get("day_end"); + + if(cond.containsKey("weekdayLimit")) { + ((JSONArray)cond.get("weekdayLimit")).toArray(this.weekdayLimit); + } + + if (cond.get("interval") != null) { + long interval = Long.parseLong((String) cond.get("interval")); + switch (unit) { + case DateTimeHelper.INTERVAL_DAY: + interval = interval * 24 * 3600 * 1000; + break; + case DateTimeHelper.INTERVAL_HOUR: + interval = interval * 3600 * 1000; + break; + case DateTimeHelper.INTERVAL_MINUTE: + interval = interval * 60000; + break; + } + this.interval = interval; + } + + this.upperLimit = (String) cond.get("upperLimit"); + this.lowerLimit = (String) cond.get("lowerLimit"); + this.func = (String) cond.get("aggr"); + this.downsample=(String) cond.get("downsample"); + this.type = Type.TIMER; + } + + private void initMatchArgExpr() { + + if (this.arg.indexOf("*") > -1) { + String[] tmps = this.arg.split("\\*"); + for (String tmp : tmps) { + matchArgExpr.add(tmp); + } + } + } + + public boolean isMatchExpr() { + + return matchArgExpr.size() > 0; + } + + public Set matchTargetArgs(Set srcArgs) { + + Set targetArgs = new HashSet(); + + for (String arg : srcArgs) { + + int matchCount = 0; + for (String matchField : this.matchArgExpr) { + + if (arg.indexOf(matchField) > -1) { + matchCount++; + } + } + + if (matchCount == this.matchArgExpr.size()) { + targetArgs.add(arg); + } + } + + return targetArgs; + } + + public String getHashCode() { + + return EncodeHelper.encodeMD5(arg + func + lowerLimit + upperLimit + time_from + time_to + interval + unit); + } + + public String getArg() { + + return arg; + } + + public String getOperator() { + + return operator; + } + + public String getExpectedValue() { + + return expectedValue; + } + + public long getRange() { + + return range; + } + + public String getFunc() { + + return func; + } + + public float getSampling() { + + return sampling; + } + + public int getIdx() { + + return idx; + } + + public Type getType() { + + return type; + } + + public long getTime_from() { + + return time_from; + } + + public long getTime_to() { + + return time_to; + } + + public long getInterval() { + + return interval; + } + + public String getUpperLimit() { + + return upperLimit; + } + + public String getLowerLimit() { + + return lowerLimit; + } + + public int getUnit() { + + return unit; + } + + public void setIdx(int idx) { + + this.idx = idx; + } + + public String getTime_end() { + + return time_end; + } + + public String getTime_start() { + + return time_start; + } + + public String getDownsample() { + + return downsample; + } + + public String getDay_start() { + + return day_start; + } + + public String getDay_end() { + + return day_end; + } + + public Boolean[] getWeekdayLimit() { + + return weekdayLimit; + } + + } + + protected class Condition { + + private int index; + private List expressions; + private String relation; + + public Condition(int index, Expression expr) { + this.index = index; + List exprs = new ArrayList<>(1); + exprs.add(expr); + this.expressions = exprs; + } + + public Condition(int index, List exprs, String relation) { + this.index = index; + this.expressions = exprs; + this.relation = relation; + } + + public int getIndex() { + + return index; + } + + public List getExpressions() { + + return expressions; + } + + public String getRelation() { + + return relation; + } + + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java index 78542f67..3615fb7c 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java @@ -57,12 +57,30 @@ public class StrategyJudgement extends AbstractComponent { readable.put("all-max", "最大"); readable.put("all-min", "最小"); readable.put("all-sum", "总和"); + readable.put("all-count", "计数"); + readable.put("all-dev", "标准差"); + readable.put("all-first", "开始"); + readable.put("all-last", "末尾"); + readable.put("all-p50", "50th百分位数"); + readable.put("all-p75", "75th百分位数"); + readable.put("all-p90", "90th百分位数"); + readable.put("all-p95", "95th百分位数"); + readable.put("all-p99", "99th百分位数"); + readable.put("all-p999", "999th百分位数"); + readable.put("avg", "平均"); readable.put("max", "最大"); readable.put("min", "最小"); readable.put("sum", "总和"); readable.put("diff", "差"); readable.put("count", "计数"); + readable.put("dev", "标准差"); + readable.put("p50", "50th百分位数"); + readable.put("p75", "75th百分位数"); + readable.put("p90", "90th百分位数"); + readable.put("p95", "95th百分位数"); + readable.put("p99", "99th百分位数"); + readable.put("p999", "999th百分位数"); } private CacheManager cm; @@ -248,10 +266,14 @@ private void judgeTimerExpression(ConditionResult cr, NotifyStrategy.Expression if (judgeResult == null) { judgeResult = new HashMap(); judgeResult.put("fire", false); + }else { + log.debug(this, "judgeTimerExpression judgeResult:" + JSONHelper.toString(judgeResult)); } + Map args = slice.getArgs(); + // if the judge is called by slice stream, just return the last result - if (slice.getKey().indexOf('@') > -1) { + if (args == null || !"timer".equals(args.get("creater"))) { if (judgeResult.get("time_to") != null) { Date date = DateTimeHelper.dateFormat(String.valueOf(judgeResult.get("time_to")), "yyyy-MM-dd HH:mm"); // if the time is not the time expr's judge time,return false @@ -275,12 +297,66 @@ && isOverdue(DateTimeHelper } else if (timeMap != null) { caculateJudgeResult(timeMap, judgeResult, slice.getKey(), expr, cr); + + if((Boolean) judgeResult.get("fire")) { + //add detail info + addDetail(timeMap,slice,expr); + } } - } + } cr.addTimerExprResult((Boolean) judgeResult.get("fire"), expr, judgeResult); } + + private void addDetail(Map timeMap, Slice slice, Expression expr) { + + + Map args=slice.getArgs(); + + String metric=expr.getArg(); + + if(args.containsKey("currentDetailValue_"+metric)) { + return; + } + + Map currentDetailValue = queryDetailValue(slice.getKey(),expr,timeMap.get("time_from"),timeMap.get("time_to")); + + Map lastDetailValue = queryDetailValue(slice.getKey(),expr,timeMap.get("last_time_from"),timeMap.get("last_time_to")); + + args.put("currentDetailValue_"+metric, currentDetailValue); + + args.put("lastDetailValue_"+metric, lastDetailValue); + } + + @SuppressWarnings("rawtypes") + private Map queryDetailValue(String instance, Expression expr, Long startTime, Long endTime) { + + Map detail = new LinkedHashMap(); + + String data = buildQueryJSON(instance,expr,startTime,endTime,true); + + List resultList = queryOpentsdb(data); + + if(resultList==null) { + return detail; + } + + for(Map result:resultList) { + + String instid=String.valueOf(((Map)result.get("tags")).get("instid")); + + for(Object value:((Map)result.get("dps")).values()) { + + detail.put(instid, String.valueOf(value)); + + break; + } + } + + return detail; + + } private void caculateJudgeResult(Map timeMap, Map judgeResult, String instance, Expression expr, ConditionResult cr) { @@ -291,19 +367,23 @@ private void caculateJudgeResult(Map timeMap, Map return; } - Double currentValue = queryOpentsdb(instance, expr.getArg(), expr.getFunc(), timeMap.get("time_from"), + Double currentValue = queryValue(instance, expr, timeMap.get("time_from"), timeMap.get("time_to")); Double lastValue = 0.0; + if ((expr.getLowerLimit().contains("#") || expr.getLowerLimit().contains("*")) + && (expr.getUpperLimit().contains("#") || expr.getUpperLimit().contains("*"))) { + // do nothing + } // if the last judgeResult is really the last judgeTime's result, use it's currentValue as lastValue. - if (judgeResult.get("time_to") != null + else if (judgeResult.get("time_to") != null && judgeResult.get("time_to") .equals(DateTimeHelper.toFormat("yyyy-MM-dd HH:mm", timeMap.get("last_time_to"))) && judgeResult.get("currentValue") != null) { lastValue = Double.parseDouble(String.valueOf(judgeResult.get("currentValue"))); } else { - lastValue = queryOpentsdb(instance, expr.getArg(), expr.getFunc(), timeMap.get("last_time_from"), + lastValue = queryValue(instance, expr, timeMap.get("last_time_from"), timeMap.get("last_time_to")); } @@ -346,68 +426,83 @@ private boolean caculate(double currentValue, double lastValue, NotifyStrategy.E boolean result = false; - String limitString = null; - double diff = currentValue - lastValue; - String prefix = (diff > 0) ? "" : "-"; - - diff = (diff > 0) ? diff : 0 - diff; + String limitString = null; - limitString = (diff >= 0) ? expr.getUpperLimit() : expr.getLowerLimit(); + String upperLimitString = expr.getUpperLimit(); + String lowerLimitString = expr.getLowerLimit(); + // 增幅or降幅 + String upperORlower = ""; + double upperLimit = 0; + double lowerLimit = 0; + // get upperLimit + if (upperLimitString.contains("#")) { + upperLimit = Double.parseDouble(upperLimitString.substring(upperLimitString.indexOf('#') + 1)); + } + else if (upperLimitString.contains("%")) { + upperLimit = Double.parseDouble(upperLimitString.substring(0, upperLimitString.indexOf('%'))); + diff = diff * 100 / lastValue; + } + else if (!upperLimitString.contains("*")) { + upperLimit = Double.parseDouble(upperLimitString); + } - double limit; - String suffix = ""; - if (limitString.endsWith("%")) { - limit = Double.parseDouble(limitString.substring(0, limitString.length() - 1)); + // get lowerLimit + if (lowerLimitString.contains("#")) { + lowerLimit = 0 - Double.parseDouble(lowerLimitString.substring(lowerLimitString.indexOf('#') + 1)); + } + else if (lowerLimitString.contains("%")) { + lowerLimit = Double.parseDouble(lowerLimitString.substring(0, lowerLimitString.indexOf('%'))); diff = diff * 100 / lastValue; - suffix = "%"; } - else { - limit = Double.parseDouble(limitString); + else if (!lowerLimitString.contains("*")) { + lowerLimit = Double.parseDouble(lowerLimitString); } - if (!"-1".equals(limitString) && diff > limit) { + if (!upperLimitString.contains("*") && diff > upperLimit) { + result = true; + upperORlower = "upper"; + limitString = upperLimitString; + } + else if (!lowerLimitString.contains("*") && diff < 0 - lowerLimit) { result = true; + upperORlower = "lower"; + limitString = lowerLimitString; } - judgeResult.put("actualValue", prefix + String.format("%.2f", diff) + suffix); + judgeResult.put("actualValue", String.format("%.2f", diff) + (limitString.contains("%") ? "%" : "")); judgeResult.put("expectedValue", limitString); - + judgeResult.put("upperORlower", upperORlower); return result; } - @SuppressWarnings({ "unchecked", "rawtypes" }) - private Double queryOpentsdb(String instance, String metric, String func, Long startTime, Long endTime) { + @SuppressWarnings({"rawtypes" }) + private Double queryValue(String instance, Expression expr, Long startTime, Long endTime) { Double result = null; - for (int i = 0; i < 3 && result == null; i++) { + for (int i = 0; i < 3; i++) { - try { - UAVHttpMessage message = new UAVHttpMessage(); + try { - String data = String.format( - "{\"start\":%d,\"end\":%d,\"queries\":[{\"aggregator\":\"avg\",\"downsample\":\"%s\",\"metric\":\"%s\",\"filters\":[{\"filter\":\"%s\",\"tagk\":\"instid\",\"type\":\"regexp\",\"groupBy\":false}]}]}", - startTime, endTime, func, metric, - instance.replace(":", "/u003a").replace("%", "/u0025").replace("#", "/u0023")); - message.putRequest("opentsdb.query.json", data); - message.putRequest("datastore.name", MonitorDataFrame.MessageType.Monitor.toString()); + String data = buildQueryJSON(instance,expr,startTime,endTime,false); - String queryResponse = String.valueOf(invoker.invoke(queryServiceName, message, String.class)); - - if (queryResponse.equals("null") || queryResponse.equals("{}") - || queryResponse.equals("{\"rs\":\"[]\"}")) { + List resultList = queryOpentsdb(data); + + if(resultList==null) { continue; } - - Map responseMap = JSONHelper.toObject(queryResponse, Map.class); - - List rsList = JSONHelper.toObjectArray((String) responseMap.get(UAVHttpMessage.RESULT), Map.class); - - for (Object value : ((Map) rsList.get(0).get("dps")).values()) { + + for (Object value : ((Map) resultList.get(0).get("dps")).values()) { + result = ((BigDecimal) value).doubleValue(); - } + + if(result!=null) { + return result; + } + } + } catch (Exception e) { log.err(this, "TimerExpression judgement query opentsdb failed ", e); @@ -416,6 +511,38 @@ private Double queryOpentsdb(String instance, String metric, String func, Long s return result; } + @SuppressWarnings({ "unchecked", "rawtypes" }) + private List queryOpentsdb(String data) { + + UAVHttpMessage message = new UAVHttpMessage(); + + message.putRequest("opentsdb.query.json", data); + message.putRequest("datastore.name", MonitorDataFrame.MessageType.Monitor.toString()); + + String queryResponse = String.valueOf(invoker.invoke(queryServiceName, message, String.class)); + + if (queryResponse.equals("null") || queryResponse.equals("{}") + || queryResponse.equals("{\"rs\":\"[]\"}")) { + return null; + } + + Map responseMap = JSONHelper.toObject(queryResponse, Map.class); + + List rsList = JSONHelper.toObjectArray((String) responseMap.get(UAVHttpMessage.RESULT), Map.class); + + return rsList; + } + + private String buildQueryJSON(String instance, Expression expr, Long startTime, Long endTime, boolean groupBy) { + + String data=String.format( + "{\"start\":%d,\"end\":%d,\"queries\":[{\"aggregator\":\"%s\",\"downsample\":\"%s\",\"metric\":\"%s\",\"filters\":[{\"filter\":\"%s\",\"tagk\":\"instid\",\"type\":\"regexp\",\"groupBy\":%b}]}]}", + startTime, endTime, expr.getFunc(), expr.getDownsample(), expr.getArg(), + instance.replace(":", "/u003a").replace("%", "/u0025").replace("#", "/u0023"),groupBy); + + return data; + } + /** * get judgeResult from redis */ @@ -441,6 +568,11 @@ private Map getJudgeResult(String instance, Expression expr) { * else return null; */ private Map getJudgeTime(Expression expr, long time) { + + + if (!inTimeScope(expr, time)) { + return null; + } Map timeMap = new HashMap(); long time_to = time; @@ -494,6 +626,48 @@ private Map getJudgeTime(Expression expr, long time) { return timeMap; } + + /** + * return true if the time is in judge time scope + */ + private boolean inTimeScope(Expression expr, long time) { + + String time_start = expr.getTime_start(); + String time_end = expr.getTime_end(); + String day_start = expr.getDay_start(); + String day_end = expr.getDay_end(); + + if (!StringHelper.isEmpty(day_start) && !StringHelper.isEmpty(day_end)) { + + long startTime = DateTimeHelper.dateFormat(day_start, "yyyy-MM-dd").getTime(); + long endTime = DateTimeHelper.dateFormat(day_end, "yyyy-MM-dd").getTime(); + + if (time < startTime || time >= endTime + 24 * 3600 * 1000) { + return false; + } + } + + if (!StringHelper.isEmpty(time_start) && !StringHelper.isEmpty(time_end)) { + + long startTime = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + time_start, "yyyy-MM-dd HH:mm").getTime(); + long endTime = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + time_end, "yyyy-MM-dd HH:mm").getTime(); + + if (time < startTime || time >= endTime) { + return false; + } + } + + int weekday = DateTimeHelper.getWeekday(new Date(time)); + + if(expr.getWeekdayLimit()!=null&&!expr.getWeekdayLimit()[weekday]) { + return false; + } + + return true; + } + private List rangeSlices(List slices, Slice cur, long range) { @@ -637,13 +811,33 @@ private String makeReadableString(Map m) { } else if (NotifyStrategy.Type.TIMER.toString().equals(m.get("type"))) { - description = ("true".equals(m.get("fire"))) ? String.format( - "%s在%s至%s时间段的%s值%s比%s至%s%s超过%s,当前值:%s。上期值:%s,本期值:%s", m.get("metric"), m.get("time_from"), - m.get("time_to"), readable.get(m.get("func")), m.get("tag"), m.get("last_time_from"), - m.get("last_time_to"), (m.get("actualValue").contains("-")) ? "降幅" : "增幅", - m.get("expectedValue"), - (m.get("actualValue").contains("-")) ? m.get("actualValue").substring(1) : m.get("actualValue"), - m.get("lastValue"), m.get("currentValue")) : "false"; + if (m.get("expectedValue").contains("#")) { + double expectedValue = Double + .parseDouble(m.get("expectedValue").substring(m.get("expectedValue").indexOf('#') + 1)); + double actualValue = Double.parseDouble(m.get("actualValue")); + description = ("true".equals(m.get("fire"))) ? String.format("%s在%s至%s时间段的%s值%s%s,当前值:%s。", + m.get("metric"), m.get("time_from"), m.get("time_to"), readable.get(m.get("downsample")), + (actualValue > expectedValue) ? ">" : "<", String.valueOf(expectedValue), + String.valueOf(actualValue)) : "false"; + } + else { + description = ("true".equals(m.get("fire"))) ? String.format( + "%s在%s至%s时间段的%s值%s比%s至%s%s%s%s,当前值:%s。上期值:%s,本期值:%s", m.get("metric"), m.get("time_from"), + m.get("time_to"), readable.get(m.get("downsample")), m.get("tag"), m.get("last_time_from"), + m.get("last_time_to"), + (m.get("upperORlower").equals("upper") && !m.get("expectedValue").contains("-")) + || (m.get("upperORlower").equals("lower") && m.get("expectedValue").contains("-")) + ? "增幅" + : "降幅", + m.get("expectedValue").contains("-") ? "低于" : "超过", + (m.get("expectedValue").contains("-")) ? m.get("expectedValue").substring(1) + : m.get("expectedValue"), + (m.get("upperORlower").equals("upper") && m.get("expectedValue").contains("-")) + || (m.get("upperORlower").equals("lower") && !m.get("expectedValue").contains("-")) + ? String.valueOf(0 - Double.parseDouble(m.get("actualValue"))) + : m.get("actualValue"), + m.get("lastValue"), m.get("currentValue")) : "false"; + } } return description; @@ -683,6 +877,7 @@ public void addTimerExprResult(boolean result, NotifyStrategy.Expression expr, M m.put("tag", expr.getInterval() == 0 ? "同" : "环"); m.put("metric", expr.getArg().substring(expr.getArg().indexOf('.') + 1)); m.put("func", expr.getFunc()); + m.put("downsample", expr.getDownsample()); m.put("type", NotifyStrategy.Type.TIMER.toString()); addExprResult(idx++, result, m); } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java index 0a642bd6..08c91657 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java @@ -1,241 +1,259 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature.runtimenotify.task; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.creditease.agent.helpers.JSONHelper; -import com.creditease.agent.helpers.NetworkHelper; -import com.creditease.agent.helpers.StringHelper; -import com.creditease.agent.monitor.api.NotificationEvent; -import com.creditease.uav.cache.api.CacheManager; -import com.creditease.uav.cache.api.CacheManager.CacheLock; -import com.creditease.uav.feature.RuntimeNotifyCatcher; -import com.creditease.uav.feature.runtimenotify.NotifyStrategy; -import com.creditease.uav.feature.runtimenotify.Slice; -import com.creditease.uav.feature.runtimenotify.StrategyJudgement; -import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; - -public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { - - private NotifyStrategy stra; - private long taskStart = System.currentTimeMillis(); - private long judge_time; - private static final String LOCK_REGION = "lock.region.uav"; - private static final long LOCK_TIMEOUT = 60 * 1000; - private CacheManager cm; - - public JudgeNotifyTimerTask(String name, String feature, long judge_time, NotifyStrategy stra) { - super(name, feature); - this.stra = stra; - this.judge_time = judge_time - judge_time % 60000; - cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); - } - - @Override - public void run() { - - CacheLock lock = null; - try { - lock = cm.newCacheLock(LOCK_REGION, stra.getName(), LOCK_TIMEOUT); - - if (!lock.getLock()) { - return; - } - /** - * Step 1:find out instance - */ - for (String instance : stra.getInstances()) { - /** - * Step 2: judge the strategy - */ - - StrategyJudgement judgement = (StrategyJudgement) getConfigManager().getComponent(feature, - "StrategyJudgement"); - Map result = judgement.judge(new Slice(instance, judge_time), stra, null); - - /** - * Step 3: if fire the event, build notification event - */ - if (result != null && !result.isEmpty()) { - NotificationEvent event = this.newNotificationEvent(instance, result, stra.getConvergences()); - - // get context - putContext(event); - - // get action - putNotifyAction(event, stra); - - // get msg tempalte - putNotifyMsg(event, stra); - - if (this.log.isTraceEnable()) { - this.log.info(this, "RuntimeNotify Notification Event Happen: event=" + event.toJSONString()); - } - - this.putNotificationEvent(event); - } - } - - } - catch (Exception e) { - log.err(this, "JudgeNotifyTimerTask" + stra.getName() + " RUN FAIL.", e); - } - finally { - if (lock != null && lock.isLockInHand()) { - lock.releaseLock(); - } - } - - if (log.isDebugEnable()) { - long cost = System.currentTimeMillis() - taskStart; - String detail = cost < 10 ? "" : " detail:strategy=" + JSONHelper.toString(stra); - log.debug(this, "whole task lifecycle COST: (" + cost + ")ms" + detail); - } - } - - /** - * get context - * - * TODO: we need support context param in strategy - */ - private void putContext(NotificationEvent event) { - - } - - /** - * newNotificationEvent - * - * - * @return - */ - private NotificationEvent newNotificationEvent(String instance, Map result, List convergences) { - - String ip = instance; - String host = instance; - String appgroup = "UNKNOWN"; - - instance = formatInstance(instance); - - Map infos = getInfoFromSliceCache(instance); - if (infos != null) { - ip = String.valueOf(infos.get("ip")); - host = String.valueOf(infos.get("host")); - appgroup = String.valueOf(infos.get("appgroup")); - } - - StringBuilder desc = new StringBuilder(); - List conditionIndex = new ArrayList(); - - for (Map.Entry cause : result.entrySet()) { - // description - desc.append(instance + "触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); - // condition index - conditionIndex.add(cause.getKey()); - } - - String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号: " + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; - - // fix  (\u00A0) can be shown in email - String description = desc.toString().replace('\u00A0', ' '); - - NotificationEvent ne = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_THRESHOLD, title, description, - judge_time, ip, host); - - // add appgroup - ne.addArg("appgroup", appgroup); - - // 兼容不存在convergences属性的旧预警策略 - if(convergences == null || convergences.size() == 0 ) { - return ne; - } - - // 同一个Event由多个策略触发时,梯度收敛以最长的为准 - String conv = obtainConvergenceForEvent(convergences, conditionIndex); - if(!StringHelper.isEmpty(conv)) { - ne.addArg("convergences", conv); - ne.addArg(NotificationEvent.EVENT_Tag_NoBlock, "true"); - } - - return ne; - } - - private String formatInstance(String instance) { - - if (NetworkHelper.isIPV4(instance)) { - instance += "_"; - } - instance = stra.getName().substring(0, stra.getName().lastIndexOf('@') + 1) + instance; - - return instance; - } - - private Map getInfoFromSliceCache(String instance) { - - String cacheKey = "SLICE_" + instance + "_"; - for (int index = 0; index < 60; index++) { - String result = cm.lpop(RuntimeNotifyStrategyMgr.UAV_CACHE_REGION, cacheKey + index); - if (result != null) { - Slice s = new Slice(result); - return s.getArgs(); - } - } - - return null; - } - - private void putNotifyAction(NotificationEvent event, NotifyStrategy stra) { - - Map actions = stra.getAction(); - if (actions == null || actions.isEmpty()) { - return; - } - - for (Entry act : actions.entrySet()) { - event.addArg("action_" + act.getKey(), act.getValue()); - } - } - - private void putNotifyMsg(NotificationEvent event, NotifyStrategy stra) { - - String msgTemplate = stra.getMsgTemplate(); - String msg = makeMsgByTemplate(msgTemplate, stra); - - if (msg != null) { - event.addArg("msg", msg); - } - } - - /** - * - * @param template - * @param slice - * @return - */ - private String makeMsgByTemplate(String template, NotifyStrategy stra) { - - return ""; - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.task; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.creditease.agent.helpers.JSONHelper; +import com.creditease.agent.helpers.NetworkHelper; +import com.creditease.agent.helpers.StringHelper; +import com.creditease.agent.monitor.api.NotificationEvent; +import com.creditease.uav.cache.api.CacheManager; +import com.creditease.uav.cache.api.CacheManager.CacheLock; +import com.creditease.uav.feature.RuntimeNotifyCatcher; +import com.creditease.uav.feature.runtimenotify.NotifyStrategy; +import com.creditease.uav.feature.runtimenotify.Slice; +import com.creditease.uav.feature.runtimenotify.StrategyJudgement; +import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; + +public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { + + private NotifyStrategy stra; + private long taskStart = System.currentTimeMillis(); + private long judge_time; + private static final String LOCK_REGION = "lock.region.uav"; + private static final long LOCK_TIMEOUT = 60 * 1000; + private CacheManager cm; + + public JudgeNotifyTimerTask(String name, String feature, long judge_time, NotifyStrategy stra) { + super(name, feature); + this.stra = stra; + this.judge_time = judge_time - judge_time % 60000; + cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); + } + + @Override + public void run() { + + CacheLock lock = null; + try { + lock = cm.newCacheLock(LOCK_REGION, stra.getName(), LOCK_TIMEOUT); + + if (!lock.getLock()) { + return; + } + /** + * Step 1:find out instance + */ + for (String instance : stra.getInstances()) { + /** + * Step 2: judge the strategy + */ + + StrategyJudgement judgement = (StrategyJudgement) getConfigManager().getComponent(feature, + "StrategyJudgement"); + + Slice slice = new Slice(instance, judge_time); + Map args = new HashMap(); + // 标识该slice由TimerTask创建,为同环比创建,非流式计算创建 + args.put("creater", "timer"); + slice.setArgs(args); + + Map result = judgement.judge(slice, stra, null); + + /** + * Step 3: if fire the event, build notification event + */ + if (result != null && !result.isEmpty()) { + NotificationEvent event = this.newNotificationEvent(instance, result, stra.getConvergences()); + + // get context + putContext(slice,event); + + // get action + putNotifyAction(event, stra); + + // get msg tempalte + putNotifyMsg(event, stra); + + if (this.log.isTraceEnable()) { + this.log.info(this, "RuntimeNotify Notification Event Happen: event=" + event.toJSONString()); + } + + this.putNotificationEvent(event); + } + } + + } + catch (Exception e) { + log.err(this, "JudgeNotifyTimerTask" + stra.getName() + " RUN FAIL.", e); + } + finally { + if (lock != null && lock.isLockInHand()) { + lock.releaseLock(); + } + } + + if (log.isDebugEnable()) { + long cost = System.currentTimeMillis() - taskStart; + String detail = cost < 10 ? "" : " detail:strategy=" + JSONHelper.toString(stra); + log.debug(this, "whole task lifecycle COST: (" + cost + ")ms" + detail); + } + } + + /** + * get context + * + * TODO: we need support context param in strategy + */ + private void putContext(Slice slice, NotificationEvent event) { + + Map args = slice.getArgs(); + + for (String key : args.keySet()) { + + Object argVal = args.get(key); + + String jsonstr = JSONHelper.toString(argVal); + + event.addArg(key, jsonstr); + } + } + + /** + * newNotificationEvent + * + * + * @return + */ + private NotificationEvent newNotificationEvent(String instance, Map result, List convergences) { + + String ip = instance; + String host = instance; + String appgroup = "UNKNOWN"; + + instance = formatInstance(instance); + + Map infos = getInfoFromSliceCache(instance); + if (infos != null) { + ip = String.valueOf(infos.get("ip")); + host = String.valueOf(infos.get("host")); + appgroup = String.valueOf(infos.get("appgroup")); + } + + StringBuilder desc = new StringBuilder(); + List conditionIndex = new ArrayList(); + + for (Map.Entry cause : result.entrySet()) { + // description + desc.append(instance + "触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); + // condition index + conditionIndex.add(cause.getKey()); + } + + String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号: " + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; + + // fix  (\u00A0) can be shown in email + String description = desc.toString().replace('\u00A0', ' '); + + NotificationEvent ne = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_THRESHOLD, title, description, + judge_time, ip, host); + + // add appgroup + ne.addArg("appgroup", appgroup); + + // 兼容不存在convergences属性的旧预警策略 + if(convergences == null || convergences.size() == 0 ) { + return ne; + } + + // 同一个Event由多个策略触发时,梯度收敛以最长的为准 + String conv = obtainConvergenceForEvent(convergences, conditionIndex); + if(!StringHelper.isEmpty(conv)) { + ne.addArg("convergences", conv); + ne.addArg(NotificationEvent.EVENT_Tag_NoBlock, "true"); + } + + return ne; + } + + private String formatInstance(String instance) { + + if (NetworkHelper.isIPV4(instance)) { + instance += "_"; + } + instance = stra.getName().substring(0, stra.getName().lastIndexOf('@') + 1) + instance; + + return instance; + } + + private Map getInfoFromSliceCache(String instance) { + + String cacheKey = "SLICE_" + instance + "_"; + for (int index = 0; index < 60; index++) { + String result = cm.lpop(RuntimeNotifyStrategyMgr.UAV_CACHE_REGION, cacheKey + index); + if (result != null) { + Slice s = new Slice(result); + return s.getArgs(); + } + } + + return null; + } + + private void putNotifyAction(NotificationEvent event, NotifyStrategy stra) { + + Map actions = stra.getAction(); + if (actions == null || actions.isEmpty()) { + return; + } + + for (Entry act : actions.entrySet()) { + event.addArg("action_" + act.getKey(), act.getValue()); + } + } + + private void putNotifyMsg(NotificationEvent event, NotifyStrategy stra) { + + String msgTemplate = stra.getMsgTemplate(); + String msg = makeMsgByTemplate(msgTemplate, stra); + + if (msg != null) { + event.addArg("msg", msg); + } + } + + /** + * + * @param template + * @param slice + * @return + */ + private String makeMsgByTemplate(String template, NotifyStrategy stra) { + + return ""; + } + +} diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java index c8b35dd5..705a8bfe 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java @@ -1,999 +1,1008 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.agent.helpers; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -public class DateTimeHelper { - - /** - * 日 - */ - public final static int INTERVAL_DAY = 1; - - /** - * 周 - */ - public final static int INTERVAL_WEEK = 2; - - /** - * 月 - */ - public final static int INTERVAL_MONTH = 3; - - /** - * 年 - */ - public final static int INTERVAL_YEAR = 4; - - /** - * 小时 - */ - public final static int INTERVAL_HOUR = 5; - - /** - * 分钟 - */ - public final static int INTERVAL_MINUTE = 6; - - /** - * 秒 - */ - public final static int INTERVAL_SECOND = 7; - - /** - * date = 1901-01-01 - */ - public final static Date tempDate = new Date(new Long("-2177481952000"));; - - private DateTimeHelper() { - } - - /** - * toStandardDateFormat yyyy-MM-dd HH:mm:ss.SSS - * - * @param timestamp - * @return - */ - public static String toStandardDateFormat(long timestamp) { - - return toFormat("yyyy-MM-dd HH:mm:ss.SSS", timestamp); - } - - /** - * toFormat - * - * @param format - * @param timestamp - * @return - */ - public static String toFormat(String format, long timestamp) { - - SimpleDateFormat sdf = new SimpleDateFormat(format); - - return sdf.format(new Date(timestamp)); - } - - /** - * get the time range index in a time span (ms) for 24 hours - * - * @param timeFlag - * @param span - * @return - */ - public static long getTimeRangeIndex(long timeFlag, long span) { - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - Calendar cl = Calendar.getInstance(); - - int year = cl.get(Calendar.YEAR); - int month = cl.get(Calendar.MONTH) + 1; - int day = cl.get(Calendar.DATE); - - long cTime = 0; - try { - Date d = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); - cTime = d.getTime(); - } - catch (ParseException e) { - // ignore - } - - long seconds = timeFlag - cTime; - - long timeRangeIndex = seconds / span; - - return timeRangeIndex; - } - - /** - * get the time range index in 1 min for 24 hours - * - * @param timeFlag - * @return - */ - public static long getTimeRangeIndexIn1Min(long timeFlag) { - - return getTimeRangeIndex(timeFlag, 60000); - } - - /** - * 测试是否是当天 - * - * @param date - * 某一日期 - * @return true 今天, false-不是 - */ - @SuppressWarnings("deprecation") - public static boolean isToday(Date date) { - - Date now = new Date(); - boolean result = true; - result &= date.getYear() == now.getYear(); - result &= date.getMonth() == now.getMonth(); - result &= date.getDate() == now.getDate(); - return result; - } - - /** - * 两个日期相减,取天数 - * - * @param date1 - * @param date2 - * @return - */ - public static long DaysBetween(Date date1, Date date2) { - - if (date2 == null) - date2 = new Date(); - long day = (date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); - return day; - } - - /** - * 比较两个日期 if date1<=date2 return true - * - * @param date1 - * @param date2 - * @return - */ - public static boolean compareDate(String date1, String date2) { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - Date d1 = format.parse(date1); - Date d2 = format.parse(date2); - return !d1.after(d2); - } - catch (ParseException e) { - e.printStackTrace(); - return false; - } - } - - /** - * 字符型转换成日期型 - * - * @param date - * @param dateFormat - * @return - */ - public static Date dateFormat(String date, String dateFormat) { - - if (date == null) - return null; - SimpleDateFormat format = new SimpleDateFormat(dateFormat); - if (date != null) { - try { - return format.parse(date); - } - catch (Exception ex) { - } - } - return null; - } - - /** - * 使用默认格式 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - */ - public static Date dateFormat(String date) { - - return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); - } - - /** - * 日期型转换成字符串 - * - * @param date - * @param dateFormat - * @return - */ - public static String dateFormat(Date date, String dateFormat) { - - if (date != null) { - SimpleDateFormat format = new SimpleDateFormat(dateFormat); - if (date != null) { - return format.format(date); - } - } - return ""; - } - - /** - * 由于生日增加保密属性,现决定1900为保密对应值,如果遇到1900的年份,则隐掉年份 - * - * @param date - * @param dateFormat - * @return 不保密显示1981-12-01保密则显示`12-01 - */ - public static String birthdayFormat(Date date) { - - if (date != null) { - SimpleDateFormat format = null; - if (date.before(tempDate)) { - format = new SimpleDateFormat("MM-dd"); - } - else { - format = new SimpleDateFormat("yyyy-MM-dd"); - } - if (date != null) { - return format.format(date); - } - } - return ""; - } - - /** - * 使用默认格式 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - */ - public static String dateFormat(Date date) { - - return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); - } - - public static boolean isExpiredDay(Date date1) { - - long day = (new Date().getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); - if (day >= 1) - return true; - else - return false; - } - - public static Date getYesterday() { - - Date date = new Date(); - long time = (date.getTime() / 1000) - 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static Date getWeekAgo() { - - Date date = new Date(); - long time = (date.getTime() / 1000) - 7 * 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static String getDaysAgo(int interval) { - - Date date = new Date(); - long time = (date.getTime() / 1000) - interval * 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - return format.format(date); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return ""; - } - - public static Date getTomorrow() { - - Date date = new Date(); - long time = (date.getTime() / 1000) + 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static Date getBeforeDate(String range) { - - Calendar today = Calendar.getInstance(); - if ("week".equalsIgnoreCase(range)) - today.add(Calendar.WEEK_OF_MONTH, -1); - else if ("month".equalsIgnoreCase(range)) - today.add(Calendar.MONTH, -1); - else - today.clear(); - return today.getTime(); - } - - public static Date getThisWeekStartTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek()); - Calendar weekFirstDay = Calendar.getInstance(); - weekFirstDay.clear(); - weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR)); - weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH)); - weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE)); - return weekFirstDay.getTime(); - } - - public static String getToday(String format) { - - String result = ""; - try { - Date today = new Date(); - SimpleDateFormat simpleFormat = new SimpleDateFormat(format); - result = simpleFormat.format(today); - } - catch (Exception e) { - } - return result; - } - - public static Date getStartDay(int year, int month) { - - Calendar today = Calendar.getInstance(); - today.clear(); - today.set(Calendar.YEAR, year); - today.set(Calendar.MONTH, month - 1); - today.set(Calendar.DAY_OF_MONTH, 1); - return today.getTime(); - } - - public static List getBeforeYearList(int before) { - - Calendar today = Calendar.getInstance(); - int theYear = today.get(Calendar.YEAR); - List list = new ArrayList(); - for (int i = before; i >= 0; i--) - list.add(theYear - i); - - return list; - } - - /** - * 增加时间 - * - * @param interval - * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] - * @param date - * @param n - * 可以为负数 - * @return - */ - public static Date dateAdd(int interval, Date date, int n) { - - long time = (date.getTime() / 1000); // 单位秒 - switch (interval) { - case INTERVAL_DAY: - time = time + n * 86400;// 60 * 60 * 24; - break; - case INTERVAL_WEEK: - time = time + n * 604800;// 60 * 60 * 24 * 7; - break; - case INTERVAL_MONTH: - time = time + n * 2678400;// 60 * 60 * 24 * 31; - break; - case INTERVAL_YEAR: - time = time + n * 31536000;// 60 * 60 * 24 * 365; - break; - case INTERVAL_HOUR: - time = time + n * 3600;// 60 * 60 ; - break; - case INTERVAL_MINUTE: - time = time + n * 60; - break; - case INTERVAL_SECOND: - time = time + n; - break; - default: - } - - Date result = new Date(); - result.setTime(time * 1000); - return result; - } - - /** - * 计算两个时间间隔 - * - * @param interval - * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] - * @param begin - * @param end - * @return - */ - public static int dateDiff(int interval, Date begin, Date end) { - - long beginTime = (begin.getTime() / 1000); // 单位:秒 - long endTime = (end.getTime() / 1000); // 单位: 秒 - long tmp = 0; - if (endTime == beginTime) { - return 0; - } - - // 确定endTime 大于 beginTime 结束时间秒数 大于 开始时间秒数 - if (endTime < beginTime) { - tmp = beginTime; - beginTime = endTime; - endTime = tmp; - } - - long intervalTime = endTime - beginTime; - long result = 0; - switch (interval) { - case INTERVAL_DAY: - result = intervalTime / 86400;// 60 * 60 * 24; - break; - case INTERVAL_WEEK: - result = intervalTime / 604800;// 60 * 60 * 24 * 7; - break; - case INTERVAL_MONTH: - result = intervalTime / 2678400;// 60 * 60 * 24 * 31; - break; - case INTERVAL_YEAR: - result = intervalTime / 31536000;// 60 * 60 * 24 * 365; - break; - case INTERVAL_HOUR: - result = intervalTime / 3600;// 60 * 60 ; - break; - case INTERVAL_MINUTE: - result = intervalTime / 60; - break; - case INTERVAL_SECOND: - result = intervalTime / 1; - break; - default: - } - - // 做过交换 - if (tmp > 0) { - result = 0 - result; - } - return (int) result; - } - - /** - * 当前年份 - * - * @return - */ - public static int getTodayYear() { - - int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy")); - return yyyy; - } - - public static Date getNow() { - - return new Date(); - } - - /** - * 把日期格式为rss格式兼容的字符串 - * - * @param date - * @return - */ - public static String dateFormatRss(Date date) { - - if (date != null) { - return dateFormat(date, "E, d MMM yyyy H:mm:ss") + " GMT"; - } - return ""; - } - - /** - * 判断当前日期是否在两个日期之间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static boolean betweenStartDateAndEndDate(Date startDate, Date endDate) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(startDate) && curDate.before(dateAdd(INTERVAL_DAY, endDate, 1))) { - bool = true; - } - return bool; - - } - - /** - * 判断当前时间是否在在两个时间之间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static boolean nowDateBetweenStartDateAndEndDate(Date startDate, Date endDate) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(startDate) && curDate.before(endDate)) { - bool = true; - } - return bool; - } - - /** - * 判断当前时间是否在date之后 - * - * @param date - * @return - */ - public static boolean nowDateAfterDate(Date date) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(date)) { - bool = true; - } - return bool; - } - - /** - * 判断二个日期相隔的天数,结束时间为null时,,取当前时间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static int getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate) { - - int betweentoday = 0; - if (startDate == null) { - return betweentoday; - } - if (endDate == null) { - Calendar calendar = Calendar.getInstance(); - String year = new Integer(calendar.get(Calendar.YEAR)).toString(); - String month = new Integer((calendar.get(Calendar.MONTH) + 1)).toString(); - String day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)).toString(); - String strtodaytime = year + "-" + month + "-" + day; - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - try { - endDate = formatter.parse(strtodaytime); - } - catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - if (endDate.after(startDate)) { - betweentoday = (int) ((endDate.getTime() - startDate.getTime()) / 86400000); - } - else { - betweentoday = (int) ((startDate.getTime() - endDate.getTime()) / 86400000); - } - return betweentoday; - } - - /** - * 取得指定长度日期时间字符串{不含格式} - * - * @param format - * 时间格式由常量决定 8: YYMMDDHH 8位 10: YYMMDDHHmm 10位 12: YYMMDDHHmmss 12位 14: YYYYMMDDHHmmss 14位 15: - * YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒) - */ - public static String getTime(int format) { - - StringBuffer cTime = new StringBuffer(10); - Calendar time = Calendar.getInstance(); - int miltime = time.get(Calendar.MILLISECOND); - int second = time.get(Calendar.SECOND); - int minute = time.get(Calendar.MINUTE); - int hour = time.get(Calendar.HOUR_OF_DAY); - int day = time.get(Calendar.DAY_OF_MONTH); - int month = time.get(Calendar.MONTH) + 1; - int year = time.get(Calendar.YEAR); - if (format != 14) { - if (year >= 2000) - year = year - 2000; - else - year = year - 1900; - } - if (format >= 2) { - if (format == 14) - cTime.append(year); - else - cTime.append(getFormatTime(year, 2)); - } - if (format >= 4) - cTime.append(getFormatTime(month, 2)); - if (format >= 6) - cTime.append(getFormatTime(day, 2)); - if (format >= 8) - cTime.append(getFormatTime(hour, 2)); - if (format >= 10) - cTime.append(getFormatTime(minute, 2)); - if (format >= 12) - cTime.append(getFormatTime(second, 2)); - if (format >= 15) - cTime.append(getFormatTime(miltime, 3)); - return cTime.toString(); - } - - /** - * 产生任意位的字符串 - * - * @param time - * 要转换格式的时间 - * @param format - * 转换的格式 - * @return String 转换的时间 - */ - private static String getFormatTime(int time, int format) { - - StringBuffer numm = new StringBuffer(); - int length = String.valueOf(time).length(); - if (format < length) - return null; - for (int i = 0; i < format - length; i++) { - numm.append("0"); - } - numm.append(time); - return numm.toString().trim(); - } - - /** - * 根据生日去用户年龄 - * - * @param birthday - * @return int - * @exception @Date - * Apr 24, 2008 - */ - public static int getUserAge(Date birthday) { - - if (birthday == null) - return 0; - Calendar cal = Calendar.getInstance(); - if (cal.before(birthday)) { - return 0; - } - int yearNow = cal.get(Calendar.YEAR); - cal.setTime(birthday);// 给时间赋值 - int yearBirth = cal.get(Calendar.YEAR); - return yearNow - yearBirth; - } - - /** - * 将int型时间(1970年至今的秒数)转换成Date型时间 - * - * @param unixTime - * 1970年至今的秒数 - * @return - */ - public static Date getDateByUnixTime(int unixTime) { - - return new Date(unixTime * 1000L); - } - - public static long getUnixTimeLong() { - - return getUnixTimeByDate(new Date()); - } - - public static int getCurrentUnixTime() { - - return getUnixTimeByDate(new Date()); - } - - /** - * 将Date型时间转换成int型时间(1970年至今的秒数) - * - * @param unixTime - * 1970年至今的秒数 - * @return - */ - public static int getUnixTimeByDate(Date date) { - - return (int) (date.getTime() / 1000); - } - - public static long getUnixTimeLong(Date date) { - - return (date.getTime() / 1000); - } - - public static Date getNextDay(Date date) { - - long time = (date.getTime() / 1000) + 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - - } - - /** - * @param date - * @return 复制新Date,不改变参数 - */ - public static Date nextDay(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) + 60 * 60 * 24; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - - } - - public static Date getNowTime() { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date(); - String dateStr = dateFormat(date); - try { - date = format.parse(dateStr); - } - catch (ParseException e) { - e.printStackTrace(); - } - return date; - } - - public static Date getTomorrow(Date date1) { - - // 创建当前时间对象 - Calendar now = Calendar.getInstance(); - now.setTime(date1); - // 日期[+1]day - now.add(Calendar.DATE, 1); - return now.getTime(); - } - - public static Date getWeekAgo(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) - 60 * 60 * 24 * 7; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - } - - /** - * @param date - * @return 复制新Date,不改变参数 - */ - public static Date yesterday(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) - 60 * 60 * 24; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - } - - public static Date getYesterday(Date date) { - - long time = (date.getTime() / 1000) - 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static String getStringNowTime() { - - Date date = new Date(); - String dateStr = dateFormat(date); - return dateStr; - } - - /** - * 指定时间的秒数 指定时间零点的秒数加指定天数的秒数 - * - * @param time - * 时间 - * @param range - * 天 - * @return - */ - public static long getSpecifyTimeSec(long time, int range) { - - Date date = new Date((time * 1000 + (23 - Calendar.ZONE_OFFSET) * 3600000) / 86400000 * 86400000 - - (23 - Calendar.ZONE_OFFSET) * 3600000); - long zeroTime = date.getTime() / 1000; - long specifyTime = range * 24 * 3600; - return (zeroTime + specifyTime); - } - - /** - * 将int型时间(1970年至今的秒数)转换成指定格式的时间 - * - * @param unixTime - * 1970年至今的秒数 - * @param dateFormat - * 时间格式 - * @return - */ - public static String formatDateByUnixTime(long unixTime, String dateFormat) { - - return dateFormat(new Date(unixTime * 1000), dateFormat); - } - - private static List dateFormats = new ArrayList(12) { - - private static final long serialVersionUID = 2249396579858199535L; - { - add(new SimpleDateFormat("yyyy-MM-dd")); - add(new SimpleDateFormat("yyyy/MM/dd")); - add(new SimpleDateFormat("yyyy.MM.dd")); - add(new SimpleDateFormat("yyyy-MM-dd HH:24:mm:ss")); - add(new SimpleDateFormat("yyyy/MM/dd HH:24:mm:ss")); - add(new SimpleDateFormat("yyyy.MM.dd HH:24:mm:ss")); - add(new SimpleDateFormat("M/dd/yyyy")); - add(new SimpleDateFormat("dd.M.yyyy")); - add(new SimpleDateFormat("M/dd/yyyy hh:mm:ss a")); - add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a")); - add(new SimpleDateFormat("dd.MMM.yyyy")); - add(new SimpleDateFormat("dd-MMM-yyyy")); - } - }; - - public static Date convertToDate(String input) { - - Date date = null; - if (null == input) { - return null; - } - for (SimpleDateFormat format : dateFormats) { - try { - format.setLenient(false); - date = format.parse(input); - } - catch (ParseException e) { - // Shhh.. try other formats - } - if (date != null) { - break; - } - } - return date; - } - - public static Long getTodayTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.HOUR_OF_DAY, 0); - today.set(Calendar.MINUTE, 0); - today.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); - } - - public static Long getYesterdayTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.HOUR_OF_DAY, -24); - today.set(Calendar.MINUTE, 0); - today.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); - } - - public static Long getTomorrowTime() { - - Calendar tomorrow = Calendar.getInstance(); - tomorrow.set(Calendar.HOUR_OF_DAY, 24); - tomorrow.set(Calendar.MINUTE, 0); - tomorrow.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(tomorrow.getTimeInMillis()).substring(0, 10)); - } - - public static Date getMonthAgo(Date date) { - - Calendar now = Calendar.getInstance(); - now.setTime(date); - - now.add(Calendar.MONTH, -1); - - return now.getTime(); - } - - public static Date getYearAgo(Date date) { - - Calendar now = Calendar.getInstance(); - now.setTime(date); - - now.add(Calendar.YEAR, -1); - - return now.getTime(); - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.agent.helpers; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +public class DateTimeHelper { + + /** + * 日 + */ + public final static int INTERVAL_DAY = 1; + + /** + * 周 + */ + public final static int INTERVAL_WEEK = 2; + + /** + * 月 + */ + public final static int INTERVAL_MONTH = 3; + + /** + * 年 + */ + public final static int INTERVAL_YEAR = 4; + + /** + * 小时 + */ + public final static int INTERVAL_HOUR = 5; + + /** + * 分钟 + */ + public final static int INTERVAL_MINUTE = 6; + + /** + * 秒 + */ + public final static int INTERVAL_SECOND = 7; + + /** + * date = 1901-01-01 + */ + public final static Date tempDate = new Date(new Long("-2177481952000"));; + + private DateTimeHelper() { + } + + /** + * toStandardDateFormat yyyy-MM-dd HH:mm:ss.SSS + * + * @param timestamp + * @return + */ + public static String toStandardDateFormat(long timestamp) { + + return toFormat("yyyy-MM-dd HH:mm:ss.SSS", timestamp); + } + + /** + * toFormat + * + * @param format + * @param timestamp + * @return + */ + public static String toFormat(String format, long timestamp) { + + SimpleDateFormat sdf = new SimpleDateFormat(format); + + return sdf.format(new Date(timestamp)); + } + + /** + * get the time range index in a time span (ms) for 24 hours + * + * @param timeFlag + * @param span + * @return + */ + public static long getTimeRangeIndex(long timeFlag, long span) { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Calendar cl = Calendar.getInstance(); + + int year = cl.get(Calendar.YEAR); + int month = cl.get(Calendar.MONTH) + 1; + int day = cl.get(Calendar.DATE); + + long cTime = 0; + try { + Date d = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); + cTime = d.getTime(); + } + catch (ParseException e) { + // ignore + } + + long seconds = timeFlag - cTime; + + long timeRangeIndex = seconds / span; + + return timeRangeIndex; + } + + /** + * get the time range index in 1 min for 24 hours + * + * @param timeFlag + * @return + */ + public static long getTimeRangeIndexIn1Min(long timeFlag) { + + return getTimeRangeIndex(timeFlag, 60000); + } + + /** + * 测试是否是当天 + * + * @param date + * 某一日期 + * @return true 今天, false-不是 + */ + @SuppressWarnings("deprecation") + public static boolean isToday(Date date) { + + Date now = new Date(); + boolean result = true; + result &= date.getYear() == now.getYear(); + result &= date.getMonth() == now.getMonth(); + result &= date.getDate() == now.getDate(); + return result; + } + + /** + * 两个日期相减,取天数 + * + * @param date1 + * @param date2 + * @return + */ + public static long DaysBetween(Date date1, Date date2) { + + if (date2 == null) + date2 = new Date(); + long day = (date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); + return day; + } + + /** + * 比较两个日期 if date1<=date2 return true + * + * @param date1 + * @param date2 + * @return + */ + public static boolean compareDate(String date1, String date2) { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date d1 = format.parse(date1); + Date d2 = format.parse(date2); + return !d1.after(d2); + } + catch (ParseException e) { + e.printStackTrace(); + return false; + } + } + + /** + * 字符型转换成日期型 + * + * @param date + * @param dateFormat + * @return + */ + public static Date dateFormat(String date, String dateFormat) { + + if (date == null) + return null; + SimpleDateFormat format = new SimpleDateFormat(dateFormat); + if (date != null) { + try { + return format.parse(date); + } + catch (Exception ex) { + } + } + return null; + } + + /** + * 使用默认格式 yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static Date dateFormat(String date) { + + return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 日期型转换成字符串 + * + * @param date + * @param dateFormat + * @return + */ + public static String dateFormat(Date date, String dateFormat) { + + if (date != null) { + SimpleDateFormat format = new SimpleDateFormat(dateFormat); + if (date != null) { + return format.format(date); + } + } + return ""; + } + + /** + * 由于生日增加保密属性,现决定1900为保密对应值,如果遇到1900的年份,则隐掉年份 + * + * @param date + * @param dateFormat + * @return 不保密显示1981-12-01保密则显示`12-01 + */ + public static String birthdayFormat(Date date) { + + if (date != null) { + SimpleDateFormat format = null; + if (date.before(tempDate)) { + format = new SimpleDateFormat("MM-dd"); + } + else { + format = new SimpleDateFormat("yyyy-MM-dd"); + } + if (date != null) { + return format.format(date); + } + } + return ""; + } + + /** + * 使用默认格式 yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static String dateFormat(Date date) { + + return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); + } + + public static boolean isExpiredDay(Date date1) { + + long day = (new Date().getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); + if (day >= 1) + return true; + else + return false; + } + + public static Date getYesterday() { + + Date date = new Date(); + long time = (date.getTime() / 1000) - 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static Date getWeekAgo() { + + Date date = new Date(); + long time = (date.getTime() / 1000) - 7 * 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static String getDaysAgo(int interval) { + + Date date = new Date(); + long time = (date.getTime() / 1000) - interval * 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + return format.format(date); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return ""; + } + + public static Date getTomorrow() { + + Date date = new Date(); + long time = (date.getTime() / 1000) + 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static Date getBeforeDate(String range) { + + Calendar today = Calendar.getInstance(); + if ("week".equalsIgnoreCase(range)) + today.add(Calendar.WEEK_OF_MONTH, -1); + else if ("month".equalsIgnoreCase(range)) + today.add(Calendar.MONTH, -1); + else + today.clear(); + return today.getTime(); + } + + public static Date getThisWeekStartTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek()); + Calendar weekFirstDay = Calendar.getInstance(); + weekFirstDay.clear(); + weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR)); + weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH)); + weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE)); + return weekFirstDay.getTime(); + } + + public static String getToday(String format) { + + String result = ""; + try { + Date today = new Date(); + SimpleDateFormat simpleFormat = new SimpleDateFormat(format); + result = simpleFormat.format(today); + } + catch (Exception e) { + } + return result; + } + + public static Date getStartDay(int year, int month) { + + Calendar today = Calendar.getInstance(); + today.clear(); + today.set(Calendar.YEAR, year); + today.set(Calendar.MONTH, month - 1); + today.set(Calendar.DAY_OF_MONTH, 1); + return today.getTime(); + } + + public static List getBeforeYearList(int before) { + + Calendar today = Calendar.getInstance(); + int theYear = today.get(Calendar.YEAR); + List list = new ArrayList(); + for (int i = before; i >= 0; i--) + list.add(theYear - i); + + return list; + } + + /** + * 增加时间 + * + * @param interval + * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] + * @param date + * @param n + * 可以为负数 + * @return + */ + public static Date dateAdd(int interval, Date date, int n) { + + long time = (date.getTime() / 1000); // 单位秒 + switch (interval) { + case INTERVAL_DAY: + time = time + n * 86400;// 60 * 60 * 24; + break; + case INTERVAL_WEEK: + time = time + n * 604800;// 60 * 60 * 24 * 7; + break; + case INTERVAL_MONTH: + time = time + n * 2678400;// 60 * 60 * 24 * 31; + break; + case INTERVAL_YEAR: + time = time + n * 31536000;// 60 * 60 * 24 * 365; + break; + case INTERVAL_HOUR: + time = time + n * 3600;// 60 * 60 ; + break; + case INTERVAL_MINUTE: + time = time + n * 60; + break; + case INTERVAL_SECOND: + time = time + n; + break; + default: + } + + Date result = new Date(); + result.setTime(time * 1000); + return result; + } + + /** + * 计算两个时间间隔 + * + * @param interval + * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] + * @param begin + * @param end + * @return + */ + public static int dateDiff(int interval, Date begin, Date end) { + + long beginTime = (begin.getTime() / 1000); // 单位:秒 + long endTime = (end.getTime() / 1000); // 单位: 秒 + long tmp = 0; + if (endTime == beginTime) { + return 0; + } + + // 确定endTime 大于 beginTime 结束时间秒数 大于 开始时间秒数 + if (endTime < beginTime) { + tmp = beginTime; + beginTime = endTime; + endTime = tmp; + } + + long intervalTime = endTime - beginTime; + long result = 0; + switch (interval) { + case INTERVAL_DAY: + result = intervalTime / 86400;// 60 * 60 * 24; + break; + case INTERVAL_WEEK: + result = intervalTime / 604800;// 60 * 60 * 24 * 7; + break; + case INTERVAL_MONTH: + result = intervalTime / 2678400;// 60 * 60 * 24 * 31; + break; + case INTERVAL_YEAR: + result = intervalTime / 31536000;// 60 * 60 * 24 * 365; + break; + case INTERVAL_HOUR: + result = intervalTime / 3600;// 60 * 60 ; + break; + case INTERVAL_MINUTE: + result = intervalTime / 60; + break; + case INTERVAL_SECOND: + result = intervalTime / 1; + break; + default: + } + + // 做过交换 + if (tmp > 0) { + result = 0 - result; + } + return (int) result; + } + + /** + * 当前年份 + * + * @return + */ + public static int getTodayYear() { + + int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy")); + return yyyy; + } + + public static Date getNow() { + + return new Date(); + } + + /** + * 把日期格式为rss格式兼容的字符串 + * + * @param date + * @return + */ + public static String dateFormatRss(Date date) { + + if (date != null) { + return dateFormat(date, "E, d MMM yyyy H:mm:ss") + " GMT"; + } + return ""; + } + + /** + * 判断当前日期是否在两个日期之间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static boolean betweenStartDateAndEndDate(Date startDate, Date endDate) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(startDate) && curDate.before(dateAdd(INTERVAL_DAY, endDate, 1))) { + bool = true; + } + return bool; + + } + + /** + * 判断当前时间是否在在两个时间之间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static boolean nowDateBetweenStartDateAndEndDate(Date startDate, Date endDate) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(startDate) && curDate.before(endDate)) { + bool = true; + } + return bool; + } + + /** + * 判断当前时间是否在date之后 + * + * @param date + * @return + */ + public static boolean nowDateAfterDate(Date date) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(date)) { + bool = true; + } + return bool; + } + + /** + * 判断二个日期相隔的天数,结束时间为null时,,取当前时间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static int getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate) { + + int betweentoday = 0; + if (startDate == null) { + return betweentoday; + } + if (endDate == null) { + Calendar calendar = Calendar.getInstance(); + String year = new Integer(calendar.get(Calendar.YEAR)).toString(); + String month = new Integer((calendar.get(Calendar.MONTH) + 1)).toString(); + String day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)).toString(); + String strtodaytime = year + "-" + month + "-" + day; + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + try { + endDate = formatter.parse(strtodaytime); + } + catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + if (endDate.after(startDate)) { + betweentoday = (int) ((endDate.getTime() - startDate.getTime()) / 86400000); + } + else { + betweentoday = (int) ((startDate.getTime() - endDate.getTime()) / 86400000); + } + return betweentoday; + } + + /** + * 取得指定长度日期时间字符串{不含格式} + * + * @param format + * 时间格式由常量决定 8: YYMMDDHH 8位 10: YYMMDDHHmm 10位 12: YYMMDDHHmmss 12位 14: YYYYMMDDHHmmss 14位 15: + * YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒) + */ + public static String getTime(int format) { + + StringBuffer cTime = new StringBuffer(10); + Calendar time = Calendar.getInstance(); + int miltime = time.get(Calendar.MILLISECOND); + int second = time.get(Calendar.SECOND); + int minute = time.get(Calendar.MINUTE); + int hour = time.get(Calendar.HOUR_OF_DAY); + int day = time.get(Calendar.DAY_OF_MONTH); + int month = time.get(Calendar.MONTH) + 1; + int year = time.get(Calendar.YEAR); + if (format != 14) { + if (year >= 2000) + year = year - 2000; + else + year = year - 1900; + } + if (format >= 2) { + if (format == 14) + cTime.append(year); + else + cTime.append(getFormatTime(year, 2)); + } + if (format >= 4) + cTime.append(getFormatTime(month, 2)); + if (format >= 6) + cTime.append(getFormatTime(day, 2)); + if (format >= 8) + cTime.append(getFormatTime(hour, 2)); + if (format >= 10) + cTime.append(getFormatTime(minute, 2)); + if (format >= 12) + cTime.append(getFormatTime(second, 2)); + if (format >= 15) + cTime.append(getFormatTime(miltime, 3)); + return cTime.toString(); + } + + /** + * 产生任意位的字符串 + * + * @param time + * 要转换格式的时间 + * @param format + * 转换的格式 + * @return String 转换的时间 + */ + private static String getFormatTime(int time, int format) { + + StringBuffer numm = new StringBuffer(); + int length = String.valueOf(time).length(); + if (format < length) + return null; + for (int i = 0; i < format - length; i++) { + numm.append("0"); + } + numm.append(time); + return numm.toString().trim(); + } + + /** + * 根据生日去用户年龄 + * + * @param birthday + * @return int + * @exception @Date + * Apr 24, 2008 + */ + public static int getUserAge(Date birthday) { + + if (birthday == null) + return 0; + Calendar cal = Calendar.getInstance(); + if (cal.before(birthday)) { + return 0; + } + int yearNow = cal.get(Calendar.YEAR); + cal.setTime(birthday);// 给时间赋值 + int yearBirth = cal.get(Calendar.YEAR); + return yearNow - yearBirth; + } + + /** + * 将int型时间(1970年至今的秒数)转换成Date型时间 + * + * @param unixTime + * 1970年至今的秒数 + * @return + */ + public static Date getDateByUnixTime(int unixTime) { + + return new Date(unixTime * 1000L); + } + + public static long getUnixTimeLong() { + + return getUnixTimeByDate(new Date()); + } + + public static int getCurrentUnixTime() { + + return getUnixTimeByDate(new Date()); + } + + /** + * 将Date型时间转换成int型时间(1970年至今的秒数) + * + * @param unixTime + * 1970年至今的秒数 + * @return + */ + public static int getUnixTimeByDate(Date date) { + + return (int) (date.getTime() / 1000); + } + + public static long getUnixTimeLong(Date date) { + + return (date.getTime() / 1000); + } + + public static Date getNextDay(Date date) { + + long time = (date.getTime() / 1000) + 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + + } + + /** + * @param date + * @return 复制新Date,不改变参数 + */ + public static Date nextDay(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) + 60 * 60 * 24; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + + } + + public static Date getNowTime() { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(); + String dateStr = dateFormat(date); + try { + date = format.parse(dateStr); + } + catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + + public static Date getTomorrow(Date date1) { + + // 创建当前时间对象 + Calendar now = Calendar.getInstance(); + now.setTime(date1); + // 日期[+1]day + now.add(Calendar.DATE, 1); + return now.getTime(); + } + + public static Date getWeekAgo(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) - 60 * 60 * 24 * 7; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + } + + /** + * @param date + * @return 复制新Date,不改变参数 + */ + public static Date yesterday(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) - 60 * 60 * 24; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + } + + public static Date getYesterday(Date date) { + + long time = (date.getTime() / 1000) - 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static String getStringNowTime() { + + Date date = new Date(); + String dateStr = dateFormat(date); + return dateStr; + } + + /** + * 指定时间的秒数 指定时间零点的秒数加指定天数的秒数 + * + * @param time + * 时间 + * @param range + * 天 + * @return + */ + public static long getSpecifyTimeSec(long time, int range) { + + Date date = new Date((time * 1000 + (23 - Calendar.ZONE_OFFSET) * 3600000) / 86400000 * 86400000 + - (23 - Calendar.ZONE_OFFSET) * 3600000); + long zeroTime = date.getTime() / 1000; + long specifyTime = range * 24 * 3600; + return (zeroTime + specifyTime); + } + + /** + * 将int型时间(1970年至今的秒数)转换成指定格式的时间 + * + * @param unixTime + * 1970年至今的秒数 + * @param dateFormat + * 时间格式 + * @return + */ + public static String formatDateByUnixTime(long unixTime, String dateFormat) { + + return dateFormat(new Date(unixTime * 1000), dateFormat); + } + + private static List dateFormats = new ArrayList(12) { + + private static final long serialVersionUID = 2249396579858199535L; + { + add(new SimpleDateFormat("yyyy-MM-dd")); + add(new SimpleDateFormat("yyyy/MM/dd")); + add(new SimpleDateFormat("yyyy.MM.dd")); + add(new SimpleDateFormat("yyyy-MM-dd HH:24:mm:ss")); + add(new SimpleDateFormat("yyyy/MM/dd HH:24:mm:ss")); + add(new SimpleDateFormat("yyyy.MM.dd HH:24:mm:ss")); + add(new SimpleDateFormat("M/dd/yyyy")); + add(new SimpleDateFormat("dd.M.yyyy")); + add(new SimpleDateFormat("M/dd/yyyy hh:mm:ss a")); + add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a")); + add(new SimpleDateFormat("dd.MMM.yyyy")); + add(new SimpleDateFormat("dd-MMM-yyyy")); + } + }; + + public static Date convertToDate(String input) { + + Date date = null; + if (null == input) { + return null; + } + for (SimpleDateFormat format : dateFormats) { + try { + format.setLenient(false); + date = format.parse(input); + } + catch (ParseException e) { + // Shhh.. try other formats + } + if (date != null) { + break; + } + } + return date; + } + + public static Long getTodayTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.HOUR_OF_DAY, 0); + today.set(Calendar.MINUTE, 0); + today.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); + } + + public static Long getYesterdayTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.HOUR_OF_DAY, -24); + today.set(Calendar.MINUTE, 0); + today.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); + } + + public static Long getTomorrowTime() { + + Calendar tomorrow = Calendar.getInstance(); + tomorrow.set(Calendar.HOUR_OF_DAY, 24); + tomorrow.set(Calendar.MINUTE, 0); + tomorrow.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(tomorrow.getTimeInMillis()).substring(0, 10)); + } + + public static Date getMonthAgo(Date date) { + + Calendar now = Calendar.getInstance(); + now.setTime(date); + + now.add(Calendar.MONTH, -1); + + return now.getTime(); + } + + public static Date getYearAgo(Date date) { + + Calendar now = Calendar.getInstance(); + now.setTime(date); + + now.add(Calendar.YEAR, -1); + + return now.getTime(); + } + + public static int getWeekday(Date date) { + + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + + return cal.get(Calendar.DAY_OF_WEEK) - 1; + } +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java index 6802f694..b14e429f 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java @@ -1,365 +1,365 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.hook.rabbitmq.interceptors; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.captureframework.spi.Monitor; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; -import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; -import com.creditease.uav.common.BaseComponent; -import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqConsumerAdapter; -import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqProducerAdapter; -import com.creditease.uav.util.JDKProxyInvokeUtil; -import com.rabbitmq.client.AMQP; -import com.rabbitmq.client.AMQP.BasicProperties; -import com.rabbitmq.client.Channel; -import com.rabbitmq.client.Connection; -import com.rabbitmq.client.Consumer; - -public class RabbitmqIT extends BaseComponent { - - private String applicationId; - static final Map queueNameIndex = new HashMap(); - static { - queueNameIndex.put("basicPublish", 1); - queueNameIndex.put("queueDeclare", 0); - queueNameIndex.put("queueDeclareNoWait", 0); - queueNameIndex.put("queueDeclarePassive", 0); - queueNameIndex.put("queueDelete", 0); - queueNameIndex.put("queueDeleteNoWait", 0); - queueNameIndex.put("queueBind", 0); - queueNameIndex.put("queueBindNoWait", 0); - queueNameIndex.put("queueUnbind", 0); - queueNameIndex.put("queuePurge", 0); - queueNameIndex.put("basicGet", 0); - queueNameIndex.put("basicConsume", 0); - } - - public RabbitmqIT(String appid) { - this.applicationId = appid; - } - - public Connection doInstall(Connection arg) { - - arg = JDKProxyInvokeUtil.newProxyInstance(Connection.class.getClassLoader(), - new Class[] { Connection.class }, - new JDKProxyInvokeHandler(arg, new ConnectionProxyProcessor())); - - return arg; - } - - /** - * - * ConnectionProxyProcessor description: ConnectionProxyProcessor - * - */ - public class ConnectionProxyProcessor extends JDKProxyInvokeProcessor { - - @Override - public void preProcess(Connection t, Object proxy, Method method, Object[] args) { - - } - - @Override - public Object postProcess(Object res, Connection t, Object proxy, Method method, Object[] args) { - - if (method.getName().equals("createChannel")) { - return JDKProxyInvokeUtil.newProxyInstance(Channel.class.getClassLoader(), - new Class[] { Channel.class }, - new JDKProxyInvokeHandler((Channel) res, new ChannelProxyProcessor())); - } - return null; - } - - } - - /** - * - * ChannelProxyProcessor description: ChannelProxyProcessor - * - */ - public class ChannelProxyProcessor extends JDKProxyInvokeProcessor { - - String address; - String targetServer; - private Map ivcContextParams = new HashMap(); - - @SuppressWarnings("unchecked") - @Override - public void preProcess(Channel t, Object proxy, Method method, Object[] args) { - - if (method.getExceptionTypes().length > 0 - && method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { - String methodName = method.getName(); - String queueName = null; - if (queueNameIndex.containsKey(methodName) && args.length != 0) { - - queueName = (String) args[queueNameIndex.get(methodName)]; - if (isTempQueue(queueName)) { - return; - } - - } - - if (null == address) { - address = t.getConnection().getAddress().getHostAddress() + ":" + t.getConnection().getPort(); - address = "mq:rabbit://" + address; - } - String url = address + ((null == queueName) ? "" : "/" + queueName); - - if ("basicConsume".equals(method.getName())) { - // delegate the consumer - args[args.length - 1] = JDKProxyInvokeUtil.newProxyInstance(Consumer.class.getClassLoader(), - new Class[] { Consumer.class }, new JDKProxyInvokeHandler( - (Consumer) args[args.length - 1], new ConsumerProxyProcessor(t, url))); - - } - - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=" + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - - // 调用链只关心真正的消息通讯 - if (method.getName().equals("basicPublish")) { - - // register adapter - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", - "registerAdapter", RabbitmqProducerAdapter.class); - - ivcContextParams = (Map) UAVServer.instance().runSupporter( - "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, - RabbitmqProducerAdapter.class, - new Object[] { (BasicProperties) args[args.length - 2], args[args.length - 1] }); - if (ivcContextParams != null - && ivcContextParams.containsKey(InvokeChainConstants.PARAM_MQHEAD_INFO)) { - args[2] = ivcContextParams.get(InvokeChainConstants.PARAM_MQHEAD_INFO); - } - } - } - } - - @Override - public Object postProcess(Object res, Channel t, Object proxy, Method method, Object[] args) { - - if (needDoCap(method, args)) { - doCap(1, t, method, null); - } - - return null; - } - - @Override - public void catchInvokeException(Channel t, Object proxy, Method method, Object[] args, Throwable e) { - - if (needDoCap(method, args)) { - doCap(-1, t, method, e); - } - - } - - private boolean needDoCap(Method method, Object[] args) { - - if (method.getExceptionTypes().length == 0 - || !method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { - return false; - } - String methodName = method.getName(); - if (queueNameIndex.containsKey(methodName) && args.length != 0) { - - if (isTempQueue((String) args[queueNameIndex.get(methodName)])) { - return false; - } - } - return true; - } - - private void doCap(int rc, Channel t, Method method, Throwable e) { - - if (null == targetServer) { - Map conn = t.getConnection().getServerProperties(); - String cluster_name = (null == conn.get("cluster_name")) ? "unknown" - : conn.get("cluster_name").toString(); - String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); - targetServer = cluster_name + "@" + version; - } - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params); - - // 调用链只关心真正的消息通讯 - if (method.getName().equals("basicPublish")) { - - if (rc == -1) { - ivcContextParams.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); - } - if (ivcContextParams != null) { - ivcContextParams.putAll(params); - } - - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, - ivcContextParams, RabbitmqProducerAdapter.class, null); - } - - } - - public boolean isTempQueue(String queueName) { - - String regEx = "^([0-9]|[a-f]){8}(-([0-9]|[a-f]){4}){3}-([0-9]|[a-f]){12}$"; - Matcher matcher = Pattern.compile(regEx).matcher(queueName); - return matcher.matches(); - - } - } - - public class ConsumerProxyProcessor extends JDKProxyInvokeProcessor { - - private Channel channel; - private String url; - private String targetServer; - - public ConsumerProxyProcessor(Channel channel, String url) { - this.channel = channel; - this.url = url; - } - - @Override - public void preProcess(Consumer t, Object proxy, Method method, Object[] args) { - - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - // 调用链只关心真正消费消息 - if (method.getName().equals("handleDelivery")) { - - AMQP.BasicProperties props = (BasicProperties) args[2]; - if (props.getHeaders() != null - && props.getHeaders().containsKey(InvokeChainConstants.PARAM_MQHEAD_SPANINFO)) { - params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, - props.getHeaders().get(InvokeChainConstants.PARAM_MQHEAD_SPANINFO) + ""); - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); - } - - // register adapter - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", - "registerAdapter", RabbitmqConsumerAdapter.class); - - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.PRECAP, params, - RabbitmqConsumerAdapter.class, args); - } - - } - - @Override - public void catchInvokeException(Consumer t, Object proxy, Method method, Object[] args, Throwable e) { - - doCap(-1, channel, t, method, e); - - } - - @Override - public Object postProcess(Object res, Consumer operation, Object proxy, Method method, Object[] args) { - - doCap(1, channel, operation, method, null); - return null; - } - - private void doCap(int rc, Channel channel, Consumer consumer, Method method, Throwable e) { - - if (null == targetServer) { - Map conn = channel.getConnection().getServerProperties(); - String cluster_name = (null == conn.get("cluster_name")) ? "unknown" - : conn.get("cluster_name").toString(); - String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); - targetServer = cluster_name + "@" + version; - } - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params); - - if (method.getName().equals("handleDelivery")) { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(InvokeChainConstants.CLIENT_IT_CLASS, consumer.getClass().getName()); - // 调用链只关心一个方法 - params.put(InvokeChainConstants.CLIENT_IT_METHOD, "handleDelivery"); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - if (rc == -1) { - params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); - } - - // invoke chain - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.DOCAP, params, - RabbitmqConsumerAdapter.class, null); - } - } - - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.rabbitmq.interceptors; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqConsumerAdapter; +import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqProducerAdapter; +import com.creditease.uav.util.JDKProxyInvokeUtil; +import com.rabbitmq.client.AMQP; +import com.rabbitmq.client.AMQP.BasicProperties; +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; +import com.rabbitmq.client.Consumer; + +public class RabbitmqIT extends BaseComponent { + + private String applicationId; + static final Map queueNameIndex = new HashMap(); + static { + queueNameIndex.put("basicPublish", 1); + queueNameIndex.put("queueDeclare", 0); + queueNameIndex.put("queueDeclareNoWait", 0); + queueNameIndex.put("queueDeclarePassive", 0); + queueNameIndex.put("queueDelete", 0); + queueNameIndex.put("queueDeleteNoWait", 0); + queueNameIndex.put("queueBind", 0); + queueNameIndex.put("queueBindNoWait", 0); + queueNameIndex.put("queueUnbind", 0); + queueNameIndex.put("queuePurge", 0); + queueNameIndex.put("basicGet", 0); + queueNameIndex.put("basicConsume", 0); + } + + public RabbitmqIT(String appid) { + this.applicationId = appid; + } + + public Connection doInstall(Connection arg) { + + arg = JDKProxyInvokeUtil.newProxyInstance(Connection.class.getClassLoader(), + new Class[] { Connection.class }, + new JDKProxyInvokeHandler(arg, new ConnectionProxyProcessor())); + + return arg; + } + + /** + * + * ConnectionProxyProcessor description: ConnectionProxyProcessor + * + */ + public class ConnectionProxyProcessor extends JDKProxyInvokeProcessor { + + @Override + public void preProcess(Connection t, Object proxy, Method method, Object[] args) { + + } + + @Override + public Object postProcess(Object res, Connection t, Object proxy, Method method, Object[] args) { + + if (method.getName().equals("createChannel")) { + return JDKProxyInvokeUtil.newProxyInstance(Channel.class.getClassLoader(), + new Class[] { Channel.class }, + new JDKProxyInvokeHandler((Channel) res, new ChannelProxyProcessor())); + } + return null; + } + + } + + /** + * + * ChannelProxyProcessor description: ChannelProxyProcessor + * + */ + public class ChannelProxyProcessor extends JDKProxyInvokeProcessor { + + String address; + String targetServer; + private Map ivcContextParams = new HashMap(); + + @SuppressWarnings("unchecked") + @Override + public void preProcess(Channel t, Object proxy, Method method, Object[] args) { + + if (method.getExceptionTypes().length > 0 + && method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { + String methodName = method.getName(); + String queueName = null; + if (queueNameIndex.containsKey(methodName) && args.length != 0) { + + queueName = (String) args[queueNameIndex.get(methodName)]; + if (isTempQueue(queueName)) { + return; + } + + } + + if (null == address) { + address = t.getConnection().getAddress().getHostAddress() + ":" + t.getConnection().getPort(); + address = "mq:rabbit://" + address; + } + String url = address + ((null == queueName) ? "" : "/" + queueName); + + if ("basicConsume".equals(method.getName())) { + // delegate the consumer + args[args.length - 1] = JDKProxyInvokeUtil.newProxyInstance(Consumer.class.getClassLoader(), + new Class[] { Consumer.class }, new JDKProxyInvokeHandler( + (Consumer) args[args.length - 1], new ConsumerProxyProcessor(t, url))); + + } + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=" + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + // 调用链只关心真正的消息通讯 + if (method.getName().equals("basicPublish")) { + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", + "registerAdapter", RabbitmqProducerAdapter.class); + + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + RabbitmqProducerAdapter.class, + new Object[] { (BasicProperties) args[args.length - 2], args[args.length - 1] }); + if (ivcContextParams != null + && ivcContextParams.containsKey(InvokeChainConstants.PARAM_MQHEAD_INFO)) { + args[args.length - 2] = ivcContextParams.get(InvokeChainConstants.PARAM_MQHEAD_INFO); + } + } + } + } + + @Override + public Object postProcess(Object res, Channel t, Object proxy, Method method, Object[] args) { + + if (needDoCap(method, args)) { + doCap(1, t, method, null); + } + + return null; + } + + @Override + public void catchInvokeException(Channel t, Object proxy, Method method, Object[] args, Throwable e) { + + if (needDoCap(method, args)) { + doCap(-1, t, method, e); + } + + } + + private boolean needDoCap(Method method, Object[] args) { + + if (method.getExceptionTypes().length == 0 + || !method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { + return false; + } + String methodName = method.getName(); + if (queueNameIndex.containsKey(methodName) && args.length != 0) { + + if (isTempQueue((String) args[queueNameIndex.get(methodName)])) { + return false; + } + } + return true; + } + + private void doCap(int rc, Channel t, Method method, Throwable e) { + + if (null == targetServer) { + Map conn = t.getConnection().getServerProperties(); + String cluster_name = (null == conn.get("cluster_name")) ? "unknown" + : conn.get("cluster_name").toString(); + String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); + targetServer = cluster_name + "@" + version; + } + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + + // 调用链只关心真正的消息通讯 + if (method.getName().equals("basicPublish")) { + + if (rc == -1) { + ivcContextParams.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + } + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, + ivcContextParams, RabbitmqProducerAdapter.class, null); + } + + } + + public boolean isTempQueue(String queueName) { + + String regEx = "^([0-9]|[a-f]){8}(-([0-9]|[a-f]){4}){3}-([0-9]|[a-f]){12}$"; + Matcher matcher = Pattern.compile(regEx).matcher(queueName); + return matcher.matches(); + + } + } + + public class ConsumerProxyProcessor extends JDKProxyInvokeProcessor { + + private Channel channel; + private String url; + private String targetServer; + + public ConsumerProxyProcessor(Channel channel, String url) { + this.channel = channel; + this.url = url; + } + + @Override + public void preProcess(Consumer t, Object proxy, Method method, Object[] args) { + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + // 调用链只关心真正消费消息 + if (method.getName().equals("handleDelivery")) { + + AMQP.BasicProperties props = (BasicProperties) args[2]; + if (props.getHeaders() != null + && props.getHeaders().containsKey(InvokeChainConstants.PARAM_MQHEAD_SPANINFO)) { + params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, + props.getHeaders().get(InvokeChainConstants.PARAM_MQHEAD_SPANINFO) + ""); + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); + } + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", + "registerAdapter", RabbitmqConsumerAdapter.class); + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.PRECAP, params, + RabbitmqConsumerAdapter.class, args); + } + + } + + @Override + public void catchInvokeException(Consumer t, Object proxy, Method method, Object[] args, Throwable e) { + + doCap(-1, channel, t, method, e); + + } + + @Override + public Object postProcess(Object res, Consumer operation, Object proxy, Method method, Object[] args) { + + doCap(1, channel, operation, method, null); + return null; + } + + private void doCap(int rc, Channel channel, Consumer consumer, Method method, Throwable e) { + + if (null == targetServer) { + Map conn = channel.getConnection().getServerProperties(); + String cluster_name = (null == conn.get("cluster_name")) ? "unknown" + : conn.get("cluster_name").toString(); + String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); + targetServer = cluster_name + "@" + version; + } + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + + if (method.getName().equals("handleDelivery")) { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(InvokeChainConstants.CLIENT_IT_CLASS, consumer.getClass().getName()); + // 调用链只关心一个方法 + params.put(InvokeChainConstants.CLIENT_IT_METHOD, "handleDelivery"); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + if (rc == -1) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + } + + // invoke chain + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.DOCAP, params, + RabbitmqConsumerAdapter.class, null); + } + } + + } + +} From 35734a18a5b5bf871b49ee62ea0a2fe6b1324d92 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 13 Apr 2018 16:32:28 +0800 Subject: [PATCH 56/97] https://github.com/uavorg/uavstack/issues/251 1.code format --- .../notifystgy/css/uav.notifystgy.css | 784 ++-- .../notifystgy/js/notifystgy.win.js | 3302 ++++++++--------- .../feature/runtimenotify/NotifyStrategy.java | 1124 +++--- .../task/JudgeNotifyTimerTask.java | 518 +-- .../agent/helpers/DateTimeHelper.java | 2016 +++++----- .../rabbitmq/interceptors/RabbitmqIT.java | 730 ++-- 6 files changed, 4237 insertions(+), 4237 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css index d8110b54..045c7162 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css @@ -1,393 +1,393 @@ -@CHARSET "UTF-8"; -/*原子布局 BEGINI*/ -html { - height: 100%; -} - -body { - font-size: 14px; - font-family: "微软雅黑"; - margin-top: 0px; - margin-left: 0px; - margin-right: 0px; - margin-bottom: 0px; - text-align: center; - height: 100%; -} - -.ListBG { - background: white; - color: black; - font-size: 14px; -} - -.ObjectBG { - background: white; - color: black; - font-size: 14px; -} - -.ObjectBG input,select,textarea,.selectDiv{ - width: 50%; - height: 34px; - border-radius: 2px; - min-width: 340px; - margin-top:1px; -} - -.selectDiv{ - display: inline-flex; -} - -.ObjectBG textarea{ - resize: none; - height:50px; -} - -.ObjectBG .well{ - width: 50%; - min-width: 340px; - border-radius: 2px; - margin: 0 auto; - padding:0px; - text-align:left; -} - -.well-title{ - float: left; - margin-top:3px; - margin-left:3px; - color: white; -} - -.well-title-div{ - background-color: #009ad6; - text-align: right; - width: 100%; - color: white; -} -.well-add{ - font-size: 18px; - margin-top:3px; - margin-right:7px; -} - -.well-add:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px white; -} - -.well-list{ - margin-top:2px; - margin-left:3px; - border-bottom: dotted 1px #999; -} -.well-list:hover{ - background: #cae4ff; -} -.well-del{ - font-size: 18px; - float: right; - margin-right:7px; -} -.well-del:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px #ff0000; -} -.well-edit{ - font-size: 18px; - float: right; - margin-right:20px; -} -.well-edit:hover { - border-radius: 3px; - box-shadow: 0 0 1px 1px #000000; -} -.icon-myout,.icon-myhelp { - float: right; - margin-top: 5px; - margin-right: 15px; - font-size: 2em; -} - -.icon-myout:hover { - border-radius: 3px; - box-shadow: 0 0 4px 4px #ffffff; -} - -.icon-myhelp{ - height: 31.4px; - width: 31.4px; - - } - -.icon-myhelp:hover{ - border-radius: 50px; - box-shadow: 0 0 4px 4px #ffffff; -} - -.titleDiv { - font-size: 16px; - color: #ffffff; - background-color: #009ad6; - height: 43px; - line-height:43px; -} - -.titleDiv-stgy-nodata{ - color: black; - margin-left: -85px; -} - -.conditions select{ - min-width: 200px; - width: 200px; -} - -.conditions input{ - width: 200px; - display: inline -} - - -/*下拉框按钮CSS*/ -.selBut{ - width: 90%; - text-align: left; - padding:0px; -} -.selBut_but{ - width: 10%; -} -.selBut_must{ - width: 90%; - text-align: left; - border:solid 1px red; -} - -.input_must{ - text-align: left; - border:solid 1px red; -} -.input_update{ - text-align: left; - border:solid 1px green; -} - -.input_must:focus{ - border:0px; -} -.defNone{ - display:none; -} - -.displayMsgInput{ - display: inline-block; - text-align: left; - background-color: #cde6c7; - padding-top: 4px; - padding-left: 2px; - border:0px; -} - -.displayMsgTitle{ - border:0px; - font-weight: 900; -} -.listIndex{ - color : black; - border-radius: 3px 3px 3px 3px; - background-color: #dddddd; -} -.listIndex > hr{ - margin:0px; - border-top: 1px solid #ffffff; - -} -.listIndex_server{ - color : #ffffff; - background-color: #0aaaaa; -} -.listIndex_client{ - color : #ffffff; - background-color: #a6c166; -} -.listIndex_log{ - color : #ffffff; - background-color: #c99f32; -} -.listIndex_appmetrics{ - color : #ffffff; - background-color: #970097; -} -/**重写CSS*/ -.table>tbody>tr>td{ - vertical-align:middle; -} - - -.titleMsgDiv{ - margin-top: -34px; - height: 34px; -} - -/**时间控件按钮样式**/ -.control-group { - margin-bottom: 10px; -} - -.control-group input { - background-color: #eeeeee; - border:1px solid #cccccc; - border-radius:4px 0 0 4px; - padding: 4px 6px; - color:#333333 -} -.control-group .add-on { - background-color: #eeeeee; - border:1px solid #cccccc; - border-radius:0 4px 4px 0; - padding: 4.5px 6px; - color:#333333 -} - -/** -*条件定义 -*/ -.btn-default.active:focus{ - color: #333; - background-color: #d4d4d4; - border-color: #8c8c8c; -} - -.btn-default.active, .btn-default:active{ - color: #333; - background-color: #d4d4d4; - border-color: #337ab7; -} - -/** -*触发策略 begin -*/ -.StgyDiv .edit-div-where{ - font-size: 14px; - width: 95%; - border-radius: 2px; - margin: 0 auto; - text-align:left; - padding: 5px; - margin-top: 5px; - margin-bottom: 5px; - border:solid 1px green; -} - -.StgyDiv .edit-div{ - font-size: 14px; - height: 130px; - width: 95%; - min-width: 340px; - border-radius: 2px; - margin: 0 auto; - text-align:left; - padding: 5px; - overflow-y:auto; - color:#000000; -} - -.StgyDiv .edit-div:empty:before{ - content: attr(placeholder); - color:darkgrey; -} - -.StgyDiv .edit-div-option{ - font-size: 14px; - height: 50px; - width: 95%; - min-width: 340px; - border-radius: 2px; - border-color:#000000; - margin: 0 auto; - text-align:left; - padding: 5px; - margin-top: 5px; - overflow-y:auto; - color:#000000; -} - -StgyDiv .edit-div-option:empty:before{ - content: attr(placeholder); - color:darkgrey; -} - -.whereStgyEdit{ - border-radius: 4px; -} -.whereStgyEdit-success{ - background-color: #dddddd; - color:#000000; - display: inline-block; - margin: 1px; -} -.whereStgyEdit-delete{ - text-decoration: line-through; - border: solid 1px red; - color: red; - display: inline-block; - margin: 1px; -} - -.btn-success { - margin: 5px; - color: #000000; - padding: 3px 10px; - background-color: #ffffff; - border-color: #3c763d; -} -.btn-success:hover { - color: #000000; - background-color: #dddddd; -} - -.well-list-display{ - display: -webkit-box; - padding-bottom: 5px; - padding-top: 5px; -} -.action-textarea-delete{ - display: inline-flex; - position: absolute; - margin-top: 17px; - margin-left: 5px; -} - -.action-textarea-delete span{ - border:solid 1px #ffffff; - font-size: 18px; -} -.action-textarea-delete span:hover{ - font-size: 18px; - border:solid 1px red; - border-radius: 2px; -} - -/** -*触发策略 end -*/ - -.itemTitle { - text-align:left; - color:#333; - border-left:6px solid #57A69C; - padding-left:5px; - margin-bottom:2px; -} - -.itemTip { - color:gray; - font-size:14px; - text-align:left; -} - -.dateTimeInput { - width:120px; +@CHARSET "UTF-8"; +/*原子布局 BEGINI*/ +html { + height: 100%; +} + +body { + font-size: 14px; + font-family: "微软雅黑"; + margin-top: 0px; + margin-left: 0px; + margin-right: 0px; + margin-bottom: 0px; + text-align: center; + height: 100%; +} + +.ListBG { + background: white; + color: black; + font-size: 14px; +} + +.ObjectBG { + background: white; + color: black; + font-size: 14px; +} + +.ObjectBG input,select,textarea,.selectDiv{ + width: 50%; + height: 34px; + border-radius: 2px; + min-width: 340px; + margin-top:1px; +} + +.selectDiv{ + display: inline-flex; +} + +.ObjectBG textarea{ + resize: none; + height:50px; +} + +.ObjectBG .well{ + width: 50%; + min-width: 340px; + border-radius: 2px; + margin: 0 auto; + padding:0px; + text-align:left; +} + +.well-title{ + float: left; + margin-top:3px; + margin-left:3px; + color: white; +} + +.well-title-div{ + background-color: #009ad6; + text-align: right; + width: 100%; + color: white; +} +.well-add{ + font-size: 18px; + margin-top:3px; + margin-right:7px; +} + +.well-add:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px white; +} + +.well-list{ + margin-top:2px; + margin-left:3px; + border-bottom: dotted 1px #999; +} +.well-list:hover{ + background: #cae4ff; +} +.well-del{ + font-size: 18px; + float: right; + margin-right:7px; +} +.well-del:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px #ff0000; +} +.well-edit{ + font-size: 18px; + float: right; + margin-right:20px; +} +.well-edit:hover { + border-radius: 3px; + box-shadow: 0 0 1px 1px #000000; +} +.icon-myout,.icon-myhelp { + float: right; + margin-top: 5px; + margin-right: 15px; + font-size: 2em; +} + +.icon-myout:hover { + border-radius: 3px; + box-shadow: 0 0 4px 4px #ffffff; +} + +.icon-myhelp{ + height: 31.4px; + width: 31.4px; + + } + +.icon-myhelp:hover{ + border-radius: 50px; + box-shadow: 0 0 4px 4px #ffffff; +} + +.titleDiv { + font-size: 16px; + color: #ffffff; + background-color: #009ad6; + height: 43px; + line-height:43px; +} + +.titleDiv-stgy-nodata{ + color: black; + margin-left: -85px; +} + +.conditions select{ + min-width: 200px; + width: 200px; +} + +.conditions input{ + width: 200px; + display: inline +} + + +/*下拉框按钮CSS*/ +.selBut{ + width: 90%; + text-align: left; + padding:0px; +} +.selBut_but{ + width: 10%; +} +.selBut_must{ + width: 90%; + text-align: left; + border:solid 1px red; +} + +.input_must{ + text-align: left; + border:solid 1px red; +} +.input_update{ + text-align: left; + border:solid 1px green; +} + +.input_must:focus{ + border:0px; +} +.defNone{ + display:none; +} + +.displayMsgInput{ + display: inline-block; + text-align: left; + background-color: #cde6c7; + padding-top: 4px; + padding-left: 2px; + border:0px; +} + +.displayMsgTitle{ + border:0px; + font-weight: 900; +} +.listIndex{ + color : black; + border-radius: 3px 3px 3px 3px; + background-color: #dddddd; +} +.listIndex > hr{ + margin:0px; + border-top: 1px solid #ffffff; + +} +.listIndex_server{ + color : #ffffff; + background-color: #0aaaaa; +} +.listIndex_client{ + color : #ffffff; + background-color: #a6c166; +} +.listIndex_log{ + color : #ffffff; + background-color: #c99f32; +} +.listIndex_appmetrics{ + color : #ffffff; + background-color: #970097; +} +/**重写CSS*/ +.table>tbody>tr>td{ + vertical-align:middle; +} + + +.titleMsgDiv{ + margin-top: -34px; + height: 34px; +} + +/**时间控件按钮样式**/ +.control-group { + margin-bottom: 10px; +} + +.control-group input { + background-color: #eeeeee; + border:1px solid #cccccc; + border-radius:4px 0 0 4px; + padding: 4px 6px; + color:#333333 +} +.control-group .add-on { + background-color: #eeeeee; + border:1px solid #cccccc; + border-radius:0 4px 4px 0; + padding: 4.5px 6px; + color:#333333 +} + +/** +*条件定义 +*/ +.btn-default.active:focus{ + color: #333; + background-color: #d4d4d4; + border-color: #8c8c8c; +} + +.btn-default.active, .btn-default:active{ + color: #333; + background-color: #d4d4d4; + border-color: #337ab7; +} + +/** +*触发策略 begin +*/ +.StgyDiv .edit-div-where{ + font-size: 14px; + width: 95%; + border-radius: 2px; + margin: 0 auto; + text-align:left; + padding: 5px; + margin-top: 5px; + margin-bottom: 5px; + border:solid 1px green; +} + +.StgyDiv .edit-div{ + font-size: 14px; + height: 130px; + width: 95%; + min-width: 340px; + border-radius: 2px; + margin: 0 auto; + text-align:left; + padding: 5px; + overflow-y:auto; + color:#000000; +} + +.StgyDiv .edit-div:empty:before{ + content: attr(placeholder); + color:darkgrey; +} + +.StgyDiv .edit-div-option{ + font-size: 14px; + height: 50px; + width: 95%; + min-width: 340px; + border-radius: 2px; + border-color:#000000; + margin: 0 auto; + text-align:left; + padding: 5px; + margin-top: 5px; + overflow-y:auto; + color:#000000; +} + +StgyDiv .edit-div-option:empty:before{ + content: attr(placeholder); + color:darkgrey; +} + +.whereStgyEdit{ + border-radius: 4px; +} +.whereStgyEdit-success{ + background-color: #dddddd; + color:#000000; + display: inline-block; + margin: 1px; +} +.whereStgyEdit-delete{ + text-decoration: line-through; + border: solid 1px red; + color: red; + display: inline-block; + margin: 1px; +} + +.btn-success { + margin: 5px; + color: #000000; + padding: 3px 10px; + background-color: #ffffff; + border-color: #3c763d; +} +.btn-success:hover { + color: #000000; + background-color: #dddddd; +} + +.well-list-display{ + display: -webkit-box; + padding-bottom: 5px; + padding-top: 5px; +} +.action-textarea-delete{ + display: inline-flex; + position: absolute; + margin-top: 17px; + margin-left: 5px; +} + +.action-textarea-delete span{ + border:solid 1px #ffffff; + font-size: 18px; +} +.action-textarea-delete span:hover{ + font-size: 18px; + border:solid 1px red; + border-radius: 2px; +} + +/** +*触发策略 end +*/ + +.itemTitle { + text-align:left; + color:#333; + border-left:6px solid #57A69C; + padding-left:5px; + margin-bottom:2px; +} + +.itemTip { + color:gray; + font-size:14px; + text-align:left; +} + +.dateTimeInput { + width:120px; } \ No newline at end of file diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 5671d8b0..2e61cdc8 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -1,1652 +1,1652 @@ -/** - * 窗体初始化 - */ -window.winmgr.build({ - id : "notifyList", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "ListBG" -}); -window.winmgr.build({ - id : "objectDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "ObjectBG" -}); -window.winmgr.build({ - id : "stgyDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "StgyDiv" -}); -window.winmgr.build({ - id : "condDiv", - height : "auto", - "overflow-y" : "auto", - order : 999, - theme : "condDiv" -}); -window.winmgr.show("notifyList"); - -/** - * 操作配置 - */ -var actionConf = { - actionObj:null //操作对象 -} -/** - * 下拉框UI - * */ -var selUiConf = { - keys:[ - - {"key":"server","value":"自定义指标"}, - {"key":"server","value":"服务端"}, - {"key":"client","value":"客户端"}, - {"key":"log","value":"日志"} - ], - "server":[ - ["procState","进程状态指标系"], - ["hostState","应用容器状态指标系"], - ["urlResp","服务状态指标系"], - ["appResp","应用状态指标系"], - ["serverResp","应用服务器状态指标系"], - ["procCrash","进程死亡指标系"] - ], - "client":[ - ["clientResp","调用状态指标系"] - ], - "log":[ - ["log","日志"] - ] - , - "userDef":[ - ["jvm","Java虚拟机状态指标系"] - ] - , - userInput:{ - "notifyNameF":"", - "notifyNameM":"", - "notifyNameI":"" - } - -} - -var supportJTA = ["服务状态指标系","应用状态指标系","应用服务器状态指标系","调用状态指标系"]; -/** - * 初始化头部 - */ -function initHeadDiv() { - var divContent = "" - + "
" - - + "" - - + "" - - + "" - - + "
" - + "" - - + "" - + "
" + "
" + ""; - HtmlHelper.id("notifyList").innerHTML += divContent; -} - -/** - * 显示添加策略 - */ -function showAddDiv() { - - var sb=new StringBuffer(); - sb.append( "
"); - sb.append( ""); - sb.append( ""); - sb.append( ""); - sb.append( "添加策略"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - - sb.append( '
'); - - - sb.append( '
'); - sb.append(''); - sb.append('
'); - sb.append(''); - sb.append(''); - sb.append(''); - sb.append('
'); - sb.append('
'); - - sb.append('
'); - sb.append('
'); - sb.append(''); - sb.append(''); - sb.append(''); - sb.append('
'); - sb.append( '
'); - sb.append('
'); - - sb.append( '
'); - sb.append( "
"); - - - sb.append( '
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
条件定义
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
触发策略
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
触发动作
'); - sb.append( '
'); - - sb.append( '
'); - sb.append( '
'); - sb.append( '
 
'); - - sb.append( ''); - - HtmlHelper.id("objectDiv").innerHTML = sb.toString(); - window.winmgr.hide("notifyList"); - window.winmgr.show("objectDiv"); - initActionDiv($("#isOwner").val()); - -} - - -/** - * 显示编辑策略 - */ -function showEditNotifyDiv(jsonObjParam) { - - var key,jsonObj,isOwner=false;enableThreadAnalysis=false; - //因为只有一对 key:value 获取key(值为id) - $.each(jsonObjParam,function(index,obj){ - key = index; - jsonObj = obj; - }); - - if(jsonObj.owner == window.parent.loginUser.userId - || window.parent.loginUser.groupId == "uav_admin" - || window.parent.loginUser.groupId == "vipgroup" - ){ - isOwner = true; - } - - var names = key.split("@"); - var cssType = "displayMsgInput",cssRedOnly = "displayMsgInput listIndex"; - var sb=new StringBuffer(); - sb.append( "
"); - sb.append( ""); - sb.append( "编辑策略"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - sb.append( "
"); - /** - * 所有渲染内容 div begin - */ - sb.append( '
'); - - sb.append( '
'); - if(window.parent.loginUser.groupId == "uav_admin" - || window.parent.loginUser.groupId == "vipgroup" - ){ - sb.append( '
'); - }else{ - - sb.append( '
'); - } - - - sb.append( '
'); - - //1 - var existsIns = jsonObj.instances.length>0?true:false; - var showNameF = getSelUiConfKeysValue(names[0],names[1]); - if(showNameF=="自定义指标"){ - cssType = "displayMsgInput listIndex_appmetrics"; - }else if(names[1] == "log"){ - showNameF = "日志"; - cssType = "displayMsgInput listIndex_log"; - }else if(names[0] == "server"){ - cssType = "displayMsgInput listIndex_server"; - }else if(names[0] == "client"){ - cssType = "displayMsgInput listIndex_client"; - } - sb.append( '
'); - selUiConf["userInput"]["notifyNameF"]=names[0];//编辑赋值,准备修改数据 - //2 - if(showNameF=="自定义指标"){ - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - }else if(names[1] == "log"){ - sb.append( '
'); - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - }else if(names[1]){ - sb.append( '
'); - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 - if($.inArray(getSelUiConfigValue(names[1]),supportJTA) >= 0){ - enableThreadAnalysis=true; - } - } - //3 - if(names[2] && names[1] == "log"){ - var nNameIShow = "指定日志:"+names[2]; - sb.append( '
'); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 - }else if(names[1] == "log"){ - sb.append( '
'); - }else if(names[2]){ - var nNameIShow = (existsIns?"实例组:":"实例:")+names[2]; - sb.append( '
'); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 - }else{ - sb.append( '
'); - } - - if(names[2] && isOwner){ - sb.append( "
'); - }else if(names[2] && !isOwner){ - sb.append( "
'); - }else if(isOwner){ - sb.append( "
'); - }else{ - sb.append( "
'); - } - - - sb.append( '
'); - if(isOwner){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - /** - * 初始化条件 begin - */ - sb.append( '
'); - sb.append( '
'); - sb.append( '条件定义'); - sb.append( '
'); - $.each(jsonObj.conditions,function(index,obj){ - if(obj.func && obj.func.indexOf("count>")>-1){ - obj.cparam = obj.func.substr(6); - obj.func = "count"; - } - - if(!obj.id){ - /** - * 兼容老数据 - */ - obj.id=StgyClass.randomId()+"_stgySpan"; - } - var html; - if(isOwner){ - html = '
'+StgyClass.formatShowWhere(obj)+'
'; - }else{ - html = '
'+StgyClass.formatShowWhere(obj)+'
'; - } - sb.append( html); - }); - sb.append( '
'); - sb.append( '
'); - /** - * 初始化条件 end - */ - - /** - * 初始化触发策略 begin - */ - sb.append( '
'); - - if(isOwner){ - sb.append( '
触发策略
'); - }else{ - sb.append( '
触发策略
'); - } - - if(jsonObj.relationsHtmls){ - $.each(jsonObj.relationsHtmls,function(index,html){ - var convergenceVal = ""; - if(jsonObj.hasOwnProperty("convergences")){ - convergenceVal = jsonObj.convergences[index]; - } - - var appendHtml = - '
'+ - '
'+ - '
'+html+'
'+ - '
'+convergenceVal+'
'+ - '
'; - - if(isOwner){ - appendHtml+=''; - }else{ - appendHtml+=''; - } - appendHtml+='
'+ - '
'+ - '
'; - sb.append(appendHtml); - }); - } - sb.append( '
'); - /** - * 初始化触发策略 begin - */ - - sb.append( '
'); - sb.append( '
触发动作
'); - var actionSum = 0; - initActionDiv(isOwner?"true":"false"); - if (jsonObj.action!=undefined) { - $.each(jsonObj.action,function(index,value){ - actionSum++; - var josnSpan ={ - "type":index, - "value":value - } - - var html ; - - if(isOwner){ - if("threadanalysis" == josnSpan.type){ - var html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - }else{ - html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - } - }else{ - html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; - } - sb.append( '
'); - sb.append( html); - sb.append( '
'); - - /** - * 计算下拉选项 - */ - $("#actionTypeSel option[value="+josnSpan.type+"]").remove(); - - }); - } - sb.append( '
'); - /** - * 初始化触发动作 end - */ - - if(isOwner){ - //按钮 - sb.append( '
'); - sb.append( '
'); - sb.append( '
 
'); - } - - sb.append( '
'); - /** - * 所有渲染内容 div end - */ - sb.append( ""); - HtmlHelper.id("objectDiv").innerHTML = sb.toString(); - - /** - * 判断出发条件:不是归属者不能添加 - */ - if(!isOwner){ - $("#whereAddButton").attr("class","well-add"); - $("#whereAddButton").click(function(){}); - } - /** - * 判断触发动作按钮 begin(类型都已经存在值,则不能再添加) - * 不是归属者也不能添加 - */ - var selTypeSize = $("#actionTypeSel option").size(); - if(selTypeSize == 0 || !isOwner){ - $("#actionAddButton").attr("class","well-add"); - $("#actionAddButton").click(function(){}); - } - /** - * 判断触发动作按钮 end - */ - window.winmgr.hide("notifyList"); - window.winmgr.show("objectDiv"); - - hideShowConStgy(names[1]); -} - - - -/** - * 触发动作添加窗口 - */ -function initActionDiv(isOwner) { - - var old = document.getElementById("actionDiv"); - if(old){ - var node = old.parentNode; - node.removeChild(old); - } - - var sb=new StringBuffer(); - - sb.append(''); - var div = document.createElement('div'); - div.innerHTML = sb.toString(); - document.body.appendChild(div); -} - -/** - * 显示添加条件窗口 - * @param thisObj - * @param type - */ -function showCon(thisObj,type){ - actionConf.actionObj=thisObj.parentNode; - if(selUiConf["userInput"]["notifyNameM"]=="log"){ - $("#condType").attr("disabled","disabled"); - } - $("#pageType").val(type); - if("EDIT" == type){ - var jsonValue = JSON.parse(thisObj.parentNode.getElementsByTagName("span")[0].textContent); - $("#condType").attr("disabled","disabled"); - var isOwner = $("#isOwner").val(); - if(!jsonValue.type||jsonValue.type=="stream"){ - $("#condType").val("stream"); - $("#contExpr").val(jsonValue.expr); - $("#conRange").val(jsonValue.range); - $("#conFunc").val((null == jsonValue.func?0:jsonValue.func)); - if("count" == jsonValue.func){ - $("#conFuncParam").val(jsonValue.cparam); - $("#conFuncParam").show(); - } - //不是归属用户,则只读 - if(isOwner!="true"){ - $("#whereSaveButton").hide(); - $("#contExpr").attr("readonly","readonly"); - $("#conRange").attr("readonly","readonly"); - $("#conFunc").attr("disabled","disabled"); - $("#conFuncParam").attr("readonly","readonly"); - - //只读CSS - $("#contExpr").attr("class","form-control"); - $("#conRange").attr("class","form-control"); - $("#conFuncParam").attr("class","form-control"); - $("#whereSaveButton").hide(); - } - - }else{ - var type; - if(jsonValue.interval){ - type="link-relative"; - }else{ - type="base-relative"; - } - $("#condType").val(type); - typeChangeShow(type); - - var hour=jsonValue.time_from.split(':')[0]; - var min=jsonValue.time_from.split(':')[1]; - $('#time_from_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - hour=jsonValue.time_to.split(':')[0]; - min=jsonValue.time_to.split(':')[1]; - $('#time_to_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - - if(jsonValue.time_start!=undefined&&jsonValue.time_end!=undefined){ - hour=jsonValue.time_start.split(':')[0]; - min=jsonValue.time_start.split(':')[1]; - $('#time_start_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - hour=jsonValue.time_end.split(':')[0]; - min=jsonValue.time_end.split(':')[1]; - $('#time_end_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); - } - - if(jsonValue.day_start!=undefined&&jsonValue.day_end!=undefined){ - var year=jsonValue.day_start.split('-')[0]; - var month=jsonValue.day_start.split('-')[1]; - var day=jsonValue.day_start.split('-')[2]; - $('#day_start_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); - year=jsonValue.day_end.split('-')[0]; - month=jsonValue.day_end.split('-')[1]; - day=jsonValue.day_end.split('-')[2]; - $('#day_end_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); - } - - showWeekDay(jsonValue.weekdayLimit); - - $("#conMetric").val(jsonValue.metric); - $("#conUpperLimit").val(jsonValue.upperLimit); - $("#conLowerLimit").val(jsonValue.lowerLimit); - $("#conAggr").val(jsonValue.aggr); - $("#conDownSample").val(jsonValue.downsample); - if(type=="link-relative"){ - $("#conInterval").val(jsonValue.interval); - } - showUnit(jsonValue.unit); - - if(isOwner!="true"){ - $("#time_from").attr("readonly","readonly"); - $("#time_to").attr("readonly","readonly"); - $("#time_start").attr("readonly","readonly"); - $("#time_end").attr("readonly","readonly"); - $("#day_start").attr("readonly","readonly"); - $("#day_end").attr("readonly","readonly"); - $("#conMetric").attr("readonly","readonly"); - $("#conUpperLimit").attr("readonly","readonly"); - $("#conLowerLimit").attr("readonly","readonly"); - $("#conMetric").attr("class","form-control"); - $("#conUpperLimit").attr("class","form-control"); - $("#conLowerLimit").attr("class","form-control"); - $("#conAggr").attr("disabled","disabled"); - $("#conDownSample").attr("disabled","disabled"); - if(type=="link-relative"){ - $("#conInterval").attr("readonly","readonly"); - $("#conInterval").attr("class","form-control"); - } - $("#whereSaveButton").hide(); - } - } - - } - -} - -function showUnit(unit){ - $("#unit").val(unit); - $("#opt"+unit).attr("class","btn btn-default active"); -} - -function showWeekDay(weekdayLimit){ - - for(var i=0;i"); - sb.append("条件定义"); - sb.append("
"); - sb.append(""); - sb.append( "
'); - - sb.append( '
'); - /** - * 普通预警条件编辑 - */ - sb.append( '
'); - - sb.append( '
触发表达式

'); - sb.append( '
持续时间(秒)

'); - sb.append( "
聚集操作

'); - sb.append( ')\" style="display:none" onkeyup="this.value=this.value.replace(\/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(\/\\D/g,\'\')">
'); - sb.append( '
'); - - /** - * 同环比预警条件编辑 - */ - sb.append( ''); - sb.append( ''); - - /** - * 保存按钮 - */ - sb.append( '
'); - sb.append( ''); - sb.append( ''); - sb.append( '
'); - - HtmlHelper.id("condDiv").innerHTML = sb.toString(); - initTimeControl(); - showCon(thisObj,type); - window.winmgr.hide("objectDiv"); - window.winmgr.show("condDiv"); - -} - -function funcChangeShow(thisObj,showId){ - if("count" == thisObj.value){ - $("#"+showId).show(); - }else{ - $("#"+showId).hide(); - } -} - -function typeChangeShow(type){ - var divs=["stream","timer","link-relative","base-relative"]; - divs.forEach(div=>{ - $("#"+div).hide(); - }) - if("stream"!=type){ - $("#timer").show(); - } - $("#"+type).show(); - -} -/** - * 初始化时间控件 - */ -function initTimeControl(){ - $('#time_from_div').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - - $('#time_to_div').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - $('#time_start_div').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - - $('#time_end_div').datetimepicker({ - pickDate: false, - pickSeconds: false - }); - - $('#day_start_div').datetimepicker({ - pickHour: false, - pickMin: false, - pickSeconds: false - }); - - - $('#day_end_div').datetimepicker({ - pickHour: false, - pickMin: false, - pickSeconds: false - }); - - -} - -function changeTimeUnit(value){ - $("#unit").val(value); -} - - - -function actionChangeShow(type){ - if("ADD" == type){ - if("threadanalysis" == $("#actionTypeSel").val()){ - $("textarea[name='actionValue']").val("10101").hide(); - $(".btn-addPriority").hide(); - }else{ - $("textarea[name='actionValue']").val("").show(); - $(".btn-addPriority").show(); - } - }else{ - $("textarea[name='actionValue']").show(); - $(".btn-addPriority").show(); - } -} - -function selServerChangeShow(type,value,text){ - var selId = type+"_notifyNameF"; - $("#"+selId).html(text); - $("#"+selId).css("padding-left","2px"); - $("#"+type+"_notifyNameF").css("color","black"); - - hideShowConStgy("show"); - - if(text == "自定义指标"){ - $("#"+type+"_appName_div").hide(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); - selUiConf["userInput"]["notifyNameF"]=value; - selUiConf["userInput"]["notifyNameM"]="jvm"; - $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - }else if(value=="log"){ - $("#"+type+"_appName_div").show(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); - $("#notifyNameI").attr("placeholder","输入指定日志"); - selUiConf["userInput"]["notifyNameF"]=""; - selUiConf["userInput"]["notifyNameM"]=value; - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - }else{ - $("#"+type+"_appName_div").hide(); - $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv"); - $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); - $("#"+type+"_notifyNameM").css("color","darkgrey"); - $("#"+type+"_notifyNameM").html("选择监控组指标"); - document.getElementById(type+"_notifyNameM_body").innerHTML =""; - $.each(selUiConf[value],function(index,obj){ - var li = document.createElement("li"); - var a = document.createElement("a"); - a.innerHTML=obj[1]; - a.onclick=function(){selIndexChangeShow(type,obj[0],obj[1]);}; - a.href="#"; - li.appendChild(a); - document.getElementById(type+"_notifyNameM_body").appendChild(li); - }); - selUiConf["userInput"]["notifyNameF"]=value; - } - -} - -function removeChoosedJTA(){ - if(HtmlHelper.id("ChoosedJTA") != null){ - HtmlHelper.id("ChoosedJTA").remove(); - } -} - -function changeJTAStat(text){ - if($.inArray(text,supportJTA) >= 0){ - $("#enableThreadAnalysis").val(true); - if(HtmlHelper.id("ChoosedJTA") == null){ - $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); - $("#actionAddButton").click(function(){showAction(this,'ADD')}); - } - }else{ - $("#enableThreadAnalysis").val(false); - removeChoosedJTA(); - } -} - -function hideShowConStgy(value){ - if(value == "procCrash"){ - $("#conFatDiv").hide(); - $("#stgyFatDiv").hide(); - } - else{ - $("#conFatDiv").show(); - $("#stgyFatDiv").show(); - } -} - -function selIndexChangeShow(type,value,text){ - changeJTAStat(text); - hideShowConStgy(value); - - $("#"+type+"_notifyNameM").html(text); - $("#"+type+"_notifyNameM").css("padding-left","2px"); - $("#"+type+"_notifyNameM").css("color","black"); - selUiConf["userInput"]["notifyNameM"]=value; -} - -function appNameChange(obj){ - selUiConf["userInput"]["notifyNameF"]=obj.value; -} -function getSelUiConfigValue(indexValue){ - var result =""; - $.each(selUiConf.keys,function(value,obj1){ - $.each(selUiConf[obj1.key],function(index,obj2){ - if(obj2[0]==indexValue){ - result=obj2[1]; - return false; - } - }); - if(result!==""){ - return false; - } - }); - - return result; -} -function getSelUiConfKeysValue(a, b) { - var result = ""; - if (b == "log") { - result="日志"; - } else if (a == "server" && b == "jvm") { - result="自定义指标"; - } else if (a == "server") { - result="服务端"; - } else if (a == "client") { - result="客户端"; - } - return result; -} -function conditionsAppend(){ - if(checkFunc()){ - var jsonObject; - if("stream"==$("#condType").val()){ - jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; - }else{ - jsonObject = {"type":"timer","time_from":HtmlHelper.inputXSSFilter($("#time_from").val()),"time_to":HtmlHelper.inputXSSFilter($("#time_to").val()),"metric":HtmlHelper.inputXSSFilter($("#conMetric").val()),"upperLimit":HtmlHelper.inputXSSFilter($("#conUpperLimit").val()),"lowerLimit":HtmlHelper.inputXSSFilter($("#conLowerLimit").val())}; - - if(HtmlHelper.inputXSSFilter($("#conAggr").val())!="0"){ - jsonObject["aggr"]=HtmlHelper.inputXSSFilter($("#conAggr").val()); - }else{ - jsonObject["aggr"]="avg"; - } - - if(HtmlHelper.inputXSSFilter($("#conDownSample").val())!="0"){ - jsonObject["downsample"]=HtmlHelper.inputXSSFilter($("#conDownSample").val()); - }else{ - jsonObject["downsample"]="all-avg"; - } - - if("link-relative"==$("#condType").val()){ - jsonObject["interval"]=HtmlHelper.inputXSSFilter($("#conInterval").val()); - jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); - }else{ - jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); - } - - if($("#time_start").val()&&$("#time_end").val()){ - jsonObject["time_start"]=HtmlHelper.inputXSSFilter($("#time_start").val()); - jsonObject["time_end"]=HtmlHelper.inputXSSFilter($("#time_end").val()); - } - - if($("#day_start").val()&&$("#day_end").val()){ - jsonObject["day_start"]=HtmlHelper.inputXSSFilter($("#day_start").val()); - jsonObject["day_end"]=HtmlHelper.inputXSSFilter($("#day_end").val()); - } - - var weekdayLimit=[]; - for(var i=0;i<7;i++){ - weekdayLimit[i]=($("#weekday"+i).attr("class")=="btn btn-default active") - } - jsonObject["weekdayLimit"]=weekdayLimit; - - } - appendConditions(jsonObject); - window.winmgr.hide("condDiv"); - window.winmgr.show("objectDiv"); - } -} - -function checkFunc(){ - - var result = true; - if("stream"==$("#condType").val()){ - if(!$("#contExpr").val()){ - result = false; - }else if("count" == $("#conFunc").val() && !$("#conFuncParam").val()){ - result = false; - } - }else{ - if(!$("#time_from").val()||!$("#time_to").val()||!$("#conMetric").val()||!$("#conUpperLimit").val()||!$("#conLowerLimit").val()){ - result = false; - } - if("link-relative"==$("#condType").val()){ - if(!$("#conInterval").val()||!$("#unit").val()){ - result = false; - } - }else{ - if(!$("#unit").val()){ - result = false; - } - } - } - - - if(result){ - $("#conditionsErrMsg").hide(); - }else{ - $("#conditionsErrMsg").show(); - } - - return result; -} -function appendConditions(jsonObj) { - var type = $("#pageType").val(); - if("ADD"==type){ - var newNode = document.createElement("div"); - var stgyDivId = StgyClass.randomId()+"_stgySpan"; - html = '
'+getHtmlAndSetId(stgyDivId)+'
'; - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - }else if("EDIT"==type){ - var oldId = actionConf.actionObj.getElementsByTagName("span")[0].id; - actionConf.actionObj.innerHTML= getHtmlAndSetId(oldId); - StgyClass.updateWhereToStgyAppend(jsonObj); - } - - function getHtmlAndSetId(stgyDivId){ - jsonObj.id = stgyDivId;//赋值id - var html = StgyClass.formatShowWhere(jsonObj)+''; - return html; - } -} -/** - * 条件窗口操作 end - */ - - -/** - * 触发动作操作 begin - */ -function showAction(thisObj,type){ - actionConf.actionObj=thisObj.parentNode; - checkJTAAction(); - $("#actiontype").val(type); - $.each($("textarea[name='actionValue']"),function(index,obj){ - if(index>0){ - removeActonTextarea(obj); - }else{ - obj.value=""; - } - }); - $("#actionDiv").modal({backdrop: 'static', keyboard: false}); - $("#actionDiv").modal(); - //还原只读 - $("#actionSaveButton").show(); - $("#actionValue").removeAttr("readonly"); - - - if("EDIT"==type){ - //不是归属用户,则只读 - var isOwner = $("#isOwner").val(); - $("#actionTypeSel").hide(); - var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].textContent); - - $.each(spanJson.value,function(index,value){ - /** - * 第一次循环:追加渲染 - */ - if(index>0){ - appendActionTextarea(); - } - }); - var actionTextValues = $("textarea[name='actionValue']"); - $.each(spanJson.value,function(index,value){ - /** - * 第二次循环:赋值 - */ - actionTextValues[index].value=value; - }); - - $("#actionEditType").val(spanJson.type); - - actionChangeShow("EDIT"); - if(isOwner!="true"){ - $("#actionSaveButton").hide(); - } - }else{ - $("#actionTypeSel").show(); - actionChangeShow("ADD"); - } -} - -function checkJTAAction(){ - if($("#enableThreadAnalysis").val() =="true"&& $("#actionTypeSel").find("option[value='threadanalysis']").size() == 0 && $("#ChoosedJTA").size() == 0){ - $("#actionTypeSel").append(""); - } - else if($("#enableThreadAnalysis").val() == "false" && $("#actionTypeSel").find("option[value='threadanalysis']").size() == 1){ - $("#actionTypeSel option[value=threadanalysis]").remove(); - } -} - -function actionAppend(){ - - $("#ActionErrMsg").hide(); - - if(checkAction()){ - appendActions(); - $("#actionDiv").modal('hide'); - }else{ - $("#ActionErrMsg").show(); - } -} - -function appendActionTextarea(thisObj){ - var isOwner = $("#isOwner").val(); - - var html = ''; - if(isOwner == "true"){ - html = ''; - html+= '
'; - }else{ - html = ''; - } - - var newNode = document.createElement("div"); - newNode.innerHTML = html; - document.getElementById("actionBodyDiv").appendChild(newNode); -} -function removeActonTextarea(thisObj){ - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); -} - -function checkAction(){ - var actionTextValues = $("textarea[name='actionValue']"); - - var checkValue = $.trim(actionTextValues[0].value); //只校验第一个必须输入 - var type = $("#actiontype").val(); - if("ADD"==type && !checkValue){ - return false; - }else if(!checkValue){ - return false; - } - - var result = false; - var actionValues = new Array(); - $.each(actionTextValues,function(index,obj){ - var values = format(obj.value); - obj.value = values; - if(values!=""){ - actionValues.push(values); - result = true; - } - }); - - if(!result){ - $("#ActionErrMsg").show(); - } - - return result; - - function format(_values){ - var result = new Array(); - var values = _values.split(","); - $.each(values,function(index,value){ - value = $.trim(value); - if(value!=""){ - result.push(value); - } - }); - - if(!result || result.length==0){ - return ""; - }else{ - return result.join(","); - } - } -} - -function appendActions() { - var type = $("#actiontype").val(); - var html = getAppendHtml(type); - - if("threadanalysis" == $("#actionTypeSel").val()){ - $("#enableThreadAnalysis").val(false); - } - if("ADD"==type){ - var newNode = document.createElement("div"); - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - - /** - * 计算下拉菜单:删除当前选项 - */ - $("#actionTypeSel option[value="+$("#actionTypeSel").val()+"]").remove(); - - /** - * 计算是否还有添加类型:添加按钮控制 - */ - var actionTypeSelect = document.getElementById("actionTypeSel"); - if(actionTypeSelect.length == 0){ - $("#actionAddButton").attr("class","well-add"); - $("#actionAddButton").click(function(){}); - } - - - }else if("EDIT"==type){ - actionConf.actionObj.parentNode.innerHTML = html; - } - - function getAppendHtml(){ - var result = new Array(); - var actionTextValues = $("textarea[name='actionValue']"); - $.each(actionTextValues,function(index,obj){ - result.push(obj.value); - }); - - var actionType =""; - if(type=="ADD"){ - actionType = $("#actionTypeSel").val(); - }else if(type=="EDIT"){ - actionType = $("#actionEditType").val(); - } - - var jsonObj = {type:HtmlHelper.inputXSSFilter(actionType),value:HtmlHelper.inputXSSFilter(result)}; - if("threadanalysis" == jsonObj.type){ - var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; - }else{ - var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; - } - return html; - } -} -/** - * 触发动作操作 end - */ - - -function delThisObj(thisObj) { - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); - StgyClass.deleteWhereToStgyAppend(thisObj); -} - -function delThisActionObj(thisObj) { - - /** - * 还原当前选项 - */ - var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].innerHTML); - if(spanJson.type == "threadanalysis"){ - $("#enableThreadAnalysis").val(true); - } - $('#actionTypeSel').append(""); - $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); - $("#actionAddButton").click(function(){showAction(this,'ADD')}); - /** - * 删除显示 - */ - var node = thisObj.parentNode.parentNode; - node.removeChild(thisObj.parentNode); -} - -function checkNameIShow(){ - if($("#notifyNameI").val()){ - $("#notifyInstances").show(); - }else{ - $("#notifyInstances").val(""); - $("#notifyInstances").hide(); - } - selUiConf["userInput"]["notifyNameI"] = $("#notifyNameI").val(); -} - -function closeObjectDiv() { - window.winmgr.hide("objectDiv"); - window.winmgr.show("notifyList"); -} - -function openHelpDiv() { - window.open("https://uavorg.github.io/documents/uavdoc_useroperation/28.html#%E5%88%9B%E5%BB%BA","apphub.help"); -} - - -/** - * 策略表达式处理类 - */ -var StgyClass = { - datas:{//数据原型 - where:new Array() - }, - initDatas:function(){//初始化数据原型 - StgyClass.datas.where = new Array(); - }, - checkWhereExists : function() { - /** - * 判断条件是否存在 - */ - StgyClass.initDatas(); - var conditions = new Array(), exists = false; - var div = document.getElementById("objectDiv"); - var spans = div.getElementsByTagName("span"); - $.each(spans, function(index, obj) { - if(obj.id && obj.id.indexOf("_stgySpan")>=0){ - exists=true - /** - * 同时将条件数据打包 - */ - StgyClass.datas.where.push(JSON.parse(obj.textContent)); - } - }); - - return exists; - }, - showStgyDiv : function(thisObj,type) { - - var isOwner = $("#isOwner").val(); - /** - * 显示策略编辑(弹出新元素) - */ - actionConf.actionObj=thisObj.parentNode; - - var sb = new StringBuffer(); - sb.append("
"); - sb.append("触发策略"); - sb.append("
"); - sb.append("
"); - - if(StgyClass.checkWhereExists()){ //渲染触发策略页面 - sb.append( '
'); - $.each(StgyClass.datas.where,function(index,data){ - - if(isOwner=="true"){ - sb.append( ''); - }else{ - sb.append( ''); - } - }); - sb.append( '
'); - - - if(isOwner=="true"){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - if(type=="edit"){ - sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[0].innerHTML); - } - sb.append( '
'); - - if(isOwner=="true"){ - sb.append( '
'); - }else{ - sb.append( '
'); - } - - if(type=="edit"){ - sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[1].innerHTML); - } - sb.append( '
'); - - if(isOwner=="true"){ - sb.append( '
'); - } - - }else{ - sb.append("
没有可用条件
"); - } - - HtmlHelper.id("stgyDiv").innerHTML = sb.toString(); - window.winmgr.hide("objectDiv"); - window.winmgr.show("stgyDiv"); - - }, - closeStgyDiv : function() { - /** - * 关闭策略编辑(关闭元素) - */ - window.winmgr.hide("stgyDiv"); - window.winmgr.show("objectDiv"); - }, - appendWhereToStgy:function(thisObj) { - /** - * 在策略编辑:将选中条件追加到策略表达式 - */ - var whereId = thisObj.id + "_exp"; - - var html = '  ' - + thisObj.innerText + '  '; - /** - * 必须要focus一下目标元素,不然会跟随光标而追加html内容。 - */ - document.getElementById("stgy_exp").focus(); - var sel = window.getSelection(); - if (sel.getRangeAt && sel.rangeCount) { - var range = sel.getRangeAt(0); - range.deleteContents(); - - var el = document.createElement("div"); - el.innerHTML = html; - var frag = document.createDocumentFragment(), node, lastNode; - while ((node = el.firstChild)) { - lastNode = frag.appendChild(node); - } - range.insertNode(frag); - - // Preserve the selection - if (lastNode) { - range = range.cloneRange(); - range.setStartAfter(lastNode); - range.collapse(true); - sel.removeAllRanges(); - sel.addRange(range); - } - } - }, - saveStgyToAppend : function(type){ - /** - * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 - */ - var html = document.getElementById("stgy_exp").innerHTML; - var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); - - if(html.length>0 && type=="add"){ - html = '
'+ - '
'+html+'
'+ - '
'+htmlConvergence+'
'+ - '
'+ - ''; - '
'+ - '
'; - - var newNode = document.createElement("div"); - newNode.innerHTML = html; - actionConf.actionObj.parentNode.appendChild(newNode); - - }else if(html.length>0 && type=="edit"){ - actionConf.actionObj.parentNode.getElementsByTagName("div")[0].innerHTML = html; - actionConf.actionObj.parentNode.getElementsByTagName("div")[1].innerHTML = htmlConvergence; - } - - StgyClass.closeStgyDiv(); - - }, - deleteStgyToAppend : function(thisObj){ - /** - * 删除策略结果 - */ - var node = thisObj.parentNode.parentNode.parentNode; - node.removeChild(thisObj.parentNode.parentNode); - }, - updateWhereToStgyAppend : function(json){ - /** - *修改策略结果 - */ - var updateId = json.id+"_exp"; - var stgys = $("span[name='"+updateId+"']"); - $.each(stgys,function(index,obj){ - obj.innerHTML = " "+StgyClass.formatShowWhere(json)+" "; - }); - }, - deleteWhereToStgyAppend : function(thisObj){ - /** - * 删除条件时: 给对应策略添加删除线 - */ - var divId = thisObj.parentNode.getElementsByTagName("span")[0].id+"_exp"; - var stgys = $("span[name='"+divId+"']"); - $.each(stgys,function(index,obj){ - obj.className = "whereStgyEdit whereStgyEdit-delete"; - }); - - }, - /** - * 格式化条件,显示格式(除去id不显示) - * - * @param json - * @returns {String} - */ - formatShowWhere : function(json) { - - if(!json){ - return ""; - } - - var result; - - if(!json.type||json.type=="stream"){ - result = json.expr; - - if(json.range && json.range!=""){ - result += ","+json.range; - } - - if(json.func && json.func!=0 && json.func=="count"){ - result += ","+json.func+">"+json.cparam; - }else if(json.func && json.func!=0){ - result += ","+json.func; - } - }else{ - result = json.metric+","+json.time_from+"-"+json.time_to+","+json.downsample+","+json.aggr+","; - if(json.interval){ - result+=json.interval+" "; - - } - switch(json.unit){ - case "6": - result+="min"; - break; - case "5": - result+="hour"; - break; - case "1": - result+="day"; - break; - case "2": - result+="week"; - break; - case "3": - result+="month"; - break; - case "4": - result+="year"; - break; - } - if(json.time_start!=undefined&&json.time_end!=undefined){ - result+=","+json.time_start+"-"+json.time_end; - } - if(json.day_start!=undefined&&json.day_end!=undefined){ - result+=","+json.day_start+"-"+json.day_end; - } - } - - return result; - }, - randomId : function(x, y) { - if (!x) { - x = 9999; - } - if (!y) { - y = 1; - } - var d = [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ]; - - var rand = parseInt(Math.random() * (x - y + 1) + y) - + d[parseInt(Math.random() * d.length + 0)] - + parseInt(Math.random() * 1000) - + d[parseInt(Math.random() * d.length + 0)] - + parseInt(Math.random() * 1000); - return rand; - } +/** + * 窗体初始化 + */ +window.winmgr.build({ + id : "notifyList", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "ListBG" +}); +window.winmgr.build({ + id : "objectDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "ObjectBG" +}); +window.winmgr.build({ + id : "stgyDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "StgyDiv" +}); +window.winmgr.build({ + id : "condDiv", + height : "auto", + "overflow-y" : "auto", + order : 999, + theme : "condDiv" +}); +window.winmgr.show("notifyList"); + +/** + * 操作配置 + */ +var actionConf = { + actionObj:null //操作对象 +} +/** + * 下拉框UI + * */ +var selUiConf = { + keys:[ + + {"key":"server","value":"自定义指标"}, + {"key":"server","value":"服务端"}, + {"key":"client","value":"客户端"}, + {"key":"log","value":"日志"} + ], + "server":[ + ["procState","进程状态指标系"], + ["hostState","应用容器状态指标系"], + ["urlResp","服务状态指标系"], + ["appResp","应用状态指标系"], + ["serverResp","应用服务器状态指标系"], + ["procCrash","进程死亡指标系"] + ], + "client":[ + ["clientResp","调用状态指标系"] + ], + "log":[ + ["log","日志"] + ] + , + "userDef":[ + ["jvm","Java虚拟机状态指标系"] + ] + , + userInput:{ + "notifyNameF":"", + "notifyNameM":"", + "notifyNameI":"" + } + +} + +var supportJTA = ["服务状态指标系","应用状态指标系","应用服务器状态指标系","调用状态指标系"]; +/** + * 初始化头部 + */ +function initHeadDiv() { + var divContent = "" + + "
" + + + "" + + + "" + + + "" + + + "
" + + "" + + + "" + + "
" + "
" + ""; + HtmlHelper.id("notifyList").innerHTML += divContent; +} + +/** + * 显示添加策略 + */ +function showAddDiv() { + + var sb=new StringBuffer(); + sb.append( "
"); + sb.append( ""); + sb.append( ""); + sb.append( ""); + sb.append( "添加策略"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + + sb.append( '
'); + + + sb.append( '
'); + sb.append(''); + sb.append('
'); + sb.append(''); + sb.append(''); + sb.append(''); + sb.append('
'); + sb.append('
'); + + sb.append('
'); + sb.append('
'); + sb.append(''); + sb.append(''); + sb.append(''); + sb.append('
'); + sb.append( '
'); + sb.append('
'); + + sb.append( '
'); + sb.append( "
"); + + + sb.append( '
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
条件定义
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
触发策略
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
触发动作
'); + sb.append( '
'); + + sb.append( '
'); + sb.append( '
'); + sb.append( '
 
'); + + sb.append( '
'); + + HtmlHelper.id("objectDiv").innerHTML = sb.toString(); + window.winmgr.hide("notifyList"); + window.winmgr.show("objectDiv"); + initActionDiv($("#isOwner").val()); + +} + + +/** + * 显示编辑策略 + */ +function showEditNotifyDiv(jsonObjParam) { + + var key,jsonObj,isOwner=false;enableThreadAnalysis=false; + //因为只有一对 key:value 获取key(值为id) + $.each(jsonObjParam,function(index,obj){ + key = index; + jsonObj = obj; + }); + + if(jsonObj.owner == window.parent.loginUser.userId + || window.parent.loginUser.groupId == "uav_admin" + || window.parent.loginUser.groupId == "vipgroup" + ){ + isOwner = true; + } + + var names = key.split("@"); + var cssType = "displayMsgInput",cssRedOnly = "displayMsgInput listIndex"; + var sb=new StringBuffer(); + sb.append( "
"); + sb.append( ""); + sb.append( "编辑策略"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + sb.append( "
"); + /** + * 所有渲染内容 div begin + */ + sb.append( '
'); + + sb.append( '
'); + if(window.parent.loginUser.groupId == "uav_admin" + || window.parent.loginUser.groupId == "vipgroup" + ){ + sb.append( '
'); + }else{ + + sb.append( '
'); + } + + + sb.append( '
'); + + //1 + var existsIns = jsonObj.instances.length>0?true:false; + var showNameF = getSelUiConfKeysValue(names[0],names[1]); + if(showNameF=="自定义指标"){ + cssType = "displayMsgInput listIndex_appmetrics"; + }else if(names[1] == "log"){ + showNameF = "日志"; + cssType = "displayMsgInput listIndex_log"; + }else if(names[0] == "server"){ + cssType = "displayMsgInput listIndex_server"; + }else if(names[0] == "client"){ + cssType = "displayMsgInput listIndex_client"; + } + sb.append( '
'); + selUiConf["userInput"]["notifyNameF"]=names[0];//编辑赋值,准备修改数据 + //2 + if(showNameF=="自定义指标"){ + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + }else if(names[1] == "log"){ + sb.append( '
'); + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + }else if(names[1]){ + sb.append( '
'); + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + if($.inArray(getSelUiConfigValue(names[1]),supportJTA) >= 0){ + enableThreadAnalysis=true; + } + } + //3 + if(names[2] && names[1] == "log"){ + var nNameIShow = "指定日志:"+names[2]; + sb.append( '
'); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + }else if(names[1] == "log"){ + sb.append( '
'); + }else if(names[2]){ + var nNameIShow = (existsIns?"实例组:":"实例:")+names[2]; + sb.append( '
'); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + }else{ + sb.append( '
'); + } + + if(names[2] && isOwner){ + sb.append( "
'); + }else if(names[2] && !isOwner){ + sb.append( "
'); + }else if(isOwner){ + sb.append( "
'); + }else{ + sb.append( "
'); + } + + + sb.append( '
'); + if(isOwner){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + /** + * 初始化条件 begin + */ + sb.append( '
'); + sb.append( '
'); + sb.append( '条件定义'); + sb.append( '
'); + $.each(jsonObj.conditions,function(index,obj){ + if(obj.func && obj.func.indexOf("count>")>-1){ + obj.cparam = obj.func.substr(6); + obj.func = "count"; + } + + if(!obj.id){ + /** + * 兼容老数据 + */ + obj.id=StgyClass.randomId()+"_stgySpan"; + } + var html; + if(isOwner){ + html = '
'+StgyClass.formatShowWhere(obj)+'
'; + }else{ + html = '
'+StgyClass.formatShowWhere(obj)+'
'; + } + sb.append( html); + }); + sb.append( '
'); + sb.append( '
'); + /** + * 初始化条件 end + */ + + /** + * 初始化触发策略 begin + */ + sb.append( '
'); + + if(isOwner){ + sb.append( '
触发策略
'); + }else{ + sb.append( '
触发策略
'); + } + + if(jsonObj.relationsHtmls){ + $.each(jsonObj.relationsHtmls,function(index,html){ + var convergenceVal = ""; + if(jsonObj.hasOwnProperty("convergences")){ + convergenceVal = jsonObj.convergences[index]; + } + + var appendHtml = + '
'+ + '
'+ + '
'+html+'
'+ + '
'+convergenceVal+'
'+ + '
'; + + if(isOwner){ + appendHtml+=''; + }else{ + appendHtml+=''; + } + appendHtml+='
'+ + '
'+ + '
'; + sb.append(appendHtml); + }); + } + sb.append( '
'); + /** + * 初始化触发策略 begin + */ + + sb.append( '
'); + sb.append( '
触发动作
'); + var actionSum = 0; + initActionDiv(isOwner?"true":"false"); + if (jsonObj.action!=undefined) { + $.each(jsonObj.action,function(index,value){ + actionSum++; + var josnSpan ={ + "type":index, + "value":value + } + + var html ; + + if(isOwner){ + if("threadanalysis" == josnSpan.type){ + var html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + }else{ + html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + } + }else{ + html = '
'+josnSpan.type+''+JSON.stringify(josnSpan)+'
'; + } + sb.append( '
'); + sb.append( html); + sb.append( '
'); + + /** + * 计算下拉选项 + */ + $("#actionTypeSel option[value="+josnSpan.type+"]").remove(); + + }); + } + sb.append( '
'); + /** + * 初始化触发动作 end + */ + + if(isOwner){ + //按钮 + sb.append( '
'); + sb.append( '
'); + sb.append( '
 
'); + } + + sb.append( '
'); + /** + * 所有渲染内容 div end + */ + sb.append( ""); + HtmlHelper.id("objectDiv").innerHTML = sb.toString(); + + /** + * 判断出发条件:不是归属者不能添加 + */ + if(!isOwner){ + $("#whereAddButton").attr("class","well-add"); + $("#whereAddButton").click(function(){}); + } + /** + * 判断触发动作按钮 begin(类型都已经存在值,则不能再添加) + * 不是归属者也不能添加 + */ + var selTypeSize = $("#actionTypeSel option").size(); + if(selTypeSize == 0 || !isOwner){ + $("#actionAddButton").attr("class","well-add"); + $("#actionAddButton").click(function(){}); + } + /** + * 判断触发动作按钮 end + */ + window.winmgr.hide("notifyList"); + window.winmgr.show("objectDiv"); + + hideShowConStgy(names[1]); +} + + + +/** + * 触发动作添加窗口 + */ +function initActionDiv(isOwner) { + + var old = document.getElementById("actionDiv"); + if(old){ + var node = old.parentNode; + node.removeChild(old); + } + + var sb=new StringBuffer(); + + sb.append(''); + var div = document.createElement('div'); + div.innerHTML = sb.toString(); + document.body.appendChild(div); +} + +/** + * 显示添加条件窗口 + * @param thisObj + * @param type + */ +function showCon(thisObj,type){ + actionConf.actionObj=thisObj.parentNode; + if(selUiConf["userInput"]["notifyNameM"]=="log"){ + $("#condType").attr("disabled","disabled"); + } + $("#pageType").val(type); + if("EDIT" == type){ + var jsonValue = JSON.parse(thisObj.parentNode.getElementsByTagName("span")[0].textContent); + $("#condType").attr("disabled","disabled"); + var isOwner = $("#isOwner").val(); + if(!jsonValue.type||jsonValue.type=="stream"){ + $("#condType").val("stream"); + $("#contExpr").val(jsonValue.expr); + $("#conRange").val(jsonValue.range); + $("#conFunc").val((null == jsonValue.func?0:jsonValue.func)); + if("count" == jsonValue.func){ + $("#conFuncParam").val(jsonValue.cparam); + $("#conFuncParam").show(); + } + //不是归属用户,则只读 + if(isOwner!="true"){ + $("#whereSaveButton").hide(); + $("#contExpr").attr("readonly","readonly"); + $("#conRange").attr("readonly","readonly"); + $("#conFunc").attr("disabled","disabled"); + $("#conFuncParam").attr("readonly","readonly"); + + //只读CSS + $("#contExpr").attr("class","form-control"); + $("#conRange").attr("class","form-control"); + $("#conFuncParam").attr("class","form-control"); + $("#whereSaveButton").hide(); + } + + }else{ + var type; + if(jsonValue.interval){ + type="link-relative"; + }else{ + type="base-relative"; + } + $("#condType").val(type); + typeChangeShow(type); + + var hour=jsonValue.time_from.split(':')[0]; + var min=jsonValue.time_from.split(':')[1]; + $('#time_from_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + hour=jsonValue.time_to.split(':')[0]; + min=jsonValue.time_to.split(':')[1]; + $('#time_to_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + + if(jsonValue.time_start!=undefined&&jsonValue.time_end!=undefined){ + hour=jsonValue.time_start.split(':')[0]; + min=jsonValue.time_start.split(':')[1]; + $('#time_start_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + hour=jsonValue.time_end.split(':')[0]; + min=jsonValue.time_end.split(':')[1]; + $('#time_end_div').data('datetimepicker').setLocalDate(new Date(2000, 1, 1, hour, min)); + } + + if(jsonValue.day_start!=undefined&&jsonValue.day_end!=undefined){ + var year=jsonValue.day_start.split('-')[0]; + var month=jsonValue.day_start.split('-')[1]; + var day=jsonValue.day_start.split('-')[2]; + $('#day_start_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); + year=jsonValue.day_end.split('-')[0]; + month=jsonValue.day_end.split('-')[1]; + day=jsonValue.day_end.split('-')[2]; + $('#day_end_div').data('datetimepicker').setLocalDate(new Date(year, month-1, day, 0, 0)); + } + + showWeekDay(jsonValue.weekdayLimit); + + $("#conMetric").val(jsonValue.metric); + $("#conUpperLimit").val(jsonValue.upperLimit); + $("#conLowerLimit").val(jsonValue.lowerLimit); + $("#conAggr").val(jsonValue.aggr); + $("#conDownSample").val(jsonValue.downsample); + if(type=="link-relative"){ + $("#conInterval").val(jsonValue.interval); + } + showUnit(jsonValue.unit); + + if(isOwner!="true"){ + $("#time_from").attr("readonly","readonly"); + $("#time_to").attr("readonly","readonly"); + $("#time_start").attr("readonly","readonly"); + $("#time_end").attr("readonly","readonly"); + $("#day_start").attr("readonly","readonly"); + $("#day_end").attr("readonly","readonly"); + $("#conMetric").attr("readonly","readonly"); + $("#conUpperLimit").attr("readonly","readonly"); + $("#conLowerLimit").attr("readonly","readonly"); + $("#conMetric").attr("class","form-control"); + $("#conUpperLimit").attr("class","form-control"); + $("#conLowerLimit").attr("class","form-control"); + $("#conAggr").attr("disabled","disabled"); + $("#conDownSample").attr("disabled","disabled"); + if(type=="link-relative"){ + $("#conInterval").attr("readonly","readonly"); + $("#conInterval").attr("class","form-control"); + } + $("#whereSaveButton").hide(); + } + } + + } + +} + +function showUnit(unit){ + $("#unit").val(unit); + $("#opt"+unit).attr("class","btn btn-default active"); +} + +function showWeekDay(weekdayLimit){ + + for(var i=0;i"); + sb.append("条件定义"); + sb.append("
"); + sb.append("
"); + sb.append( "
'); + + sb.append( '
'); + /** + * 普通预警条件编辑 + */ + sb.append( '
'); + + sb.append( '
触发表达式

'); + sb.append( '
持续时间(秒)

'); + sb.append( "
聚集操作

'); + sb.append( ')\" style="display:none" onkeyup="this.value=this.value.replace(\/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(\/\\D/g,\'\')">
'); + sb.append( '
'); + + /** + * 同环比预警条件编辑 + */ + sb.append( ''); + sb.append( ''); + + /** + * 保存按钮 + */ + sb.append( '
'); + sb.append( ''); + sb.append( ''); + sb.append( '
'); + + HtmlHelper.id("condDiv").innerHTML = sb.toString(); + initTimeControl(); + showCon(thisObj,type); + window.winmgr.hide("objectDiv"); + window.winmgr.show("condDiv"); + +} + +function funcChangeShow(thisObj,showId){ + if("count" == thisObj.value){ + $("#"+showId).show(); + }else{ + $("#"+showId).hide(); + } +} + +function typeChangeShow(type){ + var divs=["stream","timer","link-relative","base-relative"]; + divs.forEach(div=>{ + $("#"+div).hide(); + }) + if("stream"!=type){ + $("#timer").show(); + } + $("#"+type).show(); + +} +/** + * 初始化时间控件 + */ +function initTimeControl(){ + $('#time_from_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + + $('#time_to_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + $('#time_start_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + + $('#time_end_div').datetimepicker({ + pickDate: false, + pickSeconds: false + }); + + $('#day_start_div').datetimepicker({ + pickHour: false, + pickMin: false, + pickSeconds: false + }); + + + $('#day_end_div').datetimepicker({ + pickHour: false, + pickMin: false, + pickSeconds: false + }); + + +} + +function changeTimeUnit(value){ + $("#unit").val(value); +} + + + +function actionChangeShow(type){ + if("ADD" == type){ + if("threadanalysis" == $("#actionTypeSel").val()){ + $("textarea[name='actionValue']").val("10101").hide(); + $(".btn-addPriority").hide(); + }else{ + $("textarea[name='actionValue']").val("").show(); + $(".btn-addPriority").show(); + } + }else{ + $("textarea[name='actionValue']").show(); + $(".btn-addPriority").show(); + } +} + +function selServerChangeShow(type,value,text){ + var selId = type+"_notifyNameF"; + $("#"+selId).html(text); + $("#"+selId).css("padding-left","2px"); + $("#"+type+"_notifyNameF").css("color","black"); + + hideShowConStgy("show"); + + if(text == "自定义指标"){ + $("#"+type+"_appName_div").hide(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); + selUiConf["userInput"]["notifyNameF"]=value; + selUiConf["userInput"]["notifyNameM"]="jvm"; + $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + }else if(value=="log"){ + $("#"+type+"_appName_div").show(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv defNone"); + $("#notifyNameI").attr("placeholder","输入指定日志"); + selUiConf["userInput"]["notifyNameF"]=""; + selUiConf["userInput"]["notifyNameM"]=value; + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + }else{ + $("#"+type+"_appName_div").hide(); + $("#"+type+"_notifyNameM_div").attr("class","btn-group selectDiv"); + $("#notifyNameI").attr("placeholder","输入监控实例名或者实例组名"); + $("#"+type+"_notifyNameM").css("color","darkgrey"); + $("#"+type+"_notifyNameM").html("选择监控组指标"); + document.getElementById(type+"_notifyNameM_body").innerHTML =""; + $.each(selUiConf[value],function(index,obj){ + var li = document.createElement("li"); + var a = document.createElement("a"); + a.innerHTML=obj[1]; + a.onclick=function(){selIndexChangeShow(type,obj[0],obj[1]);}; + a.href="#"; + li.appendChild(a); + document.getElementById(type+"_notifyNameM_body").appendChild(li); + }); + selUiConf["userInput"]["notifyNameF"]=value; + } + +} + +function removeChoosedJTA(){ + if(HtmlHelper.id("ChoosedJTA") != null){ + HtmlHelper.id("ChoosedJTA").remove(); + } +} + +function changeJTAStat(text){ + if($.inArray(text,supportJTA) >= 0){ + $("#enableThreadAnalysis").val(true); + if(HtmlHelper.id("ChoosedJTA") == null){ + $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); + $("#actionAddButton").click(function(){showAction(this,'ADD')}); + } + }else{ + $("#enableThreadAnalysis").val(false); + removeChoosedJTA(); + } +} + +function hideShowConStgy(value){ + if(value == "procCrash"){ + $("#conFatDiv").hide(); + $("#stgyFatDiv").hide(); + } + else{ + $("#conFatDiv").show(); + $("#stgyFatDiv").show(); + } +} + +function selIndexChangeShow(type,value,text){ + changeJTAStat(text); + hideShowConStgy(value); + + $("#"+type+"_notifyNameM").html(text); + $("#"+type+"_notifyNameM").css("padding-left","2px"); + $("#"+type+"_notifyNameM").css("color","black"); + selUiConf["userInput"]["notifyNameM"]=value; +} + +function appNameChange(obj){ + selUiConf["userInput"]["notifyNameF"]=obj.value; +} +function getSelUiConfigValue(indexValue){ + var result =""; + $.each(selUiConf.keys,function(value,obj1){ + $.each(selUiConf[obj1.key],function(index,obj2){ + if(obj2[0]==indexValue){ + result=obj2[1]; + return false; + } + }); + if(result!==""){ + return false; + } + }); + + return result; +} +function getSelUiConfKeysValue(a, b) { + var result = ""; + if (b == "log") { + result="日志"; + } else if (a == "server" && b == "jvm") { + result="自定义指标"; + } else if (a == "server") { + result="服务端"; + } else if (a == "client") { + result="客户端"; + } + return result; +} +function conditionsAppend(){ + if(checkFunc()){ + var jsonObject; + if("stream"==$("#condType").val()){ + jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; + }else{ + jsonObject = {"type":"timer","time_from":HtmlHelper.inputXSSFilter($("#time_from").val()),"time_to":HtmlHelper.inputXSSFilter($("#time_to").val()),"metric":HtmlHelper.inputXSSFilter($("#conMetric").val()),"upperLimit":HtmlHelper.inputXSSFilter($("#conUpperLimit").val()),"lowerLimit":HtmlHelper.inputXSSFilter($("#conLowerLimit").val())}; + + if(HtmlHelper.inputXSSFilter($("#conAggr").val())!="0"){ + jsonObject["aggr"]=HtmlHelper.inputXSSFilter($("#conAggr").val()); + }else{ + jsonObject["aggr"]="avg"; + } + + if(HtmlHelper.inputXSSFilter($("#conDownSample").val())!="0"){ + jsonObject["downsample"]=HtmlHelper.inputXSSFilter($("#conDownSample").val()); + }else{ + jsonObject["downsample"]="all-avg"; + } + + if("link-relative"==$("#condType").val()){ + jsonObject["interval"]=HtmlHelper.inputXSSFilter($("#conInterval").val()); + jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); + }else{ + jsonObject["unit"]=HtmlHelper.inputXSSFilter($("#unit").val()); + } + + if($("#time_start").val()&&$("#time_end").val()){ + jsonObject["time_start"]=HtmlHelper.inputXSSFilter($("#time_start").val()); + jsonObject["time_end"]=HtmlHelper.inputXSSFilter($("#time_end").val()); + } + + if($("#day_start").val()&&$("#day_end").val()){ + jsonObject["day_start"]=HtmlHelper.inputXSSFilter($("#day_start").val()); + jsonObject["day_end"]=HtmlHelper.inputXSSFilter($("#day_end").val()); + } + + var weekdayLimit=[]; + for(var i=0;i<7;i++){ + weekdayLimit[i]=($("#weekday"+i).attr("class")=="btn btn-default active") + } + jsonObject["weekdayLimit"]=weekdayLimit; + + } + appendConditions(jsonObject); + window.winmgr.hide("condDiv"); + window.winmgr.show("objectDiv"); + } +} + +function checkFunc(){ + + var result = true; + if("stream"==$("#condType").val()){ + if(!$("#contExpr").val()){ + result = false; + }else if("count" == $("#conFunc").val() && !$("#conFuncParam").val()){ + result = false; + } + }else{ + if(!$("#time_from").val()||!$("#time_to").val()||!$("#conMetric").val()||!$("#conUpperLimit").val()||!$("#conLowerLimit").val()){ + result = false; + } + if("link-relative"==$("#condType").val()){ + if(!$("#conInterval").val()||!$("#unit").val()){ + result = false; + } + }else{ + if(!$("#unit").val()){ + result = false; + } + } + } + + + if(result){ + $("#conditionsErrMsg").hide(); + }else{ + $("#conditionsErrMsg").show(); + } + + return result; +} +function appendConditions(jsonObj) { + var type = $("#pageType").val(); + if("ADD"==type){ + var newNode = document.createElement("div"); + var stgyDivId = StgyClass.randomId()+"_stgySpan"; + html = '
'+getHtmlAndSetId(stgyDivId)+'
'; + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + }else if("EDIT"==type){ + var oldId = actionConf.actionObj.getElementsByTagName("span")[0].id; + actionConf.actionObj.innerHTML= getHtmlAndSetId(oldId); + StgyClass.updateWhereToStgyAppend(jsonObj); + } + + function getHtmlAndSetId(stgyDivId){ + jsonObj.id = stgyDivId;//赋值id + var html = StgyClass.formatShowWhere(jsonObj)+''; + return html; + } +} +/** + * 条件窗口操作 end + */ + + +/** + * 触发动作操作 begin + */ +function showAction(thisObj,type){ + actionConf.actionObj=thisObj.parentNode; + checkJTAAction(); + $("#actiontype").val(type); + $.each($("textarea[name='actionValue']"),function(index,obj){ + if(index>0){ + removeActonTextarea(obj); + }else{ + obj.value=""; + } + }); + $("#actionDiv").modal({backdrop: 'static', keyboard: false}); + $("#actionDiv").modal(); + //还原只读 + $("#actionSaveButton").show(); + $("#actionValue").removeAttr("readonly"); + + + if("EDIT"==type){ + //不是归属用户,则只读 + var isOwner = $("#isOwner").val(); + $("#actionTypeSel").hide(); + var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].textContent); + + $.each(spanJson.value,function(index,value){ + /** + * 第一次循环:追加渲染 + */ + if(index>0){ + appendActionTextarea(); + } + }); + var actionTextValues = $("textarea[name='actionValue']"); + $.each(spanJson.value,function(index,value){ + /** + * 第二次循环:赋值 + */ + actionTextValues[index].value=value; + }); + + $("#actionEditType").val(spanJson.type); + + actionChangeShow("EDIT"); + if(isOwner!="true"){ + $("#actionSaveButton").hide(); + } + }else{ + $("#actionTypeSel").show(); + actionChangeShow("ADD"); + } +} + +function checkJTAAction(){ + if($("#enableThreadAnalysis").val() =="true"&& $("#actionTypeSel").find("option[value='threadanalysis']").size() == 0 && $("#ChoosedJTA").size() == 0){ + $("#actionTypeSel").append(""); + } + else if($("#enableThreadAnalysis").val() == "false" && $("#actionTypeSel").find("option[value='threadanalysis']").size() == 1){ + $("#actionTypeSel option[value=threadanalysis]").remove(); + } +} + +function actionAppend(){ + + $("#ActionErrMsg").hide(); + + if(checkAction()){ + appendActions(); + $("#actionDiv").modal('hide'); + }else{ + $("#ActionErrMsg").show(); + } +} + +function appendActionTextarea(thisObj){ + var isOwner = $("#isOwner").val(); + + var html = ''; + if(isOwner == "true"){ + html = ''; + html+= '
'; + }else{ + html = ''; + } + + var newNode = document.createElement("div"); + newNode.innerHTML = html; + document.getElementById("actionBodyDiv").appendChild(newNode); +} +function removeActonTextarea(thisObj){ + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); +} + +function checkAction(){ + var actionTextValues = $("textarea[name='actionValue']"); + + var checkValue = $.trim(actionTextValues[0].value); //只校验第一个必须输入 + var type = $("#actiontype").val(); + if("ADD"==type && !checkValue){ + return false; + }else if(!checkValue){ + return false; + } + + var result = false; + var actionValues = new Array(); + $.each(actionTextValues,function(index,obj){ + var values = format(obj.value); + obj.value = values; + if(values!=""){ + actionValues.push(values); + result = true; + } + }); + + if(!result){ + $("#ActionErrMsg").show(); + } + + return result; + + function format(_values){ + var result = new Array(); + var values = _values.split(","); + $.each(values,function(index,value){ + value = $.trim(value); + if(value!=""){ + result.push(value); + } + }); + + if(!result || result.length==0){ + return ""; + }else{ + return result.join(","); + } + } +} + +function appendActions() { + var type = $("#actiontype").val(); + var html = getAppendHtml(type); + + if("threadanalysis" == $("#actionTypeSel").val()){ + $("#enableThreadAnalysis").val(false); + } + if("ADD"==type){ + var newNode = document.createElement("div"); + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + + /** + * 计算下拉菜单:删除当前选项 + */ + $("#actionTypeSel option[value="+$("#actionTypeSel").val()+"]").remove(); + + /** + * 计算是否还有添加类型:添加按钮控制 + */ + var actionTypeSelect = document.getElementById("actionTypeSel"); + if(actionTypeSelect.length == 0){ + $("#actionAddButton").attr("class","well-add"); + $("#actionAddButton").click(function(){}); + } + + + }else if("EDIT"==type){ + actionConf.actionObj.parentNode.innerHTML = html; + } + + function getAppendHtml(){ + var result = new Array(); + var actionTextValues = $("textarea[name='actionValue']"); + $.each(actionTextValues,function(index,obj){ + result.push(obj.value); + }); + + var actionType =""; + if(type=="ADD"){ + actionType = $("#actionTypeSel").val(); + }else if(type=="EDIT"){ + actionType = $("#actionEditType").val(); + } + + var jsonObj = {type:HtmlHelper.inputXSSFilter(actionType),value:HtmlHelper.inputXSSFilter(result)}; + if("threadanalysis" == jsonObj.type){ + var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; + }else{ + var html = '
'+jsonObj.type+''+JSON.stringify(jsonObj)+'
'; + } + return html; + } +} +/** + * 触发动作操作 end + */ + + +function delThisObj(thisObj) { + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); + StgyClass.deleteWhereToStgyAppend(thisObj); +} + +function delThisActionObj(thisObj) { + + /** + * 还原当前选项 + */ + var spanJson = JSON.parse(thisObj.parentNode.getElementsByTagName('span')[0].innerHTML); + if(spanJson.type == "threadanalysis"){ + $("#enableThreadAnalysis").val(true); + } + $('#actionTypeSel').append(""); + $("#actionAddButton").attr("class","glyphicon glyphicon-plus well-add"); + $("#actionAddButton").click(function(){showAction(this,'ADD')}); + /** + * 删除显示 + */ + var node = thisObj.parentNode.parentNode; + node.removeChild(thisObj.parentNode); +} + +function checkNameIShow(){ + if($("#notifyNameI").val()){ + $("#notifyInstances").show(); + }else{ + $("#notifyInstances").val(""); + $("#notifyInstances").hide(); + } + selUiConf["userInput"]["notifyNameI"] = $("#notifyNameI").val(); +} + +function closeObjectDiv() { + window.winmgr.hide("objectDiv"); + window.winmgr.show("notifyList"); +} + +function openHelpDiv() { + window.open("https://uavorg.github.io/documents/uavdoc_useroperation/28.html#%E5%88%9B%E5%BB%BA","apphub.help"); +} + + +/** + * 策略表达式处理类 + */ +var StgyClass = { + datas:{//数据原型 + where:new Array() + }, + initDatas:function(){//初始化数据原型 + StgyClass.datas.where = new Array(); + }, + checkWhereExists : function() { + /** + * 判断条件是否存在 + */ + StgyClass.initDatas(); + var conditions = new Array(), exists = false; + var div = document.getElementById("objectDiv"); + var spans = div.getElementsByTagName("span"); + $.each(spans, function(index, obj) { + if(obj.id && obj.id.indexOf("_stgySpan")>=0){ + exists=true + /** + * 同时将条件数据打包 + */ + StgyClass.datas.where.push(JSON.parse(obj.textContent)); + } + }); + + return exists; + }, + showStgyDiv : function(thisObj,type) { + + var isOwner = $("#isOwner").val(); + /** + * 显示策略编辑(弹出新元素) + */ + actionConf.actionObj=thisObj.parentNode; + + var sb = new StringBuffer(); + sb.append("
"); + sb.append("触发策略"); + sb.append("
"); + sb.append("
"); + + if(StgyClass.checkWhereExists()){ //渲染触发策略页面 + sb.append( '
'); + $.each(StgyClass.datas.where,function(index,data){ + + if(isOwner=="true"){ + sb.append( ''); + }else{ + sb.append( ''); + } + }); + sb.append( '
'); + + + if(isOwner=="true"){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + if(type=="edit"){ + sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[0].innerHTML); + } + sb.append( '
'); + + if(isOwner=="true"){ + sb.append( '
'); + }else{ + sb.append( '
'); + } + + if(type=="edit"){ + sb.append(thisObj.parentNode.parentNode.getElementsByTagName("div")[1].innerHTML); + } + sb.append( '
'); + + if(isOwner=="true"){ + sb.append( '
'); + } + + }else{ + sb.append("
没有可用条件
"); + } + + HtmlHelper.id("stgyDiv").innerHTML = sb.toString(); + window.winmgr.hide("objectDiv"); + window.winmgr.show("stgyDiv"); + + }, + closeStgyDiv : function() { + /** + * 关闭策略编辑(关闭元素) + */ + window.winmgr.hide("stgyDiv"); + window.winmgr.show("objectDiv"); + }, + appendWhereToStgy:function(thisObj) { + /** + * 在策略编辑:将选中条件追加到策略表达式 + */ + var whereId = thisObj.id + "_exp"; + + var html = '  ' + + thisObj.innerText + '  '; + /** + * 必须要focus一下目标元素,不然会跟随光标而追加html内容。 + */ + document.getElementById("stgy_exp").focus(); + var sel = window.getSelection(); + if (sel.getRangeAt && sel.rangeCount) { + var range = sel.getRangeAt(0); + range.deleteContents(); + + var el = document.createElement("div"); + el.innerHTML = html; + var frag = document.createDocumentFragment(), node, lastNode; + while ((node = el.firstChild)) { + lastNode = frag.appendChild(node); + } + range.insertNode(frag); + + // Preserve the selection + if (lastNode) { + range = range.cloneRange(); + range.setStartAfter(lastNode); + range.collapse(true); + sel.removeAllRanges(); + sel.addRange(range); + } + } + }, + saveStgyToAppend : function(type){ + /** + * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 + */ + var html = document.getElementById("stgy_exp").innerHTML; + var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); + + if(html.length>0 && type=="add"){ + html = '
'+ + '
'+html+'
'+ + '
'+htmlConvergence+'
'+ + '
'+ + ''; + '
'+ + '
'; + + var newNode = document.createElement("div"); + newNode.innerHTML = html; + actionConf.actionObj.parentNode.appendChild(newNode); + + }else if(html.length>0 && type=="edit"){ + actionConf.actionObj.parentNode.getElementsByTagName("div")[0].innerHTML = html; + actionConf.actionObj.parentNode.getElementsByTagName("div")[1].innerHTML = htmlConvergence; + } + + StgyClass.closeStgyDiv(); + + }, + deleteStgyToAppend : function(thisObj){ + /** + * 删除策略结果 + */ + var node = thisObj.parentNode.parentNode.parentNode; + node.removeChild(thisObj.parentNode.parentNode); + }, + updateWhereToStgyAppend : function(json){ + /** + *修改策略结果 + */ + var updateId = json.id+"_exp"; + var stgys = $("span[name='"+updateId+"']"); + $.each(stgys,function(index,obj){ + obj.innerHTML = " "+StgyClass.formatShowWhere(json)+" "; + }); + }, + deleteWhereToStgyAppend : function(thisObj){ + /** + * 删除条件时: 给对应策略添加删除线 + */ + var divId = thisObj.parentNode.getElementsByTagName("span")[0].id+"_exp"; + var stgys = $("span[name='"+divId+"']"); + $.each(stgys,function(index,obj){ + obj.className = "whereStgyEdit whereStgyEdit-delete"; + }); + + }, + /** + * 格式化条件,显示格式(除去id不显示) + * + * @param json + * @returns {String} + */ + formatShowWhere : function(json) { + + if(!json){ + return ""; + } + + var result; + + if(!json.type||json.type=="stream"){ + result = json.expr; + + if(json.range && json.range!=""){ + result += ","+json.range; + } + + if(json.func && json.func!=0 && json.func=="count"){ + result += ","+json.func+">"+json.cparam; + }else if(json.func && json.func!=0){ + result += ","+json.func; + } + }else{ + result = json.metric+","+json.time_from+"-"+json.time_to+","+json.downsample+","+json.aggr+","; + if(json.interval){ + result+=json.interval+" "; + + } + switch(json.unit){ + case "6": + result+="min"; + break; + case "5": + result+="hour"; + break; + case "1": + result+="day"; + break; + case "2": + result+="week"; + break; + case "3": + result+="month"; + break; + case "4": + result+="year"; + break; + } + if(json.time_start!=undefined&&json.time_end!=undefined){ + result+=","+json.time_start+"-"+json.time_end; + } + if(json.day_start!=undefined&&json.day_end!=undefined){ + result+=","+json.day_start+"-"+json.day_end; + } + } + + return result; + }, + randomId : function(x, y) { + if (!x) { + x = 9999; + } + if (!y) { + y = 1; + } + var d = [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ]; + + var rand = parseInt(Math.random() * (x - y + 1) + y) + + d[parseInt(Math.random() * d.length + 0)] + + parseInt(Math.random() * 1000) + + d[parseInt(Math.random() * d.length + 0)] + + parseInt(Math.random() * 1000); + return rand; + } } \ No newline at end of file diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java index f5b420c1..b8d163ef 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java @@ -1,562 +1,562 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature.runtimenotify; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.alibaba.fastjson.JSONArray; -import com.creditease.agent.helpers.DateTimeHelper; -import com.creditease.agent.helpers.EncodeHelper; -import com.creditease.agent.helpers.JSONHelper; - -/** - * notify strategy ds - */ -public class NotifyStrategy { - - public enum Type { - STREAM("stream"), TIMER("timer"); - - private String name; - - Type(String name) { - this.name = name; - } - - @Override - public String toString() { - - return name; - } - } - - private static final String[] OPERATORS = { ":=", "!=", ">", "<", "=" }; - - private static final Pattern INDEX_PATTERN = Pattern.compile("\\[\\d+\\]"); - - private Type type; - - private String scope; - - private List condtions; - - private List convergences; - - private String msgTemplate; - - private Map action = Collections.emptyMap(); - - private List context = Collections.emptyList(); - - private List instances = Collections.emptyList(); - - private long maxRange = 0; - - private String name; - - public NotifyStrategy() { - } - - public NotifyStrategy(String name, String scope, List context, Map action, - List instances, String msgTemplate, List convergences) { - this.name = name; - this.scope = scope; - if (context != null && context.size() != 0) { - this.context = context; - } - if (action != null && action.size() != 0) { - this.action = action; - } - if (instances != null && instances.size() != 0) { - this.instances = instances; - } - this.convergences = convergences; - this.msgTemplate = msgTemplate; - } - - public void setConditions(List conditions, List relations) { - - int idx = 0; // expression count - List exprs = new ArrayList<>(); - for (Object o : conditions) { - - // condition is simple string: "arg>123" - if (String.class.isAssignableFrom(o.getClass())) { - Expression expression = new Expression((String) o); - expression.setIdx(idx++); - exprs.add(expression); - } - else { - @SuppressWarnings("unchecked") - Map cond = (Map) o; - Expression expression; - if (cond.get("type") == null || cond.get("type").equals(Type.STREAM.name)) { - String expr = (String) cond.get("expr"); - String func = (String) cond.get("func"); - Long range = cond.get("range") == null ? null : Long.valueOf(cond.get("range").toString()); - Float sampling = cond.get("sampling") == null ? null - : Float.valueOf(cond.get("sampling").toString()); - expression = new Expression(expr, func, range, sampling); - } - else { - String metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); - cond.put("metric", metricPrefix + "." + cond.get("metric")); - expression = new Expression(cond); - this.type = Type.TIMER; - } - expression.setIdx(idx++); - exprs.add(expression); - } - } - - idx = 1; // reuse for condition count, start from 1 - List conds = null; - if (relations == null || relations.isEmpty()) { - conds = new ArrayList<>(conditions.size()); - - for (Expression expr : exprs) { - conds.add(new Condition(idx++, expr)); - } - } - else { - conds = new ArrayList<>(relations.size()); - for (String relation : relations) { - - Matcher m = INDEX_PATTERN.matcher(relation); - Set set = new HashSet<>(); - while (m.find()) { - String idxHolder = m.group(); - int i = Integer.parseInt(idxHolder.substring(1, idxHolder.length() - 1)); - if (i >= exprs.size()) { // IndexOutOfBoundsException - continue; - } - set.add(exprs.get(i)); - relation = relation.replace(idxHolder, "{" + i + "}"); // temp i - } - - List list = new ArrayList<>(set); - for (int i = 0; i < list.size(); i++) { - relation = relation.replace("{" + list.get(i).getIdx() + "}", "[" + i + "]"); - } - conds.add(new Condition(idx++, list, relation)); - } - } - - this.condtions = conds; - - /** init max range */ - for (Condition cond : this.condtions) { - for (Expression expr : cond.expressions) { - maxRange = Math.max(maxRange, expr.range); - } - } - - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static NotifyStrategy parse(String name, String json) { - - Map m = JSONHelper.toObject(json, Map.class); - String scope = (String) m.get("scope"); - List context = (List) m.get("context"); - List conditions = (List) m.get("conditions"); - List relations = (List) m.get("relations"); - List convergences = (List) m.get("convergences"); - Map action = (Map) m.get("action"); - String msgTemplate = (String) m.get("msgTemplate"); - List instances = (List) m.get("instances"); - - NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); - - stra.setConditions(conditions, relations); - - return stra; - } - - public long getMaxRange() { - - return maxRange; - } - - public String getMsgTemplate() { - - return msgTemplate; - } - - public void setMsgTemplate(String msgTemplate) { - - this.msgTemplate = msgTemplate; - } - - public Map getAction() { - - return action; - } - - public void setAction(Map action) { - - this.action = action; - } - - public List getContext() { - - return context; - } - - public void setContext(List context) { - - this.context = context; - } - - public String getScope() { - - return scope; - } - - public void setScope(String scope) { - - this.scope = scope; - } - - public List getInstances() { - - return instances; - } - - public void setInstances(List instances) { - - this.instances = instances; - } - - public String getName() { - - return name; - } - - public Type getType() { - - return type; - } - - public List getCondtions() { - - return condtions; - } - - public List getConvergences() { - - return convergences; - } - - protected static class Expression { - - private int idx; - private Type type; - private String arg; - private String operator; - private String expectedValue; - private long range = 0; - private String func; - private float sampling = 1; - private String downsample; - private Boolean[] weekdayLimit=new Boolean[] {true,true,true,true,true,true,true}; - - private Set matchArgExpr = new HashSet(); - - private long time_from; - private long time_to; - private long interval; - private int unit; - private String upperLimit; - private String lowerLimit; - private String time_end; - private String time_start; - private String day_start; - private String day_end; - - public Expression(String exprStr) { - for (String op : OPERATORS) { - if (exprStr.contains(op)) { - String[] exprs = exprStr.split(op); - this.arg = exprs[0].trim(); - - // suport * as a match - initMatchArgExpr(); - - this.operator = op; - this.expectedValue = exprs[1]; - break; - } - } - this.type = Type.STREAM; - } - - public Expression(String exprStr, String func, Long range, Float sampling) { - this(exprStr); - if (range != null && range > 0) { - this.range = range * 1000; // second to ms - } - this.func = func; - if (sampling != null) { - this.sampling = sampling; - } - - } - - public Expression(Map cond) { - - this.arg = (String) cond.get("metric"); - this.unit = Integer.parseInt((String) cond.get("unit")); - this.time_from = DateTimeHelper - .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_from"), "yyyy-MM-dd HH:mm") - .getTime(); - this.time_to = DateTimeHelper - .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_to"), "yyyy-MM-dd HH:mm") - .getTime(); - - this.time_start=(String) cond.get("time_start"); - - this.time_end= (String) cond.get("time_end"); - - this.day_start=(String) cond.get("day_start"); - - this.day_end= (String) cond.get("day_end"); - - if(cond.containsKey("weekdayLimit")) { - ((JSONArray)cond.get("weekdayLimit")).toArray(this.weekdayLimit); - } - - if (cond.get("interval") != null) { - long interval = Long.parseLong((String) cond.get("interval")); - switch (unit) { - case DateTimeHelper.INTERVAL_DAY: - interval = interval * 24 * 3600 * 1000; - break; - case DateTimeHelper.INTERVAL_HOUR: - interval = interval * 3600 * 1000; - break; - case DateTimeHelper.INTERVAL_MINUTE: - interval = interval * 60000; - break; - } - this.interval = interval; - } - - this.upperLimit = (String) cond.get("upperLimit"); - this.lowerLimit = (String) cond.get("lowerLimit"); - this.func = (String) cond.get("aggr"); - this.downsample=(String) cond.get("downsample"); - this.type = Type.TIMER; - } - - private void initMatchArgExpr() { - - if (this.arg.indexOf("*") > -1) { - String[] tmps = this.arg.split("\\*"); - for (String tmp : tmps) { - matchArgExpr.add(tmp); - } - } - } - - public boolean isMatchExpr() { - - return matchArgExpr.size() > 0; - } - - public Set matchTargetArgs(Set srcArgs) { - - Set targetArgs = new HashSet(); - - for (String arg : srcArgs) { - - int matchCount = 0; - for (String matchField : this.matchArgExpr) { - - if (arg.indexOf(matchField) > -1) { - matchCount++; - } - } - - if (matchCount == this.matchArgExpr.size()) { - targetArgs.add(arg); - } - } - - return targetArgs; - } - - public String getHashCode() { - - return EncodeHelper.encodeMD5(arg + func + lowerLimit + upperLimit + time_from + time_to + interval + unit); - } - - public String getArg() { - - return arg; - } - - public String getOperator() { - - return operator; - } - - public String getExpectedValue() { - - return expectedValue; - } - - public long getRange() { - - return range; - } - - public String getFunc() { - - return func; - } - - public float getSampling() { - - return sampling; - } - - public int getIdx() { - - return idx; - } - - public Type getType() { - - return type; - } - - public long getTime_from() { - - return time_from; - } - - public long getTime_to() { - - return time_to; - } - - public long getInterval() { - - return interval; - } - - public String getUpperLimit() { - - return upperLimit; - } - - public String getLowerLimit() { - - return lowerLimit; - } - - public int getUnit() { - - return unit; - } - - public void setIdx(int idx) { - - this.idx = idx; - } - - public String getTime_end() { - - return time_end; - } - - public String getTime_start() { - - return time_start; - } - - public String getDownsample() { - - return downsample; - } - - public String getDay_start() { - - return day_start; - } - - public String getDay_end() { - - return day_end; - } - - public Boolean[] getWeekdayLimit() { - - return weekdayLimit; - } - - } - - protected class Condition { - - private int index; - private List expressions; - private String relation; - - public Condition(int index, Expression expr) { - this.index = index; - List exprs = new ArrayList<>(1); - exprs.add(expr); - this.expressions = exprs; - } - - public Condition(int index, List exprs, String relation) { - this.index = index; - this.expressions = exprs; - this.relation = relation; - } - - public int getIndex() { - - return index; - } - - public List getExpressions() { - - return expressions; - } - - public String getRelation() { - - return relation; - } - - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.alibaba.fastjson.JSONArray; +import com.creditease.agent.helpers.DateTimeHelper; +import com.creditease.agent.helpers.EncodeHelper; +import com.creditease.agent.helpers.JSONHelper; + +/** + * notify strategy ds + */ +public class NotifyStrategy { + + public enum Type { + STREAM("stream"), TIMER("timer"); + + private String name; + + Type(String name) { + this.name = name; + } + + @Override + public String toString() { + + return name; + } + } + + private static final String[] OPERATORS = { ":=", "!=", ">", "<", "=" }; + + private static final Pattern INDEX_PATTERN = Pattern.compile("\\[\\d+\\]"); + + private Type type; + + private String scope; + + private List condtions; + + private List convergences; + + private String msgTemplate; + + private Map action = Collections.emptyMap(); + + private List context = Collections.emptyList(); + + private List instances = Collections.emptyList(); + + private long maxRange = 0; + + private String name; + + public NotifyStrategy() { + } + + public NotifyStrategy(String name, String scope, List context, Map action, + List instances, String msgTemplate, List convergences) { + this.name = name; + this.scope = scope; + if (context != null && context.size() != 0) { + this.context = context; + } + if (action != null && action.size() != 0) { + this.action = action; + } + if (instances != null && instances.size() != 0) { + this.instances = instances; + } + this.convergences = convergences; + this.msgTemplate = msgTemplate; + } + + public void setConditions(List conditions, List relations) { + + int idx = 0; // expression count + List exprs = new ArrayList<>(); + for (Object o : conditions) { + + // condition is simple string: "arg>123" + if (String.class.isAssignableFrom(o.getClass())) { + Expression expression = new Expression((String) o); + expression.setIdx(idx++); + exprs.add(expression); + } + else { + @SuppressWarnings("unchecked") + Map cond = (Map) o; + Expression expression; + if (cond.get("type") == null || cond.get("type").equals(Type.STREAM.name)) { + String expr = (String) cond.get("expr"); + String func = (String) cond.get("func"); + Long range = cond.get("range") == null ? null : Long.valueOf(cond.get("range").toString()); + Float sampling = cond.get("sampling") == null ? null + : Float.valueOf(cond.get("sampling").toString()); + expression = new Expression(expr, func, range, sampling); + } + else { + String metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); + cond.put("metric", metricPrefix + "." + cond.get("metric")); + expression = new Expression(cond); + this.type = Type.TIMER; + } + expression.setIdx(idx++); + exprs.add(expression); + } + } + + idx = 1; // reuse for condition count, start from 1 + List conds = null; + if (relations == null || relations.isEmpty()) { + conds = new ArrayList<>(conditions.size()); + + for (Expression expr : exprs) { + conds.add(new Condition(idx++, expr)); + } + } + else { + conds = new ArrayList<>(relations.size()); + for (String relation : relations) { + + Matcher m = INDEX_PATTERN.matcher(relation); + Set set = new HashSet<>(); + while (m.find()) { + String idxHolder = m.group(); + int i = Integer.parseInt(idxHolder.substring(1, idxHolder.length() - 1)); + if (i >= exprs.size()) { // IndexOutOfBoundsException + continue; + } + set.add(exprs.get(i)); + relation = relation.replace(idxHolder, "{" + i + "}"); // temp i + } + + List list = new ArrayList<>(set); + for (int i = 0; i < list.size(); i++) { + relation = relation.replace("{" + list.get(i).getIdx() + "}", "[" + i + "]"); + } + conds.add(new Condition(idx++, list, relation)); + } + } + + this.condtions = conds; + + /** init max range */ + for (Condition cond : this.condtions) { + for (Expression expr : cond.expressions) { + maxRange = Math.max(maxRange, expr.range); + } + } + + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static NotifyStrategy parse(String name, String json) { + + Map m = JSONHelper.toObject(json, Map.class); + String scope = (String) m.get("scope"); + List context = (List) m.get("context"); + List conditions = (List) m.get("conditions"); + List relations = (List) m.get("relations"); + List convergences = (List) m.get("convergences"); + Map action = (Map) m.get("action"); + String msgTemplate = (String) m.get("msgTemplate"); + List instances = (List) m.get("instances"); + + NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); + + stra.setConditions(conditions, relations); + + return stra; + } + + public long getMaxRange() { + + return maxRange; + } + + public String getMsgTemplate() { + + return msgTemplate; + } + + public void setMsgTemplate(String msgTemplate) { + + this.msgTemplate = msgTemplate; + } + + public Map getAction() { + + return action; + } + + public void setAction(Map action) { + + this.action = action; + } + + public List getContext() { + + return context; + } + + public void setContext(List context) { + + this.context = context; + } + + public String getScope() { + + return scope; + } + + public void setScope(String scope) { + + this.scope = scope; + } + + public List getInstances() { + + return instances; + } + + public void setInstances(List instances) { + + this.instances = instances; + } + + public String getName() { + + return name; + } + + public Type getType() { + + return type; + } + + public List getCondtions() { + + return condtions; + } + + public List getConvergences() { + + return convergences; + } + + protected static class Expression { + + private int idx; + private Type type; + private String arg; + private String operator; + private String expectedValue; + private long range = 0; + private String func; + private float sampling = 1; + private String downsample; + private Boolean[] weekdayLimit=new Boolean[] {true,true,true,true,true,true,true}; + + private Set matchArgExpr = new HashSet(); + + private long time_from; + private long time_to; + private long interval; + private int unit; + private String upperLimit; + private String lowerLimit; + private String time_end; + private String time_start; + private String day_start; + private String day_end; + + public Expression(String exprStr) { + for (String op : OPERATORS) { + if (exprStr.contains(op)) { + String[] exprs = exprStr.split(op); + this.arg = exprs[0].trim(); + + // suport * as a match + initMatchArgExpr(); + + this.operator = op; + this.expectedValue = exprs[1]; + break; + } + } + this.type = Type.STREAM; + } + + public Expression(String exprStr, String func, Long range, Float sampling) { + this(exprStr); + if (range != null && range > 0) { + this.range = range * 1000; // second to ms + } + this.func = func; + if (sampling != null) { + this.sampling = sampling; + } + + } + + public Expression(Map cond) { + + this.arg = (String) cond.get("metric"); + this.unit = Integer.parseInt((String) cond.get("unit")); + this.time_from = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_from"), "yyyy-MM-dd HH:mm") + .getTime(); + this.time_to = DateTimeHelper + .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_to"), "yyyy-MM-dd HH:mm") + .getTime(); + + this.time_start=(String) cond.get("time_start"); + + this.time_end= (String) cond.get("time_end"); + + this.day_start=(String) cond.get("day_start"); + + this.day_end= (String) cond.get("day_end"); + + if(cond.containsKey("weekdayLimit")) { + ((JSONArray)cond.get("weekdayLimit")).toArray(this.weekdayLimit); + } + + if (cond.get("interval") != null) { + long interval = Long.parseLong((String) cond.get("interval")); + switch (unit) { + case DateTimeHelper.INTERVAL_DAY: + interval = interval * 24 * 3600 * 1000; + break; + case DateTimeHelper.INTERVAL_HOUR: + interval = interval * 3600 * 1000; + break; + case DateTimeHelper.INTERVAL_MINUTE: + interval = interval * 60000; + break; + } + this.interval = interval; + } + + this.upperLimit = (String) cond.get("upperLimit"); + this.lowerLimit = (String) cond.get("lowerLimit"); + this.func = (String) cond.get("aggr"); + this.downsample=(String) cond.get("downsample"); + this.type = Type.TIMER; + } + + private void initMatchArgExpr() { + + if (this.arg.indexOf("*") > -1) { + String[] tmps = this.arg.split("\\*"); + for (String tmp : tmps) { + matchArgExpr.add(tmp); + } + } + } + + public boolean isMatchExpr() { + + return matchArgExpr.size() > 0; + } + + public Set matchTargetArgs(Set srcArgs) { + + Set targetArgs = new HashSet(); + + for (String arg : srcArgs) { + + int matchCount = 0; + for (String matchField : this.matchArgExpr) { + + if (arg.indexOf(matchField) > -1) { + matchCount++; + } + } + + if (matchCount == this.matchArgExpr.size()) { + targetArgs.add(arg); + } + } + + return targetArgs; + } + + public String getHashCode() { + + return EncodeHelper.encodeMD5(arg + func + lowerLimit + upperLimit + time_from + time_to + interval + unit); + } + + public String getArg() { + + return arg; + } + + public String getOperator() { + + return operator; + } + + public String getExpectedValue() { + + return expectedValue; + } + + public long getRange() { + + return range; + } + + public String getFunc() { + + return func; + } + + public float getSampling() { + + return sampling; + } + + public int getIdx() { + + return idx; + } + + public Type getType() { + + return type; + } + + public long getTime_from() { + + return time_from; + } + + public long getTime_to() { + + return time_to; + } + + public long getInterval() { + + return interval; + } + + public String getUpperLimit() { + + return upperLimit; + } + + public String getLowerLimit() { + + return lowerLimit; + } + + public int getUnit() { + + return unit; + } + + public void setIdx(int idx) { + + this.idx = idx; + } + + public String getTime_end() { + + return time_end; + } + + public String getTime_start() { + + return time_start; + } + + public String getDownsample() { + + return downsample; + } + + public String getDay_start() { + + return day_start; + } + + public String getDay_end() { + + return day_end; + } + + public Boolean[] getWeekdayLimit() { + + return weekdayLimit; + } + + } + + protected class Condition { + + private int index; + private List expressions; + private String relation; + + public Condition(int index, Expression expr) { + this.index = index; + List exprs = new ArrayList<>(1); + exprs.add(expr); + this.expressions = exprs; + } + + public Condition(int index, List exprs, String relation) { + this.index = index; + this.expressions = exprs; + this.relation = relation; + } + + public int getIndex() { + + return index; + } + + public List getExpressions() { + + return expressions; + } + + public String getRelation() { + + return relation; + } + + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java index 08c91657..3497b89e 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java @@ -1,259 +1,259 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.feature.runtimenotify.task; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.creditease.agent.helpers.JSONHelper; -import com.creditease.agent.helpers.NetworkHelper; -import com.creditease.agent.helpers.StringHelper; -import com.creditease.agent.monitor.api.NotificationEvent; -import com.creditease.uav.cache.api.CacheManager; -import com.creditease.uav.cache.api.CacheManager.CacheLock; -import com.creditease.uav.feature.RuntimeNotifyCatcher; -import com.creditease.uav.feature.runtimenotify.NotifyStrategy; -import com.creditease.uav.feature.runtimenotify.Slice; -import com.creditease.uav.feature.runtimenotify.StrategyJudgement; -import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; - -public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { - - private NotifyStrategy stra; - private long taskStart = System.currentTimeMillis(); - private long judge_time; - private static final String LOCK_REGION = "lock.region.uav"; - private static final long LOCK_TIMEOUT = 60 * 1000; - private CacheManager cm; - - public JudgeNotifyTimerTask(String name, String feature, long judge_time, NotifyStrategy stra) { - super(name, feature); - this.stra = stra; - this.judge_time = judge_time - judge_time % 60000; - cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); - } - - @Override - public void run() { - - CacheLock lock = null; - try { - lock = cm.newCacheLock(LOCK_REGION, stra.getName(), LOCK_TIMEOUT); - - if (!lock.getLock()) { - return; - } - /** - * Step 1:find out instance - */ - for (String instance : stra.getInstances()) { - /** - * Step 2: judge the strategy - */ - - StrategyJudgement judgement = (StrategyJudgement) getConfigManager().getComponent(feature, - "StrategyJudgement"); - - Slice slice = new Slice(instance, judge_time); - Map args = new HashMap(); - // 标识该slice由TimerTask创建,为同环比创建,非流式计算创建 - args.put("creater", "timer"); - slice.setArgs(args); - - Map result = judgement.judge(slice, stra, null); - - /** - * Step 3: if fire the event, build notification event - */ - if (result != null && !result.isEmpty()) { - NotificationEvent event = this.newNotificationEvent(instance, result, stra.getConvergences()); - - // get context - putContext(slice,event); - - // get action - putNotifyAction(event, stra); - - // get msg tempalte - putNotifyMsg(event, stra); - - if (this.log.isTraceEnable()) { - this.log.info(this, "RuntimeNotify Notification Event Happen: event=" + event.toJSONString()); - } - - this.putNotificationEvent(event); - } - } - - } - catch (Exception e) { - log.err(this, "JudgeNotifyTimerTask" + stra.getName() + " RUN FAIL.", e); - } - finally { - if (lock != null && lock.isLockInHand()) { - lock.releaseLock(); - } - } - - if (log.isDebugEnable()) { - long cost = System.currentTimeMillis() - taskStart; - String detail = cost < 10 ? "" : " detail:strategy=" + JSONHelper.toString(stra); - log.debug(this, "whole task lifecycle COST: (" + cost + ")ms" + detail); - } - } - - /** - * get context - * - * TODO: we need support context param in strategy - */ - private void putContext(Slice slice, NotificationEvent event) { - - Map args = slice.getArgs(); - - for (String key : args.keySet()) { - - Object argVal = args.get(key); - - String jsonstr = JSONHelper.toString(argVal); - - event.addArg(key, jsonstr); - } - } - - /** - * newNotificationEvent - * - * - * @return - */ - private NotificationEvent newNotificationEvent(String instance, Map result, List convergences) { - - String ip = instance; - String host = instance; - String appgroup = "UNKNOWN"; - - instance = formatInstance(instance); - - Map infos = getInfoFromSliceCache(instance); - if (infos != null) { - ip = String.valueOf(infos.get("ip")); - host = String.valueOf(infos.get("host")); - appgroup = String.valueOf(infos.get("appgroup")); - } - - StringBuilder desc = new StringBuilder(); - List conditionIndex = new ArrayList(); - - for (Map.Entry cause : result.entrySet()) { - // description - desc.append(instance + "触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); - // condition index - conditionIndex.add(cause.getKey()); - } - - String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号: " + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; - - // fix  (\u00A0) can be shown in email - String description = desc.toString().replace('\u00A0', ' '); - - NotificationEvent ne = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_THRESHOLD, title, description, - judge_time, ip, host); - - // add appgroup - ne.addArg("appgroup", appgroup); - - // 兼容不存在convergences属性的旧预警策略 - if(convergences == null || convergences.size() == 0 ) { - return ne; - } - - // 同一个Event由多个策略触发时,梯度收敛以最长的为准 - String conv = obtainConvergenceForEvent(convergences, conditionIndex); - if(!StringHelper.isEmpty(conv)) { - ne.addArg("convergences", conv); - ne.addArg(NotificationEvent.EVENT_Tag_NoBlock, "true"); - } - - return ne; - } - - private String formatInstance(String instance) { - - if (NetworkHelper.isIPV4(instance)) { - instance += "_"; - } - instance = stra.getName().substring(0, stra.getName().lastIndexOf('@') + 1) + instance; - - return instance; - } - - private Map getInfoFromSliceCache(String instance) { - - String cacheKey = "SLICE_" + instance + "_"; - for (int index = 0; index < 60; index++) { - String result = cm.lpop(RuntimeNotifyStrategyMgr.UAV_CACHE_REGION, cacheKey + index); - if (result != null) { - Slice s = new Slice(result); - return s.getArgs(); - } - } - - return null; - } - - private void putNotifyAction(NotificationEvent event, NotifyStrategy stra) { - - Map actions = stra.getAction(); - if (actions == null || actions.isEmpty()) { - return; - } - - for (Entry act : actions.entrySet()) { - event.addArg("action_" + act.getKey(), act.getValue()); - } - } - - private void putNotifyMsg(NotificationEvent event, NotifyStrategy stra) { - - String msgTemplate = stra.getMsgTemplate(); - String msg = makeMsgByTemplate(msgTemplate, stra); - - if (msg != null) { - event.addArg("msg", msg); - } - } - - /** - * - * @param template - * @param slice - * @return - */ - private String makeMsgByTemplate(String template, NotifyStrategy stra) { - - return ""; - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.task; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.creditease.agent.helpers.JSONHelper; +import com.creditease.agent.helpers.NetworkHelper; +import com.creditease.agent.helpers.StringHelper; +import com.creditease.agent.monitor.api.NotificationEvent; +import com.creditease.uav.cache.api.CacheManager; +import com.creditease.uav.cache.api.CacheManager.CacheLock; +import com.creditease.uav.feature.RuntimeNotifyCatcher; +import com.creditease.uav.feature.runtimenotify.NotifyStrategy; +import com.creditease.uav.feature.runtimenotify.Slice; +import com.creditease.uav.feature.runtimenotify.StrategyJudgement; +import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; + +public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { + + private NotifyStrategy stra; + private long taskStart = System.currentTimeMillis(); + private long judge_time; + private static final String LOCK_REGION = "lock.region.uav"; + private static final long LOCK_TIMEOUT = 60 * 1000; + private CacheManager cm; + + public JudgeNotifyTimerTask(String name, String feature, long judge_time, NotifyStrategy stra) { + super(name, feature); + this.stra = stra; + this.judge_time = judge_time - judge_time % 60000; + cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); + } + + @Override + public void run() { + + CacheLock lock = null; + try { + lock = cm.newCacheLock(LOCK_REGION, stra.getName(), LOCK_TIMEOUT); + + if (!lock.getLock()) { + return; + } + /** + * Step 1:find out instance + */ + for (String instance : stra.getInstances()) { + /** + * Step 2: judge the strategy + */ + + StrategyJudgement judgement = (StrategyJudgement) getConfigManager().getComponent(feature, + "StrategyJudgement"); + + Slice slice = new Slice(instance, judge_time); + Map args = new HashMap(); + // 标识该slice由TimerTask创建,为同环比创建,非流式计算创建 + args.put("creater", "timer"); + slice.setArgs(args); + + Map result = judgement.judge(slice, stra, null); + + /** + * Step 3: if fire the event, build notification event + */ + if (result != null && !result.isEmpty()) { + NotificationEvent event = this.newNotificationEvent(instance, result, stra.getConvergences()); + + // get context + putContext(slice,event); + + // get action + putNotifyAction(event, stra); + + // get msg tempalte + putNotifyMsg(event, stra); + + if (this.log.isTraceEnable()) { + this.log.info(this, "RuntimeNotify Notification Event Happen: event=" + event.toJSONString()); + } + + this.putNotificationEvent(event); + } + } + + } + catch (Exception e) { + log.err(this, "JudgeNotifyTimerTask" + stra.getName() + " RUN FAIL.", e); + } + finally { + if (lock != null && lock.isLockInHand()) { + lock.releaseLock(); + } + } + + if (log.isDebugEnable()) { + long cost = System.currentTimeMillis() - taskStart; + String detail = cost < 10 ? "" : " detail:strategy=" + JSONHelper.toString(stra); + log.debug(this, "whole task lifecycle COST: (" + cost + ")ms" + detail); + } + } + + /** + * get context + * + * TODO: we need support context param in strategy + */ + private void putContext(Slice slice, NotificationEvent event) { + + Map args = slice.getArgs(); + + for (String key : args.keySet()) { + + Object argVal = args.get(key); + + String jsonstr = JSONHelper.toString(argVal); + + event.addArg(key, jsonstr); + } + } + + /** + * newNotificationEvent + * + * + * @return + */ + private NotificationEvent newNotificationEvent(String instance, Map result, List convergences) { + + String ip = instance; + String host = instance; + String appgroup = "UNKNOWN"; + + instance = formatInstance(instance); + + Map infos = getInfoFromSliceCache(instance); + if (infos != null) { + ip = String.valueOf(infos.get("ip")); + host = String.valueOf(infos.get("host")); + appgroup = String.valueOf(infos.get("appgroup")); + } + + StringBuilder desc = new StringBuilder(); + List conditionIndex = new ArrayList(); + + for (Map.Entry cause : result.entrySet()) { + // description + desc.append(instance + "触发条件[" + cause.getKey() + "]:").append(cause.getValue()).append("\r\n"); + // condition index + conditionIndex.add(cause.getKey()); + } + + String title = ip + "[" + instance + "]触发" + result.size() + "个报警(条件序号: " + conditionIndex.toString().replaceAll("\\[|]|,", "") + ")"; + + // fix  (\u00A0) can be shown in email + String description = desc.toString().replace('\u00A0', ' '); + + NotificationEvent ne = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_THRESHOLD, title, description, + judge_time, ip, host); + + // add appgroup + ne.addArg("appgroup", appgroup); + + // 兼容不存在convergences属性的旧预警策略 + if(convergences == null || convergences.size() == 0 ) { + return ne; + } + + // 同一个Event由多个策略触发时,梯度收敛以最长的为准 + String conv = obtainConvergenceForEvent(convergences, conditionIndex); + if(!StringHelper.isEmpty(conv)) { + ne.addArg("convergences", conv); + ne.addArg(NotificationEvent.EVENT_Tag_NoBlock, "true"); + } + + return ne; + } + + private String formatInstance(String instance) { + + if (NetworkHelper.isIPV4(instance)) { + instance += "_"; + } + instance = stra.getName().substring(0, stra.getName().lastIndexOf('@') + 1) + instance; + + return instance; + } + + private Map getInfoFromSliceCache(String instance) { + + String cacheKey = "SLICE_" + instance + "_"; + for (int index = 0; index < 60; index++) { + String result = cm.lpop(RuntimeNotifyStrategyMgr.UAV_CACHE_REGION, cacheKey + index); + if (result != null) { + Slice s = new Slice(result); + return s.getArgs(); + } + } + + return null; + } + + private void putNotifyAction(NotificationEvent event, NotifyStrategy stra) { + + Map actions = stra.getAction(); + if (actions == null || actions.isEmpty()) { + return; + } + + for (Entry act : actions.entrySet()) { + event.addArg("action_" + act.getKey(), act.getValue()); + } + } + + private void putNotifyMsg(NotificationEvent event, NotifyStrategy stra) { + + String msgTemplate = stra.getMsgTemplate(); + String msg = makeMsgByTemplate(msgTemplate, stra); + + if (msg != null) { + event.addArg("msg", msg); + } + } + + /** + * + * @param template + * @param slice + * @return + */ + private String makeMsgByTemplate(String template, NotifyStrategy stra) { + + return ""; + } + +} diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java index 705a8bfe..fea71ac8 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/DateTimeHelper.java @@ -1,1008 +1,1008 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.agent.helpers; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -public class DateTimeHelper { - - /** - * 日 - */ - public final static int INTERVAL_DAY = 1; - - /** - * 周 - */ - public final static int INTERVAL_WEEK = 2; - - /** - * 月 - */ - public final static int INTERVAL_MONTH = 3; - - /** - * 年 - */ - public final static int INTERVAL_YEAR = 4; - - /** - * 小时 - */ - public final static int INTERVAL_HOUR = 5; - - /** - * 分钟 - */ - public final static int INTERVAL_MINUTE = 6; - - /** - * 秒 - */ - public final static int INTERVAL_SECOND = 7; - - /** - * date = 1901-01-01 - */ - public final static Date tempDate = new Date(new Long("-2177481952000"));; - - private DateTimeHelper() { - } - - /** - * toStandardDateFormat yyyy-MM-dd HH:mm:ss.SSS - * - * @param timestamp - * @return - */ - public static String toStandardDateFormat(long timestamp) { - - return toFormat("yyyy-MM-dd HH:mm:ss.SSS", timestamp); - } - - /** - * toFormat - * - * @param format - * @param timestamp - * @return - */ - public static String toFormat(String format, long timestamp) { - - SimpleDateFormat sdf = new SimpleDateFormat(format); - - return sdf.format(new Date(timestamp)); - } - - /** - * get the time range index in a time span (ms) for 24 hours - * - * @param timeFlag - * @param span - * @return - */ - public static long getTimeRangeIndex(long timeFlag, long span) { - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - Calendar cl = Calendar.getInstance(); - - int year = cl.get(Calendar.YEAR); - int month = cl.get(Calendar.MONTH) + 1; - int day = cl.get(Calendar.DATE); - - long cTime = 0; - try { - Date d = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); - cTime = d.getTime(); - } - catch (ParseException e) { - // ignore - } - - long seconds = timeFlag - cTime; - - long timeRangeIndex = seconds / span; - - return timeRangeIndex; - } - - /** - * get the time range index in 1 min for 24 hours - * - * @param timeFlag - * @return - */ - public static long getTimeRangeIndexIn1Min(long timeFlag) { - - return getTimeRangeIndex(timeFlag, 60000); - } - - /** - * 测试是否是当天 - * - * @param date - * 某一日期 - * @return true 今天, false-不是 - */ - @SuppressWarnings("deprecation") - public static boolean isToday(Date date) { - - Date now = new Date(); - boolean result = true; - result &= date.getYear() == now.getYear(); - result &= date.getMonth() == now.getMonth(); - result &= date.getDate() == now.getDate(); - return result; - } - - /** - * 两个日期相减,取天数 - * - * @param date1 - * @param date2 - * @return - */ - public static long DaysBetween(Date date1, Date date2) { - - if (date2 == null) - date2 = new Date(); - long day = (date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); - return day; - } - - /** - * 比较两个日期 if date1<=date2 return true - * - * @param date1 - * @param date2 - * @return - */ - public static boolean compareDate(String date1, String date2) { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - Date d1 = format.parse(date1); - Date d2 = format.parse(date2); - return !d1.after(d2); - } - catch (ParseException e) { - e.printStackTrace(); - return false; - } - } - - /** - * 字符型转换成日期型 - * - * @param date - * @param dateFormat - * @return - */ - public static Date dateFormat(String date, String dateFormat) { - - if (date == null) - return null; - SimpleDateFormat format = new SimpleDateFormat(dateFormat); - if (date != null) { - try { - return format.parse(date); - } - catch (Exception ex) { - } - } - return null; - } - - /** - * 使用默认格式 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - */ - public static Date dateFormat(String date) { - - return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); - } - - /** - * 日期型转换成字符串 - * - * @param date - * @param dateFormat - * @return - */ - public static String dateFormat(Date date, String dateFormat) { - - if (date != null) { - SimpleDateFormat format = new SimpleDateFormat(dateFormat); - if (date != null) { - return format.format(date); - } - } - return ""; - } - - /** - * 由于生日增加保密属性,现决定1900为保密对应值,如果遇到1900的年份,则隐掉年份 - * - * @param date - * @param dateFormat - * @return 不保密显示1981-12-01保密则显示`12-01 - */ - public static String birthdayFormat(Date date) { - - if (date != null) { - SimpleDateFormat format = null; - if (date.before(tempDate)) { - format = new SimpleDateFormat("MM-dd"); - } - else { - format = new SimpleDateFormat("yyyy-MM-dd"); - } - if (date != null) { - return format.format(date); - } - } - return ""; - } - - /** - * 使用默认格式 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - */ - public static String dateFormat(Date date) { - - return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); - } - - public static boolean isExpiredDay(Date date1) { - - long day = (new Date().getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); - if (day >= 1) - return true; - else - return false; - } - - public static Date getYesterday() { - - Date date = new Date(); - long time = (date.getTime() / 1000) - 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static Date getWeekAgo() { - - Date date = new Date(); - long time = (date.getTime() / 1000) - 7 * 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static String getDaysAgo(int interval) { - - Date date = new Date(); - long time = (date.getTime() / 1000) - interval * 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - return format.format(date); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return ""; - } - - public static Date getTomorrow() { - - Date date = new Date(); - long time = (date.getTime() / 1000) + 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static Date getBeforeDate(String range) { - - Calendar today = Calendar.getInstance(); - if ("week".equalsIgnoreCase(range)) - today.add(Calendar.WEEK_OF_MONTH, -1); - else if ("month".equalsIgnoreCase(range)) - today.add(Calendar.MONTH, -1); - else - today.clear(); - return today.getTime(); - } - - public static Date getThisWeekStartTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek()); - Calendar weekFirstDay = Calendar.getInstance(); - weekFirstDay.clear(); - weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR)); - weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH)); - weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE)); - return weekFirstDay.getTime(); - } - - public static String getToday(String format) { - - String result = ""; - try { - Date today = new Date(); - SimpleDateFormat simpleFormat = new SimpleDateFormat(format); - result = simpleFormat.format(today); - } - catch (Exception e) { - } - return result; - } - - public static Date getStartDay(int year, int month) { - - Calendar today = Calendar.getInstance(); - today.clear(); - today.set(Calendar.YEAR, year); - today.set(Calendar.MONTH, month - 1); - today.set(Calendar.DAY_OF_MONTH, 1); - return today.getTime(); - } - - public static List getBeforeYearList(int before) { - - Calendar today = Calendar.getInstance(); - int theYear = today.get(Calendar.YEAR); - List list = new ArrayList(); - for (int i = before; i >= 0; i--) - list.add(theYear - i); - - return list; - } - - /** - * 增加时间 - * - * @param interval - * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] - * @param date - * @param n - * 可以为负数 - * @return - */ - public static Date dateAdd(int interval, Date date, int n) { - - long time = (date.getTime() / 1000); // 单位秒 - switch (interval) { - case INTERVAL_DAY: - time = time + n * 86400;// 60 * 60 * 24; - break; - case INTERVAL_WEEK: - time = time + n * 604800;// 60 * 60 * 24 * 7; - break; - case INTERVAL_MONTH: - time = time + n * 2678400;// 60 * 60 * 24 * 31; - break; - case INTERVAL_YEAR: - time = time + n * 31536000;// 60 * 60 * 24 * 365; - break; - case INTERVAL_HOUR: - time = time + n * 3600;// 60 * 60 ; - break; - case INTERVAL_MINUTE: - time = time + n * 60; - break; - case INTERVAL_SECOND: - time = time + n; - break; - default: - } - - Date result = new Date(); - result.setTime(time * 1000); - return result; - } - - /** - * 计算两个时间间隔 - * - * @param interval - * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] - * @param begin - * @param end - * @return - */ - public static int dateDiff(int interval, Date begin, Date end) { - - long beginTime = (begin.getTime() / 1000); // 单位:秒 - long endTime = (end.getTime() / 1000); // 单位: 秒 - long tmp = 0; - if (endTime == beginTime) { - return 0; - } - - // 确定endTime 大于 beginTime 结束时间秒数 大于 开始时间秒数 - if (endTime < beginTime) { - tmp = beginTime; - beginTime = endTime; - endTime = tmp; - } - - long intervalTime = endTime - beginTime; - long result = 0; - switch (interval) { - case INTERVAL_DAY: - result = intervalTime / 86400;// 60 * 60 * 24; - break; - case INTERVAL_WEEK: - result = intervalTime / 604800;// 60 * 60 * 24 * 7; - break; - case INTERVAL_MONTH: - result = intervalTime / 2678400;// 60 * 60 * 24 * 31; - break; - case INTERVAL_YEAR: - result = intervalTime / 31536000;// 60 * 60 * 24 * 365; - break; - case INTERVAL_HOUR: - result = intervalTime / 3600;// 60 * 60 ; - break; - case INTERVAL_MINUTE: - result = intervalTime / 60; - break; - case INTERVAL_SECOND: - result = intervalTime / 1; - break; - default: - } - - // 做过交换 - if (tmp > 0) { - result = 0 - result; - } - return (int) result; - } - - /** - * 当前年份 - * - * @return - */ - public static int getTodayYear() { - - int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy")); - return yyyy; - } - - public static Date getNow() { - - return new Date(); - } - - /** - * 把日期格式为rss格式兼容的字符串 - * - * @param date - * @return - */ - public static String dateFormatRss(Date date) { - - if (date != null) { - return dateFormat(date, "E, d MMM yyyy H:mm:ss") + " GMT"; - } - return ""; - } - - /** - * 判断当前日期是否在两个日期之间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static boolean betweenStartDateAndEndDate(Date startDate, Date endDate) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(startDate) && curDate.before(dateAdd(INTERVAL_DAY, endDate, 1))) { - bool = true; - } - return bool; - - } - - /** - * 判断当前时间是否在在两个时间之间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static boolean nowDateBetweenStartDateAndEndDate(Date startDate, Date endDate) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(startDate) && curDate.before(endDate)) { - bool = true; - } - return bool; - } - - /** - * 判断当前时间是否在date之后 - * - * @param date - * @return - */ - public static boolean nowDateAfterDate(Date date) { - - boolean bool = false; - Date curDate = new Date(); - if (curDate.after(date)) { - bool = true; - } - return bool; - } - - /** - * 判断二个日期相隔的天数,结束时间为null时,,取当前时间 - * - * @param startDate - * 开始时间 - * @param endDate - * 结束时间 - * @return - */ - public static int getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate) { - - int betweentoday = 0; - if (startDate == null) { - return betweentoday; - } - if (endDate == null) { - Calendar calendar = Calendar.getInstance(); - String year = new Integer(calendar.get(Calendar.YEAR)).toString(); - String month = new Integer((calendar.get(Calendar.MONTH) + 1)).toString(); - String day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)).toString(); - String strtodaytime = year + "-" + month + "-" + day; - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - try { - endDate = formatter.parse(strtodaytime); - } - catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - if (endDate.after(startDate)) { - betweentoday = (int) ((endDate.getTime() - startDate.getTime()) / 86400000); - } - else { - betweentoday = (int) ((startDate.getTime() - endDate.getTime()) / 86400000); - } - return betweentoday; - } - - /** - * 取得指定长度日期时间字符串{不含格式} - * - * @param format - * 时间格式由常量决定 8: YYMMDDHH 8位 10: YYMMDDHHmm 10位 12: YYMMDDHHmmss 12位 14: YYYYMMDDHHmmss 14位 15: - * YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒) - */ - public static String getTime(int format) { - - StringBuffer cTime = new StringBuffer(10); - Calendar time = Calendar.getInstance(); - int miltime = time.get(Calendar.MILLISECOND); - int second = time.get(Calendar.SECOND); - int minute = time.get(Calendar.MINUTE); - int hour = time.get(Calendar.HOUR_OF_DAY); - int day = time.get(Calendar.DAY_OF_MONTH); - int month = time.get(Calendar.MONTH) + 1; - int year = time.get(Calendar.YEAR); - if (format != 14) { - if (year >= 2000) - year = year - 2000; - else - year = year - 1900; - } - if (format >= 2) { - if (format == 14) - cTime.append(year); - else - cTime.append(getFormatTime(year, 2)); - } - if (format >= 4) - cTime.append(getFormatTime(month, 2)); - if (format >= 6) - cTime.append(getFormatTime(day, 2)); - if (format >= 8) - cTime.append(getFormatTime(hour, 2)); - if (format >= 10) - cTime.append(getFormatTime(minute, 2)); - if (format >= 12) - cTime.append(getFormatTime(second, 2)); - if (format >= 15) - cTime.append(getFormatTime(miltime, 3)); - return cTime.toString(); - } - - /** - * 产生任意位的字符串 - * - * @param time - * 要转换格式的时间 - * @param format - * 转换的格式 - * @return String 转换的时间 - */ - private static String getFormatTime(int time, int format) { - - StringBuffer numm = new StringBuffer(); - int length = String.valueOf(time).length(); - if (format < length) - return null; - for (int i = 0; i < format - length; i++) { - numm.append("0"); - } - numm.append(time); - return numm.toString().trim(); - } - - /** - * 根据生日去用户年龄 - * - * @param birthday - * @return int - * @exception @Date - * Apr 24, 2008 - */ - public static int getUserAge(Date birthday) { - - if (birthday == null) - return 0; - Calendar cal = Calendar.getInstance(); - if (cal.before(birthday)) { - return 0; - } - int yearNow = cal.get(Calendar.YEAR); - cal.setTime(birthday);// 给时间赋值 - int yearBirth = cal.get(Calendar.YEAR); - return yearNow - yearBirth; - } - - /** - * 将int型时间(1970年至今的秒数)转换成Date型时间 - * - * @param unixTime - * 1970年至今的秒数 - * @return - */ - public static Date getDateByUnixTime(int unixTime) { - - return new Date(unixTime * 1000L); - } - - public static long getUnixTimeLong() { - - return getUnixTimeByDate(new Date()); - } - - public static int getCurrentUnixTime() { - - return getUnixTimeByDate(new Date()); - } - - /** - * 将Date型时间转换成int型时间(1970年至今的秒数) - * - * @param unixTime - * 1970年至今的秒数 - * @return - */ - public static int getUnixTimeByDate(Date date) { - - return (int) (date.getTime() / 1000); - } - - public static long getUnixTimeLong(Date date) { - - return (date.getTime() / 1000); - } - - public static Date getNextDay(Date date) { - - long time = (date.getTime() / 1000) + 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - - } - - /** - * @param date - * @return 复制新Date,不改变参数 - */ - public static Date nextDay(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) + 60 * 60 * 24; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - - } - - public static Date getNowTime() { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date(); - String dateStr = dateFormat(date); - try { - date = format.parse(dateStr); - } - catch (ParseException e) { - e.printStackTrace(); - } - return date; - } - - public static Date getTomorrow(Date date1) { - - // 创建当前时间对象 - Calendar now = Calendar.getInstance(); - now.setTime(date1); - // 日期[+1]day - now.add(Calendar.DATE, 1); - return now.getTime(); - } - - public static Date getWeekAgo(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) - 60 * 60 * 24 * 7; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - } - - /** - * @param date - * @return 复制新Date,不改变参数 - */ - public static Date yesterday(Date date) { - - Date newDate = (Date) date.clone(); - long time = (newDate.getTime() / 1000) - 60 * 60 * 24; - newDate.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - newDate = format.parse(format.format(newDate)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return newDate; - } - - public static Date getYesterday(Date date) { - - long time = (date.getTime() / 1000) - 60 * 60 * 24; - date.setTime(time * 1000); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - date = format.parse(format.format(date)); - } - catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return date; - } - - public static String getStringNowTime() { - - Date date = new Date(); - String dateStr = dateFormat(date); - return dateStr; - } - - /** - * 指定时间的秒数 指定时间零点的秒数加指定天数的秒数 - * - * @param time - * 时间 - * @param range - * 天 - * @return - */ - public static long getSpecifyTimeSec(long time, int range) { - - Date date = new Date((time * 1000 + (23 - Calendar.ZONE_OFFSET) * 3600000) / 86400000 * 86400000 - - (23 - Calendar.ZONE_OFFSET) * 3600000); - long zeroTime = date.getTime() / 1000; - long specifyTime = range * 24 * 3600; - return (zeroTime + specifyTime); - } - - /** - * 将int型时间(1970年至今的秒数)转换成指定格式的时间 - * - * @param unixTime - * 1970年至今的秒数 - * @param dateFormat - * 时间格式 - * @return - */ - public static String formatDateByUnixTime(long unixTime, String dateFormat) { - - return dateFormat(new Date(unixTime * 1000), dateFormat); - } - - private static List dateFormats = new ArrayList(12) { - - private static final long serialVersionUID = 2249396579858199535L; - { - add(new SimpleDateFormat("yyyy-MM-dd")); - add(new SimpleDateFormat("yyyy/MM/dd")); - add(new SimpleDateFormat("yyyy.MM.dd")); - add(new SimpleDateFormat("yyyy-MM-dd HH:24:mm:ss")); - add(new SimpleDateFormat("yyyy/MM/dd HH:24:mm:ss")); - add(new SimpleDateFormat("yyyy.MM.dd HH:24:mm:ss")); - add(new SimpleDateFormat("M/dd/yyyy")); - add(new SimpleDateFormat("dd.M.yyyy")); - add(new SimpleDateFormat("M/dd/yyyy hh:mm:ss a")); - add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a")); - add(new SimpleDateFormat("dd.MMM.yyyy")); - add(new SimpleDateFormat("dd-MMM-yyyy")); - } - }; - - public static Date convertToDate(String input) { - - Date date = null; - if (null == input) { - return null; - } - for (SimpleDateFormat format : dateFormats) { - try { - format.setLenient(false); - date = format.parse(input); - } - catch (ParseException e) { - // Shhh.. try other formats - } - if (date != null) { - break; - } - } - return date; - } - - public static Long getTodayTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.HOUR_OF_DAY, 0); - today.set(Calendar.MINUTE, 0); - today.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); - } - - public static Long getYesterdayTime() { - - Calendar today = Calendar.getInstance(); - today.set(Calendar.HOUR_OF_DAY, -24); - today.set(Calendar.MINUTE, 0); - today.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); - } - - public static Long getTomorrowTime() { - - Calendar tomorrow = Calendar.getInstance(); - tomorrow.set(Calendar.HOUR_OF_DAY, 24); - tomorrow.set(Calendar.MINUTE, 0); - tomorrow.set(Calendar.SECOND, 0); - return Long.valueOf(String.valueOf(tomorrow.getTimeInMillis()).substring(0, 10)); - } - - public static Date getMonthAgo(Date date) { - - Calendar now = Calendar.getInstance(); - now.setTime(date); - - now.add(Calendar.MONTH, -1); - - return now.getTime(); - } - - public static Date getYearAgo(Date date) { - - Calendar now = Calendar.getInstance(); - now.setTime(date); - - now.add(Calendar.YEAR, -1); - - return now.getTime(); - } - - public static int getWeekday(Date date) { - - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - - return cal.get(Calendar.DAY_OF_WEEK) - 1; - } -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.agent.helpers; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +public class DateTimeHelper { + + /** + * 日 + */ + public final static int INTERVAL_DAY = 1; + + /** + * 周 + */ + public final static int INTERVAL_WEEK = 2; + + /** + * 月 + */ + public final static int INTERVAL_MONTH = 3; + + /** + * 年 + */ + public final static int INTERVAL_YEAR = 4; + + /** + * 小时 + */ + public final static int INTERVAL_HOUR = 5; + + /** + * 分钟 + */ + public final static int INTERVAL_MINUTE = 6; + + /** + * 秒 + */ + public final static int INTERVAL_SECOND = 7; + + /** + * date = 1901-01-01 + */ + public final static Date tempDate = new Date(new Long("-2177481952000"));; + + private DateTimeHelper() { + } + + /** + * toStandardDateFormat yyyy-MM-dd HH:mm:ss.SSS + * + * @param timestamp + * @return + */ + public static String toStandardDateFormat(long timestamp) { + + return toFormat("yyyy-MM-dd HH:mm:ss.SSS", timestamp); + } + + /** + * toFormat + * + * @param format + * @param timestamp + * @return + */ + public static String toFormat(String format, long timestamp) { + + SimpleDateFormat sdf = new SimpleDateFormat(format); + + return sdf.format(new Date(timestamp)); + } + + /** + * get the time range index in a time span (ms) for 24 hours + * + * @param timeFlag + * @param span + * @return + */ + public static long getTimeRangeIndex(long timeFlag, long span) { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Calendar cl = Calendar.getInstance(); + + int year = cl.get(Calendar.YEAR); + int month = cl.get(Calendar.MONTH) + 1; + int day = cl.get(Calendar.DATE); + + long cTime = 0; + try { + Date d = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); + cTime = d.getTime(); + } + catch (ParseException e) { + // ignore + } + + long seconds = timeFlag - cTime; + + long timeRangeIndex = seconds / span; + + return timeRangeIndex; + } + + /** + * get the time range index in 1 min for 24 hours + * + * @param timeFlag + * @return + */ + public static long getTimeRangeIndexIn1Min(long timeFlag) { + + return getTimeRangeIndex(timeFlag, 60000); + } + + /** + * 测试是否是当天 + * + * @param date + * 某一日期 + * @return true 今天, false-不是 + */ + @SuppressWarnings("deprecation") + public static boolean isToday(Date date) { + + Date now = new Date(); + boolean result = true; + result &= date.getYear() == now.getYear(); + result &= date.getMonth() == now.getMonth(); + result &= date.getDate() == now.getDate(); + return result; + } + + /** + * 两个日期相减,取天数 + * + * @param date1 + * @param date2 + * @return + */ + public static long DaysBetween(Date date1, Date date2) { + + if (date2 == null) + date2 = new Date(); + long day = (date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); + return day; + } + + /** + * 比较两个日期 if date1<=date2 return true + * + * @param date1 + * @param date2 + * @return + */ + public static boolean compareDate(String date1, String date2) { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date d1 = format.parse(date1); + Date d2 = format.parse(date2); + return !d1.after(d2); + } + catch (ParseException e) { + e.printStackTrace(); + return false; + } + } + + /** + * 字符型转换成日期型 + * + * @param date + * @param dateFormat + * @return + */ + public static Date dateFormat(String date, String dateFormat) { + + if (date == null) + return null; + SimpleDateFormat format = new SimpleDateFormat(dateFormat); + if (date != null) { + try { + return format.parse(date); + } + catch (Exception ex) { + } + } + return null; + } + + /** + * 使用默认格式 yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static Date dateFormat(String date) { + + return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 日期型转换成字符串 + * + * @param date + * @param dateFormat + * @return + */ + public static String dateFormat(Date date, String dateFormat) { + + if (date != null) { + SimpleDateFormat format = new SimpleDateFormat(dateFormat); + if (date != null) { + return format.format(date); + } + } + return ""; + } + + /** + * 由于生日增加保密属性,现决定1900为保密对应值,如果遇到1900的年份,则隐掉年份 + * + * @param date + * @param dateFormat + * @return 不保密显示1981-12-01保密则显示`12-01 + */ + public static String birthdayFormat(Date date) { + + if (date != null) { + SimpleDateFormat format = null; + if (date.before(tempDate)) { + format = new SimpleDateFormat("MM-dd"); + } + else { + format = new SimpleDateFormat("yyyy-MM-dd"); + } + if (date != null) { + return format.format(date); + } + } + return ""; + } + + /** + * 使用默认格式 yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static String dateFormat(Date date) { + + return dateFormat(date, "yyyy-MM-dd HH:mm:ss"); + } + + public static boolean isExpiredDay(Date date1) { + + long day = (new Date().getTime() - date1.getTime()) / (24 * 60 * 60 * 1000); + if (day >= 1) + return true; + else + return false; + } + + public static Date getYesterday() { + + Date date = new Date(); + long time = (date.getTime() / 1000) - 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static Date getWeekAgo() { + + Date date = new Date(); + long time = (date.getTime() / 1000) - 7 * 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static String getDaysAgo(int interval) { + + Date date = new Date(); + long time = (date.getTime() / 1000) - interval * 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + return format.format(date); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return ""; + } + + public static Date getTomorrow() { + + Date date = new Date(); + long time = (date.getTime() / 1000) + 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static Date getBeforeDate(String range) { + + Calendar today = Calendar.getInstance(); + if ("week".equalsIgnoreCase(range)) + today.add(Calendar.WEEK_OF_MONTH, -1); + else if ("month".equalsIgnoreCase(range)) + today.add(Calendar.MONTH, -1); + else + today.clear(); + return today.getTime(); + } + + public static Date getThisWeekStartTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek()); + Calendar weekFirstDay = Calendar.getInstance(); + weekFirstDay.clear(); + weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR)); + weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH)); + weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE)); + return weekFirstDay.getTime(); + } + + public static String getToday(String format) { + + String result = ""; + try { + Date today = new Date(); + SimpleDateFormat simpleFormat = new SimpleDateFormat(format); + result = simpleFormat.format(today); + } + catch (Exception e) { + } + return result; + } + + public static Date getStartDay(int year, int month) { + + Calendar today = Calendar.getInstance(); + today.clear(); + today.set(Calendar.YEAR, year); + today.set(Calendar.MONTH, month - 1); + today.set(Calendar.DAY_OF_MONTH, 1); + return today.getTime(); + } + + public static List getBeforeYearList(int before) { + + Calendar today = Calendar.getInstance(); + int theYear = today.get(Calendar.YEAR); + List list = new ArrayList(); + for (int i = before; i >= 0; i--) + list.add(theYear - i); + + return list; + } + + /** + * 增加时间 + * + * @param interval + * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] + * @param date + * @param n + * 可以为负数 + * @return + */ + public static Date dateAdd(int interval, Date date, int n) { + + long time = (date.getTime() / 1000); // 单位秒 + switch (interval) { + case INTERVAL_DAY: + time = time + n * 86400;// 60 * 60 * 24; + break; + case INTERVAL_WEEK: + time = time + n * 604800;// 60 * 60 * 24 * 7; + break; + case INTERVAL_MONTH: + time = time + n * 2678400;// 60 * 60 * 24 * 31; + break; + case INTERVAL_YEAR: + time = time + n * 31536000;// 60 * 60 * 24 * 365; + break; + case INTERVAL_HOUR: + time = time + n * 3600;// 60 * 60 ; + break; + case INTERVAL_MINUTE: + time = time + n * 60; + break; + case INTERVAL_SECOND: + time = time + n; + break; + default: + } + + Date result = new Date(); + result.setTime(time * 1000); + return result; + } + + /** + * 计算两个时间间隔 + * + * @param interval + * [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR, INTERVAL_HOUR,INTERVAL_MINUTE] + * @param begin + * @param end + * @return + */ + public static int dateDiff(int interval, Date begin, Date end) { + + long beginTime = (begin.getTime() / 1000); // 单位:秒 + long endTime = (end.getTime() / 1000); // 单位: 秒 + long tmp = 0; + if (endTime == beginTime) { + return 0; + } + + // 确定endTime 大于 beginTime 结束时间秒数 大于 开始时间秒数 + if (endTime < beginTime) { + tmp = beginTime; + beginTime = endTime; + endTime = tmp; + } + + long intervalTime = endTime - beginTime; + long result = 0; + switch (interval) { + case INTERVAL_DAY: + result = intervalTime / 86400;// 60 * 60 * 24; + break; + case INTERVAL_WEEK: + result = intervalTime / 604800;// 60 * 60 * 24 * 7; + break; + case INTERVAL_MONTH: + result = intervalTime / 2678400;// 60 * 60 * 24 * 31; + break; + case INTERVAL_YEAR: + result = intervalTime / 31536000;// 60 * 60 * 24 * 365; + break; + case INTERVAL_HOUR: + result = intervalTime / 3600;// 60 * 60 ; + break; + case INTERVAL_MINUTE: + result = intervalTime / 60; + break; + case INTERVAL_SECOND: + result = intervalTime / 1; + break; + default: + } + + // 做过交换 + if (tmp > 0) { + result = 0 - result; + } + return (int) result; + } + + /** + * 当前年份 + * + * @return + */ + public static int getTodayYear() { + + int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy")); + return yyyy; + } + + public static Date getNow() { + + return new Date(); + } + + /** + * 把日期格式为rss格式兼容的字符串 + * + * @param date + * @return + */ + public static String dateFormatRss(Date date) { + + if (date != null) { + return dateFormat(date, "E, d MMM yyyy H:mm:ss") + " GMT"; + } + return ""; + } + + /** + * 判断当前日期是否在两个日期之间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static boolean betweenStartDateAndEndDate(Date startDate, Date endDate) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(startDate) && curDate.before(dateAdd(INTERVAL_DAY, endDate, 1))) { + bool = true; + } + return bool; + + } + + /** + * 判断当前时间是否在在两个时间之间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static boolean nowDateBetweenStartDateAndEndDate(Date startDate, Date endDate) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(startDate) && curDate.before(endDate)) { + bool = true; + } + return bool; + } + + /** + * 判断当前时间是否在date之后 + * + * @param date + * @return + */ + public static boolean nowDateAfterDate(Date date) { + + boolean bool = false; + Date curDate = new Date(); + if (curDate.after(date)) { + bool = true; + } + return bool; + } + + /** + * 判断二个日期相隔的天数,结束时间为null时,,取当前时间 + * + * @param startDate + * 开始时间 + * @param endDate + * 结束时间 + * @return + */ + public static int getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate) { + + int betweentoday = 0; + if (startDate == null) { + return betweentoday; + } + if (endDate == null) { + Calendar calendar = Calendar.getInstance(); + String year = new Integer(calendar.get(Calendar.YEAR)).toString(); + String month = new Integer((calendar.get(Calendar.MONTH) + 1)).toString(); + String day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)).toString(); + String strtodaytime = year + "-" + month + "-" + day; + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + try { + endDate = formatter.parse(strtodaytime); + } + catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + if (endDate.after(startDate)) { + betweentoday = (int) ((endDate.getTime() - startDate.getTime()) / 86400000); + } + else { + betweentoday = (int) ((startDate.getTime() - endDate.getTime()) / 86400000); + } + return betweentoday; + } + + /** + * 取得指定长度日期时间字符串{不含格式} + * + * @param format + * 时间格式由常量决定 8: YYMMDDHH 8位 10: YYMMDDHHmm 10位 12: YYMMDDHHmmss 12位 14: YYYYMMDDHHmmss 14位 15: + * YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒) + */ + public static String getTime(int format) { + + StringBuffer cTime = new StringBuffer(10); + Calendar time = Calendar.getInstance(); + int miltime = time.get(Calendar.MILLISECOND); + int second = time.get(Calendar.SECOND); + int minute = time.get(Calendar.MINUTE); + int hour = time.get(Calendar.HOUR_OF_DAY); + int day = time.get(Calendar.DAY_OF_MONTH); + int month = time.get(Calendar.MONTH) + 1; + int year = time.get(Calendar.YEAR); + if (format != 14) { + if (year >= 2000) + year = year - 2000; + else + year = year - 1900; + } + if (format >= 2) { + if (format == 14) + cTime.append(year); + else + cTime.append(getFormatTime(year, 2)); + } + if (format >= 4) + cTime.append(getFormatTime(month, 2)); + if (format >= 6) + cTime.append(getFormatTime(day, 2)); + if (format >= 8) + cTime.append(getFormatTime(hour, 2)); + if (format >= 10) + cTime.append(getFormatTime(minute, 2)); + if (format >= 12) + cTime.append(getFormatTime(second, 2)); + if (format >= 15) + cTime.append(getFormatTime(miltime, 3)); + return cTime.toString(); + } + + /** + * 产生任意位的字符串 + * + * @param time + * 要转换格式的时间 + * @param format + * 转换的格式 + * @return String 转换的时间 + */ + private static String getFormatTime(int time, int format) { + + StringBuffer numm = new StringBuffer(); + int length = String.valueOf(time).length(); + if (format < length) + return null; + for (int i = 0; i < format - length; i++) { + numm.append("0"); + } + numm.append(time); + return numm.toString().trim(); + } + + /** + * 根据生日去用户年龄 + * + * @param birthday + * @return int + * @exception @Date + * Apr 24, 2008 + */ + public static int getUserAge(Date birthday) { + + if (birthday == null) + return 0; + Calendar cal = Calendar.getInstance(); + if (cal.before(birthday)) { + return 0; + } + int yearNow = cal.get(Calendar.YEAR); + cal.setTime(birthday);// 给时间赋值 + int yearBirth = cal.get(Calendar.YEAR); + return yearNow - yearBirth; + } + + /** + * 将int型时间(1970年至今的秒数)转换成Date型时间 + * + * @param unixTime + * 1970年至今的秒数 + * @return + */ + public static Date getDateByUnixTime(int unixTime) { + + return new Date(unixTime * 1000L); + } + + public static long getUnixTimeLong() { + + return getUnixTimeByDate(new Date()); + } + + public static int getCurrentUnixTime() { + + return getUnixTimeByDate(new Date()); + } + + /** + * 将Date型时间转换成int型时间(1970年至今的秒数) + * + * @param unixTime + * 1970年至今的秒数 + * @return + */ + public static int getUnixTimeByDate(Date date) { + + return (int) (date.getTime() / 1000); + } + + public static long getUnixTimeLong(Date date) { + + return (date.getTime() / 1000); + } + + public static Date getNextDay(Date date) { + + long time = (date.getTime() / 1000) + 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + + } + + /** + * @param date + * @return 复制新Date,不改变参数 + */ + public static Date nextDay(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) + 60 * 60 * 24; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + + } + + public static Date getNowTime() { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(); + String dateStr = dateFormat(date); + try { + date = format.parse(dateStr); + } + catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + + public static Date getTomorrow(Date date1) { + + // 创建当前时间对象 + Calendar now = Calendar.getInstance(); + now.setTime(date1); + // 日期[+1]day + now.add(Calendar.DATE, 1); + return now.getTime(); + } + + public static Date getWeekAgo(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) - 60 * 60 * 24 * 7; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + } + + /** + * @param date + * @return 复制新Date,不改变参数 + */ + public static Date yesterday(Date date) { + + Date newDate = (Date) date.clone(); + long time = (newDate.getTime() / 1000) - 60 * 60 * 24; + newDate.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + newDate = format.parse(format.format(newDate)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return newDate; + } + + public static Date getYesterday(Date date) { + + long time = (date.getTime() / 1000) - 60 * 60 * 24; + date.setTime(time * 1000); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + date = format.parse(format.format(date)); + } + catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return date; + } + + public static String getStringNowTime() { + + Date date = new Date(); + String dateStr = dateFormat(date); + return dateStr; + } + + /** + * 指定时间的秒数 指定时间零点的秒数加指定天数的秒数 + * + * @param time + * 时间 + * @param range + * 天 + * @return + */ + public static long getSpecifyTimeSec(long time, int range) { + + Date date = new Date((time * 1000 + (23 - Calendar.ZONE_OFFSET) * 3600000) / 86400000 * 86400000 + - (23 - Calendar.ZONE_OFFSET) * 3600000); + long zeroTime = date.getTime() / 1000; + long specifyTime = range * 24 * 3600; + return (zeroTime + specifyTime); + } + + /** + * 将int型时间(1970年至今的秒数)转换成指定格式的时间 + * + * @param unixTime + * 1970年至今的秒数 + * @param dateFormat + * 时间格式 + * @return + */ + public static String formatDateByUnixTime(long unixTime, String dateFormat) { + + return dateFormat(new Date(unixTime * 1000), dateFormat); + } + + private static List dateFormats = new ArrayList(12) { + + private static final long serialVersionUID = 2249396579858199535L; + { + add(new SimpleDateFormat("yyyy-MM-dd")); + add(new SimpleDateFormat("yyyy/MM/dd")); + add(new SimpleDateFormat("yyyy.MM.dd")); + add(new SimpleDateFormat("yyyy-MM-dd HH:24:mm:ss")); + add(new SimpleDateFormat("yyyy/MM/dd HH:24:mm:ss")); + add(new SimpleDateFormat("yyyy.MM.dd HH:24:mm:ss")); + add(new SimpleDateFormat("M/dd/yyyy")); + add(new SimpleDateFormat("dd.M.yyyy")); + add(new SimpleDateFormat("M/dd/yyyy hh:mm:ss a")); + add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a")); + add(new SimpleDateFormat("dd.MMM.yyyy")); + add(new SimpleDateFormat("dd-MMM-yyyy")); + } + }; + + public static Date convertToDate(String input) { + + Date date = null; + if (null == input) { + return null; + } + for (SimpleDateFormat format : dateFormats) { + try { + format.setLenient(false); + date = format.parse(input); + } + catch (ParseException e) { + // Shhh.. try other formats + } + if (date != null) { + break; + } + } + return date; + } + + public static Long getTodayTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.HOUR_OF_DAY, 0); + today.set(Calendar.MINUTE, 0); + today.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); + } + + public static Long getYesterdayTime() { + + Calendar today = Calendar.getInstance(); + today.set(Calendar.HOUR_OF_DAY, -24); + today.set(Calendar.MINUTE, 0); + today.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(today.getTimeInMillis()).substring(0, 10)); + } + + public static Long getTomorrowTime() { + + Calendar tomorrow = Calendar.getInstance(); + tomorrow.set(Calendar.HOUR_OF_DAY, 24); + tomorrow.set(Calendar.MINUTE, 0); + tomorrow.set(Calendar.SECOND, 0); + return Long.valueOf(String.valueOf(tomorrow.getTimeInMillis()).substring(0, 10)); + } + + public static Date getMonthAgo(Date date) { + + Calendar now = Calendar.getInstance(); + now.setTime(date); + + now.add(Calendar.MONTH, -1); + + return now.getTime(); + } + + public static Date getYearAgo(Date date) { + + Calendar now = Calendar.getInstance(); + now.setTime(date); + + now.add(Calendar.YEAR, -1); + + return now.getTime(); + } + + public static int getWeekday(Date date) { + + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + + return cal.get(Calendar.DAY_OF_WEEK) - 1; + } +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java index b14e429f..662ea72e 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java @@ -1,365 +1,365 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.uav.hook.rabbitmq.interceptors; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.creditease.monitor.UAVServer; -import com.creditease.monitor.captureframework.spi.CaptureConstants; -import com.creditease.monitor.captureframework.spi.Monitor; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; -import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; -import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; -import com.creditease.uav.common.BaseComponent; -import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqConsumerAdapter; -import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqProducerAdapter; -import com.creditease.uav.util.JDKProxyInvokeUtil; -import com.rabbitmq.client.AMQP; -import com.rabbitmq.client.AMQP.BasicProperties; -import com.rabbitmq.client.Channel; -import com.rabbitmq.client.Connection; -import com.rabbitmq.client.Consumer; - -public class RabbitmqIT extends BaseComponent { - - private String applicationId; - static final Map queueNameIndex = new HashMap(); - static { - queueNameIndex.put("basicPublish", 1); - queueNameIndex.put("queueDeclare", 0); - queueNameIndex.put("queueDeclareNoWait", 0); - queueNameIndex.put("queueDeclarePassive", 0); - queueNameIndex.put("queueDelete", 0); - queueNameIndex.put("queueDeleteNoWait", 0); - queueNameIndex.put("queueBind", 0); - queueNameIndex.put("queueBindNoWait", 0); - queueNameIndex.put("queueUnbind", 0); - queueNameIndex.put("queuePurge", 0); - queueNameIndex.put("basicGet", 0); - queueNameIndex.put("basicConsume", 0); - } - - public RabbitmqIT(String appid) { - this.applicationId = appid; - } - - public Connection doInstall(Connection arg) { - - arg = JDKProxyInvokeUtil.newProxyInstance(Connection.class.getClassLoader(), - new Class[] { Connection.class }, - new JDKProxyInvokeHandler(arg, new ConnectionProxyProcessor())); - - return arg; - } - - /** - * - * ConnectionProxyProcessor description: ConnectionProxyProcessor - * - */ - public class ConnectionProxyProcessor extends JDKProxyInvokeProcessor { - - @Override - public void preProcess(Connection t, Object proxy, Method method, Object[] args) { - - } - - @Override - public Object postProcess(Object res, Connection t, Object proxy, Method method, Object[] args) { - - if (method.getName().equals("createChannel")) { - return JDKProxyInvokeUtil.newProxyInstance(Channel.class.getClassLoader(), - new Class[] { Channel.class }, - new JDKProxyInvokeHandler((Channel) res, new ChannelProxyProcessor())); - } - return null; - } - - } - - /** - * - * ChannelProxyProcessor description: ChannelProxyProcessor - * - */ - public class ChannelProxyProcessor extends JDKProxyInvokeProcessor { - - String address; - String targetServer; - private Map ivcContextParams = new HashMap(); - - @SuppressWarnings("unchecked") - @Override - public void preProcess(Channel t, Object proxy, Method method, Object[] args) { - - if (method.getExceptionTypes().length > 0 - && method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { - String methodName = method.getName(); - String queueName = null; - if (queueNameIndex.containsKey(methodName) && args.length != 0) { - - queueName = (String) args[queueNameIndex.get(methodName)]; - if (isTempQueue(queueName)) { - return; - } - - } - - if (null == address) { - address = t.getConnection().getAddress().getHostAddress() + ":" + t.getConnection().getPort(); - address = "mq:rabbit://" + address; - } - String url = address + ((null == queueName) ? "" : "/" + queueName); - - if ("basicConsume".equals(method.getName())) { - // delegate the consumer - args[args.length - 1] = JDKProxyInvokeUtil.newProxyInstance(Consumer.class.getClassLoader(), - new Class[] { Consumer.class }, new JDKProxyInvokeHandler( - (Consumer) args[args.length - 1], new ConsumerProxyProcessor(t, url))); - - } - - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=" + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - - // 调用链只关心真正的消息通讯 - if (method.getName().equals("basicPublish")) { - - // register adapter - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", - "registerAdapter", RabbitmqProducerAdapter.class); - - ivcContextParams = (Map) UAVServer.instance().runSupporter( - "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, - RabbitmqProducerAdapter.class, - new Object[] { (BasicProperties) args[args.length - 2], args[args.length - 1] }); - if (ivcContextParams != null - && ivcContextParams.containsKey(InvokeChainConstants.PARAM_MQHEAD_INFO)) { - args[args.length - 2] = ivcContextParams.get(InvokeChainConstants.PARAM_MQHEAD_INFO); - } - } - } - } - - @Override - public Object postProcess(Object res, Channel t, Object proxy, Method method, Object[] args) { - - if (needDoCap(method, args)) { - doCap(1, t, method, null); - } - - return null; - } - - @Override - public void catchInvokeException(Channel t, Object proxy, Method method, Object[] args, Throwable e) { - - if (needDoCap(method, args)) { - doCap(-1, t, method, e); - } - - } - - private boolean needDoCap(Method method, Object[] args) { - - if (method.getExceptionTypes().length == 0 - || !method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { - return false; - } - String methodName = method.getName(); - if (queueNameIndex.containsKey(methodName) && args.length != 0) { - - if (isTempQueue((String) args[queueNameIndex.get(methodName)])) { - return false; - } - } - return true; - } - - private void doCap(int rc, Channel t, Method method, Throwable e) { - - if (null == targetServer) { - Map conn = t.getConnection().getServerProperties(); - String cluster_name = (null == conn.get("cluster_name")) ? "unknown" - : conn.get("cluster_name").toString(); - String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); - targetServer = cluster_name + "@" + version; - } - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params); - - // 调用链只关心真正的消息通讯 - if (method.getName().equals("basicPublish")) { - - if (rc == -1) { - ivcContextParams.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); - } - if (ivcContextParams != null) { - ivcContextParams.putAll(params); - } - - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, - ivcContextParams, RabbitmqProducerAdapter.class, null); - } - - } - - public boolean isTempQueue(String queueName) { - - String regEx = "^([0-9]|[a-f]){8}(-([0-9]|[a-f]){4}){3}-([0-9]|[a-f]){12}$"; - Matcher matcher = Pattern.compile(regEx).matcher(queueName); - return matcher.matches(); - - } - } - - public class ConsumerProxyProcessor extends JDKProxyInvokeProcessor { - - private Channel channel; - private String url; - private String targetServer; - - public ConsumerProxyProcessor(Channel channel, String url) { - this.channel = channel; - this.url = url; - } - - @Override - public void preProcess(Consumer t, Object proxy, Method method, Object[] args) { - - Map params = new HashMap(); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); - - if (logger.isDebugable()) { - logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.PRECAP, params); - // 调用链只关心真正消费消息 - if (method.getName().equals("handleDelivery")) { - - AMQP.BasicProperties props = (BasicProperties) args[2]; - if (props.getHeaders() != null - && props.getHeaders().containsKey(InvokeChainConstants.PARAM_MQHEAD_SPANINFO)) { - params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, - props.getHeaders().get(InvokeChainConstants.PARAM_MQHEAD_SPANINFO) + ""); - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); - } - - // register adapter - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", - "registerAdapter", RabbitmqConsumerAdapter.class); - - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.PRECAP, params, - RabbitmqConsumerAdapter.class, args); - } - - } - - @Override - public void catchInvokeException(Consumer t, Object proxy, Method method, Object[] args, Throwable e) { - - doCap(-1, channel, t, method, e); - - } - - @Override - public Object postProcess(Object res, Consumer operation, Object proxy, Method method, Object[] args) { - - doCap(1, channel, operation, method, null); - return null; - } - - private void doCap(int rc, Channel channel, Consumer consumer, Method method, Throwable e) { - - if (null == targetServer) { - Map conn = channel.getConnection().getServerProperties(); - String cluster_name = (null == conn.get("cluster_name")) ? "unknown" - : conn.get("cluster_name").toString(); - String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); - targetServer = cluster_name + "@" + version; - } - - Map params = new HashMap(); - - params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - - if (logger.isDebugable()) { - logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); - } - - UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, - Monitor.CapturePhase.DOCAP, params); - - if (method.getName().equals("handleDelivery")) { - params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); - params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); - params.put(InvokeChainConstants.CLIENT_IT_CLASS, consumer.getClass().getName()); - // 调用链只关心一个方法 - params.put(InvokeChainConstants.CLIENT_IT_METHOD, "handleDelivery"); - params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); - if (rc == -1) { - params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); - } - - // invoke chain - UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", - InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.DOCAP, params, - RabbitmqConsumerAdapter.class, null); - } - } - - } - -} +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.rabbitmq.interceptors; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqConsumerAdapter; +import com.creditease.uav.hook.rabbitmq.adapter.RabbitmqProducerAdapter; +import com.creditease.uav.util.JDKProxyInvokeUtil; +import com.rabbitmq.client.AMQP; +import com.rabbitmq.client.AMQP.BasicProperties; +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; +import com.rabbitmq.client.Consumer; + +public class RabbitmqIT extends BaseComponent { + + private String applicationId; + static final Map queueNameIndex = new HashMap(); + static { + queueNameIndex.put("basicPublish", 1); + queueNameIndex.put("queueDeclare", 0); + queueNameIndex.put("queueDeclareNoWait", 0); + queueNameIndex.put("queueDeclarePassive", 0); + queueNameIndex.put("queueDelete", 0); + queueNameIndex.put("queueDeleteNoWait", 0); + queueNameIndex.put("queueBind", 0); + queueNameIndex.put("queueBindNoWait", 0); + queueNameIndex.put("queueUnbind", 0); + queueNameIndex.put("queuePurge", 0); + queueNameIndex.put("basicGet", 0); + queueNameIndex.put("basicConsume", 0); + } + + public RabbitmqIT(String appid) { + this.applicationId = appid; + } + + public Connection doInstall(Connection arg) { + + arg = JDKProxyInvokeUtil.newProxyInstance(Connection.class.getClassLoader(), + new Class[] { Connection.class }, + new JDKProxyInvokeHandler(arg, new ConnectionProxyProcessor())); + + return arg; + } + + /** + * + * ConnectionProxyProcessor description: ConnectionProxyProcessor + * + */ + public class ConnectionProxyProcessor extends JDKProxyInvokeProcessor { + + @Override + public void preProcess(Connection t, Object proxy, Method method, Object[] args) { + + } + + @Override + public Object postProcess(Object res, Connection t, Object proxy, Method method, Object[] args) { + + if (method.getName().equals("createChannel")) { + return JDKProxyInvokeUtil.newProxyInstance(Channel.class.getClassLoader(), + new Class[] { Channel.class }, + new JDKProxyInvokeHandler((Channel) res, new ChannelProxyProcessor())); + } + return null; + } + + } + + /** + * + * ChannelProxyProcessor description: ChannelProxyProcessor + * + */ + public class ChannelProxyProcessor extends JDKProxyInvokeProcessor { + + String address; + String targetServer; + private Map ivcContextParams = new HashMap(); + + @SuppressWarnings("unchecked") + @Override + public void preProcess(Channel t, Object proxy, Method method, Object[] args) { + + if (method.getExceptionTypes().length > 0 + && method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { + String methodName = method.getName(); + String queueName = null; + if (queueNameIndex.containsKey(methodName) && args.length != 0) { + + queueName = (String) args[queueNameIndex.get(methodName)]; + if (isTempQueue(queueName)) { + return; + } + + } + + if (null == address) { + address = t.getConnection().getAddress().getHostAddress() + ":" + t.getConnection().getPort(); + address = "mq:rabbit://" + address; + } + String url = address + ((null == queueName) ? "" : "/" + queueName); + + if ("basicConsume".equals(method.getName())) { + // delegate the consumer + args[args.length - 1] = JDKProxyInvokeUtil.newProxyInstance(Consumer.class.getClassLoader(), + new Class[] { Consumer.class }, new JDKProxyInvokeHandler( + (Consumer) args[args.length - 1], new ConsumerProxyProcessor(t, url))); + + } + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=" + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + // 调用链只关心真正的消息通讯 + if (method.getName().equals("basicPublish")) { + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", + "registerAdapter", RabbitmqProducerAdapter.class); + + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + RabbitmqProducerAdapter.class, + new Object[] { (BasicProperties) args[args.length - 2], args[args.length - 1] }); + if (ivcContextParams != null + && ivcContextParams.containsKey(InvokeChainConstants.PARAM_MQHEAD_INFO)) { + args[args.length - 2] = ivcContextParams.get(InvokeChainConstants.PARAM_MQHEAD_INFO); + } + } + } + } + + @Override + public Object postProcess(Object res, Channel t, Object proxy, Method method, Object[] args) { + + if (needDoCap(method, args)) { + doCap(1, t, method, null); + } + + return null; + } + + @Override + public void catchInvokeException(Channel t, Object proxy, Method method, Object[] args, Throwable e) { + + if (needDoCap(method, args)) { + doCap(-1, t, method, e); + } + + } + + private boolean needDoCap(Method method, Object[] args) { + + if (method.getExceptionTypes().length == 0 + || !method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { + return false; + } + String methodName = method.getName(); + if (queueNameIndex.containsKey(methodName) && args.length != 0) { + + if (isTempQueue((String) args[queueNameIndex.get(methodName)])) { + return false; + } + } + return true; + } + + private void doCap(int rc, Channel t, Method method, Throwable e) { + + if (null == targetServer) { + Map conn = t.getConnection().getServerProperties(); + String cluster_name = (null == conn.get("cluster_name")) ? "unknown" + : conn.get("cluster_name").toString(); + String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); + targetServer = cluster_name + "@" + version; + } + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + + // 调用链只关心真正的消息通讯 + if (method.getName().equals("basicPublish")) { + + if (rc == -1) { + ivcContextParams.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + } + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, + ivcContextParams, RabbitmqProducerAdapter.class, null); + } + + } + + public boolean isTempQueue(String queueName) { + + String regEx = "^([0-9]|[a-f]){8}(-([0-9]|[a-f]){4}){3}-([0-9]|[a-f]){12}$"; + Matcher matcher = Pattern.compile(regEx).matcher(queueName); + return matcher.matches(); + + } + } + + public class ConsumerProxyProcessor extends JDKProxyInvokeProcessor { + + private Channel channel; + private String url; + private String targetServer; + + public ConsumerProxyProcessor(Channel channel, String url) { + this.channel = channel; + this.url = url; + } + + @Override + public void preProcess(Consumer t, Object proxy, Method method, Object[] args) { + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + method.getName()); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "rabbitmq.client"); + + if (logger.isDebugable()) { + logger.debug("Invoke START:" + url + ",op=Consumer." + method.getName(), null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + // 调用链只关心真正消费消息 + if (method.getName().equals("handleDelivery")) { + + AMQP.BasicProperties props = (BasicProperties) args[2]; + if (props.getHeaders() != null + && props.getHeaders().containsKey(InvokeChainConstants.PARAM_MQHEAD_SPANINFO)) { + params.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, + props.getHeaders().get(InvokeChainConstants.PARAM_MQHEAD_SPANINFO) + ""); + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); + } + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", + "registerAdapter", RabbitmqConsumerAdapter.class); + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.PRECAP, params, + RabbitmqConsumerAdapter.class, args); + } + + } + + @Override + public void catchInvokeException(Consumer t, Object proxy, Method method, Object[] args, Throwable e) { + + doCap(-1, channel, t, method, e); + + } + + @Override + public Object postProcess(Object res, Consumer operation, Object proxy, Method method, Object[] args) { + + doCap(1, channel, operation, method, null); + return null; + } + + private void doCap(int rc, Channel channel, Consumer consumer, Method method, Throwable e) { + + if (null == targetServer) { + Map conn = channel.getConnection().getServerProperties(); + String cluster_name = (null == conn.get("cluster_name")) ? "unknown" + : conn.get("cluster_name").toString(); + String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString(); + targetServer = cluster_name + "@" + version; + } + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + if (logger.isDebugable()) { + logger.debug("Invoke END: rc=" + rc + "," + targetServer, null); + } + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + + if (method.getName().equals("handleDelivery")) { + params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url); + params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId); + params.put(InvokeChainConstants.CLIENT_IT_CLASS, consumer.getClass().getName()); + // 调用链只关心一个方法 + params.put(InvokeChainConstants.CLIENT_IT_METHOD, "handleDelivery"); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + if (rc == -1) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + } + + // invoke chain + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.DOCAP, params, + RabbitmqConsumerAdapter.class, null); + } + } + + } + +} From bc2aa14a8985566adf9d9b30656a2b1e9177ddad Mon Sep 17 00:00:00 2001 From: xiaolong Date: Fri, 20 Apr 2018 15:27:03 +0800 Subject: [PATCH 57/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/253=201.=E4=BF=AE=E6=94=B9ma=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=B8=BAUAV=E4=B8=8Ehm=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E7=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.creditease.uav.agent.buildComponent/bin/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.agent.buildComponent/bin/run.sh b/com.creditease.uav.agent.buildComponent/bin/run.sh index 2c5d3281..4f820367 100644 --- a/com.creditease.uav.agent.buildComponent/bin/run.sh +++ b/com.creditease.uav.agent.buildComponent/bin/run.sh @@ -47,7 +47,7 @@ export CLASSPATH=bin/com.creditease.uav.base-1.0-boot.jar echo $CLASSPATH javaAgent="-javaagent:../uavmof/com.creditease.uav.agent/com.creditease.uav.monitorframework.agent-1.0-agent.jar" javaOpts="-server -Xms64m -Xmx256m -Xss256k -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 -XX:+UseParNewGC -XX:+UseCMSCompactAtFullCollection -XX:-CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=0 -XX:CMSInitiatingOccupancyFraction=70 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=." -$executeJava $javaAgent $javaOpts -XX:OnOutOfMemoryError='kill -9 %p' -DNetCardIndex=$netcardIndex -DNetCardName=$netcardName -DJAppID=$2 -DJAppGroup=UNKNOWN -classpath $CLASSPATH com.creditease.mscp.boot.MSCPBoot -p $1 & +$executeJava $javaAgent $javaOpts -XX:OnOutOfMemoryError='kill -9 %p' -DNetCardIndex=$netcardIndex -DNetCardName=$netcardName -DJAppID=$2 -DJAppGroup=UAV -classpath $CLASSPATH com.creditease.mscp.boot.MSCPBoot -p $1 & # add crontab process watcher if [ "$proc_watcher" == "yes" ]; then From e5f7129fef6560553d8de3864c92746ddb48bb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 20 Apr 2018 18:51:43 +0800 Subject: [PATCH 58/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/255=20=E6=B7=BB=E5=8A=A0ESclient=20hook,=E6=94=AF=E6=8C=81tran?= =?UTF-8?q?sport=205.0.0-6.2.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appmonitor/js/uav.appstream.js | 9 +- .../notifystgy/js/notifystgy.win.js | 4 +- .../findbugs.exclude.xml | 4 + com.creditease.uav.hook.esclient/pom.xml | 43 +++++ .../transport/TransportHookProxy.java | 137 ++++++++++++++ .../transport/interceptors/TransportIT.java | 172 ++++++++++++++++++ .../invokeChain/TransportAdapter.java | 55 ++++++ .../esclient/DoTestTransportHookProxy.java | 124 +++++++++++++ .../config/uav.properties | 4 +- .../pom.xml | 4 +- .../pom.xml | 10 + .../fat/invokechain/ElasticsearchService.java | 95 ++++++++++ 12 files changed, 655 insertions(+), 6 deletions(-) create mode 100644 com.creditease.uav.hook.esclient/findbugs.exclude.xml create mode 100644 com.creditease.uav.hook.esclient/pom.xml create mode 100644 com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/TransportHookProxy.java create mode 100644 com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/interceptors/TransportIT.java create mode 100644 com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/invokeChain/TransportAdapter.java create mode 100644 com.creditease.uav.hook.esclient/src/test/java/com/creditease/uav/hook/esclient/DoTestTransportHookProxy.java create mode 100644 com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/invokechain/ElasticsearchService.java diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js index 780b3bf3..1a4941b2 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.appstream.js @@ -1115,8 +1115,8 @@ function AppServiceStream(app) { targetNode=this.createNoneAppNode(target, "未知http服务\n"+target, "unknown", 1, 1, 1, 3); } } - //jdbc client/redis/mongo - else if (target.indexOf("jdbc:")==0||target.indexOf("redis:")==0||target.indexOf("mongo:")==0) { + //jdbc client/redis/mongo/elasticsearch + else if (target.indexOf("jdbc:")==0||target.indexOf("redis:")==0||target.indexOf("mongo:")==0||target.indexOf("elasticsearch:")==0) { //filter those we don't want show client targets if (targetFilters!=undefined&&this.checkClientFilter(target,targetFilters)==false) { @@ -1198,6 +1198,11 @@ function AppServiceStream(app) { title="Mongo数据源:"; } + //elasticsearch + else if (target.indexOf("elasticsearch:")==0) { + + title="elasticsearch数据源:"; + } //mq else if (target.indexOf("mq:")==0) { diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 2e61cdc8..696f7f00 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -1031,7 +1031,7 @@ function conditionsAppend(){ if(checkFunc()){ var jsonObject; if("stream"==$("#condType").val()){ - jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; + jsonObject = {"type":"stream","expr":HtmlHelper.inputXSSFilter($("#contExpr").val()).replace(/\s+/g,''),"range":HtmlHelper.inputXSSFilter($("#conRange").val()),"func":HtmlHelper.inputXSSFilter($("#conFunc").val()),"cparam":HtmlHelper.inputXSSFilter($("#conFuncParam").val())}; }else{ jsonObject = {"type":"timer","time_from":HtmlHelper.inputXSSFilter($("#time_from").val()),"time_to":HtmlHelper.inputXSSFilter($("#time_to").val()),"metric":HtmlHelper.inputXSSFilter($("#conMetric").val()),"upperLimit":HtmlHelper.inputXSSFilter($("#conUpperLimit").val()),"lowerLimit":HtmlHelper.inputXSSFilter($("#conLowerLimit").val())}; @@ -1519,7 +1519,7 @@ var StgyClass = { /** * 策略编辑,保存按钮:关闭编辑,并且将策略结果追加到页面 */ - var html = document.getElementById("stgy_exp").innerHTML; + var html = document.getElementById("stgy_exp").innerHTML.replace('
', ''); var htmlConvergence = document.getElementById("convergence_exp").innerHTML.replace(/<\/?[^>]*>/g,''); if(html.length>0 && type=="add"){ diff --git a/com.creditease.uav.hook.esclient/findbugs.exclude.xml b/com.creditease.uav.hook.esclient/findbugs.exclude.xml new file mode 100644 index 00000000..db3ba5f4 --- /dev/null +++ b/com.creditease.uav.hook.esclient/findbugs.exclude.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/com.creditease.uav.hook.esclient/pom.xml b/com.creditease.uav.hook.esclient/pom.xml new file mode 100644 index 00000000..3730ab32 --- /dev/null +++ b/com.creditease.uav.hook.esclient/pom.xml @@ -0,0 +1,43 @@ + + + + ce-datamonitorsystem + com.creditease.moniter + 1.0 + ../com.creditease.uav.superpom + + 4.0.0 + + com.creditease.uav.hook.esclient + + + + com.creditease.moniter + com.creditease.uav.monitorframework.apm + + + com.creditease.moniter + com.creditease.uav.monitorframework.dproxy + + + org.javassist + javassist + 3.22.0-GA + provided + + + org.elasticsearch.client + transport + 5.4.1 + provided + + + org.apache.logging.log4j + log4j-to-slf4j + 2.8.2 + provided + + + \ No newline at end of file diff --git a/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/TransportHookProxy.java b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/TransportHookProxy.java new file mode 100644 index 00000000..f1b21b31 --- /dev/null +++ b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/TransportHookProxy.java @@ -0,0 +1,137 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.esclient.transport; + +import java.util.Map; + +import com.creditease.monitor.appfra.hook.spi.HookConstants; +import com.creditease.monitor.appfra.hook.spi.HookContext; +import com.creditease.monitor.appfra.hook.spi.HookProxy; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.uav.hook.esclient.transport.interceptors.TransportIT; +import com.creditease.uav.monitorframework.dproxy.DynamicProxyInstaller; +import com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor; +import com.creditease.uav.monitorframework.dproxy.bytecode.DPClass; +import com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod; +import com.creditease.uav.util.MonitorServerUtil; + +/** + * 支持Transport 5.0.0-6.2.3 + */ +public class TransportHookProxy extends HookProxy { + + private DynamicProxyInstaller dpInstaller; + + public TransportHookProxy(String id, @SuppressWarnings("rawtypes") Map config) { + + super(id, config); + dpInstaller = new DynamicProxyInstaller(); + } + + @Override + public void start(HookContext context, ClassLoader webapploader) { + + Event evt = context.get(Event.class); + + switch (evt) { + case SPRING_BEAN_REGIST: + case WEBCONTAINER_INIT: + insertIntercepter(context, webapploader); + break; + // when servlet init + case AFTER_SERVET_INIT: + break; + case BEFORE_SERVLET_DESTROY: + break; + case WEBCONTAINER_STARTED: + break; + case WEBCONTAINER_STOPPED: + break; + default: + break; + } + } + + @Override + public void stop(HookContext context, ClassLoader webapploader) { + + Event evt = context.get(Event.class); + + switch (evt) { + // when servlet init + case AFTER_SERVET_INIT: + break; + case BEFORE_SERVLET_DESTROY: + break; + case WEBCONTAINER_STARTED: + + break; + case WEBCONTAINER_STOPPED: + break; + default: + break; + } + } + + protected void insertIntercepter(HookContext context, ClassLoader webapploader) { + + if (isHookEventDone("insertIntercepter")) { + return; + } + + InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); + + String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); + String basePath = (String) ic.get(InterceptConstants.BASEPATH); + + final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath); + + doProxyInstall(webapploader, appid); + } + + public void doProxyInstall(ClassLoader webapploader, final String appid) { + + /** + * set the webapploader is the target classloader + */ + dpInstaller.setTargetClassLoader(webapploader); + + dpInstaller.installProxy("org.elasticsearch.transport.TransportService", + new String[] { "com.creditease.uav.hook.esclient.transport.interceptors" }, new DynamicProxyProcessor() { + + @Override + public void process(DPMethod m) throws Exception { + + if ("sendRequest".equals(m.getName())) { + DPClass[] ccs = m.getParameterTypes(); + if (ccs.length == 5 && ccs[0].getSimpleName().equals("DiscoveryNode")) { + dpInstaller.defineLocalVal(m, "mObj", TransportIT.class); + m.insertBefore("{mObj = new TransportIT(\"" + appid + "\");" + + "$5=mObj.doAsyncStart(new Object[]{$1, $2, $3, $4, $5});}"); + } + } + } + + }, false); + } +} diff --git a/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/interceptors/TransportIT.java b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/interceptors/TransportIT.java new file mode 100644 index 00000000..87e80eb3 --- /dev/null +++ b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/interceptors/TransportIT.java @@ -0,0 +1,172 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.esclient.transport.interceptors; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.CaptureContext; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.hook.esclient.transport.interceptors.TransportIT; +import com.creditease.uav.hook.esclient.transport.invokeChain.TransportAdapter; +import com.creditease.uav.util.JDKProxyInvokeUtil; + +import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.transport.TransportResponseHandler; + +public class TransportIT extends BaseComponent{ + + /** + * + * ESHandlerProxyInvokeProcessor description: + * + */ + @SuppressWarnings("rawtypes") + public class ESHandlerProxyInvokeProcessor extends JDKProxyInvokeProcessor { + + @Override + public void preProcess(TransportResponseHandler t, Object proxy, Method method, Object[] args) { + + } + + @Override + public void catchInvokeException(TransportResponseHandler t, Object proxy, Method method, Object[] args, Throwable e) { + + doEnd(method, args, -1, e); + } + + @Override + public Object postProcess(Object res, TransportResponseHandler t, Object proxy, Method method, Object[] args) { + + if (method.getName().equals("handleResponse")) { + doEnd(method, args, 1, null); + } + else if (method.getName().equals("handleException")){ + doEnd(method, args, -1, (Throwable)args[0]); + } + + return res; + } + + private void doEnd(Method method, Object[] args, int rc, Throwable e) { + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, "elasticsearch"); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL); + params.put(CaptureConstants.INFO_CLIENT_APPID, appid); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "elasticsearch.client"); + + if (e != null) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + + if (logger.isDebugable()) { + logger.debug("Elastaicsearch INVOKE Exception: " + targetURL + " action: " + esAction, null); + } + } + else if (logger.isDebugable()) { + logger.debug("Elastaicsearch INVOKE End: " + targetURL + " action: " + esAction, null); + } + + UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params, ccMap); + + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, ivcContextParams, + TransportAdapter.class, args); + } + + } + + private Map ccMap; + + private String targetURL = ""; + + private String esAction = ""; + + private String appid; + + private Map ivcContextParams = new HashMap(); + + public TransportIT(String appid) { + this.appid = appid; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Object doAsyncStart(Object[] args) { + + DiscoveryNode node = (DiscoveryNode) args[0]; + esAction = (String)args[1]; + TransportResponseHandler handler = (TransportResponseHandler)args[4]; + + String address = node.getHostAddress(); + Integer port = node.getAddress().getPort(); + + targetURL = "elasticsearch://" + address + ":" + port; + + if (logger.isDebugable()) { + logger.debug("Elastaicsearch INVOKE START: " + targetURL + " action: " + esAction, null); + } + + Map params = new HashMap(); + + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, esAction); + params.put(CaptureConstants.INFO_CLIENT_APPID, appid); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "elasticsearch.client"); + + + ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params, null); + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter", + TransportAdapter.class); + + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + TransportAdapter.class, args); + + if (handler == null) { + return null; + } + + handler = JDKProxyInvokeUtil.newProxyInstance(TransportResponseHandler.class.getClassLoader(), + new Class[] { TransportResponseHandler.class }, new JDKProxyInvokeHandler(handler, + new ESHandlerProxyInvokeProcessor())); + + return handler; + } + +} diff --git a/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/invokeChain/TransportAdapter.java b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/invokeChain/TransportAdapter.java new file mode 100644 index 00000000..c056aab8 --- /dev/null +++ b/com.creditease.uav.hook.esclient/src/main/java/com/creditease/uav/hook/esclient/transport/invokeChain/TransportAdapter.java @@ -0,0 +1,55 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.esclient.transport.invokeChain; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; + +public class TransportAdapter extends InvokeChainAdapter{ + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + + // 查找应用类信息所需的关键类名和相隔层数 + context.put(InvokeChainConstants.CLIENT_IT_KEY, + DataConvertHelper.toInt(System.getProperty("com.creditease.uav.invokechain.code.es.key"), 0)); + context.put(InvokeChainConstants.CLIENT_IT_CLASS, + System.getProperty("com.creditease.uav.invokechain.code.es.class")); + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + + } + +} diff --git a/com.creditease.uav.hook.esclient/src/test/java/com/creditease/uav/hook/esclient/DoTestTransportHookProxy.java b/com.creditease.uav.hook.esclient/src/test/java/com/creditease/uav/hook/esclient/DoTestTransportHookProxy.java new file mode 100644 index 00000000..ec6bdc9b --- /dev/null +++ b/com.creditease.uav.hook.esclient/src/test/java/com/creditease/uav/hook/esclient/DoTestTransportHookProxy.java @@ -0,0 +1,124 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.esclient; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; +import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; +import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.transport.client.PreBuiltTransportClient; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.helpers.StringHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.UAVServer.ServerVendor; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.log.ConsoleLogger; +import com.creditease.uav.hook.esclient.transport.TransportHookProxy; +import com.creditease.uav.monitorframework.agent.MOFAgent; + +/** + * DoTestTransportHookProxy description: ??? + * + */ +public class DoTestTransportHookProxy { + + @SuppressWarnings("unchecked") + public static void main(String[] args) throws IOException { + + ConsoleLogger cl = new ConsoleLogger("test"); + + cl.setDebugable(true); + + UAVServer.instance().setLog(cl); + + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR, ServerVendor.TOMCAT); + MOFAgent.mofContext.put("org.uavstack.mof.ext.clsloader", Thread.currentThread().getContextClassLoader()); + + TransportHookProxy p = new TransportHookProxy("test", Collections.emptyMap()); + + p.doProxyInstall(null, "testApp"); + + String[] esAddrs = {"127.0.0.1:9300"}; + String clusterName = ""; + String index = "esindex"; + String type = "String"; + String alias = "alias"; + Boolean result; + + Settings settings = Settings.EMPTY; + + if (!StringHelper.isEmpty(clusterName)) { + settings = Settings.builder().put("cluster.name", clusterName).build(); + } + + TransportClient client = new PreBuiltTransportClient(settings); + + for (String esAddr : esAddrs) { + String[] ipport = esAddr.split(":"); + client.addTransportAddress(new InetSocketTransportAddress( + new InetSocketAddress(ipport[0], DataConvertHelper.toInt(ipport[1], 9300)))); + } + + result = client.admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(); + if(result) { + result = client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet().isAcknowledged(); + } + + client.admin().indices().create(new CreateIndexRequest(index)).actionGet().isAcknowledged(); + + client.admin().indices().typesExists(new TypesExistsRequest(new String[] { index }, type)).actionGet().isExists(); + + client.admin().indices().prepareAliases().addAlias(index, alias).get().isAcknowledged(); + + client.admin().indices().prepareAliases().removeAlias(index, alias).get().isAcknowledged(); + + client.prepareSearch(index).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).get(TimeValue.timeValueMillis(15000)); + + Map m = new HashMap(); + m.put("user", "kimchy"); + m.put("postDate", new Date()); + m.put("message", "trying out Elasticsearch"); + + BulkRequestBuilder bulkRequest = client.prepareBulk(); + bulkRequest.add(client.prepareIndex("twitter", "tweet", "1").setSource(m)); + BulkResponse bulkResponse = bulkRequest.get(); + if (bulkResponse.hasFailures()) { + System.out.println("Failed"); + } + + client.close(); + } +} diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index 68ba24b5..776d0629 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -20,7 +20,7 @@ com.creditease.uav.interceptlisteners=com.creditease.uav.apm.invokechain.listene #com.creditease.uav.hookfactory.config gives the configuration of hooks for application framework such as CXF, Spring #this is a json array #each elem in this array like: {detect:"",jar:"",proxy:",supports:[,...]"} -com.creditease.uav.hookfactory.config=[{detect\:"javax.xml.ws.WSDLReader",jar\:"com.creditease.uav.hook.jaxws-1.0.jar",proxy\:"com.creditease.uav.hook.jaxws.JaxWSHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"],adapts:{"org.apache.cxf.frontend.ClientProxy":{"getClient":{args:["java.lang.Object"],target:0}}}},{detect\:"java.sql.DriverManager",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.JdbcHookProxy",adapts:{"com.alibaba.druid.pool.DruidAbstractDataSource":{"validateConnection":{args:["java.sql.Connection"],target:0,class:"com.alibaba.druid.proxy.jdbc.ConnectionProxy",preMethod:"getRawObject()"}},"com.alibaba.druid.pool.DruidDataSource":{"initExceptionSorter":{args:[],target:"driver",class:"java.sql.Driver"},"initValidConnectionChecker":{args:[],target:"driver",class:"java.sql.Driver"}}}},{detect\:"org.apache.http.client.HttpClient",jar\:"com.creditease.uav.hook.httpclients-1.0-sync.jar",proxy\:"com.creditease.uav.hook.httpclients.sync.HttpClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.commons.httpclient.HttpMethod",jar\:"com.creditease.uav.hook.httpclients-1.0-sync3.jar",proxy\:"com.creditease.uav.hook.httpclients3.sync.HttpClient3HookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.http.nio.client.HttpAsyncClient",jar\:"com.creditease.uav.hook.httpclients-1.0-async.jar",proxy\:"com.creditease.uav.hook.httpclients.async.HttpAsyncClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"redis.clients.jedis.Jedis",jar\:"com.creditease.uav.hook.redis-1.0-jedis.jar",proxy\:"com.creditease.uav.hook.redis.jedis.JedisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.lambdaworks.redis.RedisClient",jar\:"com.creditease.uav.hook.redis-1.0-lettuce.jar",proxy\:"com.creditease.uav.hook.redis.lettuce.LettuceHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.aredis.cache.AsyncRedisClient",jar\:"com.creditease.uav.hook.redis-1.0-aredis.jar",proxy\:"com.creditease.uav.hook.redis.aredis.AredisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.mongodb.Mongo",jar\:"com.creditease.uav.hook.mongoclients-1.0.jar",proxy\:"com.creditease.uav.hook.mongoclients.MongoClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.rabbitmq.client.Connection",jar\:"com.creditease.uav.hook.mq-1.0-rabbitmq.jar",proxy\:"com.creditease.uav.hook.rabbitmq.RabbitmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.alibaba.rocketmq.client.MQAdmin",jar\:"com.creditease.uav.hook.mq-1.0-rocketmq.jar",proxy\:"com.creditease.uav.hook.rocketmq.RocketmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.log4j.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.Log4jHookProxy"},{detect\:"ch.qos.logback.classic.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.LogBackHookProxy"},{detect\:"com.alibaba.dubbo.common.Constants",jar\:"com.creditease.uav.hook.dubbo-1.0.jar",proxy\:"com.creditease.uav.hook.dubbo.DubboHookProxy"},{detect\:"com.mchange.v2.c3p0.C3P0Registry",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.c3p0.C3P0HookProxy"},{detect\:"com.alibaba.druid.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.druid.DruidHookProxy"},{detect\:"org.logicalcobwebs.proxool.ProxoolConstants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.proxool.ProxoolHookProxy"},{detect\:"org.apache.commons.dbcp.DbcpException",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.commons.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.tomcat.dbcp.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"com.zaxxer.hikari.HikariConfigMXBean",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.hikari.HikariHookProxy"},{detect\:"org.apache.ibatis.datasource.DataSourceFactory",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.mybatis.MybatisHookProxy"}] +com.creditease.uav.hookfactory.config=[{detect\:"javax.xml.ws.WSDLReader",jar\:"com.creditease.uav.hook.jaxws-1.0.jar",proxy\:"com.creditease.uav.hook.jaxws.JaxWSHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"],adapts:{"org.apache.cxf.frontend.ClientProxy":{"getClient":{args:["java.lang.Object"],target:0}}}},{detect\:"java.sql.DriverManager",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.JdbcHookProxy",adapts:{"com.alibaba.druid.pool.DruidAbstractDataSource":{"validateConnection":{args:["java.sql.Connection"],target:0,class:"com.alibaba.druid.proxy.jdbc.ConnectionProxy",preMethod:"getRawObject()"}},"com.alibaba.druid.pool.DruidDataSource":{"initExceptionSorter":{args:[],target:"driver",class:"java.sql.Driver"},"initValidConnectionChecker":{args:[],target:"driver",class:"java.sql.Driver"}}}},{detect\:"org.apache.http.client.HttpClient",jar\:"com.creditease.uav.hook.httpclients-1.0-sync.jar",proxy\:"com.creditease.uav.hook.httpclients.sync.HttpClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.commons.httpclient.HttpMethod",jar\:"com.creditease.uav.hook.httpclients-1.0-sync3.jar",proxy\:"com.creditease.uav.hook.httpclients3.sync.HttpClient3HookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.http.nio.client.HttpAsyncClient",jar\:"com.creditease.uav.hook.httpclients-1.0-async.jar",proxy\:"com.creditease.uav.hook.httpclients.async.HttpAsyncClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"redis.clients.jedis.Jedis",jar\:"com.creditease.uav.hook.redis-1.0-jedis.jar",proxy\:"com.creditease.uav.hook.redis.jedis.JedisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.lambdaworks.redis.RedisClient",jar\:"com.creditease.uav.hook.redis-1.0-lettuce.jar",proxy\:"com.creditease.uav.hook.redis.lettuce.LettuceHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.aredis.cache.AsyncRedisClient",jar\:"com.creditease.uav.hook.redis-1.0-aredis.jar",proxy\:"com.creditease.uav.hook.redis.aredis.AredisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.mongodb.Mongo",jar\:"com.creditease.uav.hook.mongoclients-1.0.jar",proxy\:"com.creditease.uav.hook.mongoclients.MongoClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.rabbitmq.client.Connection",jar\:"com.creditease.uav.hook.mq-1.0-rabbitmq.jar",proxy\:"com.creditease.uav.hook.rabbitmq.RabbitmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.alibaba.rocketmq.client.MQAdmin",jar\:"com.creditease.uav.hook.mq-1.0-rocketmq.jar",proxy\:"com.creditease.uav.hook.rocketmq.RocketmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.log4j.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.Log4jHookProxy"},{detect\:"ch.qos.logback.classic.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.LogBackHookProxy"},{detect\:"com.alibaba.dubbo.common.Constants",jar\:"com.creditease.uav.hook.dubbo-1.0.jar",proxy\:"com.creditease.uav.hook.dubbo.DubboHookProxy"},{detect\:"com.mchange.v2.c3p0.C3P0Registry",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.c3p0.C3P0HookProxy"},{detect\:"com.alibaba.druid.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.druid.DruidHookProxy"},{detect\:"org.logicalcobwebs.proxool.ProxoolConstants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.proxool.ProxoolHookProxy"},{detect\:"org.apache.commons.dbcp.DbcpException",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.commons.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.tomcat.dbcp.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"com.zaxxer.hikari.HikariConfigMXBean",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.hikari.HikariHookProxy"},{detect\:"org.apache.ibatis.datasource.DataSourceFactory",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.mybatis.MybatisHookProxy"},{detect\:"org.elasticsearch.client.transport.TransportClient",jar\:"com.creditease.uav.hook.esclient-1.0.jar",proxy\:"com.creditease.uav.hook.esclient.transport.TransportHookProxy"}] #REMOVE CXF Hook{detect\:"org.apache.cxf.Bus",jar\:"com.creditease.uav.cxf2.6.plus-1.0.jar",proxy\:"com.creditease.cxfplus.CXFHookProxy"}, #hookfactory is using the application server webappclassloader to hack application framework such as CXF, Spring @@ -80,6 +80,8 @@ com.creditease.uav.invokechain.code.ws.key=1 com.creditease.uav.invokechain.code.ws.class=com.sun.proxy.* com.creditease.uav.invokechain.code.dubbo.consumer.key=2 com.creditease.uav.invokechain.code.dubbo.consumer.class=com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler +com.creditease.uav.invokechain.code.es.key=1 +com.creditease.uav.invokechain.code.es.class=org.elasticsearch.* #slowoper ivcdat com.creditease.uav.ivcdat.logroot=/data/uav/ivcdat diff --git a/com.creditease.uav.monitorframework.buildComponent/pom.xml b/com.creditease.uav.monitorframework.buildComponent/pom.xml index 9dbf796e..99d80c9f 100644 --- a/com.creditease.uav.monitorframework.buildComponent/pom.xml +++ b/com.creditease.uav.monitorframework.buildComponent/pom.xml @@ -31,6 +31,7 @@ ../com.creditease.uav.ttl ../com.creditease.uav.hook.dubbo ../com.creditease.uav.jetty.plus.core + ../com.creditease.uav.hook.esclient @@ -100,7 +101,8 @@ - + + diff --git a/com.creditease.uav.monitorframework.buildFat/pom.xml b/com.creditease.uav.monitorframework.buildFat/pom.xml index 238974ae..1efed0e2 100644 --- a/com.creditease.uav.monitorframework.buildFat/pom.xml +++ b/com.creditease.uav.monitorframework.buildFat/pom.xml @@ -291,6 +291,16 @@ struts2-config-browser-plugin ${struts2.version} + + org.elasticsearch.client + transport + 5.4.1 + + + org.apache.logging.log4j + log4j-to-slf4j + 2.8.2 + diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/invokechain/ElasticsearchService.java b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/invokechain/ElasticsearchService.java new file mode 100644 index 00000000..280c38dd --- /dev/null +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/invokechain/ElasticsearchService.java @@ -0,0 +1,95 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.monitorframework.fat.invokechain; + +import java.net.InetSocketAddress; + +import javax.inject.Singleton; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; +import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.transport.client.PreBuiltTransportClient; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.agent.helpers.StringHelper; + +/** + * 测试未与任何系统有交互的程序 + * + */ +@Singleton +@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8") +@Path("elasticsearch") +public class ElasticsearchService { + /** + * 测试用例 + * + * @return + */ + @SuppressWarnings("resource") + @GET + @Path("transportTest") + public String test() { + + String[] esAddrs = {"127.0.0.1:9300"}; + String clusterName = ""; + String index = "esindex"; + String type = "String"; + String alias = "alias"; + + Settings settings = Settings.EMPTY; + + if (!StringHelper.isEmpty(clusterName)) { + settings = Settings.builder().put("cluster.name", clusterName).build(); + } + + TransportClient client = new PreBuiltTransportClient(settings); + + for (String esAddr : esAddrs) { + String[] ipport = esAddr.split(":"); + client.addTransportAddress(new InetSocketTransportAddress( + new InetSocketAddress(ipport[0], DataConvertHelper.toInt(ipport[1], 9300)))); + } + + client.admin().indices().create(new CreateIndexRequest(index)).actionGet().isAcknowledged(); + + client.admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(); + + client.admin().indices().typesExists(new TypesExistsRequest(new String[] { index }, type)).actionGet().isExists(); + + client.admin().indices().prepareAliases().addAlias(index, alias).get().isAcknowledged(); + + client.admin().indices().prepareAliases().removeAlias(index, alias).get().isAcknowledged(); + + client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet().isAcknowledged(); + + return "transportTest"; + } +} From 0d63a142d10bf93bdabace041e93742ccfb1165e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Mon, 23 Apr 2018 17:42:58 +0800 Subject: [PATCH 59/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/255=20=E6=B7=BB=E5=8A=A0gitignore=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.creditease.uav.hook.esclient/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 com.creditease.uav.hook.esclient/.gitignore diff --git a/com.creditease.uav.hook.esclient/.gitignore b/com.creditease.uav.hook.esclient/.gitignore new file mode 100644 index 00000000..b83d2226 --- /dev/null +++ b/com.creditease.uav.hook.esclient/.gitignore @@ -0,0 +1 @@ +/target/ From e02d9ef231b7a46dc8d561951c0fe08ca43e29ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 27 Apr 2018 15:09:22 +0800 Subject: [PATCH 60/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/257=20logback=E6=94=AF=E6=8C=81asyncAppender=EF=BC=8CasyncAppe?= =?UTF-8?q?nder=E9=9C=80=E8=A6=81=E6=8C=87=E5=AE=9A=E5=85=B6=E4=BB=96appen?= =?UTF-8?q?der=E5=81=9A=E5=AE=9E=E9=99=85=E7=9A=84=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA=EF=BC=8C=E5=8E=9F=E6=9D=A5=E7=9A=84=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E8=BF=87=E6=BB=A4=E6=8E=89=E4=BA=86asyncAppender=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E9=92=88=E5=AF=B9asyncAppender?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9A=E7=9A=84fileAppender?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uav/log/hook/LogBackHookProxy.java | 91 ++++++++++--------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java b/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java index e72cad03..a359f12e 100644 --- a/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java +++ b/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java @@ -43,6 +43,7 @@ import com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod; import com.creditease.uav.profiling.handlers.log.LogProfileInfo; +import ch.qos.logback.classic.AsyncAppender; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.PatternLayout; @@ -136,55 +137,20 @@ private void figureOutLogBackConfig(HookContext context, ClassLoader webapploade private void figureoutLogConfiguration(Logger Logger, LinkedList list, String appid) { Iterator> appenders = Logger.iteratorForAppenders(); - while (appenders != null && appenders.hasNext()) { - - LogProfileInfo logProfileInfo = new LogProfileInfo(); - - if (appid != null) { - logProfileInfo.setAppId(appid); - } - - logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j); - - Map attributes = new HashMap(); - - attributes.put(LogProfileInfo.ENGINE, "logback"); - Appender appender = appenders.next(); - - if (!(appender instanceof FileAppender)) { - continue; + if (appender instanceof FileAppender) { + getAppenderInfo((FileAppender)appender, list, appid); } - - FileAppender fileAppender = (FileAppender) appender; - @SuppressWarnings("rawtypes") - LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder(); - - Layout layout = encoder.getLayout(); - - if (null != layout) { - - if (layout instanceof PatternLayout) { - PatternLayout patternLayout = (PatternLayout) encoder.getLayout(); - attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern()); - } - else if (layout instanceof HTMLLayout) { - attributes.put(LogProfileInfo.PATTERN, "HTMLLayout"); - } - else if (layout instanceof XMLLayout) { - attributes.put(LogProfileInfo.PATTERN, "XMLLayout"); - } - else if (layout instanceof TTLLLayout) { - attributes.put(LogProfileInfo.PATTERN, "TTCCLayout"); - } + else if(appender instanceof AsyncAppender) { + Iterator> itAppenders = (Iterator>)((AsyncAppender) appender).iteratorForAppenders(); + while (itAppenders != null && itAppenders.hasNext()) { + Appender ap = itAppenders.next(); + if (ap instanceof FileAppender) { + getAppenderInfo((FileAppender)ap, list, appid); + } + } } - - logProfileInfo.setFilePath(fileAppender.getFile()); - logProfileInfo.setAttributes(attributes); - - list.add(logProfileInfo); - } } @@ -224,4 +190,39 @@ public void process(DPMethod m) throws Exception { // release loader dpInstall.releaseTargetClassLoader(); } + + private void getAppenderInfo(FileAppender fileAppender, LinkedList list, String appid) { + + LogProfileInfo logProfileInfo = new LogProfileInfo(); + logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j); + logProfileInfo.setFilePath(fileAppender.getFile()); + if (appid != null) { + logProfileInfo.setAppId(appid); + } + + Map attributes = new HashMap(); + attributes.put(LogProfileInfo.ENGINE, "logback"); + + @SuppressWarnings("rawtypes") + LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder(); + Layout layout = encoder.getLayout(); + if (null != layout) { + if (layout instanceof PatternLayout) { + PatternLayout patternLayout = (PatternLayout) encoder.getLayout(); + attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern()); + } + else if (layout instanceof HTMLLayout) { + attributes.put(LogProfileInfo.PATTERN, "HTMLLayout"); + } + else if (layout instanceof XMLLayout) { + attributes.put(LogProfileInfo.PATTERN, "XMLLayout"); + } + else if (layout instanceof TTLLLayout) { + attributes.put(LogProfileInfo.PATTERN, "TTCCLayout"); + } + } + + logProfileInfo.setAttributes(attributes); + list.add(logProfileInfo); + } } From f771eab3a0b3c3dae7fba6b1f6ea8cafeb1413b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 27 Apr 2018 15:31:47 +0800 Subject: [PATCH 61/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/255=20=E4=BF=AE=E6=94=B9findbugs.exclude.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.creditease.uav.hook.esclient/findbugs.exclude.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.hook.esclient/findbugs.exclude.xml b/com.creditease.uav.hook.esclient/findbugs.exclude.xml index db3ba5f4..9f341378 100644 --- a/com.creditease.uav.hook.esclient/findbugs.exclude.xml +++ b/com.creditease.uav.hook.esclient/findbugs.exclude.xml @@ -1,4 +1,7 @@ - + + + + \ No newline at end of file From 37ea331cf512d393bcee0d0fbc9287b2d0a73e62 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Fri, 27 Apr 2018 15:35:27 +0800 Subject: [PATCH 62/97] https://github.com/uavorg/uavstack/issues/259 logagent optimization: 1.Increase the log output level 2.tailFiles and maybeReloadMap remove invalid inode nodes in logagent --- .../config/agent.properties | 2 + .../config/ma_pro.properties | 2 + .../config/ma_test.properties | 2 + .../creditease/agent/feature/LogAgent.java | 10 ++- .../logagent/ReliableTaildirEventReader.java | 48 ++++++++++----- .../feature/logagent/TailFileTaskJob.java | 5 +- .../feature/logagent/TaildirLogComponent.java | 4 +- .../ReliableTaildirEventReader.java | 61 +++++++++++++------ 8 files changed, 96 insertions(+), 38 deletions(-) diff --git a/com.creditease.uav.agent.buildComponent/config/agent.properties b/com.creditease.uav.agent.buildComponent/config/agent.properties index 0ecb6e9f..35db4f2c 100644 --- a/com.creditease.uav.agent.buildComponent/config/agent.properties +++ b/com.creditease.uav.agent.buildComponent/config/agent.properties @@ -145,6 +145,8 @@ feature.logagent.MutiThread.enable=true feature.logagent.MutiThread.thread.max=2 #default filter feature.logagent.defrule.filter= +#LOGAGENT LOG LEVEL +feature.logagent.log.level=DEBUG #Proc Detect Agent Feature feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar diff --git a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties index a69b8cc1..453d3c88 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_pro.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_pro.properties @@ -137,6 +137,8 @@ feature.logagent.MutiThread.enable=true feature.logagent.MutiThread.thread.max=2 #default filter feature.logagent.defrule.filter= +#LOGAGENT LOG LEVEL +feature.logagent.log.level=DEBUG #Proc Detect Agent Feature feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar diff --git a/com.creditease.uav.agent.buildComponent/config/ma_test.properties b/com.creditease.uav.agent.buildComponent/config/ma_test.properties index 32f05780..b8498ac7 100644 --- a/com.creditease.uav.agent.buildComponent/config/ma_test.properties +++ b/com.creditease.uav.agent.buildComponent/config/ma_test.properties @@ -137,6 +137,8 @@ feature.logagent.MutiThread.enable=true feature.logagent.MutiThread.thread.max=2 #default filter feature.logagent.defrule.filter= +#LOGAGENT LOG LEVEL +feature.logagent.log.level=DEBUG #Proc Detect Agent Feature feature.procscan.loader=com.creditease.uav.agent.heartbeat.jar diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/LogAgent.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/LogAgent.java index 6025049a..5405f0a7 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/LogAgent.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/LogAgent.java @@ -223,7 +223,11 @@ public LogAgent(String cName, String feature) { @Override protected ISystemLogger getLogger(String cName, String feature) { - return SystemLogger.getLogger("LogDataLog", feature + ".logd.%g.%u.log", "DEBUG", true, 5 * 1024 * 1024); + return SystemLogger.getLogger("LogDataLog", feature + ".logd.%g.%u.log", + StringHelper.isEmpty(this.getConfigManager().getFeatureConfiguration(this.feature, "log.level")) + ? "DEBUG" + : this.getConfigManager().getFeatureConfiguration(this.feature, "log.level"), + true, 5 * 1024 * 1024); } @Override @@ -669,7 +673,7 @@ public int compare(LogPatternInfo o1, LogPatternInfo o2) { * in some cases there are may no log pattern infos */ if (logCatcherInfoMap.isEmpty()) { - log.warn(this, + log.debug(this, "The logCatcherInfoMap is empty and will not update log pattern info in ProfileData for logCatcher."); return; } @@ -714,7 +718,7 @@ public int compare(LogPatternInfo o1, LogPatternInfo o2) { else { logCatcher.configure(logCatcherInfoMap); - log.info(this, "ApplicationServer LogCatcher updates SUCCESS"); + log.debug(this, "ApplicationServer LogCatcher updates SUCCESS"); } } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/ReliableTaildirEventReader.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/ReliableTaildirEventReader.java index d14d8ffb..44987c64 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/ReliableTaildirEventReader.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/ReliableTaildirEventReader.java @@ -188,29 +188,35 @@ public void loadPositionFile(String filePath) { inode = positionObject.getLong("inode"); pos = positionObject.getLong("pos"); file = positionObject.getString("file"); - // add line number - number = positionObject.getLongValue("num"); - for (Object v : Arrays.asList(inode, pos, file)) { - Preconditions.checkNotNull(v, "Detected missing value in position file. " + "inode: " + inode - + ", pos: " + pos + ", path: " + file); - } - TailFile tf = tailFiles.get(inode); - if (tf != null && tf.updatePos(file, inode, pos, number)) { - tailFiles.put(inode, tf); + Long currentInode = getInode(new File(file)); + if (!currentInode.equals(inode)) { + maybeReloadMap.remove(inode); } else { - // add old tail file into memory - maybeReloadMap.put(inode, new Long[] { pos, number }); - if (logger.isDebugEnable()) { - logger.debug(this, "add old&inInterrupt file: " + file + ", inode: " + inode + ", pos: " + pos); + // add line number + number = positionObject.getLongValue("num"); + for (Object v : Arrays.asList(inode, pos, file)) { + Preconditions.checkNotNull(v, "Detected missing value in position file. " + "inode: " + inode + + ", pos: " + pos + ", path: " + file); + } + TailFile tf = tailFiles.get(inode); + if (tf != null && tf.updatePos(file, inode, pos, number)) { + tailFiles.put(inode, tf); } + else { + // add old tail file into memory + maybeReloadMap.put(inode, new Long[] { pos, number }); + if (logger.isDebugEnable()) { + logger.debug(this, "add old&inInterrupt file: " + file + ", inode: " + inode + ", pos: " + pos); + } + } } } } catch (FileNotFoundException e1) { - logger.info(this, "File not found: " + filePath + ", not updating position"); + logger.err(this, "File not found: " + filePath + ", not updating position"); } catch (IOException e) { logger.err(this, "Failed loading positionFile: " + filePath, e); @@ -393,6 +399,7 @@ else if (logPatternInfo2.getFlag() == StateFlag.EXIST) { } for (File f : files) { long inode = getInode(f); + removeInvalidTFInode(f, inode); TailFile tf = tailFiles.get(inode); if (tf == null || !tf.getPath().equals(f.getAbsolutePath())) { long startPos = skipToEnd ? f.length() : 0;// 第一次读取从头开始读 @@ -432,6 +439,19 @@ else if (logPatternInfo2.getFlag() == StateFlag.EXIST) { return updatedInodes; } + /** + * @param f + * @param inodeCurrent + */ + private void removeInvalidTFInode(File f, long inodeCurrent) { + for (Long inodeKey : tailFiles.keySet()) { + TailFile tf = tailFiles.get(inodeKey); + if (tf.getPath().equals(f.getAbsolutePath()) && inodeKey != inodeCurrent) { + tailFiles.remove(inodeKey); + } + } + } + public List updateTailFiles() throws IOException { return updateTailFiles(false); diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TailFileTaskJob.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TailFileTaskJob.java index b52d78e1..5790e1ed 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TailFileTaskJob.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TailFileTaskJob.java @@ -81,8 +81,9 @@ protected void work() { log.err(this, "Unable to tail files.", t); } finally { - log.err(this, "finally invoked..."); - + if (log.isDebugEnable()) { + log.debug(this, "finally invoked..."); + } if (null != serverlogs) { serverlogs.clear(); } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TaildirLogComponent.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TaildirLogComponent.java index 3b047ce9..c81ba5e6 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TaildirLogComponent.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/logagent/TaildirLogComponent.java @@ -182,10 +182,10 @@ public synchronized void stop() { reader.close(); } catch (InterruptedException e) { - log.info(this, "Interrupted while awaiting termination", e); + log.err(this, "Interrupted while awaiting termination", e); } catch (IOException e) { - log.info(this, "Failed: " + e.getMessage(), e); + log.err(this, "Failed: " + e.getMessage(), e); } // sourceCounter.stop(); log.info("Taildir source {} stopped.", cName); diff --git a/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java b/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java index 2befc66c..7e2e164f 100644 --- a/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java +++ b/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java @@ -41,6 +41,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.creditease.agent.ConfigurationManager; +import com.creditease.agent.feature.logagent.TailFile; import com.creditease.agent.helpers.JVMToolHelper; import com.creditease.agent.helpers.NetworkHelper; import com.creditease.agent.helpers.StringHelper; @@ -182,6 +183,7 @@ else if (logPatternInfo2.getFlag() == StateFlag.EXIST) { } for (File f : files) { long inode = getInode(f); + removeInvalidTFInode(f, inode); TailFile tf = tailFiles.get(inode); if (tf == null || !tf.getPath().equals(f.getAbsolutePath())) { long startPos = skipToEnd ? f.length() : 0;// 第一次读取从头开始读 @@ -215,6 +217,19 @@ else if (logPatternInfo2.getFlag() == StateFlag.EXIST) { return updatedInodes; } + /** + * @param f + * @param inodeCurrent + */ + private void removeInvalidTFInode(File f, long inodeCurrent) { + for (Long inodeKey : tailFiles.keySet()) { + TailFile tf = tailFiles.get(inodeKey); + if (tf.getPath().equals(f.getAbsolutePath()) && inodeKey != inodeCurrent) { + tailFiles.remove(inodeKey); + } + } + } + private List getMatchFiles(File parentDir, final Pattern fileNamePattern) { FileFilter filter = new FileFilter() { @@ -427,28 +442,40 @@ public void loadPositions(String json) { inode = positionObject.getLong("inode"); pos = positionObject.getLong("pos"); file = positionObject.getString("file"); - // add line number - number = positionObject.getLongValue("num"); - for (Object v : Arrays.asList(inode, pos, file)) { - Preconditions.checkNotNull(v, "Detected missing value in position file. " + "inode: " + inode - + ", pos: " + pos + ", path: " + file); - } - TailFile tf = tailFiles.get(inode); + Long currentInode = 0L; try { - if (tf != null && tf.updatePos(file, inode, pos, number)) { - tailFiles.put(inode, tf); + currentInode = getInode(new File(file)); + } + catch (IOException e1) { + log.err(this, "TailFile updatePos FAILED,getInode Fail.", e1); + } + if (!currentInode.equals(inode)) { + maybeReloadMap.remove(inode); + } + else { + // add line number + number = positionObject.getLongValue("num"); + for (Object v : Arrays.asList(inode, pos, file)) { + Preconditions.checkNotNull(v, "Detected missing value in position file. " + "inode: " + inode + + ", pos: " + pos + ", path: " + file); } - else { - // add old tail file into memory - maybeReloadMap.put(inode, new Long[] { pos, number }); - if (log.isDebugEnable()) { - log.debug(this, "add old&inInterrupt file: " + file + ", inode: " + inode + ", pos: " + pos); + TailFile tf = tailFiles.get(inode); + try { + if (tf != null && tf.updatePos(file, inode, pos, number)) { + tailFiles.put(inode, tf); } + else { + // add old tail file into memory + maybeReloadMap.put(inode, new Long[] { pos, number }); + if (log.isDebugEnable()) { + log.debug(this, "add old&inInterrupt file: " + file + ", inode: " + inode + ", pos: " + pos); + } + } + } + catch (IOException e) { + log.err(this, "TailFile updatePos FAILED.", e); } - } - catch (IOException e) { - log.err(this, "TailFile updatePos FAILED.", e); } } } From edda1b706419f68347fe527397333e89b067b388 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Fri, 27 Apr 2018 17:24:58 +0800 Subject: [PATCH 63/97] https://github.com/uavorg/uavstack/issues/258 add kafka hook --- .../uavapp_godeye/appmonitor/js/uav.apm.js | 2 +- .../agent/helpers/StringHelper.java | 41 +++ com.creditease.uav.hook.mq/pom.xml | 18 +- .../uav/hook/kafka/KafkaHookProxy.java | 157 +++++++++ .../uav/hook/kafka/interceptors/KafkaIT.java | 324 ++++++++++++++++++ .../invokeChain/KafkaConsumerAdapter.java | 51 +++ .../invokeChain/KafkaProducerAdapter.java | 66 ++++ .../uav/hook/mq/DoTestkafkaHookProxy.java | 189 ++++++++++ .../config/uav.properties | 20 +- .../pom.xml | 3 +- .../pom.xml | 5 + .../monitorframework/fat/queue/KafkaTest.java | 182 ++++++++++ 12 files changed, 1054 insertions(+), 4 deletions(-) create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/KafkaHookProxy.java create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/interceptors/KafkaIT.java create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaConsumerAdapter.java create mode 100644 com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaProducerAdapter.java create mode 100644 com.creditease.uav.hook.mq/src/test/java/com/creditease/uav/hook/mq/DoTestkafkaHookProxy.java create mode 100644 com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/queue/KafkaTest.java diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js index ec5fd7d4..c0ee62da 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js @@ -1231,7 +1231,7 @@ function APMTool(app) { var obj = StringHelper.str2obj(result); var res = obj["rs"]; - if (obj=="ERR"||res=="ERR") { + if (obj=="ERR"||res=="ERR"||res==undefined) { alert("调用链查询操作["+intent+"]失败:"+result); } else { diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java index 3a4b575e..b603ecad 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java @@ -1014,4 +1014,45 @@ public static String getRandomNumber(int size) { } return num; } + + /** + * @param collection + * @param separator + * @return + */ + public static String join(Collection collection, String separator) { + if (collection == null) { + return null; + } + return join(collection.toArray(new String[collection.size()]), separator); + } + + /** + * Array can not be empty, the value in an array is empty and not appended to a string + * + * @param array + * @param separator + * @return + */ + public static String join(String[] array, String separator) { + if (array == null) { + return null; + } + + if (separator == null) { + separator = ""; + } + + StringBuilder builder = new StringBuilder(); + + for (int i = 0; i < array.length; i++) { + if (i > 0) { + builder.append(separator); + } + if (array[i] != null) { + builder.append(array[i]); + } + } + return builder.toString(); + } } diff --git a/com.creditease.uav.hook.mq/pom.xml b/com.creditease.uav.hook.mq/pom.xml index 183c18dd..e9b0b705 100644 --- a/com.creditease.uav.hook.mq/pom.xml +++ b/com.creditease.uav.hook.mq/pom.xml @@ -38,6 +38,12 @@ com.alibaba.rocketmq rocketmq-client 3.2.6 + + + org.apache.kafka + kafka-clients + 0.10.0.0 + provided @@ -68,7 +74,17 @@ - + + kafka + jar + package + + kafka + + **/com/creditease/uav/hook/kafka/** + + + diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/KafkaHookProxy.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/KafkaHookProxy.java new file mode 100644 index 00000000..f825a88c --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/KafkaHookProxy.java @@ -0,0 +1,157 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.kafka; + +import java.util.Map; + +import com.creditease.monitor.appfra.hook.spi.HookConstants; +import com.creditease.monitor.appfra.hook.spi.HookContext; +import com.creditease.monitor.appfra.hook.spi.HookProxy; +import com.creditease.monitor.interceptframework.spi.InterceptConstants; +import com.creditease.monitor.interceptframework.spi.InterceptContext; +import com.creditease.monitor.interceptframework.spi.InterceptContext.Event; +import com.creditease.uav.hook.kafka.interceptors.KafkaIT; +import com.creditease.uav.monitorframework.dproxy.DynamicProxyInstaller; +import com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor; +import com.creditease.uav.monitorframework.dproxy.bytecode.DPClass; +import com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod; +import com.creditease.uav.util.MonitorServerUtil; + +public class KafkaHookProxy extends HookProxy { + + private DynamicProxyInstaller dpInstaller; + + public KafkaHookProxy(String id, @SuppressWarnings("rawtypes") Map config) { + + super(id, config); + dpInstaller = new DynamicProxyInstaller(); + } + + @Override + public void start(HookContext context, ClassLoader webapploader) { + + Event evt = context.get(Event.class); + + switch (evt) { + case SPRING_BEAN_REGIST: + case WEBCONTAINER_INIT: + insertIntercepter(context, webapploader); + break; + // when servlet init + case AFTER_SERVET_INIT: + break; + case BEFORE_SERVLET_DESTROY: + break; + case WEBCONTAINER_STARTED: + break; + case WEBCONTAINER_STOPPED: + break; + default: + break; + } + } + + @Override + public void stop(HookContext context, ClassLoader webapploader) { + + Event evt = context.get(Event.class); + + switch (evt) { + // when servlet init + case AFTER_SERVET_INIT: + break; + case BEFORE_SERVLET_DESTROY: + break; + case WEBCONTAINER_STARTED: + break; + case WEBCONTAINER_STOPPED: + break; + default: + break; + } + } + + protected void insertIntercepter(HookContext context, ClassLoader webapploader) { + + if (isHookEventDone("insertIntercepter")) { + return; + } + + InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); + + String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); + String basePath = (String) ic.get(InterceptConstants.BASEPATH); + + final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath); + + doProxyInstall(webapploader, appid); + + } + + public void doProxyInstall(ClassLoader webapploader, final String appid) { + + /** + * set the webapploader is the target classloader + */ + dpInstaller.setTargetClassLoader(webapploader); + // KafkaConsumer + dpInstaller.installProxy("org.apache.kafka.clients.consumer.internals.Fetcher", + new String[] { "com.creditease.uav.hook.kafka.interceptors" }, new DynamicProxyProcessor() { + + @Override + public void process(DPMethod m) throws Exception { + + if ("parseRecord".equals(m.getName())) { + m.insertBefore("{KafkaIT.startPoll(\"" + appid + + "\",\"poll\", new Object[]{$1,$2,this.metadata});}"); + m.insertAfter("{KafkaIT.endPoll(\"poll\", new Object[]{$1,$2});}"); + dpInstaller.addCatch(m, "KafkaIT.endPoll(\"poll\",new Object[]{$e});"); + + } + } + + }, false); + // KafkaProducer + dpInstaller.installProxy("org.apache.kafka.clients.producer.KafkaProducer", + new String[] { "com.creditease.uav.hook.kafka.interceptors" }, new DynamicProxyProcessor() { + + @Override + public void process(DPMethod m) throws Exception { + if ("doSend".equals(m.getName())) { + DPClass[] dp = m.getParameterTypes(); + if (dp.length == 2) { + dpInstaller.defineLocalVal(m, "mObj", KafkaIT.class); + m.insertBefore("mObj=new KafkaIT(\"" + appid + + "\");{if($2 ==null){mObj.syncSendStart(\"" + appid + "\",\"" + m.getName() + + "\", new Object[]{this.producerConfig,$1});}else{$2=mObj.asyncSend(\"" + appid + + "\",\"" + m.getName() + "\", new Object[]{this.producerConfig,$1,$2});}}"); + + m.insertAfter("{mObj.syncSendEnd(new Object[]{$_,$2},\"" + m.getName() + "\");}"); + } + } + } + + }, false); + + dpInstaller.releaseTargetClassLoader(); + } + +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/interceptors/KafkaIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/interceptors/KafkaIT.java new file mode 100644 index 00000000..97490e56 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/interceptors/KafkaIT.java @@ -0,0 +1,324 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2018 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.kafka.interceptors; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.kafka.clients.Metadata; +import org.apache.kafka.clients.producer.Callback; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.Node; +import org.apache.kafka.common.TopicPartition; + +import com.creditease.agent.helpers.StringHelper; +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.captureframework.spi.CaptureContext; +import com.creditease.monitor.captureframework.spi.Monitor; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler; +import com.creditease.monitor.proxy.spi.JDKProxyInvokeProcessor; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.common.BaseComponent; +import com.creditease.uav.hook.kafka.invokeChain.KafkaConsumerAdapter; +import com.creditease.uav.hook.kafka.invokeChain.KafkaProducerAdapter; +import com.creditease.uav.util.JDKProxyInvokeUtil; + +public class KafkaIT extends BaseComponent { + + private static ThreadLocal tl = new ThreadLocal(); + private Map ivcContextParams = new HashMap(); + private String appid; + + private static String sendHost = ""; + private static String pollHost = ""; + + public KafkaIT(String appid) { + this.appid = appid; + } + + public static void startPoll(String appid, String methodName, Object[] args) { + KafkaIT kit = new KafkaIT(appid); + getPollHost((Metadata) args[2]); + kit.doPollStart(methodName, args); + tl.set(kit); + } + + public static void endPoll(String methodName, Object[] args) { + KafkaIT kit = tl.get(); + if (kit == null) { + return; + } + kit.doPollEnd(methodName, args); + tl.remove(); + } + + @SuppressWarnings({ "unchecked" }) + private void doPollStart(String methodName, Object[] args) { + TopicPartition tp = (TopicPartition) args[0]; + String kafkaUrl = pollHost + "/" + tp.topic(); + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, kafkaUrl); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Consumer." + methodName); + params.put(CaptureConstants.INFO_CLIENT_APPID, appid); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "kafka.client"); + if (logger.isDebugable()) { + logger.debug("KAFKA DOPOLL START: " + kafkaUrl, null); + } + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter", + KafkaConsumerAdapter.class); + + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + KafkaConsumerAdapter.class, args); + + } + + /** + * @param methodName + * @param args + */ + private void doPollEnd(String methodName, Object[] args) { + + int rc = -1; + + if (args != null && args.length > 0) { + if (!Throwable.class.isAssignableFrom(args[0].getClass())) { + rc = 1; + } + } + if (logger.isDebugable()) { + logger.debug("KAFKA " + methodName + " END: " + rc, null); + } + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, "kafka"); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + if (rc == -1) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, ((Throwable) args[0]).toString()); + } + + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, ivcContextParams, + KafkaConsumerAdapter.class, args); + + } + + @SuppressWarnings("unchecked") + public void syncSendStart(String appid, String methodName, Object[] args) { + getSendHost(args); + ProducerRecord record = (ProducerRecord) args[1]; + String kafkaUrl = sendHost + "/" + record.topic(); + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, kafkaUrl); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Producer." + methodName); + params.put(CaptureConstants.INFO_CLIENT_APPID, appid); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "kafka.client"); + if (logger.isDebugable()) { + logger.debug("KAFKA " + methodName + " START: " + kafkaUrl, null); + } + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params); + + // register adapter + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter", + KafkaProducerAdapter.class); + + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + KafkaProducerAdapter.class, args); + } + + public void syncSendEnd(Object[] args, String methodName) { + if (args != null && args.length > 0) { + if (args.length == 2 && null != args[1]) { + return; + } + } + + int rc = -1; + if (args != null && args.length > 0) { + if (!args[0].getClass().getName().equals("org.apache.kafka.clients.producer.KafkaProducer$FutureFailure")) { + rc = 1; + } + + } + if (logger.isDebugable()) { + logger.debug("KAFKA " + methodName + " END: " + rc, null); + } + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, "kafka"); + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + + UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params); + if (rc == -1) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, "kafka send msg Fail : KafkaProducer FutureFailure"); + } + + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, ivcContextParams, + KafkaProducerAdapter.class, args); + } + + /** + * @param metadata + * @return + */ + private static void getPollHost(Metadata metadata) { + if ("".equals(pollHost)) { + List nodesList = metadata.fetch().nodes(); + List nList = new ArrayList(); + for (int i = 0; i < nodesList.size(); i++) { + nList.add(nodesList.get(i).host() + ":" + nodesList.get(i).port()); + } + Collections.sort(nList); + pollHost = "mq:kafka://" + StringHelper.join(nList, ","); + } + } + + /** + * @param args + * @return + */ + private static String getSendHost(Object[] args) { + if ("".equals(sendHost)) { + ProducerConfig producerConfig = (ProducerConfig) args[0]; + Map config = (Map) producerConfig.originals(); + String[] urlArray = config.get("bootstrap.servers").toString().split(","); + Arrays.sort(urlArray); + sendHost = "mq:kafka://" + StringHelper.join(urlArray, ","); + } + return sendHost; + } + + private Map ccMap; + + @SuppressWarnings("unchecked") + public Object asyncSend(String appid, String methodName, Object[] args) { + ProducerRecord record = (ProducerRecord) args[1]; + String kafkaUrl = getSendHost(args) + "/" + record.topic(); + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, kafkaUrl); + params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, "Producer." + methodName); + params.put(CaptureConstants.INFO_CLIENT_APPID, appid); + params.put(CaptureConstants.INFO_CLIENT_TYPE, "kafka.client"); + if (logger.isDebugable()) { + logger.debug("KAFKA DOSEND START: " + kafkaUrl, null); + } + + ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.PRECAP, params, null); + ivcContextParams = (Map) UAVServer.instance().runSupporter( + "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, + KafkaProducerAdapter.class, args); + return JDKProxyInvokeUtil.newProxyInstance(Callback.class.getClassLoader(), new Class[] { Callback.class }, + new JDKProxyInvokeHandler((Callback) args[2], new KafkaCallbackProxyInvokeProcessor())); + } + + public class KafkaCallbackProxyInvokeProcessor extends JDKProxyInvokeProcessor { + + @Override + public void preProcess(Callback t, Object proxy, Method method, Object[] args) { + + } + + @Override + public Object postProcess(Object res, Callback t, Object proxy, Method method, Object[] args) { + doEnd(method, args, null); + return null; + } + + /** + * @param method + * @param args + * @param object + */ + private void doEnd(Method method, Object[] args, Throwable e) { + int rc = -1; + + Map params = new HashMap(); + params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, "kafka"); + if (args != null && args.length > 0 && null == e) { + if (null == args[1]) { + rc = 1; + } + else { + Exception ex = (Exception) args[1]; + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, ex.toString()); + if (logger.isDebugable()) { + logger.debug("kafka DOSEND EXCEPTION: " + ex.toString(), null); + } + } + } + else if (e != null) { + params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString()); + if (logger.isDebugable()) { + logger.debug("kafka DOSEND Exception: " + e.toString(), null); + } + } + if (logger.isDebugable()) { + logger.debug("KAFKA DOSEND END: " + rc, null); + } + params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc); + UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, + Monitor.CapturePhase.DOCAP, params, ccMap); + + if (ivcContextParams != null) { + ivcContextParams.putAll(params); + } + + UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", + InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, ivcContextParams, + KafkaProducerAdapter.class, args); + } + + @Override + public void catchInvokeException(Callback t, Object proxy, Method method, Object[] args, Throwable e) { + doEnd(method, args, e); + } + } + +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaConsumerAdapter.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaConsumerAdapter.java new file mode 100644 index 00000000..9d4a0ac7 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaConsumerAdapter.java @@ -0,0 +1,51 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2018 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ +package com.creditease.uav.hook.kafka.invokeChain; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; + +public class KafkaConsumerAdapter extends InvokeChainAdapter { + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + context.put(InvokeChainConstants.CLIENT_IT_KEY, DataConvertHelper + .toInt(System.getProperty("com.creditease.uav.invokechain.code.kafka.consumer.key"), 0)); + context.put(InvokeChainConstants.CLIENT_IT_CLASS, + System.getProperty("com.creditease.uav.invokechain.code.kafka.consumer.class")); + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + } + +} diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaProducerAdapter.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaProducerAdapter.java new file mode 100644 index 00000000..3e3a1597 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/kafka/invokeChain/KafkaProducerAdapter.java @@ -0,0 +1,66 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.kafka.invokeChain; + +import java.util.Map; + +import org.apache.kafka.clients.producer.ProducerConfig; + +import com.creditease.agent.helpers.DataConvertHelper; +import com.creditease.uav.apm.invokechain.span.Span; +import com.creditease.uav.apm.invokechain.spi.InvokeChainAdapter; +import com.creditease.uav.apm.invokechain.spi.InvokeChainConstants; +import com.creditease.uav.apm.invokechain.spi.InvokeChainContext; + +public class KafkaProducerAdapter extends InvokeChainAdapter { + + @Override + public void beforePreCap(InvokeChainContext context, Object[] args) { + context.put(InvokeChainConstants.CLIENT_IT_KEY, DataConvertHelper + .toInt(System.getProperty("com.creditease.uav.invokechain.code.kafka.producer.key"), 0)); + context.put(InvokeChainConstants.CLIENT_IT_CLASS, + System.getProperty("com.creditease.uav.invokechain.code.kafka.producer.class")); + + } + + @Override + public void afterPreCap(InvokeChainContext context, Object[] args) { + ProducerConfig producerConfig = (ProducerConfig) args[0]; + Map config = (Map) producerConfig.originals(); + + String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY); + Span span = this.spanFactory.getSpanFromContext(storeKey); + String spanMeta = this.spanFactory.getSpanMeta(span); + + config.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, spanMeta); + } + + @Override + public void beforeDoCap(InvokeChainContext context, Object[] args) { + + } + + @Override + public void afterDoCap(InvokeChainContext context, Object[] args) { + + } + +} diff --git a/com.creditease.uav.hook.mq/src/test/java/com/creditease/uav/hook/mq/DoTestkafkaHookProxy.java b/com.creditease.uav.hook.mq/src/test/java/com/creditease/uav/hook/mq/DoTestkafkaHookProxy.java new file mode 100644 index 00000000..09477c87 --- /dev/null +++ b/com.creditease.uav.hook.mq/src/test/java/com/creditease/uav/hook/mq/DoTestkafkaHookProxy.java @@ -0,0 +1,189 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2018 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.hook.mq; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.Callback; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.Producer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.clients.producer.RecordMetadata; + +import com.creditease.monitor.UAVServer; +import com.creditease.monitor.UAVServer.ServerVendor; +import com.creditease.monitor.captureframework.spi.CaptureConstants; +import com.creditease.monitor.log.ConsoleLogger; +import com.creditease.uav.hook.kafka.KafkaHookProxy; +import com.creditease.uav.monitorframework.agent.MOFAgent; + +public class DoTestkafkaHookProxy { + + static String url = "127.0.0.1:9092,127.0.0.2:9092,127.0.0.3:9092"; + + @SuppressWarnings("rawtypes") + public static void main(String[] args) { + + ConsoleLogger cl = new ConsoleLogger("test"); + + cl.setDebugable(true); + UAVServer.instance().setLog(cl); + + UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR, ServerVendor.TOMCAT); + MOFAgent.mofContext.put("org.uavstack.mof.ext.clsloader", Thread.currentThread().getContextClassLoader()); + + KafkaHookProxy p = new KafkaHookProxy("test", new HashMap()); + + p.doProxyInstall(null, "testApp"); + kafkaAsycnSendTest(); + kafkaSendTest(); + kafkaRecvTest(); + } + + private static void kafkaAsycnSendTest() { + Producer producer = createProducer(); + for (int i = 0; i <= 3; i++) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String testMsg = "this is producer send test msg,date:" + simpleDateFormat.format(new Date()); + String key = "key_" + i; + String topic = "test"; + if (i % 3 == 0) { + topic = "test1"; + } + producer.send(new ProducerRecord(topic, key, testMsg), new Callback() { + + public void onCompletion(RecordMetadata metadata, Exception exception) { + if (exception != null) { + exception.printStackTrace(); + System.out.println("find send exception:" + exception); + } + + System.out.println( + "send to partition(" + metadata.partition() + ")," + "offset(" + metadata.offset() + ")"); + + } + }); + + try { + TimeUnit.SECONDS.sleep(1); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + i++; + } + System.out.println("send message over."); + producer.close(100, TimeUnit.MILLISECONDS); + } + + /** + * + */ + private static void kafkaSendTest() { + Producer producer = createProducer(); + for (int i = 0; i <= 0; i++) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String testMsg = "this is producer send test msg,date:" + simpleDateFormat.format(new Date()); + String key = "key_" + i; + String topic = "test"; + if (i % 3 == 0) { + topic = "test1"; + } + try { + RecordMetadata fm = producer.send(new ProducerRecord(topic, key, testMsg)).get(); + + System.out.println(fm.topic() + "," + fm.offset()); + + } + catch (InterruptedException e) { + e.printStackTrace(); + } + catch (ExecutionException e) { + e.printStackTrace(); + } + try { + TimeUnit.SECONDS.sleep(1); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + } + System.out.println("send message over."); + producer.close(100, TimeUnit.MILLISECONDS); + + } + + private static Producer createProducer() { + Properties props = new Properties(); + props.put("bootstrap.servers", url); + // 请求完整性 + props.put("acks", "all"); + // 重试 + props.put("retries", 0); + // 缓冲批量 + props.put("batch.size", 16384); + // 缓冲处理等待时间 + props.put("linger.ms", 1); + // 缓冲内存 + props.put("buffer.memory", 33554432); + // 字符串类型 + props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + return new KafkaProducer(props); + } + + private static void kafkaRecvTest() { + + KafkaConsumer consumer = createConsumer(); + consumer.subscribe(Arrays.asList("test", "test1")); + for (int i = 0; i < 10; i++) { + ConsumerRecords records = consumer.poll(1000); + for (ConsumerRecord record : records) { + System.out.printf("offset=%d,key=%s,value=%s%n", record.offset(), record.key(), record.value()); + } + } + + consumer.close(); + } + + private static KafkaConsumer createConsumer() { + Properties props = new Properties(); + props.put("bootstrap.servers", url); + props.put("group.id", "test"); + props.put("enable.auto.commit", "true"); + props.put("auto.commit.interval.ms", "1000"); + props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + return new KafkaConsumer(props); + } + +} diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index 776d0629..e8960157 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -20,7 +20,25 @@ com.creditease.uav.interceptlisteners=com.creditease.uav.apm.invokechain.listene #com.creditease.uav.hookfactory.config gives the configuration of hooks for application framework such as CXF, Spring #this is a json array #each elem in this array like: {detect:"",jar:"",proxy:",supports:[,...]"} -com.creditease.uav.hookfactory.config=[{detect\:"javax.xml.ws.WSDLReader",jar\:"com.creditease.uav.hook.jaxws-1.0.jar",proxy\:"com.creditease.uav.hook.jaxws.JaxWSHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"],adapts:{"org.apache.cxf.frontend.ClientProxy":{"getClient":{args:["java.lang.Object"],target:0}}}},{detect\:"java.sql.DriverManager",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.JdbcHookProxy",adapts:{"com.alibaba.druid.pool.DruidAbstractDataSource":{"validateConnection":{args:["java.sql.Connection"],target:0,class:"com.alibaba.druid.proxy.jdbc.ConnectionProxy",preMethod:"getRawObject()"}},"com.alibaba.druid.pool.DruidDataSource":{"initExceptionSorter":{args:[],target:"driver",class:"java.sql.Driver"},"initValidConnectionChecker":{args:[],target:"driver",class:"java.sql.Driver"}}}},{detect\:"org.apache.http.client.HttpClient",jar\:"com.creditease.uav.hook.httpclients-1.0-sync.jar",proxy\:"com.creditease.uav.hook.httpclients.sync.HttpClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.commons.httpclient.HttpMethod",jar\:"com.creditease.uav.hook.httpclients-1.0-sync3.jar",proxy\:"com.creditease.uav.hook.httpclients3.sync.HttpClient3HookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.http.nio.client.HttpAsyncClient",jar\:"com.creditease.uav.hook.httpclients-1.0-async.jar",proxy\:"com.creditease.uav.hook.httpclients.async.HttpAsyncClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"redis.clients.jedis.Jedis",jar\:"com.creditease.uav.hook.redis-1.0-jedis.jar",proxy\:"com.creditease.uav.hook.redis.jedis.JedisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.lambdaworks.redis.RedisClient",jar\:"com.creditease.uav.hook.redis-1.0-lettuce.jar",proxy\:"com.creditease.uav.hook.redis.lettuce.LettuceHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.aredis.cache.AsyncRedisClient",jar\:"com.creditease.uav.hook.redis-1.0-aredis.jar",proxy\:"com.creditease.uav.hook.redis.aredis.AredisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.mongodb.Mongo",jar\:"com.creditease.uav.hook.mongoclients-1.0.jar",proxy\:"com.creditease.uav.hook.mongoclients.MongoClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.rabbitmq.client.Connection",jar\:"com.creditease.uav.hook.mq-1.0-rabbitmq.jar",proxy\:"com.creditease.uav.hook.rabbitmq.RabbitmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.alibaba.rocketmq.client.MQAdmin",jar\:"com.creditease.uav.hook.mq-1.0-rocketmq.jar",proxy\:"com.creditease.uav.hook.rocketmq.RocketmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.log4j.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.Log4jHookProxy"},{detect\:"ch.qos.logback.classic.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.LogBackHookProxy"},{detect\:"com.alibaba.dubbo.common.Constants",jar\:"com.creditease.uav.hook.dubbo-1.0.jar",proxy\:"com.creditease.uav.hook.dubbo.DubboHookProxy"},{detect\:"com.mchange.v2.c3p0.C3P0Registry",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.c3p0.C3P0HookProxy"},{detect\:"com.alibaba.druid.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.druid.DruidHookProxy"},{detect\:"org.logicalcobwebs.proxool.ProxoolConstants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.proxool.ProxoolHookProxy"},{detect\:"org.apache.commons.dbcp.DbcpException",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.commons.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.tomcat.dbcp.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"com.zaxxer.hikari.HikariConfigMXBean",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.hikari.HikariHookProxy"},{detect\:"org.apache.ibatis.datasource.DataSourceFactory",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.mybatis.MybatisHookProxy"},{detect\:"org.elasticsearch.client.transport.TransportClient",jar\:"com.creditease.uav.hook.esclient-1.0.jar",proxy\:"com.creditease.uav.hook.esclient.transport.TransportHookProxy"}] +com.creditease.uav.hookfactory.config=[{detect\:"javax.xml.ws.WSDLReader",jar\:"com.creditease.uav.hook.jaxws-1.0.jar",proxy\:"com.creditease.uav.hook.jaxws.JaxWSHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"],adapts:{"org.apache.cxf.frontend.ClientProxy":{"getClient":{args:["java.lang.Object"],target:0}}}},{detect\:"java.sql.DriverManager",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.JdbcHookProxy",adapts:{"com.alibaba.druid.pool.DruidAbstractDataSource":{"validateConnection":{args:["java.sql.Connection"],target:0,class:"com.alibaba.druid.proxy.jdbc.ConnectionProxy",preMethod:"getRawObject()"}},"com.alibaba.druid.pool.DruidDataSource":{"initExceptionSorter":{args:[],target:"driver",class:"java.sql.Driver"},"initValidConnectionChecker":{args:[],target:"driver",class:"java.sql.Driver"}}}},{detect\:"org.apache.http.client.HttpClient",jar\:"com.creditease.uav.hook.httpclients-1.0-sync.jar",proxy\:"com.creditease.uav.hook.httpclients.sync.HttpClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.commons.httpclient.HttpMethod",jar\:"com.creditease.uav.hook.httpclients-1.0-sync3.jar",proxy\:"com.creditease.uav.hook.httpclients3.sync.HttpClient3HookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.http.nio.client.HttpAsyncClient",jar\:"com.creditease.uav.hook.httpclients-1.0-async.jar",proxy\:"com.creditease.uav.hook.httpclients.async.HttpAsyncClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"redis.clients.jedis.Jedis",jar\:"com.creditease.uav.hook.redis-1.0-jedis.jar",proxy\:"com.creditease.uav.hook.redis.jedis.JedisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.lambdaworks.redis.RedisClient",jar\:"com.creditease.uav.hook.redis-1.0-lettuce.jar",proxy\:"com.creditease.uav.hook.redis.lettuce.LettuceHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.aredis.cache.AsyncRedisClient",jar\:"com.creditease.uav.hook.redis-1.0-aredis.jar",proxy\:"com.creditease.uav.hook.redis.aredis.AredisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.mongodb.Mongo",jar\:"com.creditease.uav.hook.mongoclients-1.0.jar",proxy\:"com.creditease.uav.hook.mongoclients.MongoClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.rabbitmq.client.Connection",jar\:"com.creditease.uav.hook.mq-1.0-rabbitmq.jar",proxy\:"com.creditease.uav.hook.rabbitmq.RabbitmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.alibaba.rocketmq.client.MQAdmin",jar\:"com.creditease.uav.hook.mq-1.0-rocketmq.jar",proxy\:"com.creditease.uav.hook.rocketmq.RocketmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.log4j.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.Log4jHookProxy"},{detect\:"ch.qos.logback.classic.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.LogBackHookProxy"},{detect\:"com.alibaba.dubbo.common.Constants",jar\:"com.creditease.uav.hook.dubbo-1.0.jar",proxy\:"com.creditease.uav.hook.dubbo.DubboHookProxy"},{detect\:"com.mchange.v2.c3p0.C3P0Registry",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.c3p0.C3P0HookProxy"},{detect\:"com.alibaba.druid.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.druid.DruidHookProxy"},{detect\:"org.logicalcobwebs.proxool.ProxoolConstants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.proxool.ProxoolHookProxy"},{detect\:"org.apache.commons.dbcp.DbcpException",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.commons.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.tomcat.dbcp.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"com.zaxxer.hikari.HikariConfigMXBean",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.hikari.HikariHookProxy"},{detect\:"org.apache.ibatis.datasource.DataSourceFactory",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.mybatis.MybatisHookProxy"},{detect\:"org.elasticsearch.client.transport.TransportClient",jar\:"com.creditease.uav.hook.esclient-1.0.jar",proxy\:"com.creditease.uav.hook.esclient.transport.TransportHookProxy"},{detect\: "org.apache.kafka.clients.Metadata",jar\: "com.creditease.uav.hook.mq-1.0-kafka.jar",proxy\:"com.creditease.uav.hook.kafka.KafkaHookProxy"}] + #REMOVE CXF Hook{detect\:"org.apache.cxf.Bus",jar\:"com.creditease.uav.cxf2.6.plus-1.0.jar",proxy\:"com.creditease.cxfplus.CXFHookProxy"}, + + #hookfactory is using the application server webappclassloader to hack application framework such as CXF, Spring +com.creditease.uav.invokechain.code.ws.key=1 +com.creditease.uav.invokechain.code.ws.class=com.sun.proxy.* +com.creditease.uav.invokechain.code.dubbo.consumer.key=2 +com.creditease.uav.invokechain.code.dubbo.consumer.class=com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler +com.creditease.uav.invokechain.code.kafka.producer.key=1 +com.creditease.uav.invokechain.code.kafka.producer.class=org.apache.kafka.clients.producer.KafkaProducer +com.creditease.uav.invokechain.code.kafka.consumer.key=1 +com.creditease.uav.invokechain.code.kafka.consumer.class=org.apache.kafka.clients.consumer.KafkaConsumer +com.creditease.uav.invokechain.code.es.key=1 +com.creditease.uav.invokechain.code.es.class=org.elasticsearch.* + +#slowoper ivcdat +com.creditease.uav.ivcdat.logroot=/data/uav/ivcdat +com.creditease.uav.ivcdat.logbuffer=100 + #REMOVE CXF Hook{detect\:"org.apache.cxf.Bus",jar\:"com.creditease.uav.cxf2.6.plus-1.0.jar",proxy\:"com.creditease.cxfplus.CXFHookProxy"}, #hookfactory is using the application server webappclassloader to hack application framework such as CXF, Spring diff --git a/com.creditease.uav.monitorframework.buildComponent/pom.xml b/com.creditease.uav.monitorframework.buildComponent/pom.xml index 99d80c9f..7042e6d0 100644 --- a/com.creditease.uav.monitorframework.buildComponent/pom.xml +++ b/com.creditease.uav.monitorframework.buildComponent/pom.xml @@ -102,7 +102,8 @@ - + + diff --git a/com.creditease.uav.monitorframework.buildFat/pom.xml b/com.creditease.uav.monitorframework.buildFat/pom.xml index 1efed0e2..a99d91e2 100644 --- a/com.creditease.uav.monitorframework.buildFat/pom.xml +++ b/com.creditease.uav.monitorframework.buildFat/pom.xml @@ -301,6 +301,11 @@ log4j-to-slf4j 2.8.2 + + org.apache.kafka + kafka-clients + 0.10.0.0 + diff --git a/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/queue/KafkaTest.java b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/queue/KafkaTest.java new file mode 100644 index 00000000..2a45048e --- /dev/null +++ b/com.creditease.uav.monitorframework.buildFat/src/main/java/com/creditease/monitorframework/fat/queue/KafkaTest.java @@ -0,0 +1,182 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2018 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.monitorframework.fat.queue; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import javax.inject.Singleton; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.Callback; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.Producer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.clients.producer.RecordMetadata; + +import com.creditease.agent.log.SystemLogger; + +/** + * KafkaTest description: ??? + * + */ +@Singleton +@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8") +@Path("kafka") +public class KafkaTest { + + String url = "127.0.0.1:9092,127.0.0.2:9092,127.0.0.3:9092"; + + @GET + @Path("kafkaSyncSend") + @Produces(MediaType.TEXT_HTML + ";charset=utf-8") + public String kafkaSyncSend() { + + SystemLogger.init("DEBUG", true, 0); + System.out.println("TEST kafkaSyncSend ======================================================"); + Producer producer = createProducer(); + for (int i = 0; i <= 5; i++) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String testMsg = "this is producer send test msg,date:" + simpleDateFormat.format(new Date()); + String key = "linlinwang3TestKey" + i; + String topic = "test"; + if (i % 3 == 0) { + topic = "test1"; + + } + try { + // 同步发送 + producer.send(new ProducerRecord(topic, key, testMsg)).get(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + catch (ExecutionException e) { + e.printStackTrace(); + } + + } + + System.out.println("send message over."); + producer.close(100, TimeUnit.MILLISECONDS); + return "kafkaSyncSend"; + } + + @GET + @Path("kafkaAsyncSend") + @Produces(MediaType.TEXT_HTML + ";charset=utf-8") + public String kafkaAsyncSend() { + + SystemLogger.init("DEBUG", true, 0); + System.out.println("TEST kafkaAsyncSend ======================================================"); + Producer producer = createProducer(); + for (int i = 0; i <= 4; i++) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String testMsg = "this is producer send test msg,date:" + simpleDateFormat.format(new Date()); + String key = "linlinwang3TestKey" + i; + String topic = "test"; + if (i % 3 == 0) { + topic = "test1"; + + } + // 异步发送 + producer.send(new ProducerRecord(topic, key, testMsg), new Callback() { + + public void onCompletion(RecordMetadata metadata, Exception exception) { + if (exception != null) { + exception.printStackTrace(); + System.out.println("find send exception:" + exception); + } + + System.out.println( + "send to partition(" + metadata.partition() + ")," + "offset(" + metadata.offset() + ")"); + + } + }); + } + + System.out.println("send message over."); + return "kafkaAsyncSend"; + } + + private Producer createProducer() { + Properties props = new Properties(); + props.put("bootstrap.servers", url); + // 请求完整性 + props.put("acks", "all"); + // 重试 + props.put("retries", 0); + // 缓冲批量 + props.put("batch.size", 16384); + // 缓冲处理等待时间 + props.put("linger.ms", 1); + // 缓冲内存 + props.put("buffer.memory", 33554432); + // 字符串类型 + props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + Producer producer = new KafkaProducer(props); + return producer; + } + + @GET + @Path("kafkaRecv") + @Produces(MediaType.TEXT_HTML + ";charset=utf-8") + public String kafkaRecv() { + + SystemLogger.init("DEBUG", true, 0); + System.out.println("TEST kafkaRecv ======================================================"); + KafkaConsumer consumer = createConsumer(); + consumer.subscribe(Arrays.asList("test", "test1")); + String result = ""; + for (int i = 0; i < 10; i++) { + ConsumerRecords records = consumer.poll(100); + for (ConsumerRecord record : records) { + result += "offset=%d,key=%s,value=%s%n" + record.offset() + record.key() + record.value(); + } + } + consumer.close(); + return "".equals(result) ? "NODATA" : result; + } + + private KafkaConsumer createConsumer() { + Properties props = new Properties(); + props.put("bootstrap.servers", url); + props.put("group.id", "test"); + props.put("enable.auto.commit", "true"); + props.put("auto.commit.interval.ms", "1000"); + props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + KafkaConsumer consumer = new KafkaConsumer(props); + return consumer; + } +} From 9db9348c1d9c655582d181b19631bd9e25b214e3 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Fri, 27 Apr 2018 18:36:32 +0800 Subject: [PATCH 64/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/259=20logagent=E4=BC=98=E5=8C=96=E5=8E=BB=E6=8E=89=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collect/client/copylogagent/ReliableTaildirEventReader.java | 1 - 1 file changed, 1 deletion(-) diff --git a/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java b/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java index 7e2e164f..252e6b7a 100644 --- a/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java +++ b/com.creditease.uav.collect/src/main/java/com/creditease/uav/collect/client/copylogagent/ReliableTaildirEventReader.java @@ -41,7 +41,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.creditease.agent.ConfigurationManager; -import com.creditease.agent.feature.logagent.TailFile; import com.creditease.agent.helpers.JVMToolHelper; import com.creditease.agent.helpers.NetworkHelper; import com.creditease.agent.helpers.StringHelper; From ff349fc9ba4178b6a02c44e68f7bb68375b0a827 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Sat, 28 Apr 2018 12:27:51 +0800 Subject: [PATCH 65/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/258=20kafka=E8=B0=83=E7=94=A8=E9=93=BE=E7=B1=BB=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/uav.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index e8960157..27a3dba9 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -100,6 +100,10 @@ com.creditease.uav.invokechain.code.dubbo.consumer.key=2 com.creditease.uav.invokechain.code.dubbo.consumer.class=com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler com.creditease.uav.invokechain.code.es.key=1 com.creditease.uav.invokechain.code.es.class=org.elasticsearch.* +com.creditease.uav.invokechain.code.kafka.producer.key=1 +com.creditease.uav.invokechain.code.kafka.producer.class=org.apache.kafka.clients.producer.KafkaProducer +com.creditease.uav.invokechain.code.kafka.consumer.key=1 +com.creditease.uav.invokechain.code.kafka.consumer.class=org.apache.kafka.clients.consumer.KafkaConsumer #slowoper ivcdat com.creditease.uav.ivcdat.logroot=/data/uav/ivcdat From d5318bc2bb30b4f67551f3bdf4aa63a3bacfde76 Mon Sep 17 00:00:00 2001 From: linlinwang3 Date: Sat, 28 Apr 2018 12:33:41 +0800 Subject: [PATCH 66/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/258=20kafka=E8=B0=83=E7=94=A8=E9=93=BE=E7=B1=BB=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/uav.properties | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index 27a3dba9..e0561558 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -22,26 +22,7 @@ com.creditease.uav.interceptlisteners=com.creditease.uav.apm.invokechain.listene #each elem in this array like: {detect:"",jar:"",proxy:",supports:[,...]"} com.creditease.uav.hookfactory.config=[{detect\:"javax.xml.ws.WSDLReader",jar\:"com.creditease.uav.hook.jaxws-1.0.jar",proxy\:"com.creditease.uav.hook.jaxws.JaxWSHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"],adapts:{"org.apache.cxf.frontend.ClientProxy":{"getClient":{args:["java.lang.Object"],target:0}}}},{detect\:"java.sql.DriverManager",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.JdbcHookProxy",adapts:{"com.alibaba.druid.pool.DruidAbstractDataSource":{"validateConnection":{args:["java.sql.Connection"],target:0,class:"com.alibaba.druid.proxy.jdbc.ConnectionProxy",preMethod:"getRawObject()"}},"com.alibaba.druid.pool.DruidDataSource":{"initExceptionSorter":{args:[],target:"driver",class:"java.sql.Driver"},"initValidConnectionChecker":{args:[],target:"driver",class:"java.sql.Driver"}}}},{detect\:"org.apache.http.client.HttpClient",jar\:"com.creditease.uav.hook.httpclients-1.0-sync.jar",proxy\:"com.creditease.uav.hook.httpclients.sync.HttpClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.commons.httpclient.HttpMethod",jar\:"com.creditease.uav.hook.httpclients-1.0-sync3.jar",proxy\:"com.creditease.uav.hook.httpclients3.sync.HttpClient3HookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.http.nio.client.HttpAsyncClient",jar\:"com.creditease.uav.hook.httpclients-1.0-async.jar",proxy\:"com.creditease.uav.hook.httpclients.async.HttpAsyncClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"redis.clients.jedis.Jedis",jar\:"com.creditease.uav.hook.redis-1.0-jedis.jar",proxy\:"com.creditease.uav.hook.redis.jedis.JedisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.lambdaworks.redis.RedisClient",jar\:"com.creditease.uav.hook.redis-1.0-lettuce.jar",proxy\:"com.creditease.uav.hook.redis.lettuce.LettuceHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.aredis.cache.AsyncRedisClient",jar\:"com.creditease.uav.hook.redis-1.0-aredis.jar",proxy\:"com.creditease.uav.hook.redis.aredis.AredisHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.mongodb.Mongo",jar\:"com.creditease.uav.hook.mongoclients-1.0.jar",proxy\:"com.creditease.uav.hook.mongoclients.MongoClientHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.rabbitmq.client.Connection",jar\:"com.creditease.uav.hook.mq-1.0-rabbitmq.jar",proxy\:"com.creditease.uav.hook.rabbitmq.RabbitmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"com.alibaba.rocketmq.client.MQAdmin",jar\:"com.creditease.uav.hook.mq-1.0-rocketmq.jar",proxy\:"com.creditease.uav.hook.rocketmq.RocketmqHookProxy",supports:["com.creditease.uav.monitorframework.dproxy-1.0-dproxy.jar"]},{detect\:"org.apache.log4j.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.Log4jHookProxy"},{detect\:"ch.qos.logback.classic.Logger",jar\:"com.creditease.uav.loghook-1.0.jar",proxy\:"com.creditease.uav.log.hook.LogBackHookProxy"},{detect\:"com.alibaba.dubbo.common.Constants",jar\:"com.creditease.uav.hook.dubbo-1.0.jar",proxy\:"com.creditease.uav.hook.dubbo.DubboHookProxy"},{detect\:"com.mchange.v2.c3p0.C3P0Registry",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.c3p0.C3P0HookProxy"},{detect\:"com.alibaba.druid.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.druid.DruidHookProxy"},{detect\:"org.logicalcobwebs.proxool.ProxoolConstants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.proxool.ProxoolHookProxy"},{detect\:"org.apache.commons.dbcp.DbcpException",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.commons.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"org.apache.tomcat.dbcp.dbcp2.Constants",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.dbcp.DBCPHookProxy"},{detect\:"com.zaxxer.hikari.HikariConfigMXBean",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.hikari.HikariHookProxy"},{detect\:"org.apache.ibatis.datasource.DataSourceFactory",jar\:"com.creditease.uav.hook.jdbc-1.0.jar",proxy\:"com.creditease.uav.hook.jdbc.pools.mybatis.MybatisHookProxy"},{detect\:"org.elasticsearch.client.transport.TransportClient",jar\:"com.creditease.uav.hook.esclient-1.0.jar",proxy\:"com.creditease.uav.hook.esclient.transport.TransportHookProxy"},{detect\: "org.apache.kafka.clients.Metadata",jar\: "com.creditease.uav.hook.mq-1.0-kafka.jar",proxy\:"com.creditease.uav.hook.kafka.KafkaHookProxy"}] #REMOVE CXF Hook{detect\:"org.apache.cxf.Bus",jar\:"com.creditease.uav.cxf2.6.plus-1.0.jar",proxy\:"com.creditease.cxfplus.CXFHookProxy"}, - #hookfactory is using the application server webappclassloader to hack application framework such as CXF, Spring -com.creditease.uav.invokechain.code.ws.key=1 -com.creditease.uav.invokechain.code.ws.class=com.sun.proxy.* -com.creditease.uav.invokechain.code.dubbo.consumer.key=2 -com.creditease.uav.invokechain.code.dubbo.consumer.class=com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler -com.creditease.uav.invokechain.code.kafka.producer.key=1 -com.creditease.uav.invokechain.code.kafka.producer.class=org.apache.kafka.clients.producer.KafkaProducer -com.creditease.uav.invokechain.code.kafka.consumer.key=1 -com.creditease.uav.invokechain.code.kafka.consumer.class=org.apache.kafka.clients.consumer.KafkaConsumer -com.creditease.uav.invokechain.code.es.key=1 -com.creditease.uav.invokechain.code.es.class=org.elasticsearch.* - -#slowoper ivcdat -com.creditease.uav.ivcdat.logroot=/data/uav/ivcdat -com.creditease.uav.ivcdat.logbuffer=100 - -#REMOVE CXF Hook{detect\:"org.apache.cxf.Bus",jar\:"com.creditease.uav.cxf2.6.plus-1.0.jar",proxy\:"com.creditease.cxfplus.CXFHookProxy"}, - -#hookfactory is using the application server webappclassloader to hack application framework such as CXF, Spring #com.creditease.uav..hookfactory is the class extends HooKFactory, is the application server vendor name such as tomcat #com.creditease.uav.tomcat.hookfactory=com.creditease.tomcat.plus.hook.TomcatHookFactory @@ -104,7 +85,6 @@ com.creditease.uav.invokechain.code.kafka.producer.key=1 com.creditease.uav.invokechain.code.kafka.producer.class=org.apache.kafka.clients.producer.KafkaProducer com.creditease.uav.invokechain.code.kafka.consumer.key=1 com.creditease.uav.invokechain.code.kafka.consumer.class=org.apache.kafka.clients.consumer.KafkaConsumer - #slowoper ivcdat com.creditease.uav.ivcdat.logroot=/data/uav/ivcdat com.creditease.uav.ivcdat.logbuffer=100 From 5888ae9d8a1463a04288f71a57c91aa0e855eb30 Mon Sep 17 00:00:00 2001 From: xiaojieshi <38932502+xiaojieshi@users.noreply.github.com> Date: Thu, 3 May 2018 12:00:20 +0800 Subject: [PATCH 67/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6dcebe4..983612de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # UAVStack UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 -它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 +它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等..。 UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. From 44cc6de1183a06b8ab36a308f323bf5e27591a83 Mon Sep 17 00:00:00 2001 From: xiaojieshi <38932502+xiaojieshi@users.noreply.github.com> Date: Thu, 3 May 2018 12:02:28 +0800 Subject: [PATCH 68/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 983612de..f6dcebe4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # UAVStack UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 -它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等..。 +它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. From a95c3f89dae8ecf95f8fb6d6dcf7637311f263ba Mon Sep 17 00:00:00 2001 From: xiaojieshi <38932502+xiaojieshi@users.noreply.github.com> Date: Thu, 3 May 2018 16:36:35 +0800 Subject: [PATCH 69/97] Update README.md --- README.md | 178 +++++++++++++++++++++++------------------------------- 1 file changed, 77 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index f6dcebe4..78b7ff8a 100644 --- a/README.md +++ b/README.md @@ -1,132 +1,114 @@ # UAVStack -UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 -它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 +UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. -UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. - -It includes AIOps Robot (HIT),full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM) etc.. - - -目前UAVStack开源系列 ( 官方网站:https://uavorg.github.io/main/ ) 包括 - -UAVStack Open Source series includes UAV.Monitor, UAV.APM, UAV.ServiceGovern, UAV.MSCP +Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP ![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) -# 更新模式 Project Updating Principle -* 开源系列源代码Issue更新,将与内部版本完全同步,最低频率每周一次 -* 开源系列源代码相关的功能优化,将与内部版本完全同步,最低频率每周一次 -* 开源系列源代码相关的新功能开放,会提前一周预告,并于下周内发布 -* 标准部署包下载会与源代码更新同步,最低频率每周一次 -* AllInOne开发演示版原则上每月更新一次(打包上传比较耗时),中间更新请下载标准部署包替换 ---- -* The open source series updating is fully synchronized with the internal version, with the lowest frequency once a week -* The open source series related functional optimizations is fully synchronized with the internal version, with the lowest frequency once a week -* The open source series related new features will be announced a week ahead of schedule, and released next week -* The standard deployment pack download is synchronized with source code updates, with the lowest frequency once a week -* AllInOne pack are updated once a month (packaged, uploaded, and time-consuming) in principle, and you can download the standard deployment package instead - +# Updating Rules +* Updates of the open source series (at least once a week) shall synchronize with those of the internal versions. +* Feature optimization of the open source series (at least once a week) shall synchronize with that of the internal versions as well. +* New features of the open source series shall be preannounced one week earlier and released within the following week. +* The standard deployment package shall synchronize with the updated source code (at least once a week). +* The AllInOne Demo Package is scheduled to be updated once a month. Please download the standard deployment package updated beyond the schedule. -# 工程说明 Source Code Project Description -uavstack是UAVStack的All in One源代码仓库。 +# Project Description uavstack is the All in One source repository of UAVStack. -## 根POM -* com.creditease.uav.superpom 根POM,包含依赖管理,Build所需plugins等 (Parent POM for dependency management & build plugins) +## Parent POM +* com.creditease.uav.superpom: parent POM that support dependency management and build plugins ## UAV.Monitor -* com.creditease.uav.agent 监控代理程序MonitorAgent核心框架 (Core of MonitorAgent) -* com.creditease.uav.healthmanager Monitor核心服务,包括实时数据,画像数据存储/查询,实时报警流式计算,AppHub支持服务 (Core feature of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time alarm streaming,AppHub Support Service) -* com.creditease.uav.notifycenter Monitor服务:报警中心服务端 (Notification Center Service) -* com.creditease.uav.monitorframework 探针MOF核心框架 (Core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc...) -* com.creditease.uav.monitorframework.agent 探针MOF的javaagent实现 (JVM MonitorFramework javaagent support) -* com.creditease.uav.monitorframework.dproxy javaassit支持 (JVM MonitorFramework javassit support) -* com.creditease.uav.hook.* 探针MOF针对技术规范的钩子,包括Dubbo,HttpClients,JAXWS,JDBC,MongoClients,MQ,Redis等 (JVM MonitorFramework Hooks for application framework) -* com.creditease.uav.loghook 探针MOF针对log4j,logback支持 (JVM MonitorFramework Hook for log4j, logback) -* com.creditease.uav.tomcat.plus.core 探针MOF对Tomcat/SpringBoot的支持 (JVM MonitorFramework extension for Tomcat/SpringBoot) -* com.creditease.uav.jetty.plus.core 探针MOF对Jetty支持 (JVM MonitorFramework extension for Jetty) -* com.creditease.uav.mock.sl4j 去除某些框架依赖sl4j (mock sl4j) -* com.creditease.uav.ttl com.alibaba.ttl源代码引入 (Alibaba TTL) -* com.creditease.uav.monitorframework.buildFat WAR测试程序 (Function Test of JVM MonitorFramework) -* com.creditease.uav.monitorframework.springbootFat SpringBoot测试程序 (Function Test of JVM MonitorFramework for springboot) -* com.creditease.uav.agent.buildComponent 制作监控代理程序部署包 (Build POM for MonitorAgent) -* com.creditease.uav.healthmanager.buildComponent 制作健康管理程序部署包 (Build POM for HealthManager) -* com.creditease.uav.monitorframework.buildComponent 制作探针MOF部署包 (Build POM for JVM MonitorFramework) +* com.creditease.uav.agent: core of MonitorAgent +* com.creditease.uav.healthmanager: core features of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time Alarm Streaming and AppHub Support Service +* com.creditease.uav.notifycenter: Notification Center Service +* com.creditease.uav.monitorframework: core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc... +* com.creditease.uav.monitorframework.agent: JVM MonitorFramework javaagent support +* com.creditease.uav.monitorframework.dproxy: JVM MonitorFramework javassit support +* com.creditease.uav.hook.* : JVM MonitorFramework Hooks for application framework, including Dubbo, HttpClients, JAXWS, JDBC, MongoClients, MQ, Redis, etc. +* com.creditease.uav.loghook: JVM MonitorFramework Hook for log4j and logback +* com.creditease.uav.tomcat.plus.core: JVM MonitorFramework extension for Tomcat/SpringBoot +* com.creditease.uav.jetty.plus.core: JVM MonitorFramework extension for Jetty +* com.creditease.uav.mock.sl4j: mock sl4j +* com.creditease.uav.ttl: com.alibaba.ttl source code introduction (Alibaba TTL) +* com.creditease.uav.monitorframework.buildFat: function test of JVM MonitorFramework) +* com.creditease.uav.monitorframework.springbootFat: function test of JVM MonitorFramework for Springboot) +* com.creditease.uav.agent.buildComponent: build POM for MonitorAgent +* com.creditease.uav.healthmanager.buildComponent: build POM for HealthManager +* com.creditease.uav.monitorframework.buildComponent: build POM for JVM MonitorFramework ## UAV.APM -* com.creditease.uav.collect APM归集客户端/服务端 (Core of APM Data Collection Client & Service) -* com.creditease.uav.invokechain 调用链,日志服务存储和查询 (InvokeChain, Log Collection 2.0) -* com.creditease.uav.monitorframework.apm 探针MOF的APM支持 (JVM MonitorFramework extension for APM) -* com.creditease.uav.threadanalysis 一键式线程分析客户端和服务端 (One Shot Thread Analysis Client & Service) +* com.creditease.uav.collect: core of APM Data Collection client and server +* com.creditease.uav.invokechain: Invocation Chain and Log Collection 2.0 +* com.creditease.uav.monitorframework.apm: JVM MonitorFramework extension for APM +* com.creditease.uav.threadanalysis: one-click thread analysis client and server ## UAV.MSCP -* com.creditease.uav.base MSCP核心框架 (Core of MSCP) -* com.creditease.uav.agent.heartbeat 心跳客户端,心跳服务端,节点远程操控,进程扫描,进程值守 (Base feature of MSCP including heartbeat client & service,node remote opertaions,process auto scanning,process keep-alive support) -* com.creditease.uav.annoscan Fastclasspathscanner源代码引入,注解Class扫描 (Fastclasspathscanner) -* com.creditease.uav.cache.redis 基于Redis的CacheManager (Cache Framework based on redis) -* com.creditease.uav.dbaccess 存储管理器,目前封装了对MySql,OpenTSDB,HBase,MongoDB的存储和查询 (Data Store Framework for MySQL,OpenTSDB,HBase,MongoDB) -* com.creditease.uav.elasticsearch.client ElasticSearch的Shaded客户端封装,避免冲突 (ElasticSearch-Shaded-Client) -* com.creditease.uav.fastjson Fastjson源代码引入 (FastJson) -* com.creditease.uav.helper Util型支持类库 (Util Support Lib) -* com.creditease.uav.httpasync Http异步通信客户端,封装Apache AsyncClient (RPC Framework based on Apache Http AsyncClient) -* com.creditease.uav.logging MSCP日志支持 (MSCP Logging support) -* com.creditease.uav.messaging MSCP消息发送者和消费者支持,无需关心底层消息服务,依赖com.creditease.uav.mq (Messaging Service) -* com.creditease.uav.mq 消息队列服务底层封装,目前使用RocketMQ (Message Queue Support based on Rocket MQ) -* com.creditease.uav.notifymanager MSCP组件级报警支持 (MSCP Component level notification support) -* com.creditease.uav.upgrade MSCP升级客户端和服务端 (Remote upgrading support for MSCP) +* com.creditease.uav.base: core of MSCP +* com.creditease.uav.agent.heartbeat: basic features of MSCP, including heartbeat client & server,node remote control,process auto scanning and process keep-alive support +* com.creditease.uav.annoscan: Fastclasspathscanner source code introduction +* com.creditease.uav.cache.redis: Redis-based cache framework +* com.creditease.uav.dbaccess: data store framework for MySQL,OpenTSDB,HBase and MongoDB +* com.creditease.uav.elasticsearch.client: ElasticSearch-shaded-client to avoid conflicts +* com.creditease.uav.fastjson: Fastjson source code introduction +* com.creditease.uav.helper: Util support library +* com.creditease.uav.httpasync: Http asynchronous communication client based on Apache Http AsyncClient) +* com.creditease.uav.logging: MSCP logging support +* com.creditease.uav.messaging: MSCP messaging support that relies on com.creditease.uav.mq and requires no underlying messaging service +* com.creditease.uav.mq: message queue support based on Rocket MQ +* com.creditease.uav.notifymanager: component-level MSCP notification support +* com.creditease.uav.upgrade: remote upgrading support for MSCP client and server ## UAV.AppHub -* com.creditease.uav.console UAVStack交互前端,包括Monitor,APM等前端交互功能 (AppHub is the GUI console for UAVStack) -* com.creditease.uav.console.buildComponent 制作AppHub部署包 (Build POM for AppHub) +* com.creditease.uav.console: GUI console of UAVStack with front-end interactive features such as Monitor and APM +* com.creditease.uav.console.buildComponent: build POM for AppHub ## UAV.ServiceGovern -* 服务自动注册包含与探针MOF代码中 -* 服务发现代码包含与健康管理程序画像数据查询中 -* 服务降级保护(代码整理中,陆续更新...) -* 服务授权(代码整理中,陆续更新...) - -# 如何构建 How to Build -如果由于缺少jar包或某些依赖jar无法下载导致Maven Build Failure,可下载[参考Maven依赖仓库](https://pan.baidu.com/s/1gfeY8pH),使用该Maven仓库或将其复制到你正在使用的Maven仓库中。 +* Service automatic registration is included in the codes of MOF. +* Codes for service discovery is included in profile data query of HealthManager. +* Service downgrading protection (To be updated). +* Service authorization (To be update). -If you are unable to build because of the lack of jar packages or certain dependency jar, pleaser refer this [Maven Repository](https://pan.baidu.com/s/1gfeY8pH), use the Maven repository, or copy it to the Maven warehouse you are using. +# How to Build +Download the [reference Maven dependency repository](https://pan.baidu.com/s/1gfeY8pH)for Maven Build Failure resulted from the lack of jar packages or the lack of dependent jar packages, and use the downloaded Maven repository instead or copy it into the Maven repository that you are using. 1. build com.creditease.uav.superpom ``` cd com.creditease.uav.superpom mvn clean install ``` -2 中间件增强框架(MOF探针) +2 MonitorFramework ``` cd com.creditease.uav.monitorframework.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavmof_1.0_XXXXX.zip > -uavmof_1.0_XXXXX.zip.MD5 -3. 监控代理程序(MA) +3. MonitorAgent ``` cd com.creditease.uav.agent.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavagent_1.0_XXXXX.zip > -uavagent_1.0_XXXXX.zip.MD5 -4. 健康管理服务(HM) +4. HealthManager ``` cd com.creditease.uav.healthmanager.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavhm_1.0_XXXXX.zip @@ -138,36 +120,30 @@ cd com.creditease.uav.console mvn clean install ``` -build结果 +build result >target > -com.creditease.uav.console-1.0.war -# 文档中心 Documents -## 全维监控UAV.Monitor+APM -* [用户指南](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) -* [安装部署](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) -* [架构说明](https://uavorg.github.io/documents/uavdoc_architecture/index.html) - -# 下载中心 Downloads -## 全维监控UAV.Monitor+APM -* [MOF探针](https://pan.baidu.com/s/1cg4J0q) -* [监控代理程序](https://pan.baidu.com/s/1ge5MJ9h) -* [健康管理服务](https://pan.baidu.com/s/1i4HnV85) +# Documents +## UAV.Monitor+APM +* [User Operation](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) +* [Deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) +* [Architecture](https://uavorg.github.io/documents/uavdoc_architecture/index.html) + +# Downloads +## UAV.Monitor+APM +* [Monitor Framework](https://pan.baidu.com/s/1cg4J0q) +* [Monitor Agent](https://pan.baidu.com/s/1ge5MJ9h) +* [Health Manager](https://pan.baidu.com/s/1i4HnV85) * [AppHub](https://pan.baidu.com/s/1dFxtDZV) -## 第三方下载 Thirdparty Downloads +## Thirdparty Downloads * [rocket.war](https://pan.baidu.com/s/1dF6NeHN) -## AllInOne开发演示版 AllInOne Install Downloads -开发演示版的健康管理服务(HM)仅适合开发环境,演示环境,小规模测试环境。 -生产环境推荐使用[分布式部署](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) +## AllInOne Installation Downloads +The Health Manager (HM) in the AllInOne Installation Package is applicable to development environments, demos and small-scale testing environments. +[A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment. -The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment - -* [Windows64位](https://pan.baidu.com/s/1jIF0wNs) +* [Windows64](https://pan.baidu.com/s/1jIF0wNs) * [Mac](https://pan.baidu.com/s/1mhCykp6) * [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) - - - - From 61ae0d2a07078490f3c0dfe9548023c585c7a210 Mon Sep 17 00:00:00 2001 From: xiaojieshi <38932502+xiaojieshi@users.noreply.github.com> Date: Thu, 3 May 2018 17:26:15 +0800 Subject: [PATCH 70/97] Create Readme-EN --- Readme-EN | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Readme-EN diff --git a/Readme-EN b/Readme-EN new file mode 100644 index 00000000..78b7ff8a --- /dev/null +++ b/Readme-EN @@ -0,0 +1,149 @@ +# UAVStack +UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. + +Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP + +![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) + +# Updating Rules +* Updates of the open source series (at least once a week) shall synchronize with those of the internal versions. +* Feature optimization of the open source series (at least once a week) shall synchronize with that of the internal versions as well. +* New features of the open source series shall be preannounced one week earlier and released within the following week. +* The standard deployment package shall synchronize with the updated source code (at least once a week). +* The AllInOne Demo Package is scheduled to be updated once a month. Please download the standard deployment package updated beyond the schedule. + +# Project Description + +uavstack is the All in One source repository of UAVStack. + +## Parent POM +* com.creditease.uav.superpom: parent POM that support dependency management and build plugins + +## UAV.Monitor +* com.creditease.uav.agent: core of MonitorAgent +* com.creditease.uav.healthmanager: core features of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time Alarm Streaming and AppHub Support Service +* com.creditease.uav.notifycenter: Notification Center Service +* com.creditease.uav.monitorframework: core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc... +* com.creditease.uav.monitorframework.agent: JVM MonitorFramework javaagent support +* com.creditease.uav.monitorframework.dproxy: JVM MonitorFramework javassit support +* com.creditease.uav.hook.* : JVM MonitorFramework Hooks for application framework, including Dubbo, HttpClients, JAXWS, JDBC, MongoClients, MQ, Redis, etc. +* com.creditease.uav.loghook: JVM MonitorFramework Hook for log4j and logback +* com.creditease.uav.tomcat.plus.core: JVM MonitorFramework extension for Tomcat/SpringBoot +* com.creditease.uav.jetty.plus.core: JVM MonitorFramework extension for Jetty +* com.creditease.uav.mock.sl4j: mock sl4j +* com.creditease.uav.ttl: com.alibaba.ttl source code introduction (Alibaba TTL) +* com.creditease.uav.monitorframework.buildFat: function test of JVM MonitorFramework) +* com.creditease.uav.monitorframework.springbootFat: function test of JVM MonitorFramework for Springboot) +* com.creditease.uav.agent.buildComponent: build POM for MonitorAgent +* com.creditease.uav.healthmanager.buildComponent: build POM for HealthManager +* com.creditease.uav.monitorframework.buildComponent: build POM for JVM MonitorFramework + +## UAV.APM +* com.creditease.uav.collect: core of APM Data Collection client and server +* com.creditease.uav.invokechain: Invocation Chain and Log Collection 2.0 +* com.creditease.uav.monitorframework.apm: JVM MonitorFramework extension for APM +* com.creditease.uav.threadanalysis: one-click thread analysis client and server + +## UAV.MSCP +* com.creditease.uav.base: core of MSCP +* com.creditease.uav.agent.heartbeat: basic features of MSCP, including heartbeat client & server,node remote control,process auto scanning and process keep-alive support +* com.creditease.uav.annoscan: Fastclasspathscanner source code introduction +* com.creditease.uav.cache.redis: Redis-based cache framework +* com.creditease.uav.dbaccess: data store framework for MySQL,OpenTSDB,HBase and MongoDB +* com.creditease.uav.elasticsearch.client: ElasticSearch-shaded-client to avoid conflicts +* com.creditease.uav.fastjson: Fastjson source code introduction +* com.creditease.uav.helper: Util support library +* com.creditease.uav.httpasync: Http asynchronous communication client based on Apache Http AsyncClient) +* com.creditease.uav.logging: MSCP logging support +* com.creditease.uav.messaging: MSCP messaging support that relies on com.creditease.uav.mq and requires no underlying messaging service +* com.creditease.uav.mq: message queue support based on Rocket MQ +* com.creditease.uav.notifymanager: component-level MSCP notification support +* com.creditease.uav.upgrade: remote upgrading support for MSCP client and server + +## UAV.AppHub +* com.creditease.uav.console: GUI console of UAVStack with front-end interactive features such as Monitor and APM +* com.creditease.uav.console.buildComponent: build POM for AppHub + +## UAV.ServiceGovern +* Service automatic registration is included in the codes of MOF. +* Codes for service discovery is included in profile data query of HealthManager. +* Service downgrading protection (To be updated). +* Service authorization (To be update). + +# How to Build +Download the [reference Maven dependency repository](https://pan.baidu.com/s/1gfeY8pH)for Maven Build Failure resulted from the lack of jar packages or the lack of dependent jar packages, and use the downloaded Maven repository instead or copy it into the Maven repository that you are using. + +1. build com.creditease.uav.superpom +``` +cd com.creditease.uav.superpom +mvn clean install +``` +2 MonitorFramework +``` +cd com.creditease.uav.monitorframework.buildComponent +mvn clean install +``` + +build result +>target +> -build +> -uavmof_1.0_XXXXX.zip +> -uavmof_1.0_XXXXX.zip.MD5 + +3. MonitorAgent +``` +cd com.creditease.uav.agent.buildComponent +mvn clean install +``` + +build result +>target +> -build +> -uavagent_1.0_XXXXX.zip +> -uavagent_1.0_XXXXX.zip.MD5 + +4. HealthManager +``` +cd com.creditease.uav.healthmanager.buildComponent +mvn clean install +``` + +build result +>target +> -build +> -uavhm_1.0_XXXXX.zip +> -uavhm_1.0_XXXXX.zip.MD5 + +5. AppHub +``` +cd com.creditease.uav.console +mvn clean install +``` + +build result +>target +> -com.creditease.uav.console-1.0.war + +# Documents +## UAV.Monitor+APM +* [User Operation](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) +* [Deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) +* [Architecture](https://uavorg.github.io/documents/uavdoc_architecture/index.html) + +# Downloads +## UAV.Monitor+APM +* [Monitor Framework](https://pan.baidu.com/s/1cg4J0q) +* [Monitor Agent](https://pan.baidu.com/s/1ge5MJ9h) +* [Health Manager](https://pan.baidu.com/s/1i4HnV85) +* [AppHub](https://pan.baidu.com/s/1dFxtDZV) + +## Thirdparty Downloads +* [rocket.war](https://pan.baidu.com/s/1dF6NeHN) + +## AllInOne Installation Downloads +The Health Manager (HM) in the AllInOne Installation Package is applicable to development environments, demos and small-scale testing environments. +[A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment. + +* [Windows64](https://pan.baidu.com/s/1jIF0wNs) +* [Mac](https://pan.baidu.com/s/1mhCykp6) +* [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) From 5655d21a6833e8b80427992e3780e0c15dccfa17 Mon Sep 17 00:00:00 2001 From: xiaojieshi <38932502+xiaojieshi@users.noreply.github.com> Date: Thu, 3 May 2018 18:17:36 +0800 Subject: [PATCH 71/97] Update README.md --- README.md | 178 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 101 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 78b7ff8a..f6dcebe4 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,132 @@ # UAVStack -UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. +UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 +它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 -Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP +UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. + +It includes AIOps Robot (HIT),full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM) etc.. + + +目前UAVStack开源系列 ( 官方网站:https://uavorg.github.io/main/ ) 包括 + +UAVStack Open Source series includes UAV.Monitor, UAV.APM, UAV.ServiceGovern, UAV.MSCP ![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) -# Updating Rules -* Updates of the open source series (at least once a week) shall synchronize with those of the internal versions. -* Feature optimization of the open source series (at least once a week) shall synchronize with that of the internal versions as well. -* New features of the open source series shall be preannounced one week earlier and released within the following week. -* The standard deployment package shall synchronize with the updated source code (at least once a week). -* The AllInOne Demo Package is scheduled to be updated once a month. Please download the standard deployment package updated beyond the schedule. +# 更新模式 Project Updating Principle +* 开源系列源代码Issue更新,将与内部版本完全同步,最低频率每周一次 +* 开源系列源代码相关的功能优化,将与内部版本完全同步,最低频率每周一次 +* 开源系列源代码相关的新功能开放,会提前一周预告,并于下周内发布 +* 标准部署包下载会与源代码更新同步,最低频率每周一次 +* AllInOne开发演示版原则上每月更新一次(打包上传比较耗时),中间更新请下载标准部署包替换 +--- +* The open source series updating is fully synchronized with the internal version, with the lowest frequency once a week +* The open source series related functional optimizations is fully synchronized with the internal version, with the lowest frequency once a week +* The open source series related new features will be announced a week ahead of schedule, and released next week +* The standard deployment pack download is synchronized with source code updates, with the lowest frequency once a week +* AllInOne pack are updated once a month (packaged, uploaded, and time-consuming) in principle, and you can download the standard deployment package instead + -# Project Description +# 工程说明 Source Code Project Description +uavstack是UAVStack的All in One源代码仓库。 uavstack is the All in One source repository of UAVStack. -## Parent POM -* com.creditease.uav.superpom: parent POM that support dependency management and build plugins +## 根POM +* com.creditease.uav.superpom 根POM,包含依赖管理,Build所需plugins等 (Parent POM for dependency management & build plugins) ## UAV.Monitor -* com.creditease.uav.agent: core of MonitorAgent -* com.creditease.uav.healthmanager: core features of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time Alarm Streaming and AppHub Support Service -* com.creditease.uav.notifycenter: Notification Center Service -* com.creditease.uav.monitorframework: core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc... -* com.creditease.uav.monitorframework.agent: JVM MonitorFramework javaagent support -* com.creditease.uav.monitorframework.dproxy: JVM MonitorFramework javassit support -* com.creditease.uav.hook.* : JVM MonitorFramework Hooks for application framework, including Dubbo, HttpClients, JAXWS, JDBC, MongoClients, MQ, Redis, etc. -* com.creditease.uav.loghook: JVM MonitorFramework Hook for log4j and logback -* com.creditease.uav.tomcat.plus.core: JVM MonitorFramework extension for Tomcat/SpringBoot -* com.creditease.uav.jetty.plus.core: JVM MonitorFramework extension for Jetty -* com.creditease.uav.mock.sl4j: mock sl4j -* com.creditease.uav.ttl: com.alibaba.ttl source code introduction (Alibaba TTL) -* com.creditease.uav.monitorframework.buildFat: function test of JVM MonitorFramework) -* com.creditease.uav.monitorframework.springbootFat: function test of JVM MonitorFramework for Springboot) -* com.creditease.uav.agent.buildComponent: build POM for MonitorAgent -* com.creditease.uav.healthmanager.buildComponent: build POM for HealthManager -* com.creditease.uav.monitorframework.buildComponent: build POM for JVM MonitorFramework +* com.creditease.uav.agent 监控代理程序MonitorAgent核心框架 (Core of MonitorAgent) +* com.creditease.uav.healthmanager Monitor核心服务,包括实时数据,画像数据存储/查询,实时报警流式计算,AppHub支持服务 (Core feature of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time alarm streaming,AppHub Support Service) +* com.creditease.uav.notifycenter Monitor服务:报警中心服务端 (Notification Center Service) +* com.creditease.uav.monitorframework 探针MOF核心框架 (Core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc...) +* com.creditease.uav.monitorframework.agent 探针MOF的javaagent实现 (JVM MonitorFramework javaagent support) +* com.creditease.uav.monitorframework.dproxy javaassit支持 (JVM MonitorFramework javassit support) +* com.creditease.uav.hook.* 探针MOF针对技术规范的钩子,包括Dubbo,HttpClients,JAXWS,JDBC,MongoClients,MQ,Redis等 (JVM MonitorFramework Hooks for application framework) +* com.creditease.uav.loghook 探针MOF针对log4j,logback支持 (JVM MonitorFramework Hook for log4j, logback) +* com.creditease.uav.tomcat.plus.core 探针MOF对Tomcat/SpringBoot的支持 (JVM MonitorFramework extension for Tomcat/SpringBoot) +* com.creditease.uav.jetty.plus.core 探针MOF对Jetty支持 (JVM MonitorFramework extension for Jetty) +* com.creditease.uav.mock.sl4j 去除某些框架依赖sl4j (mock sl4j) +* com.creditease.uav.ttl com.alibaba.ttl源代码引入 (Alibaba TTL) +* com.creditease.uav.monitorframework.buildFat WAR测试程序 (Function Test of JVM MonitorFramework) +* com.creditease.uav.monitorframework.springbootFat SpringBoot测试程序 (Function Test of JVM MonitorFramework for springboot) +* com.creditease.uav.agent.buildComponent 制作监控代理程序部署包 (Build POM for MonitorAgent) +* com.creditease.uav.healthmanager.buildComponent 制作健康管理程序部署包 (Build POM for HealthManager) +* com.creditease.uav.monitorframework.buildComponent 制作探针MOF部署包 (Build POM for JVM MonitorFramework) ## UAV.APM -* com.creditease.uav.collect: core of APM Data Collection client and server -* com.creditease.uav.invokechain: Invocation Chain and Log Collection 2.0 -* com.creditease.uav.monitorframework.apm: JVM MonitorFramework extension for APM -* com.creditease.uav.threadanalysis: one-click thread analysis client and server +* com.creditease.uav.collect APM归集客户端/服务端 (Core of APM Data Collection Client & Service) +* com.creditease.uav.invokechain 调用链,日志服务存储和查询 (InvokeChain, Log Collection 2.0) +* com.creditease.uav.monitorframework.apm 探针MOF的APM支持 (JVM MonitorFramework extension for APM) +* com.creditease.uav.threadanalysis 一键式线程分析客户端和服务端 (One Shot Thread Analysis Client & Service) ## UAV.MSCP -* com.creditease.uav.base: core of MSCP -* com.creditease.uav.agent.heartbeat: basic features of MSCP, including heartbeat client & server,node remote control,process auto scanning and process keep-alive support -* com.creditease.uav.annoscan: Fastclasspathscanner source code introduction -* com.creditease.uav.cache.redis: Redis-based cache framework -* com.creditease.uav.dbaccess: data store framework for MySQL,OpenTSDB,HBase and MongoDB -* com.creditease.uav.elasticsearch.client: ElasticSearch-shaded-client to avoid conflicts -* com.creditease.uav.fastjson: Fastjson source code introduction -* com.creditease.uav.helper: Util support library -* com.creditease.uav.httpasync: Http asynchronous communication client based on Apache Http AsyncClient) -* com.creditease.uav.logging: MSCP logging support -* com.creditease.uav.messaging: MSCP messaging support that relies on com.creditease.uav.mq and requires no underlying messaging service -* com.creditease.uav.mq: message queue support based on Rocket MQ -* com.creditease.uav.notifymanager: component-level MSCP notification support -* com.creditease.uav.upgrade: remote upgrading support for MSCP client and server +* com.creditease.uav.base MSCP核心框架 (Core of MSCP) +* com.creditease.uav.agent.heartbeat 心跳客户端,心跳服务端,节点远程操控,进程扫描,进程值守 (Base feature of MSCP including heartbeat client & service,node remote opertaions,process auto scanning,process keep-alive support) +* com.creditease.uav.annoscan Fastclasspathscanner源代码引入,注解Class扫描 (Fastclasspathscanner) +* com.creditease.uav.cache.redis 基于Redis的CacheManager (Cache Framework based on redis) +* com.creditease.uav.dbaccess 存储管理器,目前封装了对MySql,OpenTSDB,HBase,MongoDB的存储和查询 (Data Store Framework for MySQL,OpenTSDB,HBase,MongoDB) +* com.creditease.uav.elasticsearch.client ElasticSearch的Shaded客户端封装,避免冲突 (ElasticSearch-Shaded-Client) +* com.creditease.uav.fastjson Fastjson源代码引入 (FastJson) +* com.creditease.uav.helper Util型支持类库 (Util Support Lib) +* com.creditease.uav.httpasync Http异步通信客户端,封装Apache AsyncClient (RPC Framework based on Apache Http AsyncClient) +* com.creditease.uav.logging MSCP日志支持 (MSCP Logging support) +* com.creditease.uav.messaging MSCP消息发送者和消费者支持,无需关心底层消息服务,依赖com.creditease.uav.mq (Messaging Service) +* com.creditease.uav.mq 消息队列服务底层封装,目前使用RocketMQ (Message Queue Support based on Rocket MQ) +* com.creditease.uav.notifymanager MSCP组件级报警支持 (MSCP Component level notification support) +* com.creditease.uav.upgrade MSCP升级客户端和服务端 (Remote upgrading support for MSCP) ## UAV.AppHub -* com.creditease.uav.console: GUI console of UAVStack with front-end interactive features such as Monitor and APM -* com.creditease.uav.console.buildComponent: build POM for AppHub +* com.creditease.uav.console UAVStack交互前端,包括Monitor,APM等前端交互功能 (AppHub is the GUI console for UAVStack) +* com.creditease.uav.console.buildComponent 制作AppHub部署包 (Build POM for AppHub) ## UAV.ServiceGovern -* Service automatic registration is included in the codes of MOF. -* Codes for service discovery is included in profile data query of HealthManager. -* Service downgrading protection (To be updated). -* Service authorization (To be update). +* 服务自动注册包含与探针MOF代码中 +* 服务发现代码包含与健康管理程序画像数据查询中 +* 服务降级保护(代码整理中,陆续更新...) +* 服务授权(代码整理中,陆续更新...) + +# 如何构建 How to Build +如果由于缺少jar包或某些依赖jar无法下载导致Maven Build Failure,可下载[参考Maven依赖仓库](https://pan.baidu.com/s/1gfeY8pH),使用该Maven仓库或将其复制到你正在使用的Maven仓库中。 -# How to Build -Download the [reference Maven dependency repository](https://pan.baidu.com/s/1gfeY8pH)for Maven Build Failure resulted from the lack of jar packages or the lack of dependent jar packages, and use the downloaded Maven repository instead or copy it into the Maven repository that you are using. +If you are unable to build because of the lack of jar packages or certain dependency jar, pleaser refer this [Maven Repository](https://pan.baidu.com/s/1gfeY8pH), use the Maven repository, or copy it to the Maven warehouse you are using. 1. build com.creditease.uav.superpom ``` cd com.creditease.uav.superpom mvn clean install ``` -2 MonitorFramework +2 中间件增强框架(MOF探针) ``` cd com.creditease.uav.monitorframework.buildComponent mvn clean install ``` -build result +build结果 >target > -build > -uavmof_1.0_XXXXX.zip > -uavmof_1.0_XXXXX.zip.MD5 -3. MonitorAgent +3. 监控代理程序(MA) ``` cd com.creditease.uav.agent.buildComponent mvn clean install ``` -build result +build结果 >target > -build > -uavagent_1.0_XXXXX.zip > -uavagent_1.0_XXXXX.zip.MD5 -4. HealthManager +4. 健康管理服务(HM) ``` cd com.creditease.uav.healthmanager.buildComponent mvn clean install ``` -build result +build结果 >target > -build > -uavhm_1.0_XXXXX.zip @@ -120,30 +138,36 @@ cd com.creditease.uav.console mvn clean install ``` -build result +build结果 >target > -com.creditease.uav.console-1.0.war -# Documents -## UAV.Monitor+APM -* [User Operation](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) -* [Deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) -* [Architecture](https://uavorg.github.io/documents/uavdoc_architecture/index.html) - -# Downloads -## UAV.Monitor+APM -* [Monitor Framework](https://pan.baidu.com/s/1cg4J0q) -* [Monitor Agent](https://pan.baidu.com/s/1ge5MJ9h) -* [Health Manager](https://pan.baidu.com/s/1i4HnV85) +# 文档中心 Documents +## 全维监控UAV.Monitor+APM +* [用户指南](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) +* [安装部署](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) +* [架构说明](https://uavorg.github.io/documents/uavdoc_architecture/index.html) + +# 下载中心 Downloads +## 全维监控UAV.Monitor+APM +* [MOF探针](https://pan.baidu.com/s/1cg4J0q) +* [监控代理程序](https://pan.baidu.com/s/1ge5MJ9h) +* [健康管理服务](https://pan.baidu.com/s/1i4HnV85) * [AppHub](https://pan.baidu.com/s/1dFxtDZV) -## Thirdparty Downloads +## 第三方下载 Thirdparty Downloads * [rocket.war](https://pan.baidu.com/s/1dF6NeHN) -## AllInOne Installation Downloads -The Health Manager (HM) in the AllInOne Installation Package is applicable to development environments, demos and small-scale testing environments. -[A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment. +## AllInOne开发演示版 AllInOne Install Downloads +开发演示版的健康管理服务(HM)仅适合开发环境,演示环境,小规模测试环境。 +生产环境推荐使用[分布式部署](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) -* [Windows64](https://pan.baidu.com/s/1jIF0wNs) +The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment + +* [Windows64位](https://pan.baidu.com/s/1jIF0wNs) * [Mac](https://pan.baidu.com/s/1mhCykp6) * [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) + + + + From 331db92da4b1a432c315132e8733f6274fb1ebf8 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Tue, 8 May 2018 16:46:17 +0800 Subject: [PATCH 72/97] https://github.com/uavorg/uavstack/issues/265 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authorization to add keyword matching to Apphub Apphub管理->授权管理,新建授权组:添加关键字功能 关键字 获取: 通过:Apphub管理->查询信息->用户查询,可以查看到属性为string字段 选其中任意一段字符串作为关键字,添加到 新建授权->关键字 中 --- 授权规则(如果匹配到多个,则去重,授权叠加) 1.1) 先匹配 授权组 1.2) 再匹配 授权组的 关键字 --- .../config/web_pro.xml | 10 +- .../config/web_test.xml | 10 +- .../uav/apphub/filter/SessionAsyncFilter.java | 2 +- .../uav/apphub/rest/GUIService.java | 83 +++++++++++++--- .../uav/apphub/sso/GUISSOClient.java | 65 ------------ .../uav/apphub/sso/GUISSOLdapClient.java | 46 +++++++-- .../uav/manage/rest/ManageRestService.java | 98 +++++++++++++------ .../uav/manage/rest/entity/GroupEntity.java | 31 ++++-- .../src/main/webapp/WEB-INF/web.xml | 10 +- .../src/main/webapp/apphub/js/main.temp.js | 2 +- .../uavapp_manage/groupmanage/js/group.add.js | 9 +- .../uavapp_manage/groupmanage/js/group.del.js | 6 +- .../groupmanage/js/group.modfy.js | 4 +- .../groupmanage/js/group.searchbar.js | 2 +- .../groupmanage/js/group.table.js | 13 ++- .../groupmanage/js/restful.client.js | 38 ++++--- .../uavapp_manage/groupmanage/main.html | 12 ++- .../uav/datastore/core/MongoDBDataStore.java | 9 +- .../uav/datastore/core/OpentsdbDataStore.java | 7 +- .../datastore/mongo/MongodbImplStrategy.java | 11 ++- .../datastore/source/OpentsdbDataSource.java | 20 ++-- 21 files changed, 288 insertions(+), 200 deletions(-) diff --git a/com.creditease.uav.console.buildComponent/config/web_pro.xml b/com.creditease.uav.console.buildComponent/config/web_pro.xml index 8f294db8..0a5a62b0 100644 --- a/com.creditease.uav.console.buildComponent/config/web_pro.xml +++ b/com.creditease.uav.console.buildComponent/config/web_pro.xml @@ -117,10 +117,6 @@ uav.app.manage.redis.store.addr 127.0.0.1:26379 - - uav.app.ldap.redis.store.addr - 127.0.0.1:26379 - uav.app.godeye.redis.store.addr 127.0.0.1:26379 @@ -137,10 +133,6 @@ uav.app.manage.redis.store.params {"min":50,"max":300,"queue":10} - - uav.app.ldap.redis.store.params - {"min":30,"max":100,"queue":10} - uav.app.godeye.redis.store.params {"min":30,"max":100,"queue":5,"cacheaccess":5} @@ -235,7 +227,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} uav.apphub.sso.grafana.connection.info diff --git a/com.creditease.uav.console.buildComponent/config/web_test.xml b/com.creditease.uav.console.buildComponent/config/web_test.xml index 28d97594..4dd2a1a7 100644 --- a/com.creditease.uav.console.buildComponent/config/web_test.xml +++ b/com.creditease.uav.console.buildComponent/config/web_test.xml @@ -117,10 +117,6 @@ uav.app.manage.redis.store.addr 127.0.0.1:6379 - - uav.app.ldap.redis.store.addr - 127.0.0.1:6379 - uav.app.godeye.redis.store.addr 127.0.0.1:6379 @@ -137,10 +133,6 @@ uav.app.manage.redis.store.params {"min":50,"max":300,"queue":10,"pwd":"Uav!1227Admin"} - - uav.app.ldap.redis.store.params - {"min":30,"max":100,"queue":5,"pwd":"Uav!1227Admin"} - uav.app.godeye.redis.store.params {"min":30,"max":100,"queue":5,"cacheaccess":5,"pwd":"Uav!1227Admin"} @@ -240,7 +232,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} uav.apphub.sso.grafana.connection.info diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java index 9f3b15c5..21cdf631 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/filter/SessionAsyncFilter.java @@ -56,7 +56,7 @@ public class SessionAsyncFilter implements Filter { private String[] exResSs; private ISystemLogger logger = null; - private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); @Override public void init(FilterConfig filterConfig) throws ServletException { diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java index 13898971..b7f81049 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java @@ -31,11 +31,13 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import javax.inject.Singleton; import javax.servlet.http.HttpServletRequest; @@ -139,9 +141,17 @@ public void init() { try { /** - * redis cache init :等待AppHubInit执行完成(0.5秒为估计值) + * redis cache init :等待AppHubInit执行完成(1秒为估计值) + */ + Thread.sleep(1000L); + /** + * 先清空redis:app group 授权信息 + */ + cm.del("apphub.gui.cache", "manage.app"); + cm.del("apphub.gui.cache", "manage.group"); + /** + * 然后将mongodb数据缓存到redis */ - Thread.sleep(500L); createGroupInfoCache(); createAppInfoCache(); } @@ -218,7 +228,7 @@ else if (loginRegister(loginId, loginPwd, request)) { String xip = request.getHeader("X-Forwarded-For"); String userip = getClientIP(ip, xip); Map userInfo = new HashMap(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String time = sdf.format(new Date()); userInfo.put("key", "ulog"); userInfo.put("time", time); @@ -261,7 +271,7 @@ public void loginOut() { String xip = request.getHeader("X-Forwarded-For"); String userip = getClientIP(ip, xip); Map userInfo = new HashMap(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String time = sdf.format(new Date()); userInfo.put("key", "ulog"); userInfo.put("time", time); @@ -327,29 +337,72 @@ public String loadMainMenu() throws IOException { * * @return */ + @SuppressWarnings("rawtypes") @GET @Path("loadUserManageInfo") @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") public void loadUserManageInfo(@Suspended AsyncResponse response) { - String result = ""; String userGroup = String .valueOf(request.getSession(false).getAttribute("apphub.gui.session.login.user.group")); Map manageGroup = cm.getHashAll("apphub.gui.cache", "manage.group"); - // 授权匹配 - if (manageGroup.containsKey(userGroup)) { + /** + * 获取用户ldap信息 begin + */ + GUISSOClient guissoClient = GUISSOClientFactory.getGUISSOClient(request); + String userLoginId = String.valueOf(request.getSession(false).getAttribute("apphub.gui.session.login.user.id")); + Object userLdapInfo = guissoClient.getUserByQuery(userLoginId); + String userLdapInfoStr = JSONHelper.toString(userLdapInfo); + /** + * 获取用户ldap信息 end + */ + + /** + * 获取匹配授权信息,去重 + * + * 只要匹配上,权限都能得到 + */ + Set appids = new HashSet(); + Iterator manageGroupI = manageGroup.keySet().iterator(); + while (manageGroupI.hasNext()) { + String key = String.valueOf(manageGroupI.next()); + String[] keys = key.split(","); + String groupId = keys[0].replace("groupId:", ""); + String ldapKey = keys[1].replace("ldappKey:", ""); + + boolean keyCheck = false; + if (ldapKey.length() == 0) { + keyCheck = true; // 没有则不验证 + } + else { + keyCheck = userLdapInfoStr.contains(ldapKey); // 关键字匹配 + } + + if (userGroup.equals(groupId) && keyCheck) { + // 授权匹配 + String[] userManAppids = manageGroup.get(key).split(","); + for (String appid : userManAppids) { + appids.add(appid); + } + } + } + + String result = ""; + if (appids.size() > 0) { + // 赋值 + Iterator appidsI = appids.iterator(); Map userManageInfo = new HashMap(); - String[] userManAppids = manageGroup.get(userGroup).split(","); - for (String appid : userManAppids) { + while (appidsI.hasNext()) { + String appid = String.valueOf(appidsI.next()); Map appinfo = cm.getHash("apphub.gui.cache", "manage.app", appid); userManageInfo.putAll(appinfo); } + result = JSONHelper.toString(userManageInfo); } - logger.info(this, "\r\nloadUserManageInfo\r\nuserGroup:" + userGroup + "\r\nmanageGroup:" + manageGroup - + " \r\nresult:" + result); + logger.info(this, "\r\nloadUserManageInfo->\r\nuserGroup:" + userGroup + "\r\nmapping:" + appids.toString()); response.resume(result); @@ -495,13 +548,11 @@ private void whiteListFilter(String loginId, Map userInfo) { * @return */ private boolean whiteListSet(String loginId, String groupName, Map userInfo) { - - String checkLoginId = loginId; - + boolean result = false; String[] memberNames = whiteList.get(groupName).split(","); for (String memberName : memberNames) { - if (checkLoginId.equals(memberName)) { + if (loginId.toLowerCase().equals(memberName.toLowerCase())) { userInfo.remove("groupId"); userInfo.put("groupId", groupName); result = true; @@ -670,6 +721,8 @@ public void completed(HttpClientCallbackResult result) { for (Map map : respList) { String key = map.get("groupid"); String value = map.get("appids"); + + key = "groupId:" + key + ",ldappKey:"; groupCache.put(key, value); } cm.putHash("apphub.gui.cache", "manage.group", groupCache); diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOClient.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOClient.java index fff8ff44..e44ecbf6 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOClient.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOClient.java @@ -51,7 +51,6 @@ public GUISSOClient(HttpServletRequest request) { initMessageMD5(); initSystemUser(request); - initRedis(request); } @@ -61,22 +60,8 @@ public Map getUserByLogin(String loginId, String loginPwd) { userInfo = getUserBySystem(loginId, loginPwd); - if (userInfo.isEmpty()) { - userInfo = getUserByCache(loginId, loginPwd); - } - if (userInfo.isEmpty()) { userInfo = getUserByLoginImpl(loginId, loginPwd); - if (!userInfo.isEmpty()) { - userInfo.put("loginPwd", bytes2Hex(md.digest(loginPwd.getBytes()))); - cm.putJSON("apphub.ldap.cache", loginId, userInfo, 7L, TimeUnit.DAYS); - loggerInfo("用户信息缓存 ", "保存7天", "成功", loginId); - } - } - - if (!userInfo.isEmpty()) { - userInfo.remove("loginPwd"); - loggerInfo("用户登录 ", "信息获取", "成功", userInfo.toString()); } return userInfo; @@ -160,21 +145,6 @@ private void initSystemUser(HttpServletRequest request) { } - @SuppressWarnings("unchecked") - private void initRedis(HttpServletRequest request) { - - if (null == cm) { - String redisAddrStr = request.getServletContext().getInitParameter("uav.app.ldap.redis.store.addr"); - Map redisParamsMap = JSONHelper.toObject( - request.getServletContext().getInitParameter("uav.app.ldap.redis.store.params"), Map.class); - cm = CacheManagerFactory.build(redisAddrStr, Integer.valueOf(String.valueOf(redisParamsMap.get("min"))), - Integer.valueOf(String.valueOf(redisParamsMap.get("max"))), - Integer.valueOf(String.valueOf(redisParamsMap.get("queue"))), - String.valueOf(redisParamsMap.get("pwd"))); - } - - } - private Map getUserBySystem(String loginId, String loginPwd) { Map result = new HashMap(); @@ -186,44 +156,9 @@ private Map getUserBySystem(String loginId, String loginPwd) { } } - if (!result.isEmpty()) { - loggerInfo("系统用户 ", "校验", "成功", loginId); - } - return result; } - @SuppressWarnings("unchecked") - private Map getUserByCache(String loginId, String loginPwd) { - - Map result = new HashMap(); - - if (cm.exists("apphub.ldap.cache", loginId)) { - Map cache = cm.getJSON("apphub.ldap.cache", loginId, Map.class); - if (bytes2Hex(md.digest(loginPwd.getBytes())).equals(cache.get("loginPwd"))) { - result = cache; - } - } - - if (!result.isEmpty()) { - loggerInfo("缓存用户 ", "校验", "成功", loginId); - } - return result; - - } - - private String bytes2Hex(byte[] bys) { - - char[] chs = new char[bys.length * 2]; - int stopCondition = bys.length; - int offset = 0; - for (int i = 0; i < stopCondition; i++) { - chs[offset++] = hex[bys[i] >> 4 & 0xf]; - chs[offset++] = hex[bys[i] & 0xf]; - } - return new String(chs); - } - protected void loggerInfo(String title, String action, String result, String msg) { logger.info(this, title + "[" + action + "]" + result + " " + msg); diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java index e28e8a57..7136bac3 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java @@ -85,11 +85,20 @@ private void initLdapParams(String action) { String ldapConUrl = ldapConfig.get("url"); String ldapConUser = ldapConfig.get("user"); String ldapConPassWord = ldapConfig.get("password"); + String ldapConTimeout = ldapConfig.get("contimeout"); param.put(Context.PROVIDER_URL, ldapConUrl + ldapConBasedn); param.put(Context.SECURITY_PRINCIPAL, ldapConUser); param.put(Context.SECURITY_CREDENTIALS, ldapConPassWord); param.put(Context.SECURITY_AUTHENTICATION, "simple"); param.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + param.put("com.sun.jndi.ldap.connect.timeout", ldapConTimeout); + + /** + * ldap以下字段转码需要特殊处理:不显示乱码,但也不会显示为可识别的string,以binary string显示 + */ + param.put("java.naming.ldap.attributes.binary", + "msExchMailboxGuid objectSid objectGUID msExchMailboxSecurityDescriptor "); + ldapParams.put(action, param); } @@ -146,25 +155,38 @@ private boolean ldapApiCheck(String loginId, String password) { boolean result = false; String action = "login"; + LdapContext newContext = null; try { initLdapContext(action); - LdapContext ldapCtx = ldapContexts.get(action); + Properties actionParam = ldapParams.get(action); - ldapCtx.addToEnvironment(Context.SECURITY_PRINCIPAL, loginId); - ldapCtx.addToEnvironment(Context.SECURITY_CREDENTIALS, password); + // 替换参数,账号密码验证 + actionParam.put(Context.SECURITY_PRINCIPAL, loginId); + actionParam.put(Context.SECURITY_CREDENTIALS, password); // 密码验证,不报错则为验证成功 - ldapCtx.reconnect(null); + newContext = new InitialLdapContext(actionParam, null); result = true; - loggerInfo("LDAP信息", "校验", "成功", loginId); + loggerInfo("LDAP信息", "登陆校验", "成功", loginId); } catch (AuthenticationException e) { - // 此异常为用户验证失败,因此不做ldapContext清除 - loggerError("LDAP信息校验", loginId + " (业务意义为验证失败,异常信息可以忽略)", e); + // 此异常为用户验证失败 + loggerInfo("LDAP信息", "登陆校验", "失败", loginId); } catch (Exception e1) { loggerError("LDAP信息校验", loginId, e1); clearLdapContext(action); } + finally { + + try { + if (null != newContext) { + newContext.close(); + } + } + catch (NamingException e) { + loggerError("LDAP信息校验,链接关闭", loginId, e); + } + } return result; @@ -180,6 +202,9 @@ private List ldapApiQuery(String action, String name, String filte SearchControls constraints = new SearchControls(); constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); + + String ldapConTimeout = ldapConfig.get("contimeout"); + constraints.setTimeLimit(Integer.valueOf(ldapConTimeout)); NamingEnumeration en = ldapCtx.search(name, filter, constraints); // means all nodes @@ -283,13 +308,12 @@ public List> getUserByQuery(String email) { /** * 遍历格式化用户信息 */ - Map emailInfoMap = formatEmailInfo(sResult, userQueryField); String groupIdStr = formatGroupId(sResult); String emailListStr = formatEmailList(sResult); + Map emailInfoMap = formatEmailInfo(sResult, userQueryField); Map info = new HashMap(); - info.put("email", emailInfoMap.get("email")); - info.put("name", emailInfoMap.get("name")); + info.putAll(emailInfoMap); info.put("groupId", groupIdStr); info.put("emailList", emailListStr); @@ -481,6 +505,8 @@ private Map formatEmailInfo(SearchResult sResult, String targetK if ("cn".equals(attrId)) { result.put("name", attrValue); } + + result.put(attrId, attrValue); } } diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java index feb935bd..81f327cc 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java @@ -121,7 +121,7 @@ public void loadAppByid(AppEntity appEntity, @Suspended AsyncResponse response) data.put("where", where); Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); - Map callBackInput = createInput(null, null, "query"); + Map callBackInput = createAppInput(null, null, "query"); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); } @@ -152,7 +152,7 @@ public void loadApps(AppEntity appEntity, @Suspended AsyncResponse response) { data.put("sort", sort); Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); - Map callBackInput = createInput(null, null, "query"); + Map callBackInput = createAppInput(null, null, "query"); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); } @@ -170,23 +170,40 @@ public void loadAllApps(@Suspended AsyncResponse response) { data.put("sort", sort); Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); - Map callBackInput = createInput(null, null, "query"); + Map callBackInput = createAppInput(null, null, "query"); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); } + @POST + @Path("loadGroupByInfo") + public void loadGroupByInfo(GroupEntity groupEntity, @Suspended AsyncResponse response) { + + Map where = new HashMap(); + where.put("groupid", groupEntity.getGroupid()); + where.put("ldapkey", groupEntity.getLdapkey()); + where.put("state", 1); + + Map data = new HashMap(); + data.put("where", where); + + Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); + Map callBackInput = createGroupInput(null, null, null, "query"); + manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); + } + @POST @Path("loadGroupByid") public void loadGroupByid(GroupEntity groupEntity, @Suspended AsyncResponse response) { Map where = new HashMap(); - where.put("groupid", groupEntity.getGroupid()); + where.put("_id", groupEntity.getId()); where.put("state", 1); Map data = new HashMap(); data.put("where", where); Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); - Map callBackInput = createInput(null, null, "query"); + Map callBackInput = createGroupInput(null, null, null, "query"); manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); } @@ -216,7 +233,7 @@ public void loadAllGroups(GroupEntity groupEntity, @Suspended AsyncResponse resp data.put("sort", sort); Map jsonRequest = createHttpMapRequest(bussinessTypeQuery, data); - Map callBackInput = createInput(null, null, "query"); + Map callBackInput = createGroupInput(null, null, null, "query"); manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); } @@ -228,17 +245,17 @@ public void loadCount(String paramVlue, @Suspended AsyncResponse response) { String coulum = null; String mType = null; ManageHttpClientCallback messageCallBack = null; - Map callBackInput = createInput(null, null, "query"); Map obj = JSONHelper.toObject(paramVlue, Map.class); String type = (String) obj.get("type"); if ("APP".equals(type)) { coulum = "appurl"; mType = manageTypeApp; - messageCallBack = new AppHttpCallBack(response, callBackInput); + messageCallBack = new AppHttpCallBack(response, createAppInput(null, null, "query")); } else if ("GROUP".equals(type)) { coulum = "groupid"; mType = manageTypeGroup; + Map callBackInput = createGroupInput(null, null, null, "query"); messageCallBack = new GroupHttpCallBack(response, callBackInput); } Map regex = new HashMap(); @@ -276,7 +293,7 @@ public void addApp(AppEntity appEntity, @Suspended AsyncResponse response) throw data.put("operationuser", request.getSession(false).getAttribute("apphub.gui.session.login.user.id")); Map jsonRequest = createHttpMapRequest(bussinessTypeCreate, data); - Map callBackInput = createInput(id, appurl, "create"); + Map callBackInput = createAppInput(id, appurl, "create"); callBackInput.put("configpath", configpath); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); @@ -287,10 +304,12 @@ public void addApp(AppEntity appEntity, @Suspended AsyncResponse response) throw public void addGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) throws Exception { String groupId = XSSFilter(groupEntity.getGroupid()); + String ldapkey = XSSFilter(groupEntity.getLdapkey()); String appIds = XSSFilter(groupEntity.getAppids()); String time = df.format(new Date()); Map data = new HashMap(); data.put("groupid", groupId); + data.put("ldapkey", ldapkey); data.put("appids", appIds); data.put("state", 1); data.put("createtime", time); @@ -298,7 +317,7 @@ public void addGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) data.put("operationuser", request.getSession(false).getAttribute("apphub.gui.session.login.user.id")); Map jsonRequest = createHttpMapRequest(bussinessTypeCreate, data); - Map callBackInput = createInput(groupId, appIds, "create"); + Map callBackInput = createGroupInput(groupId, ldapkey, appIds, "create"); manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); } @@ -325,7 +344,7 @@ public void updateApp(AppEntity appEntity, @Suspended AsyncResponse response) th modify.put("update", update); Map jsonRequest = createHttpMapRequest(bussinessTypeModify, modify); - Map callBackInput = createInput(id, newurl, "modify"); + Map callBackInput = createAppInput(id, newurl, "modify"); callBackInput.put("configpath", configpath); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); } @@ -334,11 +353,13 @@ public void updateApp(AppEntity appEntity, @Suspended AsyncResponse response) th @Path("updateGroup") public void updateGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) throws Exception { + String id = XSSFilter(groupEntity.getId()); String groupId = XSSFilter(groupEntity.getGroupid()); + String ldapKey = XSSFilter(groupEntity.getLdapkey()); String appIds = XSSFilter(groupEntity.getAppids()); String time = df.format(new Date()); Map where = new HashMap(); - where.put("groupid", groupId); + where.put("_id", id); Map cloumns = new HashMap(); cloumns.put("operationtime", time); @@ -352,7 +373,7 @@ public void updateGroup(GroupEntity groupEntity, @Suspended AsyncResponse respon data.put("where", where); data.put("update", set); Map jsonRequest = createHttpMapRequest(bussinessTypeModify, data); - Map callBackInput = createInput(groupEntity.getGroupid(), appIds, "modify"); + Map callBackInput = createGroupInput(groupId, ldapKey, appIds, "modify"); manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); } @@ -376,7 +397,7 @@ public void delApp(AppEntity appEntity, @Suspended AsyncResponse response) throw modify.put("update", update); Map jsonRequest = createHttpMapRequest(bussinessTypeModify, modify); - Map callBackInput = createInput(appEntity.getAppid(), null, "delete"); + Map callBackInput = createAppInput(id, null, "delete"); manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput)); } @@ -384,9 +405,12 @@ public void delApp(AppEntity appEntity, @Suspended AsyncResponse response) throw @Path("delGroup") public void delGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) throws Exception { + String id = XSSFilter(groupEntity.getId()); + String groupId = XSSFilter(groupEntity.getGroupid()); + String ldapKey = XSSFilter(groupEntity.getLdapkey()); String time = df.format(new Date()); Map where = new HashMap(); - where.put("groupid", groupEntity.getGroupid()); + where.put("_id", id); Map cloumns = new HashMap(); cloumns.put("state", 0); @@ -400,7 +424,7 @@ public void delGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) data.put("where", where); data.put("update", set); Map jsonRequest = createHttpMapRequest(bussinessTypeModify, data); - Map callBackInput = createInput(groupEntity.getGroupid(), null, "delete"); + Map callBackInput = createGroupInput(groupId,ldapKey, null, "delete"); manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput)); } @@ -510,18 +534,31 @@ private String getWebProName(HttpServletRequest request) { return requestUrl.substring(0, index); } - private Map createInput(String id, String value, String bType) { + private Map createAppInput(String id, String value, String bType) { Map input = new HashMap(); input.put("region", "apphub.gui.cache"); - input.put("appKey", "manage.app"); - input.put("groupKey", "manage.group"); + input.put("region.appKey", "manage.app"); + input.put("region.groupKey", "manage.group"); input.put("id", id); input.put("value", value); input.put("bType", bType); return input; } + private Map createGroupInput(String groupId, String ldappKey, String value, String bType) { + + Map input = new HashMap(); + input.put("region", "apphub.gui.cache"); + input.put("region.appKey", "manage.app"); + input.put("region.groupKey", "manage.group"); + input.put("groupId", groupId); + input.put("ldappKey", ldappKey); + input.put("value", value); + input.put("bType", bType); + return input; + } + // tools end----------------------------------------------------------> /** @@ -571,16 +608,13 @@ public AppHttpCallBack(AsyncResponse asyncResponseParam, Map inp void after(HttpClientCallbackResult result) { String id = input.get("id"); - String appKey = input.get("appKey"); String region = input.get("region"); + String regionAppKey = input.get("region.appKey"); String bType = input.get("bType"); String appUrl = input.get("value"); - logger.info(this, "ManageRestService AppHttpCallBack : region=" + region + ",key=" + appKey + ",id=" + id - + ",value=" + appUrl + ",type=" + bType); - if ("delete".equals(bType)) { - cm.delHash(region, appKey, id); + cm.delHash(region, regionAppKey, id); } else if ("modify".equals(bType) || "create".equals(bType)) { @@ -600,7 +634,6 @@ else if ("modify".equals(bType) || "create".equals(bType)) { Properties properties; try { - logger.info(this, "UAV管理 APP管理(添加or修改) app 配置加载 :" + configUrl); properties = PropertiesHelper.downloadProperties(configUrl); } catch (Exception e) { @@ -619,7 +652,7 @@ else if ("modify".equals(bType) || "create".equals(bType)) { resultJson.put("menu", jsonArray); String dataStr = JSONHelper.toString(resultJson); - cm.putHash(region, appKey, id, dataStr); + cm.putHash(region, regionAppKey, id, dataStr); } @@ -636,19 +669,20 @@ public GroupHttpCallBack(AsyncResponse asyncResponseParam, Map i @Override void after(HttpClientCallbackResult result) { - String id = input.get("id"); - String groupKey = input.get("groupKey"); String region = input.get("region"); + String regionAppKey = input.get("region.appKey"); String bType = input.get("bType"); + + String groupId = input.get("groupId"); + String ldappKey = input.get("ldappKey"); String value = input.get("value"); - logger.info(this, "ManageRestService GroupHttpCallBack : region=" + region + ",key=" + groupKey + ",id=" - + id + ",value=" + value + ",type=" + bType); + String cacheId = "groupId:" + groupId + ",ldappKey:" + ldappKey; if ("delete".equals(bType)) { - cm.delHash(region, groupKey, id); + cm.delHash(region, regionAppKey, cacheId); } else if ("modify".equals(bType) || "create".equals(bType)) { - cm.putHash(region, groupKey, id, value); + cm.putHash(region, regionAppKey, cacheId, value); } } diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/entity/GroupEntity.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/entity/GroupEntity.java index 27fe73a3..d55c2a66 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/entity/GroupEntity.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/entity/GroupEntity.java @@ -24,8 +24,9 @@ * @author Created by lbay on 2016/4/14. */ public class GroupEntity { - + private String id; private String groupid; + private String ldapkey; private String appids; private int state; private String createtime; @@ -34,6 +35,16 @@ public class GroupEntity { private String pageindex; private String pagesize; + public String getId() { + + return id; + } + + public void setId(String id) { + + this.id = id; + } + public String getGroupid() { return groupid; @@ -44,6 +55,16 @@ public void setGroupid(String groupid) { this.groupid = groupid; } + public String getLdapkey() { + + return ldapkey; + } + + public void setLdapkey(String ldapkey) { + + this.ldapkey = ldapkey; + } + public String getAppids() { return appids; @@ -114,12 +135,4 @@ public void setPagesize(String pagesize) { this.pagesize = pagesize; } - @Override - public String toString() { - - return "GroupEntity [groupid=" + groupid + ", appids=" + appids + ", state=" + state + ", createtime=" - + createtime + ", operationtime=" + operationtime + ", operationuser=" + operationuser + ", pageindex=" - + pageindex + ", pagesize=" + pagesize + "]"; - } - } diff --git a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml index 6e300e01..3960d430 100644 --- a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml +++ b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml @@ -121,10 +121,6 @@ uav.app.manage.redis.store.addr localhost:6379 - - uav.app.ldap.redis.store.addr - localhost:6379 - uav.app.godeye.redis.store.addr localhost:6379 @@ -141,10 +137,6 @@ uav.app.manage.redis.store.params {"min":50,"max":200,"queue":5,"pwd":""} - - uav.app.ldap.redis.store.params - {"min":30,"max":100,"queue":5,"pwd":""} - uav.app.godeye.redis.store.params {"min":30,"max":100,"queue":5,"cacheaccess":5,"pwd":""} @@ -249,7 +241,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} diff --git a/com.creditease.uav.console/src/main/webapp/apphub/js/main.temp.js b/com.creditease.uav.console/src/main/webapp/apphub/js/main.temp.js index 3de775e1..a2255da9 100644 --- a/com.creditease.uav.console/src/main/webapp/apphub/js/main.temp.js +++ b/com.creditease.uav.console/src/main/webapp/apphub/js/main.temp.js @@ -168,7 +168,7 @@ $("document").ready( * userlogger记录,通过用ping提交到filter begin * 同时会进行会话check(ping逻辑) */ - guiPing_RSClient(mainTempInit(),"jumpmain","","") + guiPing_RSClient(mainTempInit(),"jumpmain","","主页") /** * userlogger记录,通过用ping提交到filter end * diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.add.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.add.js index 6ec5bcea..a2d93e54 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.add.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.add.js @@ -26,9 +26,14 @@ function addGroupSubmit(){ $("#addGroupid").val(groupid); groupid = HtmlHelper.inputXSSFilter(groupid); var appids = HtmlHelper.inputXSSFilter($("#addAppids").val()); + + var ldapkey = $("#addLdapKey").val().trim(); + $("#addKey").val(ldapkey); + ldapkey = HtmlHelper.inputXSSFilter(ldapkey); + if(thisCheck()){ appids = getformatAppids(appids); - addGroup_RESTClient(groupid,appids); + addGroup_RESTClient(groupid,ldapkey,appids); }else{ commitEnd(); } @@ -36,7 +41,7 @@ function addGroupSubmit(){ function thisCheck(){ var c = false; if(!groupid){ - setErrorMsg("addErrorMsg","未输入组ID"); + setErrorMsg("addErrorMsg","未输入授权组"); }else if(!appids){ setErrorMsg("addErrorMsg","未授权APP"); }else{ diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.del.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.del.js index 7e73533c..544900dc 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.del.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.del.js @@ -1,16 +1,16 @@ var delmodalConfig = { - groupid:0, + id:0, head:"提示", content:"", callback:"clickSureCallback()" }; function clickSureCallback(){ - delGroup_RESTClient(delmodalConfig.groupid); + delGroup_RESTClient(delmodalConfig.id); } function userDelete(id){ - delmodalConfig.groupid=id; + delmodalConfig.id=id; delmodalConfig.content="是否确定删除["+id+"]"; showConfirm(delmodalConfig); } \ No newline at end of file diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js index 5b04eee0..f5995e54 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js @@ -69,10 +69,10 @@ function vmButtonSwitch(){ function saveModfy(){ - var groupid = $("#viewGroupid").html(); + var id = $("#viewid").html(); var appids = $("#viewAppids").val(); if(thisCheck()){ - updateGroup_RESTClient(groupid,getformatAppids(appids)); + updateGroup_RESTClient(id,groupId,ldapKey,getformatAppids(appids)); } function thisCheck(){ diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.searchbar.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.searchbar.js index f21900f3..486db507 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.searchbar.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.searchbar.js @@ -11,7 +11,7 @@ function generateSearchBar(id){ buf.push(''); buf.push(''); - buf.push(''); + buf.push(''); buf.push(''); buf.push('
'); diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.table.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.table.js index 004da501..a36376bf 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.table.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.table.js @@ -1,14 +1,17 @@ var mtableConfig = { + tableListData:null, id : "AppManagerTableada", pid : "AppManagerTableDiv", openDelete : true, - key : "id", + key : "_id", pagerSwitchThreshold : 600, pagesize:20, head : { - groupid : [ '组ID', '25%' ], + _id : [ 'ID', '15%' ], + groupid : [ '授权组', '15%' ], + ldapkey : [ 'LDAP关键字', '10%' ], appids : [ '授权APP', '35%' ], - createtime : [ '创建时间' ,'15%'], + // createtime : [ '创建时间' ,'15%'], operationtime : [ '操作时间', '15%' ], operationuser : [ '操作人', '10%' ] //,state : ['状态', '5%'] @@ -16,8 +19,8 @@ var mtableConfig = { cloHideStrategy : { 1100 : [ 0, 1, 2, 3, 4, 5 ], 1000 : [ 0, 1, 4, 5 ], - 800 : [ 0, 1, 5 ], - 500 : [ 0, 1 ], + 800 : [ 0, 1, 2 ], + 500 : [ 0, 1, 2 ], 400 : [ 0 ] } }; diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/restful.client.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/restful.client.js index 9ed530c3..e289c6c4 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/restful.client.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/restful.client.js @@ -19,12 +19,13 @@ function loadAllApps_RESTClient(func) { }); } -function addGroup_RESTClient(groupid, appids) { +function addGroup_RESTClient(groupid, ldapkey,appids) { var json = { - "groupid" : groupid + "groupid" : groupid, + "ldapkey":ldapkey }; - var postUrl = url + "loadGroupByid"; + var postUrl = url + "loadGroupByInfo"; //先查询是否存在 AjaxHelper.call({ url : postUrl, data : JSON.stringify(json), @@ -36,7 +37,7 @@ function addGroup_RESTClient(groupid, appids) { result = eval("(" + result["rs"] + ")"); if (result.code == "1") { if (result.data.length > 0) { - setErrorMsg("addErrorMsg", "组ID已经存在"); + setErrorMsg("addErrorMsg", "已经存在"); } else { submitAddGroup(); } @@ -54,6 +55,7 @@ function addGroup_RESTClient(groupid, appids) { function submitAddGroup() { var json = { "groupid" : groupid, + "ldapkey": ldapkey, "appids" : appids }; var postUrl = url + "addGroup"; @@ -153,7 +155,8 @@ function loadAllGroups_Count_RESTClient(groupDatas) { $.each(groupDatas, function(index, obj) { table.add(obj); }); - + //页面全部变量赋值 + mtableConfig.tableListData=groupDatas; } else { console.log(result); } @@ -166,8 +169,17 @@ function loadAllGroups_Count_RESTClient(groupDatas) { function delGroup_RESTClient(id) { var json = { - "groupid" : id - }; + "id" : id + }; + + $.each(mtableConfig.tableListData, function(index, obj) { + + if(obj["_id"]==id){ + json["groupid"]=obj["groupid"]; + json["ldapkey"]=obj["ldapkey"]==null?"":obj["ldapkey"]; + } + }); + var postUrl = url + "delGroup"; AjaxHelper.call({ url : postUrl, @@ -190,9 +202,9 @@ function delGroup_RESTClient(id) { }); } -function loadGroupById_RESTClient(groupid) { +function loadGroupById_RESTClient(id) { var json = { - "groupid" : groupid + "id" : id }; var postUrl = url + "loadGroupByid"; AjaxHelper.call({ @@ -216,10 +228,12 @@ function loadGroupById_RESTClient(groupid) { }); } -function updateGroup_RESTClient(groupid, appids) { +function updateGroup_RESTClient(id, groupId,ldapKey,appids) { var json = { - "groupid" : groupid, - "appids" : appids + "id" : id, + "groupid":groupId, + "ldapkey":ldapKey, + "appids" : appids }; var postUrl = url + "updateGroup"; AjaxHelper.call({ diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/main.html b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/main.html index c9451952..39e6f90e 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/main.html +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/main.html @@ -48,9 +48,13 @@
新建授权
- + + + + +
组ID:授权组:
关键字:
授权APP: @@ -86,9 +90,13 @@
授权详情
- + + + + + diff --git a/com.creditease.uav.healthmanager.buildComponent/config/mail.template b/com.creditease.uav.healthmanager.buildComponent/config/mail.template index 828fd920..d371cc9a 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/mail.template +++ b/com.creditease.uav.healthmanager.buildComponent/config/mail.template @@ -34,7 +34,17 @@ #timeFlag# - +
  • + + 报警策略 + + + : + + + #strategydesc# + +
  • 问题描述 @@ -141,10 +151,7 @@
  • diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java index d9ab2459..9bd0f67d 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java @@ -33,7 +33,6 @@ import com.creditease.agent.helpers.DateTimeHelper; import com.creditease.agent.helpers.EncodeHelper; import com.creditease.agent.helpers.JSONHelper; - /** * notify strategy ds */ @@ -59,48 +58,209 @@ public String toString() { private static final Pattern INDEX_PATTERN = Pattern.compile("\\[\\d+\\]"); - private Type type; + private long maxRange = 0; + private Type type; + + private String name; + + private String desc; + private String scope; - - private List condtions; - - private List convergences; private String msgTemplate; + + private List condtions; - private Map action = Collections.emptyMap(); + private List convergences; private List context = Collections.emptyList(); private List instances = Collections.emptyList(); - private long maxRange = 0; - - private String name; + private Map action = Collections.emptyMap(); public NotifyStrategy() { } - public NotifyStrategy(String name, String scope, List context, Map action, - List instances, String msgTemplate, List convergences) { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public NotifyStrategy(String name, String json) { + + Map m = JSONHelper.toObject(json, Map.class); + String scope = (String) m.get("scope"); + String desc = (String) m.get("desc"); + List context = (List) m.get("context"); + List conds = (List) m.get("conditions"); + List relations = (List) m.get("relations"); + List convergences = (List) m.get("convergences"); + Map action = (Map) m.get("action"); + String msgTemplate = (String) m.get("msgTemplate"); + List instances = (List) m.get("instances"); + + List conditions = determineConditions(conds, relations, name); + long maxRange = determineMaxRange(conditions); + Type type = determineType(conds); + + setMaxRange(maxRange).setType(type).setName(name).setDesc(desc).setScope(scope).setMsgTemplate(msgTemplate) + .setConditions(conditions).setConvergences(convergences).setContext(context).setInstances(instances) + .setAction(action); + } + + public NotifyStrategy setMaxRange(long maxRange) { + + this.maxRange = maxRange; + return this; + } + + public NotifyStrategy setType(Type type) { + + this.type = type; + return this; + } + + public NotifyStrategy setName(String name) { + this.name = name; + return this; + } + + public NotifyStrategy setDesc(String desc) { + + this.desc = desc; + return this; + } + + public NotifyStrategy setScope(String scope) { + this.scope = scope; + return this; + } + + public NotifyStrategy setMsgTemplate(String msgTemplate) { + + this.msgTemplate = msgTemplate; + return this; + } + + public NotifyStrategy setConditions(List conditions) { + + this.condtions = conditions; + return this; + } + + public NotifyStrategy setConvergences(List convergences) { + + this.convergences = convergences; + return this; + } + + public NotifyStrategy setContext(List context) { + if (context != null && context.size() != 0) { this.context = context; } - if (action != null && action.size() != 0) { - this.action = action; - } + return this; + } + + public NotifyStrategy setInstances(List instances) { + if (instances != null && instances.size() != 0) { this.instances = instances; } - this.convergences = convergences; - this.msgTemplate = msgTemplate; + return this; + } + + public NotifyStrategy setAction(Map action) { + + if (action != null && action.size() != 0) { + this.action = action; + } + return this; + } + + public long getMaxRange() { + + return maxRange; + } + + public Type getType() { + + return type; + } + + public String getName() { + + return name; + } + + public String getDesc() { + + return desc; + } + + public String getScope() { + + return scope; + } + + public String getMsgTemplate() { + + return msgTemplate; + } + + public List getCondtions() { + + return condtions; + } + + public List getConvergences() { + + return convergences; + } + + public List getContext() { + + return context; + } + + public List getInstances() { + + return instances; } - public void setConditions(List conditions, List relations) { + public Map getAction() { + return action; + } + + private long determineMaxRange(List conditions) { + + long maxRange = 0; + for (Condition cond : conditions) { + for (Expression expr : cond.expressions) { + maxRange = Math.max(maxRange, expr.range); + } + } + + return maxRange; + } + + private Type determineType(List conds) { + + Type type = Type.STREAM; + for (Object o : conds) { + @SuppressWarnings("unchecked") + Map cond = (Map) o; + if (cond.get("type") != null && cond.get("type").equals(Type.TIMER.name)) { + type = Type.TIMER; + } + } + + return type; + } + + private List determineConditions(List conditions, List relations, String name) { + int idx = 0; // expression count List exprs = new ArrayList<>(); for (Object o : conditions) { @@ -144,7 +304,6 @@ public void setConditions(List conditions, List relations) { cond.put("metric", metric); expression = new Expression(cond); - this.type = Type.TIMER; } expression.setIdx(idx++); exprs.add(expression); @@ -184,110 +343,7 @@ public void setConditions(List conditions, List relations) { } } - this.condtions = conds; - - /** init max range */ - for (Condition cond : this.condtions) { - for (Expression expr : cond.expressions) { - maxRange = Math.max(maxRange, expr.range); - } - } - - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static NotifyStrategy parse(String name, String json) { - - Map m = JSONHelper.toObject(json, Map.class); - String scope = (String) m.get("scope"); - List context = (List) m.get("context"); - List conditions = (List) m.get("conditions"); - List relations = (List) m.get("relations"); - List convergences = (List) m.get("convergences"); - Map action = (Map) m.get("action"); - String msgTemplate = (String) m.get("msgTemplate"); - List instances = (List) m.get("instances"); - - NotifyStrategy stra = new NotifyStrategy(name, scope, context, action, instances, msgTemplate, convergences); - - stra.setConditions(conditions, relations); - - return stra; - } - - public long getMaxRange() { - - return maxRange; - } - - public String getMsgTemplate() { - - return msgTemplate; - } - - public void setMsgTemplate(String msgTemplate) { - - this.msgTemplate = msgTemplate; - } - - public Map getAction() { - - return action; - } - - public void setAction(Map action) { - - this.action = action; - } - - public List getContext() { - - return context; - } - - public void setContext(List context) { - - this.context = context; - } - - public String getScope() { - - return scope; - } - - public void setScope(String scope) { - - this.scope = scope; - } - - public List getInstances() { - - return instances; - } - - public void setInstances(List instances) { - - this.instances = instances; - } - - public String getName() { - - return name; - } - - public Type getType() { - - return type; - } - - public List getCondtions() { - - return condtions; - } - - public List getConvergences() { - - return convergences; + return conds; } protected static class Expression { diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java index 84ce49f9..6a97450b 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java @@ -110,6 +110,7 @@ public StrategyJudgement(String cName, String feature) { public Map judge(Slice cur, NotifyStrategy stra, List slices) { JudgeResult re = new JudgeResult(); + re.setStrategy(stra); List conds = stra.getCondtions(); for (NotifyStrategy.Condition cond : conds) { @@ -756,9 +757,16 @@ private String generateJsExpression(String jointCondition, boolean[] exprResult) } private class JudgeResult { + + private NotifyStrategy stra; private List crs = new ArrayList<>(); + public void setStrategy(NotifyStrategy stra) { + + this.stra = stra; + } + public void add(ConditionResult cr) { crs.add(cr); @@ -789,7 +797,7 @@ public Map buildReadableResult() { if (result == null) { if (log.isTraceEnable()) { - log.warn(this, "JsHelper eval Exception: script=" + script); + log.warn(this, "JsHelper eval Exception: script=" + script + ", StrategyDesc=" + stra.getDesc() + ", StrategyName=" + stra.getName()); } continue; } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java index 217b552e..50e9320c 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/NodeInfoWatcher.java @@ -473,6 +473,7 @@ private void fireEvent(Map> deadProcs) { if (null != stra) { putNotifyAction(event, stra); + event.addArg("strategydesc", stra.getDesc()); } if (log.isTraceEnable()) { diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/RuntimeNotifyStrategyMgr.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/RuntimeNotifyStrategyMgr.java index 5a493f10..91759c0a 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/RuntimeNotifyStrategyMgr.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/RuntimeNotifyStrategyMgr.java @@ -96,7 +96,7 @@ public void loadStrategy(String json) { String key = entry.getKey(); Map m = (Map) entry.getValue(); - NotifyStrategy stra = NotifyStrategy.parse(key, JSONHelper.toString(m)); + NotifyStrategy stra = new NotifyStrategy(key, JSONHelper.toString(m)); if (log.isDebugEnable()) { log.debug(this, "Parse NotifyStrategy: " + JSONHelper.toString(stra)); @@ -234,7 +234,7 @@ public void run() { for (String key : strategyMap.keySet()) { String json = strategyMap.get(key); - NotifyStrategy stra = NotifyStrategy.parse(key, json); + NotifyStrategy stra = new NotifyStrategy(key, json); if (log.isDebugEnable()) { log.debug(this, "Parse NotifyStrategy: " + JSONHelper.toString(stra)); diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java index 461cede5..8de49491 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTask.java @@ -133,7 +133,7 @@ public void run() { * Step 5: if fire the event, build notification event */ if (result != null && !result.isEmpty()) { - NotificationEvent event = this.newNotificationEvent(result, stra.getConvergences()); + NotificationEvent event = this.newNotificationEvent(result, stra); // get context putContext(event); @@ -152,7 +152,7 @@ public void run() { } } catch (Exception e) { - log.err(this, "JudgeNotifyTask RUN FAIL.", e); + log.err(this, "JudgeNotifyTask RUN FAIL." + " StrategyDesc=" + stra.getDesc() + ", StrategyName=" + stra.getName() + "\n", e); } if (log.isDebugEnable()) { @@ -188,7 +188,7 @@ private void putContext(NotificationEvent event) { * * @return */ - private NotificationEvent newNotificationEvent(Map result, List convergences) { + private NotificationEvent newNotificationEvent(Map result, NotifyStrategy stra) { String ip = this.curSlice.getMdf().getIP(); String host = this.curSlice.getMdf().getHost(); @@ -215,10 +215,11 @@ private NotificationEvent newNotificationEvent(Map result, List< NotificationEvent ne = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_THRESHOLD, title, description, curSlice.getTime(), ip, host); - // add appgroup ne.addArg("appgroup", appgroup); + ne.addArg("strategydesc", stra.getDesc()); // 兼容不存在convergences属性的旧预警策略 + List convergences = stra.getConvergences(); if(convergences == null || convergences.size() == 0 ) { return ne; } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java index ad1cad4c..f8de278d 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java @@ -122,7 +122,7 @@ public void run() { } catch (Exception e) { - log.err(this, "JudgeNotifyTimerTask" + stra.getName() + " RUN FAIL.", e); + log.err(this, "JudgeNotifyTimerTask RUN FAIL." + " StrategyDesc=" + stra.getDesc() + ", StrategyName=" + stra.getName() + "\n", e); } finally { if (lock != null && lock.isLockInHand()) { @@ -195,8 +195,8 @@ private NotificationEvent newNotificationEvent(String instance, Map Date: Wed, 23 May 2018 14:11:27 +0800 Subject: [PATCH 89/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/286=20=E4=BF=AE=E6=94=B9=E6=8A=A5=E8=AD=A6=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=9A=84=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/JTAmail.template | 2 +- .../config/mail.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template b/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template index 46539f95..14f6cde4 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template +++ b/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template @@ -34,7 +34,7 @@ #timeFlag# -
  • +
  • 报警策略 diff --git a/com.creditease.uav.healthmanager.buildComponent/config/mail.template b/com.creditease.uav.healthmanager.buildComponent/config/mail.template index d371cc9a..555f6430 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/mail.template +++ b/com.creditease.uav.healthmanager.buildComponent/config/mail.template @@ -34,7 +34,7 @@ #timeFlag#
  • -
  • +
  • 报警策略 From 39273bc45e36c16c930e2e663cbea812ef8c75b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Wed, 23 May 2018 14:24:13 +0800 Subject: [PATCH 90/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/287=20httpclient=E8=AE=B0=E5=BD=95=E8=BF=94=E5=9B=9E=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/creditease/agent/helpers/StringHelper.java | 14 ++++++++++++++ .../monitor/handlers/ClientRespTimeCapHandler.java | 10 ++++++++++ .../profiling/handlers/ClientProfileHandler.java | 6 ++++++ .../uav/profiling/spi/ProfileConstants.java | 1 + 4 files changed, 31 insertions(+) diff --git a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java index b603ecad..d6a8579b 100644 --- a/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java +++ b/com.creditease.uav.helper/src/main/java/com/creditease/agent/helpers/StringHelper.java @@ -950,6 +950,7 @@ public static Set commaDelimitedListToSet(String str) { return set; } + @Deprecated public static boolean isNumeric(String str) { if (str == null || str.isEmpty()) { @@ -958,6 +959,19 @@ public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); } + + public static boolean isNaturalNumber(String str) { + + if (str == null || str.isEmpty()) { + return false; + } + for (int i = 0; i < str.length(); i++) { + if (str.charAt(i) < '0' || str.charAt(i) > '9') { + return false; + } + } + return true; + } /** * get sub string before the token str diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/handlers/ClientRespTimeCapHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/handlers/ClientRespTimeCapHandler.java index e688e506..10c8fbfb 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/handlers/ClientRespTimeCapHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/monitor/handlers/ClientRespTimeCapHandler.java @@ -118,12 +118,14 @@ private void doProfileClient(CaptureContext context, String clientRequestURL, St String action = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_ACTION); Integer rc = (Integer) context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE); + String rs = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE); String type = (String) context.get(CaptureConstants.INFO_CLIENT_TYPE); String server = (String) context.get(CaptureConstants.INFO_CLIENT_TARGETSERVER); pc.put(ProfileConstants.PC_ARG_CLIENT_URL, clientRequestURL); pc.put(ProfileConstants.PC_ARG_CLIENT_ACTION, action); pc.put(ProfileConstants.PC_ARG_CLIENT_RC, rc); + pc.put(ProfileConstants.PC_ARG_CLIENT_RS, rs); pc.put(ProfileConstants.PC_ARG_CLIENT_TYPE, type); pc.put(ProfileConstants.PC_ARG_CLIENT_TARGETSERVER, server); @@ -148,6 +150,7 @@ protected void recordCounters(CaptureContext context, MonitorElementInstance ins */ String action = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_ACTION); Integer rc = (Integer) context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE); + String clientRequestURL = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_URL); if (rc != null && rc == -1) { inst.increValue(CaptureConstants.MEI_ERROR); @@ -161,6 +164,13 @@ else if (rc == -1) { inst.increValue(MonitorServerUtil.getActionErrorTag(action)); } } + + if (clientRequestURL.startsWith("http")) { + String rs = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE); + if(StringHelper.isNaturalNumber(rs)) { + inst.increValue(MonitorServerUtil.getActionTag(rs)); + } + } } @Override diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ClientProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ClientProfileHandler.java index 24d126e5..27ac4a89 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ClientProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ClientProfileHandler.java @@ -132,6 +132,12 @@ else if (rc == -1) { urlAttrs.put(MonitorServerUtil.getActionErrorTag(action), curTime); } + if (clientURL.startsWith("http")) { + String rs = (String) context.get(ProfileConstants.PC_ARG_CLIENT_RS); + if(StringHelper.isNaturalNumber(rs)) { + urlAttrs.put(MonitorServerUtil.getActionTag(rs), curTime); + } + } } /** diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileConstants.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileConstants.java index 04a42266..2085617f 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileConstants.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileConstants.java @@ -48,6 +48,7 @@ public class ProfileConstants { public final static String PC_ARG_CLIENT_URL = "pc.client.url"; public final static String PC_ARG_CLIENT_ACTION = "pc.client.action"; public static final String PC_ARG_CLIENT_RC = "pc.client.rc"; + public static final String PC_ARG_CLIENT_RS = "pc.client.rs"; public static final String PC_ARG_CLIENT_TYPE = "pc.client.type"; public static final String PC_ARG_CLIENT_TARGETSERVER = "pc.client.target.server"; From 240a5269debbba5d5d8acbc27c9f4e12be351bea Mon Sep 17 00:00:00 2001 From: wenqiangzhu Date: Fri, 25 May 2018 12:53:14 +0800 Subject: [PATCH 91/97] #289 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加调用链条件查询功能,目前可查字段有服务URL(url)、状态(state)、服务类(class)、 方法(method),每个字段均支持多关键字联合查询及模糊查询。 --- .../uav/godeye/rest/APMRestService.java | 21 ++ .../appmonitor/css/uav.appmonitor.css | 5 + .../uavapp_godeye/appmonitor/js/uav.apm.js | 192 ++++++++++++++++-- .../http/InvokeChainQueryHandler.java | 89 +++++++- 4 files changed, 284 insertions(+), 23 deletions(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/APMRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/APMRestService.java index 7ffccc73..50b544d3 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/APMRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/godeye/rest/APMRestService.java @@ -21,6 +21,7 @@ package com.creditease.uav.godeye.rest; import java.io.InputStream; +import java.util.Map; import javax.inject.Singleton; import javax.ws.rs.POST; @@ -32,6 +33,7 @@ import org.apache.http.HttpStatus; +import com.creditease.agent.helpers.StringHelper; import com.creditease.agent.http.api.UAVHttpMessage; import com.creditease.uav.httpasync.HttpClientCallback; import com.creditease.uav.httpasync.HttpClientCallbackResult; @@ -86,6 +88,25 @@ public void queryIVC(String data, @Suspended AsyncResponse response) { UAVHttpMessage msg = new UAVHttpMessage(data); + Map request = msg.getRequest(); + String content = request.get("content"); + + if (!StringHelper.isEmpty(content)) { + String[] contents = content.split(","); + String[] condition; + for (String ctn : contents) { + if(StringHelper.isEmpty(ctn)) { + continue; + } + condition = ctn.split("="); + if(condition.length < 2) { + response.resume("{\"rs\":\"ERR\",\"msg\":\"query syntax error\"}"); + return; + } + request.put(condition[0], condition[1].replaceAll("\"", "")); + } + } + this.doHttpPost("uav.app.apm.ivc.http.addr", "/ivc/q", msg, new IVCCallback(response)); } diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/css/uav.appmonitor.css b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/css/uav.appmonitor.css index 5d91a127..74b9c967 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/css/uav.appmonitor.css +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/css/uav.appmonitor.css @@ -491,6 +491,11 @@ select{ color:#333; } +.IvcHighLightKeyword { + background:yellow; + color:#333; +} + .pluginAlertNtfy { width: 30px; height: 30px; diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js index c0ee62da..2a1b40c4 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/appmonitor/js/uav.apm.js @@ -158,7 +158,7 @@ function APMTool(app) { openDelete : false, key : "traceid", pagerSwitchThreshold : 600, - pagesize : 100, + pagesize : 50, deleteCtr : { key : "state", showDelete : "0" @@ -503,34 +503,39 @@ function APMTool(app) { "
    "+ ""; - html+="
    "; + html+="
    "; } //全局模式 else { - html="
    " + html="
    " html+= "
    应用实例
    "; } - html+="
    时间
    " - + "" + html+="
    " + + "时间" + "" + "" + + "
    " + - + "" - - + "
    "; - -// + "
    搜索 " + + "" + + "
    "; html+=" "+ " " + " " + - " " ; + " 
    " ; html+="
    "; @@ -577,6 +582,16 @@ function APMTool(app) { app.controller.showWindow({traceid:id,comeFrom:"IVC"},"AppIVCTraceWnd","buildAppIVCTraceWnd","runAppIVCTraceWnd"); }; + // 分页事件 + this.mainList.sendRequest=function() { + + var pInfo=_this.mainList.getPagingInfo(); + + var start=(pInfo.pageNum-1)*pInfo.pageSize; + + _this.callIVCQuery("qsearch",{},{from:start,size:pInfo.pageSize}); + }; + //init datetime picker $('.form_datetime').datetimepicker({ language : 'zh-CN', @@ -697,6 +712,13 @@ function APMTool(app) { } + /** + * 跳转查询帮助界面 + */ + this.openHelpDiv = function() { + window.open("https://uavorg.github.io/documents/uavdoc_useroperation/59.html#%E6%9F%A5%E8%AF%A2%E5%B8%AE%E5%8A%A9","apphub.help"); + } + /** * 跳转到日志搜索结果页 */ @@ -911,8 +933,17 @@ function APMTool(app) { } // 必须先显示分页 - list.setTotalRow(count); - list.renderPagination(); + list.setTotalRow(totalCount); + list.renderPagination(); + + var keywords = this.getHighlightKeywords(); + + if(params == undefined && keywords != undefined){ + for(var type in keywords){ + this.setKeywordsHighlight(type,keywords[type],datas); + } + } + list.addTreeTableRows(datas); // only AppIVCTraceWnd_TraceList need treetable @@ -924,6 +955,70 @@ function APMTool(app) { //diaplay the Root Node $("#AppIVCTraceWnd_TraceList").treetable("expandNode","1"); } + + if(datas.length > 50){ + list.hidePagerPagination(); + } + }; + + this.getHighlightKeywords=function() { + + var content = this.parseKeyword(); + + if(content == undefined){ + return; + } + + var contents = content.split(","); + + var result = {}; + + for (var i = 0;i < contents.length;i++){ + + this.getKeywordArray(contents[i],result); + + } + + return result; + }; + + this.getKeywordArray = function(contents,result){ + if(contents.indexOf("=") == -1){ + return; + } + + var keywords = []; + var ctn = contents.split("="); + var orkwds=ctn[1].replace(/\"/g,"").split(" "); + + for(var i=0;i -1) { + lines=datas[j][type].split(keywords[i]); + datas[j][type] = lines.join(""+keywords[i]+""); + } + } + } }; // TODO ----------------------------------调用链查看窗口:全局模式专有--------------------- this.profileDAO=new UAVProfileDAO(); @@ -1101,7 +1196,7 @@ function APMTool(app) { /** * 访问调用链查询服务 */ - this.callIVCQuery=function(intent,pObj) { + this.callIVCQuery=function(intent,pObj,cursor) { var data={intent:"qApp",request:{}}; @@ -1120,7 +1215,12 @@ function APMTool(app) { appuuid=this.appInfo["appuuid"]; } else { - appuuid=pObj["appuuid"]; + appuuid=this.appInfo["appuuid"]; + } + + var content = this.parseKeyword(); + if(content != undefined){ + data["request"]["content"] = content; } switch(intent) { @@ -1134,7 +1234,7 @@ function APMTool(app) { if (timeRange==undefined) { var tmp=new Date().getTime(); - timeRange={etime:tmp,stime:tmp-60000}; + timeRange={etime:tmp,stime:tmp-60000*60}; } var etime=timeRange["etime"]; @@ -1144,9 +1244,17 @@ function APMTool(app) { data["request"]["etime"]=etime+""; data["request"]["eptype"]="E,S"; data["request"]["from"]=0+""; - data["request"]["size"]=500+""; + data["request"]["size"]=50+""; data["request"]["indexdate"]=timeRange["indexdate"]; + if (cursor != undefined){ + data["request"]["from"]=cursor.from+""; + data["request"]["size"]=cursor.size+""; + } + else{ + dataList.setPageNum(1); + } + var timeSort=this.timeSortSelector.value(); if (timeSort=="DESC") { data["request"]["sort"]="stime=DESC"; @@ -1165,7 +1273,7 @@ function APMTool(app) { data["request"]["etime"]=etime+""; data["request"]["eptype"]="E,S"; data["request"]["from"]=0+""; - data["request"]["size"]=100+""; + data["request"]["size"]=50+""; break; case "lst100": dataList=this.mainList; @@ -1256,6 +1364,50 @@ function APMTool(app) { }); }; + this.getKeyword=function() { + + var keys=""; + + if (HtmlHelper.id("AppIVCWnd_KeyWord")!=undefined&&HtmlHelper.id("AppIVCWnd_KeyWord").value!="") { + keys=HtmlHelper.id("AppIVCWnd_KeyWord").value; + } + + return keys; + }; + + /** + * 把keyword转换成后台需要的格式url="xxx",stat="xxx",class="xxx" + */ + this.parseKeyword=function(){ + + var keyword = this.getKeyword(); + if(keyword == ""){ + return; + } + + //如果是类似method="**"直接返回 + if(keyword.indexOf("=") > -1 && keyword.indexOf("\"") > -1){ + return keyword; + } + //不包含@标识,当作url关键字 + if(keyword.indexOf("@") == -1){ + return "url=\"" + keyword + "\""; + } + //以@标识开头,当作state关键字 + if(keyword.startsWith("@")){ + return "state=\"" + keyword.substring(1) + "\""; + } + //@标识符超过一个,目前先当作url关键字 + var keywords = keyword.split("@"); + if(! keywords.length == 2){ + return "url=\"" + keyword + "\""; + } + //@标识符只有一个,@前面的为url关键字,后边的为state关键字 + var content = "url=\"" + keywords[0] + "\""; + content += ",state=\"" + keywords[1] + "\""; + return content; + }; + /** * 访问重调用链查询服务 */ diff --git a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/InvokeChainQueryHandler.java b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/InvokeChainQueryHandler.java index f9c1c536..a868184d 100644 --- a/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/InvokeChainQueryHandler.java +++ b/com.creditease.uav.invokechain/src/main/java/com/creditease/uav/invokechain/http/InvokeChainQueryHandler.java @@ -206,25 +206,108 @@ private void queryByApp(UAVHttpMessage data) { String cls = data.getRequest("class"); if (cls != null) { - queryBuilder.must(QueryBuilders.wildcardQuery("class.keyword", cls.trim())); + parseSearchCondition(queryBuilder, cls, "class"); } String method = data.getRequest("method"); if (method != null) { - queryBuilder.must(QueryBuilders.wildcardQuery("method.keyword", method.trim())); + parseSearchCondition(queryBuilder, method, "method"); } String url = data.getRequest("url"); if (url != null) { - queryBuilder.must(QueryBuilders.wildcardQuery("url.keyword", url.trim())); + parseSearchCondition(queryBuilder, url, "url"); + } + + String state = data.getRequest("state"); + + if (state != null) { + parseSearchCondition(queryBuilder, state, "state"); } SortBuilder[] sorts = buildSort(data); this.queryToList(data, queryBuilder, null, sorts); } + + /** + * parseSearchCondition + * + * 如果用空格分开多个关键字,则默认为或的关系 + * + * 如果某些关键字是以+连接,代表与关系 + * + * 注意这里只支持或优先的操作 + * + * 举例: + + * + * 则代表的是意思是(kwd1 and kwd2 同时存在)或kwd3存在或kwd4存在 + * + * @param queryBuilder + * @param content + */ + private void parseSearchCondition(BoolQueryBuilder queryBuilder, String content, String field) { + + if (content == null) { + return; + } + + boolean hasCompandSearch = (content.indexOf("+") > -1) ? true : false; + + if (hasCompandSearch == false) { + if (content.indexOf("*") == -1) { + queryBuilder.must(QueryBuilders.matchQuery(field, content)); + } + else { + queryBuilder.must(QueryBuilders.wildcardQuery(field+".keyword", content)); + } + } + else { + + BoolQueryBuilder orQueryBuilder = QueryBuilders.boolQuery(); + + String[] orKwds = content.split(" "); + + for (String orKwd : orKwds) { + + /** + * 如果没有与关系,就检查是否有* + */ + if (orKwd.indexOf("+") == -1) { + if (orKwd.indexOf("*") == -1) { + orQueryBuilder.should(QueryBuilders.matchQuery(field, orKwd)); + } + else { + orQueryBuilder.should(QueryBuilders.wildcardQuery(field+".keyword", orKwd)); + } + } + else { + /** + * 或关系,检查是否有* + */ + String[] andKwds = orKwd.split("\\+"); + + BoolQueryBuilder andQueryBuilder = QueryBuilders.boolQuery(); + + for (String andKwd : andKwds) { + if (andKwd.indexOf("*") == -1) { + andQueryBuilder.must(QueryBuilders.matchQuery(field, andKwd)); + } + else { + andQueryBuilder.must(QueryBuilders.wildcardQuery(field+".keyword", andKwd)); + } + } + + orQueryBuilder.should(andQueryBuilder); + } + + } + + queryBuilder.must(orQueryBuilder); + } + } @SuppressWarnings("rawtypes") private SortBuilder[] buildSort(UAVHttpMessage data) { From dcfd9097598d25929d2337a06084570506dfd6fd Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 25 May 2018 14:17:31 +0800 Subject: [PATCH 92/97] https://github.com/uavorg/uavstack/issues/290 1.change the key of jvmInfos map from workerId to workerName in detector --- .../agent/feature/monitoragent/detect/BaseDetector.java | 6 +++--- .../feature/monitoragent/detect/JVMContainerOSDetector.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java index 056b31cf..fb0b8d5f 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/BaseDetector.java @@ -141,7 +141,7 @@ protected void addWorker(JVMAgentInfo appServerInfo) { this.workers.put(workerName, worker); // save appserverinfo - this.jvmAgentInfos.put(worker.getWorkerId(), appServerInfo); + this.jvmAgentInfos.put(workerName, appServerInfo); log.info(this, worker.getClass().getSimpleName() + "[" + workerName + "] started"); } @@ -182,7 +182,7 @@ public void stop() { // cancel worker worker.cancel(); - this.jvmAgentInfos.remove(worker.getWorkerId()); + this.jvmAgentInfos.remove(worker.getName()); log.info(this, "MonitorDataCatchWorker[" + worker.getName() + "] stopped"); } @@ -201,7 +201,7 @@ public void removeWorker(String workName) { worker.cancel(); - this.jvmAgentInfos.remove(worker.getWorkerId()); + this.jvmAgentInfos.remove(workName); log.info(this, "MonitorDataCatchWorker[" + worker.getName() + "] stopped"); } diff --git a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java index 9cecaa4a..266baafc 100644 --- a/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java +++ b/com.creditease.uav.agent/src/main/java/com/creditease/agent/feature/monitoragent/detect/JVMContainerOSDetector.java @@ -354,7 +354,7 @@ public boolean workerExist(String pid,String url,List urlList) { for(BaseMonitorDataCatchWorker worker:workers.values()) { - JVMAgentInfo appServerInfo = jvmAgentInfos.get(worker.getWorkerId()); + JVMAgentInfo appServerInfo = jvmAgentInfos.get(worker.getName()); if(appServerInfo!=null && JVMAccessURL.equals((appServerInfo.getJVMAccessURL()))) { From 78ec45b42996250f5bbb4af63f46c461fe85d526 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 25 May 2018 16:19:30 +0800 Subject: [PATCH 93/97] https://github.com/uavorg/uavstack/issues/275 --- .../main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js | 1 - 1 file changed, 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index d056403d..e0fd5689 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -445,7 +445,6 @@ function showEditNotifyDiv(jsonObjParam,isCopy) { }else{ sb.append( '
    '); } - sb.append( '
    '); sb.append( '
    '); sb.append( '
     
    '); } From e5cda5bb3996de1ecc00aacecaaab04fca4672c9 Mon Sep 17 00:00:00 2001 From: chongli8 Date: Thu, 31 May 2018 11:36:38 +0800 Subject: [PATCH 94/97] add initialization value of rocketmq consumer --- .../uav/messaging/api/MessagingFactory.java | 10 +- .../messaging/impl/RMQMessageConsumer.java | 9 +- .../messaging/TestRMQMessageConsumer.java | 2 +- .../MessageProducerResourceComponent.java | 98 ------------ .../messaging/StandardMessagingBuilder.java | 142 ------------------ .../messaging/StandardMessagingBuilder.java | 4 + 6 files changed, 16 insertions(+), 249 deletions(-) delete mode 100644 com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/MessageProducerResourceComponent.java delete mode 100644 com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/messaging/StandardMessagingBuilder.java diff --git a/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/api/MessagingFactory.java b/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/api/MessagingFactory.java index 4a2a7b6e..47f916ad 100644 --- a/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/api/MessagingFactory.java +++ b/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/api/MessagingFactory.java @@ -77,17 +77,19 @@ public static MessageProducer getMessageProducer(String producerId) { * @return */ public static MessageConsumer createMessageConsumer(String name, String[] bizIDs, int maxConcurrent, - long stopInterval, MQFactory.QueueType queueType) { + int initConcurrent, long stopInterval, MQFactory.QueueType queueType) { - MessageConsumer consumer = new RMQMessageConsumer(name, bizIDs, maxConcurrent, stopInterval, queueType); + MessageConsumer consumer = new RMQMessageConsumer(name, bizIDs, maxConcurrent, initConcurrent, stopInterval, + queueType); return consumer; } public static MessageConsumer createMessageConsumer(String name, String[] bizIDs, int maxConcurrent, - long stopInterval) { + int initConcurrent, long stopInterval) { - return createMessageConsumer(name, bizIDs, maxConcurrent, stopInterval, MQFactory.QueueType.QUEUE); + return createMessageConsumer(name, bizIDs, maxConcurrent, initConcurrent, stopInterval, + MQFactory.QueueType.QUEUE); } /** diff --git a/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/impl/RMQMessageConsumer.java b/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/impl/RMQMessageConsumer.java index 46ecf89d..f43ff13f 100644 --- a/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/impl/RMQMessageConsumer.java +++ b/com.creditease.uav.messaging/src/main/java/com/creditease/uav/messaging/impl/RMQMessageConsumer.java @@ -48,8 +48,9 @@ public class RMQMessageConsumer extends MessageConsumer { private long stopInterval = 0; @SuppressWarnings("unchecked") - public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, long stopInterval, + public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, int initConcurrent, long stopInterval, MQFactory.QueueType queueType) { + super(name, bizIds); this.context = MessagingContext.instance(); @@ -61,7 +62,7 @@ public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, long // group不同的consumer不能重复 config.setComsumerGroup(MessagingContext.DefaultConsumerGroup + "-" + this.getName()); config.setConsumeThreadMax(maxConcurrent); - config.setConsumeThreadMin(1); + config.setConsumeThreadMin(initConcurrent); // 暂时使用默认值,调优的时候可能需要调整这个参数 config.setPullBatchSize(0); // get bizId2TopicMap @@ -79,9 +80,9 @@ public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, long consumer = MQFactory.createMQConsumer(config, queueInfo); } - public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, long stopInterval) { + public RMQMessageConsumer(String name, String[] bizIds, int maxConcurrent, int initConcurrent, long stopInterval) { - this(name, bizIds, maxConcurrent, stopInterval, MQFactory.QueueType.QUEUE); + this(name, bizIds, maxConcurrent, initConcurrent, stopInterval, MQFactory.QueueType.QUEUE); } @Override diff --git a/com.creditease.uav.messaging/src/test/java/test/messaging/TestRMQMessageConsumer.java b/com.creditease.uav.messaging/src/test/java/test/messaging/TestRMQMessageConsumer.java index 6ba491d4..e0791663 100644 --- a/com.creditease.uav.messaging/src/test/java/test/messaging/TestRMQMessageConsumer.java +++ b/com.creditease.uav.messaging/src/test/java/test/messaging/TestRMQMessageConsumer.java @@ -44,7 +44,7 @@ public static void main(String[] args) { bizIDs[0] = "test"; String[] handlerNames = new String[1]; handlerNames[0] = "test"; - MessageConsumer consumer = MessagingFactory.createMessageConsumer("name", bizIDs, 10, 0); + MessageConsumer consumer = MessagingFactory.createMessageConsumer("name", bizIDs, 10, 10, 0); consumer.start(); } } diff --git a/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/MessageProducerResourceComponent.java b/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/MessageProducerResourceComponent.java deleted file mode 100644 index cfbb9baa..00000000 --- a/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/MessageProducerResourceComponent.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.agent.feature.common; - -import java.io.IOException; -import java.util.Properties; - -import com.creditease.agent.feature.common.messaging.StandardMessagingBuilder; -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.helpers.StringHelper; -import com.creditease.agent.spi.AgentResourceComponent; -import com.creditease.uav.messaging.api.MessageProducer; -import com.creditease.uav.messaging.api.MessagingContext; - -public class MessageProducerResourceComponent extends AgentResourceComponent { - - private MessageProducer msgProducer; - - public MessageProducerResourceComponent(String cName, String feature) { - super(cName, feature); - } - - @Override - public Object initResource() { - - StandardMessagingBuilder smb = new StandardMessagingBuilder("CommonProducerBuilder", this.feature); - - try { - smb.init(null); - } - catch (IOException e) { - log.err(this, "Read msgtype2topic.properties FAILs, UAV MessageProducer can not start", e); - return null; - } - - msgProducer = smb.buildProducer(); - msgProducer.start(); - - if (log.isTraceEnable()) { - log.info(this, "UAV MessageProducer is started"); - } - - return msgProducer; - } - - @Override - public void releaseResource() { - - if (msgProducer != null) { - msgProducer.stop(); - } - - if (log.isTraceEnable()) { - log.info(this, "UAV MessageProducer is stopped"); - } - } - - @Override - public Object getResource() { - - return msgProducer; - } - - @Override - public void onConfigUpdate(Properties updatedConfig) { - - if (StringHelper.isEmpty((String) updatedConfig.get("resource.messageproducer.messagesizelimit"))) { - return; - } - - long msgSizeLimit = DataConvertHelper.toLong(updatedConfig.get("resource.messageproducer.messagesizelimit"), - MessagingContext.DEFAULT_MSG_SIZE_LIMIT); - - msgProducer.setMsgSizeLimit(msgSizeLimit); - - if (log.isTraceEnable()) { - log.info(this, "Update Message Size Limit To " + msgSizeLimit); - } - } -} diff --git a/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/messaging/StandardMessagingBuilder.java b/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/messaging/StandardMessagingBuilder.java deleted file mode 100644 index f860f7a5..00000000 --- a/com.creditease.uav.notifymanager/src/main/java/com/creditease/agent/feature/common/messaging/StandardMessagingBuilder.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * << - * UAVStack - * == - * Copyright (C) 2016 - 2017 UAVStack - * == - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * >> - */ - -package com.creditease.agent.feature.common.messaging; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; - -import com.creditease.agent.ConfigurationManager; -import com.creditease.agent.helpers.DataConvertHelper; -import com.creditease.agent.helpers.PackageHelper; -import com.creditease.agent.helpers.PropertiesHelper; -import com.creditease.agent.helpers.StringHelper; -import com.creditease.agent.spi.AbstractComponent; -import com.creditease.agent.spi.IConfigurationManager; -import com.creditease.uav.messaging.api.MessageConsumer; -import com.creditease.uav.messaging.api.MessageProducer; -import com.creditease.uav.messaging.api.MessagingContext; -import com.creditease.uav.messaging.api.MessagingFactory; -import com.creditease.uav.mq.api.MQFactory; - -public class StandardMessagingBuilder extends AbstractComponent { - - public StandardMessagingBuilder(String cName, String feature) { - super(cName, feature); - } - - // init first - public void init(String handlerPackageName) throws IOException { - - Properties pro = null; - - pro = PropertiesHelper - .loadPropertyFile(ConfigurationManager.getInstance().getContext(IConfigurationManager.CONFIGPATH) - + "msgtype2topic.properties"); - - Map map = getConfigOfMsgType2topicData(pro); - String nameServer = ConfigurationManager.getInstance().getFeatureConfiguration(this.feature, - "messagingnameserver"); - String[] consumerHandlerClasses = StringHelper.isEmpty(handlerPackageName) ? new String[] {} - : PackageHelper.getHandlerName(handlerPackageName); - - long msgThreshold = DataConvertHelper.toLong( - ConfigurationManager.getInstance().getResourceConfiguration("messageproducer", "messagingthreshold"), - MessagingContext.DEFAULT_MESSAGE_THRESHOLD); - - long msgSizeLimit = DataConvertHelper.toLong( - ConfigurationManager.getInstance().getResourceConfiguration("messageproducer", "messagesizelimit"), - MessagingContext.DEFAULT_MSG_SIZE_LIMIT); - - this.log.info(this, "The message threshold is " + msgThreshold + " kb"); - - MessagingContext.init(nameServer, map, consumerHandlerClasses, msgThreshold, msgSizeLimit); - } - - public void init() throws IOException { - - init(null); - } - - /** - * build producer - */ - public MessageProducer buildProducer() { - - return MessagingFactory - .getMessageProducer(ConfigurationManager.getInstance().getContext(IConfigurationManager.NODEUUID)); - } - - /** - * build comsumer by msgtype - */ - public MessageConsumer buildConsumer(String msgType, MQFactory.QueueType queueType) { - - String ConsumeThreadMax = ConfigurationManager.getInstance().getFeatureConfiguration(feature, - msgType + ".consumethreadmax"); - String ConsumeStopInterval = ConfigurationManager.getInstance().getFeatureConfiguration(feature, - msgType + ".consumestopinterval"); - - boolean check = DataConvertHelper.toBoolean( - ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".enable"), true); - - if (check == false) { - return null; - } - - String[] bizIDs = new String[1]; - bizIDs[0] = msgType; - MessageConsumer consumer = MessagingFactory.createMessageConsumer(msgType, bizIDs, - ConsumeThreadMax == null ? 10 : Integer.parseInt(ConsumeThreadMax), - ConsumeStopInterval == null ? 0 : Long.parseLong(ConsumeStopInterval), queueType); - - return consumer; - } - - public MessageConsumer buildConsumer(String msgType) { - - return buildConsumer(msgType, MQFactory.QueueType.QUEUE); - } - - /** - * read MsgType2topicData from properties to Map - * - * @param pro - * @return - */ - private Map getConfigOfMsgType2topicData(Properties pro) { - - Iterator> it = pro.entrySet().iterator(); - Map type2topic = new HashMap(); - while (it.hasNext()) { - Entry entry = it.next(); - String topicName = entry.getValue().toString(); - String msgType = entry.getKey().toString(); - - type2topic.put(msgType, topicName); - } - return type2topic; - } - -} diff --git a/org.uavstack.resources.common/src/main/java/org/uavstack/resources/common/messaging/StandardMessagingBuilder.java b/org.uavstack.resources.common/src/main/java/org/uavstack/resources/common/messaging/StandardMessagingBuilder.java index 975fcc9e..410c6a4a 100644 --- a/org.uavstack.resources.common/src/main/java/org/uavstack/resources/common/messaging/StandardMessagingBuilder.java +++ b/org.uavstack.resources.common/src/main/java/org/uavstack/resources/common/messaging/StandardMessagingBuilder.java @@ -43,6 +43,7 @@ public class StandardMessagingBuilder extends AbstractComponent { public StandardMessagingBuilder(String cName, String feature) { + super(cName, feature); } @@ -103,6 +104,8 @@ public MessageConsumer buildConsumer(String groupName, String msgType, MQFactory String ConsumeThreadMax = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumethreadmax"); + String ConsumeThreadInit = ConfigurationManager.getInstance().getFeatureConfiguration(feature, + msgType + ".consumethreadinit"); String ConsumeStopInterval = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumestopinterval"); @@ -117,6 +120,7 @@ public MessageConsumer buildConsumer(String groupName, String msgType, MQFactory bizIDs[0] = msgType; MessageConsumer consumer = MessagingFactory.createMessageConsumer(groupName, bizIDs, ConsumeThreadMax == null ? 10 : Integer.parseInt(ConsumeThreadMax), + ConsumeThreadInit == null ? 10 : Integer.parseInt(ConsumeThreadInit), ConsumeStopInterval == null ? 0 : Long.parseLong(ConsumeStopInterval), queueType); return consumer; From faab5303d9610bb006afde29a2afc43e90b675ec Mon Sep 17 00:00:00 2001 From: chongli8 Date: Fri, 1 Jun 2018 12:49:04 +0800 Subject: [PATCH 95/97] =?UTF-8?q?=E4=B8=BA=E6=9C=80=E5=A4=A7=E5=80=BC?= =?UTF-8?q?=E5=B0=8F=E4=BA=8E10=E7=9A=84=E9=85=8D=E7=BD=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=88=9D=E5=A7=8B=E5=8C=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/agent.properties | 1 + .../config/hm_pro_apmserver.properties | 1 + .../config/hm_test_apmserver.properties | 1 + 3 files changed, 3 insertions(+) diff --git a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties index dbb2d7c8..15f2b836 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/agent.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/agent.properties @@ -368,6 +368,7 @@ feature.collectserver.JQ_SLW.consumestopinterval=0 feature.collectserver.JQ_SLW.enable=true feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumethreadinit=1 feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties index 66cf7507..c33932ea 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_pro_apmserver.properties @@ -88,6 +88,7 @@ feature.collectserver.JQ_SLW.consumestopinterval=0 feature.collectserver.JQ_SLW.enable=true feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumethreadinit=1 feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true diff --git a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties index d88227d9..ea7b1059 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties +++ b/com.creditease.uav.healthmanager.buildComponent/config/hm_test_apmserver.properties @@ -91,6 +91,7 @@ feature.collectserver.JQ_SLW.consumestopinterval=0 feature.collectserver.JQ_SLW.enable=true feature.collectserver.JQ_JTA.consumethreadmax=5 +feature.collectserver.JQ_JTA.consumethreadinit=1 feature.collectserver.JQ_JTA.consumestopinterval=0 feature.collectserver.JQ_JTA.enable=true From 259f012d7195b70240d738c45472b1a42ed5643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 1 Jun 2018 13:07:34 +0800 Subject: [PATCH 96/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/296=20=E9=97=AE=E9=A2=98=EF=BC=9A=E5=BA=94=E7=94=A8=E4=B8=AD?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E4=BD=BF=E7=94=A8logback=E5=92=8Clog4j?= =?UTF-8?q?=E7=AD=89=E6=97=B6=EF=BC=8C=E5=9B=A0org.slf4j.LoggerFactory.get?= =?UTF-8?q?Logger()=E5=8F=AF=E8=83=BD=E8=8E=B7=E5=8F=96=E5=88=B0=E9=9D=9El?= =?UTF-8?q?ogback=E7=9A=84logger=EF=BC=8C=E8=BD=AC=E6=8D=A2=E4=B8=BAch.qos?= =?UTF-8?q?.logback.classic.Logger=E6=97=B6=E5=BC=82=E5=B8=B8=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9A=E5=AF=B9=E8=8E=B7=E5=8F=96=E7=9A=84logger?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E6=98=AFch.qos.logback.classic.Logger=E6=89=8D=E5=81=9A?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=EF=BC=8C=E5=90=A6=E5=88=99=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/creditease/uav/log/hook/LogBackHookProxy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java b/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java index a359f12e..7b9184e9 100644 --- a/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java +++ b/com.creditease.uav.loghook/src/main/java/com/creditease/uav/log/hook/LogBackHookProxy.java @@ -103,7 +103,13 @@ public void stop(HookContext context, ClassLoader webapploader) { */ private void figureOutLogBackConfig(HookContext context, ClassLoader webapploader) { - Logger logback = (Logger) LoggerFactory.getLogger(LogBackHookProxy.class); + org.slf4j.Logger slflogger = LoggerFactory.getLogger(LogBackHookProxy.class); + + if (!(slflogger instanceof Logger)) { + return; + } + + Logger logback = (Logger) slflogger; InterceptContext interceptContext = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); From cd23fa4ed610c2f9a50277b55edfbc7460b42116 Mon Sep 17 00:00:00 2001 From: Zhuang Date: Fri, 1 Jun 2018 15:00:56 +0800 Subject: [PATCH 97/97] fixed issue #298 --- .../creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java index 662ea72e..f9b937be 100644 --- a/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java +++ b/com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook/rabbitmq/interceptors/RabbitmqIT.java @@ -119,7 +119,7 @@ public void preProcess(Channel t, Object proxy, Method method, Object[] args) { && method.getExceptionTypes()[0].getName().equals(IOException.class.getName())) { String methodName = method.getName(); String queueName = null; - if (queueNameIndex.containsKey(methodName) && args.length != 0) { + if (queueNameIndex.containsKey(methodName) && (args != null && args.length != 0)) { queueName = (String) args[queueNameIndex.get(methodName)]; if (isTempQueue(queueName)) { @@ -201,7 +201,7 @@ private boolean needDoCap(Method method, Object[] args) { return false; } String methodName = method.getName(); - if (queueNameIndex.containsKey(methodName) && args.length != 0) { + if (queueNameIndex.containsKey(methodName) && (args != null && args.length != 0)) { if (isTempQueue((String) args[queueNameIndex.get(methodName)])) { return false;
  • 组ID:>授权组:
    关键字:
    授权APP: diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java index f5e9b1f9..4297d96d 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java @@ -395,7 +395,7 @@ private List findAction(Map queryObj, MongoCollection collection) Document sorts = new Document(); Document filterBson = new Document(); - filterBson.append("_id", 0); + // filterBson.append("_id", 0); //代码含义:查询返回结果中,不包含mongodb的_id字段 if (!StringHelper.isEmpty(fileds)) { String[] filters = fileds.split(";"); @@ -459,6 +459,13 @@ private List queryResultFormat(MongoCursor cursor, boolean checkC Document doc = cursor.next(); Map docInfo = new LinkedHashMap(); for (String key : doc.keySet()) { + if ("_id".equals(key)) { + /** + * _id 是mongodb的对象,只获取_id的ObjectId String值(返回数据) + */ + docInfo.put("_id", doc.getObjectId("_id").toString()); + continue; + } docInfo.put(key, doc.get(key)); } results.add(docInfo); diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java index d31deaa9..f9d686ed 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/OpentsdbDataStore.java @@ -382,7 +382,12 @@ protected List query(DataStoreMsg msg, byte[] datab, String queryJson) { this.datasource.getSourceConnect().doAsyncHttpPost(queryURL, datab, "application/json", "utf-8", queryCallBack); try { - cdl.await(10, TimeUnit.SECONDS); + /** + * 因为是异步http(http 有超时设置),因此等待http处理完。 + * + * 由callback里CountDownLatch.countDown()来结束等待 + */ + cdl.await(); } catch (InterruptedException e) { log.err(this, "DataStore QUERY InterruptedException.", e); diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/mongo/MongodbImplStrategy.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/mongo/MongodbImplStrategy.java index a1f21b9b..961f77ff 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/mongo/MongodbImplStrategy.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/mongo/MongodbImplStrategy.java @@ -26,6 +26,8 @@ import java.util.Map; import java.util.Set; +import org.bson.types.ObjectId; + import com.creditease.agent.log.SystemLogger; import com.creditease.agent.log.api.ISystemLogger; import com.mongodb.BasicDBObject; @@ -59,7 +61,14 @@ public void concretProcessor(Object expKey, Map expValue, BasicDBObject set) { while (iter.hasNext()) { String key = (String) iter.next(); Object value = expressions.get(key); - + + if ("_id".equals(key)) { + /** + * 使用api 按id查询格式必须是: _id:string + */ + value = new ObjectId(value.toString()); + } + if (value instanceof Map) { RGLStrategy rgl = new RGLStrategy(); rgl.concretProcessor(key, expressions, set); diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/source/OpentsdbDataSource.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/source/OpentsdbDataSource.java index 42e74f7d..3975b4dd 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/source/OpentsdbDataSource.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/source/OpentsdbDataSource.java @@ -33,32 +33,32 @@ */ public class OpentsdbDataSource extends AbstractDataSource { - private static int maxConnectionPerRoute; + private int maxConnectionPerRoute; - private static int maxTotalConnection; + private int maxTotalConnection; - private static int sockTimeout; + private int sockTimeout; - private static int connectTimeout; + private int connectTimeout; - private static int requestTimeout; + private int requestTimeout; public OpentsdbDataSource(DataStoreConnection connection) { super(connection); - maxConnectionPerRoute = DataConvertHelper + this.maxConnectionPerRoute = DataConvertHelper .toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE), 10); - maxTotalConnection = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE), + this.maxTotalConnection = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE), 50); - sockTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT), 5000); + this.sockTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT), 5000); - connectTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT), + this.connectTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT), 5000); - requestTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT), + this.requestTimeout = DataConvertHelper.toInt(connection.getContext(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT), 5000); } From bde5a9f5816c9a26fa4b2d1066e25106266dd9f4 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Tue, 8 May 2018 18:49:13 +0800 Subject: [PATCH 73/97] https://github.com/uavorg/uavstack/issues/267 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ldap 机制更换 添加超时限制,查询时超时无效,修改为属性配置 --- .../java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java index 7136bac3..3b9d563f 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java @@ -92,6 +92,7 @@ private void initLdapParams(String action) { param.put(Context.SECURITY_AUTHENTICATION, "simple"); param.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); param.put("com.sun.jndi.ldap.connect.timeout", ldapConTimeout); + param.put("com.sun.jndi.ldap.read.timeout", ldapConTimeout); /** * ldap以下字段转码需要特殊处理:不显示乱码,但也不会显示为可识别的string,以binary string显示 @@ -203,8 +204,6 @@ private List ldapApiQuery(String action, String name, String filte SearchControls constraints = new SearchControls(); constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); - String ldapConTimeout = ldapConfig.get("contimeout"); - constraints.setTimeLimit(Integer.valueOf(ldapConTimeout)); NamingEnumeration en = ldapCtx.search(name, filter, constraints); // means all nodes From 1c0f69e30b2afdee3e2405a9c0b6a5c2ac307ec3 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Tue, 8 May 2018 19:47:23 +0800 Subject: [PATCH 74/97] https://github.com/uavorg/uavstack/issues/267 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ldap 超时用户体验增强 --- .../config/web_pro.xml | 2 +- .../config/web_test.xml | 2 +- .../uav/apphub/sso/GUISSOLdapClient.java | 22 +++++++++---------- .../src/main/webapp/WEB-INF/web.xml | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/com.creditease.uav.console.buildComponent/config/web_pro.xml b/com.creditease.uav.console.buildComponent/config/web_pro.xml index 0a5a62b0..de80af5a 100644 --- a/com.creditease.uav.console.buildComponent/config/web_pro.xml +++ b/com.creditease.uav.console.buildComponent/config/web_pro.xml @@ -227,7 +227,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","timeout":"1000","retry":"5","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} uav.apphub.sso.grafana.connection.info diff --git a/com.creditease.uav.console.buildComponent/config/web_test.xml b/com.creditease.uav.console.buildComponent/config/web_test.xml index 4dd2a1a7..4238f9e4 100644 --- a/com.creditease.uav.console.buildComponent/config/web_test.xml +++ b/com.creditease.uav.console.buildComponent/config/web_test.xml @@ -232,7 +232,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","timeout":"1000","retry":"5","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} uav.apphub.sso.grafana.connection.info diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java index 3b9d563f..15a4f04b 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java @@ -85,14 +85,14 @@ private void initLdapParams(String action) { String ldapConUrl = ldapConfig.get("url"); String ldapConUser = ldapConfig.get("user"); String ldapConPassWord = ldapConfig.get("password"); - String ldapConTimeout = ldapConfig.get("contimeout"); + String ldapTimeout = ldapConfig.get("timeout"); param.put(Context.PROVIDER_URL, ldapConUrl + ldapConBasedn); param.put(Context.SECURITY_PRINCIPAL, ldapConUser); param.put(Context.SECURITY_CREDENTIALS, ldapConPassWord); param.put(Context.SECURITY_AUTHENTICATION, "simple"); param.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); - param.put("com.sun.jndi.ldap.connect.timeout", ldapConTimeout); - param.put("com.sun.jndi.ldap.read.timeout", ldapConTimeout); + param.put("com.sun.jndi.ldap.connect.timeout", ldapTimeout); + param.put("com.sun.jndi.ldap.read.timeout", ldapTimeout); /** * ldap以下字段转码需要特殊处理:不显示乱码,但也不会显示为可识别的string,以binary string显示 @@ -193,8 +193,9 @@ private boolean ldapApiCheck(String loginId, String password) { } - private List ldapApiQuery(String action, String name, String filter) { + private List ldapApiQuery(String name, String filter) { + String action = "query"; String logMsg = action + " " + filter; List result = new ArrayList(); try { @@ -254,10 +255,9 @@ protected Map getUserByLoginImpl(String loginId, String password return Collections.emptyMap(); } - String action = "login"; String filter = primaryKey + "=" + loginId; - List sResultList = ldapApiQuery(action, "", filter); + List sResultList = ldapApiQuery("", filter); // filter userPrincipalName= 只能查询到一个结果 SearchResult sResult = sResultList.get(0); @@ -289,13 +289,12 @@ public List> getUserByQuery(String email) { String filter = "(|(" + userCNField + "=" + email + ")(" + userQueryField + "=" + email + ")(" + userQueryField + "=" + email1 + "))"; - - String action = "query"; + /** * 查询ldap 获取list信息 */ List> result = new ArrayList>(); - List sResultList = ldapApiQuery(action, "", filter); + List sResultList = ldapApiQuery("", filter); if (sResultList.isEmpty()) { Map msg = new HashMap(); msg.put("msg", "email query,result is empty."); @@ -330,7 +329,6 @@ public List> getUserByQuery(String email) { public Map getEmailListByQuery(String email) { Map result = new LinkedHashMap(); - String action = "query"; String filter = ""; String suffix = ldapConfig.get("suffix"); try { @@ -343,7 +341,7 @@ public Map getEmailListByQuery(String email) { filter = "(|(" + groupCNField + "=" + email + ")(" + groupQueryField + "=" + email + ")(" + groupQueryField + "=" + email1 + "))"; - List sResultList = ldapApiQuery(action, "", filter); + List sResultList = ldapApiQuery("", filter); // filter 只能查询到一个结果 SearchResult sResult = sResultList.get(0); if (null == sResult) { @@ -369,7 +367,7 @@ public Map getEmailListByQuery(String email) { } catch (Exception e) { - clearLdapContext(action); + clearLdapContext("query"); logger.err(this, e.getMessage(), e); } return result; diff --git a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml index 3960d430..2e6af654 100644 --- a/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml +++ b/com.creditease.uav.console/src/main/webapp/WEB-INF/web.xml @@ -241,7 +241,7 @@ uav.apphub.sso.ldap.connection.info - {"url":"ldap://127.0.0.1:389/","contimeout":"1000","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} + {"url":"ldap://127.0.0.1:389/","timeout":"1000","retry":"5","loginbasedn":"","querybasedn":"","user":"","password":"","suffix":"","primaryKey":"userPrincipalName","groupKey":"memberOf","groupTag":"邮件通讯组List","memberKey":"member","groupQueryField":"mail","userQueryField":"mail"} From fca44a5fe9a313f57734abf20b97d1609aa81a50 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Wed, 9 May 2018 14:40:45 +0800 Subject: [PATCH 75/97] https://github.com/uavorg/uavstack/issues/265 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit apphub init 权限redis操作不正确修改 https://github.com/uavorg/uavstack/issues/266 datastore 添加对mongodb “_id”操作字段的api支持,查询返回为空判断 --- .../java/com/creditease/uav/apphub/rest/GUIService.java | 7 ++++--- .../creditease/uav/datastore/core/MongoDBDataStore.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java index b7f81049..f60efc97 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/rest/GUIService.java @@ -719,10 +719,11 @@ public void completed(HttpClientCallbackResult result) { Map respMap = JSONHelper.toObject(respStr, Map.class); List> respList = (List>) respMap.get("data"); for (Map map : respList) { - String key = map.get("groupid"); + String groupid = map.get("groupid"); String value = map.get("appids"); - - key = "groupId:" + key + ",ldappKey:"; + String ldapkey = map.get("ldapkey") == null ? "" : map.get("ldapkey"); + + String key = "groupId:" + groupid + ",ldappKey:" + ldapkey; groupCache.put(key, value); } cm.putHash("apphub.gui.cache", "manage.group", groupCache); diff --git a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java index 4297d96d..68a7ec44 100644 --- a/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java +++ b/com.creditease.uav.dbaccess/src/main/java/com/creditease/uav/datastore/core/MongoDBDataStore.java @@ -459,7 +459,7 @@ private List queryResultFormat(MongoCursor cursor, boolean checkC Document doc = cursor.next(); Map docInfo = new LinkedHashMap(); for (String key : doc.keySet()) { - if ("_id".equals(key)) { + if ("_id".equals(key) && doc.getObjectId("_id") != null) { /** * _id 是mongodb的对象,只获取_id的ObjectId String值(返回数据) */ From f468cc6968d5fc54c8d1db663f865b348a57127e Mon Sep 17 00:00:00 2001 From: Zhuang Date: Thu, 10 May 2018 13:55:22 +0800 Subject: [PATCH 76/97] fixed issue 271 --- .../uav/apm/RewriteIvcRequestWrapper.java | 91 ++++++++++++++----- .../jee/JEEServiceRunGlobalFilterHandler.java | 17 ++-- .../slowoper/adapter/ServerSpanAdapter.java | 50 ++++++---- .../handlers/HttpServerSlowOperHandler.java | 40 ++++---- 4 files changed, 129 insertions(+), 69 deletions(-) diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/RewriteIvcRequestWrapper.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/RewriteIvcRequestWrapper.java index 97091557..97570a6b 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/RewriteIvcRequestWrapper.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/RewriteIvcRequestWrapper.java @@ -23,6 +23,9 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; @@ -30,38 +33,49 @@ public class RewriteIvcRequestWrapper extends HttpServletRequestWrapper { - private String tag; + private HttpServletRequest request; + private Map parameterMap; - private ServletInputStream inputStream; + private String tag; private RewriteIvcInputStream rewriteInputStream; private StringBuilder builder; public RewriteIvcRequestWrapper(HttpServletRequest request, String tag) { + super(request); + this.request = request; this.tag = tag; + } - try { - this.inputStream = request.getInputStream(); - } - catch (IOException e) { - this.builder = new StringBuilder(e.toString()); - } - rewriteInputStream = new RewriteIvcInputStream(this.inputStream, request.getCharacterEncoding()); + @Override + public String getParameter(String name) { + + initAllParameters(); + + return request.getParameter(name); + } + + @Override + public Map getParameterMap() { + + initAllParameters(); + + return request.getParameterMap(); } @Override public ServletInputStream getInputStream() throws IOException { - return this.rewriteInputStream; + return wrapServletInputStream(); } @Override public BufferedReader getReader() throws IOException { - return new BufferedReader(new InputStreamReader(rewriteInputStream)); + return new BufferedReader(new InputStreamReader(wrapServletInputStream())); } public String getTag() { @@ -69,28 +83,61 @@ public String getTag() { return tag; } + public Map getAllParameters() { + + if (parameterMap == null) { + return Collections.emptyMap(); + } + return parameterMap; + } + + private void initAllParameters() { + + if (parameterMap == null) { + Map map = request.getParameterMap(); + parameterMap = new HashMap(map); + } + } + + private ServletInputStream wrapServletInputStream() throws IOException { + + if (rewriteInputStream == null) { + try { + ServletInputStream inputStream = request.getInputStream(); + rewriteInputStream = new RewriteIvcInputStream(inputStream, request.getCharacterEncoding()); + } + catch (IOException e) { + builder = new StringBuilder(e.toString()); + throw e; + } + } + + return rewriteInputStream; + } + public StringBuilder getContent() { - if (this.builder == null) { - return this.rewriteInputStream.getContent(); + if (builder != null) { + return builder; } - else { - return this.builder; + + if (rewriteInputStream == null) { + return new StringBuilder(); } + + return rewriteInputStream.getContent(); } /** - * 清空池,方便回收 + * 清空池,方便回收, 虽然可能并没有什么卵用 */ public void clearBodyContent() { - StringBuilder bodyContent; - if (this.builder == null) { - bodyContent = this.rewriteInputStream.getContent(); - } - else { - bodyContent = this.builder; + if (builder != null || rewriteInputStream == null) { + return; } + + StringBuilder bodyContent = rewriteInputStream.getContent(); bodyContent.delete(0, bodyContent.length()); } diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java index 364896ca..a0f73bf4 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/jee/JEEServiceRunGlobalFilterHandler.java @@ -47,6 +47,7 @@ public class JEEServiceRunGlobalFilterHandler extends AbsJEEGlobalFilterHandler { public JEEServiceRunGlobalFilterHandler(String id) { + super(id); } @@ -91,18 +92,12 @@ protected void doRequest(HttpServletRequest request, HttpServletResponse respons // 重调用链开启时添加warpper if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) { - RewriteIvcResponseWrapper responseWrapper = new RewriteIvcResponseWrapper(response, "IVC_DAT"); - - context.put(InterceptConstants.HTTPRESPONSE, responseWrapper); - - // 由于application/x-www-form-urlencoded - // 形式传参时获取inputsteam会删除parameters,故在添加wrapper时先通过调用getParameterMap方法lock(tomcat源码进行)parameters - request.getParameterMap(); - RewriteIvcRequestWrapper requestWrapper = new RewriteIvcRequestWrapper(request, "IVC_DAT"); - context.put(InterceptConstants.HTTPREQUEST, requestWrapper); + RewriteIvcResponseWrapper responseWrapper = new RewriteIvcResponseWrapper(response, "IVC_DAT"); + context.put(InterceptConstants.HTTPRESPONSE, responseWrapper); + args = new Object[] { requestWrapper, responseWrapper }; } else { @@ -178,8 +173,8 @@ private int getRespRetStatus(HttpServletResponse response) { Object resp = ReflectionHelper.getField(response.getClass(), response, "response"); if (resp != null) { - Object result = ReflectionHelper.invoke("org.apache.catalina.connector.Response", resp, "getStatus", null, - null, response.getClass().getClassLoader()); + Object result = ReflectionHelper.invoke("org.apache.catalina.connector.Response", resp, "getStatus", + null, null, response.getClass().getClassLoader()); return (Integer) result; } diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/adapter/ServerSpanAdapter.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/adapter/ServerSpanAdapter.java index 91698d93..45f84c02 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/adapter/ServerSpanAdapter.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/adapter/ServerSpanAdapter.java @@ -20,6 +20,7 @@ package com.creditease.uav.apm.slowoper.adapter; +import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -54,27 +55,10 @@ public void afterPreCap(InvokeChainContext context, Object[] args) { String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL); Span span = this.spanFactory.getSpanFromContext(url); - SlowOperContext slowOperContext = new SlowOperContext(); - - HttpServletRequest request = (HttpServletRequest) args[0]; - // 由于会存在没有拦截住的情况,但当前无论拦截与未拦截的情况均可以使用HttpServletRequest获取header,故此处预留出来 - // if (RewriteIvcRequestWrapper.class.isAssignableFrom(args[0].getClass())) { - // } - // else { - // - // } - // 当前将所有header信息打印出来,后续可能只打印用户自定义的将UAV的header过滤 - // 提取参数并放入header里 - String parameters = JSONHelper.toString(request.getParameterMap()); - if (parameters == null) { - parameters = "{}"; - } - slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER, getRequestHeaders(request) + parameters); Object params[] = { span, slowOperContext }; UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params); - } } @@ -101,6 +85,10 @@ public void afterDoCap(InvokeChainContext context, Object[] args) { if (RewriteIvcRequestWrapper.class.isAssignableFrom(args[0].getClass()) && RewriteIvcResponseWrapper.class.isAssignableFrom(args[1].getClass())) { RewriteIvcRequestWrapper request = (RewriteIvcRequestWrapper) args[0]; + // 在最后取parameter,放入Header末尾 + slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER, + getRequestHeaders(request) + generateParameterString(request.getAllParameters())); + slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY, request.getContent().toString()); request.clearBodyContent(); @@ -110,6 +98,8 @@ public void afterDoCap(InvokeChainContext context, Object[] args) { response.clearBodyContent(); } else { + HttpServletRequest request = (HttpServletRequest) args[0]; + slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER, getRequestHeaders(request)); slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY, "unsupported request"); HttpServletResponse response = (HttpServletResponse) args[1]; slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_RSP_HEADER, getResponHeaders(response)); @@ -154,4 +144,30 @@ private String getResponHeaders(HttpServletResponse response) { return JSONHelper.toString(result); } + /** + * 将request的parameterMap,转成非数组的Map,有数据的情况将数组转String + * 因为,大部分业务场景都需要重复的value传值,request.getParameter也只取了value[0]。这样做方便后面的数据处理 + * + * @param parameterMap + * @return + */ + private String generateParameterString(Map parameterMap) { + + if (parameterMap.isEmpty()) { + return "{}"; + } + + Map map = new HashMap(); + for (Map.Entry en : parameterMap.entrySet()) { + String[] v = en.getValue(); + if (v.length == 1) { + map.put(en.getKey(), v[0]); + } + else if (v.length > 1) { + map.put(en.getKey(), Arrays.toString(v)); + } + } + + return JSONHelper.toString(map); + } } diff --git a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/HttpServerSlowOperHandler.java b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/HttpServerSlowOperHandler.java index 022060d5..974c8926 100644 --- a/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/HttpServerSlowOperHandler.java +++ b/com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/slowoper/handlers/HttpServerSlowOperHandler.java @@ -32,29 +32,31 @@ */ public class HttpServerSlowOperHandler extends AbstractSlowOperHandler { + private final String lineSeparator = System.getProperty("line.separator", "/n"); + private final int headerLength = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.rpc.header"), + 2000); + private final int bodyLength = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.rpc.body"), + 2000); + @Override public void buildSpanContent(SlowOperContext slowOperContext, SlowOperSpan slowOperSpan) { - if (slowOperContext.containsKey(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER)) { - String reqHeader = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER); - // 限定采集的协议体的大小 - int length = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.rpc.header"), 2000); - slowOperSpan.appendContent(reqHeader, length, true); - } - else { - String reqBody = ((String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY)) - .replace(System.getProperty("line.separator", "/n"), "").trim(); - String rspHeader = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_RSP_HEADER); - String rspBody = ((String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_RSP_BODY)) - .replace(System.getProperty("line.separator", "/n"), "").trim(); - // 限定采集的协议体的大小 - int headerLength = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.rpc.header"), - 2000); - int bodyLength = DataConvertHelper.toInt(System.getProperty("com.creditease.uav.ivcdat.rpc.body"), 2000); - slowOperSpan.appendContent(reqBody, bodyLength, true); - slowOperSpan.appendContent(rspHeader, headerLength, true); - slowOperSpan.appendContent(rspBody, bodyLength, true); + if (!slowOperContext.containsKey(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER)) { + return; } + + String reqHeader = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER); + String reqBody = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY); + reqBody = reqBody.replace(lineSeparator, "").trim(); + + String respHeader = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_RSP_HEADER); + String respBody = (String) slowOperContext.get(SlowOperConstants.PROTOCOL_HTTP_RSP_BODY); + respBody = respBody.replace(lineSeparator, "").trim(); + + slowOperSpan.appendContent(reqHeader, headerLength, true); + slowOperSpan.appendContent(reqBody, bodyLength, true); + slowOperSpan.appendContent(respHeader, headerLength, true); + slowOperSpan.appendContent(respBody, bodyLength, true); } } From 728dc4994e44245b859c93d094be47cf19c72439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 11 May 2018 14:08:05 +0800 Subject: [PATCH 77/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/273=20spring-data-redis=E5=9F=BA=E4=BA=8Ejedis=E5=B0=81?= =?UTF-8?q?=E8=A3=85=EF=BC=8Chook=20jedis=E6=97=B6=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E9=93=BE=E6=9F=A5=E6=89=BE=E6=89=80=E5=9C=A8=E7=B1=BB=E5=92=8C?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=89=80=E7=94=A8=E5=9F=BA=E5=87=86=E7=B1=BB?= =?UTF-8?q?=E5=9C=A8spring-data-redis=E4=B8=AD=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E8=B0=83=E7=94=A8=E9=93=BE=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=89=80=E5=9C=A8=E7=B1=BB=E5=92=8C=E6=96=B9=E6=B3=95?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=EF=BC=9A=E8=B0=83=E6=95=B4=E5=9F=BA?= =?UTF-8?q?=E5=87=86=E7=B1=BB=EF=BC=8C=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=AF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=89=80=E5=9C=A8=E7=B1=BB=E5=92=8C=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E4=BD=86=E4=BD=BF=E7=94=A8spring-data-redis?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=AA=E8=83=BD=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E5=88=B0org.springframework.*=E7=B1=BB=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=AE=9A=E4=BD=8D=E5=88=B0=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BD=BF=E7=94=A8jedis=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E7=9A=84=E4=B8=8D=E5=8F=97=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/uav.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties index e0561558..ab89a96f 100644 --- a/com.creditease.uav.monitorframework.buildComponent/config/uav.properties +++ b/com.creditease.uav.monitorframework.buildComponent/config/uav.properties @@ -70,7 +70,7 @@ com.creditease.uav.invokechain.code.mongo.class=com.mongodb.* com.creditease.uav.invokechain.code.mq.rabbitmq.key=2 com.creditease.uav.invokechain.code.mq.rabbitmq.class=com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler com.creditease.uav.invokechain.code.redis.jedis.key=1 -com.creditease.uav.invokechain.code.redis.jedis.class=redis.clients.jedis.Jedis +com.creditease.uav.invokechain.code.redis.jedis.class=redis.clients.jedis.* com.creditease.uav.invokechain.code.redis.lettuce.key.1=3 com.creditease.uav.invokechain.code.redis.lettuce.class.1=com.lambdaworks.redis.FutureSyncInvocationHandler com.creditease.uav.invokechain.code.redis.lettuce.key.2=1 From 30bc7e42a22d871d3ecdce9ece136068d33ef169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Fri, 11 May 2018 14:08:48 +0800 Subject: [PATCH 78/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/274=20=E5=8E=9F=E9=A2=84=E8=AD=A6=E6=94=B6=E6=95=9B=E4=BB=A5cu?= =?UTF-8?q?rtime-viewtime=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E8=B6=85?= =?UTF-8?q?=E8=BF=874=E5=B0=8F=E6=97=B6=EF=BC=8C=E5=BD=93=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8vimetime=EF=BC=88=E5=8D=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=AA=E6=B5=8F=E8=A7=88=E8=AF=A5=E9=A2=84=E8=AD=A6=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=EF=BC=89=E6=97=B6=EF=BC=8C=E5=B0=86=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=9F=A5=E8=BF=874?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=20=E4=BF=AE=E6=94=B9=EF=BC=9A=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8viewtime=E6=97=B6=E4=BB=A5curtime-firstrecord?= =?UTF-8?q?Time=EF=BC=88=E9=A6=96=E6=AC=A1=E9=A2=84=E8=AD=A6=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=89=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/feature/notifycenter/NCConstant.java | 1 + .../feature/notifycenter/actions/CEMailAction.java | 10 +++++----- .../notifycenter/handlers/NCJudgementHandler.java | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/NCConstant.java b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/NCConstant.java index 1dbdd540..9c44d1b5 100644 --- a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/NCConstant.java +++ b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/NCConstant.java @@ -72,6 +72,7 @@ public int getStatFlag() { public static final String COLUMN_LATESTIME = "latest_ts"; public static final String COLUMN_VIEWTIME = "view_ts"; public static final String COLUMN_LATESTRECORDTIME = "latestrecord_ts"; + public static final String COLUMN_FIRSTRECORDTIME = "firstrecord_ts"; public static final String COLUMN_RETRY_COUNT = "retry"; public static final String COLUMN_PRIORITY = "priority";// default is 0 diff --git a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/actions/CEMailAction.java b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/actions/CEMailAction.java index efaefd78..387cc5a8 100644 --- a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/actions/CEMailAction.java +++ b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/actions/CEMailAction.java @@ -72,12 +72,12 @@ public class CEMailAction extends AbstractMailAction { public CEMailAction(String cName, String feature, IActionEngine engine) { super(cName, feature, engine); - userName = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.username"); - password = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.password"); - brokerURL = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.brokerurl"); + userName = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.cemail.username"); + password = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.cemail.password"); + brokerURL = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.cemail.brokerurl"); - activeID = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.activeid"); - systemSign = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.systemsign"); + activeID = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.cemail.activeid"); + systemSign = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.cemail.systemsign"); } /** diff --git a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java index 814cc62f..4cd53dd3 100644 --- a/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java +++ b/com.creditease.uav.notifycenter/src/main/java/com/creditease/agent/feature/notifycenter/handlers/NCJudgementHandler.java @@ -111,6 +111,7 @@ public void doAction(ActionContext context) throws Exception { long curTime = System.currentTimeMillis(); long viewTime = DataConvertHelper.toLong(stateData.get(NCConstant.COLUMN_VIEWTIME), -1); + long firstrecordTime = DataConvertHelper.toLong(stateData.get(NCConstant.COLUMN_FIRSTRECORDTIME), curTime); if (viewTime > -1) { @@ -135,6 +136,8 @@ public void doAction(ActionContext context) throws Exception { return; } + } else if (curTime - firstrecordTime > viewTTL){ + stateData = playAsFirstEventRecordConvergence(event, eventKey); } else { int count = increEventCount(stateData); stateData.put(NCConstant.EVENT_COUNT, count); @@ -199,6 +202,7 @@ private Map playAsFirstEventRecordConvergence(NotificationEvent statusSet.put(NCConstant.COLUMN_STATE, NCConstant.StateFlag.NEWCOME.getStatFlag()); statusSet.put(NCConstant.COLUMN_RETRY_COUNT, 0); statusSet.put(NCConstant.COLUMN_LATESTIME, System.currentTimeMillis()); + statusSet.put(NCConstant.COLUMN_FIRSTRECORDTIME, System.currentTimeMillis()); // First Time NTFE take priority as the "0" Priority. statusSet.put(NCConstant.COLUMN_PRIORITY, 0); @@ -553,6 +557,7 @@ private void playAsFirstEventRecord(NotificationEvent event, String eventKey) { statusSet.put(NCConstant.COLUMN_STATE, NCConstant.StateFlag.NEWCOME.getStatFlag()); statusSet.put(NCConstant.COLUMN_RETRY_COUNT, 1); statusSet.put(NCConstant.COLUMN_LATESTIME, System.currentTimeMillis()); + statusSet.put(NCConstant.COLUMN_FIRSTRECORDTIME, System.currentTimeMillis()); // NOTE: the latest record event time, then we can find out all records from first record startTime to this time statusSet.put(NCConstant.COLUMN_LATESTRECORDTIME, event.getTime()); From 2b30673a78161bf6d96ed0fe20592d0a613274b3 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Fri, 11 May 2018 14:52:47 +0800 Subject: [PATCH 79/97] https://github.com/uavorg/uavstack/issues/265 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apphub管理 授权管理 新建授权组:添加关键字功能 js代码添加 --- .../webapp/uavapp_manage/groupmanage/js/group.modfy.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js index f5995e54..708943fa 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_manage/groupmanage/js/group.modfy.js @@ -4,7 +4,9 @@ function showViewGroup(result){ $("#viewGroupDiv").modal({backdrop: 'static', keyboard: false}); initMody(); + $("#viewid").html(viewData._id); $("#viewGroupid").html(viewData.groupid); + $("#viewLdapKey").html(viewData.ldapkey); loadAllApps_RESTClient(function(result){showViewAppids(result);}); } @@ -69,8 +71,11 @@ function vmButtonSwitch(){ function saveModfy(){ - var id = $("#viewid").html(); + var id = $("#viewid").html(); var appids = $("#viewAppids").val(); + var groupId = $("#viewGroupid").html(); + var ldapKey = $("#viewLdapKey").html(); + if(thisCheck()){ updateGroup_RESTClient(id,groupId,ldapKey,getformatAppids(appids)); } From 6c5ca193b310aebaf874538a91e19cf7e3bbdd36 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Fri, 11 May 2018 15:23:54 +0800 Subject: [PATCH 80/97] https://github.com/uavorg/uavstack/issues/267 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ldap 机制更换:用户体验增强 --- .../uav/apphub/sso/GUISSOLdapClient.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java index 15a4f04b..4940783b 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/apphub/sso/GUISSOLdapClient.java @@ -257,17 +257,27 @@ protected Map getUserByLoginImpl(String loginId, String password String filter = primaryKey + "=" + loginId; - List sResultList = ldapApiQuery("", filter); - // filter userPrincipalName= 只能查询到一个结果 - SearchResult sResult = sResultList.get(0); + int retry = Integer.parseInt(ldapConfig.get("retry")); + List sResultList = new ArrayList(); + do { + sResultList = ldapApiQuery("", filter); + retry--; + } + while ((sResultList.isEmpty() && retry > 0)); + + Map result = new HashMap(); + if (!sResultList.isEmpty()) { - String groupIdStr = formatGroupId(sResult); - String emailListStr = formatEmailList(sResult); + // filter userPrincipalName= 只能查询到一个结果 + SearchResult sResult = sResultList.get(0); - Map result = new HashMap(); - result.put("loginId", loginId); - result.put("groupId", groupIdStr); - result.put("emailList", emailListStr); + String groupIdStr = formatGroupId(sResult); + String emailListStr = formatEmailList(sResult); + + result.put("loginId", loginId); + result.put("groupId", groupIdStr); + result.put("emailList", emailListStr); + } return result; } From b33dd02f0c1f5583e687577a083104d70d35669c Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 11 May 2018 15:40:35 +0800 Subject: [PATCH 81/97] https://github.com/uavorg/uavstack/issues/275 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.add copy function for notify strategy configuration https://github.com/uavorg/uavstack/issues/277 1.httpclienthook support AbstractHttpClient's deprecated doExecute method 2.fix pathparameter‘s inaccurate matching --- .../notifystgy/css/uav.notifystgy.css | 12 +++- .../notifystgy/js/notifystgy.edit.js | 2 +- .../notifystgy/js/notifystgy.win.js | 55 ++++++++++++++++--- .../httpclients/sync/HttpClientHookProxy.java | 11 +++- .../handlers/ComponentProfileHandler.java | 10 +++- .../profiling/spi/ProfileServiceMapMgr.java | 6 +- 6 files changed, 75 insertions(+), 21 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css index 045c7162..88785035 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/css/uav.notifystgy.css @@ -103,7 +103,7 @@ body { border-radius: 3px; box-shadow: 0 0 1px 1px #000000; } -.icon-myout,.icon-myhelp { +.icon-myout,.icon-myhelp,.icon-mycopy { float: right; margin-top: 5px; margin-right: 15px; @@ -126,6 +126,16 @@ body { box-shadow: 0 0 4px 4px #ffffff; } +.icon-mycopy{ + height: 31.4px; + width: 31.4px; + + } +.icon-mycopy:hover{ + border-radius: 3px; + box-shadow: 0 0 4px 4px #ffffff; +} + .titleDiv { font-size: 16px; color: #ffffff; diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.edit.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.edit.js index b4db82f3..11339db2 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.edit.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.edit.js @@ -3,5 +3,5 @@ function showEditDiv(id,obj){ } function showEditDivIsReadOnly(jsonObj){ - showEditNotifyDiv(jsonObj); + showEditNotifyDiv(jsonObj,false); } \ No newline at end of file diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 696f7f00..385c46e7 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -187,7 +187,7 @@ function showAddDiv() { /** * 显示编辑策略 */ -function showEditNotifyDiv(jsonObjParam) { +function showEditNotifyDiv(jsonObjParam,isCopy) { var key,jsonObj,isOwner=false;enableThreadAnalysis=false; //因为只有一对 key:value 获取key(值为id) @@ -196,6 +196,12 @@ function showEditNotifyDiv(jsonObjParam) { jsonObj = obj; }); + if(isCopy==true){ + jsonObj.owner=window.parent.loginUser.userId; + }else{ + actionConf.actionObj=jsonObjParam; + } + if(jsonObj.owner == window.parent.loginUser.userId || window.parent.loginUser.groupId == "uav_admin" || window.parent.loginUser.groupId == "vipgroup" @@ -208,7 +214,13 @@ function showEditNotifyDiv(jsonObjParam) { var sb=new StringBuffer(); sb.append( "
    "); sb.append( ""); - sb.append( "编辑策略"); + + if(isCopy){ + sb.append( "编辑复制策略"); + }else{ + sb.append( "编辑策略"); + } + sb.append( "
    "); sb.append( "
    "); sb.append( "
    "); @@ -250,8 +262,12 @@ function showEditNotifyDiv(jsonObjParam) { if(showNameF=="自定义指标"){ selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 }else if(names[1] == "log"){ - sb.append( '
    '); - selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + if(isCopy){ + sb.append( '
    '); + }else{ + sb.append( '
    '); + selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 + } }else if(names[1]){ sb.append( '
    '); selUiConf["userInput"]["notifyNameM"]=names[1];//编辑赋值,准备修改数据 @@ -262,14 +278,26 @@ function showEditNotifyDiv(jsonObjParam) { //3 if(names[2] && names[1] == "log"){ var nNameIShow = "指定日志:"+names[2]; - sb.append( '
    '); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + if(isCopy){ + sb.append( '
    '); + }else{ + sb.append( '
    '); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + } }else if(names[1] == "log"){ - sb.append( '
    '); + if(isCopy){ + sb.append( '
    '); + }else{ + sb.append( '
    '); + } }else if(names[2]){ var nNameIShow = (existsIns?"实例组:":"实例:")+names[2]; - sb.append( '
    '); - selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + if(isCopy){ + sb.append( '
    '); + }else{ + sb.append( '
    '); + selUiConf["userInput"]["notifyNameI"]=names[2];//编辑赋值,准备修改数据 + } }else{ sb.append( '
    '); } @@ -407,6 +435,11 @@ function showEditNotifyDiv(jsonObjParam) { if(isOwner){ //按钮 + if(isCopy){ + sb.append( '
    '); + }else{ + sb.append( '
    '); + } sb.append( '
    '); sb.append( '
    '); sb.append( '
     
    '); @@ -1380,6 +1413,10 @@ function openHelpDiv() { window.open("https://uavorg.github.io/documents/uavdoc_useroperation/28.html#%E5%88%9B%E5%BB%BA","apphub.help"); } +function copyNotifyStra(){ + + showEditNotifyDiv(actionConf.actionObj,true); +} /** * 策略表达式处理类 diff --git a/com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/sync/HttpClientHookProxy.java b/com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/sync/HttpClientHookProxy.java index cd64e32f..c3946347 100644 --- a/com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/sync/HttpClientHookProxy.java +++ b/com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/sync/HttpClientHookProxy.java @@ -98,14 +98,14 @@ public void doInstallDProxy(ClassLoader webapploader, final String appid) { dpInstall.setTargetClassLoader(webapploader); /** - * install proxy to AbstractHttpClient before 4.3 + * install proxy to AbstractHttpClient */ dpInstall.installProxy("org.apache.http.impl.client.AbstractHttpClient", new String[] { "com.creditease.uav.hook.httpclients.sync.interceptors" }, new DynamicProxyProcessor() { @Override public void process(DPMethod m) throws Exception { - + //before 4.3 if ("execute".equals(m.getName())) { if (m.getParameterTypes().length == 3 && m.getReturnType().getSimpleName().equals("HttpResponse")) { @@ -114,6 +114,13 @@ public void process(DPMethod m) throws Exception { m.insertAfter("{ApacheHttpClientIT.end(new Object[]{$_});}"); dpInstall.addCatch(m, "ApacheHttpClientIT.end(new Object[]{$e});"); } + + //after 4.3 + }else if ("doExecute".equals(m.getName())) { + + m.insertBefore("{ApacheHttpClientIT.start(\"" + appid + "\",new Object[]{$1,$2,$3});}"); + m.insertAfter("{ApacheHttpClientIT.end(new Object[]{$_});}"); + dpInstall.addCatch(m, "ApacheHttpClientIT.end(new Object[]{$e});"); } } }, false); diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java index 17db8b11..279b5890 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/ComponentProfileHandler.java @@ -911,8 +911,10 @@ private String getImplClassAsKey(String key, Node jaxws, ClassLoader cl, String Node beanClazz = processor .selectXMLNode("/beans/bean[@id='" + impl.getNodeValue() + "']/@class"); - - return beanClazz.getNodeValue(); + + if(beanClazz!=null) { + return beanClazz.getNodeValue(); + } } // step 2.3 load serviceBean|implementor/@ref @@ -923,7 +925,9 @@ private String getImplClassAsKey(String key, Node jaxws, ClassLoader cl, String Node beanClazz = processor .selectXMLNode("/beans/bean[@id='" + impl.getNodeValue() + "']/@class"); - return beanClazz.getNodeValue(); + if(beanClazz!=null) { + return beanClazz.getNodeValue(); + } } return key; diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileServiceMapMgr.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileServiceMapMgr.java index 39b62012..12d9a7b1 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileServiceMapMgr.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/spi/ProfileServiceMapMgr.java @@ -63,11 +63,7 @@ public ServiceURLBinding(String url, boolean allowAbMatch) { String[] pathParams = url.split("/"); - for (String pathParam : pathParams) { - if (pathParam.indexOf("{") > -1 && pathParam.indexOf("}") > -1) { - pathParamCount++; - } - } + pathParamCount=pathParams.length; this.pathPattern = url.substring(0, pathParamStartIndex); } From ea7a3ef64a9969e732e3536e6bd118d8d3f72046 Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 11 May 2018 15:50:06 +0800 Subject: [PATCH 82/97] https://github.com/uavorg/uavstack/issues/275 --- .../webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 385c46e7..9b75f4e2 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -223,6 +223,11 @@ function showEditNotifyDiv(jsonObjParam,isCopy) { sb.append( "
    "); sb.append( "
    "); + + if(!isCopy){ + sb.append( "
    "); + } + sb.append( ""); sb.append( "
    "); /** From 912dc913f4e77f8c17f4c12ecc1b3cb8e2658fcb Mon Sep 17 00:00:00 2001 From: xinyuzhou1 Date: Fri, 11 May 2018 18:23:35 +0800 Subject: [PATCH 83/97] https://github.com/uavorg/uavstack/issues/279 --- README.md | 178 ++++++++---------- ...ME\344\270\255\346\226\207\347\211\210.md" | 173 +++++++++++++++++ Readme-EN | 149 --------------- 3 files changed, 250 insertions(+), 250 deletions(-) create mode 100644 "README\344\270\255\346\226\207\347\211\210.md" delete mode 100644 Readme-EN diff --git a/README.md b/README.md index f6dcebe4..78b7ff8a 100644 --- a/README.md +++ b/README.md @@ -1,132 +1,114 @@ # UAVStack -UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 -它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 +UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. -UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. - -It includes AIOps Robot (HIT),full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM) etc.. - - -目前UAVStack开源系列 ( 官方网站:https://uavorg.github.io/main/ ) 包括 - -UAVStack Open Source series includes UAV.Monitor, UAV.APM, UAV.ServiceGovern, UAV.MSCP +Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP ![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) -# 更新模式 Project Updating Principle -* 开源系列源代码Issue更新,将与内部版本完全同步,最低频率每周一次 -* 开源系列源代码相关的功能优化,将与内部版本完全同步,最低频率每周一次 -* 开源系列源代码相关的新功能开放,会提前一周预告,并于下周内发布 -* 标准部署包下载会与源代码更新同步,最低频率每周一次 -* AllInOne开发演示版原则上每月更新一次(打包上传比较耗时),中间更新请下载标准部署包替换 ---- -* The open source series updating is fully synchronized with the internal version, with the lowest frequency once a week -* The open source series related functional optimizations is fully synchronized with the internal version, with the lowest frequency once a week -* The open source series related new features will be announced a week ahead of schedule, and released next week -* The standard deployment pack download is synchronized with source code updates, with the lowest frequency once a week -* AllInOne pack are updated once a month (packaged, uploaded, and time-consuming) in principle, and you can download the standard deployment package instead - +# Updating Rules +* Updates of the open source series (at least once a week) shall synchronize with those of the internal versions. +* Feature optimization of the open source series (at least once a week) shall synchronize with that of the internal versions as well. +* New features of the open source series shall be preannounced one week earlier and released within the following week. +* The standard deployment package shall synchronize with the updated source code (at least once a week). +* The AllInOne Demo Package is scheduled to be updated once a month. Please download the standard deployment package updated beyond the schedule. -# 工程说明 Source Code Project Description -uavstack是UAVStack的All in One源代码仓库。 +# Project Description uavstack is the All in One source repository of UAVStack. -## 根POM -* com.creditease.uav.superpom 根POM,包含依赖管理,Build所需plugins等 (Parent POM for dependency management & build plugins) +## Parent POM +* com.creditease.uav.superpom: parent POM that support dependency management and build plugins ## UAV.Monitor -* com.creditease.uav.agent 监控代理程序MonitorAgent核心框架 (Core of MonitorAgent) -* com.creditease.uav.healthmanager Monitor核心服务,包括实时数据,画像数据存储/查询,实时报警流式计算,AppHub支持服务 (Core feature of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time alarm streaming,AppHub Support Service) -* com.creditease.uav.notifycenter Monitor服务:报警中心服务端 (Notification Center Service) -* com.creditease.uav.monitorframework 探针MOF核心框架 (Core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc...) -* com.creditease.uav.monitorframework.agent 探针MOF的javaagent实现 (JVM MonitorFramework javaagent support) -* com.creditease.uav.monitorframework.dproxy javaassit支持 (JVM MonitorFramework javassit support) -* com.creditease.uav.hook.* 探针MOF针对技术规范的钩子,包括Dubbo,HttpClients,JAXWS,JDBC,MongoClients,MQ,Redis等 (JVM MonitorFramework Hooks for application framework) -* com.creditease.uav.loghook 探针MOF针对log4j,logback支持 (JVM MonitorFramework Hook for log4j, logback) -* com.creditease.uav.tomcat.plus.core 探针MOF对Tomcat/SpringBoot的支持 (JVM MonitorFramework extension for Tomcat/SpringBoot) -* com.creditease.uav.jetty.plus.core 探针MOF对Jetty支持 (JVM MonitorFramework extension for Jetty) -* com.creditease.uav.mock.sl4j 去除某些框架依赖sl4j (mock sl4j) -* com.creditease.uav.ttl com.alibaba.ttl源代码引入 (Alibaba TTL) -* com.creditease.uav.monitorframework.buildFat WAR测试程序 (Function Test of JVM MonitorFramework) -* com.creditease.uav.monitorframework.springbootFat SpringBoot测试程序 (Function Test of JVM MonitorFramework for springboot) -* com.creditease.uav.agent.buildComponent 制作监控代理程序部署包 (Build POM for MonitorAgent) -* com.creditease.uav.healthmanager.buildComponent 制作健康管理程序部署包 (Build POM for HealthManager) -* com.creditease.uav.monitorframework.buildComponent 制作探针MOF部署包 (Build POM for JVM MonitorFramework) +* com.creditease.uav.agent: core of MonitorAgent +* com.creditease.uav.healthmanager: core features of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time Alarm Streaming and AppHub Support Service +* com.creditease.uav.notifycenter: Notification Center Service +* com.creditease.uav.monitorframework: core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc... +* com.creditease.uav.monitorframework.agent: JVM MonitorFramework javaagent support +* com.creditease.uav.monitorframework.dproxy: JVM MonitorFramework javassit support +* com.creditease.uav.hook.* : JVM MonitorFramework Hooks for application framework, including Dubbo, HttpClients, JAXWS, JDBC, MongoClients, MQ, Redis, etc. +* com.creditease.uav.loghook: JVM MonitorFramework Hook for log4j and logback +* com.creditease.uav.tomcat.plus.core: JVM MonitorFramework extension for Tomcat/SpringBoot +* com.creditease.uav.jetty.plus.core: JVM MonitorFramework extension for Jetty +* com.creditease.uav.mock.sl4j: mock sl4j +* com.creditease.uav.ttl: com.alibaba.ttl source code introduction (Alibaba TTL) +* com.creditease.uav.monitorframework.buildFat: function test of JVM MonitorFramework) +* com.creditease.uav.monitorframework.springbootFat: function test of JVM MonitorFramework for Springboot) +* com.creditease.uav.agent.buildComponent: build POM for MonitorAgent +* com.creditease.uav.healthmanager.buildComponent: build POM for HealthManager +* com.creditease.uav.monitorframework.buildComponent: build POM for JVM MonitorFramework ## UAV.APM -* com.creditease.uav.collect APM归集客户端/服务端 (Core of APM Data Collection Client & Service) -* com.creditease.uav.invokechain 调用链,日志服务存储和查询 (InvokeChain, Log Collection 2.0) -* com.creditease.uav.monitorframework.apm 探针MOF的APM支持 (JVM MonitorFramework extension for APM) -* com.creditease.uav.threadanalysis 一键式线程分析客户端和服务端 (One Shot Thread Analysis Client & Service) +* com.creditease.uav.collect: core of APM Data Collection client and server +* com.creditease.uav.invokechain: Invocation Chain and Log Collection 2.0 +* com.creditease.uav.monitorframework.apm: JVM MonitorFramework extension for APM +* com.creditease.uav.threadanalysis: one-click thread analysis client and server ## UAV.MSCP -* com.creditease.uav.base MSCP核心框架 (Core of MSCP) -* com.creditease.uav.agent.heartbeat 心跳客户端,心跳服务端,节点远程操控,进程扫描,进程值守 (Base feature of MSCP including heartbeat client & service,node remote opertaions,process auto scanning,process keep-alive support) -* com.creditease.uav.annoscan Fastclasspathscanner源代码引入,注解Class扫描 (Fastclasspathscanner) -* com.creditease.uav.cache.redis 基于Redis的CacheManager (Cache Framework based on redis) -* com.creditease.uav.dbaccess 存储管理器,目前封装了对MySql,OpenTSDB,HBase,MongoDB的存储和查询 (Data Store Framework for MySQL,OpenTSDB,HBase,MongoDB) -* com.creditease.uav.elasticsearch.client ElasticSearch的Shaded客户端封装,避免冲突 (ElasticSearch-Shaded-Client) -* com.creditease.uav.fastjson Fastjson源代码引入 (FastJson) -* com.creditease.uav.helper Util型支持类库 (Util Support Lib) -* com.creditease.uav.httpasync Http异步通信客户端,封装Apache AsyncClient (RPC Framework based on Apache Http AsyncClient) -* com.creditease.uav.logging MSCP日志支持 (MSCP Logging support) -* com.creditease.uav.messaging MSCP消息发送者和消费者支持,无需关心底层消息服务,依赖com.creditease.uav.mq (Messaging Service) -* com.creditease.uav.mq 消息队列服务底层封装,目前使用RocketMQ (Message Queue Support based on Rocket MQ) -* com.creditease.uav.notifymanager MSCP组件级报警支持 (MSCP Component level notification support) -* com.creditease.uav.upgrade MSCP升级客户端和服务端 (Remote upgrading support for MSCP) +* com.creditease.uav.base: core of MSCP +* com.creditease.uav.agent.heartbeat: basic features of MSCP, including heartbeat client & server,node remote control,process auto scanning and process keep-alive support +* com.creditease.uav.annoscan: Fastclasspathscanner source code introduction +* com.creditease.uav.cache.redis: Redis-based cache framework +* com.creditease.uav.dbaccess: data store framework for MySQL,OpenTSDB,HBase and MongoDB +* com.creditease.uav.elasticsearch.client: ElasticSearch-shaded-client to avoid conflicts +* com.creditease.uav.fastjson: Fastjson source code introduction +* com.creditease.uav.helper: Util support library +* com.creditease.uav.httpasync: Http asynchronous communication client based on Apache Http AsyncClient) +* com.creditease.uav.logging: MSCP logging support +* com.creditease.uav.messaging: MSCP messaging support that relies on com.creditease.uav.mq and requires no underlying messaging service +* com.creditease.uav.mq: message queue support based on Rocket MQ +* com.creditease.uav.notifymanager: component-level MSCP notification support +* com.creditease.uav.upgrade: remote upgrading support for MSCP client and server ## UAV.AppHub -* com.creditease.uav.console UAVStack交互前端,包括Monitor,APM等前端交互功能 (AppHub is the GUI console for UAVStack) -* com.creditease.uav.console.buildComponent 制作AppHub部署包 (Build POM for AppHub) +* com.creditease.uav.console: GUI console of UAVStack with front-end interactive features such as Monitor and APM +* com.creditease.uav.console.buildComponent: build POM for AppHub ## UAV.ServiceGovern -* 服务自动注册包含与探针MOF代码中 -* 服务发现代码包含与健康管理程序画像数据查询中 -* 服务降级保护(代码整理中,陆续更新...) -* 服务授权(代码整理中,陆续更新...) - -# 如何构建 How to Build -如果由于缺少jar包或某些依赖jar无法下载导致Maven Build Failure,可下载[参考Maven依赖仓库](https://pan.baidu.com/s/1gfeY8pH),使用该Maven仓库或将其复制到你正在使用的Maven仓库中。 +* Service automatic registration is included in the codes of MOF. +* Codes for service discovery is included in profile data query of HealthManager. +* Service downgrading protection (To be updated). +* Service authorization (To be update). -If you are unable to build because of the lack of jar packages or certain dependency jar, pleaser refer this [Maven Repository](https://pan.baidu.com/s/1gfeY8pH), use the Maven repository, or copy it to the Maven warehouse you are using. +# How to Build +Download the [reference Maven dependency repository](https://pan.baidu.com/s/1gfeY8pH)for Maven Build Failure resulted from the lack of jar packages or the lack of dependent jar packages, and use the downloaded Maven repository instead or copy it into the Maven repository that you are using. 1. build com.creditease.uav.superpom ``` cd com.creditease.uav.superpom mvn clean install ``` -2 中间件增强框架(MOF探针) +2 MonitorFramework ``` cd com.creditease.uav.monitorframework.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavmof_1.0_XXXXX.zip > -uavmof_1.0_XXXXX.zip.MD5 -3. 监控代理程序(MA) +3. MonitorAgent ``` cd com.creditease.uav.agent.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavagent_1.0_XXXXX.zip > -uavagent_1.0_XXXXX.zip.MD5 -4. 健康管理服务(HM) +4. HealthManager ``` cd com.creditease.uav.healthmanager.buildComponent mvn clean install ``` -build结果 +build result >target > -build > -uavhm_1.0_XXXXX.zip @@ -138,36 +120,30 @@ cd com.creditease.uav.console mvn clean install ``` -build结果 +build result >target > -com.creditease.uav.console-1.0.war -# 文档中心 Documents -## 全维监控UAV.Monitor+APM -* [用户指南](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) -* [安装部署](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) -* [架构说明](https://uavorg.github.io/documents/uavdoc_architecture/index.html) - -# 下载中心 Downloads -## 全维监控UAV.Monitor+APM -* [MOF探针](https://pan.baidu.com/s/1cg4J0q) -* [监控代理程序](https://pan.baidu.com/s/1ge5MJ9h) -* [健康管理服务](https://pan.baidu.com/s/1i4HnV85) +# Documents +## UAV.Monitor+APM +* [User Operation](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) +* [Deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) +* [Architecture](https://uavorg.github.io/documents/uavdoc_architecture/index.html) + +# Downloads +## UAV.Monitor+APM +* [Monitor Framework](https://pan.baidu.com/s/1cg4J0q) +* [Monitor Agent](https://pan.baidu.com/s/1ge5MJ9h) +* [Health Manager](https://pan.baidu.com/s/1i4HnV85) * [AppHub](https://pan.baidu.com/s/1dFxtDZV) -## 第三方下载 Thirdparty Downloads +## Thirdparty Downloads * [rocket.war](https://pan.baidu.com/s/1dF6NeHN) -## AllInOne开发演示版 AllInOne Install Downloads -开发演示版的健康管理服务(HM)仅适合开发环境,演示环境,小规模测试环境。 -生产环境推荐使用[分布式部署](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) +## AllInOne Installation Downloads +The Health Manager (HM) in the AllInOne Installation Package is applicable to development environments, demos and small-scale testing environments. +[A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment. -The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment - -* [Windows64位](https://pan.baidu.com/s/1jIF0wNs) +* [Windows64](https://pan.baidu.com/s/1jIF0wNs) * [Mac](https://pan.baidu.com/s/1mhCykp6) * [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) - - - - diff --git "a/README\344\270\255\346\226\207\347\211\210.md" "b/README\344\270\255\346\226\207\347\211\210.md" new file mode 100644 index 00000000..f6dcebe4 --- /dev/null +++ "b/README\344\270\255\346\226\207\347\211\210.md" @@ -0,0 +1,173 @@ +# UAVStack +UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。 +它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。 + +UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently. + +It includes AIOps Robot (HIT),full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM) etc.. + + +目前UAVStack开源系列 ( 官方网站:https://uavorg.github.io/main/ ) 包括 + +UAVStack Open Source series includes UAV.Monitor, UAV.APM, UAV.ServiceGovern, UAV.MSCP + +![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) + +# 更新模式 Project Updating Principle +* 开源系列源代码Issue更新,将与内部版本完全同步,最低频率每周一次 +* 开源系列源代码相关的功能优化,将与内部版本完全同步,最低频率每周一次 +* 开源系列源代码相关的新功能开放,会提前一周预告,并于下周内发布 +* 标准部署包下载会与源代码更新同步,最低频率每周一次 +* AllInOne开发演示版原则上每月更新一次(打包上传比较耗时),中间更新请下载标准部署包替换 +--- +* The open source series updating is fully synchronized with the internal version, with the lowest frequency once a week +* The open source series related functional optimizations is fully synchronized with the internal version, with the lowest frequency once a week +* The open source series related new features will be announced a week ahead of schedule, and released next week +* The standard deployment pack download is synchronized with source code updates, with the lowest frequency once a week +* AllInOne pack are updated once a month (packaged, uploaded, and time-consuming) in principle, and you can download the standard deployment package instead + + +# 工程说明 Source Code Project Description +uavstack是UAVStack的All in One源代码仓库。 + +uavstack is the All in One source repository of UAVStack. + +## 根POM +* com.creditease.uav.superpom 根POM,包含依赖管理,Build所需plugins等 (Parent POM for dependency management & build plugins) + +## UAV.Monitor +* com.creditease.uav.agent 监控代理程序MonitorAgent核心框架 (Core of MonitorAgent) +* com.creditease.uav.healthmanager Monitor核心服务,包括实时数据,画像数据存储/查询,实时报警流式计算,AppHub支持服务 (Core feature of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time alarm streaming,AppHub Support Service) +* com.creditease.uav.notifycenter Monitor服务:报警中心服务端 (Notification Center Service) +* com.creditease.uav.monitorframework 探针MOF核心框架 (Core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc...) +* com.creditease.uav.monitorframework.agent 探针MOF的javaagent实现 (JVM MonitorFramework javaagent support) +* com.creditease.uav.monitorframework.dproxy javaassit支持 (JVM MonitorFramework javassit support) +* com.creditease.uav.hook.* 探针MOF针对技术规范的钩子,包括Dubbo,HttpClients,JAXWS,JDBC,MongoClients,MQ,Redis等 (JVM MonitorFramework Hooks for application framework) +* com.creditease.uav.loghook 探针MOF针对log4j,logback支持 (JVM MonitorFramework Hook for log4j, logback) +* com.creditease.uav.tomcat.plus.core 探针MOF对Tomcat/SpringBoot的支持 (JVM MonitorFramework extension for Tomcat/SpringBoot) +* com.creditease.uav.jetty.plus.core 探针MOF对Jetty支持 (JVM MonitorFramework extension for Jetty) +* com.creditease.uav.mock.sl4j 去除某些框架依赖sl4j (mock sl4j) +* com.creditease.uav.ttl com.alibaba.ttl源代码引入 (Alibaba TTL) +* com.creditease.uav.monitorframework.buildFat WAR测试程序 (Function Test of JVM MonitorFramework) +* com.creditease.uav.monitorframework.springbootFat SpringBoot测试程序 (Function Test of JVM MonitorFramework for springboot) +* com.creditease.uav.agent.buildComponent 制作监控代理程序部署包 (Build POM for MonitorAgent) +* com.creditease.uav.healthmanager.buildComponent 制作健康管理程序部署包 (Build POM for HealthManager) +* com.creditease.uav.monitorframework.buildComponent 制作探针MOF部署包 (Build POM for JVM MonitorFramework) + +## UAV.APM +* com.creditease.uav.collect APM归集客户端/服务端 (Core of APM Data Collection Client & Service) +* com.creditease.uav.invokechain 调用链,日志服务存储和查询 (InvokeChain, Log Collection 2.0) +* com.creditease.uav.monitorframework.apm 探针MOF的APM支持 (JVM MonitorFramework extension for APM) +* com.creditease.uav.threadanalysis 一键式线程分析客户端和服务端 (One Shot Thread Analysis Client & Service) + +## UAV.MSCP +* com.creditease.uav.base MSCP核心框架 (Core of MSCP) +* com.creditease.uav.agent.heartbeat 心跳客户端,心跳服务端,节点远程操控,进程扫描,进程值守 (Base feature of MSCP including heartbeat client & service,node remote opertaions,process auto scanning,process keep-alive support) +* com.creditease.uav.annoscan Fastclasspathscanner源代码引入,注解Class扫描 (Fastclasspathscanner) +* com.creditease.uav.cache.redis 基于Redis的CacheManager (Cache Framework based on redis) +* com.creditease.uav.dbaccess 存储管理器,目前封装了对MySql,OpenTSDB,HBase,MongoDB的存储和查询 (Data Store Framework for MySQL,OpenTSDB,HBase,MongoDB) +* com.creditease.uav.elasticsearch.client ElasticSearch的Shaded客户端封装,避免冲突 (ElasticSearch-Shaded-Client) +* com.creditease.uav.fastjson Fastjson源代码引入 (FastJson) +* com.creditease.uav.helper Util型支持类库 (Util Support Lib) +* com.creditease.uav.httpasync Http异步通信客户端,封装Apache AsyncClient (RPC Framework based on Apache Http AsyncClient) +* com.creditease.uav.logging MSCP日志支持 (MSCP Logging support) +* com.creditease.uav.messaging MSCP消息发送者和消费者支持,无需关心底层消息服务,依赖com.creditease.uav.mq (Messaging Service) +* com.creditease.uav.mq 消息队列服务底层封装,目前使用RocketMQ (Message Queue Support based on Rocket MQ) +* com.creditease.uav.notifymanager MSCP组件级报警支持 (MSCP Component level notification support) +* com.creditease.uav.upgrade MSCP升级客户端和服务端 (Remote upgrading support for MSCP) + +## UAV.AppHub +* com.creditease.uav.console UAVStack交互前端,包括Monitor,APM等前端交互功能 (AppHub is the GUI console for UAVStack) +* com.creditease.uav.console.buildComponent 制作AppHub部署包 (Build POM for AppHub) + +## UAV.ServiceGovern +* 服务自动注册包含与探针MOF代码中 +* 服务发现代码包含与健康管理程序画像数据查询中 +* 服务降级保护(代码整理中,陆续更新...) +* 服务授权(代码整理中,陆续更新...) + +# 如何构建 How to Build +如果由于缺少jar包或某些依赖jar无法下载导致Maven Build Failure,可下载[参考Maven依赖仓库](https://pan.baidu.com/s/1gfeY8pH),使用该Maven仓库或将其复制到你正在使用的Maven仓库中。 + +If you are unable to build because of the lack of jar packages or certain dependency jar, pleaser refer this [Maven Repository](https://pan.baidu.com/s/1gfeY8pH), use the Maven repository, or copy it to the Maven warehouse you are using. + +1. build com.creditease.uav.superpom +``` +cd com.creditease.uav.superpom +mvn clean install +``` +2 中间件增强框架(MOF探针) +``` +cd com.creditease.uav.monitorframework.buildComponent +mvn clean install +``` + +build结果 +>target +> -build +> -uavmof_1.0_XXXXX.zip +> -uavmof_1.0_XXXXX.zip.MD5 + +3. 监控代理程序(MA) +``` +cd com.creditease.uav.agent.buildComponent +mvn clean install +``` + +build结果 +>target +> -build +> -uavagent_1.0_XXXXX.zip +> -uavagent_1.0_XXXXX.zip.MD5 + +4. 健康管理服务(HM) +``` +cd com.creditease.uav.healthmanager.buildComponent +mvn clean install +``` + +build结果 +>target +> -build +> -uavhm_1.0_XXXXX.zip +> -uavhm_1.0_XXXXX.zip.MD5 + +5. AppHub +``` +cd com.creditease.uav.console +mvn clean install +``` + +build结果 +>target +> -com.creditease.uav.console-1.0.war + +# 文档中心 Documents +## 全维监控UAV.Monitor+APM +* [用户指南](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) +* [安装部署](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) +* [架构说明](https://uavorg.github.io/documents/uavdoc_architecture/index.html) + +# 下载中心 Downloads +## 全维监控UAV.Monitor+APM +* [MOF探针](https://pan.baidu.com/s/1cg4J0q) +* [监控代理程序](https://pan.baidu.com/s/1ge5MJ9h) +* [健康管理服务](https://pan.baidu.com/s/1i4HnV85) +* [AppHub](https://pan.baidu.com/s/1dFxtDZV) + +## 第三方下载 Thirdparty Downloads +* [rocket.war](https://pan.baidu.com/s/1dF6NeHN) + +## AllInOne开发演示版 AllInOne Install Downloads +开发演示版的健康管理服务(HM)仅适合开发环境,演示环境,小规模测试环境。 +生产环境推荐使用[分布式部署](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) + +The health management service (HM) in AllInOne Install Package is only suitable for development environments, demos, and small scale testing environments. [A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment + +* [Windows64位](https://pan.baidu.com/s/1jIF0wNs) +* [Mac](https://pan.baidu.com/s/1mhCykp6) +* [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) + + + + diff --git a/Readme-EN b/Readme-EN deleted file mode 100644 index 78b7ff8a..00000000 --- a/Readme-EN +++ /dev/null @@ -1,149 +0,0 @@ -# UAVStack -UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. - -Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP - -![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png) - -# Updating Rules -* Updates of the open source series (at least once a week) shall synchronize with those of the internal versions. -* Feature optimization of the open source series (at least once a week) shall synchronize with that of the internal versions as well. -* New features of the open source series shall be preannounced one week earlier and released within the following week. -* The standard deployment package shall synchronize with the updated source code (at least once a week). -* The AllInOne Demo Package is scheduled to be updated once a month. Please download the standard deployment package updated beyond the schedule. - -# Project Description - -uavstack is the All in One source repository of UAVStack. - -## Parent POM -* com.creditease.uav.superpom: parent POM that support dependency management and build plugins - -## UAV.Monitor -* com.creditease.uav.agent: core of MonitorAgent -* com.creditease.uav.healthmanager: core features of HealthManager, including Monitoring Data Service,Application/Service Profiling,Real-time Alarm Streaming and AppHub Support Service -* com.creditease.uav.notifycenter: Notification Center Service -* com.creditease.uav.monitorframework: core of JVM MonitorFramework for Tomcat,Jetty,SpringBoot,MSCP, etc... -* com.creditease.uav.monitorframework.agent: JVM MonitorFramework javaagent support -* com.creditease.uav.monitorframework.dproxy: JVM MonitorFramework javassit support -* com.creditease.uav.hook.* : JVM MonitorFramework Hooks for application framework, including Dubbo, HttpClients, JAXWS, JDBC, MongoClients, MQ, Redis, etc. -* com.creditease.uav.loghook: JVM MonitorFramework Hook for log4j and logback -* com.creditease.uav.tomcat.plus.core: JVM MonitorFramework extension for Tomcat/SpringBoot -* com.creditease.uav.jetty.plus.core: JVM MonitorFramework extension for Jetty -* com.creditease.uav.mock.sl4j: mock sl4j -* com.creditease.uav.ttl: com.alibaba.ttl source code introduction (Alibaba TTL) -* com.creditease.uav.monitorframework.buildFat: function test of JVM MonitorFramework) -* com.creditease.uav.monitorframework.springbootFat: function test of JVM MonitorFramework for Springboot) -* com.creditease.uav.agent.buildComponent: build POM for MonitorAgent -* com.creditease.uav.healthmanager.buildComponent: build POM for HealthManager -* com.creditease.uav.monitorframework.buildComponent: build POM for JVM MonitorFramework - -## UAV.APM -* com.creditease.uav.collect: core of APM Data Collection client and server -* com.creditease.uav.invokechain: Invocation Chain and Log Collection 2.0 -* com.creditease.uav.monitorframework.apm: JVM MonitorFramework extension for APM -* com.creditease.uav.threadanalysis: one-click thread analysis client and server - -## UAV.MSCP -* com.creditease.uav.base: core of MSCP -* com.creditease.uav.agent.heartbeat: basic features of MSCP, including heartbeat client & server,node remote control,process auto scanning and process keep-alive support -* com.creditease.uav.annoscan: Fastclasspathscanner source code introduction -* com.creditease.uav.cache.redis: Redis-based cache framework -* com.creditease.uav.dbaccess: data store framework for MySQL,OpenTSDB,HBase and MongoDB -* com.creditease.uav.elasticsearch.client: ElasticSearch-shaded-client to avoid conflicts -* com.creditease.uav.fastjson: Fastjson source code introduction -* com.creditease.uav.helper: Util support library -* com.creditease.uav.httpasync: Http asynchronous communication client based on Apache Http AsyncClient) -* com.creditease.uav.logging: MSCP logging support -* com.creditease.uav.messaging: MSCP messaging support that relies on com.creditease.uav.mq and requires no underlying messaging service -* com.creditease.uav.mq: message queue support based on Rocket MQ -* com.creditease.uav.notifymanager: component-level MSCP notification support -* com.creditease.uav.upgrade: remote upgrading support for MSCP client and server - -## UAV.AppHub -* com.creditease.uav.console: GUI console of UAVStack with front-end interactive features such as Monitor and APM -* com.creditease.uav.console.buildComponent: build POM for AppHub - -## UAV.ServiceGovern -* Service automatic registration is included in the codes of MOF. -* Codes for service discovery is included in profile data query of HealthManager. -* Service downgrading protection (To be updated). -* Service authorization (To be update). - -# How to Build -Download the [reference Maven dependency repository](https://pan.baidu.com/s/1gfeY8pH)for Maven Build Failure resulted from the lack of jar packages or the lack of dependent jar packages, and use the downloaded Maven repository instead or copy it into the Maven repository that you are using. - -1. build com.creditease.uav.superpom -``` -cd com.creditease.uav.superpom -mvn clean install -``` -2 MonitorFramework -``` -cd com.creditease.uav.monitorframework.buildComponent -mvn clean install -``` - -build result ->target -> -build -> -uavmof_1.0_XXXXX.zip -> -uavmof_1.0_XXXXX.zip.MD5 - -3. MonitorAgent -``` -cd com.creditease.uav.agent.buildComponent -mvn clean install -``` - -build result ->target -> -build -> -uavagent_1.0_XXXXX.zip -> -uavagent_1.0_XXXXX.zip.MD5 - -4. HealthManager -``` -cd com.creditease.uav.healthmanager.buildComponent -mvn clean install -``` - -build result ->target -> -build -> -uavhm_1.0_XXXXX.zip -> -uavhm_1.0_XXXXX.zip.MD5 - -5. AppHub -``` -cd com.creditease.uav.console -mvn clean install -``` - -build result ->target -> -com.creditease.uav.console-1.0.war - -# Documents -## UAV.Monitor+APM -* [User Operation](https://uavorg.github.io/documents/uavdoc_useroperation/index.html) -* [Deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/index.html) -* [Architecture](https://uavorg.github.io/documents/uavdoc_architecture/index.html) - -# Downloads -## UAV.Monitor+APM -* [Monitor Framework](https://pan.baidu.com/s/1cg4J0q) -* [Monitor Agent](https://pan.baidu.com/s/1ge5MJ9h) -* [Health Manager](https://pan.baidu.com/s/1i4HnV85) -* [AppHub](https://pan.baidu.com/s/1dFxtDZV) - -## Thirdparty Downloads -* [rocket.war](https://pan.baidu.com/s/1dF6NeHN) - -## AllInOne Installation Downloads -The Health Manager (HM) in the AllInOne Installation Package is applicable to development environments, demos and small-scale testing environments. -[A distributed deployment](https://uavorg.github.io/documents/uavdoc_deploydocs/healmanagerInstall/healmanagerInstall/microservice.html) is recommended for the production environment. - -* [Windows64](https://pan.baidu.com/s/1jIF0wNs) -* [Mac](https://pan.baidu.com/s/1mhCykp6) -* [Linux(CentOS)](https://pan.baidu.com/s/1nvj6jW1) From ada4c3d76d96b79309c03eb3febe41150fea89b0 Mon Sep 17 00:00:00 2001 From: boanyeliu Date: Fri, 11 May 2018 18:34:01 +0800 Subject: [PATCH 84/97] https://github.com/uavorg/uavstack/issues/265 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apphub管理 cache处理异常修改 --- .../java/com/creditease/uav/manage/rest/ManageRestService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java index 81f327cc..a55c3c75 100644 --- a/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java +++ b/com.creditease.uav.console/src/main/java/com/creditease/uav/manage/rest/ManageRestService.java @@ -670,7 +670,7 @@ public GroupHttpCallBack(AsyncResponse asyncResponseParam, Map i void after(HttpClientCallbackResult result) { String region = input.get("region"); - String regionAppKey = input.get("region.appKey"); + String regionAppKey = input.get("region.groupKey"); String bType = input.get("bType"); String groupId = input.get("groupId"); From a01c3be802761465ba0a36b150119f3c7aefcb8b Mon Sep 17 00:00:00 2001 From: xinyuzhou1 Date: Fri, 11 May 2018 18:40:35 +0800 Subject: [PATCH 85/97] https://github.com/uavorg/uavstack/issues/279 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 78b7ff8a..6f5822a6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # UAVStack +中文版README请点击(https://github.com/uavorg/uavstack/blob/master/README%E4%B8%AD%E6%96%87%E7%89%88.md) + UAVStack as an intelligent service technology stack is the integrated solution to R&D, operation and maintenance. As the acronym of unmanned aerial vehicle, UAV depicts the scenario where the unmanned aerial vehicle hovers under the sky and completes tasks in an intelligent and transparent manner. This stack features AIOps Robot (HIT), full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM), etc.. Please visit https://uavorg.github.io/main/ for the open source series of UAVStack, including UAV.Monitor, UAV.APM, UAV.ServiceGovern and UAV.MSCP From 6298eedc82d6a18cf624478d3a85241bd4f93064 Mon Sep 17 00:00:00 2001 From: xingshengli Date: Fri, 18 May 2018 14:46:25 +0800 Subject: [PATCH 86/97] =?UTF-8?q?=E4=BF=AE=E5=A4=8Diplink=E4=B8=AD?= =?UTF-8?q?=E5=90=AB=E6=9C=89''=E5=AF=BC=E8=87=B4=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=94=BB=E5=83=8F=E7=94=BB=E4=B8=8D=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/IPLinkProfileHandler.java | 2 +- .../uav/util/MonitorServerUtil.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/IPLinkProfileHandler.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/IPLinkProfileHandler.java index eb641131..0882eb04 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/IPLinkProfileHandler.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling/handlers/IPLinkProfileHandler.java @@ -182,7 +182,7 @@ private void getAccessTargetInfo(ProfileContext context, long curTime, ProfileEl else { path = iplnkTargetURI.getPath(); } - + path = MonitorServerUtil.cleanIplnkTargetURL(path); if (path.indexOf("/" + appid) == 0) { path = path.substring(("/" + appid).length()); } diff --git a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/util/MonitorServerUtil.java b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/util/MonitorServerUtil.java index 1775c43a..9558632b 100644 --- a/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/util/MonitorServerUtil.java +++ b/com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/util/MonitorServerUtil.java @@ -453,6 +453,25 @@ public static String cleanRelativeURL(String reUrl) { return reUrl; } + + /** + * sometimes we meet the url like: + * http://localhost:8080/static/dev/css/product_pdfView//"932105@ + * + * clean the Illegal characters in the IplnkTargetURL + * + * @param iplinkTargetUrl + * + * @return + */ + public static String cleanIplnkTargetURL(String iplinkTargetUrl) { + + if (!StringHelper.isEmpty(iplinkTargetUrl)&&iplinkTargetUrl.contains("\"")) { + iplinkTargetUrl = iplinkTargetUrl.replace("\"", ""); + } + return iplinkTargetUrl; + } + /** * check if the request is from browser * From c5f7cb5d292c149960d9a8a71f61af736e5fd4bd Mon Sep 17 00:00:00 2001 From: minglangyang Date: Fri, 18 May 2018 15:29:44 +0800 Subject: [PATCH 87/97] https://github.com/uavorg/uavstack/issues/282 1.time_based notification support notify cross diffirent metric type --- .../uav/feature/RuntimeNotifyCatcher.java | 32 +++++- .../feature/runtimenotify/NotifyStrategy.java | 40 ++++++- .../runtimenotify/StrategyJudgement.java | 87 +++++++++++---- .../expradaptors/AbstractExprAdaptor.java | 96 ++++++++++++++++ .../expradaptors/AppExprAdaptor.java | 76 +++++++++++++ .../expradaptors/ClientExprAdaptor.java | 59 ++++++++++ .../expradaptors/HostExprAdaptor.java | 66 +++++++++++ .../expradaptors/JvmExprAdaptor.java | 71 ++++++++++++ .../expradaptors/ProcExprAdaptor.java | 103 ++++++++++++++++++ .../expradaptors/ServerExprAdaptor.java | 71 ++++++++++++ .../expradaptors/UrlExprAdaptor.java | 57 ++++++++++ .../scheduler/TimerNotifyWorker.java | 4 +- ...Task.java => JudgeNotifyTaskForTimer.java} | 22 +++- 13 files changed, 750 insertions(+), 34 deletions(-) create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AbstractExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AppExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ClientExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/HostExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/JvmExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ProcExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ServerExprAdaptor.java create mode 100644 com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/UrlExprAdaptor.java rename com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/{JudgeNotifyTimerTask.java => JudgeNotifyTaskForTimer.java} (89%) diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/RuntimeNotifyCatcher.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/RuntimeNotifyCatcher.java index 5c86ba2c..54107e11 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/RuntimeNotifyCatcher.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/RuntimeNotifyCatcher.java @@ -37,11 +37,20 @@ import com.creditease.agent.monitor.api.MonitorDataFrame; import com.creditease.agent.spi.AgentFeatureComponent; import com.creditease.agent.spi.I1NQueueWorker; +import com.creditease.agent.spi.IActionEngine; import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.cache.api.CacheManagerFactory; import com.creditease.uav.feature.runtimenotify.RuntimeNotifySliceMgr; import com.creditease.uav.feature.runtimenotify.Slice; import com.creditease.uav.feature.runtimenotify.StrategyJudgement; +import com.creditease.uav.feature.runtimenotify.expradaptors.AbstractExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.AppExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.ClientExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.HostExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.JvmExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.ProcExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.ServerExprAdaptor; +import com.creditease.uav.feature.runtimenotify.expradaptors.UrlExprAdaptor; import com.creditease.uav.feature.runtimenotify.http.RuntimeNotifyServerWorker; import com.creditease.uav.feature.runtimenotify.scheduler.NodeInfoWatcher; import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; @@ -69,6 +78,8 @@ public class RuntimeNotifyCatcher extends AgentFeatureComponent { private Thread qwThread; + private IActionEngine engine; + public RuntimeNotifyCatcher(String cName, String feature) { super(cName, feature); } @@ -157,6 +168,17 @@ public void start() { + "] started: coresize:%d,maxsize:%d,bqsize:%d,keepalivetimeout:%d", coreSize, maxSize, bqSize, timeout)); } + + //init RuntimeNotifyActionEngine + engine = this.getActionEngineMgr().newActionEngine("RuntimeNotifyActionEngine", this.feature); + //register exprAdaptor + new ClientExprAdaptor(AbstractExprAdaptor.CLIENT_RESP, this.feature, engine); + new UrlExprAdaptor(AbstractExprAdaptor.URL_RESP, this.feature, engine); + new AppExprAdaptor(AbstractExprAdaptor.APP_RESP, this.feature, engine); + new ServerExprAdaptor(AbstractExprAdaptor.SERVER_RESP, this.feature, engine); + new JvmExprAdaptor(AbstractExprAdaptor.JVM, this.feature, engine); + new ProcExprAdaptor(AbstractExprAdaptor.PROC_STATE, this.feature, engine); + new HostExprAdaptor(AbstractExprAdaptor.HOST_STATE, this.feature, engine); // start runtime notify data consumer StandardMessagingBuilder smb = new StandardMessagingBuilder("RTNTFCommonMsgBuilder", this.feature); @@ -297,7 +319,11 @@ public void stop() { } this.getConfigManager().unregisterComponent(this.feature, "StrategyJudgement"); - + + if(engine!=null) { + this.getActionEngineMgr().shutdown("RuntimeNotifyActionEngine"); + } + super.stop(); } @@ -396,6 +422,7 @@ private List extractSlice(MonitorDataFrame mdf) { List list = new ArrayList<>(); Map> frames = mdf.getDatas(); String appgroup = mdf.getExt("appgroup"); + String pid=mdf.getExt("pid"); for (Map.Entry> frame : frames.entrySet()) { List servers = frame.getValue(); for (Map server : servers) { @@ -407,6 +434,9 @@ private List extractSlice(MonitorDataFrame mdf) { Map values = (Map) ins.get("values"); values.put("ip", mdf.getIP()); values.put("host", mdf.getHost()); + if(pid != null) { + values.put("pid", pid); + } values.put("appgroup", appgroup); String key = frame.getKey() + RuntimeNotifyCatcher.STRATEGY_SEPARATOR + meId + RuntimeNotifyCatcher.STRATEGY_SEPARATOR + id; diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java index b8d163ef..d9ab2459 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/NotifyStrategy.java @@ -124,8 +124,25 @@ public void setConditions(List conditions, List relations) { expression = new Expression(expr, func, range, sampling); } else { - String metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); - cond.put("metric", metricPrefix + "." + cond.get("metric")); + String metric = String.valueOf(cond.get("metric")); + + //add default metricPrefix if missing, such as "clientResp.", "hostState." and so on + String metricPrefix=""; + + int index = metric.indexOf('.'); + + if(index>-1) { + metricPrefix = metric.substring(0, metric.indexOf('.')); + } + + if(!metricPrefix.contains("State")&&!metricPrefix.contains("Resp")&&!metricPrefix.contains("jvm")) { + + metricPrefix = name.substring(name.indexOf('@') + 1, name.lastIndexOf('@')); + + metric = metricPrefix + "."+ metric; + } + + cond.put("metric", metric); expression = new Expression(cond); this.type = Type.TIMER; } @@ -299,6 +316,10 @@ protected static class Expression { private String day_start; private String day_end; + private String exprAdaptorId; + + private String hashcode; + public Expression(String exprStr) { for (String op : OPERATORS) { if (exprStr.contains(op)) { @@ -331,7 +352,11 @@ public Expression(String exprStr, String func, Long range, Float sampling) { public Expression(Map cond) { this.arg = (String) cond.get("metric"); + + this.exprAdaptorId = arg.substring(0,arg.indexOf('.')); + this.unit = Integer.parseInt((String) cond.get("unit")); + this.time_from = DateTimeHelper .dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_from"), "yyyy-MM-dd HH:mm") .getTime(); @@ -413,7 +438,11 @@ public Set matchTargetArgs(Set srcArgs) { public String getHashCode() { - return EncodeHelper.encodeMD5(arg + func + lowerLimit + upperLimit + time_from + time_to + interval + unit); + if(this.hashcode == null) { + hashcode = EncodeHelper.encodeMD5(arg + func + downsample + lowerLimit + upperLimit + time_from + time_to + interval + unit + time_start + time_end + day_start + day_end); + } + + return hashcode; } public String getArg() { @@ -520,6 +549,11 @@ public Boolean[] getWeekdayLimit() { return weekdayLimit; } + + public String getExprAdaptorId() { + + return exprAdaptorId; + } } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java index 3615fb7c..84ce49f9 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/StrategyJudgement.java @@ -39,6 +39,7 @@ import com.creditease.agent.monitor.api.MonitorDataFrame; import com.creditease.agent.spi.AbstractComponent; import com.creditease.agent.spi.AbstractSystemInvoker; +import com.creditease.agent.spi.ActionContext; import com.creditease.agent.spi.ISystemInvokerMgr.InvokerType; import com.creditease.uav.cache.api.CacheManager; import com.creditease.uav.feature.RuntimeNotifyCatcher; @@ -296,7 +297,7 @@ && isOverdue(DateTimeHelper judgeResult.put("fire", false); } else if (timeMap != null) { - caculateJudgeResult(timeMap, judgeResult, slice.getKey(), expr, cr); + caculateJudgeResult(timeMap, judgeResult, slice, expr, cr); if((Boolean) judgeResult.get("fire")) { //add detail info @@ -320,9 +321,9 @@ private void addDetail(Map timeMap, Slice slice, Expression expr) return; } - Map currentDetailValue = queryDetailValue(slice.getKey(),expr,timeMap.get("time_from"),timeMap.get("time_to")); + Map currentDetailValue = queryDetailValue(slice,expr,timeMap.get("time_from"),timeMap.get("time_to")); - Map lastDetailValue = queryDetailValue(slice.getKey(),expr,timeMap.get("last_time_from"),timeMap.get("last_time_to")); + Map lastDetailValue = queryDetailValue(slice,expr,timeMap.get("last_time_from"),timeMap.get("last_time_to")); args.put("currentDetailValue_"+metric, currentDetailValue); @@ -330,11 +331,11 @@ private void addDetail(Map timeMap, Slice slice, Expression expr) } @SuppressWarnings("rawtypes") - private Map queryDetailValue(String instance, Expression expr, Long startTime, Long endTime) { + private Map queryDetailValue(Slice slice, Expression expr, Long startTime, Long endTime) { Map detail = new LinkedHashMap(); - String data = buildQueryJSON(instance,expr,startTime,endTime,true); + String data = buildQueryJSON(slice,expr,startTime,endTime,true); List resultList = queryOpentsdb(data); @@ -358,7 +359,7 @@ private Map queryDetailValue(String instance, Expression expr, L } - private void caculateJudgeResult(Map timeMap, Map judgeResult, String instance, + private void caculateJudgeResult(Map timeMap, Map judgeResult, Slice slice, Expression expr, ConditionResult cr) { // if this time's judge has been done, return the last result. @@ -367,7 +368,7 @@ private void caculateJudgeResult(Map timeMap, Map return; } - Double currentValue = queryValue(instance, expr, timeMap.get("time_from"), + Double currentValue = queryValue(slice, expr, timeMap.get("time_from"), timeMap.get("time_to")); Double lastValue = 0.0; @@ -383,11 +384,11 @@ else if (judgeResult.get("time_to") != null lastValue = Double.parseDouble(String.valueOf(judgeResult.get("currentValue"))); } else { - lastValue = queryValue(instance, expr, timeMap.get("last_time_from"), + lastValue = queryValue(slice, expr, timeMap.get("last_time_from"), timeMap.get("last_time_to")); } - judgeResult.put("instance", instance); + judgeResult.put("instance", slice.getKey()); for (String key : timeMap.keySet()) { judgeResult.put(key, DateTimeHelper.dateFormat(new Date(timeMap.get(key)), "yyyy-MM-dd HH:mm")); @@ -404,7 +405,7 @@ else if (judgeResult.get("time_to") != null } // cache the judgeResult - cm.putHash(RuntimeNotifyCatcher.UAV_CACHE_REGION, TIMER_JUDGE_RESULT, instance + expr.getHashCode(), + cm.putHash(RuntimeNotifyCatcher.UAV_CACHE_REGION, TIMER_JUDGE_RESULT, slice.getKey() + expr.getHashCode(), JSONHelper.toString(judgeResult)); // set there is a judge event @@ -428,7 +429,7 @@ private boolean caculate(double currentValue, double lastValue, NotifyStrategy.E double diff = currentValue - lastValue; - String limitString = null; + String limitString = ""; String upperLimitString = expr.getUpperLimit(); String lowerLimitString = expr.getLowerLimit(); @@ -479,15 +480,20 @@ else if (!lowerLimitString.contains("*") && diff < 0 - lowerLimit) { } @SuppressWarnings({"rawtypes" }) - private Double queryValue(String instance, Expression expr, Long startTime, Long endTime) { + private Double queryValue(Slice slice, Expression expr, Long startTime, Long endTime) { Double result = null; - for (int i = 0; i < 3; i++) { - try { + String data = buildQueryJSON(slice,expr,startTime,endTime,false); - String data = buildQueryJSON(instance,expr,startTime,endTime,false); + if(data==null) { + return result; + } + + for (int i = 0; i < 2; i++) { + try { + List resultList = queryOpentsdb(data); if(resultList==null) { @@ -533,16 +539,46 @@ private List queryOpentsdb(String data) { return rsList; } - private String buildQueryJSON(String instance, Expression expr, Long startTime, Long endTime, boolean groupBy) { + private String buildQueryJSON(Slice slice, Expression expr, Long startTime, Long endTime, boolean groupBy) { + + String instance = slice.getKey(); - String data=String.format( - "{\"start\":%d,\"end\":%d,\"queries\":[{\"aggregator\":\"%s\",\"downsample\":\"%s\",\"metric\":\"%s\",\"filters\":[{\"filter\":\"%s\",\"tagk\":\"instid\",\"type\":\"regexp\",\"groupBy\":%b}]}]}", - startTime, endTime, expr.getFunc(), expr.getDownsample(), expr.getArg(), - instance.replace(":", "/u003a").replace("%", "/u0025").replace("#", "/u0023"),groupBy); + instance=convertInstance(instance, (String)slice.getArgs().get("instType"), expr); + + if (instance==null) { + return null; + } + + String filterType=(instance.contains("*"))?"wildcard":"literal_or"; + + String data = String.format( + "{\"start\":%d,\"end\":%d,\"queries\":[{\"aggregator\":\"%s\",\"downsample\":\"%s\",\"metric\":\"%s\",\"filters\":[{\"filter\":\"%s\",\"tagk\":\"instid\",\"type\":\"%s\",\"groupBy\":%b}]}]}", + startTime, endTime, expr.getFunc(), expr.getDownsample(), expr.getArg(), + instance.replace(":", "/u003a").replace("%", "/u0025").replace("#", "/u0023"),filterType,groupBy); return data; } + /** + * @param orignal instance + * + * @return adaptive instance + * + * convert instance to expr's adaptive instance + */ + private String convertInstance(String instance,String instType,Expression expr) { + + ActionContext ac = new ActionContext(); + + ac.putParam("instance", instance); + + ac.putParam("instType", instType); + + this.getActionEngineMgr().getActionEngine("RuntimeNotifyActionEngine").execute(expr.getExprAdaptorId(), ac); + + return (String) ac.getParam("instance"); + } + /** * get judgeResult from redis */ @@ -810,7 +846,10 @@ private String makeReadableString(Map m) { } } else if (NotifyStrategy.Type.TIMER.toString().equals(m.get("type"))) { - + + if(!"true".equals(m.get("fire"))) { + description="false"; + } if (m.get("expectedValue").contains("#")) { double expectedValue = Double .parseDouble(m.get("expectedValue").substring(m.get("expectedValue").indexOf('#') + 1)); @@ -821,11 +860,11 @@ else if (NotifyStrategy.Type.TIMER.toString().equals(m.get("type"))) { String.valueOf(actualValue)) : "false"; } else { - description = ("true".equals(m.get("fire"))) ? String.format( + description = String.format( "%s在%s至%s时间段的%s值%s比%s至%s%s%s%s,当前值:%s。上期值:%s,本期值:%s", m.get("metric"), m.get("time_from"), m.get("time_to"), readable.get(m.get("downsample")), m.get("tag"), m.get("last_time_from"), m.get("last_time_to"), - (m.get("upperORlower").equals("upper") && !m.get("expectedValue").contains("-")) + (("upper").equals(m.get("upperORlower")) && !m.get("expectedValue").contains("-")) || (m.get("upperORlower").equals("lower") && m.get("expectedValue").contains("-")) ? "增幅" : "降幅", @@ -836,7 +875,7 @@ else if (NotifyStrategy.Type.TIMER.toString().equals(m.get("type"))) { || (m.get("upperORlower").equals("lower") && !m.get("expectedValue").contains("-")) ? String.valueOf(0 - Double.parseDouble(m.get("actualValue"))) : m.get("actualValue"), - m.get("lastValue"), m.get("currentValue")) : "false"; + m.get("lastValue"), m.get("currentValue")); } } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AbstractExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AbstractExprAdaptor.java new file mode 100644 index 00000000..119d6b23 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AbstractExprAdaptor.java @@ -0,0 +1,96 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.AbstractBaseAction; +import com.creditease.agent.spi.ActionContext; +import com.creditease.agent.spi.IActionEngine; + +/** + * AbstractExprAdaptAction description: expr's adaption + * + */ +public abstract class AbstractExprAdaptor extends AbstractBaseAction { + + public final static String CLIENT_RESP="clientResp"; + + public final static String URL_RESP="urlResp"; + + public final static String APP_RESP="appResp"; + + public final static String SERVER_RESP="serverResp"; + + public final static String JVM="jvm"; + + public final static String PROC_STATE="procState"; + + public final static String HOST_STATE="hostState"; + + public AbstractExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + + @Override + public void doAction(ActionContext context) throws Exception { + + String instance=(String) context.getParam("instance"); + String type=(String) context.getParam("instType"); + + context.putParam("instance", convertInstance(instance, type)); + } + + + @Override + public String getSuccessNextActionId() { + + return null; + } + + @Override + public String getFailureNextActionId() { + + return null; + } + + + @Override + public String getExceptionNextActionId() { + + return null; + } + + /** + * convert source instance to target Expr's valid instance
    + *
    + * sample instance:
    + *
    + * clientRespInst: "127.0.0.1:8080#apphub#http://127.0.0.1:4243"
    + * urlRespInst: "http://127.0.0.1:8080/apphub/godeye/hm/q"
    + * appRespInst: "http://127.0.0.1:8080/apphub---apphub"
    + * serverRespInst: "http://127.0.0.1:8080"
    + * procStateInst: "127.0.0.1_java_10342"
    + * hostStateInst: "127.0.0.1"
    + */ + public abstract String convertInstance(String instance, String type); + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AppExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AppExprAdaptor.java new file mode 100644 index 00000000..92a7caa7 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/AppExprAdaptor.java @@ -0,0 +1,76 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * AppExprAdaptor description: for APP_RESP expr's adaption + * + */ +public class AppExprAdaptor extends AbstractExprAdaptor{ + + + public AppExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case CLIENT_RESP: + String[] strs=instance.split("#"); + if(strs.length==3) { + instance = "http://"+strs[0]+"*---"+strs[1]; + }else { + instance = null ; + } + break; + //not true when one server have several Apps + case URL_RESP: + int index=instance.indexOf("//")+2; + String temp=instance.substring(index); + if(temp.indexOf("/")>-1) { + instance = instance.substring(0,temp.indexOf("/")+index); + } + instance = instance+"*"; + break; + case APP_RESP: + instance = instance+"*"; + break; + //not true when one server have several Apps + case SERVER_RESP: + case JVM: + instance = instance+"*"; + break; + case PROC_STATE: + case HOST_STATE: + default: + instance = null; + break; + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ClientExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ClientExprAdaptor.java new file mode 100644 index 00000000..8236f963 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ClientExprAdaptor.java @@ -0,0 +1,59 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * ClientExprAdaptor description: for CLIENT_RESP expr's adaption + * + */ +public class ClientExprAdaptor extends AbstractExprAdaptor{ + + + public ClientExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + + switch (type) { + case CLIENT_RESP: + break; + case URL_RESP: + case APP_RESP: + case SERVER_RESP: + case JVM: + case PROC_STATE: + case HOST_STATE: + default: + instance = null; + break; + + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/HostExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/HostExprAdaptor.java new file mode 100644 index 00000000..e65af639 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/HostExprAdaptor.java @@ -0,0 +1,66 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * HostExprAdaptor description: for HOST_STATE expr's adaption + * + */ +public class HostExprAdaptor extends AbstractExprAdaptor{ + + + public HostExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case CLIENT_RESP: + instance = instance.substring(0,instance.indexOf(":")); + break; + case URL_RESP: + case APP_RESP: + case SERVER_RESP: + case JVM: + instance = instance.substring(instance.indexOf("//") + 2, instance.lastIndexOf(":")); + break; + case PROC_STATE: + int endIndex=instance.indexOf("_"); + if(endIndex != -1) { + instance = instance.substring(0,endIndex); + } + break; + case HOST_STATE: + break; + default: + instance = null; + break; + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/JvmExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/JvmExprAdaptor.java new file mode 100644 index 00000000..c8d8f7a4 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/JvmExprAdaptor.java @@ -0,0 +1,71 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * JvmExprAdaptor description: for JVM expr's adaption + * + */ +public class JvmExprAdaptor extends AbstractExprAdaptor{ + + + public JvmExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case CLIENT_RESP: + String[] strs=instance.split("#"); + if(strs.length==3) { + instance = "http://"+strs[0]; + }else { + instance = null ; + } + break; + case URL_RESP: + case APP_RESP: + int index=instance.indexOf("//")+2; + String temp=instance.substring(index); + if(temp.indexOf("/")>-1) { + instance = instance.substring(0,temp.indexOf("/")+index); + } + break; + case SERVER_RESP: + case JVM: + break; + case PROC_STATE: + case HOST_STATE: + default: + instance = null; + break; + + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ProcExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ProcExprAdaptor.java new file mode 100644 index 00000000..2254e8e4 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ProcExprAdaptor.java @@ -0,0 +1,103 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; +import com.creditease.uav.cache.api.CacheManager; +import com.creditease.uav.feature.RuntimeNotifyCatcher; +import com.creditease.uav.feature.runtimenotify.Slice; +import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; + +/** + * ProcExprAdaptor description: for PROC_STATE expr's adaption + * + */ +public class ProcExprAdaptor extends AbstractExprAdaptor{ + + private CacheManager cm; + + public ProcExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + + cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); + + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case CLIENT_RESP: + String pid = getPidFromCache(instance,type); + if (pid!=null) { + instance = instance.substring(0,instance.indexOf(":")); + instance = instance+"_*_"+pid; + }else { + instance =null; + } + break; + case URL_RESP: + case APP_RESP: + case SERVER_RESP: + case JVM: + pid = getPidFromCache(instance,type); + if (pid!=null) { + instance = instance.substring(instance.indexOf("//") + 2, instance.lastIndexOf(":")); + instance = instance+"_*_"+pid; + }else { + instance =null; + } + break; + case PROC_STATE: + instance = instance+"*"; + break; + case HOST_STATE: + default: + instance = null; + break; + } + + return instance; + } + + private String getPidFromCache(String instance, String type) { + + if(CLIENT_RESP.equals(type)) { + instance = "client@"+type+"@"+instance; + } + else{ + instance = "server@"+type+"@"+instance; + } + + String cacheKey = "SLICE_" + instance + "_"; + + for (int index = 0; index < 60; index++) { + String result = cm.lpop(RuntimeNotifyStrategyMgr.UAV_CACHE_REGION, cacheKey + index); + if (result != null) { + Slice s = new Slice(result); + return (String) s.getArgs().get("pid"); + } + } + + return null; + } +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ServerExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ServerExprAdaptor.java new file mode 100644 index 00000000..f5f4b08d --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/ServerExprAdaptor.java @@ -0,0 +1,71 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * ServerExprAdaptor description: for SERVER_RESP expr's adaption + * + */ +public class ServerExprAdaptor extends AbstractExprAdaptor{ + + + public ServerExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case CLIENT_RESP: + String[] strs=instance.split("#"); + if(strs.length==3) { + instance = "http://"+strs[0]; + }else { + instance = null ; + } + break; + case URL_RESP: + case APP_RESP: + int index=instance.indexOf("//")+2; + String temp=instance.substring(index); + if(temp.indexOf("/")>-1) { + instance = instance.substring(0,temp.indexOf("/")+index); + } + break; + case SERVER_RESP: + case JVM: + break; + case PROC_STATE: + case HOST_STATE: + default: + instance = null; + break; + + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/UrlExprAdaptor.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/UrlExprAdaptor.java new file mode 100644 index 00000000..25849de7 --- /dev/null +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/expradaptors/UrlExprAdaptor.java @@ -0,0 +1,57 @@ +/*- + * << + * UAVStack + * == + * Copyright (C) 2016 - 2017 UAVStack + * == + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * >> + */ + +package com.creditease.uav.feature.runtimenotify.expradaptors; + +import com.creditease.agent.spi.IActionEngine; + +/** + * UrlExprAdaptor description: for URL_RESP expr's adaption + * + */ +public class UrlExprAdaptor extends AbstractExprAdaptor{ + + + public UrlExprAdaptor(String cName, String feature, IActionEngine engine) { + + super(cName, feature, engine); + } + + @Override + public String convertInstance(String instance, String type) { + + switch (type) { + case URL_RESP: + break; + case CLIENT_RESP: + case APP_RESP: + case SERVER_RESP: + case JVM: + case PROC_STATE: + case HOST_STATE: + default: + instance = null; + break; + } + + return instance; + } + +} diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/TimerNotifyWorker.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/TimerNotifyWorker.java index 189a7ee2..772e1d9f 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/TimerNotifyWorker.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/scheduler/TimerNotifyWorker.java @@ -27,7 +27,7 @@ import com.creditease.uav.feature.RuntimeNotifyCatcher; import com.creditease.uav.feature.runtimenotify.NotifyStrategy; import com.creditease.uav.feature.runtimenotify.task.JudgeNotifyTask; -import com.creditease.uav.feature.runtimenotify.task.JudgeNotifyTimerTask; +import com.creditease.uav.feature.runtimenotify.task.JudgeNotifyTaskForTimer; /** * @@ -56,7 +56,7 @@ public void run() { } I1NQueueWorker n1nqw = get1NQueueWorkerMgr().getQueueWorker(this.feature, RuntimeNotifyCatcher.QWORKER_NAME); - n1nqw.put(new JudgeNotifyTimerTask(JudgeNotifyTask.class.getSimpleName(), feature, + n1nqw.put(new JudgeNotifyTaskForTimer(JudgeNotifyTask.class.getSimpleName(), feature, System.currentTimeMillis(), stra)); } diff --git a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java similarity index 89% rename from com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java rename to com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java index 3497b89e..ad1cad4c 100644 --- a/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTimerTask.java +++ b/com.creditease.uav.healthmanager/src/main/java/com/creditease/uav/feature/runtimenotify/task/JudgeNotifyTaskForTimer.java @@ -38,7 +38,7 @@ import com.creditease.uav.feature.runtimenotify.StrategyJudgement; import com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr; -public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { +public class JudgeNotifyTaskForTimer extends JudgeNotifyCommonTask { private NotifyStrategy stra; private long taskStart = System.currentTimeMillis(); @@ -47,10 +47,10 @@ public class JudgeNotifyTimerTask extends JudgeNotifyCommonTask { private static final long LOCK_TIMEOUT = 60 * 1000; private CacheManager cm; - public JudgeNotifyTimerTask(String name, String feature, long judge_time, NotifyStrategy stra) { + public JudgeNotifyTaskForTimer(String name, String feature, long judge_time, NotifyStrategy stra) { super(name, feature); this.stra = stra; - this.judge_time = judge_time - judge_time % 60000; + this.judge_time = judge_time; cm = (CacheManager) this.getConfigManager().getComponent(feature, RuntimeNotifyCatcher.CACHE_MANAGER_NAME); } @@ -64,6 +64,12 @@ public void run() { if (!lock.getLock()) { return; } + + //get the type of source instance,like 'hostState'.For convert it to another type's instance + String instType = stra.getName().substring(stra.getName().indexOf('@') + 1, stra.getName().lastIndexOf('@')); + + long judge_time_minute = judge_time - judge_time % 60000; + /** * Step 1:find out instance */ @@ -75,10 +81,18 @@ public void run() { StrategyJudgement judgement = (StrategyJudgement) getConfigManager().getComponent(feature, "StrategyJudgement"); - Slice slice = new Slice(instance, judge_time); + /** + * we add "_" to the end of each instance in hostState strategy for stream judge, we should remove it in timer judge. + */ + if(instance.endsWith("_")) { + instance = instance.substring(0,instance.length()-1); + } + + Slice slice = new Slice(instance, judge_time_minute); Map args = new HashMap(); // 标识该slice由TimerTask创建,为同环比创建,非流式计算创建 args.put("creater", "timer"); + args.put("instType", instType); slice.setArgs(args); Map result = judgement.judge(slice, stra, null); From 7cec83c8911d4446a9bb5b6d7b27135822a0e357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B0=B8=E5=BD=AA?= Date: Wed, 23 May 2018 13:54:39 +0800 Subject: [PATCH 88/97] =?UTF-8?q?https://github.com/uavorg/uavstack/issues?= =?UTF-8?q?/286=201.=E6=9F=A5=E8=AF=A2=E7=9A=84=E9=A2=84=E8=AD=A6=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=9C=A8=E2=80=9C=E6=9D=A5=E6=BA=90=E2=80=9D=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E6=B7=BB=E5=8A=A0=E6=8A=A5=E8=AD=A6=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=202.=E6=8A=A5=E8=AD=A6=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E2=80=9C=E9=97=AE=E9=A2=98=E6=8F=8F=E8=BF=B0=E2=80=9D?= =?UTF-8?q?=E4=B8=8A=E6=96=B9=E6=B7=BB=E5=8A=A0=E6=8A=A5=E8=AD=A6=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E6=8F=8F=E8=BF=B0=203.=E5=AE=9E=E6=97=B6=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E5=BC=82=E5=B8=B8=E6=97=B6=E5=9C=A8log=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=A6=E5=8F=91=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E7=AD=96=E7=95=A5=E6=8F=8F=E8=BF=B0=E5=92=8C?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E7=AD=96=E7=95=A5name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notifymgr/js/notify.desc.temp.js | 4 +- .../notifystgy/js/notifystgy.win.js | 6 +- .../config/JTAmail.template | 17 +- .../config/mail.template | 17 +- .../feature/runtimenotify/NotifyStrategy.java | 302 +++++++++++------- .../runtimenotify/StrategyJudgement.java | 10 +- .../scheduler/NodeInfoWatcher.java | 1 + .../scheduler/RuntimeNotifyStrategyMgr.java | 4 +- .../runtimenotify/task/JudgeNotifyTask.java | 9 +- .../task/JudgeNotifyTaskForTimer.java | 4 +- .../actions/AbstractMailAction.java | 2 + 11 files changed, 230 insertions(+), 146 deletions(-) diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifymgr/js/notify.desc.temp.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifymgr/js/notify.desc.temp.js index 324c7d36..4dfc54ce 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifymgr/js/notify.desc.temp.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifymgr/js/notify.desc.temp.js @@ -72,8 +72,9 @@ function loadDescDiv(appendId,datas){ "viewTs":{"n":"预警浏览时间","v":obj['view_ts'] ? TimeHelper.getTime(obj['view_ts'],'FMS'): ""}, "nodename":{"n":"UAV节点进程","v":obj['args']['nodename']}, "nodeuuid":{"n":"UAV节点ID","v":obj['args']['nodeuuid']}, - "component":{"n":"报警组件","v":obj['args']['component']}, + "component":{"n":"报警组件","v":obj['args']['component']}, "feature":{"n":"报警组件Feature","v":obj['args']['feature']}, + "strategydesc":{"n":"报警策略","v":obj['args']['strategydesc']}, "desc":{"n":"问题描述","v":obj['description']} }; @@ -98,6 +99,7 @@ function loadDescDiv(appendId,datas){ sb.append( "
  • 来源
  • "); sb.append("
  • "+objattr.nodename.n+""+objattr.nodename.v+"("+objattr.nodeuuid.v+")
  • "); sb.append( "
  • "+objattr.component.n+""+objattr.feature.v+"."+objattr.component.v+"
  • "); + sb.append( "
  • "+objattr.strategydesc.n+""+objattr.strategydesc.v+"
  • "); sb.append( "
  • "+objattr.desc.n+"
    "+issueDesc+"
  • "); sb.append( "
    " /*用于后续扩充收缩功能*/); sb.append( "
  • 上下文信息
  • "); diff --git a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js index 9b75f4e2..d056403d 100644 --- a/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js +++ b/com.creditease.uav.console/src/main/webapp/uavapp_godeye/notifystgy/js/notifystgy.win.js @@ -156,7 +156,7 @@ function showAddDiv() { sb.append( '
    '); - sb.append( '
    '); + sb.append( '
    '); sb.append( '
    '); sb.append( '
    条件定义
    '); @@ -320,9 +320,9 @@ function showEditNotifyDiv(jsonObjParam,isCopy) { sb.append( '
    '); if(isOwner){ - sb.append( '
    '); + sb.append( '
    '); }else{ - sb.append( '
    '); + sb.append( '
    '); } /** diff --git a/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template b/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template index 304d2689..46539f95 100644 --- a/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template +++ b/com.creditease.uav.healthmanager.buildComponent/config/JTAmail.template @@ -34,7 +34,17 @@ #timeFlag# - +
  • + + 报警策略 + + + : + + + #strategydesc# + +
  • 问题描述 @@ -88,10 +98,7 @@
  • - ©2016-2017 宜信技术研发中心 -
    -
    - 智能微服务团队 + ©2016-2018 UAVStack
    - ©2016 宜信技术研发中心 -
    -
    - 智能微服务团队 + ©2016-2018 UAVStack