Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
a20592a4
Commit
a20592a4
authored
Aug 18, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增强多数据源数据库灰度发布的界面显示
parent
32983ad4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
discovery-common/src/main/java/com/nepxion/discovery/common/entity/RouterEntity.java
+10
-0
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/RouterTopology.java
+9
-0
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/RouterEndpoint.java
+23
-0
discovery-springcloud-example-service/src/main/resources/rule.xml
+5
-3
No files found.
discovery-common/src/main/java/com/nepxion/discovery/common/entity/RouterEntity.java
View file @
a20592a4
...
@@ -12,6 +12,7 @@ package com.nepxion.discovery.common.entity;
...
@@ -12,6 +12,7 @@ package com.nepxion.discovery.common.entity;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
...
@@ -26,6 +27,7 @@ public class RouterEntity implements Serializable {
...
@@ -26,6 +27,7 @@ public class RouterEntity implements Serializable {
private
String
host
;
private
String
host
;
private
int
port
;
private
int
port
;
private
int
weight
=
-
1
;
private
int
weight
=
-
1
;
private
Map
<
String
,
String
>
customMap
;
private
String
contextPath
;
private
String
contextPath
;
private
List
<
RouterEntity
>
nexts
=
new
ArrayList
<
RouterEntity
>();
private
List
<
RouterEntity
>
nexts
=
new
ArrayList
<
RouterEntity
>();
...
@@ -70,6 +72,14 @@ public class RouterEntity implements Serializable {
...
@@ -70,6 +72,14 @@ public class RouterEntity implements Serializable {
this
.
weight
=
weight
;
this
.
weight
=
weight
;
}
}
public
Map
<
String
,
String
>
getCustomMap
()
{
return
customMap
;
}
public
void
setCustomMap
(
Map
<
String
,
String
>
customMap
)
{
this
.
customMap
=
customMap
;
}
public
String
getContextPath
()
{
public
String
getContextPath
()
{
return
contextPath
;
return
contextPath
;
}
}
...
...
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/RouterTopology.java
View file @
a20592a4
...
@@ -19,6 +19,7 @@ import java.awt.event.HierarchyEvent;
...
@@ -19,6 +19,7 @@ import java.awt.event.HierarchyEvent;
import
java.awt.event.ItemEvent
;
import
java.awt.event.ItemEvent
;
import
java.awt.event.ItemListener
;
import
java.awt.event.ItemListener
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
javax.swing.Box
;
import
javax.swing.Box
;
import
javax.swing.DefaultComboBoxModel
;
import
javax.swing.DefaultComboBoxModel
;
...
@@ -29,6 +30,7 @@ import javax.swing.JSlider;
...
@@ -29,6 +30,7 @@ import javax.swing.JSlider;
import
javax.swing.JToolBar
;
import
javax.swing.JToolBar
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.nepxion.cots.twaver.element.TElementManager
;
import
com.nepxion.cots.twaver.element.TElementManager
;
...
@@ -203,6 +205,13 @@ public class RouterTopology extends AbstractTopology {
...
@@ -203,6 +205,13 @@ public class RouterTopology extends AbstractTopology {
stringBuilder
.
append
(
"\n [V"
).
append
(
routerEntity
.
getVersion
()).
append
(
"]"
);
stringBuilder
.
append
(
"\n [V"
).
append
(
routerEntity
.
getVersion
()).
append
(
"]"
);
}
}
Map
<
String
,
String
>
customMap
=
routerEntity
.
getCustomMap
();
if
(
MapUtils
.
isNotEmpty
(
customMap
))
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
customMap
.
entrySet
())
{
stringBuilder
.
append
(
"\n "
).
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
entry
.
getValue
());
}
}
return
ButtonManager
.
getHtmlText
(
stringBuilder
.
toString
());
return
ButtonManager
.
getHtmlText
(
stringBuilder
.
toString
());
}
}
...
...
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/RouterEndpoint.java
View file @
a20592a4
...
@@ -38,6 +38,7 @@ import org.springframework.web.client.RestTemplate;
...
@@ -38,6 +38,7 @@ import org.springframework.web.client.RestTemplate;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.common.entity.CustomizationEntity
;
import
com.nepxion.discovery.common.entity.DiscoveryEntity
;
import
com.nepxion.discovery.common.entity.DiscoveryEntity
;
import
com.nepxion.discovery.common.entity.RouterEntity
;
import
com.nepxion.discovery.common.entity.RouterEntity
;
import
com.nepxion.discovery.common.entity.RuleEntity
;
import
com.nepxion.discovery.common.entity.RuleEntity
;
...
@@ -157,6 +158,7 @@ public class RouterEndpoint {
...
@@ -157,6 +158,7 @@ public class RouterEndpoint {
String
host
=
instance
.
getHost
();
String
host
=
instance
.
getHost
();
int
port
=
instance
.
getPort
();
int
port
=
instance
.
getPort
();
int
weight
=
getWeight
(
routeServiceId
,
version
);
int
weight
=
getWeight
(
routeServiceId
,
version
);
Map
<
String
,
String
>
customMap
=
getCustomMap
(
serviceId
);
String
contextPath
=
metadata
.
get
(
DiscoveryConstant
.
SPRING_APPLICATION_CONTEXT_PATH
);
String
contextPath
=
metadata
.
get
(
DiscoveryConstant
.
SPRING_APPLICATION_CONTEXT_PATH
);
RouterEntity
routerEntity
=
new
RouterEntity
();
RouterEntity
routerEntity
=
new
RouterEntity
();
...
@@ -165,6 +167,7 @@ public class RouterEndpoint {
...
@@ -165,6 +167,7 @@ public class RouterEndpoint {
routerEntity
.
setHost
(
host
);
routerEntity
.
setHost
(
host
);
routerEntity
.
setPort
(
port
);
routerEntity
.
setPort
(
port
);
routerEntity
.
setWeight
(
weight
);
routerEntity
.
setWeight
(
weight
);
routerEntity
.
setCustomMap
(
customMap
);
routerEntity
.
setContextPath
(
contextPath
);
routerEntity
.
setContextPath
(
contextPath
);
routerEntityList
.
add
(
routerEntity
);
routerEntityList
.
add
(
routerEntity
);
...
@@ -300,4 +303,23 @@ public class RouterEndpoint {
...
@@ -300,4 +303,23 @@ public class RouterEndpoint {
return
-
1
;
return
-
1
;
}
}
private
Map
<
String
,
String
>
getCustomMap
(
String
serviceId
)
{
RuleEntity
ruleEntity
=
pluginAdapter
.
getRule
();
if
(
ruleEntity
==
null
)
{
return
null
;
}
CustomizationEntity
customizationEntity
=
ruleEntity
.
getCustomizationEntity
();
if
(
customizationEntity
==
null
)
{
return
null
;
}
Map
<
String
,
Map
<
String
,
String
>>
customizationMap
=
customizationEntity
.
getCustomizationMap
();
if
(
MapUtils
.
isEmpty
(
customizationMap
))
{
return
null
;
}
return
customizationMap
.
get
(
serviceId
);
}
}
}
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/rule.xml
View file @
a20592a4
...
@@ -78,8 +78,9 @@
...
@@ -78,8 +78,9 @@
<!-- 客户定制化控制,由远程推送客户化参数的改变,实现一些特色化的灰度发布,例如,基于数据库的灰度发布 -->
<!-- 客户定制化控制,由远程推送客户化参数的改变,实现一些特色化的灰度发布,例如,基于数据库的灰度发布 -->
<customization>
<customization>
<!-- 服务b有两个库的配置,分别是临时数据库(database的value为temp)和生产数据库(database的value为prod) -->
<!-- 服务a和c分别有两个库的配置,分别是测试数据库(database的value为qa)和生产数据库(database的value为prod) -->
<!-- 上线后,一开始数据库指向临时数据库,对应value为temp,然后灰度发布的时候,改对应value为prod,即实现数据库的灰度发布 -->
<!-- 上线后,一开始数据库指向测试数据库,对应value为qa,然后灰度发布的时候,改对应value为prod,即实现数据库的灰度发布 -->
<service
service-name=
"discovery-springcloud-example-b"
key=
"database"
value=
"prod"
/>
<service
service-name=
"discovery-springcloud-example-a"
key=
"database"
value=
"qa"
/>
<service
service-name=
"discovery-springcloud-example-c"
key=
"database"
value=
"prod"
/>
</customization>
</customization>
</rule>
</rule>
\ 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