Commit 25555e1c authored by Tom Evans's avatar Tom Evans

Merge branch 'aberenguel-of-421-mina2'

parents 5ff34d2d d15c2045
...@@ -53,9 +53,13 @@ jzlib.jar | 1.0.7 ...@@ -53,9 +53,13 @@ jzlib.jar | 1.0.7
libidn.jar | 1.15 | GNU Lesser General Public License version 2.1 or later (http://www.gnu.org/licenses/licenses.html) libidn.jar | 1.15 | GNU Lesser General Public License version 2.1 or later (http://www.gnu.org/licenses/licenses.html)
log4j.jar | 1.2.15 | Apache 2.0 (http://logging.apache.org/log4j/1.2/license.html) log4j.jar | 1.2.15 | Apache 2.0 (http://logging.apache.org/log4j/1.2/license.html)
mail.jar | 1.4.1 (JavaMail) | mail.jar | 1.4.1 (JavaMail) |
mina-core.jar | 1.1.8 (https://svn.apache.org/repos/asf/mina/branches/1.1) | Apache 2.0 mina-core.jar | Apache Mina 2.0.7 | Apache 2.0
mina-filter-compression.jar | 1.1.8 (https://svn.apache.org/repos/asf/mina/branches/1.1) | Apache 2.0 mina-filter-compression.jar | Apache Mina 2.0.7 | Apache 2.0
mina-filter-ssl.jar | 1.1.8-SNAPSHOT (see note #2) | Apache 2.0 mina-integration-beans.jar | Apache Mina 2.0.7 | Apache 2.0
mina-integration-jmx.jar | Apache Mina 2.0.7 | Apache 2.0
mina-integration-ognl.jar | Apache Mina 2.0.7 | Apache 2.0
javassist.jar | 3.11.0.GA (Apache Mina 2.0.7) | Apache 2.0
ognl.jar | 3.0.5 (Apache Mina 2.0.7) | Apache 2.0
mysql.jar | 5.1.30 | GPL mysql.jar | 5.1.30 | GPL
objenesis | 1.0 (JMock 2.1.0) | BSD (http://www.jmock.org/license.html) objenesis | 1.0 (JMock 2.1.0) | BSD (http://www.jmock.org/license.html)
pack200task.jar | August 5, 2004 | LGPL pack200task.jar | August 5, 2004 | LGPL
...@@ -79,5 +83,5 @@ xpp3.jar | XPP_3 1.1.4c ...@@ -79,5 +83,5 @@ xpp3.jar | XPP_3 1.1.4c
Notes Notes
----- -----
1) proxool - patched ProxyConnection to send log message in #registerClosedStatement to debug instead of warn 1) proxool - patched ProxyConnection to send log message in #registerClosedStatement to debug instead of warn
2) mina-filter-ssl - applied patch to resize buffers OF-496 DIRMINA-914. Source code used: https://git-wip-us.apache.org/repos/asf?p=mina.git;a=commit;h=dd6395befe672d7bdb210b28b1b81592a3dc5e64 2) mina-* - upgraded to MINA 2.0.7; added javassist/ognl dependencies
3) npn-boot-1.1.7.v20140316.jar added to dist folder 3) npn-boot-1.1.7.v20140316.jar added to dist folder
package org.apache.mina.management; package org.apache.mina.management;
import org.apache.mina.common.*; import static org.jivesoftware.openfire.spi.ConnectionManagerImpl.EXECUTOR_FILTER_NAME;
import org.apache.mina.core.service.IoService;
import org.apache.mina.core.service.IoServiceListener;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.executor.ExecutorFilter; import org.apache.mina.filter.executor.ExecutorFilter;
import org.apache.mina.filter.executor.OrderedThreadPoolExecutor;
import java.net.SocketAddress; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/** /**
...@@ -59,15 +65,6 @@ public class MINAStatCollector { ...@@ -59,15 +65,6 @@ public class MINAStatCollector {
private final IoServiceListener serviceListener = new IoServiceListener() private final IoServiceListener serviceListener = new IoServiceListener()
{ {
public void serviceActivated( IoService service, SocketAddress serviceAddress, IoHandler handler,
IoServiceConfig config )
{
}
public void serviceDeactivated( IoService service, SocketAddress serviceAddress, IoHandler handler,
IoServiceConfig config )
{
}
public void sessionCreated( IoSession session ) public void sessionCreated( IoSession session )
{ {
...@@ -78,6 +75,18 @@ public class MINAStatCollector { ...@@ -78,6 +75,18 @@ public class MINAStatCollector {
{ {
removeSession( session ); removeSession( session );
} }
@Override
public void serviceActivated(IoService service) throws Exception {
}
@Override
public void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception {
}
@Override
public void serviceDeactivated(IoService service) throws Exception {
}
}; };
/** /**
...@@ -115,12 +124,10 @@ public class MINAStatCollector { ...@@ -115,12 +124,10 @@ public class MINAStatCollector {
polledSessions = new ConcurrentLinkedQueue<IoSession>(); polledSessions = new ConcurrentLinkedQueue<IoSession>();
Set<SocketAddress> addresses = service.getManagedServiceAddresses(); Map<Long, IoSession> sessions = service.getManagedSessions();
if (addresses != null) { if (sessions != null) {
for (SocketAddress element : addresses) { for (IoSession ioSession : sessions.values()) {
for (IoSession ioSession : service.getManagedSessions(element)) { addSession(ioSession);
addSession(ioSession);
}
} }
} }
...@@ -307,12 +314,15 @@ public class MINAStatCollector { ...@@ -307,12 +314,15 @@ public class MINAStatCollector {
tmpMsgRead += (readMessages - sessStat.lastMessageRead); tmpMsgRead += (readMessages - sessStat.lastMessageRead);
tmpBytesWritten += (writtenBytes - sessStat.lastByteWrite); tmpBytesWritten += (writtenBytes - sessStat.lastByteWrite);
tmpBytesRead += (readBytes - sessStat.lastByteRead); tmpBytesRead += (readBytes - sessStat.lastByteRead);
tmpScheduledWrites += session.getScheduledWriteRequests(); tmpScheduledWrites += session.getScheduledWriteMessages();
ExecutorFilter executorFilter = ExecutorFilter executorFilter =
(ExecutorFilter) session.getFilterChain().get(ExecutorThreadModel.class.getName()); (ExecutorFilter) session.getFilterChain().get(EXECUTOR_FILTER_NAME);
if (executorFilter != null) { if (executorFilter != null) {
tmpQueuevedEvents += executorFilter.getEventQueueSize(session); Executor executor = executorFilter.getExecutor();
if (executor instanceof OrderedThreadPoolExecutor) {
tmpQueuevedEvents += ((OrderedThreadPoolExecutor) executor).getActiveCount();
}
} }
sessStat.lastByteRead = readBytes; sessStat.lastByteRead = readBytes;
...@@ -331,4 +341,85 @@ public class MINAStatCollector { ...@@ -331,4 +341,85 @@ public class MINAStatCollector {
} }
} }
} }
public class IoSessionStat {
long lastByteRead = -1;
long lastByteWrite = -1;
long lastMessageRead = -1;
long lastMessageWrite = -1;
float byteWrittenThroughput = 0;
float byteReadThroughput = 0;
float messageWrittenThroughput = 0;
float messageReadThroughput = 0;
// last time the session was polled
long lastPollingTime = System.currentTimeMillis();
/**
* Bytes read per second
* @return bytes per second
*/
public float getByteReadThroughput() {
return byteReadThroughput;
}
/**
* Bytes written per second
* @return bytes per second
*/
public float getByteWrittenThroughput() {
return byteWrittenThroughput;
}
/**
* Messages read per second
* @return messages per second
*/
public float getMessageReadThroughput() {
return messageReadThroughput;
}
/**
* Messages written per second
* @return messages per second
*/
public float getMessageWrittenThroughput() {
return messageWrittenThroughput;
}
/**
* used for the StatCollector, last polling value
*/
long getLastByteRead() {
return lastByteRead;
}
/**
* used for the StatCollector, last polling value
*/
long getLastByteWrite() {
return lastByteWrite;
}
/**
* used for the StatCollector, last polling value
*/
long getLastMessageRead() {
return lastMessageRead;
}
/**
* used for the StatCollector, last polling value
*/
long getLastMessageWrite() {
return lastMessageWrite;
}
}
} }
...@@ -23,8 +23,9 @@ package org.jivesoftware.openfire.net; ...@@ -23,8 +23,9 @@ package org.jivesoftware.openfire.net;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
import org.apache.mina.common.IoFilterAdapter; import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.apache.mina.core.write.WriteRequest;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -47,15 +48,15 @@ public class StalledSessionsFilter extends IoFilterAdapter { ...@@ -47,15 +48,15 @@ public class StalledSessionsFilter extends IoFilterAdapter {
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
throws Exception { throws Exception {
// Get number of pending requests // Get number of pending requests
int pendingBytes = session.getScheduledWriteBytes(); long pendingBytes = session.getScheduledWriteBytes();
if (pendingBytes > bytesCap) { if (pendingBytes > bytesCap) {
// Get last time we were able to send something to the connected client // Get last time we were able to send something to the connected client
long writeTime = session.getLastWriteTime(); long writeTime = session.getLastWriteTime();
int pendingRequests = session.getScheduledWriteRequests(); int pendingRequests = session.getScheduledWriteMessages();
Log.debug("About to kill session with pendingBytes: " + pendingBytes + " pendingWrites: " + Log.debug("About to kill session with pendingBytes: " + pendingBytes + " pendingWrites: " +
pendingRequests + " lastWrite: " + new Date(writeTime) + "session: " + session); pendingRequests + " lastWrite: " + new Date(writeTime) + "session: " + session);
// Close the session and throw an exception // Close the session and throw an exception
session.close(); session.close(false);
throw new IOException("Closing session that seems to be stalled. Preventing OOM"); throw new IOException("Closing session that seems to be stalled. Preventing OOM");
} }
// Call next filter (everything is fine) // Call next filter (everything is fine)
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
...@@ -32,17 +32,17 @@ import java.nio.charset.CharsetEncoder; ...@@ -32,17 +32,17 @@ import java.nio.charset.CharsetEncoder;
*/ */
public class ByteBufferWriter extends Writer { public class ByteBufferWriter extends Writer {
private CharsetEncoder encoder; private CharsetEncoder encoder;
private ByteBuffer byteBuffer; private IoBuffer ioBuffer;
public ByteBufferWriter(ByteBuffer byteBuffer, CharsetEncoder encoder) { public ByteBufferWriter(IoBuffer byteBuffer, CharsetEncoder encoder) {
this.encoder = encoder; this.encoder = encoder;
this.byteBuffer = byteBuffer; this.ioBuffer = byteBuffer;
} }
@Override @Override
public void write(char cbuf[], int off, int len) throws IOException { public void write(char cbuf[], int off, int len) throws IOException {
byteBuffer.putString(new String(cbuf, off, len), encoder); ioBuffer.putString(new String(cbuf, off, len), encoder);
} }
@Override @Override
......
...@@ -19,20 +19,20 @@ ...@@ -19,20 +19,20 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.IdleStatus; import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.handler.IQPingHandler; import org.jivesoftware.openfire.handler.IQPingHandler;
import org.jivesoftware.openfire.net.ClientStanzaHandler; import org.jivesoftware.openfire.net.ClientStanzaHandler;
import org.jivesoftware.openfire.net.StanzaHandler; import org.jivesoftware.openfire.net.StanzaHandler;
import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.IQ.Type; import org.xmpp.packet.IQ.Type;
import org.xmpp.packet.JID;
/** /**
* ConnectionHandler that knows which subclass of {@link StanzaHandler} should * ConnectionHandler that knows which subclass of {@link StanzaHandler} should
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.net.ComponentStanzaHandler; import org.jivesoftware.openfire.net.ComponentStanzaHandler;
import org.jivesoftware.openfire.net.StanzaHandler; import org.jivesoftware.openfire.net.StanzaHandler;
......
...@@ -23,9 +23,9 @@ import java.io.IOException; ...@@ -23,9 +23,9 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.apache.mina.common.IdleStatus; import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.common.IoHandlerAdapter; import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolDecoderException; import org.apache.mina.filter.codec.ProtocolDecoderException;
import org.dom4j.io.XMPPPacketReader; import org.dom4j.io.XMPPPacketReader;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
...@@ -92,7 +92,7 @@ public abstract class ConnectionHandler extends IoHandlerAdapter { ...@@ -92,7 +92,7 @@ public abstract class ConnectionHandler extends IoHandlerAdapter {
// removing connections without warning. // removing connections without warning.
final int idleTime = getMaxIdleTime() / 2; final int idleTime = getMaxIdleTime() / 2;
if (idleTime > 0) { if (idleTime > 0) {
session.setIdleTime(IdleStatus.READER_IDLE, idleTime); session.getConfig().setIdleTime(IdleStatus.READER_IDLE, idleTime);
} }
} }
...@@ -151,7 +151,7 @@ public abstract class ConnectionHandler extends IoHandlerAdapter { ...@@ -151,7 +151,7 @@ public abstract class ConnectionHandler extends IoHandlerAdapter {
final Connection connection = (Connection) session.getAttribute(CONNECTION); final Connection connection = (Connection) session.getAttribute(CONNECTION);
connection.deliverRawText(error.toXML()); connection.deliverRawText(error.toXML());
session.close(); session.close(true);
} }
else { else {
Log.error("ConnectionHandler reports unexpected exception for session: " + session, cause); Log.error("ConnectionHandler reports unexpected exception for session: " + session, cause);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.multiplex.MultiplexerPacketDeliverer; import org.jivesoftware.openfire.multiplex.MultiplexerPacketDeliverer;
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import static org.jivesoftware.openfire.spi.ConnectionManagerImpl.EXECUTOR_FILTER_NAME;
import static org.jivesoftware.openfire.spi.ConnectionManagerImpl.TLS_FILTER_NAME;
import static org.jivesoftware.openfire.spi.ConnectionManagerImpl.COMPRESSION_FILTER_NAME;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
...@@ -34,11 +38,11 @@ import javax.net.ssl.SSLPeerUnverifiedException; ...@@ -34,11 +38,11 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import org.apache.mina.common.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.common.IoFilterChain; import org.apache.mina.core.filterchain.IoFilterChain;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.CompressionFilter; import org.apache.mina.filter.compression.CompressionFilter;
import org.apache.mina.filter.SSLFilter; import org.apache.mina.filter.ssl.SslFilter;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionCloseListener; import org.jivesoftware.openfire.ConnectionCloseListener;
...@@ -49,6 +53,7 @@ import org.jivesoftware.openfire.net.SSLConfig; ...@@ -49,6 +53,7 @@ import org.jivesoftware.openfire.net.SSLConfig;
import org.jivesoftware.openfire.net.SSLJiveKeyManagerFactory; import org.jivesoftware.openfire.net.SSLJiveKeyManagerFactory;
import org.jivesoftware.openfire.net.SSLJiveTrustManagerFactory; import org.jivesoftware.openfire.net.SSLJiveTrustManagerFactory;
import org.jivesoftware.openfire.net.ServerTrustManager; import org.jivesoftware.openfire.net.ServerTrustManager;
import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.openfire.session.LocalSession; import org.jivesoftware.openfire.session.LocalSession;
import org.jivesoftware.openfire.session.Session; import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
...@@ -155,7 +160,7 @@ public class NIOConnection implements Connection { ...@@ -155,7 +160,7 @@ public class NIOConnection implements Connection {
} }
public Certificate[] getLocalCertificates() { public Certificate[] getLocalCertificates() {
SSLSession sslSession = (SSLSession) ioSession.getAttribute(SSLFilter.SSL_SESSION); SSLSession sslSession = (SSLSession) ioSession.getAttribute(SslFilter.SSL_SESSION);
if (sslSession != null) { if (sslSession != null) {
return sslSession.getLocalCertificates(); return sslSession.getLocalCertificates();
} }
...@@ -164,7 +169,7 @@ public class NIOConnection implements Connection { ...@@ -164,7 +169,7 @@ public class NIOConnection implements Connection {
public Certificate[] getPeerCertificates() { public Certificate[] getPeerCertificates() {
try { try {
SSLSession sslSession = (SSLSession) ioSession.getAttribute(SSLFilter.SSL_SESSION); SSLSession sslSession = (SSLSession) ioSession.getAttribute(SslFilter.SSL_SESSION);
if (sslSession != null) { if (sslSession != null) {
return sslSession.getPeerCertificates(); return sslSession.getPeerCertificates();
} }
...@@ -198,7 +203,7 @@ public class NIOConnection implements Connection { ...@@ -198,7 +203,7 @@ public class NIOConnection implements Connection {
if (session != null) { if (session != null) {
session.setStatus(Session.STATUS_CLOSED); session.setStatus(Session.STATUS_CLOSED);
} }
ioSession.close(); ioSession.close(false);
closed = true; closed = true;
closedSuccessfully = true; closedSuccessfully = true;
} }
...@@ -240,7 +245,7 @@ public class NIOConnection implements Connection { ...@@ -240,7 +245,7 @@ public class NIOConnection implements Connection {
} }
public boolean isSecure() { public boolean isSecure() {
return ioSession.getFilterChain().contains("tls"); return ioSession.getFilterChain().contains(TLS_FILTER_NAME);
} }
public void deliver(Packet packet) throws UnauthorizedException { public void deliver(Packet packet) throws UnauthorizedException {
...@@ -248,7 +253,7 @@ public class NIOConnection implements Connection { ...@@ -248,7 +253,7 @@ public class NIOConnection implements Connection {
backupDeliverer.deliver(packet); backupDeliverer.deliver(packet);
} }
else { else {
ByteBuffer buffer = ByteBuffer.allocate(4096); IoBuffer buffer = IoBuffer.allocate(4096);
buffer.setAutoExpand(true); buffer.setAutoExpand(true);
boolean errorDelivering = false; boolean errorDelivering = false;
...@@ -290,7 +295,7 @@ public class NIOConnection implements Connection { ...@@ -290,7 +295,7 @@ public class NIOConnection implements Connection {
private void deliverRawText(String text, boolean asynchronous) { private void deliverRawText(String text, boolean asynchronous) {
if (!isClosed()) { if (!isClosed()) {
ByteBuffer buffer = ByteBuffer.allocate(text.length()); IoBuffer buffer = IoBuffer.allocate(text.length());
buffer.setAutoExpand(true); buffer.setAutoExpand(true);
boolean errorDelivering = false; boolean errorDelivering = false;
...@@ -312,7 +317,7 @@ public class NIOConnection implements Connection { ...@@ -312,7 +317,7 @@ public class NIOConnection implements Connection {
else { else {
// Send stanza and wait for ACK (using a 2 seconds default timeout) // Send stanza and wait for ACK (using a 2 seconds default timeout)
boolean ok = boolean ok =
ioSession.write(buffer).join(JiveGlobals.getIntProperty("connection.ack.timeout", 2000)); ioSession.write(buffer).awaitUninterruptibly(JiveGlobals.getIntProperty("connection.ack.timeout", 2000));
if (!ok) { if (!ok) {
Log.warn("No ACK was received when sending stanza to: " + this.toString()); Log.warn("No ACK was received when sending stanza to: " + this.toString());
} }
...@@ -355,12 +360,12 @@ public class NIOConnection implements Connection { ...@@ -355,12 +360,12 @@ public class NIOConnection implements Connection {
} }
} }
String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS"); String algorithm = JiveGlobals.getProperty(ConnectionSettings.Client.TLS_ALGORITHM, "TLS");
SSLContext tlsContext = SSLContext.getInstance(algorithm); SSLContext tlsContext = SSLContext.getInstance(algorithm);
tlsContext.init(km, tm, null); tlsContext.init(km, tm, null);
SSLFilter filter = new SSLFilter(tlsContext); SslFilter filter = new SslFilter(tlsContext);
filter.setUseClientMode(clientMode); filter.setUseClientMode(clientMode);
if (authentication == ClientAuth.needed) { if (authentication == ClientAuth.needed) {
filter.setNeedClientAuth(true); filter.setNeedClientAuth(true);
...@@ -371,12 +376,9 @@ public class NIOConnection implements Connection { ...@@ -371,12 +376,9 @@ public class NIOConnection implements Connection {
// good // good
filter.setWantClientAuth(true); filter.setWantClientAuth(true);
} }
// TODO Temporary workaround (placing SSLFilter before ExecutorFilter) to avoid deadlock. Waiting for ioSession.getFilterChain().addAfter(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, filter);
// MINA devs feedback. Note that ExecutorFilter is flanked by ReadThrottleFilterBuilder and we must not ioSession.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE);
// get in between them.
ioSession.getFilterChain().addBefore("org.apache.mina.filter.ReadThrottleFilterBuilder.add", "tls", filter);
//ioSession.getFilterChain().addAfter("org.apache.mina.filter.ReadThrottleFilterBuilder.release", "tls", filter);
ioSession.setAttribute(SSLFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE);
if (!clientMode) { if (!clientMode) {
// Indicate the client that the server is ready to negotiate TLS // Indicate the client that the server is ready to negotiate TLS
deliverRawText("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"); deliverRawText("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>");
...@@ -385,11 +387,11 @@ public class NIOConnection implements Connection { ...@@ -385,11 +387,11 @@ public class NIOConnection implements Connection {
public void addCompression() { public void addCompression() {
IoFilterChain chain = ioSession.getFilterChain(); IoFilterChain chain = ioSession.getFilterChain();
String baseFilter = "org.apache.mina.common.ExecutorThreadModel"; String baseFilter = EXECUTOR_FILTER_NAME;
if (chain.contains("tls")) { if (chain.contains(TLS_FILTER_NAME)) {
baseFilter = "tls"; baseFilter = TLS_FILTER_NAME;
} }
chain.addAfter(baseFilter, "compression", new CompressionFilter(true, false, CompressionFilter.COMPRESSION_MAX)); chain.addAfter(baseFilter, COMPRESSION_FILTER_NAME, new CompressionFilter(true, false, CompressionFilter.COMPRESSION_MAX));
} }
public void startCompression() { public void startCompression() {
......
...@@ -29,8 +29,7 @@ import java.util.Map; ...@@ -29,8 +29,7 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.mina.common.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderException; import org.apache.mina.filter.codec.ProtocolDecoderException;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.PropertyEventDispatcher; import org.jivesoftware.util.PropertyEventDispatcher;
...@@ -179,7 +178,7 @@ class XMLLightweightParser { ...@@ -179,7 +178,7 @@ class XMLLightweightParser {
/* /*
* Main reading method * Main reading method
*/ */
public void read(ByteBuffer byteBuffer) throws Exception { public void read(IoBuffer byteBuffer) throws Exception {
if (buffer == null) { if (buffer == null) {
// exception was thrown before, avoid duplicate exception(s) // exception was thrown before, avoid duplicate exception(s)
// "read" and discard remaining data // "read" and discard remaining data
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory; import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder; import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder; import org.apache.mina.filter.codec.ProtocolEncoder;
...@@ -38,11 +39,11 @@ public class XMPPCodecFactory implements ProtocolCodecFactory { ...@@ -38,11 +39,11 @@ public class XMPPCodecFactory implements ProtocolCodecFactory {
decoder = new XMPPDecoder(); decoder = new XMPPDecoder();
} }
public ProtocolEncoder getEncoder() throws Exception { public ProtocolEncoder getEncoder(IoSession session) throws Exception {
return encoder; return encoder;
} }
public ProtocolDecoder getDecoder() throws Exception { public ProtocolDecoder getDecoder(IoSession session) throws Exception {
return decoder; return decoder;
} }
} }
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder; import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput; import org.apache.mina.filter.codec.ProtocolDecoderOutput;
...@@ -33,7 +33,7 @@ import org.apache.mina.filter.codec.ProtocolDecoderOutput; ...@@ -33,7 +33,7 @@ import org.apache.mina.filter.codec.ProtocolDecoderOutput;
public class XMPPDecoder extends CumulativeProtocolDecoder { public class XMPPDecoder extends CumulativeProtocolDecoder {
@Override @Override
protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
throws Exception { throws Exception {
// Get the XML light parser from the IoSession // Get the XML light parser from the IoSession
XMLLightweightParser parser = (XMLLightweightParser) session.getAttribute(ConnectionHandler.XML_PARSER); XMLLightweightParser parser = (XMLLightweightParser) session.getAttribute(ConnectionHandler.XML_PARSER);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.jivesoftware.openfire.nio; package org.jivesoftware.openfire.nio;
import org.apache.mina.common.IoSession; import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter; import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput; import org.apache.mina.filter.codec.ProtocolEncoderOutput;
......
...@@ -21,6 +21,13 @@ public final class ConnectionSettings { ...@@ -21,6 +21,13 @@ public final class ConnectionSettings {
public static final String LOGIN_ALLOWED = "xmpp.client.login.allowed"; public static final String LOGIN_ALLOWED = "xmpp.client.login.allowed";
public static final String LOGIN_ANONYM_ALLOWED = "xmpp.client.login.allowedAnonym"; public static final String LOGIN_ANONYM_ALLOWED = "xmpp.client.login.allowedAnonym";
public static final String MAX_THREADS = "xmpp.client.processing.threads";
public static final String MAX_READ_BUFFER = "xmpp.client.maxReadBufferSize";
public static final String MAX_THREADS_SSL = "xmpp.client_ssl.processing.threads";
public static final String MAX_READ_BUFFER_SSL = "xmpp.client_ssl.maxReadBufferSize";
public static final String TLS_ALGORITHM = "xmpp.socket.ssl.algorithm";
private Client() { private Client() {
} }
} }
......
...@@ -20,16 +20,19 @@ ...@@ -20,16 +20,19 @@
package org.jivesoftware.openfire.plugin; package org.jivesoftware.openfire.plugin;
import org.apache.mina.common.ExecutorThreadModel; import static org.jivesoftware.openfire.spi.ConnectionManagerImpl.EXECUTOR_FILTER_NAME;
import org.apache.mina.filter.executor.ExecutorFilter;
import org.apache.mina.management.MINAStatCollector; import org.apache.mina.management.MINAStatCollector;
import org.apache.mina.transport.socket.nio.SocketAcceptor; import org.apache.mina.transport.socket.SocketAcceptor;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.SessionManager; import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl; import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.TaskEngine; import org.jivesoftware.util.TaskEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
...@@ -47,6 +50,9 @@ import java.util.concurrent.ThreadPoolExecutor; ...@@ -47,6 +50,9 @@ import java.util.concurrent.ThreadPoolExecutor;
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class StatCollector extends TimerTask { public class StatCollector extends TimerTask {
private static final Logger Log = LoggerFactory.getLogger(StatCollector.class);
private boolean headerPrinter = false; private boolean headerPrinter = false;
private List<String> content = new ArrayList<String>(); private List<String> content = new ArrayList<String>();
private SocketAcceptor socketAcceptor; private SocketAcceptor socketAcceptor;
...@@ -80,13 +86,17 @@ public class StatCollector extends TimerTask { ...@@ -80,13 +86,17 @@ public class StatCollector extends TimerTask {
sb.append(DbConnectionManager.getConnectionProvider().toString()); sb.append(DbConnectionManager.getConnectionProvider().toString());
sb.append(','); sb.append(',');
// Add info about the thread pool that process incoming requests // Add info about the thread pool that process incoming requests
ExecutorThreadModel threadModel = (ExecutorThreadModel) socketAcceptor.getDefaultConfig().getThreadModel(); ExecutorFilter executorFilter = (ExecutorFilter) socketAcceptor.getFilterChain().get(EXECUTOR_FILTER_NAME);
ThreadPoolExecutor executor = (ThreadPoolExecutor) threadModel.getExecutor(); ThreadPoolExecutor executor = (ThreadPoolExecutor) executorFilter.getExecutor();
sb.append(executor.getCorePoolSize()); sb.append(executor.getCorePoolSize());
sb.append(','); sb.append(',');
sb.append(executor.getActiveCount()); sb.append(executor.getActiveCount());
sb.append(','); sb.append(',');
sb.append(executor.getQueue().size()); try {
sb.append(executor.getQueue().size());
} catch (UnsupportedOperationException e) {
sb.append(-1);
}
sb.append(','); sb.append(',');
sb.append(executor.getCompletedTaskCount()); sb.append(executor.getCompletedTaskCount());
// Add info about number of connected sessions // Add info about number of connected sessions
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
%> %>
<%@ page import="com.sun.syndication.fetcher.impl.FeedFetcherCache"%> <%@ page import="com.sun.syndication.fetcher.impl.FeedFetcherCache"%>
<%@ page import="com.sun.syndication.fetcher.impl.HashMapFeedInfoCache"%> <%@ page import="com.sun.syndication.fetcher.impl.HashMapFeedInfoCache"%>
<%@ page import="org.apache.mina.transport.socket.nio.SocketAcceptor"%> <%@ page import="org.apache.mina.transport.socket.nio.NioSocketAcceptor"%>
<%@ page import="org.jivesoftware.admin.AdminConsole"%> <%@ page import="org.jivesoftware.admin.AdminConsole"%>
<%@ page import="org.jivesoftware.openfire.*" %> <%@ page import="org.jivesoftware.openfire.*" %>
<%@ page import="org.jivesoftware.openfire.container.AdminConsolePlugin" %> <%@ page import="org.jivesoftware.openfire.container.AdminConsolePlugin" %>
...@@ -75,9 +75,9 @@ ...@@ -75,9 +75,9 @@
String interfaceName = JiveGlobals.getXMLProperty("network.interface"); String interfaceName = JiveGlobals.getXMLProperty("network.interface");
ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager()); ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
SocketAcceptor socketAcceptor = connectionManager.getSocketAcceptor(); NioSocketAcceptor socketAcceptor = connectionManager.getSocketAcceptor();
SocketAcceptor sslSocketAcceptor = connectionManager.getSSLSocketAcceptor(); NioSocketAcceptor sslSocketAcceptor = connectionManager.getSSLSocketAcceptor();
SocketAcceptor multiplexerSocketAcceptor = connectionManager.getMultiplexerSocketAcceptor(); NioSocketAcceptor multiplexerSocketAcceptor = connectionManager.getMultiplexerSocketAcceptor();
ServerPort serverPort = null; ServerPort serverPort = null;
ServerPort componentPort = null; ServerPort componentPort = null;
AdminConsolePlugin adminConsolePlugin = AdminConsolePlugin adminConsolePlugin =
...@@ -445,7 +445,7 @@ ...@@ -445,7 +445,7 @@
</thead> </thead>
<tbody> <tbody>
<% if (socketAcceptor != null) { <% if (socketAcceptor != null) {
for (SocketAddress socketAddress : socketAcceptor.getManagedServiceAddresses()) { for (SocketAddress socketAddress : socketAcceptor.getLocalAddresses()) {
InetSocketAddress address = (InetSocketAddress) socketAddress; InetSocketAddress address = (InetSocketAddress) socketAddress;
%> %>
<tr> <tr>
...@@ -469,7 +469,7 @@ ...@@ -469,7 +469,7 @@
</tr> </tr>
<% } } %> <% } } %>
<% if (sslSocketAcceptor != null) { <% if (sslSocketAcceptor != null) {
for (SocketAddress socketAddress : sslSocketAcceptor.getManagedServiceAddresses()) { for (SocketAddress socketAddress : sslSocketAcceptor.getLocalAddresses()) {
InetSocketAddress address = (InetSocketAddress) socketAddress; InetSocketAddress address = (InetSocketAddress) socketAddress;
%> %>
<tr> <tr>
...@@ -506,7 +506,7 @@ ...@@ -506,7 +506,7 @@
</tr> </tr>
<% } %> <% } %>
<% if (multiplexerSocketAcceptor != null) { <% if (multiplexerSocketAcceptor != null) {
for (SocketAddress socketAddress : multiplexerSocketAcceptor.getManagedServiceAddresses()) { for (SocketAddress socketAddress : multiplexerSocketAcceptor.getLocalAddresses()) {
InetSocketAddress address = (InetSocketAddress) socketAddress; InetSocketAddress address = (InetSocketAddress) socketAddress;
%> %>
<tr> <tr>
......
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