View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.management;
    21
    22  import org.apache.mina.common.IoSession;
    23
    24  /**
    25   * The collected stats for a session. It's used by {@link StatCollector} to attach
    26   * throughput stats to an {@link IoSession}. You can accces a session stat using
    27   * {@link IoSession} getAttribute method :
    28   * <pre>
    29   * IoSession session = ...
    30   * IoSessionStat stat = session.getAttribute( StatCollector.KEY );
    31   * </pre>
    32   *
    33   * @author The Apache Directory Project (mina-dev@directory.apache.org)
    34   * @version $Rev: 555855 $, $Date: 2007-07-13 12:19:00 +0900 (Fri, 13 Jul 2007) $
    35   */
    36  public class IoSessionStat {
    37      long lastByteRead = -1;
    38
    39      long lastByteWrite = -1;
    40
    41      long lastMessageRead = -1;
    42
    43      long lastMessageWrite = -1;
    44
    45      float byteWrittenThroughput = 0;
    46
    47      float byteReadThroughput = 0;
    48
    49      float messageWrittenThroughput = 0;
    50
    51      float messageReadThroughput = 0;
    52
    53      //  last time the session was polled
    54      long lastPollingTime = System.currentTimeMillis();
    55
    56      /**
    57       * Bytes read per second
    58       * @return bytes per second
    59       */
    60      public float getByteReadThroughput() {
    61          return byteReadThroughput;
    62      }
    63
    64      /**
    65       * Bytes written per second
    66       * @return bytes per second
    67       */
    68      public float getByteWrittenThroughput() {
    69          return byteWrittenThroughput;
    70      }
    71
    72      /**
    73       * Messages read per second
    74       * @return messages per second
    75       */
    76      public float getMessageReadThroughput() {
    77          return messageReadThroughput;
    78      }
    79
    80      /**
    81       * Messages written per second
    82       * @return messages per second
    83       */
    84      public float getMessageWrittenThroughput() {
    85          return messageWrittenThroughput;
    86      }
    87
    88      /**
    89       * used for the StatCollector, last polling value
    90       */
    91      long getLastByteRead() {
    92          return lastByteRead;
    93      }
    94
    95      /**
    96       * used for the StatCollector, last polling value
    97       */
    98      long getLastByteWrite() {
    99          return lastByteWrite;
    100     }
    101
    102     /**
    103      * used for the StatCollector, last polling value
    104      */
    105     long getLastMessageRead() {
    106         return lastMessageRead;
    107     }
    108
    109     /**
    110      * used for the StatCollector, last polling value
    111      */
    112     long getLastMessageWrite() {
    113         return lastMessageWrite;
    114     }
    115 }