Skip to content

Commit

Permalink
Fix warmup timestamp bug, add 'remote.timestamp' key to url on consum…
Browse files Browse the repository at this point in the history
…er side
  • Loading branch information
chickenlj committed Oct 10, 2017
1 parent ab47426 commit ed66afd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Expand Up @@ -48,7 +48,7 @@ public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invo
protected int getWeight(Invoker<?> invoker, Invocation invocation) {
int weight = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT);
if (weight > 0) {
long timestamp = invoker.getUrl().getParameter(Constants.TIMESTAMP_KEY, 0L);
long timestamp = invoker.getUrl().getParameter(Constants.REMOTE_TIMESTAMP_KEY, 0L);
if (timestamp > 0L) {
int uptime = (int) (System.currentTimeMillis() - timestamp);
int warmup = invoker.getUrl().getParameter(Constants.WARMUP_KEY, Constants.DEFAULT_WARMUP);
Expand Down
Expand Up @@ -80,6 +80,8 @@ public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {
if (methods != null && methods.length() > 0) {
map.put(Constants.METHODS_KEY, methods);
}
// 保留provider的启动timestamp
map.put(Constants.REMOTE_TIMESTAMP_KEY, remoteMap.get(Constants.TIMESTAMP_KEY));
// 合并filter和listener
String remoteFilter = remoteMap.get(Constants.REFERENCE_FILTER_KEY);
String localFilter = localMap.get(Constants.REFERENCE_FILTER_KEY);
Expand Down
Expand Up @@ -296,6 +296,8 @@ public class Constants {

public static final String TIMESTAMP_KEY = "timestamp";

public static final String REMOTE_TIMESTAMP_KEY = "remote.timestamp";

public static final String WARMUP_KEY = "warmup";

public static final int DEFAULT_WARMUP = 10 * 60 * 1000;
Expand Down

0 comments on commit ed66afd

Please sign in to comment.