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
37343ed9
Commit
37343ed9
authored
Feb 02, 2021
by
房斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1优化超时问题
2版本加载判断 3停机组件加载判断
parent
130068a9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
ConfigCenter.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/monitor/config/ConfigCenter.java
+13
-4
GracefulShutDown.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/service/GracefulShutDown.java
+0
-1
DubboCustomerShutDownHook.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/service/impl/DubboCustomerShutDownHook.java
+1
-1
MatrixGracefulShutDownAutoConfiguration.java
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/spring/boot/autoconfigure/MatrixGracefulShutDownAutoConfiguration.java
+9
-4
No files found.
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/monitor/config/ConfigCenter.java
View file @
37343ed9
...
...
@@ -17,8 +17,10 @@
package
com
.
secoo
.
mall
.
dubbo
.
monitor
.
config
;
import
com.secoo.mall.common.util.string.StringUtil
;
import
com.secoo.mall.dubbo.monitor.dubbo.Constants.Constants
;
import
com.secoo.mall.dubbo.monitor.dubbo.exception.ConfigurationException
;
import
io.swagger.models.auth.In
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.dubbo.common.URL
;
import
org.apache.dubbo.common.extension.ExtensionLoader
;
...
...
@@ -34,8 +36,6 @@ import org.springframework.context.annotation.Configuration;
public
class
ConfigCenter
{
public
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ConfigCenter
.
class
);
@Value
(
"${dubbo.registry.address:}"
)
public
String
registryAddress
;
@Value
(
"${dubbo.protocol.name}"
)
...
...
@@ -46,6 +46,8 @@ public class ConfigCenter {
public
String
password
;
@Value
(
"${dubbo.monitorpatch:}"
)
public
String
patch
;
@Value
(
"${dubbo.application.timeout:}"
)
public
String
timeout
;
public
URL
registryUrl
;
@Bean
...
...
@@ -55,7 +57,8 @@ public class ConfigCenter {
if
(
StringUtils
.
isBlank
(
registryAddress
))
{
throw
new
ConfigurationException
(
"Either config center or registry address is needed, please refer to https://github.com/apache/incubator-dubbo-admin/wiki/Dubbo-Admin-configuration"
);
}
registryUrl
=
formUrl
(
registryAddress
,
registryGroup
,
username
,
password
);
registryUrl
=
formUrl
(
registryAddress
,
registryGroup
,
username
,
password
,
timeout
);
// registryUrl.setPath(patch);
}
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
...
...
@@ -63,11 +66,17 @@ public class ConfigCenter {
return
registry
;
}
public
URL
formUrl
(
String
config
,
String
group
,
String
username
,
String
password
)
{
public
URL
formUrl
(
String
config
,
String
group
,
String
username
,
String
password
,
String
timeout
)
{
URL
url
=
URL
.
valueOf
(
config
);
if
(
StringUtils
.
isNotEmpty
(
group
))
{
url
=
url
.
addParameter
(
Constants
.
GROUP_KEY
,
group
);
}
if
(
StringUtil
.
isEmpty
(
timeout
)){
url
=
url
.
addParameter
(
"timeout"
,
20000
);
}
else
{
url
=
url
.
addParameter
(
"timeout"
,
Integer
.
valueOf
(
timeout
).
intValue
());
}
if
(
StringUtils
.
isNotEmpty
(
username
))
{
url
=
url
.
setUsername
(
username
);
}
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/service/GracefulShutDown.java
View file @
37343ed9
...
...
@@ -44,7 +44,6 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
public
void
run
(
String
...
args
)
throws
Exception
{
logger
.
info
(
"dddddddddddddduuuuuuuuuuuuuuuuubbbbbbbbbbbboooooooooooolllllllllll!!!!"
);
if
(
DubboShutdownHook
.
getDubboShutdownHook
()
!=
null
)
{
//TODO 判断是否dubbo组件,如果没有就不执行卸载和 shutDownhook
//hock卸载
DubboShutdownHook
.
getDubboShutdownHook
().
unregister
();
//listener 卸载
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/service/impl/DubboCustomerShutDownHook.java
View file @
37343ed9
...
...
@@ -56,7 +56,7 @@ public class DubboCustomerShutDownHook extends AbstractShutDown implements Obser
public
ExecutorDetail
stop
()
{
ExecutorDetail
detail
=
new
ExecutorDetail
();
detail
.
setBeginTime
(
DateUtil
.
getDateTime
());
detail
.
setServiceName
(
"dubboDownHock104
5
"
);
detail
.
setServiceName
(
"dubboDownHock104
6
"
);
List
<
String
>
str
=
new
ArrayList
<
String
>();
detail
.
setDetail
(
str
);
detail
.
setCode
(
0
);
...
...
matrix-gracefulshutdown/src/main/java/com/secoo/mall/dubbo/spring/boot/autoconfigure/MatrixGracefulShutDownAutoConfiguration.java
View file @
37343ed9
...
...
@@ -38,7 +38,7 @@ public class MatrixGracefulShutDownAutoConfiguration {
@DependsOn
(
"configCenter"
)
UpDatas
dubboUpdata
(
ConfigCenter
configCenter
){
ShutDownDataReport
transport
=
new
ShutDownDataReport
();
URL
url
=
configCenter
.
formUrl
(
configCenter
.
registryAddress
,
configCenter
.
registryGroup
,
configCenter
.
username
,
configCenter
.
password
);
URL
url
=
configCenter
.
formUrl
(
configCenter
.
registryAddress
,
configCenter
.
registryGroup
,
configCenter
.
username
,
configCenter
.
password
,
configCenter
.
timeout
);
transport
.
setUrl
(
url
);
if
(
StringUtil
.
isEmpty
(
configCenter
.
patch
)){
configCenter
.
patch
=
"/monitorZ"
;
...
...
@@ -75,18 +75,23 @@ public class MatrixGracefulShutDownAutoConfiguration {
}
@Bean
@ConditionalOnClass
(
TomcatConnectorCustomizer
.
class
)
@ConditionalOnClass
({
TomcatGracefulShutDown
.
class
,
org
.
apache
.
catalina
.
connector
.
Connector
.
class
})
@SpringBootVersionJudgment
()
TomcatShutDownHook
createServletConnectShoutDownHock
()
{
return
new
TomcatShutDownHook
();
}
@Bean
@ConditionalOnClass
(
TomcatShutDownHook
.
class
)
@ConditionalOnClass
(
org
.
apache
.
catalina
.
connector
.
Connector
.
class
)
@SpringBootVersionJudgment
()
public
TomcatGracefulShutDown
createSpringbootTomcatInit
(
TomcatShutDownHook
tomcatShutDownHook
){
return
new
TomcatGracefulShutDown
(
tomcatShutDownHook
);
}
@Bean
@ConditionalOnExpression
(
"!T(org.springframework.util.StringUtils).isEmpty('${dubbo.registry.address:}')"
)
public
GracefulShutDown
createGraceObject
(
UpDatas
dubboUpdata
)
{
...
...
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