Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
java-devop-sentry
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
zhouzihao
java-devop-sentry
Commits
b4386d8d
Commit
b4386d8d
authored
Mar 17, 2020
by
zhouzihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev-添加配置项获取。添加失败跳过。添加说明文档
parent
0decc262
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
92 additions
and
3 deletions
+92
-3
README.md
README.md
+18
-0
pom.xml
pom.xml
+5
-0
src/main/java/com/vandyo/sentry/core/Tmp.java
src/main/java/com/vandyo/sentry/core/Tmp.java
+10
-1
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
...java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
+2
-0
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
+1
-0
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarListDecorator.java
+1
-0
src/main/java/com/vandyo/sentry/core/cases/EmptyCase.java
src/main/java/com/vandyo/sentry/core/cases/EmptyCase.java
+2
-0
src/main/java/com/vandyo/sentry/core/collectionMachine/CollectionMachine.java
...ndyo/sentry/core/collectionMachine/CollectionMachine.java
+2
-1
src/main/java/com/vandyo/sentry/core/config/MapConfig.java
src/main/java/com/vandyo/sentry/core/config/MapConfig.java
+33
-0
src/main/java/com/vandyo/sentry/core/dto/Res.java
src/main/java/com/vandyo/sentry/core/dto/Res.java
+11
-0
src/main/resources/application.yaml
src/main/resources/application.yaml
+7
-1
No files found.
README.md
0 → 100644
View file @
b4386d8d
# java-devop-sentry
# Overview
定期请求接口,检查是否成功。如果失败累计到一定程度。发送邮件(或者其他形式)
来进行提醒。
# Feature
-
正常接口请求一组的时间间隔为5秒钟(配置的),也就是一分钟请求了12次。
-
可以设置接口在时间段内出错个数。可以设置一个阈值。(建议设置成6次)。
# 项目结构
# TODO
# ChangeLog
pom.xml
View file @
b4386d8d
...
...
@@ -47,6 +47,11 @@
<artifactId>
hutool-all
</artifactId>
<version>
5.2.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
...
...
src/main/java/com/vandyo/sentry/core/Tmp.java
View file @
b4386d8d
...
...
@@ -3,9 +3,11 @@ package com.vandyo.sentry.core;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.cases.*
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.config.MapConfig
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -26,6 +28,10 @@ public class Tmp {
@Value
(
"${vandyo.pwd}"
)
public
String
pwd
;
@Autowired
private
MapConfig
mapConfig
;
@Scheduled
(
fixedRate
=
1000
)
public
void
test
()
{
log
.
info
(
"we run it {} times"
,
++
times
);
...
...
@@ -47,6 +53,9 @@ public class Tmp {
public
void
check
()
{
Map
<
String
,
Map
<
ErrStatus
,
Long
>>
data
=
CollectionMachine
.
checkRule
(
5
);
String
info
=
JSONUtil
.
parseFromMap
(
data
).
toStringPretty
();
log
.
warn
(
info
);
// log.warn(info);
// 查看是否 符合规则 Using timeMap
Map
<
String
,
Integer
>
timeMap
=
mapConfig
.
getTimeMap
();
log
.
info
(
"start to check rule!"
);
}
}
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
View file @
b4386d8d
...
...
@@ -56,12 +56,14 @@ public class CarDetectDecorator extends CaseDecorator {
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
newRes
.
setKey
(
carDetectUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
return
newRes
;
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
}
}
...
...
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
View file @
b4386d8d
...
...
@@ -60,6 +60,7 @@ public class CarInfoDecorator extends CaseDecorator {
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
}
}
...
...
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
View file @
b4386d8d
...
...
@@ -55,6 +55,7 @@ public class CarListDecorator extends CaseDecorator {
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
oldRes
.
setIgnore
(
true
);
return
oldRes
;
}
}
...
...
src/main/java/com/vandyo/sentry/core/cases/EmptyCase.java
View file @
b4386d8d
...
...
@@ -24,6 +24,8 @@ public class EmptyCase extends Case {
res
.
setSId
(
sId
);
res
.
setUId
(
uid
);
res
.
setSuccess
(
true
);
// 这里的请求结果进行跳过
res
.
setIgnore
(
true
);
CollectionMachine
.
post
(
res
);
return
res
;
}
...
...
src/main/java/com/vandyo/sentry/core/collectionMachine/CollectionMachine.java
View file @
b4386d8d
...
...
@@ -16,7 +16,7 @@ import java.util.stream.Collectors;
public
class
CollectionMachine
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Tmp
.
class
);
// 收集进来的数据 进到存储 相当于一个临时的日志
private
static
Map
<
Long
,
Res
>
temp
=
new
ConcurrentHashMap
<>(
124
);
private
static
Map
<
Long
,
Res
>
temp
=
new
ConcurrentHashMap
<>(
1
0
24
);
public
static
void
post
(
Res
<
Map
<
String
,
String
>>
log
)
{
// 应该对于不同的请求统一管理 还是 每个单独管理呢?
...
...
@@ -26,6 +26,7 @@ public class CollectionMachine {
}
else
{
if
(
temp
.
size
()
>
100
)
{
logger
.
info
(
"try to put data"
);
// 删除一分钟前的key数据
checkSize
(
1
);
}
try
{
...
...
src/main/java/com/vandyo/sentry/core/config/MapConfig.java
0 → 100644
View file @
b4386d8d
package
com
.
vandyo
.
sentry
.
core
.
config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
@ConfigurationProperties
(
prefix
=
"checkmeta"
)
@EnableConfigurationProperties
(
MapConfig
.
class
)
public
class
MapConfig
{
private
Map
<
String
,
String
>
desMap
=
new
HashMap
<>();
private
Map
<
String
,
Integer
>
timeMap
=
new
HashMap
<>();
public
Map
<
String
,
String
>
getDesMap
()
{
return
desMap
;
}
public
void
setDesMap
(
Map
<
String
,
String
>
desMap
)
{
this
.
desMap
=
desMap
;
}
public
Map
<
String
,
Integer
>
getTimeMap
()
{
return
timeMap
;
}
public
void
setTimeMap
(
Map
<
String
,
Integer
>
timeMap
)
{
this
.
timeMap
=
timeMap
;
}
}
src/main/java/com/vandyo/sentry/core/dto/Res.java
View file @
b4386d8d
...
...
@@ -29,4 +29,15 @@ public class Res<T> {
* 失败类型
*/
private
ErrStatus
status
;
/**
* 请求接口 (和配置项一样)
*/
private
String
key
;
/**
* 是否忽略请求
*/
private
Boolean
ignore
=
false
;
}
src/main/resources/application.yaml
View file @
b4386d8d
...
...
@@ -2,4 +2,10 @@ vandyo:
sid
:
38201fe198ef43b68f6bcf6101bc2970
uid
:
860a776c832749ce86754d59c7ca9fca
mobile
:
18623414467
pwd
:
5f83f54fb34e2eed0439d37d80f5b1a3
\ No newline at end of file
pwd
:
5f83f54fb34e2eed0439d37d80f5b1a3
checkmeta
:
desMap
:
"
[/car/my_car/info]"
:
车辆信息
timeMap
:
"
[/car/my_car/info]"
:
6
\ No newline at end of file
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