提交 8eac52e5 编写于 作者: C Crecel 提交者: Jared Tan

configure the server side's long polling timeout (#2532)

* configure server side's long polling timeout

* logical update

* Revert "logical update"

This reverts commit 99943df3

* logic uapte
上级 cbb6d7d5
......@@ -27,6 +27,7 @@ public class BizConfig extends RefreshableConfig {
private static final int DEFAULT_RELEASE_MESSAGE_SCAN_INTERVAL_IN_MS = 1000; //1000ms
private static final int DEFAULT_RELEASE_MESSAGE_NOTIFICATION_BATCH = 100;
private static final int DEFAULT_RELEASE_MESSAGE_NOTIFICATION_BATCH_INTERVAL_IN_MILLI = 100;//100ms
private static final int DEFAULT_LONG_POLLING_TIMEOUT = 60; //60s
private Gson gson = new Gson();
private static final Type namespaceValueLengthOverrideTypeReference =
......@@ -58,6 +59,11 @@ public class BizConfig extends RefreshableConfig {
return checkInt(interval, 1, Integer.MAX_VALUE, DEFAULT_GRAY_RELEASE_RULE_SCAN_INTERVAL);
}
public long longPollingTimeout() {
int timeout = getIntProperty("long.polling.timeout", DEFAULT_LONG_POLLING_TIMEOUT);
return 1000 * checkInt(timeout, 1, Integer.MAX_VALUE, DEFAULT_LONG_POLLING_TIMEOUT);
}
public int itemKeyLengthLimit() {
int limit = getIntProperty("item.key.length.limit", DEFAULT_ITEM_KEY_LENGTH);
return checkInt(limit, 5, Integer.MAX_VALUE, DEFAULT_ITEM_KEY_LENGTH);
......@@ -146,4 +152,5 @@ public class BizConfig extends RefreshableConfig {
}
return defaultValue;
}
}
......@@ -108,7 +108,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
throw new BadRequestException("Invalid format of notifications: " + notificationsAsString);
}
DeferredResultWrapper deferredResultWrapper = new DeferredResultWrapper();
DeferredResultWrapper deferredResultWrapper = new DeferredResultWrapper(bizConfig.longPollingTimeout());
Set<String> namespaces = Sets.newHashSet();
Map<String, Long> clientSideNotifications = Maps.newHashMap();
Map<String, ApolloConfigNotification> filteredNotifications = filterNotifications(appId, notifications);
......
......@@ -16,7 +16,6 @@ import java.util.Map;
* @author Jason Song(song_s@ctrip.com)
*/
public class DeferredResultWrapper {
private static final long TIMEOUT = 60 * 1000;//60 seconds
private static final ResponseEntity<List<ApolloConfigNotification>>
NOT_MODIFIED_RESPONSE_LIST = new ResponseEntity<>(HttpStatus.NOT_MODIFIED);
......@@ -24,8 +23,8 @@ public class DeferredResultWrapper {
private DeferredResult<ResponseEntity<List<ApolloConfigNotification>>> result;
public DeferredResultWrapper() {
result = new DeferredResult<>(TIMEOUT, NOT_MODIFIED_RESPONSE_LIST);
public DeferredResultWrapper(long timeout) {
result = new DeferredResult<>(timeout, NOT_MODIFIED_RESPONSE_LIST);
}
public void recordNamespaceNameNormalizedResult(String originalNamespaceName, String normalizedNamespaceName) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册