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