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
896a53f7
Commit
896a53f7
authored
Jul 28, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构测试用例
parent
f6871877
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
21 deletions
+3
-21
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/extension/MyDiscoveryEnabledAdapter.java
+1
-7
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
+1
-7
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabledAdapter.java
+1
-7
No files found.
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/extension/MyDiscoveryEnabledAdapter.java
View file @
896a53f7
...
...
@@ -14,9 +14,7 @@ import java.util.Map;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.extension.gateway.context.GatewayStrategyContext
;
import
com.netflix.loadbalancer.Server
;
...
...
@@ -24,11 +22,8 @@ import com.netflix.loadbalancer.Server;
public
class
MyDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabledAdapter
.
class
);
@Autowired
protected
PluginAdapter
pluginAdapter
;
@Override
public
boolean
apply
(
Server
server
)
{
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
GatewayStrategyContext
context
=
GatewayStrategyContext
.
getCurrentContext
();
String
token
=
context
.
getExchange
().
getRequest
().
getHeaders
().
getFirst
(
"token"
);
// String value = context.getExchange().getRequest().getQueryParams().getFirst("value");
...
...
@@ -37,7 +32,6 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
GatewayStrategyContext
.
clearCurrentContext
();
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
LOG
.
info
(
"Gateway端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
View file @
896a53f7
...
...
@@ -14,9 +14,7 @@ import java.util.Map;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.extension.service.constant.ServiceStrategyConstant
;
...
...
@@ -26,17 +24,13 @@ import com.netflix.loadbalancer.Server;
public
class
MyDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabledAdapter
.
class
);
@Autowired
protected
PluginAdapter
pluginAdapter
;
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
apply
(
Server
server
)
{
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
ServiceStrategyContext
context
=
ServiceStrategyContext
.
getCurrentContext
();
Map
<
String
,
Object
>
attributes
=
context
.
getAttributes
();
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
String
version
=
metadata
.
get
(
PluginConstant
.
VERSION
);
LOG
.
info
(
"Serivice端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
...
...
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabledAdapter.java
View file @
896a53f7
...
...
@@ -14,9 +14,7 @@ import java.util.Map;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.zuul.context.RequestContext
;
...
...
@@ -24,17 +22,13 @@ import com.netflix.zuul.context.RequestContext;
public
class
MyDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabledAdapter
.
class
);
@Autowired
protected
PluginAdapter
pluginAdapter
;
@Override
public
boolean
apply
(
Server
server
)
{
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
String
token
=
context
.
getRequest
().
getHeader
(
"token"
);
// String value = context.getRequest().getParameter("value");
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
LOG
.
info
(
"Zuul端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
...
...
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