2012-09-14 35 views
3

我正在使用已在應用程序內部配置了maxIdleTime的現有Jetty應用程序。maxIdleTime設置在碼頭中意味着什麼

<servlet> 
     <servlet-name>UserServlet</servlet-name> 
     <servlet-class>com.UserServlet</servlet-class> 
     <init-param> 
     <param-name>maxIdleTime</param-name> 
      <param-value>300000</param-value> 
     </init-param> 
    </servlet> 

按照Jetty的文檔,這意味着,但我不明白這是什麼意思?有誰能讓我知道。提前致謝 。

Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: when waiting for a new request to be received on a connection; when reading the headers and content of a request; when writing the headers and content of a response. Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may take many 10s of seconds for large content written to a slow device. 

回答

4

在你上面提到,作爲一個初始參數,以用戶的servlet上下文,它無關碼頭。它只是一個傳遞給該servlet的參數,完全取決於該servlet將使用的參數。

在碼頭你設置像最大的空閒時間到連接器那麼它是怎麼長到該連接器將被允許保持閒置,沒有交通之前,它是關閉與空閒超時。

+0

此配置UserServlet擴展碼頭的WebSocketServlet,這WebSocketServlet延伸的HttpServlet,並在那裏爲HttpServlet中沒有得到與maxIdleTime什麼關係?所以我想這個maxIdleTime與Jetty本身有關。 – Pawan

+0

哦,你離開了這一點了!的WebSocket的servlet的Javadoc說 - 該initParameter「maxIdleTime」可以用來設置在毫秒的時間,一個WebSocket的可能是關閉前的閒置。 –