瀏覽代碼

Move CommandCenterLog to sentinel-transport-common and polish related code (#1341)

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao GitHub 4 年之前
父節點
當前提交
e4769293dc
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 9 個檔案被更改,包括 13 行新增14 行删除
  1. +1
    -1
      sentinel-demo/sentinel-demo-log-logback/src/main/java/com/alibaba/csp/sentinel/demo/log/logback/CommandCenterLogLoggerImpl.java
  2. +1
    -1
      sentinel-demo/sentinel-demo-log-logback/src/test/java/com/alibaba/csp/sentinel/demo/log/logback/CommandCenterLogTest.java
  3. +2
    -1
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/log/CommandCenterLog.java
  4. +1
    -2
      sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/NettyHttpCommandCenter.java
  5. +2
    -2
      sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/netty/HttpServer.java
  6. +1
    -1
      sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/netty/HttpServerHandler.java
  7. +1
    -1
      sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/command/SimpleHttpCommandCenter.java
  8. +2
    -2
      sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/command/http/HttpEventTask.java
  9. +2
    -3
      sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/client/SimpleHttpClient.java

+ 1
- 1
sentinel-demo/sentinel-demo-log-logback/src/main/java/com/alibaba/csp/sentinel/demo/log/logback/CommandCenterLogLoggerImpl.java 查看文件

@@ -15,7 +15,7 @@
*/ */
package com.alibaba.csp.sentinel.demo.log.logback; package com.alibaba.csp.sentinel.demo.log.logback;


import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import com.alibaba.csp.sentinel.log.LogTarget; import com.alibaba.csp.sentinel.log.LogTarget;
import com.alibaba.csp.sentinel.log.Logger; import com.alibaba.csp.sentinel.log.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


+ 1
- 1
sentinel-demo/sentinel-demo-log-logback/src/test/java/com/alibaba/csp/sentinel/demo/log/logback/CommandCenterLogTest.java 查看文件

@@ -15,7 +15,7 @@
*/ */
package com.alibaba.csp.sentinel.demo.log.logback; package com.alibaba.csp.sentinel.demo.log.logback;


import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


sentinel-core/src/main/java/com/alibaba/csp/sentinel/log/CommandCenterLog.java → sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/log/CommandCenterLog.java 查看文件

@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.csp.sentinel.log;
package com.alibaba.csp.sentinel.transport.log;


import com.alibaba.csp.sentinel.log.LoggerSpiProvider;
import com.alibaba.csp.sentinel.log.jul.JavaLoggingAdapter; import com.alibaba.csp.sentinel.log.jul.JavaLoggingAdapter;


/** /**

+ 1
- 2
sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/NettyHttpCommandCenter.java 查看文件

@@ -49,9 +49,8 @@ public class NettyHttpCommandCenter implements CommandCenter {
try { try {
server.start(); server.start();
} catch (Exception ex) { } catch (Exception ex) {
RecordLog.info("Start netty server error", ex);
RecordLog.warn("[NettyHttpCommandCenter] Failed to start Netty transport server", ex);
ex.printStackTrace(); ex.printStackTrace();
System.exit(-1);
} }
} }
}); });


+ 2
- 2
sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/netty/HttpServer.java 查看文件

@@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import com.alibaba.csp.sentinel.command.CommandHandler; import com.alibaba.csp.sentinel.command.CommandHandler;
import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import com.alibaba.csp.sentinel.log.RecordLog; import com.alibaba.csp.sentinel.log.RecordLog;
import com.alibaba.csp.sentinel.transport.config.TransportConfig; import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.StringUtil;
@@ -78,7 +78,7 @@ public final class HttpServer {
break; break;
} catch (Exception e) { } catch (Exception e) {
TimeUnit.MILLISECONDS.sleep(30); TimeUnit.MILLISECONDS.sleep(30);
RecordLog.warn("[HttpServer] Netty server bind error, port={0}, retry={1}", newPort, retryCount);
RecordLog.warn("[HttpServer] Netty server bind error, port={}, retry={}", newPort, retryCount);
retryCount ++; retryCount ++;
} }
} }


+ 1
- 1
sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/command/netty/HttpServerHandler.java 查看文件

@@ -25,7 +25,7 @@ import com.alibaba.csp.sentinel.command.CommandHandler;
import com.alibaba.csp.sentinel.command.CommandRequest; import com.alibaba.csp.sentinel.command.CommandRequest;
import com.alibaba.csp.sentinel.command.CommandResponse; import com.alibaba.csp.sentinel.command.CommandResponse;
import com.alibaba.csp.sentinel.config.SentinelConfig; import com.alibaba.csp.sentinel.config.SentinelConfig;
import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.command.codec.CodecRegistry; import com.alibaba.csp.sentinel.transport.command.codec.CodecRegistry;
import com.alibaba.csp.sentinel.transport.command.codec.Encoder; import com.alibaba.csp.sentinel.transport.command.codec.Encoder;
import com.alibaba.csp.sentinel.transport.util.HttpCommandUtils; import com.alibaba.csp.sentinel.transport.util.HttpCommandUtils;


+ 1
- 1
sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/command/SimpleHttpCommandCenter.java 查看文件

@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
import com.alibaba.csp.sentinel.command.CommandHandler; import com.alibaba.csp.sentinel.command.CommandHandler;
import com.alibaba.csp.sentinel.command.CommandHandlerProvider; import com.alibaba.csp.sentinel.command.CommandHandlerProvider;
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory;
import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.CommandCenter; import com.alibaba.csp.sentinel.transport.CommandCenter;
import com.alibaba.csp.sentinel.transport.command.http.HttpEventTask; import com.alibaba.csp.sentinel.transport.command.http.HttpEventTask;
import com.alibaba.csp.sentinel.transport.config.TransportConfig; import com.alibaba.csp.sentinel.transport.config.TransportConfig;


+ 2
- 2
sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/command/http/HttpEventTask.java 查看文件

@@ -19,7 +19,7 @@ import com.alibaba.csp.sentinel.command.CommandHandler;
import com.alibaba.csp.sentinel.command.CommandRequest; import com.alibaba.csp.sentinel.command.CommandRequest;
import com.alibaba.csp.sentinel.command.CommandResponse; import com.alibaba.csp.sentinel.command.CommandResponse;
import com.alibaba.csp.sentinel.config.SentinelConfig; import com.alibaba.csp.sentinel.config.SentinelConfig;
import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.log.CommandCenterLog;
import com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter; import com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter;
import com.alibaba.csp.sentinel.transport.command.exception.RequestException; import com.alibaba.csp.sentinel.transport.command.exception.RequestException;
import com.alibaba.csp.sentinel.transport.util.HttpCommandUtils; import com.alibaba.csp.sentinel.transport.util.HttpCommandUtils;
@@ -126,7 +126,7 @@ public class HttpEventTask implements Runnable {
printWriter.flush(); printWriter.flush();
} }
} catch (Exception e1) { } catch (Exception e1) {
CommandCenterLog.warn("[SimpleHttpCommandCenter] Close server socket failed", e);
CommandCenterLog.warn("Failed to write error response", e1);
} }
} finally { } finally {
closeResource(inputStream); closeResource(inputStream);


+ 2
- 3
sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/client/SimpleHttpClient.java 查看文件

@@ -25,7 +25,6 @@ import java.nio.charset.Charset;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;


import com.alibaba.csp.sentinel.log.CommandCenterLog;
import com.alibaba.csp.sentinel.log.RecordLog; import com.alibaba.csp.sentinel.log.RecordLog;


/** /**
@@ -125,7 +124,7 @@ public class SimpleHttpClient {
try { try {
socket.close(); socket.close();
} catch (Exception ex) { } catch (Exception ex) {
CommandCenterLog.info("Error when closing " + type + " request to " + socketAddress + ": ", ex);
RecordLog.warn("Error when closing {} request to {} in SimpleHttpClient", type, socketAddress, ex);
} }
} }
} }
@@ -177,7 +176,7 @@ public class SimpleHttpClient {
} }
return paramsBuilder.toString(); return paramsBuilder.toString();
} catch (Throwable e) { } catch (Throwable e) {
RecordLog.info("Encode request params fail", e);
RecordLog.warn("Encode request params fail", e);
return ""; return "";
} }
} }


Loading…
取消
儲存