response model optimize (#3357)
* Add gprc support-> add grpc log to distribution logback * Add gprc support-> response model optimize
This commit is contained in:
parent
b10a24885e
commit
3f06a7a0f8
@ -18,6 +18,7 @@ package com.alibaba.nacos.api.config.remote.request;
|
||||
|
||||
|
||||
/**
|
||||
* ConfigChangeListenRequest.
|
||||
* @author liuzunfei
|
||||
* @version $Id: ConfigChangeListenRequest.java, v 0.1 2020年07月13日 9:01 PM liuzunfei Exp $
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.alibaba.nacos.api.config.remote.response;
|
||||
|
||||
import com.alibaba.nacos.api.remote.response.Response;
|
||||
import com.alibaba.nacos.api.remote.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* ConfigChangeListenResponse.
|
||||
@ -26,13 +27,37 @@ import com.alibaba.nacos.api.remote.response.Response;
|
||||
*/
|
||||
public class ConfigChangeListenResponse extends Response {
|
||||
|
||||
|
||||
public ConfigChangeListenResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ConfigChangeListenResponse(int resultCode, String message) {
|
||||
super(ConfigResponseTypeConstants.CONFIG_CHANGE, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ConfigResponseTypeConstants.CONFIG_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* build sucess response.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ConfigChangeListenResponse buildSucessResponse() {
|
||||
ConfigChangeListenResponse response = new ConfigChangeListenResponse();
|
||||
response.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* build fail response.
|
||||
*
|
||||
* @param errorMessage errorMessage.
|
||||
* @return
|
||||
*/
|
||||
public static ConfigChangeListenResponse buildFailResponse(String errorMessage) {
|
||||
ConfigChangeListenResponse response = new ConfigChangeListenResponse();
|
||||
response.setResultCode(ResponseCode.FAIL.getCode());
|
||||
response.setMessage(errorMessage);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.remote.response;
|
||||
|
||||
import com.alibaba.nacos.api.remote.response.Response;
|
||||
@ -34,8 +35,9 @@ public class ConfigChangeNotifyResponse extends Response {
|
||||
|
||||
}
|
||||
|
||||
public ConfigChangeNotifyResponse(int resultCode, String message) {
|
||||
super(ConfigResponseTypeConstants.CONFIG_CHANGE_NOTIFY, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ConfigResponseTypeConstants.CONFIG_CHANGE_NOTIFY;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,8 +49,7 @@ public class ConfigChangeNotifyResponse extends Response {
|
||||
* @return ConfigChangeNotifyResponse
|
||||
*/
|
||||
public static ConfigChangeNotifyResponse buildSuccessResponse(String dataId, String group, String tenant) {
|
||||
ConfigChangeNotifyResponse response = new ConfigChangeNotifyResponse(ResponseCode.SUCCESS.getCode(),
|
||||
"data changed");
|
||||
ConfigChangeNotifyResponse response = new ConfigChangeNotifyResponse();
|
||||
response.setDataId(dataId);
|
||||
response.setGroup(group);
|
||||
response.setTenant(tenant);
|
||||
|
@ -31,8 +31,9 @@ public class ConfigPubishResponse extends Response {
|
||||
super();
|
||||
}
|
||||
|
||||
public ConfigPubishResponse(int resultCode, String message) {
|
||||
super(ConfigResponseTypeConstants.CONFIG_PUBLISH, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ConfigResponseTypeConstants.CONFIG_PUBLISH;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +42,7 @@ public class ConfigPubishResponse extends Response {
|
||||
* @return
|
||||
*/
|
||||
public static ConfigPubishResponse buildSuccessResponse() {
|
||||
return new ConfigPubishResponse(ResponseCode.SUCCESS.getCode(), "");
|
||||
return new ConfigPubishResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,6 +51,9 @@ public class ConfigPubishResponse extends Response {
|
||||
* @return
|
||||
*/
|
||||
public static ConfigPubishResponse buildFailResponse(String errorMsg) {
|
||||
return new ConfigPubishResponse(ResponseCode.FAIL.getCode(), errorMsg);
|
||||
ConfigPubishResponse configPubishResponse = new ConfigPubishResponse();
|
||||
configPubishResponse.setResultCode(ResponseCode.FAIL.getCode());
|
||||
configPubishResponse.setMessage(errorMsg);
|
||||
return configPubishResponse;
|
||||
}
|
||||
}
|
@ -41,14 +41,18 @@ public class ConfigQueryResponse extends Response {
|
||||
Map<String, String> labels = new HashMap<String, String>();
|
||||
|
||||
public ConfigQueryResponse() {
|
||||
super(ConfigResponseTypeConstants.CONFIG_QUERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return ConfigResponseTypeConstants.CONFIG_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* add label to this response.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param key key.
|
||||
* @param value value.
|
||||
*/
|
||||
public void addLabel(String key, String value) {
|
||||
this.labels.put(key, value);
|
||||
@ -62,19 +66,21 @@ public class ConfigQueryResponse extends Response {
|
||||
* @return
|
||||
*/
|
||||
public static ConfigQueryResponse buildFailResponse(int errorCode, String message) {
|
||||
ConfigQueryResponse response = new ConfigQueryResponse(ResponseCode.FAIL.getCode(), message);
|
||||
ConfigQueryResponse response = new ConfigQueryResponse();
|
||||
response.setResultCode(ResponseCode.FAIL.getCode());
|
||||
response.setErrorCode(errorCode);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Buidl success resposne.
|
||||
*
|
||||
* @param content.
|
||||
* @param content content.
|
||||
* @return
|
||||
*/
|
||||
public static ConfigQueryResponse buildSuccessResponse(String content) {
|
||||
ConfigQueryResponse response = new ConfigQueryResponse(ResponseCode.SUCCESS.getCode(), "");
|
||||
ConfigQueryResponse response = new ConfigQueryResponse();
|
||||
response.setContent(content);
|
||||
return response;
|
||||
}
|
||||
@ -115,10 +121,6 @@ public class ConfigQueryResponse extends Response {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public ConfigQueryResponse(int resultCode, String message) {
|
||||
super(ConfigResponseTypeConstants.CONFIG_QUERY, resultCode, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>contentType</tt>.
|
||||
*
|
||||
|
@ -31,8 +31,9 @@ public class ConfigRemoveResponse extends Response {
|
||||
super();
|
||||
}
|
||||
|
||||
public ConfigRemoveResponse(int resultCode, String message) {
|
||||
super(ConfigResponseTypeConstants.CONFIG_REMOVE, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ConfigResponseTypeConstants.CONFIG_REMOVE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +42,7 @@ public class ConfigRemoveResponse extends Response {
|
||||
* @return
|
||||
*/
|
||||
public static ConfigRemoveResponse buildSuccessResponse() {
|
||||
return new ConfigRemoveResponse(ResponseCode.SUCCESS.getCode(), "");
|
||||
return new ConfigRemoveResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,6 +51,9 @@ public class ConfigRemoveResponse extends Response {
|
||||
* @return
|
||||
*/
|
||||
public static ConfigRemoveResponse buildFailResponse(String errorMsg) {
|
||||
return new ConfigRemoveResponse(ResponseCode.FAIL.getCode(), errorMsg);
|
||||
ConfigRemoveResponse removeResponse = new ConfigRemoveResponse();
|
||||
removeResponse.setResultCode(ResponseCode.FAIL.getCode());
|
||||
removeResponse.setMessage(errorMsg);
|
||||
return removeResponse;
|
||||
}
|
||||
}
|
@ -25,15 +25,18 @@ import com.alibaba.nacos.api.remote.response.Response;
|
||||
*/
|
||||
public class InstanceResponse extends Response {
|
||||
|
||||
private String type;
|
||||
|
||||
public InstanceResponse() {
|
||||
}
|
||||
|
||||
public InstanceResponse(int resultCode, String message, String type) {
|
||||
this(resultCode, 0, message, type);
|
||||
@Override
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public InstanceResponse(int resultCode, int errorCode, String message, String type) {
|
||||
super(type, resultCode, message);
|
||||
setErrorCode(errorCode);
|
||||
public InstanceResponse(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package com.alibaba.nacos.api.naming.remote.response;
|
||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants;
|
||||
import com.alibaba.nacos.api.remote.response.Response;
|
||||
import com.alibaba.nacos.api.remote.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Nacos naming query request.
|
||||
@ -30,16 +31,28 @@ public class ServiceQueryResponse extends Response {
|
||||
private ServiceInfo serviceInfo;
|
||||
|
||||
public ServiceQueryResponse() {
|
||||
setType(NamingRemoteConstants.QUERY_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return NamingRemoteConstants.QUERY_SERVICE;
|
||||
}
|
||||
|
||||
public ServiceQueryResponse(ServiceInfo serviceInfo) {
|
||||
this(200, "success");
|
||||
this.serviceInfo = serviceInfo;
|
||||
}
|
||||
|
||||
public ServiceQueryResponse(int resultCode, String message) {
|
||||
super(NamingRemoteConstants.QUERY_SERVICE, resultCode, message);
|
||||
public static ServiceQueryResponse buildSuccessResponse(ServiceInfo serviceInfo) {
|
||||
ServiceQueryResponse serviceQueryResponse = new ServiceQueryResponse();
|
||||
serviceQueryResponse.setServiceInfo(serviceInfo);
|
||||
return serviceQueryResponse;
|
||||
}
|
||||
|
||||
public static ServiceQueryResponse buildFailResponse(String message) {
|
||||
ServiceQueryResponse serviceQueryResponse = new ServiceQueryResponse();
|
||||
serviceQueryResponse.setResultCode(ResponseCode.FAIL.getCode());
|
||||
serviceQueryResponse.setMessage(message);
|
||||
return serviceQueryResponse;
|
||||
}
|
||||
|
||||
public ServiceInfo getServiceInfo() {
|
||||
|
@ -28,6 +28,7 @@ import com.alibaba.nacos.api.naming.remote.response.ServiceQueryResponse;
|
||||
import com.alibaba.nacos.api.remote.response.ConnectResetResponse;
|
||||
import com.alibaba.nacos.api.remote.response.HeartBeatResponse;
|
||||
import com.alibaba.nacos.api.remote.response.ResponseTypeConstants;
|
||||
import com.alibaba.nacos.api.remote.response.UnKnowResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -47,6 +48,7 @@ public class ResponseRegistry {
|
||||
//internal response regitry
|
||||
REGISTRY_RESPONSES.put(ResponseTypeConstants.HEART_BEAT, HeartBeatResponse.class);
|
||||
REGISTRY_RESPONSES.put(ResponseTypeConstants.CONNECT_SWITCH, ConnectResetResponse.class);
|
||||
REGISTRY_RESPONSES.put(ResponseTypeConstants.UNKNOW, UnKnowResponse.class);
|
||||
|
||||
//config response registry
|
||||
REGISTRY_RESPONSES.put(ConfigResponseTypeConstants.CONFIG_CHANGE, ConfigChangeListenResponse.class);
|
||||
|
@ -24,7 +24,8 @@ package com.alibaba.nacos.api.remote.response;
|
||||
*/
|
||||
public class ConnectResetResponse extends Response {
|
||||
|
||||
public ConnectResetResponse(int resultCode, String message) {
|
||||
super(ResponseTypeConstants.CONNECT_SWITCH, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ResponseTypeConstants.CONNECT_SWITCH;
|
||||
}
|
||||
}
|
@ -24,8 +24,8 @@ package com.alibaba.nacos.api.remote.response;
|
||||
*/
|
||||
public class HeartBeatResponse extends Response {
|
||||
|
||||
public HeartBeatResponse(int resultCode, String message) {
|
||||
super(ResponseTypeConstants.HEART_BEAT, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ResponseTypeConstants.HEART_BEAT;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ public class PlainBodyResponse extends Response {
|
||||
|
||||
}
|
||||
|
||||
public PlainBodyResponse(int resultCode, String message) {
|
||||
super(ResponseTypeConstants.PLAIN_BODY_STRING, resultCode, message);
|
||||
@Override
|
||||
public String getType() {
|
||||
return ResponseTypeConstants.PLAIN_BODY_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,14 +24,12 @@ package com.alibaba.nacos.api.remote.response;
|
||||
*/
|
||||
public class Response {
|
||||
|
||||
int resultCode;
|
||||
int resultCode = ResponseCode.SUCCESS.getCode();
|
||||
|
||||
int errorCode;
|
||||
|
||||
String message;
|
||||
|
||||
String type;
|
||||
|
||||
/**
|
||||
* Check Response is Successd.
|
||||
*
|
||||
@ -42,18 +40,14 @@ public class Response {
|
||||
}
|
||||
|
||||
public Response() {
|
||||
|
||||
}
|
||||
|
||||
public Response(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Response(String type, int resultCode, String message) {
|
||||
this.type = type;
|
||||
this.resultCode = resultCode;
|
||||
this.message = message;
|
||||
}
|
||||
/**
|
||||
* get type.
|
||||
*
|
||||
* @return type value;
|
||||
*/
|
||||
public abstract String getType();
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>resultCode</tt>.
|
||||
@ -109,22 +103,4 @@ public class Response {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>type</tt>.
|
||||
*
|
||||
* @return property value of type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>type</tt>.
|
||||
*
|
||||
* @param type value to be assigned to property type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,4 +29,7 @@ public class ResponseTypeConstants {
|
||||
|
||||
public static final String CONNECT_SWITCH = "CONNECT_SWITCH";
|
||||
|
||||
public static final String UNKNOW = "UNKNOW";
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 1999-2020 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.api.remote.response;
|
||||
|
||||
/**
|
||||
* UnKnowResponse.
|
||||
*
|
||||
* @author liuzunfei
|
||||
* @version $Id: UnKnowResponse.java, v 0.1 2020年07月16日 9:47 PM liuzunfei Exp $
|
||||
*/
|
||||
public class UnKnowResponse extends Response {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return ResponseTypeConstants.UNKNOW;
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ public class ConfigChangeListenRequestHandler extends RequestHandler {
|
||||
} else {
|
||||
asyncListenContext.addListen(NacosRemoteConstants.LISTEN_CONTEXT_CONFIG, configKey, connectionId);
|
||||
}
|
||||
return new ConfigChangeListenResponse(200, "success");
|
||||
return ConfigChangeListenResponse.buildSucessResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,9 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.nacos.core.remote;
|
||||
|
||||
import java.util.List;
|
||||
package com.alibaba.nacos.core.remote;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.remote.request.HeartBeatRequest;
|
||||
@ -25,12 +24,15 @@ import com.alibaba.nacos.api.remote.request.RequestTypeConstants;
|
||||
import com.alibaba.nacos.api.remote.response.HeartBeatResponse;
|
||||
import com.alibaba.nacos.api.remote.response.Response;
|
||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* HeartBeatRequestHandler.
|
||||
*
|
||||
* @author liuzunfei
|
||||
* @version $Id: HeartBeatRequestHandler.java, v 0.1 2020年07月14日 1:58 PM liuzunfei Exp $
|
||||
*/
|
||||
@ -49,8 +51,9 @@ public class HeartBeatRequestHandler extends RequestHandler{
|
||||
public Response handle(Request request, RequestMeta meta) throws NacosException {
|
||||
String connectionId = meta.getConnectionId();
|
||||
connectionManager.refreshActiveTime(connectionId);
|
||||
return new HeartBeatResponse(200,"heart beat success");
|
||||
return new HeartBeatResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRequestTypes() {
|
||||
return Lists.newArrayList(RequestTypeConstants.HEART_BEAT);
|
||||
|
@ -16,17 +16,17 @@
|
||||
|
||||
package com.alibaba.nacos.core.remote.grpc;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import com.alibaba.nacos.api.grpc.GrpcMetadata;
|
||||
import com.alibaba.nacos.api.grpc.GrpcResponse;
|
||||
import com.alibaba.nacos.api.remote.response.Response;
|
||||
import com.alibaba.nacos.api.remote.response.ResponseCode;
|
||||
import com.alibaba.nacos.api.remote.response.UnKnowResponse;
|
||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* GrpcUtils.
|
||||
*
|
||||
@ -64,8 +64,7 @@ public class GrpcUtils {
|
||||
* @return
|
||||
*/
|
||||
public static GrpcResponse buildFailResponse(String msg) {
|
||||
|
||||
Response response = new Response();
|
||||
UnKnowResponse response = new UnKnowResponse();
|
||||
response.setErrorCode(ResponseCode.FAIL.getCode());
|
||||
response.setMessage(msg);
|
||||
byte[] bytes = JacksonUtils.toJsonBytes(response);
|
||||
|
@ -477,6 +477,42 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="grpc-core"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_HOME}/grpc-core.log</file>
|
||||
<append>true</append>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/grpc-core.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
|
||||
<maxFileSize>2GB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
<totalSizeCap>7GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<Pattern>%date %level %msg%n%n</Pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="grpc-digest"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_HOME}/grpc-digest.log</file>
|
||||
<append>true</append>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/grpc-digest.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
|
||||
<maxFileSize>2GB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
<totalSizeCap>7GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<Pattern>%date %level %msg%n%n</Pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.alibaba.nacos.address.main" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="nacos-address"/>
|
||||
@ -487,6 +523,16 @@
|
||||
<appender-ref ref="cmdb-main"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.alibaba.nacos.core.grpc" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="grpc-core"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.alibaba.nacos.core.grpc.digest" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="grpc-digest"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.alibaba.nacos.naming.main" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="async-naming-server"/>
|
||||
|
@ -81,18 +81,18 @@ public class InstanceRequestHandler extends RequestHandler<InstanceRequest> {
|
||||
instance.setMarked(true);
|
||||
instance.validate();
|
||||
serviceManager.addInstance(namespace, serviceName, instance.isEphemeral(), instance);
|
||||
return new InstanceResponse(200, "success", NamingRemoteConstants.REGISTER_INSTANCE);
|
||||
return new InstanceResponse(NamingRemoteConstants.REGISTER_INSTANCE);
|
||||
}
|
||||
|
||||
private Response deregisterInstance(String namespace, String serviceName, InstanceRequest instanceRequest,
|
||||
RequestMeta meta) throws NacosException {
|
||||
if (!serviceManager.containService(namespace, serviceName)) {
|
||||
Loggers.SRV_LOG.warn("remove instance from non-exist service: {}", serviceName);
|
||||
return new InstanceResponse(200, "success", NamingRemoteConstants.DE_REGISTER_INSTANCE);
|
||||
return new InstanceResponse(NamingRemoteConstants.DE_REGISTER_INSTANCE);
|
||||
}
|
||||
Instance instance = parseInstance(instanceRequest.getInstance());
|
||||
serviceManager.removeInstance(namespace, serviceName, instance.isEphemeral(), instance);
|
||||
return new InstanceResponse(200, "success", NamingRemoteConstants.DE_REGISTER_INSTANCE);
|
||||
return new InstanceResponse(NamingRemoteConstants.DE_REGISTER_INSTANCE);
|
||||
}
|
||||
|
||||
private Instance parseInstance(com.alibaba.nacos.api.naming.pojo.Instance instance) {
|
||||
|
Loading…
Reference in New Issue
Block a user