Update version to 1.1.4
This commit is contained in:
parent
2587fa1415
commit
4d68565667
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</parent>
|
||||
<artifactId>nacos-console</artifactId>
|
||||
<!--<packaging>war</packaging>-->
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</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"
|
||||
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} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
|
||||
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.data.warmup=true
|
||||
# nacos.naming.expireInstance=true
|
||||
|
||||
nacos.istio.mcp.server.enabled=false
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -32,6 +32,7 @@ import io.grpc.stub.StreamObserver;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -64,7 +65,8 @@ public class NacosMcpService extends ResourceSourceGrpc.ResourceSourceImplBase {
|
||||
@Autowired
|
||||
private IstioConfig istioConfig;
|
||||
|
||||
public NacosMcpService() {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (!istioConfig.isMcpServerEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.alibaba.nacos.naming.core.ServiceManager;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.push.ClientInfo;
|
||||
import com.alibaba.nacos.naming.web.CanDistro;
|
||||
import com.alibaba.nacos.naming.web.OverrideParameterRequestWrapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.codehaus.jackson.util.VersionUtil;
|
||||
@ -141,13 +142,10 @@ public class ApiController extends InstanceController {
|
||||
|
||||
@CanDistro
|
||||
@RequestMapping("/clientBeat")
|
||||
public JSONObject clientBeat(HttpServletRequest request,
|
||||
@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
||||
@RequestParam String beat,
|
||||
@RequestParam String dom) throws Exception {
|
||||
|
||||
String serviceName = Constants.DEFAULT_GROUP + Constants.SERVICE_INFO_SPLITER + dom;
|
||||
|
||||
return beat(namespaceId, beat, serviceName);
|
||||
public JSONObject clientBeat(HttpServletRequest request) throws Exception {
|
||||
OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(request);
|
||||
requestWrapper.addParameter(CommonParams.SERVICE_NAME,
|
||||
Constants.DEFAULT_GROUP + Constants.SERVICE_INFO_SPLITER + WebUtils.required(request, "dom"));
|
||||
return beat(requestWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,13 @@ package com.alibaba.nacos.naming.controllers;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.core.utils.WebUtils;
|
||||
import com.alibaba.nacos.naming.core.Cluster;
|
||||
import com.alibaba.nacos.naming.core.Service;
|
||||
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.misc.Loggers;
|
||||
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.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
*/
|
||||
@ -46,13 +49,16 @@ public class ClusterController {
|
||||
protected ServiceManager serviceManager;
|
||||
|
||||
@PutMapping
|
||||
public String update( @RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
||||
@RequestParam String clusterName,
|
||||
@RequestParam String serviceName,
|
||||
@RequestParam String healthChecker,
|
||||
@RequestParam(defaultValue = StringUtils.EMPTY) String metadata,
|
||||
@RequestParam String checkPort,
|
||||
@RequestParam String useInstancePort4Check) throws Exception {
|
||||
public String update(HttpServletRequest request) throws Exception {
|
||||
|
||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||
Constants.DEFAULT_NAMESPACE_ID);
|
||||
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||
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);
|
||||
if (service == null) {
|
||||
|
@ -17,7 +17,9 @@ package com.alibaba.nacos.naming.controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.core.utils.WebUtils;
|
||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||
import com.alibaba.nacos.naming.core.Instance;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -66,23 +69,29 @@ public class HealthController {
|
||||
|
||||
@CanDistro
|
||||
@PutMapping(value = {"", "/instance"})
|
||||
public String update(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
||||
@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) {
|
||||
public String update(HttpServletRequest request) {
|
||||
|
||||
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)) {
|
||||
healthyString = validString;
|
||||
healthyString = WebUtils.optional(request, "valid", StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(healthyString)) {
|
||||
throw new IllegalArgumentException("Param 'healthy' is required.");
|
||||
}
|
||||
|
||||
boolean valid = BooleanUtils.toBoolean(healthyString);
|
||||
valid = BooleanUtils.toBoolean(healthyString);
|
||||
|
||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||
// Only health check "none" need update health status with api
|
||||
|
@ -207,14 +207,15 @@ public class InstanceController {
|
||||
|
||||
@CanDistro
|
||||
@PutMapping("/beat")
|
||||
public JSONObject beat(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
||||
@RequestParam String beat,
|
||||
@RequestParam String serviceName) throws Exception {
|
||||
public JSONObject beat(HttpServletRequest request) throws Exception {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
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);
|
||||
|
||||
if (!switchDomain.isDefaultInstanceEphemeral() && !clientBeat.isEphemeral()) {
|
||||
@ -445,7 +446,7 @@ public class InstanceController {
|
||||
|
||||
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);
|
||||
if (isCheck) {
|
||||
|
@ -20,6 +20,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
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.KeyBuilder;
|
||||
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.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.web.NeedAuth;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.HttpServletResponse;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -66,19 +70,24 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@PostMapping("/vote")
|
||||
public JSONObject vote(@RequestParam String vote) {
|
||||
public JSONObject vote(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
RaftPeer peer = raftCore.receivedVote(
|
||||
JSON.parseObject(vote, RaftPeer.class));
|
||||
JSON.parseObject(WebUtils.required(request, "vote"), RaftPeer.class));
|
||||
|
||||
return JSON.parseObject(JSON.toJSONString(peer));
|
||||
}
|
||||
|
||||
@NeedAuth
|
||||
@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);
|
||||
|
||||
@ -87,7 +96,7 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@GetMapping("/peer")
|
||||
public JSONObject getPeer() {
|
||||
public JSONObject getPeer(HttpServletRequest request, HttpServletResponse response) {
|
||||
List<RaftPeer> peers = raftCore.getPeers();
|
||||
RaftPeer peer = null;
|
||||
|
||||
@ -107,19 +116,24 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@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);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@NeedAuth
|
||||
@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("Cache-Control", "no-cache");
|
||||
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");
|
||||
if (KeyBuilder.matchInstanceListKey(key)) {
|
||||
raftConsistencyService.put(key, JSON.parseObject(json.getString("value"), Instances.class));
|
||||
@ -141,24 +155,23 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@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("Cache-Control", "no-cache");
|
||||
response.setHeader("Content-Encode", "gzip");
|
||||
|
||||
raftConsistencyService.remove(key);
|
||||
raftConsistencyService.remove(WebUtils.required(request, "key"));
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@NeedAuth
|
||||
@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("Cache-Control", "no-cache");
|
||||
response.setHeader("Content-Encode", "gzip");
|
||||
|
||||
String keysString = WebUtils.required(request, "keys");
|
||||
keysString = URLDecoder.decode(keysString, "UTF-8");
|
||||
String[] keys = keysString.split(",");
|
||||
List<Datum> datums = new ArrayList<Datum>();
|
||||
@ -172,7 +185,7 @@ public class RaftController {
|
||||
}
|
||||
|
||||
@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("Cache-Control", "no-cache");
|
||||
@ -187,15 +200,18 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@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("Cache-Control", "no-cache");
|
||||
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";
|
||||
|
||||
RaftPeer source = jsonObject.getObject("source", RaftPeer.class);
|
||||
RaftPeer source = JSON.parseObject(jsonObject.getString("source"), RaftPeer.class);
|
||||
JSONObject datumJson = jsonObject.getJSONObject("datum");
|
||||
|
||||
Datum datum = null;
|
||||
@ -216,21 +232,26 @@ public class RaftController {
|
||||
|
||||
@NeedAuth
|
||||
@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("Cache-Control", "no-cache");
|
||||
response.setHeader("Content-Encode", "gzip");
|
||||
|
||||
Datum datum = jsonObject.getObject("datum", Datum.class);
|
||||
RaftPeer source = jsonObject.getObject("source", RaftPeer.class);
|
||||
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
|
||||
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);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/leader")
|
||||
public JSONObject getLeader() {
|
||||
public JSONObject getLeader(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("leader", JSONObject.toJSONString(raftCore.getLeader()));
|
||||
@ -238,20 +259,21 @@ public class RaftController {
|
||||
}
|
||||
|
||||
@GetMapping("/listeners")
|
||||
public JSONObject getAllListeners() {
|
||||
public JSONObject getAllListeners(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
Map<String, List<RecordListener>> listeners = raftCore.getListeners();
|
||||
|
||||
JSONArray listenerArray = new JSONArray();
|
||||
listenerArray.addAll(listeners.keySet());
|
||||
|
||||
for (String key : listeners.keySet()) {
|
||||
listenerArray.add(key);
|
||||
}
|
||||
result.put("listeners", listenerArray);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String getAcceptEncoding(HttpServletRequest req) {
|
||||
public static String getAcceptEncoding(HttpServletRequest req) {
|
||||
String encode = StringUtils.defaultIfEmpty(req.getHeader("Accept-Charset"), "UTF-8");
|
||||
encode = 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
|
||||
public String update(HttpServletRequest request,@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
|
||||
@RequestParam String serviceName,
|
||||
@RequestParam(required = false) float protectThreshold,
|
||||
@RequestParam(defaultValue = StringUtils.EMPTY) String metadata,
|
||||
@RequestParam(defaultValue = StringUtils.EMPTY) String selector) throws Exception {
|
||||
public String update(HttpServletRequest request) throws Exception {
|
||||
|
||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||
Constants.DEFAULT_NAMESPACE_ID);
|
||||
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);
|
||||
if (service == null) {
|
||||
|
@ -315,28 +315,16 @@ public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implement
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getName())
|
||||
.append(service)
|
||||
.toHashCode();
|
||||
return Objects.hash(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Cluster)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Cluster cluster = (Cluster) o;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(getName(), cluster.getName())
|
||||
.append(service, cluster.service)
|
||||
.isEquals();
|
||||
return getName().equals(((Cluster) obj).getName());
|
||||
}
|
||||
|
||||
public int getDefCkport() {
|
||||
|
@ -424,6 +424,9 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
|
||||
updateOrAddCluster(vDom.getClusterMap().values());
|
||||
remvDeadClusters(this, vDom);
|
||||
|
||||
Loggers.SRV_LOG.info("cluster size, new: {}, old: {}", getClusterMap().size(), vDom.getClusterMap().size());
|
||||
|
||||
recalculateChecksum();
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ public class ServiceManager implements RecordListener<Service> {
|
||||
if (valid != instance.isHealthy()) {
|
||||
changed = true;
|
||||
instance.setHealthy(valid);
|
||||
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}@{}{}",
|
||||
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}:{}@{}",
|
||||
serviceName, (instance.isHealthy() ? "ENABLED" : "DISABLED"),
|
||||
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.
|
||||
* <p>
|
||||
|
14
pom.xml
14
pom.xml
@ -21,7 +21,7 @@
|
||||
<inceptionYear>2018</inceptionYear>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Alibaba NACOS ${project.version}</name>
|
||||
@ -785,17 +785,5 @@
|
||||
|
||||
</dependencies>
|
||||
</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>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
Loading…
Reference in New Issue
Block a user