Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
9ad76d7c
Commit
9ad76d7c
authored
Jul 21, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move shuffle logic to service locator
parent
782796c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
AdminServiceAddressLocator.java
...amework/apollo/portal/api/AdminServiceAddressLocator.java
+11
-1
RetryableRestTemplate.java
...ip/framework/apollo/portal/api/RetryableRestTemplate.java
+0
-2
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAddressLocator.java
View file @
9ad76d7c
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
api
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
api
;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
...
@@ -11,9 +13,11 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
...
@@ -11,9 +13,11 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -67,7 +71,13 @@ public class AdminServiceAddressLocator {
...
@@ -67,7 +71,13 @@ public class AdminServiceAddressLocator {
}
}
public
List
<
ServiceDTO
>
getServiceList
(
Env
env
)
{
public
List
<
ServiceDTO
>
getServiceList
(
Env
env
)
{
return
cache
.
get
(
env
);
List
<
ServiceDTO
>
services
=
cache
.
get
(
env
);
if
(
CollectionUtils
.
isEmpty
(
services
))
{
return
Collections
.
EMPTY_LIST
;
}
List
<
ServiceDTO
>
randomConfigServices
=
Lists
.
newArrayList
(
services
);
Collections
.
shuffle
(
randomConfigServices
);
return
randomConfigServices
;
}
}
//Maintain admin server address
//Maintain admin server address
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/RetryableRestTemplate.java
View file @
9ad76d7c
...
@@ -78,8 +78,6 @@ public class RetryableRestTemplate {
...
@@ -78,8 +78,6 @@ public class RetryableRestTemplate {
ct
.
complete
();
ct
.
complete
();
throw
e
;
throw
e
;
}
}
//randomly load balance
Collections
.
shuffle
(
services
);
for
(
ServiceDTO
serviceDTO
:
services
)
{
for
(
ServiceDTO
serviceDTO
:
services
)
{
try
{
try
{
...
...
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