You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pr...@apache.org on 2006/11/06 00:28:14 UTC
svn commit: r471569 - in /directory/branches/mina/1.2:
core/src/main/java/org/apache/mina/common/
core/src/main/java/org/apache/mina/common/support/
core/src/main/java/org/apache/mina/handler/support/
core/src/test/java/org/apache/mina/common/support/ ...
Author: proyal
Date: Sun Nov 5 15:28:13 2006
New Revision: 471569
URL: http://svn.apache.org/viewvc?view=rev&rev=471569
Log:
Use new concurrency primitives in the DefaultIoFuture. Changes external API slightly by throwing an InterruptedException (which is good, to force calling code to handle anyways). Remove un-used cxtor that took an external object to synchornize on, since it now uses a CountDownLatch
Modified:
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoFuture.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoSession.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultCloseFuture.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultConnectFuture.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultWriteFuture.java
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java
directory/branches/mina/1.2/core/src/test/java/org/apache/mina/common/support/FutureTest.java
directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/httpserver/codec/ServerHandler.java
directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManager.java
directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManagerMBean.java
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoFuture.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoFuture.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoFuture.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoFuture.java Sun Nov 5 15:28:13 2006
@@ -6,23 +6,23 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common;
/**
* Represents the result of an ashynchronous I/O operation.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -32,23 +32,18 @@
* Returns the {@link IoSession} which is associated with this future.
*/
IoSession getSession();
-
- /**
- * Returns the lock object this future acquires.
- */
- Object getLock();
-
+
/**
* Wait for the asynchronous operation to end.
*/
- void join();
+ void join() throws InterruptedException;
/**
* Wait for the asynchronous operation to end with the specified timeout.
- *
+ *
* @return <tt>true</tt> if the operation is finished.
*/
- boolean join( long timeoutInMillis );
+ boolean join( long timeoutInMillis ) throws InterruptedException;
/**
* Returns if the asynchronous operation is finished.
@@ -60,7 +55,7 @@
* the state of this future changes.
*/
void addListener( IoFutureListener listener );
-
+
/**
* Removes an existing event <tt>listener</tt> which is notified when
* the state of this future changes.
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoSession.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoSession.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/IoSession.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common;
@@ -23,38 +23,38 @@
import java.util.Set;
/**
- * A handle which represents connection between two endpoints regardless of
+ * A handle which represents connection between two endpoints regardless of
* transport types.
* <p>
* {@link IoSession} provides user-defined attributes. User-defined attributes
* are application-specific data which is associated with a session.
* It often contains objects that represents the state of a higher-level protocol
* and becomes a way to exchange data between filters and handlers.
- *
+ *
* <h3>Adjusting Transport Type Specific Properties</h3>
* <p>
* You can simply downcast the session to an appropriate subclass.
* </p>
- *
+ *
* <h3>Thread Safety</h3>
* <p>
* {@link IoSession} is thread-safe. But please note that performing
* more than one {@link #write(Object)} calls at the same time will
* cause the {@link IoFilter#filterWrite(IoFilter.NextFilter, IoSession, IoFilter.WriteRequest)}
* is executed simnutaneously, and therefore you have to make sure the
- * {@link IoFilter} implementations you're using are thread-safe, too.
+ * {@link IoFilter} implementations you're using are thread-safe, too.
* </p>
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
public interface IoSession {
-
+
/**
* Returns the {@link IoService} which provides I/O service to this session.
*/
IoService getService();
-
+
/**
* Returns the {@link IoServiceConfig} of this session.
*/
@@ -69,7 +69,7 @@
* Returns the configuration of this session.
*/
IoSessionConfig getConfig();
-
+
/**
* Returns the filter chain that only affects this session.
*/
@@ -100,56 +100,56 @@
/**
* Sets an attachment of this session.
* This method is identical with <tt>setAttribute( "", attachment )</tt>.
- *
+ *
* @return Old attachment. <tt>null</tt> if it is new.
*/
Object setAttachment( Object attachment );
-
+
/**
* Returns the value of user-defined attribute of this session.
- *
+ *
* @param key the key of the attribute
* @return <tt>null</tt> if there is no attribute with the specified key
*/
Object getAttribute( String key );
-
+
/**
* Sets a user-defined attribute.
- *
+ *
* @param key the key of the attribute
* @param value the value of the attribute
* @return The old value of the attribute. <tt>null</tt> if it is new.
*/
Object setAttribute( String key, Object value );
-
+
/**
* Sets a user defined attribute without a value. This is useful when
* you just want to put a 'mark' attribute. Its value is set to
* {@link Boolean#TRUE}.
- *
+ *
* @param key the key of the attribute
* @return The old value of the attribute. <tt>null</tt> if it is new.
*/
Object setAttribute( String key );
-
+
/**
* Removes a user-defined attribute with the specified key.
- *
+ *
* @return The old value of the attribute. <tt>null</tt> if not found.
*/
Object removeAttribute( String key );
-
+
/**
* Returns <tt>true</tt> if this session contains the attribute with
* the specified <tt>key</tt>.
*/
boolean containsAttribute( String key );
-
+
/**
* Returns the set of keys of all user-defined attributes.
*/
- Set getAttributeKeys();
-
+ Set<String> getAttributeKeys();
+
/**
* Returns transport type of this session.
*/
@@ -159,13 +159,13 @@
* Returns <code>true</code> if this session is connected with remote peer.
*/
boolean isConnected();
-
+
/**
* Returns <code>true</tt> if and only if this session is being closed
* (but not disconnected yet) or is closed.
*/
boolean isClosing();
-
+
/**
* Returns the {@link CloseFuture} of this session. This method returns
* the same instance whenever user calls it.
@@ -173,7 +173,7 @@
CloseFuture getCloseFuture();
/**
- * Returns the socket address of remote peer.
+ * Returns the socket address of remote peer.
*/
SocketAddress getRemoteAddress();
@@ -182,14 +182,14 @@
* session.
*/
SocketAddress getLocalAddress();
-
+
/**
* Returns the socket address of the {@link IoService} listens to to manage
* this session. If this session is managed by {@link IoAcceptor}, it
* returns the {@link SocketAddress} which is specified as a parameter of
* {@link IoAcceptor#bind(SocketAddress, IoHandler)}. If this session is
* managed by {@link IoConnector}, this method returns the same address with
- * that of {@link #getRemoteAddress()}.
+ * that of {@link #getRemoteAddress()}.
*/
SocketAddress getServiceAddress();
@@ -207,7 +207,7 @@
* Sets idle time for the specified type of idleness in seconds.
*/
void setIdleTime( IdleStatus status, int idleTime );
-
+
/**
* Returns write timeout in seconds.
*/
@@ -222,12 +222,12 @@
* Sets write timeout in seconds.
*/
void setWriteTimeout( int writeTimeout );
-
+
/**
* Returns the current {@link TrafficMask} of this session.
*/
TrafficMask getTrafficMask();
-
+
/**
* Sets the {@link TrafficMask} of this session which will result
* the parent {@link IoService} to start to control the traffic
@@ -240,25 +240,25 @@
* suspends read operations for this session.
*/
void suspendRead();
-
+
/**
* A shortcut method for {@link #setTrafficMask(TrafficMask)} that
* suspends write operations for this session.
*/
void suspendWrite();
-
+
/**
* A shortcut method for {@link #setTrafficMask(TrafficMask)} that
* resumes read operations for this session.
*/
void resumeRead();
-
+
/**
* A shortcut method for {@link #setTrafficMask(TrafficMask)} that
* resumes write operations for this session.
*/
void resumeWrite();
-
+
/**
* Returns the total number of bytes which were read from this session.
*/
@@ -268,9 +268,9 @@
* Returns the total number of bytes which were written to this session.
*/
long getWrittenBytes();
-
+
/**
- * Returns the total number of messages which were read and decoded from this session.
+ * Returns the total number of messages which were read and decoded from this session.
*/
long getReadMessages();
@@ -283,7 +283,7 @@
* Returns the total number of write requests which were written to this session.
*/
long getWrittenWriteRequests();
-
+
/**
* Returns the number of write requests which are scheduled to be written
* to this session.
@@ -300,7 +300,7 @@
* Returns the time in millis when this session is created.
*/
long getCreationTime();
-
+
/**
* Returns the time in millis when I/O occurred lastly.
*/
@@ -317,7 +317,7 @@
long getLastWriteTime();
/**
- * Returns <code>true</code> if this session is idle for the specified
+ * Returns <code>true</code> if this session is idle for the specified
* {@link IdleStatus}.
*/
boolean isIdle( IdleStatus status );
@@ -333,7 +333,7 @@
* any I/O between two (or more) <tt>sessionIdle</tt> events.
*/
int getIdleCount( IdleStatus status );
-
+
/**
* Returns the time in millis when the last <tt>sessionIdle</tt> event
* is fired for the specified {@link IdleStatus}.
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java Sun Nov 5 15:28:13 2006
@@ -6,27 +6,28 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common;
import java.nio.ByteOrder;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.mina.common.support.BaseByteBuffer;
/**
* A simplistic {@link ByteBufferAllocator} which simply allocates a new
* buffer every time.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -37,21 +38,21 @@
public SimpleByteBufferAllocator()
{
}
-
+
public ByteBuffer allocate( int capacity, boolean direct )
{
java.nio.ByteBuffer nioBuffer;
if( direct )
{
- nioBuffer = java.nio.ByteBuffer.allocateDirect( capacity );
+ nioBuffer = java.nio.ByteBuffer.allocateDirect( capacity );
}
else
{
- nioBuffer = java.nio.ByteBuffer.allocate( capacity );
+ nioBuffer = java.nio.ByteBuffer.allocate( capacity );
}
return new SimpleByteBuffer( nioBuffer );
}
-
+
public ByteBuffer wrap( java.nio.ByteBuffer nioBuffer )
{
return new SimpleByteBuffer( nioBuffer );
@@ -64,58 +65,57 @@
private static class SimpleByteBuffer extends BaseByteBuffer
{
private java.nio.ByteBuffer buf;
- private int refCount = 1;
+ private final AtomicInteger refCount = new AtomicInteger();
protected SimpleByteBuffer( java.nio.ByteBuffer buf )
{
this.buf = buf;
buf.order( ByteOrder.BIG_ENDIAN );
- refCount = 1;
+ refCount.set( 1 );
}
- public synchronized void acquire()
+ @Override
+ public void acquire()
{
- if( refCount <= 0 )
+ if( refCount.get() <= 0 )
{
throw new IllegalStateException( "Already released buffer." );
}
- refCount ++;
+ refCount.incrementAndGet();
}
+ @Override
public void release()
{
- synchronized( this )
+ if( refCount.get() <= 0 )
{
- if( refCount <= 0 )
- {
- refCount = 0;
- throw new IllegalStateException(
- "Already released buffer. You released the buffer too many times." );
- }
-
- refCount --;
- if( refCount > 0)
- {
- return;
- }
+ refCount.set( 0 );
+ throw new IllegalStateException(
+ "Already released buffer. You released the buffer too many times." );
}
+
+ refCount.decrementAndGet();
}
+ @Override
public java.nio.ByteBuffer buf()
{
return buf;
}
-
+
+ @Override
public boolean isPooled()
{
return false;
}
-
+
+ @Override
public void setPooled( boolean pooled )
{
}
+ @Override
protected void capacity0( int requestedCapacity )
{
int newCapacity = MINIMUM_CAPACITY;
@@ -123,7 +123,7 @@
{
newCapacity <<= 1;
}
-
+
java.nio.ByteBuffer oldBuf = this.buf;
java.nio.ByteBuffer newBuf;
if( isDirect() )
@@ -141,23 +141,31 @@
this.buf = newBuf;
}
- public ByteBuffer duplicate() {
+ @Override
+ public ByteBuffer duplicate()
+ {
return new SimpleByteBuffer( this.buf.duplicate() );
}
- public ByteBuffer slice() {
+ @Override
+ public ByteBuffer slice()
+ {
return new SimpleByteBuffer( this.buf.slice() );
}
- public ByteBuffer asReadOnlyBuffer() {
+ @Override
+ public ByteBuffer asReadOnlyBuffer()
+ {
return new SimpleByteBuffer( this.buf.asReadOnlyBuffer() );
}
+ @Override
public byte[] array()
{
return buf.array();
}
-
+
+ @Override
public int arrayOffset()
{
return buf.arrayOffset();
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultCloseFuture.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultCloseFuture.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultCloseFuture.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultCloseFuture.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common.support;
@@ -24,7 +24,7 @@
/**
* A default implementation of {@link CloseFuture}.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -37,27 +37,19 @@
{
super( session );
}
-
- /**
- * Creates a new instance which uses the specified object as a lock.
- */
- public DefaultCloseFuture( IoSession session, Object lock )
- {
- super( session, lock );
- }
-
+
public boolean isClosed()
{
if( isReady() )
{
- return ( ( Boolean ) getValue() ).booleanValue();
+ return ( Boolean ) getValue();
}
else
{
return false;
}
}
-
+
public void setClosed()
{
setValue( Boolean.TRUE );
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultConnectFuture.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultConnectFuture.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultConnectFuture.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultConnectFuture.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common.support;
@@ -40,7 +40,7 @@
failedFuture.setException( exception );
return failedFuture;
}
-
+
/**
* Creates a new instance.
*/
@@ -48,15 +48,8 @@
{
super( null );
}
-
- /**
- * Creates a new instance which uses the specified object as a lock.
- */
- public DefaultConnectFuture( Object lock )
- {
- super( null, lock );
- }
+ @Override
public IoSession getSession() throws RuntimeIOException
{
Object v = getValue();
@@ -78,12 +71,12 @@
{
return getValue() instanceof IoSession;
}
-
+
public void setSession( IoSession session )
{
setValue( session );
}
-
+
public void setException( Throwable exception )
{
setValue( exception );
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java Sun Nov 5 15:28:13 2006
@@ -6,22 +6,24 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common.support;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.mina.common.IoFuture;
import org.apache.mina.common.IoFutureListener;
@@ -29,116 +31,47 @@
/**
* A default implementation of {@link IoFuture}.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
public class DefaultIoFuture implements IoFuture
{
private final IoSession session;
- private final Object lock;
- private final List listeners = new ArrayList();
- private Object result;
- private boolean ready;
+ private final CountDownLatch completionLatch = new CountDownLatch( 1 );
+ private final List<IoFutureListener> listeners = new CopyOnWriteArrayList<IoFutureListener>();
+ private final AtomicBoolean ready = new AtomicBoolean( false );
+
+ private volatile Object result;
/**
* Creates a new instance.
- *
+ *
* @param session an {@link IoSession} which is associated with this future
*/
public DefaultIoFuture( IoSession session )
{
this.session = session;
- this.lock = this;
}
-
- /**
- * Creates a new instance which uses the specified object as a lock.
- */
- public DefaultIoFuture( IoSession session, Object lock )
- {
- if( lock == null )
- {
- throw new NullPointerException( "lock" );
- }
- this.session = session;
- this.lock = lock;
- }
-
+
public IoSession getSession()
{
return session;
}
-
- public Object getLock()
- {
- return lock;
- }
-
- public void join()
+
+ public void join() throws InterruptedException
{
- synchronized( lock )
- {
- while( !ready )
- {
- try
- {
- lock.wait();
- }
- catch( InterruptedException e )
- {
- }
- }
- }
+ completionLatch.await();
}
- public boolean join( long timeoutInMillis )
+ public boolean join( long timeoutInMillis ) throws InterruptedException
{
- long startTime = ( timeoutInMillis <= 0 ) ? 0 : System
- .currentTimeMillis();
- long waitTime = timeoutInMillis;
-
- synchronized( lock )
- {
- if( ready )
- {
- return ready;
- }
- else if( waitTime <= 0 )
- {
- return ready;
- }
-
- for( ;; )
- {
- try
- {
- lock.wait( waitTime );
- }
- catch( InterruptedException e )
- {
- }
-
- if( ready )
- return true;
- else
- {
- waitTime = timeoutInMillis - ( System.currentTimeMillis() - startTime );
- if( waitTime <= 0 )
- {
- return ready;
- }
- }
- }
- }
+ return completionLatch.await( timeoutInMillis, TimeUnit.MILLISECONDS );
}
public boolean isReady()
{
- synchronized( lock )
- {
- return ready;
- }
+ return ready.get();
}
/**
@@ -146,18 +79,10 @@
*/
protected void setValue( Object newValue )
{
- synchronized( lock )
+ if( ready.compareAndSet( false, true ) )
{
- // Allow only once.
- if( ready )
- {
- return;
- }
-
result = newValue;
- ready = true;
- lock.notifyAll();
-
+ completionLatch.countDown();
notifyListeners();
}
}
@@ -167,12 +92,9 @@
*/
protected Object getValue()
{
- synchronized( lock )
- {
- return result;
- }
+ return result;
}
-
+
public void addListener( IoFutureListener listener )
{
if( listener == null )
@@ -180,16 +102,14 @@
throw new NullPointerException( "listener" );
}
- synchronized( lock )
+ listeners.add( listener );
+
+ if( ready.get() )
{
- listeners.add( listener );
- if( ready )
- {
- listener.operationComplete( this );
- }
+ listener.operationComplete( this );
}
}
-
+
public void removeListener( IoFutureListener listener )
{
if( listener == null )
@@ -197,19 +117,14 @@
throw new NullPointerException( "listener" );
}
- synchronized( lock )
- {
- listeners.remove( listener );
- }
+ listeners.remove( listener );
}
private void notifyListeners()
{
- synchronized( lock )
+ for( IoFutureListener listener : listeners )
{
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- ( ( IoFutureListener ) i.next() ).operationComplete( this );
- }
+ listener.operationComplete( this );
}
}
}
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultWriteFuture.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultWriteFuture.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultWriteFuture.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/support/DefaultWriteFuture.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common.support;
@@ -24,7 +24,7 @@
/**
* A default implementation of {@link WriteFuture}.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -49,7 +49,7 @@
unwrittenFuture.setWritten( false );
return unwrittenFuture;
}
-
+
/**
* Creates a new instance.
*/
@@ -57,20 +57,12 @@
{
super( session );
}
-
- /**
- * Creates a new instance which uses the specified object as a lock.
- */
- public DefaultWriteFuture( IoSession session, Object lock )
- {
- super( session, lock );
- }
-
+
public boolean isWritten()
{
if( isReady() )
{
- return ( ( Boolean ) getValue() ).booleanValue();
+ return ( Boolean ) getValue();
}
else
{
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java (original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.handler.support;
@@ -24,6 +24,7 @@
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
+import org.apache.mina.common.RuntimeIOException;
import org.apache.mina.common.WriteFuture;
/**
@@ -32,21 +33,27 @@
*
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
- *
*/
public class IoSessionOutputStream extends OutputStream
{
private final IoSession session;
private WriteFuture lastWriteFuture;
-
+
public IoSessionOutputStream( IoSession session )
{
this.session = session;
}
-
+
+ @Override
public void close()
{
- session.close().join();
+ try
+ {
+ session.close().join();
+ } catch( InterruptedException e )
+ {
+ throw new RuntimeIOException( e );
+ }
}
private void checkClosed() throws IOException
@@ -56,19 +63,20 @@
throw new IOException( "The session has been closed." );
}
}
-
+
private synchronized void write( ByteBuffer buf ) throws IOException
{
checkClosed();
- WriteFuture future = session.write( buf );
- lastWriteFuture = future;
+ lastWriteFuture = session.write( buf );
}
-
+
+ @Override
public void write( byte[] b, int off, int len ) throws IOException
{
write( ByteBuffer.wrap( b, off, len ) );
}
+ @Override
public void write( int b ) throws IOException
{
ByteBuffer buf = ByteBuffer.allocate( 1 );
@@ -76,15 +84,23 @@
buf.flip();
write( buf );
}
-
+
+ @Override
public synchronized void flush() throws IOException
{
if( lastWriteFuture == null )
{
return;
}
-
- lastWriteFuture.join();
+
+ try
+ {
+ lastWriteFuture.join();
+ } catch( InterruptedException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+
if( !lastWriteFuture.isWritten() )
{
throw new IOException( "The bytes could not be written to the session" );
Modified: directory/branches/mina/1.2/core/src/test/java/org/apache/mina/common/support/FutureTest.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/test/java/org/apache/mina/common/support/FutureTest.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/core/src/test/java/org/apache/mina/common/support/FutureTest.java (original)
+++ directory/branches/mina/1.2/core/src/test/java/org/apache/mina/common/support/FutureTest.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common.support;
@@ -35,30 +35,30 @@
/**
* Tests {@link IoFuture} implementations.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
- * @version $Rev$, $Date$
+ * @version $Rev$, $Date$
*/
public class FutureTest extends TestCase
{
-
+
public void testCloseFuture() throws Exception
{
DefaultCloseFuture future = new DefaultCloseFuture( null );
assertFalse( future.isReady() );
assertFalse( future.isClosed() );
-
+
TestThread thread = new TestThread( future );
thread.start();
-
+
future.setClosed();
thread.join();
-
+
assertTrue( thread.success );
assertTrue( future.isReady() );
assertTrue( future.isClosed() );
}
-
+
public void testConnectFuture() throws Exception
{
DefaultConnectFuture future = new DefaultConnectFuture();
@@ -68,7 +68,7 @@
TestThread thread = new TestThread( future );
thread.start();
-
+
IoSession session = new BaseIoSession()
{
public IoHandler getHandler()
@@ -101,10 +101,12 @@
return 0;
}
+ @Override
protected void updateTrafficMask()
{
}
+ @Override
public boolean isClosing()
{
return false;
@@ -135,25 +137,25 @@
return null;
}
};
-
+
future.setSession( session );
thread.join();
-
+
assertTrue( thread.success );
assertTrue( future.isReady() );
assertTrue( future.isConnected() );
assertEquals( session, future.getSession() );
-
+
future = new DefaultConnectFuture();
thread = new TestThread( future );
thread.start();
future.setException( new IOException() );
thread.join();
-
+
assertTrue( thread.success );
assertTrue( future.isReady() );
assertFalse( future.isConnected() );
-
+
try
{
future.getSession();
@@ -163,19 +165,19 @@
{
}
}
-
+
public void testWriteFuture() throws Exception
{
DefaultWriteFuture future = new DefaultWriteFuture( null );
assertFalse( future.isReady() );
assertFalse( future.isWritten() );
-
+
TestThread thread = new TestThread( future );
thread.start();
-
+
future.setWritten( true );
thread.join();
-
+
assertTrue( thread.success );
assertTrue( future.isReady() );
assertTrue( future.isWritten() );
@@ -183,28 +185,36 @@
future = new DefaultWriteFuture( null );
thread = new TestThread( future );
thread.start();
-
+
future.setWritten( false );
thread.join();
-
+
assertTrue( thread.success );
assertTrue( future.isReady() );
assertFalse( future.isWritten() );
}
-
+
private static class TestThread extends Thread
{
private final IoFuture future;
private boolean success;
-
- public TestThread( IoFuture future )
+
+ TestThread( IoFuture future )
{
this.future = future;
}
-
+
+ @Override
public void run()
{
- success = future.join( 10000 );
+ try
+ {
+ success = future.join( 10000 );
+ } catch( InterruptedException e )
+ {
+ // propagate
+ Thread.currentThread().interrupt();
+ }
}
}
}
Modified: directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java (original)
+++ directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.example.chat.client;
@@ -26,6 +26,7 @@
import org.apache.mina.common.ConnectFuture;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoSession;
+import org.apache.mina.common.RuntimeIOException;
import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
import org.apache.mina.filter.SSLFilter;
import org.apache.mina.transport.socket.nio.SocketConnector;
@@ -33,7 +34,7 @@
/**
* A simple chat client for a given user.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -59,10 +60,10 @@
{
throw new IllegalStateException( "Already connected. Disconnect first." );
}
-
+
try
{
-
+
SocketConnectorConfig config = new SocketConnectorConfig();
if( useSsl )
{
@@ -71,7 +72,7 @@
sslFilter.setUseClientMode( true );
config.getFilterChain().addLast( "sslFilter", sslFilter );
}
-
+
ConnectFuture future1 = connector.connect( address, handler, config );
future1.join();
if( ! future1.isConnected() )
@@ -79,7 +80,7 @@
return false;
}
session = future1.getSession();
-
+
return true;
}
catch ( Exception e)
@@ -106,7 +107,13 @@
{
session.write( "QUIT" );
// Wait until the chat ends.
- session.getCloseFuture().join();
+ try
+ {
+ session.getCloseFuture().join();
+ } catch( InterruptedException e )
+ {
+ throw new RuntimeIOException( e );
+ }
}
session.close();
}
Modified: directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/httpserver/codec/ServerHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/httpserver/codec/ServerHandler.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/httpserver/codec/ServerHandler.java (original)
+++ directory/branches/mina/1.2/example/src/main/java/org/apache/mina/example/httpserver/codec/ServerHandler.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.example.httpserver.codec;
@@ -23,22 +23,25 @@
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
+import org.apache.mina.common.RuntimeIOException;
import org.apache.mina.util.SessionLog;
/**
* An {@link IoHandler} for HTTP.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
public class ServerHandler extends IoHandlerAdapter
{
+ @Override
public void sessionOpened( IoSession session )
{
// set idle time to 60 seconds
session.setIdleTime( IdleStatus.BOTH_IDLE, 60 );
}
+ @Override
public void messageReceived( IoSession session, Object message )
{
// Check that we can service the request context
@@ -64,15 +67,25 @@
// HttpResponseMessage.HTTP_STATUS_NOT_FOUND));
if( response != null )
- session.write( response ).join();
+ {
+ try
+ {
+ session.write( response ).join();
+ } catch( InterruptedException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+ }
}
+ @Override
public void sessionIdle( IoSession session, IdleStatus status )
{
SessionLog.info( session, "Disconnecting the idle." );
session.close();
}
+ @Override
public void exceptionCaught( IoSession session, Throwable cause )
{
session.close();
Modified: directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManager.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManager.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManager.java (original)
+++ directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManager.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.integration.jmx;
@@ -23,11 +23,9 @@
import java.util.Date;
import java.util.List;
-
import org.apache.mina.common.IdleStatus;
import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoSession;
-import org.apache.mina.common.support.BaseIoSession;
import org.apache.mina.filter.LoggingFilter;
import org.apache.mina.management.IoSessionStat;
import org.apache.mina.management.StatCollector;
@@ -52,28 +50,16 @@
this.session = session;
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#isConnected()
- */
public boolean isConnected()
{
return session.isConnected();
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getReadBytes()
- */
public long getReadBytes()
{
return session.getReadBytes();
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getWrittenBytes()
- */
public long getWrittenBytes()
{
return session.getWrittenBytes();
@@ -82,63 +68,42 @@
public long getReadMessages()
{
- return ( ( BaseIoSession ) session ).getReadMessages();
+ return session.getReadMessages();
}
public long getWrittenMessages()
{
- return ( ( BaseIoSession ) session ).getWrittenMessages();
+ return session.getWrittenMessages();
}
- /**
- * @see archean.util.mina.IoSessionManagerMBean#close()
- */
- public void close()
+ public void close() throws InterruptedException
{
session.close().join();
}
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getCreationTime()
- */
public Date getCreationTime()
{
return new Date( session.getCreationTime() );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getLastIoTime()
- */
public Date getLastIoTime()
{
return new Date( session.getLastIoTime() );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getLastReadTime()
- */
public Date getLastReadTime()
{
return new Date( session.getLastReadTime() );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getLastWriteTime()
- */
public Date getLastWriteTime()
{
return new Date( session.getLastWriteTime() );
}
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getInstalledFilters()
- */
public String[] getInstalledFilters()
{
List filters = session.getFilterChain().getAll();
@@ -150,37 +115,24 @@
return res;
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#addLastLoggingFilter()
- */
public void addLastLoggingFilter()
{
LoggingFilter f = new LoggingFilter();
session.getFilterChain().addLast( "LoggerLast", f );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#removeLastLoggingFilter()
- */
public void removeLastLoggingFilter()
{
session.getFilterChain().remove( "LoggerLast" );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#addFirstLoggingFilter()
- */
public void addFirstLoggingFilter()
{
LoggingFilter f = new LoggingFilter();
session.getFilterChain().addFirst( "LoggerFirst", f );
}
-
public void removeFirstLoggingFilter()
{
@@ -190,27 +142,16 @@
// IDLE monitoring
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getReadIdleTime()
- */
public long getReadIdleTime()
{
return session.getIdleTimeInMillis( IdleStatus.READER_IDLE );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getWriteIdleTime()
- */
public long getWriteIdleTime()
{
return session.getIdleTimeInMillis( IdleStatus.WRITER_IDLE );
}
-
- /**
- * @see archean.util.mina.IoSessionManagerMBean#getBothIdleTime()
- */
public long getBothIdleTime()
{
return session.getIdleTimeInMillis( IdleStatus.BOTH_IDLE );
Modified: directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManagerMBean.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManagerMBean.java?view=diff&rev=471569&r1=471568&r2=471569
==============================================================================
--- directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManagerMBean.java (original)
+++ directory/branches/mina/1.2/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionManagerMBean.java Sun Nov 5 15:28:13 2006
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.mina.integration.jmx;
@@ -24,7 +24,7 @@
/**
- * MBean interface for the session manager, it's used for instrumenting IoSession
+ * MBean interface for the session manager, it's used for instrumenting IoSession
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
@@ -53,14 +53,14 @@
/**
* PDU decoded from the beginning. Only revelent if a ProtocolCodecFilter is installed.
- * @return
+ * @return Number of read messages
*/
public long getReadMessages();
/**
* PDU encoded from the beginning. Only revelent if a ProtocolCodecFilter is installed.
- * @return
+ * @return Number of written messages
*/
public long getWrittenMessages();
@@ -68,7 +68,7 @@
/**
* close the session
*/
- public void close();
+ public void close() throws InterruptedException;
/**
@@ -147,32 +147,32 @@
* @return write idle time in milli-seconds
*/
public long getWriteIdleTime();
-
-
+
+
/**
* get the read bytes per second throughput
- * works only if a stat collector is inspecting this session,
+ * works only if a stat collector is inspecting this session,
* @return read bytes per seconds
*/
public float getByteReadThroughtput();
-
+
/**
* get the written bytes per second throughput
- * works only if a stat collector is inspecting this session,
+ * works only if a stat collector is inspecting this session,
* @return written bytes per seconds
*/
public float getByteWrittenThroughtput();
-
+
/**
* get the read messages per second throughput
- * works only if a stat collector is inspecting this session, and only if a ProtocolDecoderFilter is used
+ * works only if a stat collector is inspecting this session, and only if a ProtocolDecoderFilter is used
* @return read messages per seconds
*/
public float getMessageReadThroughtput();
/**
* get the written messages per second throughput
- * works only if a stat collector is inspecting this session, and only if a ProtocolDecoderFilter is used
+ * works only if a stat collector is inspecting this session, and only if a ProtocolDecoderFilter is used
* @return written messages per seconds
*/
public float getMessageWrittenThroughtput();