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

[ISSUE#11659] Develop config query chain of responsibility. #12892

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -28,6 +28,7 @@
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.constant.ParametersField;
import com.alibaba.nacos.config.server.controller.parameters.SameNamespaceCloneConfigBean;
import com.alibaba.nacos.config.server.enums.ApiVersionEnum;
import com.alibaba.nacos.config.server.model.ConfigAdvanceInfo;
import com.alibaba.nacos.config.server.model.ConfigAllInfo;
import com.alibaba.nacos.config.server.model.ConfigInfo;
Expand Down Expand Up @@ -244,7 +245,7 @@ public void getConfig(HttpServletRequest request, HttpServletResponse response,

final String clientIp = RequestUtil.getRemoteIp(request);
String isNotify = request.getHeader("notify");
inner.doGetConfig(request, response, dataId, group, tenant, tag, isNotify, clientIp);
inner.doGetConfig(request, response, dataId, group, tenant, tag, isNotify, clientIp, ApiVersionEnum.V1);
}

/**
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.controller.ConfigServletInner;
import com.alibaba.nacos.config.server.enums.ApiVersionEnum;
import com.alibaba.nacos.config.server.model.ConfigInfo;
import com.alibaba.nacos.config.server.model.ConfigRequestInfo;
import com.alibaba.nacos.config.server.paramcheck.ConfigBlurSearchHttpParamExtractor;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void getConfig(HttpServletRequest request, HttpServletResponse response,
ParamUtils.checkParamV2(tag);
final String clientIp = RequestUtil.getRemoteIp(request);
String isNotify = request.getHeader("notify");
inner.doGetConfig(request, response, dataId, group, namespaceId, tag, isNotify, clientIp, true);
inner.doGetConfig(request, response, dataId, group, namespaceId, tag, isNotify, clientIp, ApiVersionEnum.V2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 1999-$toady.year Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.config.server.enums;

/**
* Config Api Version enum.
* @author Nacos
*/
public enum ApiVersionEnum {

V1("v1"),

V2("v2");

private final String version;

ApiVersionEnum(String version) {
this.version = version;
}

public String getVersion() {
return version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 1999-$toady.year Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.config.server.model;

import java.util.Map;
import java.util.Objects;

/**
* ConfigQueryChainRequest.
* @author Nacos
*/
public class ConfigQueryChainRequest {

private String dataId;

private String group;

private String tenant;

private String tag;

private Map<String, String> appLabels;

public String getDataId() {
return dataId;
}

public void setDataId(String dataId) {
this.dataId = dataId;
}

public String getGroup() {
return group;
}

public void setGroup(String group) {
this.group = group;
}

public String getTenant() {
return tenant;
}

public void setTenant(String tenant) {
this.tenant = tenant;
}

public String getTag() {
return tag;
}

public void setTag(String tag) {
this.tag = tag;
}

public Map<String, String> getAppLabels() {
return appLabels;
}

public void setAppLabels(Map<String, String> appLabels) {
this.appLabels = appLabels;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConfigQueryChainRequest that = (ConfigQueryChainRequest) o;
return Objects.equals(dataId, that.dataId)
&& Objects.equals(group, that.group)
&& Objects.equals(tenant, that.tenant)
&& Objects.equals(tag, that.tag)
&& Objects.equals(appLabels, that.appLabels);
}

@Override
public int hashCode() {
return Objects.hash(dataId, group, tenant, tag, appLabels);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright 1999-$toady.year Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.config.server.model;

import java.util.Objects;

/**
* ConfigQueryChainResponse.
* @author Nacos
*/
public class ConfigQueryChainResponse {

private String content;

private String contentType;

private String encryptedDataKey;

private String md5;

private long lastModified;

private ConfigCacheGray matchedGray;

private ConfigQueryStatus status;

public enum ConfigQueryStatus {
BETA,
TAG,
TAG_NOT_FOUND,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beta,tag-> gray

FORMAL,
CONFIG_QUERY_CONFLICT,
CONFIG_NOT_FOUND,
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public String getContentType() {
return contentType;
}

public void setContentType(String contentType) {
this.contentType = contentType;
}

public String getEncryptedDataKey() {
return encryptedDataKey;
}

public void setEncryptedDataKey(String encryptedDataKey) {
this.encryptedDataKey = encryptedDataKey;
}

public String getMd5() {
return md5;
}

public void setMd5(String md5) {
this.md5 = md5;
}

public long getLastModified() {
return lastModified;
}

public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}

public ConfigCacheGray getMatchedGray() {
return matchedGray;
}

public void setMatchedGray(ConfigCacheGray matchedGray) {
this.matchedGray = matchedGray;
}

public ConfigQueryStatus getStatus() {
return status;
}

public void setStatus(ConfigQueryStatus status) {
this.status = status;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConfigQueryChainResponse that = (ConfigQueryChainResponse) o;
return lastModified == that.lastModified
&& Objects.equals(content, that.content)
&& Objects.equals(contentType, that.contentType)
&& Objects.equals(encryptedDataKey, that.encryptedDataKey)
&& Objects.equals(md5, that.md5)
&& Objects.equals(matchedGray, that.matchedGray)
&& status == that.status;
}

@Override
public int hashCode() {
return Objects.hash(content, contentType, encryptedDataKey, md5, lastModified, matchedGray, status);
}
}
Loading
Loading