Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhj-report
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
data-spider
zhj-report
Commits
38691261
Commit
38691261
authored
Feb 25, 2020
by
data爬虫-冯 军凯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
中互金项目支持eureka平滑下线
parent
de1ad45f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
CheckController.java
src/main/java/com/controller/CheckController.java
+68
-0
DiscoveryManagerController.java
src/main/java/com/controller/DiscoveryManagerController.java
+44
-0
No files found.
src/main/java/com/controller/CheckController.java
0 → 100644
View file @
38691261
package
com
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.ImmutableMap
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @Author fengjunkai
*/
@Slf4j
@RestController
@RequestMapping
(
"/"
)
public
class
CheckController
{
private
static
Map
<
String
,
String
>
map
=
new
ConcurrentHashMap
<>();
@ResponseBody
@RequestMapping
(
value
=
"check"
)
public
ResponseEntity
<
String
>
check
(){
if
(
map
!=
null
&&
map
.
size
()>
0
){
return
new
ResponseEntity
<
String
>(
HttpStatus
.
NOT_FOUND
);
}
else
{
return
new
ResponseEntity
<
String
>(
HttpStatus
.
OK
);
}
}
@ResponseBody
@RequestMapping
(
value
=
"/online"
)
public
Map
<
String
,
String
>
online
(){
log
.
info
(
"应用上线,流量开始切入...."
);
map
.
clear
();
return
responseOk
();
}
@ResponseBody
@RequestMapping
(
value
=
"/offline"
)
public
Map
<
String
,
String
>
offline
(){
log
.
info
(
"应用下线,流量不再切入...."
);
map
.
put
(
"status"
,
"offline"
);
return
responseOk
();
}
@ResponseBody
@RequestMapping
(
value
=
"/test"
)
public
Map
<
String
,
String
>
test
()
{
log
.
info
(
"CheckController测试!map = {}"
,
map
);
return
ImmutableMap
.
of
(
"code"
,
"0"
,
"msg"
,
JSON
.
toJSONString
(
map
));
}
public
static
Map
<
String
,
String
>
responseOk
()
{
return
ImmutableMap
.
of
(
"code"
,
"0"
,
"msg"
,
"ok"
);
}
@RequestMapping
(
"/getuuid"
)
public
String
getUuid
(
String
param
){
return
UUID
.
nameUUIDFromBytes
(
param
.
getBytes
()).
toString
();
}
}
src/main/java/com/controller/DiscoveryManagerController.java
0 → 100644
View file @
38691261
package
com
.
controller
;
import
com.netflix.discovery.EurekaClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Author fengjunkai
*/
@Slf4j
@RestController
@RequestMapping
(
"/"
)
public
class
DiscoveryManagerController
{
@Autowired
@Qualifier
(
"eurekaClient"
)
private
EurekaClient
eurekaClient
;
@RequestMapping
(
"clientShutdown"
)
public
void
clientShutdown
(){
try
{
eurekaClient
.
shutdown
();
log
.
info
(
"百行报送项目通知eureka下线成功"
);
}
catch
(
Exception
e
){
log
.
error
(
"百行报送项目通知eureka下线异常"
,
e
);
}
}
@RequestMapping
(
"test1"
)
public
String
test
(){
try
{
log
.
info
(
"开始执行"
);
Thread
.
sleep
(
10000
);
log
.
info
(
"执行结束"
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
"hello world !!!"
;
}
}
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