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
f2803837
Commit
f2803837
authored
Jun 28, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试用例,增加Route接口
parent
57562afd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/controller/DiscoveryController.java
+13
-7
No files found.
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/controller/DiscoveryController.java
View file @
f2803837
...
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.example.controller;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -32,10 +33,10 @@ public class DiscoveryController {
private
RestTemplate
restTemplate
;
@Value
(
"${"
+
PluginConstant
.
SPRING_APPLICATION_NAME
+
"}"
)
private
String
s
erviceId
;
private
String
aS
erviceId
;
@Value
(
"${"
+
PluginConstant
.
EUREKA_METADATA_VERSION
+
"}"
)
private
String
e
urekaVersion
;
private
String
aE
urekaVersion
;
@RequestMapping
(
path
=
"/instances"
,
method
=
RequestMethod
.
GET
)
public
List
<
ServiceInstance
>
instances
()
{
...
...
@@ -51,13 +52,18 @@ public class DiscoveryController {
List
<
ServiceInstance
>
bInstances
=
instances
();
// 获取C服务的实例列表
List
<
ServiceInstance
>
cInstances
=
(
List
<
ServiceInstance
>)
restTemplate
.
getForEntity
(
"http://discovery-springcloud-example-b/instances"
,
List
.
class
);
List
<
Map
<
String
,
?>>
cInstances
=
restTemplate
.
getForEntity
(
"http://discovery-springcloud-example-b/instances"
,
List
.
class
).
getBody
(
);
String
aInfo
=
aServiceId
.
toLowerCase
()
+
"["
+
aEurekaVersion
+
"]"
;
for
(
ServiceInstance
bInstance
:
bInstances
)
{
String
aInfo
=
serviceId
+
"["
+
eurekaVersion
+
"]"
;
String
bInfo
=
bInstance
.
getServiceId
()
+
"["
+
bInstance
.
getMetadata
().
get
(
PluginConstant
.
EUREKA_METADATA_VERSION
)
+
"]"
;
for
(
ServiceInstance
cInstance
:
cInstances
)
{
String
cInfo
=
cInstance
.
getServiceId
()
+
"["
+
cInstance
.
getMetadata
().
get
(
PluginConstant
.
EUREKA_METADATA_VERSION
)
+
"]"
;
String
bServiceId
=
bInstance
.
getServiceId
().
toLowerCase
();
String
bEurekaVersion
=
bInstance
.
getMetadata
().
get
(
PluginConstant
.
VERSION
);
String
bInfo
=
bServiceId
+
"["
+
bEurekaVersion
+
"]"
;
for
(
Map
<
String
,
?>
cInstance
:
cInstances
)
{
String
cServiceId
=
cInstance
.
get
(
"serviceId"
).
toString
().
toLowerCase
();
String
cEurekaVersion
=
((
Map
<
String
,
String
>)
cInstance
.
get
(
"metadata"
)).
get
(
PluginConstant
.
VERSION
);
String
cInfo
=
cServiceId
+
"["
+
cEurekaVersion
+
"]"
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
routes
.
add
(
stringBuilder
.
append
(
aInfo
).
append
(
"->"
).
append
(
bInfo
).
append
(
"->"
).
append
(
cInfo
).
toString
());
}
...
...
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