readTimeoutSeconds优化
This commit is contained in:
@@ -146,8 +146,8 @@
|
|||||||
bufferPoolSize: ByteBuffer池的大小,默认: 线程数*4
|
bufferPoolSize: ByteBuffer池的大小,默认: 线程数*4
|
||||||
responsePoolSize: Response池的大小,默认: 1024
|
responsePoolSize: Response池的大小,默认: 1024
|
||||||
aliveTimeoutSeconds: KeepAlive读操作超时秒数, 默认30, 0表示永久不超时; -1表示禁止KeepAlive
|
aliveTimeoutSeconds: KeepAlive读操作超时秒数, 默认30, 0表示永久不超时; -1表示禁止KeepAlive
|
||||||
readTimeoutSeconds: 读操作超时秒数, 默认0, 表示永久不超时
|
readTimeoutSeconds: 读操作超时秒数, 默认0, 0表示永久不超时
|
||||||
writeTimeoutSeconds: 写操作超时秒数, 默认0, 表示永久不超时
|
writeTimeoutSeconds: 写操作超时秒数, 默认0, 0表示永久不超时
|
||||||
interceptor: 启动/关闭NodeServer时被调用的拦截器实现类,必须是org.redkale.boot.NodeInterceptor的子类,默认为null
|
interceptor: 启动/关闭NodeServer时被调用的拦截器实现类,必须是org.redkale.boot.NodeInterceptor的子类,默认为null
|
||||||
-->
|
-->
|
||||||
<server protocol="HTTP" host="127.0.0.1" port="6060" root="root" lib="">
|
<server protocol="HTTP" host="127.0.0.1" port="6060" root="root" lib="">
|
||||||
|
|||||||
@@ -444,8 +444,6 @@ public final class Application {
|
|||||||
MessageAgent[] mqs = null;
|
MessageAgent[] mqs = null;
|
||||||
int bufferCapacity = 32 * 1024;
|
int bufferCapacity = 32 * 1024;
|
||||||
int bufferPoolSize = Utility.cpus() * 8;
|
int bufferPoolSize = Utility.cpus() * 8;
|
||||||
int readTimeoutSeconds = 6;
|
|
||||||
int writeTimeoutSeconds = 6;
|
|
||||||
AnyValue executorConf = null;
|
AnyValue executorConf = null;
|
||||||
executorConf = config.getAnyValue("executor");
|
executorConf = config.getAnyValue("executor");
|
||||||
AnyValue excludelibConf = config.getAnyValue("excludelibs");
|
AnyValue excludelibConf = config.getAnyValue("excludelibs");
|
||||||
@@ -1342,7 +1340,7 @@ public final class Application {
|
|||||||
try {
|
try {
|
||||||
DatagramChannel channel = DatagramChannel.open();
|
DatagramChannel channel = DatagramChannel.open();
|
||||||
channel.configureBlocking(true);
|
channel.configureBlocking(true);
|
||||||
channel.socket().setSoTimeout(3000);
|
channel.socket().setSoTimeout(6000); //单位:毫秒
|
||||||
channel.bind(new InetSocketAddress("127.0.0.1", config.getIntValue("port")));
|
channel.bind(new InetSocketAddress("127.0.0.1", config.getIntValue("port")));
|
||||||
if (!singletonMode) {
|
if (!singletonMode) {
|
||||||
signalShutdownHandle();
|
signalShutdownHandle();
|
||||||
@@ -1471,7 +1469,7 @@ public final class Application {
|
|||||||
private static void sendCommand(Logger logger, int port, String cmd, String[] params) throws Exception {
|
private static void sendCommand(Logger logger, int port, String cmd, String[] params) throws Exception {
|
||||||
final DatagramChannel channel = DatagramChannel.open();
|
final DatagramChannel channel = DatagramChannel.open();
|
||||||
channel.configureBlocking(true);
|
channel.configureBlocking(true);
|
||||||
channel.socket().setSoTimeout(3000);
|
channel.socket().setSoTimeout(6000); //单位:毫秒
|
||||||
SocketAddress dest = new InetSocketAddress("127.0.0.1", port);
|
SocketAddress dest = new InetSocketAddress("127.0.0.1", port);
|
||||||
channel.connect(dest);
|
channel.connect(dest);
|
||||||
//命令和参数合成一个数组
|
//命令和参数合成一个数组
|
||||||
|
|||||||
@@ -192,10 +192,6 @@ public class AsyncIOGroup extends AsyncGroup {
|
|||||||
return ioWriteThreads[i];
|
return ioWriteThreads[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncIOThread connectThread() {
|
|
||||||
return connectThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScheduledFuture scheduleTimeout(Runnable callable, long delay, TimeUnit unit) {
|
public ScheduledFuture scheduleTimeout(Runnable callable, long delay, TimeUnit unit) {
|
||||||
return timeoutExecutor.schedule(callable, delay, unit);
|
return timeoutExecutor.schedule(callable, delay, unit);
|
||||||
|
|||||||
@@ -463,6 +463,14 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
|||||||
this.serverClassLoader = serverClassLoader;
|
this.serverClassLoader = serverClassLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//必须在Server.start执行后才能调用此方法
|
||||||
|
public AsyncGroup getAsyncGroup() {
|
||||||
|
if (this.serverChannel == null) {
|
||||||
|
throw new RedkaleException("Server is not running");
|
||||||
|
}
|
||||||
|
return this.serverChannel.getAsyncGroup();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否存在Filter
|
* 判断是否存在Filter
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
|||||||
|
|
||||||
protected MappingEntry[] regxWsArray = null;
|
protected MappingEntry[] regxWsArray = null;
|
||||||
|
|
||||||
protected Map<String, WebSocketServlet> wsmappings = new HashMap<>(); //super.mappings 包含 wsmappings
|
protected Map<String, WebSocketServlet> wsMappings = new HashMap<>(); //super.mappings 包含 wsMappings
|
||||||
|
|
||||||
protected final Map<String, Class> allMapStrings = new HashMap<>();
|
protected final Map<String, Class> allMapStrings = new HashMap<>();
|
||||||
|
|
||||||
@@ -82,17 +82,17 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, WebSocketServlet> newwsmappings = new HashMap<>();
|
Map<String, WebSocketServlet> newWsMappings = new HashMap<>();
|
||||||
for (Map.Entry<String, WebSocketServlet> en : wsmappings.entrySet()) {
|
for (Map.Entry<String, WebSocketServlet> en : wsMappings.entrySet()) {
|
||||||
if (predicateFilter.test(en)) {
|
if (predicateFilter.test(en)) {
|
||||||
servlets.add(en.getValue());
|
servlets.add(en.getValue());
|
||||||
keys.add(en.getKey());
|
keys.add(en.getKey());
|
||||||
} else {
|
} else {
|
||||||
newwsmappings.put(en.getKey(), en.getValue());
|
newWsMappings.put(en.getKey(), en.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newwsmappings.size() != wsmappings.size()) {
|
if (newWsMappings.size() != wsMappings.size()) {
|
||||||
this.wsmappings = newwsmappings;
|
this.wsMappings = newWsMappings;
|
||||||
}
|
}
|
||||||
if (!keys.isEmpty()) {
|
if (!keys.isEmpty()) {
|
||||||
this.regxArray = Utility.remove(this.regxArray, predicateEntry);
|
this.regxArray = Utility.remove(this.regxArray, predicateEntry);
|
||||||
@@ -320,7 +320,7 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (request.isWebSocket()) {
|
if (request.isWebSocket()) {
|
||||||
servlet = wsmappings.get(uri);
|
servlet = wsMappings.get(uri);
|
||||||
if (servlet == null && this.regxWsArray != null) {
|
if (servlet == null && this.regxWsArray != null) {
|
||||||
for (MappingEntry en : regxWsArray) {
|
for (MappingEntry en : regxWsArray) {
|
||||||
if (en.predicate.test(uri)) {
|
if (en.predicate.test(uri)) {
|
||||||
@@ -451,9 +451,9 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
|||||||
putMapping(mappingPath, servlet);
|
putMapping(mappingPath, servlet);
|
||||||
}
|
}
|
||||||
if (servlet instanceof WebSocketServlet) {
|
if (servlet instanceof WebSocketServlet) {
|
||||||
Map<String, WebSocketServlet> newMappings = new HashMap<>(wsmappings);
|
Map<String, WebSocketServlet> newMappings = new HashMap<>(wsMappings);
|
||||||
newMappings.put(mappingPath, (WebSocketServlet) servlet);
|
newMappings.put(mappingPath, (WebSocketServlet) servlet);
|
||||||
this.wsmappings = newMappings;
|
this.wsMappings = newMappings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.allMapStrings.containsKey(mappingPath)) {
|
if (this.allMapStrings.containsKey(mappingPath)) {
|
||||||
@@ -545,7 +545,7 @@ public class HttpDispatcherServlet extends DispatcherServlet<String, HttpContext
|
|||||||
s.postDestroy(application, context, getServletConf(s));
|
s.postDestroy(application, context, getServletConf(s));
|
||||||
});
|
});
|
||||||
this.allMapStrings.clear();
|
this.allMapStrings.clear();
|
||||||
this.wsmappings.clear();
|
this.wsMappings.clear();
|
||||||
this.regxArray = null;
|
this.regxArray = null;
|
||||||
this.regxWsArray = null;
|
this.regxWsArray = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ public class SncpClient extends Client<SncpClientConnection, SncpClientRequest,
|
|||||||
public SncpClient(String name, AsyncGroup group, InetSocketAddress clientSncpAddress, ClientAddress address, String netprotocol, int maxConns, int maxPipelines) {
|
public SncpClient(String name, AsyncGroup group, InetSocketAddress clientSncpAddress, ClientAddress address, String netprotocol, int maxConns, int maxPipelines) {
|
||||||
super(name, group, "TCP".equalsIgnoreCase(netprotocol), address, maxConns, maxPipelines, null, null, null); //maxConns
|
super(name, group, "TCP".equalsIgnoreCase(netprotocol), address, maxConns, maxPipelines, null, null, null); //maxConns
|
||||||
this.clientSncpAddress = clientSncpAddress;
|
this.clientSncpAddress = clientSncpAddress;
|
||||||
this.readTimeoutSeconds = 12;
|
this.readTimeoutSeconds = 15;
|
||||||
this.writeTimeoutSeconds = 12;
|
this.writeTimeoutSeconds = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4554,8 +4554,8 @@ public final class Utility {
|
|||||||
// HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
|
// HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
|
||||||
// boolean opening = true;
|
// boolean opening = true;
|
||||||
// try {
|
// try {
|
||||||
// conn.setConnectTimeout(timeoutMs > 0 ? timeoutMs : 3000);
|
// conn.setConnectTimeout(timeoutMs > 0 ? timeoutMs : 30000);
|
||||||
// conn.setReadTimeout(timeoutMs > 0 ? timeoutMs : 3000);
|
// conn.setReadTimeout(timeoutMs > 0 ? timeoutMs : 30000);
|
||||||
// if (conn instanceof HttpsURLConnection) {
|
// if (conn instanceof HttpsURLConnection) {
|
||||||
// HttpsURLConnection httpsconn = ((HttpsURLConnection) conn);
|
// HttpsURLConnection httpsconn = ((HttpsURLConnection) conn);
|
||||||
// httpsconn.setSSLSocketFactory((ctx == null ? DEFAULTSSL_CONTEXT : ctx).getSocketFactory());
|
// httpsconn.setSSLSocketFactory((ctx == null ? DEFAULTSSL_CONTEXT : ctx).getSocketFactory());
|
||||||
|
|||||||
Reference in New Issue
Block a user