Author: elecharny Date: Thu Jul 17 06:27:07 2008 New Revision: 677580 URL: http://svn.apache.org/viewvc?rev=677580&view=rev Log: Applied patch for DIRMINA-608 provided by Barend
Added: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java?rev=677580&r1=677579&r2=677580&view=diff ============================================================================== --- mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java (original) +++ mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java Thu Jul 17 06:27:07 2008 @@ -61,7 +61,7 @@ * @author The Apache MINA Project ([EMAIL PROTECTED]) * @version $Rev$, $Date$ */ -public abstract class AbstractIoService implements IoService { +public abstract class AbstractIoService implements IoService, IoServiceStatistics, IoServiceIdleState { /** * The unique number identifying the Service. It's incremented * for each new IoService created. @@ -433,6 +433,20 @@ /** * [EMAIL PROTECTED] */ + public IoServiceIdleState getIdleState() { + return this; + } + + /** + * [EMAIL PROTECTED] + */ + public IoServiceStatistics getStatistics() { + return this; + } + + /** + * [EMAIL PROTECTED] + */ public final long getReadBytes() { return readBytes.get(); } Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java?rev=677580&r1=677579&r2=677580&view=diff ============================================================================== --- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java (original) +++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java Thu Jul 17 06:27:07 2008 @@ -28,7 +28,6 @@ import org.apache.mina.core.filterchain.IoFilterChain; import org.apache.mina.core.filterchain.IoFilterChainBuilder; import org.apache.mina.core.future.WriteFuture; -import org.apache.mina.core.session.IdleStatus; import org.apache.mina.core.session.IoSession; import org.apache.mina.core.session.IoSessionConfig; import org.apache.mina.core.session.IoSessionDataStructureFactory; @@ -104,19 +103,6 @@ int getManagedSessionCount(); /** - * Returns the maximum number of sessions which were being managed at the - * same time. - */ - int getLargestManagedSessionCount(); - - /** - * Returns the cumulative number of sessions which were managed (or are - * being managed) by this service, which means 'currently managed session - * count + closed session count'. - */ - long getCumulativeManagedSessionCount(); - - /** * Returns the default configuration of the new [EMAIL PROTECTED] IoSession}s * created by this service. */ @@ -169,253 +155,23 @@ long getActivationTime(); /** - * Returns the time in millis when I/O occurred lastly. - */ - long getLastIoTime(); - - /** - * Returns the time in millis when read operation occurred lastly. - */ - long getLastReadTime(); - - /** - * Returns the time in millis when write operation occurred lastly. - */ - long getLastWriteTime(); - - /** - * Returns <code>true</code> if this service is idle for the specified - * [EMAIL PROTECTED] IdleStatus}. - */ - boolean isIdle(IdleStatus status); - - /** - * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#READER_IDLE}. - * @see #isIdle(IdleStatus) - */ - boolean isReaderIdle(); - - /** - * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. - * @see #isIdle(IdleStatus) - */ - boolean isWriterIdle(); - - /** - * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. - * @see #isIdle(IdleStatus) - */ - boolean isBothIdle(); - - /** - * Returns the number of the fired continuous <tt>serviceIdle</tt> events - * for the specified [EMAIL PROTECTED] IdleStatus}. - * <p/> - * If <tt>serviceIdle</tt> event is fired first after some time after I/O, - * <tt>idleCount</tt> becomes <tt>1</tt>. <tt>idleCount</tt> resets to - * <tt>0</tt> if any I/O occurs again, otherwise it increases to - * <tt>2</tt> and so on if <tt>serviceIdle</tt> event is fired again without - * any I/O between two (or more) <tt>serviceIdle</tt> events. - */ - int getIdleCount(IdleStatus status); - - /** - * Returns the number of the fired continuous <tt>serviceIdle</tt> events - * for [EMAIL PROTECTED] IdleStatus#READER_IDLE}. - * @see #getIdleCount(IdleStatus) - */ - int getReaderIdleCount(); - - /** - * Returns the number of the fired continuous <tt>serviceIdle</tt> events - * for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. - * @see #getIdleCount(IdleStatus) - */ - int getWriterIdleCount(); - - /** - * Returns the number of the fired continuous <tt>serviceIdle</tt> events - * for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. - * @see #getIdleCount(IdleStatus) - */ - int getBothIdleCount(); - - /** - * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event - * is fired for the specified [EMAIL PROTECTED] IdleStatus}. - */ - long getLastIdleTime(IdleStatus status); - - /** - * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event - * is fired for [EMAIL PROTECTED] IdleStatus#READER_IDLE}. - * @see #getLastIdleTime(IdleStatus) - */ - long getLastReaderIdleTime(); - - /** - * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event - * is fired for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. - * @see #getLastIdleTime(IdleStatus) - */ - long getLastWriterIdleTime(); - - /** - * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event - * is fired for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. - * @see #getLastIdleTime(IdleStatus) - */ - long getLastBothIdleTime(); - - /** - * Returns idle time for the specified type of idleness in seconds. - */ - int getIdleTime(IdleStatus status); - - /** - * Returns idle time for the specified type of idleness in milliseconds. - */ - long getIdleTimeInMillis(IdleStatus status); - - /** - * Sets idle time for the specified type of idleness in seconds. - */ - void setIdleTime(IdleStatus status, int idleTime); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in seconds. - */ - int getReaderIdleTime(); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in milliseconds. - */ - long getReaderIdleTimeInMillis(); - - /** - * Sets idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in seconds. - */ - void setReaderIdleTime(int idleTime); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. - */ - int getWriterIdleTime(); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in milliseconds. - */ - long getWriterIdleTimeInMillis(); - - /** - * Sets idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. - */ - void setWriterIdleTime(int idleTime); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE} in seconds. - */ - int getBothIdleTime(); - - /** - * Returns idle time for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE} in milliseconds. - */ - long getBothIdleTimeInMillis(); - - /** - * Sets idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. - */ - void setBothIdleTime(int idleTime); - - /** - * Returns the number of bytes read by this service - * - * @return - * The number of bytes this service has read - */ - long getReadBytes(); - - /** - * Returns the number of bytes written out by this service - * - * @return - * The number of bytes this service has written - */ - long getWrittenBytes(); - - /** - * Returns the number of messages this services has read - * - * @return - * The number of messages this services has read - */ - long getReadMessages(); - - /** - * Returns the number of messages this service has written - * - * @return - * The number of messages this service has written - */ - long getWrittenMessages(); - - /** - * Returns the number of read bytes per second. - */ - double getReadBytesThroughput(); - - /** - * Returns the number of written bytes per second. - */ - double getWrittenBytesThroughput(); - - /** - * Returns the number of read messages per second. - */ - double getReadMessagesThroughput(); - - /** - * Returns the number of written messages per second. - */ - double getWrittenMessagesThroughput(); - - /** - * Returns the maximum of the [EMAIL PROTECTED] #getReadBytesThroughput() readBytesThroughput}. - */ - double getLargestReadBytesThroughput(); - - /** - * Returns the maximum of the [EMAIL PROTECTED] #getWrittenBytesThroughput() writtenBytesThroughput}. - */ - double getLargestWrittenBytesThroughput(); - - /** - * Returns the maximum of the [EMAIL PROTECTED] #getReadMessagesThroughput() readMessagesThroughput}. - */ - double getLargestReadMessagesThroughput(); - - /** - * Returns the maximum of the [EMAIL PROTECTED] #getWrittenMessagesThroughput() writtenMessagesThroughput}. - */ - double getLargestWrittenMessagesThroughput(); - - /** - * Returns the interval (seconds) between each throughput calculation. - * The default value is <tt>3</tt> seconds. + * Writes the specified [EMAIL PROTECTED] message} to all the [EMAIL PROTECTED] IoSession}s + * managed by this service. This method is a convenience shortcut for + * [EMAIL PROTECTED] IoUtil#broadcast(Object, Collection)}. */ - int getThroughputCalculationInterval(); + Set<WriteFuture> broadcast(Object message); /** - * Returns the interval (milliseconds) between each throughput calculation. - * The default value is <tt>3</tt> seconds. + * Returns the [EMAIL PROTECTED] IoSessionDataStructureFactory} that provides + * related data structures for a new session created by this service. */ - long getThroughputCalculationIntervalInMillis(); + IoSessionDataStructureFactory getSessionDataStructureFactory(); /** - * Sets the interval (seconds) between each throughput calculation. The - * default value is <tt>3</tt> seconds. + * Sets the [EMAIL PROTECTED] IoSessionDataStructureFactory} that provides + * related data structures for a new session created by this service. */ - void setThroughputCalculationInterval(int throughputCalculationInterval); + void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory); /** * Returns the number of bytes scheduled to be written @@ -434,21 +190,16 @@ int getScheduledWriteMessages(); /** - * Writes the specified [EMAIL PROTECTED] message} to all the [EMAIL PROTECTED] IoSession}s - * managed by this service. This method is a convenience shortcut for - * [EMAIL PROTECTED] IoUtil#broadcast(Object, Collection)}. + * Returns the IoServiceIdleState for this service. + * + * @return The idle state object for this service. */ - Set<WriteFuture> broadcast(Object message); + IoServiceIdleState getIdleState(); /** - * Returns the [EMAIL PROTECTED] IoSessionDataStructureFactory} that provides - * related data structures for a new session created by this service. + * Returns the IoServiceStatistics object for this service. + * + * @return The statistics object for this service. */ - IoSessionDataStructureFactory getSessionDataStructureFactory(); - - /** - * Sets the [EMAIL PROTECTED] IoSessionDataStructureFactory} that provides - * related data structures for a new session created by this service. - */ - void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory); + IoServiceStatistics getStatistics(); } Added: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java?rev=677580&view=auto ============================================================================== --- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java (added) +++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java Thu Jul 17 06:27:07 2008 @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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. + * + */ +package org.apache.mina.core.service; + +import org.apache.mina.core.session.IdleStatus; + +/** + * Gives access to the idle state information for an IoService. + * + * @author The Apache MINA Project ([EMAIL PROTECTED]) + * @since 2.0-M3 + */ +public interface IoServiceIdleState { + + /** + * Returns <code>true</code> if this service is idle for the specified + * [EMAIL PROTECTED] IdleStatus}. + */ + boolean isIdle(IdleStatus status); + + /** + * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#READER_IDLE}. + * @see #isIdle(IdleStatus) + */ + boolean isReaderIdle(); + + /** + * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. + * @see #isIdle(IdleStatus) + */ + boolean isWriterIdle(); + + /** + * Returns <code>true</code> if this service is [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. + * @see #isIdle(IdleStatus) + */ + boolean isBothIdle(); + + /** + * Returns the number of the fired continuous <tt>serviceIdle</tt> events + * for the specified [EMAIL PROTECTED] IdleStatus}. + * <p/> + * If <tt>serviceIdle</tt> event is fired first after some time after I/O, + * <tt>idleCount</tt> becomes <tt>1</tt>. <tt>idleCount</tt> resets to + * <tt>0</tt> if any I/O occurs again, otherwise it increases to + * <tt>2</tt> and so on if <tt>serviceIdle</tt> event is fired again without + * any I/O between two (or more) <tt>serviceIdle</tt> events. + */ + int getIdleCount(IdleStatus status); + + /** + * Returns the number of the fired continuous <tt>serviceIdle</tt> events + * for [EMAIL PROTECTED] IdleStatus#READER_IDLE}. + * @see #getIdleCount(IdleStatus) + */ + int getReaderIdleCount(); + + /** + * Returns the number of the fired continuous <tt>serviceIdle</tt> events + * for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. + * @see #getIdleCount(IdleStatus) + */ + int getWriterIdleCount(); + + /** + * Returns the number of the fired continuous <tt>serviceIdle</tt> events + * for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. + * @see #getIdleCount(IdleStatus) + */ + int getBothIdleCount(); + + /** + * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event + * is fired for the specified [EMAIL PROTECTED] IdleStatus}. + */ + long getLastIdleTime(IdleStatus status); + + /** + * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event + * is fired for [EMAIL PROTECTED] IdleStatus#READER_IDLE}. + * @see #getLastIdleTime(IdleStatus) + */ + long getLastReaderIdleTime(); + + /** + * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event + * is fired for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE}. + * @see #getLastIdleTime(IdleStatus) + */ + long getLastWriterIdleTime(); + + /** + * Returns the time in milliseconds when the last <tt>serviceIdle</tt> event + * is fired for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE}. + * @see #getLastIdleTime(IdleStatus) + */ + long getLastBothIdleTime(); + + /** + * Returns idle time for the specified type of idleness in seconds. + */ + int getIdleTime(IdleStatus status); + + /** + * Returns idle time for the specified type of idleness in milliseconds. + */ + long getIdleTimeInMillis(IdleStatus status); + + /** + * Sets idle time for the specified type of idleness in seconds. + */ + void setIdleTime(IdleStatus status, int idleTime); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in seconds. + */ + int getReaderIdleTime(); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in milliseconds. + */ + long getReaderIdleTimeInMillis(); + + /** + * Sets idle time for [EMAIL PROTECTED] IdleStatus#READER_IDLE} in seconds. + */ + void setReaderIdleTime(int idleTime); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. + */ + int getWriterIdleTime(); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in milliseconds. + */ + long getWriterIdleTimeInMillis(); + + /** + * Sets idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. + */ + void setWriterIdleTime(int idleTime); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE} in seconds. + */ + int getBothIdleTime(); + + /** + * Returns idle time for [EMAIL PROTECTED] IdleStatus#BOTH_IDLE} in milliseconds. + */ + long getBothIdleTimeInMillis(); + + /** + * Sets idle time for [EMAIL PROTECTED] IdleStatus#WRITER_IDLE} in seconds. + */ + void setBothIdleTime(int idleTime); +} \ No newline at end of file Added: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java?rev=677580&view=auto ============================================================================== --- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java (added) +++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java Thu Jul 17 06:27:07 2008 @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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. + * + */ +package org.apache.mina.core.service; + +/** + * Provides usage statistics for an IoService. + * + * @author The Apache MINA Project ([EMAIL PROTECTED]) + */ +public interface IoServiceStatistics { + /** + * Returns the maximum number of sessions which were being managed at the + * same time. + */ + int getLargestManagedSessionCount(); + + /** + * Returns the cumulative number of sessions which were managed (or are + * being managed) by this service, which means 'currently managed session + * count + closed session count'. + */ + long getCumulativeManagedSessionCount(); + + /** + * Returns the time in millis when I/O occurred lastly. + */ + long getLastIoTime(); + + /** + * Returns the time in millis when read operation occurred lastly. + */ + long getLastReadTime(); + + /** + * Returns the time in millis when write operation occurred lastly. + */ + long getLastWriteTime(); + + /** + * Returns the number of bytes read by this service + * + * @return + * The number of bytes this service has read + */ + long getReadBytes(); + + /** + * Returns the number of bytes written out by this service + * + * @return + * The number of bytes this service has written + */ + long getWrittenBytes(); + + /** + * Returns the number of messages this services has read + * + * @return + * The number of messages this services has read + */ + long getReadMessages(); + + /** + * Returns the number of messages this service has written + * + * @return + * The number of messages this service has written + */ + long getWrittenMessages(); + + /** + * Returns the number of read bytes per second. + */ + double getReadBytesThroughput(); + + /** + * Returns the number of written bytes per second. + */ + double getWrittenBytesThroughput(); + + /** + * Returns the number of read messages per second. + */ + double getReadMessagesThroughput(); + + /** + * Returns the number of written messages per second. + */ + double getWrittenMessagesThroughput(); + + /** + * Returns the maximum of the [EMAIL PROTECTED] #getReadBytesThroughput() readBytesThroughput}. + */ + double getLargestReadBytesThroughput(); + + /** + * Returns the maximum of the [EMAIL PROTECTED] #getWrittenBytesThroughput() writtenBytesThroughput}. + */ + double getLargestWrittenBytesThroughput(); + + /** + * Returns the maximum of the [EMAIL PROTECTED] #getReadMessagesThroughput() readMessagesThroughput}. + */ + double getLargestReadMessagesThroughput(); + + /** + * Returns the maximum of the [EMAIL PROTECTED] #getWrittenMessagesThroughput() writtenMessagesThroughput}. + */ + double getLargestWrittenMessagesThroughput(); + + /** + * Returns the interval (seconds) between each throughput calculation. + * The default value is <tt>3</tt> seconds. + */ + int getThroughputCalculationInterval(); + + /** + * Returns the interval (milliseconds) between each throughput calculation. + * The default value is <tt>3</tt> seconds. + */ + long getThroughputCalculationIntervalInMillis(); + + /** + * Sets the interval (seconds) between each throughput calculation. The + * default value is <tt>3</tt> seconds. + */ + void setThroughputCalculationInterval(int throughputCalculationInterval); +}