Enhance log info and fix code checkstyle (#4529)

* 1.fix code checkstyle check
2.enhance disconnect log info

* log enhance

* revert line
This commit is contained in:
赵延 2020-12-21 09:42:11 +08:00 committed by GitHub
parent 04c5056f13
commit c72cb016b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

View File

@ -74,7 +74,6 @@ public class PayloadRegistry {
inited = true;
}
static void register(String type, Class clazz) {
if (Modifier.isAbstract(clazz.getModifiers())) {
return;

View File

@ -595,7 +595,7 @@ public class ClientWorker implements Closeable {
@Override
public void onDisConnect() {
String taskId = rpcClientInner.getLabels().get("taskId");
LOGGER.info("[0]clear listen context...", rpcClientInner.getName());
LOGGER.info("[{}] clear listen context...", rpcClientInner.getName());
Collection<CacheData> values = cacheMap.get().values();
for (CacheData cacheData : values) {

View File

@ -119,14 +119,15 @@ public abstract class RpcClient implements Closeable {
}
/**
* Notify when client re connected.
* Notify when client disconnected.
*/
protected void notifyDisConnected() {
if (!connectionEventListeners.isEmpty()) {
LoggerUtils.printIfInfoEnabled(LOGGER, "Notify connection event listeners.");
for (ConnectionEventListener connectionEventListener : connectionEventListeners) {
connectionEventListener.onDisConnect();
}
if (connectionEventListeners.isEmpty()) {
return;
}
LoggerUtils.printIfInfoEnabled(LOGGER, "Notify disconnected event to listeners");
for (ConnectionEventListener connectionEventListener : connectionEventListeners) {
connectionEventListener.onDisConnect();
}
}
@ -134,10 +135,12 @@ public abstract class RpcClient implements Closeable {
* Notify when client new connected.
*/
protected void notifyConnected() {
if (!connectionEventListeners.isEmpty()) {
for (ConnectionEventListener connectionEventListener : connectionEventListeners) {
connectionEventListener.onConnected();
}
if (connectionEventListeners.isEmpty()) {
return;
}
LoggerUtils.printIfInfoEnabled(LOGGER, "Notify connected event to listeners.");
for (ConnectionEventListener connectionEventListener : connectionEventListeners) {
connectionEventListener.onConnected();
}
}
@ -256,7 +259,8 @@ public abstract class RpcClient implements Closeable {
}
if (connectToServer != null) {
LoggerUtils.printIfInfoEnabled(LOGGER, String.format("[%s] success to connect to server on start up", name));
LoggerUtils
.printIfInfoEnabled(LOGGER, String.format("[%s] success to connect to server on start up", name));
this.currentConnection = connectToServer;
rpcClientStatus.set(RpcClientStatus.RUNNING);
eventLinkedBlockingQueue.offer(new ConnectionEvent(ConnectionEvent.CONNECTED));

View File

@ -21,7 +21,6 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.pojo.Cluster;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.naming.core.v2.ServiceManager;
import com.alibaba.nacos.naming.core.v2.index.ServiceStorage;