这里我设置现成是20,然后出现了io异常,说socket无法读取。。而且FTPServer日志文件说,连接被关闭的错误。。
这个折磨的头大啊,死活找不出来原因。。。纠结纠结。。。。
于是上FtpServer的源码。。下载不多说。。和下载FtpServer一个页面里面。
用maven把项目导入Eclipse中,阅读。。。。
于是令人吐血的地方发现了。。。
在package org.apache.ftpserver.impl中的DefaultFtpServerContext类中我发现了这么一些方法。。。。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
publicsynchronizedThreadPoolExecutor getThreadPoolExecutor() {
if(threadPoolExecutor ==null) {
intmaxThreads = connectionConfig.getMaxThreads();
if(maxThreads <1) {
intmaxLogins = connectionConfig.getMaxLogins();
if(maxLogins >0) {
maxThreads = maxLogins;
}
else{
maxThreads =16;
}
}
LOG.debug("Intializing shared thread pool executor with max threads of {}", maxThreads);
threadPoolExecutor =newOrderedThreadPoolExecutor(maxThreads);
}
returnthreadPoolExecutor;
}
|
然后connectionConfig里面我又看了下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
packageorg.apache.ftpserver;
importorg.apache.ftpserver.impl.DefaultConnectionConfig;
/**
* Factory for creating connection configurations
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
publicclassConnectionConfigFactory {
privateintmaxLogins =10;
privatebooleananonymousLoginEnabled =true;
privateintmaxAnonymousLogins =10;
privateintmaxLoginFailures =3;
privateintloginFailureDelay =500;
privateintmaxThreads =0;
/**
* Create a connection configuration instances based on the configuration on this factory
* @return The { @link ConnectionConfig} instance
*/
publicConnectionConfig createConnectionConfig() {
returnnewDefaultConnectionConfig(anonymousLoginEnabled,
loginFailureDelay, maxLogins, maxAnonymousLogins,
maxLoginFailures, maxThreads);
}
/**
* The delay in number of milliseconds between login failures. Important to
* make brute force attacks harder.
*
* @return The delay time in milliseconds
*/
publicintgetLoginFailureDelay() {
returnloginFailureDelay;
}
/**
* The maximum number of anonymous logins the server would allow at any given time
* @return The maximum number of anonymous logins
*/
publicintgetMaxAnonymousLogins() {
returnmaxAnonymousLogins;
}
/**
* The maximum number of time an user can fail to login before getting disconnected
* @return The maximum number of failure login attempts
*/
publicintgetMaxLoginFailures() {
returnmaxLoginFailures;
}
/**
* The maximum number of concurrently logged in users
* @return The maximum number of users
*/
publicintgetMaxLogins() {
returnmaxLogins;
}
/**
* Is anonymous logins allowed at the server?
* @return true if anonymous logins are enabled
*/
publicbooleanisAnonymousLoginEnabled() {
returnanonymousLoginEnabled;
}
/**
* Set she maximum number of concurrently logged in users
* @param maxLogins The maximum number of users
*/
publicvoidsetMaxLogins(finalintmaxLogins) {
this.maxLogins = maxLogins;
}
/**
* Returns the maximum number of threads the server is allowed to create for
* processing client requests.
*
* @return the maximum number of threads the server is allowed to create for
* processing client requests.
*/
publicintgetMaxThreads() {
returnmaxThreads;
}
/**
* Sets the maximum number of threads the server is allowed to create for
* processing client requests.
*
* @param maxThreads
* the maximum number of threads the server is allowed to create
* for processing client requests.
*/
publicvoidsetMaxThreads(intmaxThreads) {
this.maxThreads = maxThreads;
}
/**
* Set if anonymous logins are allowed at the server
* @param anonymousLoginEnabled true if anonymous logins should be enabled
*/
publicvoidsetAnonymousLoginEnabled(finalbooleananonymousLoginEnabled) {
this.anonymousLoginEnabled = anonymousLoginEnabled;
}
/**
* Sets the maximum number of anonymous logins the server would allow at any given time
* @param maxAnonymousLogins The maximum number of anonymous logins
*/
publicvoidsetMaxAnonymousLogins(finalintmaxAnonymousLogins) {
this.maxAnonymousLogins = maxAnonymousLogins;
}
/**
* Set the maximum number of time an user can fail to login before getting disconnected
* @param maxLoginFailures The maximum number of failure login attempts
*/
publicvoidsetMaxLoginFailures(finalintmaxLoginFailures) {
this.maxLoginFailures = maxLoginFailures;
}
/**
* Set the delay in number of milliseconds between login failures. Important to
* make brute force attacks harder.
*
* @param loginFailureDelay The delay time in milliseconds
*/
publicvoidsetLoginFailureDelay(finalintloginFailureDelay) {
this.loginFailureDelay = loginFailureDelay;
}
}
|
我直接吐血了。。private int maxLogins = 10;。。。根据DefaultFtpServerContext,我发现了,FtpServer里面的
线程池默认值是10。。。也就是说FtpServer里面默认的线程池是10个线程。。。无语。。
难道apache就这么傻?答案是不能,所以我就找所有的配置文件,把用户的单个ip登录设置成1w,同时登录1w。。。
启动发现还是有问题。。。那怎么设置这个线程池。。。。
读源码把。。。。。
终于发现。。。在ftpd-typical.xml中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<serverxmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
"
id="myServer"<spanstyle="color:#e53333;">max-logins="20000"</span>>
<listeners>
<nio-listenername="default"port="21">
<ssl>
<keystorefile="./res/ftpserver.jks"password="password"/>
</ssl>
</nio-listener>
</listeners>
<file-user-managerfile="./res/conf/users.properties"/>
</server>
|
苍天,max-logins。。。。这里可以设置。。。。添加上之后,便可以变更线程池大小了。,。
于是,问题解决了。。。
对了,ftpserver目录/common/classes/下有log4j.properties。把info修改成debug启动。、。然后看log日志
[ INFO] 2011-10-20 18:48:14,234 [] [] Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7: display name [org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7]; startup date [Thu Oct 20 18:48:14 CST 2011]; root of context hierarchy [ INFO] 2011-10-20 18:48:14,288 [] [] Loading XML bean definitions from file [F:\developtool\ftpserver-1.0.6\apache-ftpserver-1.0.6\res\conf\ftpd-typical.xml] [DEBUG] 2011-10-20 18:48:14,300 [] [] Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl] [DEBUG] 2011-10-20 18:48:14,346 [] [] Loading schema mappings from [META-INF/spring.schemas] [DEBUG] 2011-10-20 18:48:14,350 [] [] Loaded schema mappings: {http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://mina.apache.org/ftpserver/ftpserver-1.0.xsd=org/apache/ftpserver/config/spring/ftpserver-1.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd} [DEBUG] 2011-10-20 18:48:14,351 [] [] Found XML schema [http://mina.apache.org/ftpserver/ftpserver-1.0.xsd] in classpath: org/apache/ftpserver/config/spring/ftpserver-1.0.xsd [DEBUG] 2011-10-20 18:48:14,367 [] [] Found XML schema [http://www.springframework.org/schema/beans/spring-beans-2.5.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-2.5.xsd [DEBUG] 2011-10-20 18:48:14,397 [] [] Loading bean definitions [DEBUG] 2011-10-20 18:48:14,408 [] [] Loaded mappings [{http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://mina.apache.org/ftpserver/spring/v1=org.apache.ftpserver.config.spring.FtpServerNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler}] [DEBUG] 2011-10-20 18:48:14,427 [] [] Loading key store from "F:\developtool\ftpserver-1.0.6\apache-ftpserver-1.0.6\.\res\ftpserver.jks", using the key store type "jks" [DEBUG] 2011-10-20 18:48:14,427 [] [] Trying to load store from file [DEBUG] 2011-10-20 18:48:14,464 [] [] SSL configuration found for the listener, falling back for that for the data connection [DEBUG] 2011-10-20 18:48:14,486 [] [] Loaded 4 bean definitions from location pattern [res/conf/ftpd-typical.xml] [ INFO] 2011-10-20 18:48:14,486 [] [] Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7]: org.springframework.beans.factory.support.DefaultListableBeanFactory@641e9a [DEBUG] 2011-10-20 18:48:14,486 [] [] 4 beans defined in org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7: display name [org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7]; startup date [Thu Oct 20 18:48:14 CST 2011]; root of context hierarchy [DEBUG] 2011-10-20 18:48:14,497 [] [] Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@62937c] [DEBUG] 2011-10-20 18:48:14,498 [] [] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@a31e1b] [ INFO] 2011-10-20 18:48:14,499 [] [] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@641e9a: defining beans [org.apache.ftpserver.listener.ListenerFactory#0,org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0,org.apache.ftpserver.FtpServerFactory#0,myServer]; root of factory hierarchy [DEBUG] 2011-10-20 18:48:14,500 [] [] Creating shared instance of singleton bean 'org.apache.ftpserver.listener.ListenerFactory#0' [DEBUG] 2011-10-20 18:48:14,500 [] [] Creating instance of bean 'org.apache.ftpserver.listener.ListenerFactory#0' [DEBUG] 2011-10-20 18:48:14,513 [] [] Eagerly caching bean 'org.apache.ftpserver.listener.ListenerFactory#0' to allow for resolving potential circular references [DEBUG] 2011-10-20 18:48:14,521 [] [] Finished creating instance of bean 'org.apache.ftpserver.listener.ListenerFactory#0' [DEBUG] 2011-10-20 18:48:14,521 [] [] Creating shared instance of singleton bean 'org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0' [DEBUG] 2011-10-20 18:48:14,522 [] [] Creating instance of bean 'org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0' [DEBUG] 2011-10-20 18:48:14,522 [] [] Eagerly caching bean 'org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0' to allow for resolving potential circular references [DEBUG] 2011-10-20 18:48:14,524 [] [] Finished creating instance of bean 'org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0' [DEBUG] 2011-10-20 18:48:14,524 [] [] Creating shared instance of singleton bean 'org.apache.ftpserver.FtpServerFactory#0' [DEBUG] 2011-10-20 18:48:14,524 [] [] Creating instance of bean 'org.apache.ftpserver.FtpServerFactory#0' [DEBUG] 2011-10-20 18:48:14,576 [] [] Eagerly caching bean 'org.apache.ftpserver.FtpServerFactory#0' to allow for resolving potential circular references [DEBUG] 2011-10-20 18:48:14,577 [] [] Creating instance of bean '(inner bean)' [DEBUG] 2011-10-20 18:48:14,578 [] [] Returning cached instance of singleton bean 'org.apache.ftpserver.listener.ListenerFactory#0' [DEBUG] 2011-10-20 18:48:14,580 [] [] Finished creating instance of bean '(inner bean)' [DEBUG] 2011-10-20 18:48:14,584 [] [] Creating instance of bean '(inner bean)#1' [DEBUG] 2011-10-20 18:48:14,584 [] [] Returning cached instance of singleton bean 'org.apache.ftpserver.usermanager.PropertiesUserManagerFactory#0' [DEBUG] 2011-10-20 18:48:14,584 [] [] File configured, will try loading [DEBUG] 2011-10-20 18:48:14,585 [] [] File found on file system [DEBUG] 2011-10-20 18:48:14,585 [] [] Finished creating instance of bean '(inner bean)#1' [DEBUG] 2011-10-20 18:48:14,585 [] [] Finished creating instance of bean 'org.apache.ftpserver.FtpServerFactory#0' [DEBUG] 2011-10-20 18:48:14,586 [] [] Creating shared instance of singleton bean 'myServer' [DEBUG] 2011-10-20 18:48:14,586 [] [] Creating instance of bean 'myServer' [DEBUG] 2011-10-20 18:48:14,586 [] [] Returning cached instance of singleton bean 'org.apache.ftpserver.FtpServerFactory#0' [DEBUG] 2011-10-20 18:48:14,587 [] [] Eagerly caching bean 'myServer' to allow for resolving potential circular references [DEBUG] 2011-10-20 18:48:14,587 [] [] Finished creating instance of bean 'myServer' [DEBUG] 2011-10-20 18:48:14,587 [] [] Publishing event in context [org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7: display name [org.springframework.context.support.FileSystemXmlApplicationContext@1ff5ea7]; startup date [Thu Oct 20 18:48:14 CST 2011]; root of context hierarchy] [DEBUG] 2011-10-20 18:48:14,587 [] [] Returning cached instance of singleton bean 'myServer' [DEBUG] 2011-10-20 18:48:14,664 [] [] Intializing shared thread pool executor with max threads of 20000 [ INFO] 2011-10-20 18:48:14,698 [] [] FTP server started
看到倒数第二条了吗? 线程池大小。。。。
于是到此结束。。。。