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
8f3e0d2a
Commit
8f3e0d2a
authored
Jun 22, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构测试用例
parent
44b040f0
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
155 additions
and
9 deletions
+155
-9
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/impl/DiscoveryConfigurationLoader.java
+2
-2
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/impl/DiscoveryConfigurationSimulator.java
+2
-1
discovery-springcloud-example-a/src/main/resources/rule1.xml
+3
-2
discovery-springcloud-example-a/src/main/resources/rule2.xml
+3
-2
discovery-springcloud-example-a/src/main/resources/rule3.xml
+3
-2
discovery-springcloud-example-b3/pom.xml
+63
-0
discovery-springcloud-example-b3/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplication.java
+23
-0
discovery-springcloud-example-b3/src/main/resources/application.properties
+6
-0
discovery-springcloud-example-b3/src/main/resources/logback.xml
+49
-0
pom.xml
+1
-0
No files found.
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/impl/DiscoveryConfigurationLoader.java
View file @
8f3e0d2a
...
@@ -22,13 +22,13 @@ public class DiscoveryConfigurationLoader extends AbstractConfigurationLoader {
...
@@ -22,13 +22,13 @@ public class DiscoveryConfigurationLoader extends AbstractConfigurationLoader {
@Override
@Override
public
InputStream
getRemoteInputStream
()
throws
IOException
{
public
InputStream
getRemoteInputStream
()
throws
IOException
{
// 本地文件模拟代替远程文件
// 本地文件模拟代替远程文件
return
getInputStream
(
"src/main/resources/
plugin
1.xml"
);
return
getInputStream
(
"src/main/resources/
rule
1.xml"
);
}
}
@Override
@Override
protected
String
getLocalContextPath
()
{
protected
String
getLocalContextPath
()
{
// 配置文件放在resources目录下
// 配置文件放在resources目录下
return
"classpath:
plugin
1.xml"
;
return
"classpath:
rule
1.xml"
;
// 配置文件放在工程根目录下
// 配置文件放在工程根目录下
// return "file:plugin1.xml";
// return "file:plugin1.xml";
...
...
discovery-springcloud-example-a/src/main/java/com/nepxion/discovery/plugin/example/impl/DiscoveryConfigurationSimulator.java
View file @
8f3e0d2a
...
@@ -38,7 +38,8 @@ public class DiscoveryConfigurationSimulator {
...
@@ -38,7 +38,8 @@ public class DiscoveryConfigurationSimulator {
public
void
run
()
{
public
void
run
()
{
// 本地文件模拟代替远程文件,随机读取
// 本地文件模拟代替远程文件,随机读取
int
index
=
threadLocalRandom
.
nextInt
(
5
)
+
1
;
int
index
=
threadLocalRandom
.
nextInt
(
5
)
+
1
;
InputStream
inputStream
=
getInputStream
(
"src/main/resources/plugin"
+
index
+
".xml"
);
System
.
out
.
println
(
"-------------------- rule"
+
index
+
".xml is loaded --------------------"
);
InputStream
inputStream
=
getInputStream
(
"src/main/resources/rule"
+
index
+
".xml"
);
configurationPublisher
.
publish
(
inputStream
);
configurationPublisher
.
publish
(
inputStream
);
}
}
},
10000L
,
15000L
);
},
10000L
,
15000L
);
...
...
discovery-springcloud-example-a/src/main/resources/rule1.xml
View file @
8f3e0d2a
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<discovery>
<!-- 表示消费端服务a的1.0,允许访问提供端服务b的1.0版本 -->
<!-- 表示消费端服务a的1.0,允许访问提供端服务b的1.0
和1.1
版本 -->
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.0"
provider-version-value=
"1.0"
/>
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.0"
provider-version-value=
"1.0
;1.1
"
/>
</discovery>
</discovery>
</rule>
</rule>
\ No newline at end of file
discovery-springcloud-example-a/src/main/resources/rule2.xml
View file @
8f3e0d2a
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<discovery>
<!-- 表示消费端服务a的1.
1,允许访问提供端服务b的1.1
版本 -->
<!-- 表示消费端服务a的1.
0,允许访问提供端服务b的3.0
版本 -->
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.
1"
provider-version-value=
"1.1
"
/>
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.
0"
provider-version-value=
"3.0
"
/>
</discovery>
</discovery>
</rule>
</rule>
\ No newline at end of file
discovery-springcloud-example-a/src/main/resources/rule3.xml
View file @
8f3e0d2a
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<discovery>
<!-- 表示消费端服务a的1.0和1.1版本,允许访问提供端服务b的1.0和1.1版本 -->
<!-- 表示消费端服务a的1.0和1.1版本,允许访问提供端服务b的1.0和1.1
和2.0
版本 -->
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.0;1.1"
provider-version-value=
"1.0;1.1"
/>
<service
consumer-service-name=
"discovery-springcloud-example-a"
provider-service-name=
"discovery-springcloud-example-b"
consumer-version-value=
"1.0;1.1"
provider-version-value=
"1.0;1.1
;2.0
"
/>
</discovery>
</discovery>
</rule>
</rule>
\ No newline at end of file
discovery-springcloud-example-b3/pom.xml
0 → 100644
View file @
8f3e0d2a
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<groupId>
com.nepxion
</groupId>
<artifactId>
discovery-springcloud-example-b3
</artifactId>
<name>
Nepxion Discovery Spring Cloud Example B3
</name>
<packaging>
jar
</packaging>
<modelVersion>
4.0.0
</modelVersion>
<version>
1.0.0
</version>
<description>
Nepxion Discovery is an enhancement for Spring Cloud Discovery
</description>
<url>
http://www.nepxion.com
</url>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.6.RELEASE
</version>
</parent>
<properties>
<spring.cloud.version>
Dalston.SR4
</spring.cloud.version>
<!-- <spring.cloud.version>Edgware.RELEASE</spring.cloud.version> -->
<discovery.plugin.version>
1.0.0
</discovery.plugin.version>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${spring.cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<compilerArgs>
<arg>
-parameters
</arg>
</compilerArgs>
<encoding>
${project.build.sourceEncoding}
</encoding>
<source>
${java.version}
</source>
<target>
${java.version}
</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
discovery-springcloud-example-b3/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplication.java
0 → 100644
View file @
8f3e0d2a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
/**
* <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
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
@SpringBootApplication
@EnableDiscoveryClient
public
class
DiscoveryApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
DiscoveryApplication
.
class
).
web
(
true
).
run
(
args
);
}
}
\ No newline at end of file
discovery-springcloud-example-b3/src/main/resources/application.properties
0 → 100644
View file @
8f3e0d2a
# Spring cloud config
spring.application.name
=
discovery-springcloud-example-b
server.port
=
4324
eureka.client.serviceUrl.defaultZone
=
http://10.0.75.1:9528/eureka/
eureka.instance.metadataMap.version
=
2.0
\ No newline at end of file
discovery-springcloud-example-b3/src/main/resources/logback.xml
0 → 100644
View file @
8f3e0d2a
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration
scan=
"true"
scanPeriod=
"10 seconds"
>
<!-- Simple file output -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
discovery %date %level [%thread] %logger{10} [%file:%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
log/discovery-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>
50MB
</maxFileSize>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
</filter>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
true
</prudent>
</appender>
<appender
name =
"FILE_ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<discardingThreshold>
0
</discardingThreshold>
<queueSize>
512
</queueSize>
<appender-ref
ref =
"FILE"
/>
</appender>
<!-- Console output -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
discovery %date %level [%thread] %logger{10} [%file:%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<!-- Only log level WARN and above -->
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
</filter>
</appender>
<!-- For loggers in the these namespaces, log at all levels. -->
<logger
name=
"pedestal"
level=
"ALL"
/>
<logger
name=
"hammock-cafe"
level=
"ALL"
/>
<logger
name=
"user"
level=
"ALL"
/>
<root
level=
"INFO"
>
<!-- <appender-ref ref="FILE_ASYNC" /> -->
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
pom.xml
View file @
8f3e0d2a
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
<module>
discovery-springcloud-example-a
</module>
<module>
discovery-springcloud-example-a
</module>
<module>
discovery-springcloud-example-b1
</module>
<module>
discovery-springcloud-example-b1
</module>
<module>
discovery-springcloud-example-b2
</module>
<module>
discovery-springcloud-example-b2
</module>
<module>
discovery-springcloud-example-b3
</module>
</modules>
</modules>
<properties>
<properties>
...
...
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