Optimized code
This commit is contained in:
@@ -12,34 +12,42 @@ public class Constants {
|
||||
return SYS_ENV.get(key) == null ? "" : SYS_ENV.get(key);
|
||||
}
|
||||
|
||||
public static String DEFAULT_HOST = "localhost";
|
||||
public static String SERVER_HOST = "localhost";
|
||||
/**
|
||||
* HTTP协议和SDK协议服务器的端口
|
||||
* HTTP 协议和 SDK 协议服务器默认端口
|
||||
*/
|
||||
public static int HTTP_PORT = 16830;
|
||||
public static int SDKS_PORT = 16831;
|
||||
public static int SDK_PORT = 16831;
|
||||
|
||||
/**
|
||||
* HTTP协议和SDK协议的请求路径
|
||||
*/
|
||||
public static String HTTP_REQUEST = "did";
|
||||
public static String SDKS_REQUEST = "did";
|
||||
|
||||
/**
|
||||
* 数据中心的标识ID,取值范围:0~31
|
||||
* 机器或进程的标识ID,取值范围:0~31
|
||||
* 两个标识ID组合在分布式环境中必须唯一
|
||||
* 数据中心默认标识 ID,取值范围:0~31
|
||||
* 机器或进程默认标识 ID,取值范围:0~31
|
||||
* <p>
|
||||
* 两个标识 ID 组合在分布式环境中必须唯一
|
||||
*/
|
||||
public static long DATACENTER_ID = 1;
|
||||
public static long MACHINES_ID = 1;
|
||||
|
||||
/**
|
||||
* 流量控制,表示每秒处理的并发数
|
||||
* Server 流量控制,表示每秒处理的并发数
|
||||
*/
|
||||
public static int HANDLE_HTTP_TPS = 10000;
|
||||
public static int HANDLE_SDKS_TPS = 50000;
|
||||
public static int HANDLE_SDK_TPS = 50000;
|
||||
|
||||
/**
|
||||
* sdk client 流量控制,表示每秒处理的并发数
|
||||
*/
|
||||
public static int SDK_CLIENT_ASYNC_TPS = 100000;
|
||||
public static int SDK_CLIENT_ONEWAY_TPS = 100000;
|
||||
|
||||
public static int ACQUIRE_TIMEOUTMILLIS = 5000;
|
||||
|
||||
/**
|
||||
* sdk client 默认超时时间
|
||||
*/
|
||||
public static int SDK_CLIENT_TIMEOUTMILLIS = 2000;
|
||||
|
||||
|
||||
private Constants() {
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package cn.ceres.did.common;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -36,11 +35,8 @@ public class NettyUtil {
|
||||
|
||||
public static void closeChannel(Channel channel) {
|
||||
final String addrRemote = parseRemoteAddr(channel);
|
||||
channel.close().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
logger.info("closeChannel: close the connection to remote address[{}] result: {}", addrRemote, future.isSuccess());
|
||||
}
|
||||
});
|
||||
channel.close().addListener((ChannelFutureListener) future ->
|
||||
logger.info("closeChannel: close the connection to remote address[{}] result: {}",
|
||||
addrRemote, future.isSuccess()));
|
||||
}
|
||||
}
|
||||
|
53
did-common/src/main/java/cn/ceres/did/common/SdkProto.java
Normal file
53
did-common/src/main/java/cn/ceres/did/common/SdkProto.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package cn.ceres.did.common;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author ehlxr
|
||||
*/
|
||||
public class SdkProto {
|
||||
private static final AtomicInteger REQUEST_ID = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* 请求的ID
|
||||
*/
|
||||
private int rqid;
|
||||
/**
|
||||
* 全局的 ID
|
||||
*/
|
||||
private long did;
|
||||
|
||||
public SdkProto() {
|
||||
rqid = REQUEST_ID.incrementAndGet();
|
||||
did = 0;
|
||||
}
|
||||
|
||||
public SdkProto(int rqid, long did) {
|
||||
this.rqid = rqid;
|
||||
this.did = did;
|
||||
}
|
||||
|
||||
public int getRqid() {
|
||||
return rqid;
|
||||
}
|
||||
|
||||
public void setRqid(int rqid) {
|
||||
this.rqid = rqid;
|
||||
}
|
||||
|
||||
public long getDid() {
|
||||
return did;
|
||||
}
|
||||
|
||||
public void setDid(long did) {
|
||||
this.did = did;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SdkProto{" +
|
||||
"rqid=" + rqid +
|
||||
", did=" + did +
|
||||
'}';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user