Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
05d14a21
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05d14a21
编写于
3月 18, 2016
作者:
J
Jason Song
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15 from yiming187/service_fix
Fix Eureka Service Discovery
上级
fcd61233
77c3ae79
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
49 addition
and
51 deletion
+49
-51
apollo-configserver/src/main/resources/bootstrap.yml
apollo-configserver/src/main/resources/bootstrap.yml
+1
-5
apollo-configserver/src/test/resources/bootstrap.yml
apollo-configserver/src/test/resources/bootstrap.yml
+1
-5
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java
...va/com/ctrip/apollo/metaserver/MetaServerApplication.java
+1
-11
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java
...com/ctrip/apollo/metaserver/service/DiscoveryService.java
+3
-2
apollo-metaserver/src/main/resources/bootstrap.yml
apollo-metaserver/src/main/resources/bootstrap.yml
+1
-3
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/controller/DiscoveryControllerTest.java
...apollo/metaserver/controller/DiscoveryControllerTest.java
+37
-0
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
...ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
+0
-21
apollo-metaserver/src/test/resources/bootstrap.yml
apollo-metaserver/src/test/resources/bootstrap.yml
+4
-3
apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java
...com/ctrip/apollo/portal/controller/AppControllerTest.java
+1
-1
未找到文件。
apollo-configserver/src/main/resources/bootstrap.yml
浏览文件 @
05d14a21
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
defaultZone
:
http://${eureka.instance.hostname}:8761/eureka/
apollo-configserver/src/test/resources/bootstrap.yml
浏览文件 @
05d14a21
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
defaultZone
:
http://${eureka.instance.hostname}:8761/eureka/
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java
浏览文件 @
05d14a21
package
com.ctrip.apollo.metaserver
;
import
java.util.List
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
com.ctrip.apollo.metaserver.service.DiscoveryService
;
import
com.netflix.appinfo.InstanceInfo
;
@SpringBootApplication
@EnableEurekaServer
...
...
@@ -17,10 +11,6 @@ import com.netflix.appinfo.InstanceInfo;
public
class
MetaServerApplication
{
public
static
void
main
(
String
[]
args
)
{
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
MetaServerApplication
.
class
).
web
(
true
).
run
(
args
);
DiscoveryService
discoveryService
=
context
.
getBean
(
DiscoveryService
.
class
);
List
<
InstanceInfo
>
instances
=
discoveryService
.
getMetaServerServiceInstance
();
System
.
out
.
println
(
instances
);
}
}
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java
浏览文件 @
05d14a21
package
com.ctrip.apollo.metaserver.service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,12 +19,12 @@ public class DiscoveryService {
public
List
<
InstanceInfo
>
getConfigServerServiceInstance
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceIdConsts
.
APOLLO_CONFIGSERVER
);
return
application
.
getInstances
();
return
application
!=
null
?
application
.
getInstances
()
:
new
ArrayList
<>
();
}
public
List
<
InstanceInfo
>
getMetaServerServiceInstance
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceIdConsts
.
APOLLO_METASERVER
);
return
application
.
getInstances
();
return
application
!=
null
?
application
.
getInstances
()
:
new
ArrayList
<>
();
}
}
apollo-metaserver/src/main/resources/bootstrap.yml
浏览文件 @
05d14a21
...
...
@@ -4,9 +4,7 @@ server:
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
...
...
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/controller/DiscoveryControllerTest.java
0 → 100644
浏览文件 @
05d14a21
package
com.ctrip.apollo.metaserver.controller
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.apollo.core.ServiceIdConsts
;
import
com.ctrip.apollo.metaserver.AbstractMetaServerTest
;
import
com.netflix.appinfo.InstanceInfo
;
@WebIntegrationTest
public
class
DiscoveryControllerTest
extends
AbstractMetaServerTest
{
RestTemplate
restTemplate
=
new
TestRestTemplate
();
@Value
(
"${local.server.port}"
)
String
serverPort
;
@Test
public
void
testGetMetaServerServices
()
throws
InterruptedException
,
URISyntaxException
{
// Wait Eureka Client to fresh meta
Thread
.
sleep
(
5000
);
URI
uri
=
new
URI
(
"http://localhost:"
+
serverPort
+
"/services/meta"
);
InstanceInfo
[]
serviceInstances
=
restTemplate
.
getForObject
(
uri
,
InstanceInfo
[].
class
);
Assert
.
assertEquals
(
1
,
serviceInstances
.
length
);
Assert
.
assertEquals
(
ServiceIdConsts
.
APOLLO_METASERVER
,
serviceInstances
[
0
].
getAppName
().
toLowerCase
());
}
}
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
已删除
100644 → 0
浏览文件 @
fcd61233
package
com.ctrip.apollo.metaserver.service
;
import
java.util.List
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.apollo.metaserver.AbstractMetaServerTest
;
import
com.netflix.appinfo.InstanceInfo
;
public
class
DiscoveryServiceTest
extends
AbstractMetaServerTest
{
@Autowired
private
DiscoveryService
discoveryService
;
@Test
public
void
testGetLocalMetaServerServices
()
{
List
<
InstanceInfo
>
instances
=
discoveryService
.
getMetaServerServiceInstance
();
System
.
out
.
println
(
instances
);
}
}
apollo-metaserver/src/test/resources/bootstrap.yml
浏览文件 @
05d14a21
...
...
@@ -4,10 +4,11 @@ server:
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
leaseRenewalIntervalInSeconds
:
1
client
:
fetchRegistry
:
false
# initialInstanceInfoReplicationIntervalSeconds: 1
registryFetchIntervalSeconds
:
2
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
defaultZone
:
http://${eureka.instance.hostname}:${server.port
:8761
}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java
浏览文件 @
05d14a21
...
...
@@ -26,7 +26,7 @@ public class AppControllerTest extends AbstractPortalTest {
@Autowired
AppRepository
appRepository
;
@Value
(
"${server.port}"
)
@Value
(
"${
local.
server.port}"
)
String
serverPort
;
@Test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录