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
37890e8f
Commit
37890e8f
authored
Jul 13, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加getMetaData适配接口
parent
5d6c43fa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ConsulAdapter.java
+9
-2
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/adapter/EurekaAdapter.java
+9
-2
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ZookeeperAdapter.java
+9
-2
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/adapter/PluginAdapter.java
+4
-0
No files found.
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ConsulAdapter.java
View file @
37890e8f
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.Map
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
...
@@ -76,17 +78,22 @@ public class ConsulAdapter extends AbstractPluginAdapter {
...
@@ -76,17 +78,22 @@ public class ConsulAdapter extends AbstractPluginAdapter {
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
public
Map
<
String
,
String
>
getMetaData
(
Server
server
)
{
if
(
server
instanceof
ConsulServer
)
{
if
(
server
instanceof
ConsulServer
)
{
ConsulServer
consulServer
=
(
ConsulServer
)
server
;
ConsulServer
consulServer
=
(
ConsulServer
)
server
;
return
consulServer
.
getMetadata
()
.
get
(
PluginConstant
.
VERSION
)
;
return
consulServer
.
getMetadata
();
}
}
throw
new
PluginException
(
"Server instance isn't the type of ConsulServer"
);
throw
new
PluginException
(
"Server instance isn't the type of ConsulServer"
);
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
return
getMetaData
(
server
).
get
(
PluginConstant
.
VERSION
);
}
@Override
public
String
getLocalVersion
()
{
public
String
getLocalVersion
()
{
return
version
;
return
version
;
}
}
...
...
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/adapter/EurekaAdapter.java
View file @
37890e8f
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.Map
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
com.nepxion.discovery.plugin.framework.constant.EurekaConstant
;
import
com.nepxion.discovery.plugin.framework.constant.EurekaConstant
;
...
@@ -49,17 +51,22 @@ public class EurekaAdapter extends AbstractPluginAdapter {
...
@@ -49,17 +51,22 @@ public class EurekaAdapter extends AbstractPluginAdapter {
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
public
Map
<
String
,
String
>
getMetaData
(
Server
server
)
{
if
(
server
instanceof
DiscoveryEnabledServer
)
{
if
(
server
instanceof
DiscoveryEnabledServer
)
{
DiscoveryEnabledServer
discoveryEnabledServer
=
(
DiscoveryEnabledServer
)
server
;
DiscoveryEnabledServer
discoveryEnabledServer
=
(
DiscoveryEnabledServer
)
server
;
return
discoveryEnabledServer
.
getInstanceInfo
().
getMetadata
()
.
get
(
PluginConstant
.
VERSION
)
;
return
discoveryEnabledServer
.
getInstanceInfo
().
getMetadata
();
}
}
throw
new
PluginException
(
"Server instance isn't the type of DiscoveryEnabledServer"
);
throw
new
PluginException
(
"Server instance isn't the type of DiscoveryEnabledServer"
);
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
return
getMetaData
(
server
).
get
(
PluginConstant
.
VERSION
);
}
@Override
public
String
getLocalVersion
()
{
public
String
getLocalVersion
()
{
return
pluginContextAware
.
getEnvironment
().
getProperty
(
EurekaConstant
.
METADATA_VERSION
);
return
pluginContextAware
.
getEnvironment
().
getProperty
(
EurekaConstant
.
METADATA_VERSION
);
}
}
...
...
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ZookeeperAdapter.java
View file @
37890e8f
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.Map
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.zookeeper.discovery.ZookeeperServer
;
import
org.springframework.cloud.zookeeper.discovery.ZookeeperServer
;
...
@@ -45,17 +47,22 @@ public class ZookeeperAdapter extends AbstractPluginAdapter {
...
@@ -45,17 +47,22 @@ public class ZookeeperAdapter extends AbstractPluginAdapter {
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
public
Map
<
String
,
String
>
getMetaData
(
Server
server
)
{
if
(
server
instanceof
ZookeeperServer
)
{
if
(
server
instanceof
ZookeeperServer
)
{
ZookeeperServer
zookeeperServer
=
(
ZookeeperServer
)
server
;
ZookeeperServer
zookeeperServer
=
(
ZookeeperServer
)
server
;
return
zookeeperServer
.
getInstance
().
getPayload
().
getMetadata
()
.
get
(
PluginConstant
.
VERSION
)
;
return
zookeeperServer
.
getInstance
().
getPayload
().
getMetadata
();
}
}
throw
new
PluginException
(
"Server instance isn't the type of ZookeeperServer"
);
throw
new
PluginException
(
"Server instance isn't the type of ZookeeperServer"
);
}
}
@Override
@Override
public
String
getServerVersion
(
Server
server
)
{
return
getMetaData
(
server
).
get
(
PluginConstant
.
VERSION
);
}
@Override
public
String
getLocalVersion
()
{
public
String
getLocalVersion
()
{
return
pluginContextAware
.
getEnvironment
().
getProperty
(
ZookeeperConstant
.
METADATA_VERSION
);
return
pluginContextAware
.
getEnvironment
().
getProperty
(
ZookeeperConstant
.
METADATA_VERSION
);
}
}
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/adapter/PluginAdapter.java
View file @
37890e8f
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
...
@@ -9,6 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.Map
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.Server
;
...
@@ -20,6 +22,8 @@ public interface PluginAdapter {
...
@@ -20,6 +22,8 @@ public interface PluginAdapter {
int
getPort
(
Registration
registration
);
int
getPort
(
Registration
registration
);
Map
<
String
,
String
>
getMetaData
(
Server
server
);
String
getServerVersion
(
Server
server
);
String
getServerVersion
(
Server
server
);
String
getVersion
();
String
getVersion
();
...
...
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