Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: code clean. #11337

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.alibaba.nacos.plugin.auth.constant.SignType;
import org.springframework.stereotype.Component;

import java.io.PrintWriter;
import java.net.URLEncoder;

import static com.alibaba.nacos.config.server.constant.Constants.ENCODE_UTF8;
Expand Down Expand Up @@ -109,7 +108,6 @@ private ConfigQueryResponse getContext(ConfigQueryRequest configQueryRequest, Re
int lockResult = tryConfigReadLock(groupKey);
String pullEvent = ConfigTraceService.PULL_EVENT;
boolean isBeta = false;
boolean isSli = false;
if (lockResult > 0) {
try {
String md5 = Constants.NULL;
Expand All @@ -125,7 +123,6 @@ private ConfigQueryResponse getContext(ConfigQueryRequest configQueryRequest, Re
}
String content = null;
ConfigInfoBase configInfoBase = null;
PrintWriter out = null;
if (isBeta) {
md5 = cacheItem.getConfigCacheBeta().getMd5(acceptCharset);
lastModified = cacheItem.getConfigCacheBeta().getLastModifiedTs();
Expand Down Expand Up @@ -164,20 +161,13 @@ private ConfigQueryResponse getContext(ConfigQueryRequest configQueryRequest, Re
}
pullEvent = ConfigTraceService.PULL_EVENT;
if (configInfoBase == null && content == null) {
// FIXME CacheItem
// No longer exists. It is impossible to simply calculate the push delayed. Here, simply record it as - 1.
ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, -1, pullEvent,
ConfigTraceService.PULL_TYPE_NOTFOUND, -1, clientIp, false, "grpc");

// pullLog.info("[client-get] clientIp={}, {},
// no data",
// new Object[]{clientIp, groupKey});

response.setErrorInfo(ConfigQueryResponse.CONFIG_NOT_FOUND, "config data not exist");
return response;
}
isSli = true;

}
} else {
if (cacheItem != null) {
Expand All @@ -192,18 +182,12 @@ private ConfigQueryResponse getContext(ConfigQueryRequest configQueryRequest, Re
response.setTag(tag);
pullEvent = ConfigTraceService.PULL_EVENT_TAG + "-" + tag;
if (configInfoBase == null && content == null) {
// FIXME CacheItem
// No longer exists. It is impossible to simply calculate the push delayed. Here, simply record it as - 1.
ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, -1, pullEvent,
ConfigTraceService.PULL_TYPE_NOTFOUND, -1, clientIp, false, "grpc");

// pullLog.info("[client-get] clientIp={}, {},
// no data",
// new Object[]{clientIp, groupKey});

response.setErrorInfo(ConfigQueryResponse.CONFIG_NOT_FOUND, "config data not exist");
return response;

}
}
}
Expand All @@ -215,25 +199,17 @@ private ConfigQueryResponse getContext(ConfigQueryRequest configQueryRequest, Re
response.setLastModified(lastModified);
response.setContent(configInfoBase.getContent());
response.setResultCode(ResponseCode.SUCCESS.getCode());

} else {
//read from file
try {
response.setContent(content);
response.setLastModified(lastModified);
response.setResultCode(ResponseCode.SUCCESS.getCode());
} catch (Exception e) {
response.setErrorInfo(ResponseCode.FAIL.getCode(), e.getMessage());
return response;
}
response.setContent(content);
response.setLastModified(lastModified);
response.setResultCode(ResponseCode.SUCCESS.getCode());
}

LogUtil.PULL_CHECK_LOG.warn("{}|{}|{}|{}", groupKey, clientIp, md5, TimeUtils.getCurrentTimeStr());

final long delayed = System.currentTimeMillis() - lastModified;

if (notify) {

ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, lastModified, pullEvent,
ConfigTraceService.PULL_TYPE_OK, delayed, clientIp, notify, "grpc");
} else {
Expand Down Expand Up @@ -263,8 +239,7 @@ private String getEncryptedDataKey(String tag, String clientIp, CacheItem cacheI
if (cacheItem == null) {
return null;
}

String encryptedDataKey = null;
String encryptedDataKey;
if (isBeta && cacheItem.getConfigCacheBeta() != null) {
encryptedDataKey = cacheItem.getConfigCacheBeta().getEncryptedDataKey();
} else {
Expand All @@ -282,7 +257,6 @@ private String getEncryptedDataKey(String tag, String clientIp, CacheItem cacheI
encryptedDataKey = cacheItem.getTagEncryptedDataKey(tag);
}
}

return encryptedDataKey;
}

Expand Down
Loading