Commit 57ddd524 authored by 张乐's avatar 张乐 Committed by GitHub

Merge pull request #285 from nobodyiam/fix-client-rate-limiter-issue

use tryAcquire to avoid acquire compatibility issue
parents b75a4114 98fea81f
...@@ -161,7 +161,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { ...@@ -161,7 +161,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
} }
private ApolloConfig loadApolloConfig() { private ApolloConfig loadApolloConfig() {
m_loadConfigRateLimiter.acquire(); m_loadConfigRateLimiter.tryAcquire(5, TimeUnit.SECONDS);//wait at most 5 seconds
String appId = m_configUtil.getAppId(); String appId = m_configUtil.getAppId();
String cluster = m_configUtil.getCluster(); String cluster = m_configUtil.getCluster();
String dataCenter = m_configUtil.getDataCenter(); String dataCenter = m_configUtil.getDataCenter();
...@@ -285,7 +285,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { ...@@ -285,7 +285,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
final Random random = new Random(); final Random random = new Random();
ServiceDTO lastServiceDto = null; ServiceDTO lastServiceDto = null;
while (!m_longPollingStopped.get() && !Thread.currentThread().isInterrupted()) { while (!m_longPollingStopped.get() && !Thread.currentThread().isInterrupted()) {
m_longPollRateLimiter.acquire(); m_longPollRateLimiter.tryAcquire(5, TimeUnit.SECONDS);//wait at most 5 seconds
Transaction transaction = Cat.newTransaction("Apollo.ConfigService", "pollNotification"); Transaction transaction = Cat.newTransaction("Apollo.ConfigService", "pollNotification");
try { try {
if (lastServiceDto == null) { if (lastServiceDto == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment