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
d0f069c4
Commit
d0f069c4
authored
Jul 01, 2019
by
陈文顺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apollo 配置
parent
33f9833c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
244 additions
and
379 deletions
+244
-379
discovery-springcloud-example-console/pom.xml
+4
-4
discovery-springcloud-example-console/src/main/resources/bootstrap.properties
+5
-5
discovery-springcloud-example-service/pom.xml
+4
-4
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA1.java
+3
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA2.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB1.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB2.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC1.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC2.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC3.java
+1
-0
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/ARestImpl.java
+39
-5
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/BRestImpl.java
+1
-1
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/CRestImpl.java
+1
-1
discovery-springcloud-example-service/src/main/resources/application-a1.properties
+21
-14
discovery-springcloud-example-service/src/main/resources/application-a2.properties
+21
-14
discovery-springcloud-example-service/src/main/resources/application-b1.properties
+20
-13
discovery-springcloud-example-service/src/main/resources/application-b2.properties
+9
-2
discovery-springcloud-example-service/src/main/resources/application-c1.properties
+21
-13
discovery-springcloud-example-service/src/main/resources/bootstrap.properties
+2
-4
discovery-springcloud-example-service/src/main/resources/rule.json
+0
-131
discovery-springcloud-example-service/src/main/resources/rule.xml
+0
-107
discovery-springcloud-example-zuul/pom.xml
+4
-4
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul.java
+2
-1
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul2.java
+40
-0
discovery-springcloud-example-zuul/src/main/resources/application-g2.properties
+27
-0
discovery-springcloud-example-zuul/src/main/resources/application.properties
+13
-12
discovery-springcloud-example-zuul/src/main/resources/bootstrap.properties
+1
-1
discovery-springcloud-example-zuul/src/main/resources/rule.json
+0
-31
discovery-springcloud-example-zuul/src/main/resources/rule.xml
+0
-12
No files found.
discovery-springcloud-example-console/pom.xml
View file @
d0f069c4
...
...
@@ -59,18 +59,18 @@
<dependencies>
<dependency>
<groupId>
com.nepxion
</groupId>
<!-- <artifactId>discovery-console-starter-apollo</artifactId> --
>
<
artifactId>
discovery-console-starter-nacos
</artifactId
>
<artifactId>
discovery-console-starter-apollo
</artifactId
>
<
!--<artifactId>discovery-console-starter-nacos</artifactId>--
>
<!-- <artifactId>discovery-console-starter-redis</artifactId> -->
<version>
${discovery.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> --
>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId
>
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId> -->
<!-- <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> -->
<
artifactId>
spring-cloud-starter-alibaba-nacos-discovery
</artifactId
>
<
!--<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>--
>
</dependency>
<dependency>
...
...
discovery-springcloud-example-console/src/main/resources/bootstrap.properties
View file @
d0f069c4
...
...
@@ -16,7 +16,7 @@ spring.cloud.zookeeper.discovery.root=/spring-cloud-service
spring.cloud.zookeeper.discovery.preferIpAddress
=
true
# Nacos config for discovery
spring.cloud.nacos.discovery.server-addr
=
localhost:8848
spring.cloud.nacos.discovery.server-addr
=
111.231.12.200:9010
# spring.cloud.nacos.discovery.namespace=discovery
# Ribbon config
...
...
@@ -24,18 +24,18 @@ ribbon.ConnectTimeout=60000
ribbon.ReadTimeout
=
60000
# Apollo config for rule
apollo.portal-url
=
http://
localhost:808
8
apollo.token
=
b26d851c635fd51ae21981443d7aa75f14d99e4e
apollo.portal-url
=
http://
129.211.152.12
8
apollo.token
=
cd415f8abe42c880b9f881bccc888410b3a1081d
apollo.operator
=
apollo
# apollo.connect-timeout=1000
# apollo.read-timeout=5000
apollo.plugin.app.id
=
discovery
apollo.plugin.env
=
DEV
# apollo.plugin.cluster=default
# apollo.plugin.namespace=application
apollo.plugin.namespace
=
architect.gray.rule
# Nacos config for rule
nacos.server-addr
=
localhost:8848
nacos.server-addr
=
111.231.12.200:9010
# nacos.plugin.namespace=application
# Redis config for rule
...
...
discovery-springcloud-example-service/pom.xml
View file @
d0f069c4
...
...
@@ -59,17 +59,17 @@
<dependencies>
<dependency>
<groupId>
com.nepxion
</groupId>
<!-- <artifactId>discovery-plugin-starter-eureka</artifactId> --
>
<artifactId>
discovery-plugin-starter-eureka
</artifactId
>
<!-- <artifactId>discovery-plugin-starter-consul</artifactId> -->
<!-- <artifactId>discovery-plugin-starter-zookeeper</artifactId> -->
<
artifactId>
discovery-plugin-starter-nacos
</artifactId
>
<
!--<artifactId>discovery-plugin-starter-nacos</artifactId>--
>
<version>
${discovery.version}
</version>
</dependency>
<dependency>
<groupId>
com.nepxion
</groupId>
<!-- <artifactId>discovery-plugin-config-center-starter-apollo</artifactId> --
>
<
artifactId>
discovery-plugin-config-center-starter-nacos
</artifactId
>
<artifactId>
discovery-plugin-config-center-starter-apollo
</artifactId
>
<
!--<artifactId>discovery-plugin-config-center-starter-nacos</artifactId>--
>
<!-- <artifactId>discovery-plugin-config-center-starter-redis</artifactId> -->
<version>
${discovery.version}
</version>
</dependency>
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA1.java
View file @
d0f069c4
...
...
@@ -9,6 +9,7 @@ package com.nepxion.discovery.plugin.example.service;
* @version 1.0
*/
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
...
...
@@ -34,9 +35,11 @@ import com.nepxion.discovery.plugin.strategy.service.aop.RestTemplateStrategyInt
@EnableFeignClients
// Hystrix测试
// @EnableCircuitBreaker
//@EnableApolloConfig(value = {"application"},order = 0)
public
class
DiscoveryApplicationA1
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"a1"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationA1
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA2.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationA2
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"a2"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationA2
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB1.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationB1
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"b1"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationB1
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB2.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationB2
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"b2"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationB2
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC1.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationC1
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"c1"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationC1
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC2.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationC2
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"c2"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationC2
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC3.java
View file @
d0f069c4
...
...
@@ -20,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public
class
DiscoveryApplicationC3
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"c3"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationC3
.
class
).
run
(
args
);
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/ARestImpl.java
View file @
d0f069c4
...
...
@@ -11,9 +11,14 @@ package com.nepxion.discovery.plugin.example.service.rest;
import
java.util.Enumeration
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
...
...
@@ -29,6 +34,8 @@ import com.alibaba.csp.sentinel.slots.block.BlockException;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.plugin.strategy.service.context.ServiceStrategyContextHolder
;
import
javax.validation.Valid
;
@RestController
@ConditionalOnProperty
(
name
=
DiscoveryConstant
.
SPRING_APPLICATION_NAME
,
havingValue
=
"discovery-springcloud-example-a"
)
public
class
ARestImpl
extends
AbstractRestImpl
{
...
...
@@ -40,9 +47,13 @@ public class ARestImpl extends AbstractRestImpl {
@Autowired
private
ServiceStrategyContextHolder
serviceStrategyContextHolder
;
@Autowired
private
PluginAdapter
pluginAdapter
;
@RequestMapping
(
path
=
"/rest"
,
method
=
RequestMethod
.
POST
)
@SentinelResource
(
value
=
"sentinel-resource"
,
blockHandler
=
"handleBlock"
,
fallback
=
"handleFallback"
)
//
@SentinelResource(value = "sentinel-resource", blockHandler = "handleBlock", fallback = "handleFallback")
public
String
rest
(
@RequestBody
String
value
)
{
LOG
.
info
(
"调用开始{}"
,
System
.
currentTimeMillis
());
value
=
doRest
(
value
);
// Just for testing
...
...
@@ -71,13 +82,36 @@ public class ARestImpl extends AbstractRestImpl {
return
value
;
}
@Autowired
Config
config
;
@Value
(
"${eureka.instance.metadataMap.region}"
)
String
region
;
@RequestMapping
(
path
=
"/test"
,
method
=
RequestMethod
.
POST
)
public
String
test
(
@RequestBody
String
value
)
{
try
{
Thread
.
sleep
(
5000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
String
serviceId
=
pluginAdapter
.
getServiceId
();
String
host
=
pluginAdapter
.
getHost
();
int
port
=
pluginAdapter
.
getPort
();
String
version
=
pluginAdapter
.
getVersion
();
String
region
=
pluginAdapter
.
getRegion
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
"haha gray"
+
" -> "
+
serviceId
);
stringBuilder
.
append
(
"["
+
host
+
":"
+
port
+
"]"
);
if
(
StringUtils
.
isNotEmpty
(
version
))
{
stringBuilder
.
append
(
"[V"
+
version
+
"]"
);
}
if
(
StringUtils
.
isNotEmpty
(
region
))
{
stringBuilder
.
append
(
"[Region="
+
region
+
"]"
);
}
Config
configa
=
ConfigService
.
getConfig
(
"application"
);
LOG
.
info
(
">>>>>>>>>>>>>>>> {} config:{}"
,
stringBuilder
.
toString
(),
config
.
getProperty
(
"eureka.instance.metadataMap.region"
,
"xxxx"
));
// try {
// Thread.sleep(5000);
// } catch (Exception e) {
// e.printStackTrace();
// }
return
value
;
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/BRestImpl.java
View file @
d0f069c4
...
...
@@ -41,7 +41,7 @@ public class BRestImpl extends AbstractRestImpl {
private
ServiceStrategyContextHolder
serviceStrategyContextHolder
;
@RequestMapping
(
path
=
"/rest"
,
method
=
RequestMethod
.
POST
)
@SentinelResource
(
value
=
"sentinel-resource"
,
blockHandler
=
"handleBlock"
,
fallback
=
"handleFallback"
)
//
@SentinelResource(value = "sentinel-resource", blockHandler = "handleBlock", fallback = "handleFallback")
public
String
rest
(
@RequestBody
String
value
)
{
value
=
doRest
(
value
);
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/rest/CRestImpl.java
View file @
d0f069c4
...
...
@@ -35,7 +35,7 @@ public class CRestImpl extends AbstractRestImpl {
private
ServiceStrategyContextHolder
serviceStrategyContextHolder
;
@RequestMapping
(
path
=
"/rest"
,
method
=
RequestMethod
.
POST
)
@SentinelResource
(
value
=
"sentinel-resource"
,
blockHandler
=
"handleBlock"
,
fallback
=
"handleFallback"
)
//
@SentinelResource(value = "sentinel-resource", blockHandler = "handleBlock", fallback = "handleFallback")
public
String
rest
(
@RequestBody
String
value
)
{
value
=
doRest
(
value
);
...
...
discovery-springcloud-example-service/src/main/resources/application-a1.properties
View file @
d0f069c4
...
...
@@ -7,18 +7,25 @@ eureka.instance.metadataMap.group=example-service-group
eureka.instance.metadataMap.version
=
1.0
eureka.instance.metadataMap.region
=
dev
# Consul config for discovery
spring.cloud.consul.discovery.tags
=
group=example-service-group,version=1.0,region=dev
# Zookeeper config for discovery
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
spring.cloud.zookeeper.discovery.metadata.version
=
1.0
spring.cloud.zookeeper.discovery.metadata.region
=
dev
# Nacos config for discovery
spring.cloud.nacos.discovery.metadata.group
=
example-service-group
spring.cloud.nacos.discovery.metadata.version
=
1.0
spring.cloud.nacos.discovery.metadata.region
=
dev
#
#
Consul config for discovery
#
spring.cloud.consul.discovery.tags=group=example-service-group,version=1.0,region=dev
#
#
#
Zookeeper config for discovery
#
spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#
spring.cloud.zookeeper.discovery.metadata.version=1.0
#
spring.cloud.zookeeper.discovery.metadata.region=dev
#
#
#
Nacos config for discovery
#
spring.cloud.nacos.discovery.metadata.group=example-service-group
#
spring.cloud.nacos.discovery.metadata.version=1.0
#
spring.cloud.nacos.discovery.metadata.region=dev
# Admin config
management.server.port
=
5100
\ No newline at end of file
management.server.port
=
5100
# Apollo config for rule
app.id
=
discovery-springcloud-example-a
apollo.meta
=
http://localhost:8080
apollo.bootstrap.enabled
=
true
apollo.bootstrap.namespaces
=
application
apollo.plugin.namespace
=
architect.gray.rule
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/application-a2.properties
View file @
d0f069c4
...
...
@@ -7,18 +7,25 @@ eureka.instance.metadataMap.group=example-service-group
eureka.instance.metadataMap.version
=
1.1
eureka.instance.metadataMap.region
=
qa
# Consul config for discovery
spring.cloud.consul.discovery.tags
=
group=example-service-group,version=1.1,region=qa
# Zookeeper config for discovery
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
spring.cloud.zookeeper.discovery.metadata.version
=
1.1
spring.cloud.zookeeper.discovery.metadata.region
=
qa
# Nacos config for discovery
spring.cloud.nacos.discovery.metadata.group
=
example-service-group
spring.cloud.nacos.discovery.metadata.version
=
1.1
spring.cloud.nacos.discovery.metadata.region
=
qa
#
#
Consul config for discovery
#
spring.cloud.consul.discovery.tags=group=example-service-group,version=1.1,region=qa
#
#
#
Zookeeper config for discovery
#
spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#
spring.cloud.zookeeper.discovery.metadata.version=1.1
#
spring.cloud.zookeeper.discovery.metadata.region=qa
#
#
#
Nacos config for discovery
#
spring.cloud.nacos.discovery.metadata.group=example-service-group
#
spring.cloud.nacos.discovery.metadata.version=1.1
#
spring.cloud.nacos.discovery.metadata.region=qa
# Admin config
management.server.port
=
5101
\ No newline at end of file
management.server.port
=
5101
# Apollo config for rule
app.id
=
discovery-springcloud-example-a
apollo.meta
=
http://localhost:8080
apollo.bootstrap.enabled
=
true
apollo.bootstrap.namespaces
=
application
apollo.plugin.namespace
=
architect.gray.rule
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/application-b1.properties
View file @
d0f069c4
...
...
@@ -8,17 +8,24 @@ eureka.instance.metadataMap.version=1.0
eureka.instance.metadataMap.region
=
dev
# Consul config for discovery
spring.cloud.consul.discovery.tags
=
group=example-service-group,version=1.0,region=dev
# Zookeeper config for discovery
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
spring.cloud.zookeeper.discovery.metadata.version
=
1.0
spring.cloud.zookeeper.discovery.metadata.region
=
dev
# Nacos config for discovery
spring.cloud.nacos.discovery.metadata.group
=
example-service-group
spring.cloud.nacos.discovery.metadata.version
=
1.0
spring.cloud.nacos.discovery.metadata.region
=
dev
#
spring.cloud.consul.discovery.tags=group=example-service-group,version=1.0,region=dev
#
#
#
Zookeeper config for discovery
#
spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#
spring.cloud.zookeeper.discovery.metadata.version=1.0
#
spring.cloud.zookeeper.discovery.metadata.region=dev
#
#
#
Nacos config for discovery
#
spring.cloud.nacos.discovery.metadata.group=example-service-group
#
spring.cloud.nacos.discovery.metadata.version=1.0
#
spring.cloud.nacos.discovery.metadata.region=dev
# Admin config
management.server.port
=
5200
\ No newline at end of file
management.server.port
=
5200
# apollo
app.id
=
discovery-springcloud-example-b
apollo.meta
=
http://localhost:8080
apollo.bootstrap.enabled
=
true
apollo.bootstrap.namespaces
=
application
apollo.plugin.namespace
=
architect.gray.rule
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/application-b2.properties
View file @
d0f069c4
...
...
@@ -21,4 +21,11 @@ spring.cloud.nacos.discovery.metadata.version=1.1
spring.cloud.nacos.discovery.metadata.region
=
qa
# Admin config
management.server.port
=
5201
\ No newline at end of file
management.server.port
=
5201
# apollo
app.id
=
discovery-springcloud-example-b
apollo.meta
=
http://localhost:8080
apollo.bootstrap.enabled
=
true
#apollo.bootstrap.namespaces=application
apollo.plugin.namespace
=
architect.gray.rule
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/application-c1.properties
View file @
d0f069c4
...
...
@@ -7,18 +7,26 @@ eureka.instance.metadataMap.group=example-service-group
eureka.instance.metadataMap.version
=
1.0
eureka.instance.metadataMap.region
=
dev
# Consul config for discovery
spring.cloud.consul.discovery.tags
=
group=example-service-group,version=1.0,region=dev
## Consul config for discovery
#spring.cloud.consul.discovery.tags=group=example-service-group,version=1.0,region=dev
#
## Zookeeper config for discovery
#spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#spring.cloud.zookeeper.discovery.metadata.version=1.0
#spring.cloud.zookeeper.discovery.metadata.region=dev
#
## Nacos config for discovery
#spring.cloud.nacos.discovery.metadata.group=example-service-group
#spring.cloud.nacos.discovery.metadata.version=1.0
#spring.cloud.nacos.discovery.metadata.region=dev
# Zookeeper config for discovery
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
spring.cloud.zookeeper.discovery.metadata.version
=
1.0
spring.cloud.zookeeper.discovery.metadata.region
=
dev
# Admin config
management.server.port
=
5300
# Nacos config for discovery
spring.cloud.nacos.discovery.metadata.group
=
example-service-group
spring.cloud.nacos.discovery.metadata.version
=
1.0
spring.cloud.nacos.discovery.metadata.region
=
dev
# Admin config
management.server.port
=
5300
\ No newline at end of file
# apollo
app.id
=
discovery-springcloud-example-c
apollo.meta
=
http://localhost:8080
apollo.bootstrap.enabled
=
true
apollo.bootstrap.namespaces
=
application
apollo.plugin.namespace
=
architect.gray.rule
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/bootstrap.properties
View file @
d0f069c4
# Spring cloud config
# server.servlet.context-path=/nepxion
spring.mvc.servlet.load-on-startup
=
1
# Eureka config for discovery
eureka.client.serviceUrl.defaultZone
=
http://localhost:9528/eureka/
...
...
@@ -27,10 +28,7 @@ ribbon.ReadTimeout=60000
# 支持G版,FeignClientSpecification的问题
spring.main.allow-bean-definition-overriding
=
true
# Apollo config for rule
app.id
=
discovery
apollo.meta
=
http://localhost:8080
# apollo.plugin.namespace=application
# Nacos config for rule
nacos.server-addr
=
localhost:8848
...
...
discovery-springcloud-example-service/src/main/resources/rule.json
deleted
100644 → 0
View file @
33f9833c
{
"registerEntity"
:
{
"hostFilterEntity"
:
{
"filterType"
:
"BLACKLIST"
,
"filterValueList"
:
[
"10.10"
,
"11.11"
],
"filterMap"
:
{
"discovery-springcloud-example-a"
:
[
"172.16"
]
}
},
"countFilterEntity"
:
{
"filterValue"
:
10000
,
"filterMap"
:
{
"discovery-springcloud-example-a"
:
5000
}
}
},
"discoveryEntity"
:
{
"hostFilterEntity"
:
{
"filterType"
:
"BLACKLIST"
,
"filterValueList"
:
[
"10.10"
,
"11.11"
],
"filterMap"
:
{
"discovery-springcloud-example-b"
:
[
"172.16"
]
}
},
"versionFilterEntity"
:
{
"versionEntityMap"
:
{
"discovery-springcloud-example-a"
:
[
{
"consumerServiceName"
:
"discovery-springcloud-example-a"
,
"providerServiceName"
:
"discovery-springcloud-example-b"
,
"consumerVersionValueList"
:
[
"1.0"
],
"providerVersionValueList"
:
[
"1.0"
]
},
{
"consumerServiceName"
:
"discovery-springcloud-example-a"
,
"providerServiceName"
:
"discovery-springcloud-example-b"
,
"consumerVersionValueList"
:
[
"1.1"
],
"providerVersionValueList"
:
[
"1.1"
]
}
],
"discovery-springcloud-example-b"
:
[
{
"consumerServiceName"
:
"discovery-springcloud-example-b"
,
"providerServiceName"
:
"discovery-springcloud-example-c"
,
"consumerVersionValueList"
:
[
"1.0"
],
"providerVersionValueList"
:
[
"1.0"
,
"1.1"
]
},
{
"consumerServiceName"
:
"discovery-springcloud-example-b"
,
"providerServiceName"
:
"discovery-springcloud-example-c"
,
"consumerVersionValueList"
:
[
"1.1"
],
"providerVersionValueList"
:
[
"1.2"
]
}
]
}
},
"weightFilterEntity"
:
{
"weightEntityMap"
:
{
"discovery-springcloud-example-b"
:
[
{
"consumerServiceName"
:
"discovery-springcloud-example-b"
,
"providerServiceName"
:
"discovery-springcloud-example-c"
,
"weightMap"
:
{
"1.0"
:
90
,
"1.1"
:
10
}
}
],
""
:
[
{
"consumerServiceName"
:
""
,
"providerServiceName"
:
"discovery-springcloud-example-c"
,
"weightMap"
:
{
"1.0"
:
80
,
"1.1"
:
20
}
}
]
},
"regionWeightEntity"
:
{
"weightMap"
:
{
"dev"
:
85
,
"qa"
:
15
}
}
}
},
"strategyEntity"
:
{
"versionValue"
:
"{
\"
discovery-springcloud-example-a
\"
:
\"
1.0
\"
,
\"
discovery-springcloud-example-b
\"
:
\"
1.0
\"
,
\"
discovery-springcloud-example-c
\"
:
\"
1.0;1.2
\"
}"
,
"regionValue"
:
"{
\"
discovery-springcloud-example-a
\"
:
\"
qa;dev
\"
,
\"
discovery-springcloud-example-b
\"
:
\"
dev
\"
,
\"
discovery-springcloud-example-c
\"
:
\"
qa
\"
}"
,
"addressValue"
:
"{
\"
discovery-springcloud-example-a
\"
:
\"
192.168.43.101:1100
\"
,
\"
discovery-springcloud-example-b
\"
:
\"
192.168.43.101:1201
\"
,
\"
discovery-springcloud-example-c
\"
:
\"
192.168.43.101:1300
\"
}"
},
"customizationEntity"
:
{
"customizationMap"
:
{
"discovery-springcloud-example-a"
:
{
"database"
:
"qa"
},
"discovery-springcloud-example-c"
:
{
"database"
:
"prod"
}
}
}
}
\ No newline at end of file
discovery-springcloud-example-service/src/main/resources/rule.xml
deleted
100644 → 0
View file @
33f9833c
This diff is collapsed.
Click to expand it.
discovery-springcloud-example-zuul/pom.xml
View file @
d0f069c4
...
...
@@ -59,17 +59,17 @@
<dependencies>
<dependency>
<groupId>
com.nepxion
</groupId>
<!-- <artifactId>discovery-plugin-starter-eureka</artifactId> --
>
<artifactId>
discovery-plugin-starter-eureka
</artifactId
>
<!-- <artifactId>discovery-plugin-starter-consul</artifactId> -->
<!-- <artifactId>discovery-plugin-starter-zookeeper</artifactId> -->
<
artifactId>
discovery-plugin-starter-nacos
</artifactId
>
<
!--<artifactId>discovery-plugin-starter-nacos</artifactId>--
>
<version>
${discovery.version}
</version>
</dependency>
<dependency>
<groupId>
com.nepxion
</groupId>
<!-- <artifactId>discovery-plugin-config-center-starter-apollo</artifactId> --
>
<
artifactId>
discovery-plugin-config-center-starter-nacos
</artifactId
>
<artifactId>
discovery-plugin-config-center-starter-apollo
</artifactId
>
<
!--<artifactId>discovery-plugin-config-center-starter-nacos</artifactId>--
>
<!-- <artifactId>discovery-plugin-config-center-starter-redis</artifactId> -->
<version>
${discovery.version}
</version>
</dependency>
...
...
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul.java
View file @
d0f069c4
...
...
@@ -23,6 +23,7 @@ import com.nepxion.discovery.plugin.strategy.zuul.filter.ZuulStrategyRouteFilter
@EnableZuulProxy
public
class
DiscoveryApplicationZuul
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationZuul
.
class
).
run
(
args
);
}
...
...
@@ -31,7 +32,7 @@ public class DiscoveryApplicationZuul {
return
new
ZuulStrategyRouteFilter
();
}
@Bean
//
@Bean
public
MyDiscoveryEnabledStrategy
myDiscoveryEnabledStrategy
()
{
return
new
MyDiscoveryEnabledStrategy
();
}
...
...
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul2.java
0 → 100644
View file @
d0f069c4
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
zuul
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
com.nepxion.discovery.plugin.example.zuul.impl.MyDiscoveryEnabledStrategy
;
import
com.nepxion.discovery.plugin.strategy.zuul.filter.ZuulStrategyRouteFilter
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.context.annotation.Bean
;
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public
class
DiscoveryApplicationZuul2
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"g2"
);
System
.
setProperty
(
"apollo.configService"
,
"http://212.129.229.203"
);
new
SpringApplicationBuilder
(
DiscoveryApplicationZuul2
.
class
).
run
(
args
);
}
// @Bean
public
ZuulStrategyRouteFilter
zuulStrategyRouteFilter
()
{
return
new
ZuulStrategyRouteFilter
();
}
// @Bean
public
MyDiscoveryEnabledStrategy
myDiscoveryEnabledStrategy
()
{
return
new
MyDiscoveryEnabledStrategy
();
}
}
\ No newline at end of file
discovery-springcloud-example-zuul/src/main/resources/application-g2.properties
0 → 100644
View file @
d0f069c4
# Spring cloud config
spring.application.name
=
discovery-springcloud-example-zuul
server.port
=
1401
# Eureka config for discovery
eureka.instance.metadataMap.group
=
example-service-group
eureka.instance.metadataMap.version
=
1.0
## Consul config for discovery
#spring.cloud.consul.discovery.tags=group=example-service-group,version=1.0
#
## Zookeeper config for discovery
#spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#spring.cloud.zookeeper.discovery.metadata.version=1.0
#
## Nacos config for discovery
#spring.cloud.nacos.discovery.metadata.group=example-service-group
#spring.cloud.nacos.discovery.metadata.version=1.0
# Admin config
management.server.port
=
5401
# Zuul config
#zuul.routes.discovery-springcloud-example-a.path=/discovery-springcloud-example-a/**
#zuul.routes.discovery-springcloud-example-a.serviceId=discovery-springcloud-example-a
#
zuul.ribbon-isolation-strategy
=
THREAD
\ No newline at end of file
discovery-springcloud-example-zuul/src/main/resources/application.properties
View file @
d0f069c4
...
...
@@ -6,21 +6,21 @@ server.port=1400
eureka.instance.metadataMap.group
=
example-service-group
eureka.instance.metadataMap.version
=
1.0
# Consul config for discovery
spring.cloud.consul.discovery.tags
=
group=example-service-group,version=1.0
# Zookeeper config for discovery
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
spring.cloud.zookeeper.discovery.metadata.version
=
1.0
# Nacos config for discovery
spring.cloud.nacos.discovery.metadata.group
=
example-service-group
spring.cloud.nacos.discovery.metadata.version
=
1.0
#
#
Consul config for discovery
#
spring.cloud.consul.discovery.tags=group=example-service-group,version=1.0
#
#
#
Zookeeper config for discovery
#
spring.cloud.zookeeper.discovery.metadata.group=example-service-group
#
spring.cloud.zookeeper.discovery.metadata.version=1.0
#
#
#
Nacos config for discovery
#
spring.cloud.nacos.discovery.metadata.group=example-service-group
#
spring.cloud.nacos.discovery.metadata.version=1.0
# Admin config
management.server.port
=
5400
# Zuul config
zuul.routes.discovery-springcloud-example-a.path
=
/discovery-springcloud-example-a/**
zuul.routes.discovery-springcloud-example-a.serviceId
=
discovery-springcloud-example-a
#
zuul.routes.discovery-springcloud-example-a.path=/discovery-springcloud-example-a/**
#
zuul.routes.discovery-springcloud-example-a.serviceId=discovery-springcloud-example-a
#
zuul.ribbon-isolation-strategy
=
THREAD
\ No newline at end of file
discovery-springcloud-example-zuul/src/main/resources/bootstrap.properties
View file @
d0f069c4
...
...
@@ -26,7 +26,7 @@ ribbon.ReadTimeout=60000
# Apollo config for rule
app.id
=
discovery
apollo.meta
=
http://localhost:8080
# apollo.plugin.namespace=application
apollo.plugin.namespace
=
architect.gray.rule
# Nacos config for rule
nacos.server-addr
=
localhost:8848
...
...
discovery-springcloud-example-zuul/src/main/resources/rule.json
deleted
100644 → 0
View file @
33f9833c
{
"discoveryEntity"
:
{
"versionFilterEntity"
:
{
"versionEntityMap"
:
{
"discovery-springcloud-example-zuul"
:
[
{
"consumerServiceName"
:
"discovery-springcloud-example-zuul"
,
"providerServiceName"
:
"discovery-springcloud-example-a"
,
"consumerVersionValueList"
:
[
"1.0"
],
"providerVersionValueList"
:
[
"1.0"
]
},
{
"consumerServiceName"
:
"discovery-springcloud-example-zuul"
,
"providerServiceName"
:
"discovery-springcloud-example-a"
,
"consumerVersionValueList"
:
[
"1.1"
],
"providerVersionValueList"
:
[
"1.1"
]
}
]
}
}
}
}
\ No newline at end of file
discovery-springcloud-example-zuul/src/main/resources/rule.xml
deleted
100644 → 0
View file @
33f9833c
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<discovery>
<version>
<!-- 表示网关z的1.0,允许访问提供端服务a的1.0版本 -->
<service
consumer-service-name=
"discovery-springcloud-example-zuul"
provider-service-name=
"discovery-springcloud-example-a"
consumer-version-value=
"1.0"
provider-version-value=
"1.0"
/>
<!-- 表示网关z的1.1,允许访问提供端服务a的1.1版本 -->
<service
consumer-service-name=
"discovery-springcloud-example-zuul"
provider-service-name=
"discovery-springcloud-example-a"
consumer-version-value=
"1.1"
provider-version-value=
"1.1"
/>
</version>
</discovery>
</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