Commit 95cf37c5 by Jason Song

dramatically improve the apollo client unit test performance

parent 91f5b94c
......@@ -131,7 +131,7 @@ public class ConfigServiceLocator implements Initializable {
}
try {
TimeUnit.SECONDS.sleep(1);
m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) {
//ignore
}
......
......@@ -228,7 +228,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
}
try {
TimeUnit.SECONDS.sleep(1);
m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) {
//ignore
}
......
......@@ -29,6 +29,9 @@ public class ConfigUtil {
private String cluster;
private int loadConfigQPS = 2; //2 times per second
private int longPollQPS = 2; //2 times per second
//for on error retry
private long onErrorRetryInterval = 1;//1 second
private TimeUnit onErrorRetryIntervalTimeUnit = TimeUnit.SECONDS;//1 second
//for typed config cache of parser result, e.g. integer, double, long, etc.
private long maxConfigCacheSize = 500;//500 cache key
private long configCacheExpireTime = 1;//1 minute
......@@ -212,6 +215,14 @@ public class ConfigUtil {
return longPollQPS;
}
public long getOnErrorRetryInterval() {
return onErrorRetryInterval;
}
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return onErrorRetryIntervalTimeUnit;
}
public String getDefaultLocalCacheDir() {
String cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s";
return String.format(cacheRoot, getAppId());
......
......@@ -182,6 +182,16 @@ public abstract class BaseIntegrationTest extends ComponentTestCase {
public String getDefaultLocalCacheDir() {
return ClassLoaderUtil.getClassPath();
}
@Override
public long getOnErrorRetryInterval() {
return 10;
}
@Override
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return TimeUnit.MILLISECONDS;
}
}
/**
......
......@@ -233,6 +233,16 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
public int getLongPollQPS() {
return 200;
}
@Override
public long getOnErrorRetryInterval() {
return 10;
}
@Override
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return TimeUnit.MILLISECONDS;
}
}
public static class MockConfigServiceLocator extends ConfigServiceLocator {
......
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