コード例 #1
0
    @Override
    public synchronized void check(IO service) {
      bytesReceived += service.getBytesReceived(true);
      bytesSent += service.getBytesSent(true);
      socketOverflow += service.getBuffOverflow(true);
      service.getPacketsReceived(true);
      service.getPacketsSent(true);

      // service.getStatistics(list, true);
      // bytesReceived += list.getValue("socketio", "Bytes received", -1l);
      // bytesSent += list.getValue("socketio", "Bytes sent", -1l);
      // socketOverflow += list.getValue("socketio", "Buffers overflow", -1l);
    }
コード例 #2
0
  /**
   * Method description
   *
   * @param serv
   * @return a value of <code>boolean</code>
   */
  public boolean checkTrafficLimits(IO serv) {
    boolean xmppLimitHit = false;

    if (last_minute_packets_limit > 0) {
      xmppLimitHit = (serv.getPacketsReceived(false) >= last_minute_packets_limit)
      //							|| (serv.getPacketsSent(false) >= last_minute_packets_limit)
      ;
    }
    if (!xmppLimitHit && (total_packets_limit > 0)) {
      xmppLimitHit = (serv.getTotalPacketsReceived() >= total_packets_limit)
      //							|| (serv.getTotalPacketsSent() >= total_packets_limit)
      ;
    }
    if (xmppLimitHit) {
      Level level = Level.FINER;

      if (isHighThroughput()) {
        level = Level.WARNING;
      }
      switch (xmppLimitAction) {
        case DROP_PACKETS:
          if (log.isLoggable(level)) {
            log.log(
                level,
                "[[{0}]] XMPP Limits exceeded on connection {1}" + " dropping pakcets: {2}",
                new Object[] {getName(), serv, serv.getReceivedPackets()});
          }
          while (serv.getReceivedPackets().poll() != null) ;

          break;

        default:
          if (log.isLoggable(level)) {
            log.log(
                level,
                "[[{0}]] XMPP Limits exceeded on connection {1}"
                    + " stopping, packets dropped: {2}",
                new Object[] {getName(), serv, serv.getReceivedPackets()});
          }
          serv.forceStop();

          break;
      }

      return false;
    }

    boolean binLimitHit = false;
    long bytesSent = serv.getBytesSent(false);
    long bytesReceived = serv.getBytesReceived(false);

    if (last_minute_bin_limit > 0) {
      binLimitHit =
          (bytesSent >= last_minute_bin_limit) || (bytesReceived >= last_minute_bin_limit);
    }

    long totalSent = serv.getTotalBytesSent();
    long totalReceived = serv.getTotalBytesReceived();

    if (!binLimitHit && (total_bin_limit > 0)) {
      binLimitHit = (totalReceived >= total_bin_limit) || (totalSent >= total_bin_limit);
    }
    if (binLimitHit) {
      if (log.isLoggable(Level.FINE)) {
        log.log(
            Level.FINE,
            "[[{0}]] Binary Limits exceeded ({1}:{2}:{3}:{4}) on"
                + " connection {5} stopping, packets dropped: {6}",
            new Object[] {
              getName(),
              bytesSent,
              bytesReceived,
              totalSent,
              totalReceived,
              serv,
              serv.getReceivedPackets()
            });
      }
      serv.forceStop();

      return false;
    }

    return true;
  }