Commit b46d89a1 authored by Dave Cridland's avatar Dave Cridland

Merge pull request #431 from guusdk/OF-992

OF-992: Re-init on restart
parents 001400ed 5a38e194
......@@ -81,25 +81,37 @@ public class HttpSessionManager {
JiveGlobals.migrateProperty("xmpp.httpbind.worker.threads");
JiveGlobals.migrateProperty("xmpp.httpbind.worker.timeout");
}
this.sessionManager = SessionManager.getInstance();
init();
/**
* @deprecated As of Openfire 4.0.0, the functionality of this method was added to the implementation of #start().
*/
@Deprecated
public void init() {}
private int getCorePoolSize(int maxPoolSize) {
return (maxPoolSize/4)+1;
}
public void init() {
Log.warn("HttpSessionManager.init() recreate sendPacketPool");
// Configure a pooled executor to handle async routing for incoming packets
// with a default size of 16 threads ("xmpp.httpbind.worker.threads"); also
// uses an unbounded task queue and configurable keep-alive (default: 60 secs)
/**
* Starts the services used by the HttpSessionManager.
*
* (Re)creates and configures a pooled executor to handle async routing for incoming packets with a configurable
* (through property "xmpp.httpbind.worker.threads") amount of threads; also uses an unbounded task queue and
* configurable ("xmpp.httpbind.worker.timeout") keep-alive.
*
* Note: Apart from the processing threads configured in this class, the server also uses a threadpool to perform
* the network IO (as configured in ({@link HttpBindManager}). BOSH installations expecting heavy loads may want to
* allocate additional threads to this worker pool to ensure timely delivery of inbound packets
*/
public void start() {
Log.info( "Starting instance" );
// Note: server supports up to 254 client threads by default (@see HttpBindManager)
// BOSH installations expecting heavy loads may want to allocate additional threads
// to this worker pool to ensure timely delivery of inbound packets
this.sessionManager = SessionManager.getInstance();
int maxPoolSize = JiveGlobals.getIntProperty("xmpp.httpbind.worker.threads",
// use deprecated property as default (shared with ConnectionManagerImpl)
JiveGlobals.getIntProperty("xmpp.client.processing.threads", 8));
int keepAlive = JiveGlobals.getIntProperty("xmpp.httpbind.worker.timeout", 60);
final int maxClientPoolSize = JiveGlobals.getIntProperty( "xmpp.client.processing.threads", 8 );
final int maxPoolSize = JiveGlobals.getIntProperty("xmpp.httpbind.worker.threads", maxClientPoolSize );
final int keepAlive = JiveGlobals.getIntProperty( "xmpp.httpbind.worker.timeout", 60 );
sendPacketPool = new ThreadPoolExecutor(getCorePoolSize(maxPoolSize), maxPoolSize, keepAlive, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(), // unbounded task queue
......@@ -113,26 +125,19 @@ public class HttpSessionManager {
return thread;
}
});
}
private int getCorePoolSize(int maxPoolSize) {
return (maxPoolSize/4)+1;
}
sendPacketPool.prestartCoreThread();
/**
* Starts the services used by the HttpSessionManager.
*/
public void start() {
// Periodically check for Sessions that need a cleanup.
inactivityTask = new HttpSessionReaper();
TaskEngine.getInstance().schedule(inactivityTask, 30 * JiveConstants.SECOND,
30 * JiveConstants.SECOND);
sendPacketPool.prestartCoreThread();
TaskEngine.getInstance().schedule( inactivityTask, 30 * JiveConstants.SECOND, 30 * JiveConstants.SECOND );
}
/**
* Stops any services and cleans up any resources used by the HttpSessionManager.
*/
public void stop() {
Log.info( "Stopping instance" );
inactivityTask.cancel();
for (HttpSession session : sessionMap.values()) {
session.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment