Update version to 1.1.4
This commit is contained in:
parent
2587fa1415
commit
4d68565667
@ -16,7 +16,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>nacos-console</artifactId>
|
<artifactId>nacos-console</artifactId>
|
||||||
<!--<packaging>war</packaging>-->
|
<!--<packaging>war</packaging>-->
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ else
|
|||||||
JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
|
JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
|
||||||
JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
|
JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
|
||||||
JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
|
JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
|
||||||
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
|
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
|
||||||
|
@ -44,3 +44,5 @@ nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/
|
|||||||
# nacos.naming.distro.syncRetryDelay=5000
|
# nacos.naming.distro.syncRetryDelay=5000
|
||||||
# nacos.naming.data.warmup=true
|
# nacos.naming.data.warmup=true
|
||||||
# nacos.naming.expireInstance=true
|
# nacos.naming.expireInstance=true
|
||||||
|
|
||||||
|
nacos.istio.mcp.server.enabled=false
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -32,6 +32,7 @@ import io.grpc.stub.StreamObserver;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -64,7 +65,8 @@ public class NacosMcpService extends ResourceSourceGrpc.ResourceSourceImplBase {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IstioConfig istioConfig;
|
private IstioConfig istioConfig;
|
||||||
|
|
||||||
public NacosMcpService() {
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
if (!istioConfig.isMcpServerEnabled()) {
|
if (!istioConfig.isMcpServerEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import com.alibaba.nacos.naming.core.ServiceManager;
|
|||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import com.alibaba.nacos.naming.push.ClientInfo;
|
import com.alibaba.nacos.naming.push.ClientInfo;
|
||||||
import com.alibaba.nacos.naming.web.CanDistro;
|
import com.alibaba.nacos.naming.web.CanDistro;
|
||||||
|
import com.alibaba.nacos.naming.web.OverrideParameterRequestWrapper;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.codehaus.jackson.util.VersionUtil;
|
import org.codehaus.jackson.util.VersionUtil;
|
||||||
@ -141,13 +142,10 @@ public class ApiController extends InstanceController {
|
|||||||
|
|
||||||
@CanDistro
|
@CanDistro
|
||||||
@RequestMapping("/clientBeat")
|
@RequestMapping("/clientBeat")
|
||||||
public JSONObject clientBeat(HttpServletRequest request,
|
public JSONObject clientBeat(HttpServletRequest request) throws Exception {
|
||||||
@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(request);
|
||||||
@RequestParam String beat,
|
requestWrapper.addParameter(CommonParams.SERVICE_NAME,
|
||||||
@RequestParam String dom) throws Exception {
|
Constants.DEFAULT_GROUP + Constants.SERVICE_INFO_SPLITER + WebUtils.required(request, "dom"));
|
||||||
|
return beat(requestWrapper);
|
||||||
String serviceName = Constants.DEFAULT_GROUP + Constants.SERVICE_INFO_SPLITER + dom;
|
|
||||||
|
|
||||||
return beat(namespaceId, beat, serviceName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,13 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||||
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.core.Cluster;
|
import com.alibaba.nacos.naming.core.Cluster;
|
||||||
import com.alibaba.nacos.naming.core.Service;
|
import com.alibaba.nacos.naming.core.Service;
|
||||||
import com.alibaba.nacos.naming.core.ServiceManager;
|
import com.alibaba.nacos.naming.core.ServiceManager;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
|
||||||
import com.alibaba.nacos.naming.healthcheck.HealthCheckType;
|
import com.alibaba.nacos.naming.healthcheck.HealthCheckType;
|
||||||
import com.alibaba.nacos.naming.misc.Loggers;
|
import com.alibaba.nacos.naming.misc.Loggers;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
@ -32,9 +34,10 @@ import org.apache.commons.lang3.math.NumberUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
@ -46,13 +49,16 @@ public class ClusterController {
|
|||||||
protected ServiceManager serviceManager;
|
protected ServiceManager serviceManager;
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public String update( @RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
@RequestParam String clusterName,
|
|
||||||
@RequestParam String serviceName,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
@RequestParam String healthChecker,
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
@RequestParam(defaultValue = StringUtils.EMPTY) String metadata,
|
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
||||||
@RequestParam String checkPort,
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
@RequestParam String useInstancePort4Check) throws Exception {
|
String healthChecker = WebUtils.required(request, "healthChecker");
|
||||||
|
String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY);
|
||||||
|
String checkPort = WebUtils.required(request, "checkPort");
|
||||||
|
String useInstancePort4Check = WebUtils.required(request, "useInstancePort4Check");
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
@ -17,7 +17,9 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||||
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||||
import com.alibaba.nacos.naming.core.Instance;
|
import com.alibaba.nacos.naming.core.Instance;
|
||||||
import com.alibaba.nacos.naming.core.Service;
|
import com.alibaba.nacos.naming.core.Service;
|
||||||
@ -34,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -66,23 +69,29 @@ public class HealthController {
|
|||||||
|
|
||||||
@CanDistro
|
@CanDistro
|
||||||
@PutMapping(value = {"", "/instance"})
|
@PutMapping(value = {"", "/instance"})
|
||||||
public String update(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
public String update(HttpServletRequest request) {
|
||||||
@RequestParam String serviceName,
|
|
||||||
@RequestParam(defaultValue = UtilsAndCommons.DEFAULT_CLUSTER_NAME) String clusterName,
|
|
||||||
@RequestParam String ip,
|
|
||||||
@RequestParam int port,
|
|
||||||
@RequestParam(name = "healthy", defaultValue = StringUtils.EMPTY) String healthyString,
|
|
||||||
@RequestParam(defaultValue = StringUtils.EMPTY) String validString) {
|
|
||||||
|
|
||||||
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
String clusterName = WebUtils.optional(request, CommonParams.CLUSTER_NAME
|
||||||
|
, UtilsAndCommons.DEFAULT_CLUSTER_NAME);
|
||||||
|
|
||||||
|
String ip = WebUtils.required(request, "ip");
|
||||||
|
int port = Integer.parseInt(WebUtils.required(request, "port"));
|
||||||
|
|
||||||
|
boolean valid = false;
|
||||||
|
|
||||||
|
String healthyString = WebUtils.optional(request, "healthy", StringUtils.EMPTY);
|
||||||
if (StringUtils.isBlank(healthyString)) {
|
if (StringUtils.isBlank(healthyString)) {
|
||||||
healthyString = validString;
|
healthyString = WebUtils.optional(request, "valid", StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(healthyString)) {
|
if (StringUtils.isBlank(healthyString)) {
|
||||||
throw new IllegalArgumentException("Param 'healthy' is required.");
|
throw new IllegalArgumentException("Param 'healthy' is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean valid = BooleanUtils.toBoolean(healthyString);
|
valid = BooleanUtils.toBoolean(healthyString);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
// Only health check "none" need update health status with api
|
// Only health check "none" need update health status with api
|
||||||
|
@ -207,14 +207,15 @@ public class InstanceController {
|
|||||||
|
|
||||||
@CanDistro
|
@CanDistro
|
||||||
@PutMapping("/beat")
|
@PutMapping("/beat")
|
||||||
public JSONObject beat(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
public JSONObject beat(HttpServletRequest request) throws Exception {
|
||||||
@RequestParam String beat,
|
|
||||||
@RequestParam String serviceName) throws Exception {
|
|
||||||
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
|
|
||||||
result.put("clientBeatInterval", switchDomain.getClientBeatInterval());
|
result.put("clientBeatInterval", switchDomain.getClientBeatInterval());
|
||||||
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
String beat = WebUtils.required(request, "beat");
|
||||||
RsInfo clientBeat = JSON.parseObject(beat, RsInfo.class);
|
RsInfo clientBeat = JSON.parseObject(beat, RsInfo.class);
|
||||||
|
|
||||||
if (!switchDomain.isDefaultInstanceEphemeral() && !clientBeat.isEphemeral()) {
|
if (!switchDomain.isDefaultInstanceEphemeral() && !clientBeat.isEphemeral()) {
|
||||||
@ -445,7 +446,7 @@ public class InstanceController {
|
|||||||
|
|
||||||
double threshold = service.getProtectThreshold();
|
double threshold = service.getProtectThreshold();
|
||||||
|
|
||||||
if ((float)ipMap.get(Boolean.TRUE).size() / srvedIPs.size() <= threshold) {
|
if ((float) ipMap.get(Boolean.TRUE).size() / srvedIPs.size() <= threshold) {
|
||||||
|
|
||||||
Loggers.SRV_LOG.warn("protect threshold reached, return all ips, service: {}", serviceName);
|
Loggers.SRV_LOG.warn("protect threshold reached, return all ips, service: {}", serviceName);
|
||||||
if (isCheck) {
|
if (isCheck) {
|
||||||
|
@ -20,6 +20,8 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
import com.alibaba.nacos.common.util.IoUtils;
|
||||||
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.consistency.Datum;
|
import com.alibaba.nacos.naming.consistency.Datum;
|
||||||
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||||
import com.alibaba.nacos.naming.consistency.RecordListener;
|
import com.alibaba.nacos.naming.consistency.RecordListener;
|
||||||
@ -33,6 +35,7 @@ import com.alibaba.nacos.naming.misc.NetUtils;
|
|||||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import com.alibaba.nacos.naming.web.NeedAuth;
|
import com.alibaba.nacos.naming.web.NeedAuth;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -40,6 +43,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -66,19 +70,24 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@PostMapping("/vote")
|
@PostMapping("/vote")
|
||||||
public JSONObject vote(@RequestParam String vote) {
|
public JSONObject vote(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
RaftPeer peer = raftCore.receivedVote(
|
RaftPeer peer = raftCore.receivedVote(
|
||||||
JSON.parseObject(vote, RaftPeer.class));
|
JSON.parseObject(WebUtils.required(request, "vote"), RaftPeer.class));
|
||||||
|
|
||||||
return JSON.parseObject(JSON.toJSONString(peer));
|
return JSON.parseObject(JSON.toJSONString(peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@PostMapping("/beat")
|
@PostMapping("/beat")
|
||||||
public JSONObject beat(@RequestBody JSONObject json) throws Exception {
|
public JSONObject beat(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
JSONObject beat = json.getJSONObject("beat");
|
String entity = new String(IoUtils.tryDecompress(request.getInputStream()), StandardCharsets.UTF_8);
|
||||||
|
String value = URLDecoder.decode(entity, "UTF-8");
|
||||||
|
value = URLDecoder.decode(value, "UTF-8");
|
||||||
|
|
||||||
|
JSONObject json = JSON.parseObject(value);
|
||||||
|
JSONObject beat = JSON.parseObject(json.getString("beat"));
|
||||||
|
|
||||||
RaftPeer peer = raftCore.receivedBeat(beat);
|
RaftPeer peer = raftCore.receivedBeat(beat);
|
||||||
|
|
||||||
@ -87,7 +96,7 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@GetMapping("/peer")
|
@GetMapping("/peer")
|
||||||
public JSONObject getPeer() {
|
public JSONObject getPeer(HttpServletRequest request, HttpServletResponse response) {
|
||||||
List<RaftPeer> peers = raftCore.getPeers();
|
List<RaftPeer> peers = raftCore.getPeers();
|
||||||
RaftPeer peer = null;
|
RaftPeer peer = null;
|
||||||
|
|
||||||
@ -107,19 +116,24 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@PutMapping("/datum/reload")
|
@PutMapping("/datum/reload")
|
||||||
public String reloadDatum(@RequestParam String key) {
|
public String reloadDatum(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
String key = WebUtils.required(request, "key");
|
||||||
raftCore.loadDatum(key);
|
raftCore.loadDatum(key);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@PostMapping("/datum")
|
@PostMapping("/datum")
|
||||||
public String publish(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String publish(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setHeader("Content-Encode", "gzip");
|
response.setHeader("Content-Encode", "gzip");
|
||||||
|
|
||||||
|
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
|
||||||
|
String value = URLDecoder.decode(entity, "UTF-8");
|
||||||
|
JSONObject json = JSON.parseObject(value);
|
||||||
|
|
||||||
String key = json.getString("key");
|
String key = json.getString("key");
|
||||||
if (KeyBuilder.matchInstanceListKey(key)) {
|
if (KeyBuilder.matchInstanceListKey(key)) {
|
||||||
raftConsistencyService.put(key, JSON.parseObject(json.getString("value"), Instances.class));
|
raftConsistencyService.put(key, JSON.parseObject(json.getString("value"), Instances.class));
|
||||||
@ -141,24 +155,23 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@DeleteMapping("/datum")
|
@DeleteMapping("/datum")
|
||||||
public String delete(@RequestParam String key, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String delete(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setHeader("Content-Encode", "gzip");
|
response.setHeader("Content-Encode", "gzip");
|
||||||
|
raftConsistencyService.remove(WebUtils.required(request, "key"));
|
||||||
raftConsistencyService.remove(key);
|
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@GetMapping("/datum")
|
@GetMapping("/datum")
|
||||||
public String get(@RequestParam(name = "keys") String keysString, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String get(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setHeader("Content-Encode", "gzip");
|
response.setHeader("Content-Encode", "gzip");
|
||||||
|
String keysString = WebUtils.required(request, "keys");
|
||||||
keysString = URLDecoder.decode(keysString, "UTF-8");
|
keysString = URLDecoder.decode(keysString, "UTF-8");
|
||||||
String[] keys = keysString.split(",");
|
String[] keys = keysString.split(",");
|
||||||
List<Datum> datums = new ArrayList<Datum>();
|
List<Datum> datums = new ArrayList<Datum>();
|
||||||
@ -172,7 +185,7 @@ public class RaftController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/state")
|
@GetMapping("/state")
|
||||||
public JSONObject state(HttpServletRequest request, HttpServletResponse response) {
|
public JSONObject state(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
@ -187,15 +200,18 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@PostMapping("/datum/commit")
|
@PostMapping("/datum/commit")
|
||||||
public String onPublish(@RequestBody JSONObject jsonObject, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String onPublish(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setHeader("Content-Encode", "gzip");
|
response.setHeader("Content-Encode", "gzip");
|
||||||
|
|
||||||
|
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
|
||||||
|
String value = URLDecoder.decode(entity, "UTF-8");
|
||||||
|
JSONObject jsonObject = JSON.parseObject(value);
|
||||||
String key = "key";
|
String key = "key";
|
||||||
|
|
||||||
RaftPeer source = jsonObject.getObject("source", RaftPeer.class);
|
RaftPeer source = JSON.parseObject(jsonObject.getString("source"), RaftPeer.class);
|
||||||
JSONObject datumJson = jsonObject.getJSONObject("datum");
|
JSONObject datumJson = jsonObject.getJSONObject("datum");
|
||||||
|
|
||||||
Datum datum = null;
|
Datum datum = null;
|
||||||
@ -216,21 +232,26 @@ public class RaftController {
|
|||||||
|
|
||||||
@NeedAuth
|
@NeedAuth
|
||||||
@DeleteMapping("/datum/commit")
|
@DeleteMapping("/datum/commit")
|
||||||
public String onDelete(@RequestBody JSONObject jsonObject, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String onDelete(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setHeader("Content-Encode", "gzip");
|
response.setHeader("Content-Encode", "gzip");
|
||||||
|
|
||||||
Datum datum = jsonObject.getObject("datum", Datum.class);
|
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
|
||||||
RaftPeer source = jsonObject.getObject("source", RaftPeer.class);
|
String value = URLDecoder.decode(entity, "UTF-8");
|
||||||
|
value = URLDecoder.decode(value, "UTF-8");
|
||||||
|
JSONObject jsonObject = JSON.parseObject(value);
|
||||||
|
|
||||||
|
Datum datum = JSON.parseObject(jsonObject.getString("datum"), Datum.class);
|
||||||
|
RaftPeer source = JSON.parseObject(jsonObject.getString("source"), RaftPeer.class);
|
||||||
|
|
||||||
raftConsistencyService.onRemove(datum, source);
|
raftConsistencyService.onRemove(datum, source);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/leader")
|
@GetMapping("/leader")
|
||||||
public JSONObject getLeader() {
|
public JSONObject getLeader(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("leader", JSONObject.toJSONString(raftCore.getLeader()));
|
result.put("leader", JSONObject.toJSONString(raftCore.getLeader()));
|
||||||
@ -238,20 +259,21 @@ public class RaftController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/listeners")
|
@GetMapping("/listeners")
|
||||||
public JSONObject getAllListeners() {
|
public JSONObject getAllListeners(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
Map<String, List<RecordListener>> listeners = raftCore.getListeners();
|
Map<String, List<RecordListener>> listeners = raftCore.getListeners();
|
||||||
|
|
||||||
JSONArray listenerArray = new JSONArray();
|
JSONArray listenerArray = new JSONArray();
|
||||||
listenerArray.addAll(listeners.keySet());
|
for (String key : listeners.keySet()) {
|
||||||
|
listenerArray.add(key);
|
||||||
|
}
|
||||||
result.put("listeners", listenerArray);
|
result.put("listeners", listenerArray);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAcceptEncoding(HttpServletRequest req) {
|
public static String getAcceptEncoding(HttpServletRequest req) {
|
||||||
String encode = StringUtils.defaultIfEmpty(req.getHeader("Accept-Charset"), "UTF-8");
|
String encode = StringUtils.defaultIfEmpty(req.getHeader("Accept-Charset"), "UTF-8");
|
||||||
encode = encode.contains(",") ? encode.substring(0, encode.indexOf(",")) : encode;
|
encode = encode.contains(",") ? encode.substring(0, encode.indexOf(",")) : encode;
|
||||||
return encode.contains(";") ? encode.substring(0, encode.indexOf(";")) : encode;
|
return encode.contains(";") ? encode.substring(0, encode.indexOf(";")) : encode;
|
||||||
|
@ -209,11 +209,14 @@ public class ServiceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public String update(HttpServletRequest request,@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
@RequestParam String serviceName,
|
|
||||||
@RequestParam(required = false) float protectThreshold,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
@RequestParam(defaultValue = StringUtils.EMPTY) String metadata,
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
@RequestParam(defaultValue = StringUtils.EMPTY) String selector) throws Exception {
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
float protectThreshold = NumberUtils.toFloat(WebUtils.required(request, "protectThreshold"));
|
||||||
|
String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY);
|
||||||
|
String selector = WebUtils.optional(request, "selector", StringUtils.EMPTY);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
@ -315,28 +315,16 @@ public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return new HashCodeBuilder(17, 37)
|
return Objects.hash(getName());
|
||||||
.append(getName())
|
|
||||||
.append(service)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object obj) {
|
||||||
if (this == o) {
|
if (!(obj instanceof Cluster)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cluster cluster = (Cluster) o;
|
return getName().equals(((Cluster) obj).getName());
|
||||||
|
|
||||||
return new EqualsBuilder()
|
|
||||||
.append(getName(), cluster.getName())
|
|
||||||
.append(service, cluster.service)
|
|
||||||
.isEquals();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefCkport() {
|
public int getDefCkport() {
|
||||||
|
@ -424,6 +424,9 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
|||||||
|
|
||||||
updateOrAddCluster(vDom.getClusterMap().values());
|
updateOrAddCluster(vDom.getClusterMap().values());
|
||||||
remvDeadClusters(this, vDom);
|
remvDeadClusters(this, vDom);
|
||||||
|
|
||||||
|
Loggers.SRV_LOG.info("cluster size, new: {}, old: {}", getClusterMap().size(), vDom.getClusterMap().size());
|
||||||
|
|
||||||
recalculateChecksum();
|
recalculateChecksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
if (valid != instance.isHealthy()) {
|
if (valid != instance.isHealthy()) {
|
||||||
changed = true;
|
changed = true;
|
||||||
instance.setHealthy(valid);
|
instance.setHealthy(valid);
|
||||||
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}@{}{}",
|
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}:{}@{}",
|
||||||
serviceName, (instance.isHealthy() ? "ENABLED" : "DISABLED"),
|
serviceName, (instance.isHealthy() ? "ENABLED" : "DISABLED"),
|
||||||
instance.getIp(), instance.getPort(), instance.getClusterName());
|
instance.getIp(), instance.getPort(), instance.getClusterName());
|
||||||
}
|
}
|
||||||
@ -454,30 +454,6 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putServiceIfAbsent(Service service, boolean local, Cluster cluster) throws NacosException {
|
|
||||||
final String namespaceId = service.getNamespaceId();
|
|
||||||
final String serviceName = service.getName();
|
|
||||||
|
|
||||||
if (getService(namespaceId, serviceName) != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Loggers.SRV_LOG.info("creating empty service {}:{}", namespaceId, serviceName);
|
|
||||||
// now validate the service. if failed, exception will be thrown
|
|
||||||
service.setLastModifiedMillis(System.currentTimeMillis());
|
|
||||||
service.recalculateChecksum();
|
|
||||||
if (cluster != null) {
|
|
||||||
cluster.setService(service);
|
|
||||||
service.getClusterMap().put(cluster.getName(), cluster);
|
|
||||||
}
|
|
||||||
service.validate();
|
|
||||||
|
|
||||||
putServiceAndInit(service);
|
|
||||||
if (!local) {
|
|
||||||
addOrReplaceService(service);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an instance to a service in AP mode.
|
* Register an instance to a service in AP mode.
|
||||||
* <p>
|
* <p>
|
||||||
|
14
pom.xml
14
pom.xml
@ -21,7 +21,7 @@
|
|||||||
<inceptionYear>2018</inceptionYear>
|
<inceptionYear>2018</inceptionYear>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Alibaba NACOS ${project.version}</name>
|
<name>Alibaba NACOS ${project.version}</name>
|
||||||
@ -785,17 +785,5 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<snapshotRepository>
|
|
||||||
<!-- 这里的ID一定要在maven setting文件中存在于server下的ID -->
|
|
||||||
<id>sona</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
<repository>
|
|
||||||
<id>sona</id>
|
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
Loading…
Reference in New Issue
Block a user