Beispiel #1
0
  /** Remove all registered statistics. */
  public void stop() {

    // Remove Server to Server Statistic
    statisticsManager.removeStatistic(SERVER_2_SERVER_SESSIONS_KEY);

    // Remove Active Session Statistic
    statisticsManager.removeStatistic(SESSIONS_KEY);

    // Remove Packet Traffic Statistic
    statisticsManager.removeStatistic(TRAFFIC_KEY);

    statisticsManager = null;

    // Remove the packet listener.
    InterceptorManager.getInstance().removeInterceptor(packetInterceptor);
    packetInterceptor = null;
    packetCount = null;
  }
Beispiel #2
0
  /** Tracks the total number of packets both incoming and outgoing in the server. */
  private void addPacketStatistic() {
    // Register a statistic.
    Statistic packetTrafficStatistic =
        new i18nStatistic(TRAFFIC_KEY, "monitoring", Statistic.Type.rate) {
          public double sample() {
            return packetCount.getAndSet(0);
          }

          public boolean isPartialSample() {
            return true;
          }
        };
    statisticsManager.addStatistic(TRAFFIC_KEY, packetTrafficStatistic);
  }
Beispiel #3
0
  /**
   * Tracks the number of Active Sessions with the server at any point in time. Active Sessions are
   * defined as one client connection.
   */
  private void addActiveSessionsStatistic() {
    // Register a statistic.
    Statistic activeSessionStatistic =
        new i18nStatistic(SESSIONS_KEY, "monitoring", Statistic.Type.count) {
          public double sample() {
            return SessionManager.getInstance().getUserSessionsCount(false);
          }

          public boolean isPartialSample() {
            return false;
          }
        };
    statisticsManager.addStatistic(SESSIONS_KEY, activeSessionStatistic);
  }
Beispiel #4
0
  /**
   * Tracks the number of Server To Server connections taking place in the server at anyone time.
   * This includes both incoming and outgoing connections.
   */
  private void addServerToServerStatistic() {
    // Register a statistic.
    Statistic serverToServerStatistic =
        new i18nStatistic(SERVER_2_SERVER_SESSIONS_KEY, "monitoring", Statistic.Type.count) {
          public double sample() {
            return (SessionManager.getInstance().getIncomingServers().size()
                + SessionManager.getInstance().getOutgoingServers().size());
          }

          public boolean isPartialSample() {
            return false;
          }
        };

    // Add to StatisticsManager
    statisticsManager.addStatistic(SERVER_2_SERVER_SESSIONS_KEY, serverToServerStatistic);
  }
Beispiel #5
0
  public void start() {
    // Retrieve instance of StatisticsManager
    statisticsManager = StatisticsManager.getInstance();

    // Register a packet listener so that we can track packet traffic.
    packetInterceptor =
        new PacketInterceptor() {
          public void interceptPacket(
              Packet packet, Session session, boolean incoming, boolean processed) {
            // Only track processed packets so that we don't count them twice.
            if (processed) {
              packetCount.incrementAndGet();
            }
          }
        };
    InterceptorManager.getInstance().addInterceptor(packetInterceptor);

    // Register all statistics.
    addServerToServerStatistic();
    addActiveSessionsStatistic();
    addPacketStatistic();
  }