Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
85baf3f0
Commit
85baf3f0
authored
Mar 12, 2021
by
房斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1找到了报zk关闭问题 2 去掉多余日志 3url改为生产得url
parent
496a4e03
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
60 deletions
+7
-60
ConfigConstant.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/ConfigConstant.java
+2
-1
GracefulShutDown.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/GracefulShutDown.java
+0
-48
ShutDownDataReportAsyncHttp.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/ShutDownDataReportAsyncHttp.java
+1
-1
TomcatGracefulShutDown.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/TomcatGracefulShutDown.java
+0
-2
DubboCustomerShutDownHook.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/hook/DubboCustomerShutDownHook.java
+2
-6
RegistryServerSync.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/monitor/dubbo/service/RegistryServerSync.java
+2
-2
No files found.
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/ConfigConstant.java
View file @
85baf3f0
...
...
@@ -3,7 +3,8 @@ package com.secoo.mall.gracefulshutdown.component;
public
class
ConfigConstant
{
// public static String EXWARN="http://172.17.76.196:6080/gracefulshutdown/gracefulSave";
public
static
String
EXWARN
=
"http://test-exwarn.secoo.com/gracefulshutdown/gracefulSave"
;
// public static String EXWARN="http://test-exwarn.secoo.com/gracefulshutdown/gracefulSave";
public
static
String
EXWARN
=
"http://exwarn.secoo.com/gracefulshutdown/gracefulSave"
;
public
static
final
int
CONNECT_TIMEOUT
=
1000
;
//连接超时时间
public
static
final
int
SOCKET_TIMEOUT
=
5000
;
//等待数据超时时间
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/GracefulShutDown.java
View file @
85baf3f0
...
...
@@ -42,7 +42,6 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
//容器初始化后执行
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
logger
.
info
(
"dddddddddddddduuuuuuuuuuuuuuuuubbbbbbbbbbbboooooooooooolllllllllllme!!!!"
);
if
(
DubboShutdownHook
.
getDubboShutdownHook
()
!=
null
)
{
//hock卸载
DubboShutdownHook
.
getDubboShutdownHook
().
unregister
();
...
...
@@ -55,56 +54,9 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
}
public
void
test
()
{
ExecutorDetails
result
=
new
ExecutorDetails
();
result
.
setCode
(
0
);
List
<
ExecutorDetail
>
details
=
new
ArrayList
<
ExecutorDetail
>();
result
.
setT
(
details
);
String
ip
=
NetUtils
.
getIpByHost
(
NetUtils
.
getLocalAddress
().
getHostName
());
String
name
=
ApplicationModel
.
getApplication
();
result
.
setIp
(
ip
);
result
.
setName
(
name
);
logger
.
info
(
"gracefulshutdown execute:name:"
+
name
+
" ip:"
+
ip
+
" time:"
+
DateUtil
.
getDateTime
());
try
{
Map
<
String
,
StopService
>
map
=
context
.
getBeansOfType
(
StopService
.
class
);
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
Set
<
StopService
>
ts
=
new
TreeSet
<
StopService
>();
for
(
StopService
service
:
map
.
values
())
{
if
(!(
service
instanceof
TomcatShutDownHook
))
{
ts
.
add
(
service
);
}
}
//按定义顺序执行
Iterator
<
StopService
>
it
=
ts
.
iterator
();
while
(
it
.
hasNext
())
{
StopService
service
=
(
StopService
)
it
.
next
();
ExecutorDetail
one
=
(
ExecutorDetail
)
service
.
stop
();
if
(
one
!=
null
)
{
details
.
add
(
one
);
if
(
one
.
getCode
()
!=
0
)
{
result
.
setCode
(-
1
);
}
}
}
}
}
catch
(
Exception
e
)
{
LoggerUtil
.
error
(
"matrix.gracefulshutdown.error"
,
e
);
}
try
{
dubboUpdata
.
upData
(
result
);
}
catch
(
Exception
e
)
{
LoggerUtil
.
error
(
"matrix.gracefulshutdown update .error data:"
+
JSON
.
toJSONString
(
result
),
e
);
}
logger
.
info
(
"gracefulshutdown execute end :name:"
+
name
+
" ip:"
+
ip
+
" time:"
+
DateUtil
.
getDateTime
());
}
@Override
public
void
onApplicationEvent
(
ContextClosedEvent
contextClosedEvent
)
{
logger
.
info
(
"222222222222222 dubbo stop"
);
ExecutorDetails
result
=
new
ExecutorDetails
();
result
.
setCode
(
0
);
List
<
ExecutorDetail
>
details
=
new
ArrayList
<
ExecutorDetail
>();
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/ShutDownDataReportAsyncHttp.java
View file @
85baf3f0
...
...
@@ -27,7 +27,7 @@ public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> {
nvps
.
add
(
new
BasicNameValuePair
(
"gracefulresult"
,
result
));
HttpClientUtils
.
setHttpParam
(
ConfigConstant
.
CONNECT_TIMEOUT
,
ConfigConstant
.
SOCKET_TIMEOUT
,
ConfigConstant
.
REQUEST_TIMEOUT
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
));
logger
.
info
(
"test in http start"
);
//
logger.info("test in http start");
String
back
=
HttpClientUtils
.
asynchronousPost
(
httpPost
);
return
true
;
}
catch
(
Exception
e
){
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/TomcatGracefulShutDown.java
View file @
85baf3f0
...
...
@@ -34,7 +34,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
context
=
applicationContext
;
logger
.
info
(
"11111111111111111111 tomcat set Application"
);
}
public
TomcatShutDownHook
getTomcatShutDownHook
()
{
return
tomcatShutDownHook
;
...
...
@@ -51,7 +50,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override
public
void
onApplicationEvent
(
ContextClosedEvent
contextClosedEvent
)
{
logger
.
info
(
"11111111111111111111 tomcat stop"
);
tomcatShutDownHook
.
stop
();
}
}
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/component/hook/DubboCustomerShutDownHook.java
View file @
85baf3f0
...
...
@@ -74,17 +74,13 @@ public class DubboCustomerShutDownHook extends AbstractShutDown implements Obser
while
(
iterator
.
hasNext
())
{
Registry
r
=
iterator
.
next
();
zookperRegster
=
(
ZookeeperRegistry
)
r
;
logger
.
info
(
" DubboCustomerShutDownHook ip:{},name :{}, zookperRegstered ,:{}"
,
ip
,
name
,
zookperRegster
.
getRegistered
().
toString
()+
StringUtil
.
line
());
//
logger.info(" DubboCustomerShutDownHook ip:{},name :{}, zookperRegstered ,:{}",ip,name,zookperRegster.getRegistered().toString()+StringUtil.line());
if
(
zookperRegster
.
getRegistered
()
!=
null
&&
zookperRegster
.
getRegistered
().
size
()
>
0
)
{
urls
=
zookperRegster
.
getRegistered
();
logger
.
info
(
" DubboCustomerShutDownHook ip:{},name :{},zookperRegstered urls :{}"
,
ip
,
name
,((
urls
!=
null
&&
urls
.
size
()>
0
)?
JSON
.
toJSONString
(
urls
):
"url si null"
)+
StringUtil
.
line
());
//
logger.info(" DubboCustomerShutDownHook ip:{},name :{},zookperRegstered urls :{}",ip,name,((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null")+StringUtil.line());
if
(
urls
!=
null
&&
urls
.
size
()
>
0
)
{
checks
=
new
ArrayList
<
URL
>();
for
(
URL
value
:
urls
)
{
if
(
value
!=
null
&&
StringUtil
.
isNotEmpty
(
value
.
getParameter
(
Constants
.
CATEGORY_KEY
))&&
value
.
getParameter
(
Constants
.
CATEGORY_KEY
).
equals
(
Constants
.
PROVIDERS_CONSUMERS
)){
logger
.
info
(
"matrix gracefulshutdown delete before service:{},category:{}"
,
value
.
getServiceKey
(),
value
.
getParameter
(
Constants
.
CATEGORY_KEY
));
//消费者不用处理,走默认优雅停机就可以
continue
;
}
checks
.
add
(
value
);
try
{
logger
.
info
(
"provider url executer ip:{},name :{} unregister before:{} time:{}"
,
ip
,
name
,
value
.
getServiceInterface
()
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss:SSS"
).
format
(
new
Date
())
+
StringUtil
.
line
());
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/gracefulshutdown/monitor/dubbo/service/RegistryServerSync.java
View file @
85baf3f0
...
...
@@ -157,10 +157,10 @@ public class RegistryServerSync extends Observable implements InitializingBean,
while
(
iterator
.
hasNext
())
{
Registry
r
=
iterator
.
next
();
zookperRegster
=
(
ZookeeperRegistry
)
r
;
logger
.
info
(
"RegistryServerSync r-------------->"
+
zookperRegster
.
getRegistered
().
toString
());
//
logger.info("RegistryServerSync r-------------->"+zookperRegster.getRegistered().toString());
if
(
zookperRegster
.
getRegistered
()
!=
null
&&
zookperRegster
.
getRegistered
().
size
()
>
0
)
{
urls
=
zookperRegster
.
getRegistered
();
logger
.
info
(
"RegistryServerSync urls-------------->"
+((
urls
!=
null
&&
urls
.
size
()>
0
)?
JSON
.
toJSONString
(
urls
):
"url si null"
));
//
logger.info("RegistryServerSync urls-------------->"+((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null"));
if
(
urls
!=
null
&&
urls
.
size
()
>
0
)
{
subscribedUrl
=
new
ArrayList
<
URL
>();
for
(
URL
value:
urls
){
...
...
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