Commit efe7d498 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-573: Improve synchronization model for http-bind to reduce thread blocking;...

OF-573: Improve synchronization model for http-bind to reduce thread blocking; include static web context resources for http-bind in RPM build

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13305 b35dd754-fafc-0310-a699-88a17e54d16e
parent 309ba9a6
......@@ -72,7 +72,6 @@ rm -rf $RPM_BUILD_ROOT%{homedir}/resources/nativeAuth/osx-ppc
rm -rf $RPM_BUILD_ROOT%{homedir}/resources/nativeAuth/solaris-sparc
rm -rf $RPM_BUILD_ROOT%{homedir}/resources/nativeAuth/win32-x86
rm -f $RPM_BUILD_ROOT%{homedir}/lib/*.dll
rm -rf $RPM_BUILD_ROOT%{homedir}/resources/spank
%clean
rm -rf $RPM_BUILD_ROOT
......@@ -129,6 +128,10 @@ exit 0
%dir %{homedir}/resources/nativeAuth/linux-i386
%{homedir}/resources/nativeAuth/linux-i386/*
%dir %{homedir}/resources/security
%dir %{homedir}/resources/spank
%{homedir}/resources/spank/index.html
%dir %{homedir}/resources/spank/WEB-INF
%{homedir}/resources/spank/WEB-INF/web.xml
%config(noreplace) %{homedir}/resources/security/keystore
%config(noreplace) %{homedir}/resources/security/truststore
%config(noreplace) %{homedir}/resources/security/client.truststore
......
......@@ -69,6 +69,10 @@ public final class HttpBindManager {
public static final int HTTP_BIND_SECURE_PORT_DEFAULT = 7443;
public static final String HTTP_BIND_THREADS = "httpbind.client.processing.threads";
public static final int HTTP_BIND_THREADS_DEFAULT = 254;
// http binding CORS default properties
public static final String HTTP_BIND_CORS_ENABLED = "httpbind.CORS.enabled";
......@@ -378,7 +382,8 @@ public final class HttpBindManager {
*/
private synchronized void configureHttpBindServer(int port, int securePort) {
httpBindServer = new Server();
final QueuedThreadPool tp = new QueuedThreadPool(254);
final QueuedThreadPool tp = new QueuedThreadPool(
JiveGlobals.getIntProperty(HTTP_BIND_THREADS, HTTP_BIND_THREADS_DEFAULT));
tp.setName("Jetty-QTP-BOSH");
httpBindServer.setThreadPool(tp);
......
......@@ -29,7 +29,7 @@ import java.security.cert.X509Certificate;
/**
* Represents one HTTP connection with a client using the HTTP Binding service. The client will wait
* on {@link #getResponse()} until the server forwards a message to it or the wait time on the
* session timesout.
* session timeout.
*
* @author Alexander Wenckus
*/
......@@ -79,7 +79,7 @@ public class HttpConnection {
/**
* Returns true if this connection has been closed, either a response was delivered to the
* client or the server closed the connection abrubtly.
* client or the server closed the connection abruptly.
*
* @return true if this connection has been closed.
*/
......@@ -107,22 +107,23 @@ public class HttpConnection {
*
* @param body the XMPP content to be forwarded to the client inside of a body tag.
*
* @throws HttpConnectionClosedException when this connection to the client has already recieved
* @throws HttpConnectionClosedException when this connection to the client has already received
* a deliverable to forward to the client
*/
public void deliverBody(String body) throws HttpConnectionClosedException {
if(body == null) {
throw new IllegalArgumentException("Body cannot be null!");
}
// We only want to use this function once so we will close it when the body is delivered.
if (isClosed) {
throw new HttpConnectionClosedException("The http connection is no longer " +
"available to deliver content");
synchronized (this) {
if (isClosed) {
throw new HttpConnectionClosedException("The http connection is no longer " +
"available to deliver content");
}
else {
isClosed = true;
}
}
if (body == null) {
body = CONNECTION_CLOSED;
}
else {
isClosed = true;
}
if (continuation != null && continuation.isSuspended()) {
continuation.setAttribute("response-body", body);
continuation.resume();
......@@ -212,7 +213,7 @@ public class HttpConnection {
if (continuation.isResumed()) {
String deliverable = (String) continuation.getAttribute("response-body");
// This will occur when the hold attribute of a session has been exceded.
// This will occur when the hold attribute of a session has been exceeded.
this.isDelivered = true;
if (deliverable == null) {
throw new HttpBindTimeoutException();
......
......@@ -51,7 +51,8 @@ public class HttpSessionManager {
private static final Logger Log = LoggerFactory.getLogger(HttpSessionManager.class);
private SessionManager sessionManager;
private Map<String, HttpSession> sessionMap = new ConcurrentHashMap<String, HttpSession>();
private Map<String, HttpSession> sessionMap = new ConcurrentHashMap<String, HttpSession>(
JiveGlobals.getIntProperty("xmpp.httpbind.session.initial.count", 16));
private TimerTask inactivityTask;
private Executor sendPacketPool;
private SessionListener sessionListener = new SessionListener() {
......@@ -73,7 +74,8 @@ public class HttpSessionManager {
this.sessionManager = SessionManager.getInstance();
// Set the executor to use for processing http requests
int eventThreads = JiveGlobals.getIntProperty("xmpp.client.processing.threads", 16);
int eventThreads = JiveGlobals.getIntProperty("httpbind.client.processing.threads",
JiveGlobals.getIntProperty("xmpp.client.processing.threads", 16));
sendPacketPool = new ThreadPoolExecutor(
eventThreads + 1, eventThreads + 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>() );
}
......
......@@ -838,7 +838,7 @@ public class LocalClientSession extends LocalSession implements ClientSession {
}
@Override
void deliver(Packet packet) throws UnauthorizedException {
public void deliver(Packet packet) throws UnauthorizedException {
if (conn != null && !conn.isClosed()) {
conn.deliver(packet);
}
......
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