Fix typo: Long pulling -> Long polling.
This commit is contained in:
parent
d5fcfc4a81
commit
98e447e146
@ -114,7 +114,7 @@ public class Constants {
|
||||
|
||||
public static final String WORD_SEPARATOR = Character.toString((char)2);
|
||||
|
||||
public static final String LONGPULLING_LINE_SEPARATOR = "\r\n";
|
||||
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";
|
||||
|
||||
public static final String CLIENT_APPNAME_HEADER = "Client-AppName";
|
||||
public static final String CLIENT_REQUEST_TS_HEADER = "Client-RequestTS";
|
||||
|
@ -57,7 +57,7 @@ public class NacosConfigService implements ConfigService {
|
||||
*/
|
||||
private ServerHttpAgent agent;
|
||||
/**
|
||||
* longpulling
|
||||
* longpolling
|
||||
*/
|
||||
private ClientWorker worker;
|
||||
private String namespace;
|
||||
|
@ -43,7 +43,7 @@ import static com.alibaba.nacos.api.common.Constants.LINE_SEPARATOR;
|
||||
import static com.alibaba.nacos.api.common.Constants.WORD_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Longpulling
|
||||
* Longpolling
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
@ -289,7 +289,7 @@ public class ClientWorker {
|
||||
if (longingTaskCount > currentLongingTaskCount) {
|
||||
for (int i = (int)currentLongingTaskCount; i < longingTaskCount; i++) {
|
||||
// 要判断任务是否在执行 这块需要好好想想。 任务列表现在是无序的。变化过程可能有问题
|
||||
executorService.execute(new LongPullingRunnable(i));
|
||||
executorService.execute(new LongPollingRunnable(i));
|
||||
}
|
||||
currentLongingTaskCount = longingTaskCount;
|
||||
}
|
||||
@ -330,12 +330,12 @@ public class ClientWorker {
|
||||
long timeout = TimeUnit.SECONDS.toMillis(30L);
|
||||
|
||||
List<String> headers = new ArrayList<String>(2);
|
||||
headers.add("Long-Pulling-Timeout");
|
||||
headers.add("Long-Polling-Timeout");
|
||||
headers.add("" + timeout);
|
||||
|
||||
// told server do not hang me up if new initializing cacheData added in
|
||||
if (isInitializingCacheList) {
|
||||
headers.add("Long-Pulling-Timeout-No-Hangup");
|
||||
headers.add("Long-Polling-Timeout-No-Hangup");
|
||||
headers.add("true");
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ public class ClientWorker {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
t.setName("com.alibaba.nacos.client.Worker.longPulling" + agent.getName());
|
||||
t.setName("com.alibaba.nacos.client.Worker.longPolling" + agent.getName());
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
@ -440,10 +440,10 @@ public class ClientWorker {
|
||||
}, 1L, 10L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
class LongPullingRunnable implements Runnable {
|
||||
class LongPollingRunnable implements Runnable {
|
||||
private int taskId;
|
||||
|
||||
public LongPullingRunnable(int taskId) {
|
||||
public LongPollingRunnable(int taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ public class ClientWorker {
|
||||
}
|
||||
inInitializingCacheList.clear();
|
||||
} catch (Throwable e) {
|
||||
log.error("500", "longPulling error", e);
|
||||
log.error("500", "longPolling error", e);
|
||||
} finally {
|
||||
executorService.execute(this);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class ConfigServletInner {
|
||||
|
||||
private static final int TRY_GET_LOCK_TIMES = 9;
|
||||
|
||||
private static final int START_LONGPULLING_VERSION_NUM = 204;
|
||||
private static final int START_LONGPOLLING_VERSION_NUM = 204;
|
||||
|
||||
/**
|
||||
* 轮询接口
|
||||
@ -70,8 +70,8 @@ public class ConfigServletInner {
|
||||
throws IOException, ServletException {
|
||||
|
||||
// 长轮询
|
||||
if (LongPollingService.isSupportLongPulling(request)) {
|
||||
longPollingService.addLongPullingClient(request, response, clientMd5Map, probeRequestSize);
|
||||
if (LongPollingService.isSupportLongPolling(request)) {
|
||||
longPollingService.addLongPollingClient(request, response, clientMd5Map, probeRequestSize);
|
||||
return HttpServletResponse.SC_OK + "";
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class ConfigServletInner {
|
||||
/**
|
||||
* 2.0.4版本以前, 返回值放入header中
|
||||
*/
|
||||
if (versionNum < START_LONGPULLING_VERSION_NUM) {
|
||||
if (versionNum < START_LONGPOLLING_VERSION_NUM) {
|
||||
response.addHeader(Constants.PROBE_MODIFY_RESPONSE, oldResult);
|
||||
response.addHeader(Constants.PROBE_MODIFY_RESPONSE_NEW, newResult);
|
||||
} else {
|
||||
|
@ -35,7 +35,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Config longpulling
|
||||
* Config longpolling
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ public class LongPollingService extends AbstractEventListener {
|
||||
}
|
||||
|
||||
public Map<String, String> getClientSubConfigInfo(String clientIp) {
|
||||
ClientLongPulling record = getClientPollingRecord(clientIp);
|
||||
ClientLongPolling record = getClientPollingRecord(clientIp);
|
||||
|
||||
if (record == null) {
|
||||
return Collections.<String, String>emptyMap();
|
||||
@ -79,9 +79,9 @@ public class LongPollingService extends AbstractEventListener {
|
||||
SampleResult sampleResult = new SampleResult();
|
||||
Map<String, String> lisentersGroupkeyStatus = new HashMap<String, String>(50);
|
||||
|
||||
for (ClientLongPulling clientLongPulling : allSubs) {
|
||||
if (clientLongPulling.clientMd5Map.containsKey(groupKey)) {
|
||||
lisentersGroupkeyStatus.put(clientLongPulling.ip, clientLongPulling.clientMd5Map.get(groupKey));
|
||||
for (ClientLongPolling clientLongPolling : allSubs) {
|
||||
if (clientLongPolling.clientMd5Map.containsKey(groupKey)) {
|
||||
lisentersGroupkeyStatus.put(clientLongPolling.ip, clientLongPolling.clientMd5Map.get(groupKey));
|
||||
}
|
||||
}
|
||||
sampleResult.setLisentersGroupkeyStatus(lisentersGroupkeyStatus);
|
||||
@ -92,11 +92,11 @@ public class LongPollingService extends AbstractEventListener {
|
||||
SampleResult sampleResult = new SampleResult();
|
||||
Map<String, String> lisentersGroupkeyStatus = new HashMap<String, String>(50);
|
||||
|
||||
for (ClientLongPulling clientLongPulling : allSubs) {
|
||||
if (clientLongPulling.ip.equals(clientIp)) {
|
||||
for (ClientLongPolling clientLongPolling : allSubs) {
|
||||
if (clientLongPolling.ip.equals(clientIp)) {
|
||||
// 一个ip可能有多个监听
|
||||
if (!lisentersGroupkeyStatus.equals(clientLongPulling.clientMd5Map)) {
|
||||
lisentersGroupkeyStatus.putAll(clientLongPulling.clientMd5Map);
|
||||
if (!lisentersGroupkeyStatus.equals(clientLongPolling.clientMd5Map)) {
|
||||
lisentersGroupkeyStatus.putAll(clientLongPolling.clientMd5Map);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,18 +128,18 @@ public class LongPollingService extends AbstractEventListener {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, Set<String>> app2Groupkeys = new HashMap<String, Set<String>>(50);
|
||||
for (ClientLongPulling clientLongPulling : allSubs) {
|
||||
if (StringUtils.isEmpty(clientLongPulling.appName) || "unknown".equalsIgnoreCase(
|
||||
clientLongPulling.appName)) {
|
||||
for (ClientLongPolling clientLongPolling : allSubs) {
|
||||
if (StringUtils.isEmpty(clientLongPolling.appName) || "unknown".equalsIgnoreCase(
|
||||
clientLongPolling.appName)) {
|
||||
continue;
|
||||
}
|
||||
Set<String> appSubscribeConfigs = app2Groupkeys.get(clientLongPulling.appName);
|
||||
Set<String> clientSubscribeConfigs = clientLongPulling.clientMd5Map.keySet();
|
||||
Set<String> appSubscribeConfigs = app2Groupkeys.get(clientLongPolling.appName);
|
||||
Set<String> clientSubscribeConfigs = clientLongPolling.clientMd5Map.keySet();
|
||||
if (appSubscribeConfigs == null) {
|
||||
appSubscribeConfigs = new HashSet<String>(clientSubscribeConfigs.size());
|
||||
}
|
||||
appSubscribeConfigs.addAll(clientSubscribeConfigs);
|
||||
app2Groupkeys.put(clientLongPulling.appName, appSubscribeConfigs);
|
||||
app2Groupkeys.put(clientLongPolling.appName, appSubscribeConfigs);
|
||||
}
|
||||
|
||||
return app2Groupkeys;
|
||||
@ -187,27 +187,27 @@ public class LongPollingService extends AbstractEventListener {
|
||||
return sampleResult;
|
||||
}
|
||||
|
||||
private ClientLongPulling getClientPollingRecord(String clientIp) {
|
||||
private ClientLongPolling getClientPollingRecord(String clientIp) {
|
||||
if (allSubs == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ClientLongPulling clientLongPulling : allSubs) {
|
||||
HttpServletRequest request = (HttpServletRequest)clientLongPulling.asyncContext.getRequest();
|
||||
for (ClientLongPolling clientLongPolling : allSubs) {
|
||||
HttpServletRequest request = (HttpServletRequest) clientLongPolling.asyncContext.getRequest();
|
||||
|
||||
if (clientIp.equals(RequestUtil.getRemoteIp(request))) {
|
||||
return clientLongPulling;
|
||||
return clientLongPolling;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addLongPullingClient(HttpServletRequest req, HttpServletResponse rsp, Map<String, String> clientMd5Map,
|
||||
public void addLongPollingClient(HttpServletRequest req, HttpServletResponse rsp, Map<String, String> clientMd5Map,
|
||||
int probeRequestSize) {
|
||||
|
||||
String str = req.getHeader(LongPollingService.LONG_PULLING_HEADER);
|
||||
String noHangUpFlag = req.getHeader(LongPollingService.LONG_PULLING_NO_HANG_UP_HEADER);
|
||||
String str = req.getHeader(LongPollingService.LONG_POLLING_HEADER);
|
||||
String noHangUpFlag = req.getHeader(LongPollingService.LONG_POLLING_NO_HANG_UP_HEADER);
|
||||
String appName = req.getHeader(RequestUtil.CLIENT_APPNAME_HEADER);
|
||||
String tag = req.getHeader("Vipserver-Tag");
|
||||
int delayTime = SwitchService.getSwitchInteger(SwitchService.FIXED_DELAY_TIME, 500);
|
||||
@ -241,7 +241,7 @@ public class LongPollingService extends AbstractEventListener {
|
||||
asyncContext.setTimeout(0L);
|
||||
|
||||
scheduler.execute(
|
||||
new ClientLongPulling(asyncContext, clientMd5Map, ip, probeRequestSize, timeout, appName, tag));
|
||||
new ClientLongPolling(asyncContext, clientMd5Map, ip, probeRequestSize, timeout, appName, tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,20 +263,20 @@ public class LongPollingService extends AbstractEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean isSupportLongPulling(HttpServletRequest req) {
|
||||
return null != req.getHeader(LONG_PULLING_HEADER);
|
||||
static public boolean isSupportLongPolling(HttpServletRequest req) {
|
||||
return null != req.getHeader(LONG_POLLING_HEADER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.ThreadPoolCreationRule")
|
||||
public LongPollingService() {
|
||||
allSubs = new ConcurrentLinkedQueue<ClientLongPulling>();
|
||||
allSubs = new ConcurrentLinkedQueue<ClientLongPolling>();
|
||||
|
||||
scheduler = Executors.newScheduledThreadPool(1, new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
t.setDaemon(true);
|
||||
t.setName("com.alibaba.nacos.LongPulling");
|
||||
t.setName("com.alibaba.nacos.LongPolling");
|
||||
return t;
|
||||
}
|
||||
});
|
||||
@ -285,15 +285,15 @@ public class LongPollingService extends AbstractEventListener {
|
||||
|
||||
// =================
|
||||
|
||||
static public final String LONG_PULLING_HEADER = "Long-Pulling-Timeout";
|
||||
static public final String LONG_PULLING_NO_HANG_UP_HEADER = "Long-Pulling-Timeout-No-Hangup";
|
||||
static public final String LONG_POLLING_HEADER = "Long-Polling-Timeout";
|
||||
static public final String LONG_POLLING_NO_HANG_UP_HEADER = "Long-Polling-Timeout-No-Hangup";
|
||||
|
||||
final ScheduledExecutorService scheduler;
|
||||
|
||||
/**
|
||||
* 长轮询订阅关系
|
||||
*/
|
||||
final Queue<ClientLongPulling> allSubs;
|
||||
final Queue<ClientLongPolling> allSubs;
|
||||
|
||||
// =================
|
||||
|
||||
@ -302,8 +302,8 @@ public class LongPollingService extends AbstractEventListener {
|
||||
public void run() {
|
||||
try {
|
||||
ConfigService.getContentBetaMd5(groupKey);
|
||||
for (Iterator<ClientLongPulling> iter = allSubs.iterator(); iter.hasNext(); ) {
|
||||
ClientLongPulling clientSub = iter.next();
|
||||
for (Iterator<ClientLongPolling> iter = allSubs.iterator(); iter.hasNext(); ) {
|
||||
ClientLongPolling clientSub = iter.next();
|
||||
if (clientSub.clientMd5Map.containsKey(groupKey)) {
|
||||
// 如果beta发布且不在beta列表直接跳过
|
||||
if (isBeta && !betaIps.contains(clientSub.ip)) {
|
||||
@ -358,24 +358,24 @@ public class LongPollingService extends AbstractEventListener {
|
||||
class StatTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
memoryLog.info("[long-pulling] client count " + allSubs.size());
|
||||
memoryLog.info("[long-polling] client count " + allSubs.size());
|
||||
}
|
||||
}
|
||||
|
||||
// =================
|
||||
|
||||
class ClientLongPulling implements Runnable {
|
||||
class ClientLongPolling implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
asyncTimeoutFuture = scheduler.schedule(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
getRetainIps().put(ClientLongPulling.this.ip, System.currentTimeMillis());
|
||||
getRetainIps().put(ClientLongPolling.this.ip, System.currentTimeMillis());
|
||||
/**
|
||||
* 删除订阅关系
|
||||
*/
|
||||
allSubs.remove(ClientLongPulling.this);
|
||||
allSubs.remove(ClientLongPolling.this);
|
||||
|
||||
if (isFixedPolling()) {
|
||||
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}",
|
||||
@ -400,7 +400,7 @@ public class LongPollingService extends AbstractEventListener {
|
||||
sendResponse(null);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LogUtil.defaultLog.error("long pulling error:" + t.getMessage(), t.getCause());
|
||||
LogUtil.defaultLog.error("long polling error:" + t.getMessage(), t.getCause());
|
||||
}
|
||||
|
||||
}
|
||||
@ -446,7 +446,7 @@ public class LongPollingService extends AbstractEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
ClientLongPulling(AsyncContext ac, Map<String, String> clientMd5Map, String ip, int probeRequestSize,
|
||||
ClientLongPolling(AsyncContext ac, Map<String, String> clientMd5Map, String ip, int probeRequestSize,
|
||||
long timeoutTime, String appName, String tag) {
|
||||
this.asyncContext = ac;
|
||||
this.clientMd5Map = clientMd5Map;
|
||||
|
Loading…
Reference in New Issue
Block a user