Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
b46d89a1
Commit
b46d89a1
authored
Dec 07, 2015
by
Dave Cridland
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #431 from guusdk/OF-992
OF-992: Re-init on restart
parents
001400ed
5a38e194
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
34 deletions
+39
-34
HttpSessionManager.java
...va/org/jivesoftware/openfire/http/HttpSessionManager.java
+39
-34
No files found.
src/java/org/jivesoftware/openfire/http/HttpSessionManager.java
View file @
b46d89a1
...
@@ -81,39 +81,13 @@ public class HttpSessionManager {
...
@@ -81,39 +81,13 @@ public class HttpSessionManager {
JiveGlobals
.
migrateProperty
(
"xmpp.httpbind.worker.threads"
);
JiveGlobals
.
migrateProperty
(
"xmpp.httpbind.worker.threads"
);
JiveGlobals
.
migrateProperty
(
"xmpp.httpbind.worker.timeout"
);
JiveGlobals
.
migrateProperty
(
"xmpp.httpbind.worker.timeout"
);
this
.
sessionManager
=
SessionManager
.
getInstance
();
init
();
}
}
public
void
init
()
{
/**
Log
.
warn
(
"HttpSessionManager.init() recreate sendPacketPool"
);
* @deprecated As of Openfire 4.0.0, the functionality of this method was added to the implementation of #start().
// Configure a pooled executor to handle async routing for incoming packets
*/
// with a default size of 16 threads ("xmpp.httpbind.worker.threads"); also
@Deprecated
// uses an unbounded task queue and configurable keep-alive (default: 60 secs)
public
void
init
()
{}
// 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
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
);
sendPacketPool
=
new
ThreadPoolExecutor
(
getCorePoolSize
(
maxPoolSize
),
maxPoolSize
,
keepAlive
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(),
// unbounded task queue
new
ThreadFactory
()
{
// custom thread factory for BOSH workers
final
AtomicInteger
counter
=
new
AtomicInteger
(
1
);
@Override
public
Thread
newThread
(
Runnable
runnable
)
{
Thread
thread
=
new
Thread
(
Thread
.
currentThread
().
getThreadGroup
(),
runnable
,
"httpbind-worker-"
+
counter
.
getAndIncrement
());
thread
.
setDaemon
(
true
);
return
thread
;
}
});
}
private
int
getCorePoolSize
(
int
maxPoolSize
)
{
private
int
getCorePoolSize
(
int
maxPoolSize
)
{
return
(
maxPoolSize
/
4
)+
1
;
return
(
maxPoolSize
/
4
)+
1
;
...
@@ -121,18 +95,49 @@ public class HttpSessionManager {
...
@@ -121,18 +95,49 @@ public class HttpSessionManager {
/**
/**
* Starts the services used by the HttpSessionManager.
* 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
()
{
public
void
start
()
{
inactivityTask
=
new
HttpSessionReaper
();
Log
.
info
(
"Starting instance"
);
TaskEngine
.
getInstance
().
schedule
(
inactivityTask
,
30
*
JiveConstants
.
SECOND
,
30
*
JiveConstants
.
SECOND
);
this
.
sessionManager
=
SessionManager
.
getInstance
();
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
new
ThreadFactory
()
{
// custom thread factory for BOSH workers
final
AtomicInteger
counter
=
new
AtomicInteger
(
1
);
@Override
public
Thread
newThread
(
Runnable
runnable
)
{
Thread
thread
=
new
Thread
(
Thread
.
currentThread
().
getThreadGroup
(),
runnable
,
"httpbind-worker-"
+
counter
.
getAndIncrement
());
thread
.
setDaemon
(
true
);
return
thread
;
}
});
sendPacketPool
.
prestartCoreThread
();
sendPacketPool
.
prestartCoreThread
();
// Periodically check for Sessions that need a cleanup.
inactivityTask
=
new
HttpSessionReaper
();
TaskEngine
.
getInstance
().
schedule
(
inactivityTask
,
30
*
JiveConstants
.
SECOND
,
30
*
JiveConstants
.
SECOND
);
}
}
/**
/**
* Stops any services and cleans up any resources used by the HttpSessionManager.
* Stops any services and cleans up any resources used by the HttpSessionManager.
*/
*/
public
void
stop
()
{
public
void
stop
()
{
Log
.
info
(
"Stopping instance"
);
inactivityTask
.
cancel
();
inactivityTask
.
cancel
();
for
(
HttpSession
session
:
sessionMap
.
values
())
{
for
(
HttpSession
session
:
sessionMap
.
values
())
{
session
.
close
();
session
.
close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment