Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
2f47610f
Unverified
Commit
2f47610f
authored
Apr 05, 2022
by
aiwenmo
Committed by
GitHub
Apr 05, 2022
Browse files
Options
Browse Files
Download
Plain Diff
[Fix-347] [alert] Fix to the latest configuration take effect during …
[Fix-347] [alert] Fix to the latest configuration take effect during …
parents
574c7403
3ff5d3f3
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
32 deletions
+33
-32
AlertInstanceController.java
...in/java/com/dlink/controller/AlertInstanceController.java
+4
-5
AlertInstanceService.java
...src/main/java/com/dlink/service/AlertInstanceService.java
+1
-1
AlertInstanceServiceImpl.java
...java/com/dlink/service/impl/AlertInstanceServiceImpl.java
+8
-15
Alert.java
...dlink-alert-base/src/main/java/com/dlink/alert/Alert.java
+9
-0
DingTalkForm.tsx
...k-web/src/pages/AlertInstance/components/DingTalkForm.tsx
+2
-2
EmailForm.tsx
dlink-web/src/pages/AlertInstance/components/EmailForm.tsx
+3
-3
FeiShuForm.tsx
dlink-web/src/pages/AlertInstance/components/FeiShuForm.tsx
+3
-3
WeChatForm.tsx
dlink-web/src/pages/AlertInstance/components/WeChatForm.tsx
+3
-3
No files found.
dlink-admin/src/main/java/com/dlink/controller/AlertInstanceController.java
View file @
2f47610f
...
@@ -7,7 +7,9 @@ import com.dlink.common.result.Result;
...
@@ -7,7 +7,9 @@ import com.dlink.common.result.Result;
import
com.dlink.model.AlertInstance
;
import
com.dlink.model.AlertInstance
;
import
com.dlink.service.AlertInstanceService
;
import
com.dlink.service.AlertInstanceService
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -93,14 +95,11 @@ public class AlertInstanceController {
...
@@ -93,14 +95,11 @@ public class AlertInstanceController {
*/
*/
@PostMapping
(
"/sendTest"
)
@PostMapping
(
"/sendTest"
)
public
Result
sendTest
(
@RequestBody
AlertInstance
alertInstance
)
throws
Exception
{
public
Result
sendTest
(
@RequestBody
AlertInstance
alertInstance
)
throws
Exception
{
AlertResult
alertResult
=
alertInstanceService
.
getAlerTesttResul
t
(
alertInstance
);
AlertResult
alertResult
=
alertInstanceService
.
testAler
t
(
alertInstance
);
if
(
alertResult
.
getSuccess
())
{
if
(
alertResult
.
getSuccess
())
{
return
Result
.
succeed
(
"发送成功"
);
return
Result
.
succeed
(
"发送成功"
);
}
else
{
}
else
{
return
Result
.
failed
(
"发送失败"
);
return
Result
.
failed
(
"发送失败"
);
}
}
}
}
}
}
dlink-admin/src/main/java/com/dlink/service/AlertInstanceService.java
View file @
2f47610f
...
@@ -16,5 +16,5 @@ public interface AlertInstanceService extends ISuperService<AlertInstance> {
...
@@ -16,5 +16,5 @@ public interface AlertInstanceService extends ISuperService<AlertInstance> {
List
<
AlertInstance
>
listEnabledAll
();
List
<
AlertInstance
>
listEnabledAll
();
AlertResult
getAlerTesttResul
t
(
AlertInstance
alertInstance
);
AlertResult
testAler
t
(
AlertInstance
alertInstance
);
}
}
dlink-admin/src/main/java/com/dlink/service/impl/AlertInstanceServiceImpl.java
View file @
2f47610f
...
@@ -7,6 +7,7 @@ import com.dlink.mapper.AlertInstanceMapper;
...
@@ -7,6 +7,7 @@ import com.dlink.mapper.AlertInstanceMapper;
import
com.dlink.model.AlertInstance
;
import
com.dlink.model.AlertInstance
;
import
com.dlink.service.AlertInstanceService
;
import
com.dlink.service.AlertInstanceService
;
import
com.dlink.utils.JSONUtil
;
import
com.dlink.utils.JSONUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -28,27 +29,19 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
...
@@ -28,27 +29,19 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
}
}
@Override
@Override
public
AlertResult
getAlerTesttResult
(
AlertInstance
alertInstance
)
{
public
AlertResult
testAlert
(
AlertInstance
alertInstance
)
{
AlertConfig
alertConfig
=
null
;
AlertConfig
alertConfig
=
AlertConfig
.
build
(
alertInstance
.
getName
(),
alertInstance
.
getType
(),
JSONUtil
.
toMap
(
alertInstance
.
getParams
()));
Alert
alert
=
null
;
Alert
alert
=
Alert
.
buildTest
(
alertConfig
);
if
(!
AlertPool
.
exist
(
alertInstance
.
getName
()))
{
alertConfig
=
AlertConfig
.
build
(
alertInstance
.
getName
(),
alertInstance
.
getType
(),
JSONUtil
.
toMap
(
alertInstance
.
getParams
()));
alert
=
Alert
.
build
(
alertConfig
);
AlertPool
.
push
(
alertInstance
.
getName
(),
alert
);
}
else
{
alert
=
AlertPool
.
get
(
alertInstance
.
getName
());
}
String
currentDateTime
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
Calendar
.
getInstance
().
getTime
());
String
currentDateTime
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
Calendar
.
getInstance
().
getTime
());
String
testSendMsg
=
"[{\"type\":\"Flink 实时监控\","
+
String
testSendMsg
=
"[{\"type\":\"Flink 实时监控\","
+
"\"time\":\""
+
currentDateTime
+
"\","
+
"\"time\":\""
+
currentDateTime
+
"\","
+
"\"id\":\""
+
UUID
.
randomUUID
()
+
"\","
+
"\"id\":\""
+
UUID
.
randomUUID
()
+
"\","
+
"\"name\":\"此信息仅用于测试告警信息是否发送正常 ! 请忽略此信息!\","
+
"\"name\":\"此信息仅用于测试告警信息是否发送正常 ! 请忽略此信息!\","
+
"\"status\":\"Test\","
+
"\"status\":\"Test\","
+
"\"content\" :\""
+
UUID
.
randomUUID
()
+
"\"}]"
;
"\"content\" :\""
+
UUID
.
randomUUID
()
+
"\"}]"
;
List
<
AlertMsg
>
lists
=
JSONUtil
.
toList
(
testSendMsg
,
AlertMsg
.
class
);
List
<
AlertMsg
>
lists
=
JSONUtil
.
toList
(
testSendMsg
,
AlertMsg
.
class
);
String
title
=
"任务【测试任务】:"
+
alertInstance
.
getType
()
+
" 报警 !"
;
String
title
=
"任务【测试任务】:"
+
alertInstance
.
getType
()
+
" 报警 !"
;
String
content
=
JSONUtil
.
toJsonString
(
lists
);
String
content
=
JSONUtil
.
toJsonString
(
lists
);
AlertResult
alertResult
=
alert
.
send
(
title
,
content
);
return
alert
.
send
(
title
,
content
);
return
alertResult
;
}
}
}
}
dlink-alert/dlink-alert-base/src/main/java/com/dlink/alert/Alert.java
View file @
2f47610f
package
com
.
dlink
.
alert
;
package
com
.
dlink
.
alert
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.assertion.Asserts
;
import
sun.misc.Service
;
import
sun.misc.Service
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -40,6 +41,14 @@ public interface Alert {
...
@@ -40,6 +41,14 @@ public interface Alert {
return
driver
;
return
driver
;
}
}
static
Alert
buildTest
(
AlertConfig
config
)
{
Optional
<
Alert
>
optionalDriver
=
Alert
.
get
(
config
);
if
(!
optionalDriver
.
isPresent
())
{
throw
new
AlertException
(
"不支持报警组件类型【"
+
config
.
getType
()
+
"】,请在 lib 下添加扩展依赖"
);
}
return
optionalDriver
.
get
();
}
Alert
setConfig
(
AlertConfig
config
);
Alert
setConfig
(
AlertConfig
config
);
default
boolean
canHandle
(
String
type
)
{
default
boolean
canHandle
(
String
type
)
{
...
...
dlink-web/src/pages/AlertInstance/components/DingTalkForm.tsx
View file @
2f47610f
...
@@ -42,7 +42,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -42,7 +42,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
const
sendTestForm
=
async
()
=>
{
const
sendTestForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
(
buildJSONData
(
formVals
,
fieldsValue
));
setFormVals
(
buildJSONData
(
formVals
,
fieldsValue
));
handleTest
(
{...
formVals
,
...
fieldsValue
}
);
handleTest
(
buildJSONData
(
formVals
,
fieldsValue
)
);
};
};
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
...
@@ -143,7 +143,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -143,7 +143,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
return
(
return
(
<>
<>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
type=
"primary"
danger
htmlType=
"button"
onClick=
{
sendTestForm
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
sendTestForm
()
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
完成
完成
</
Button
>
</
Button
>
...
...
dlink-web/src/pages/AlertInstance/components/EmailForm.tsx
View file @
2f47610f
...
@@ -41,8 +41,8 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -41,8 +41,8 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
const
sendTestForm
=
async
()
=>
{
const
sendTestForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
(
{...
formVals
,
...
fieldsValue
}
);
setFormVals
(
buildJSONData
(
formVals
,
fieldsValue
)
);
handleTest
(
{...
formVals
,
...
fieldsValue
}
);
handleTest
(
buildJSONData
(
formVals
,
fieldsValue
)
);
};
};
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
...
@@ -181,7 +181,7 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -181,7 +181,7 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
return
(
return
(
<>
<>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
type=
"primary"
danger
htmlType=
"button"
onClick=
{
sendTestForm
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
sendTestForm
()
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
完成
完成
</
Button
>
</
Button
>
...
...
dlink-web/src/pages/AlertInstance/components/FeiShuForm.tsx
View file @
2f47610f
...
@@ -47,8 +47,8 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -47,8 +47,8 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
const
sendTestForm
=
async
()
=>
{
const
sendTestForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
getFieldsValue
();
const
fieldsValue
=
await
form
.
getFieldsValue
();
setFormVals
(
{...
formVals
,
...
fieldsValue
}
);
setFormVals
(
buildJSONData
(
formVals
,
fieldsValue
)
);
handleTest
(
{...
formVals
,
...
fieldsValue
}
);
handleTest
(
buildJSONData
(
formVals
,
fieldsValue
)
);
};
};
const
renderContent
=
(
vals
)
=>
{
const
renderContent
=
(
vals
)
=>
{
...
@@ -152,7 +152,7 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -152,7 +152,7 @@ const FeiShuForm: React.FC<AlertInstanceFormProps> = (props) => {
return
(
return
(
<>
<>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
type=
"primary"
danger
htmlType=
"button"
onClick=
{
sendTestForm
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
sendTestForm
()
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
完成
完成
</
Button
>
</
Button
>
...
...
dlink-web/src/pages/AlertInstance/components/WeChatForm.tsx
View file @
2f47610f
...
@@ -40,8 +40,8 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -40,8 +40,8 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
};
};
const
sendTestForm
=
async
()
=>
{
const
sendTestForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
(
{...
formVals
,
...
fieldsValue
}
);
setFormVals
(
buildJSONData
(
formVals
,
fieldsValue
)
);
handleTest
(
{...
formVals
,
...
fieldsValue
}
);
handleTest
(
buildJSONData
(
formVals
,
fieldsValue
)
);
};
};
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
...
@@ -185,7 +185,7 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -185,7 +185,7 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
return
(
return
(
<>
<>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
取消
</
Button
>
<
Button
type=
"primary"
danger
htmlType=
"button"
onClick=
{
sendTestForm
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
sendTestForm
()
}
>
测试
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
完成
完成
</
Button
>
</
Button
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment