All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cisco.trex.stateful.model.stats.AstfStatistics Maven / Gradle / Ivy

There is a newer version: 1.69
Show newest version
package com.cisco.trex.stateful.model.stats;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;

/** ASTF statistics */
public class AstfStatistics {

  /** Json Property */
  @JsonProperty("client")
  private Map clientCounters = new HashMap<>();

  @JsonProperty("server")
  private Map serverCounters = new HashMap<>();

  @JsonProperty("epoch")
  private int epoch;

  @JsonProperty("name")
  private String name;

  private Map matchedNameAndValuesForClient = new HashMap<>();

  private Map matchedNameAndValuesForServer = new HashMap<>();

  @JsonProperty("client")
  public Map getClientCounters() {
    return clientCounters;
  }

  @JsonProperty("client")
  public void setClientCounters(Map clientCounters) {
    this.clientCounters = clientCounters;
  }

  @JsonProperty("server")
  public Map getServerCounters() {
    return serverCounters;
  }

  @JsonProperty("server")
  public void setServerCounters(Map serverCounters) {
    this.serverCounters = serverCounters;
  }

  @JsonProperty("epoch")
  public int getEpoch() {
    return epoch;
  }

  @JsonProperty("epoch")
  public void setEpoch(int epoch) {
    this.epoch = epoch;
  }

  @JsonProperty("name")
  public String getName() {
    return name;
  }

  @JsonProperty("name")
  public void setName(String name) {
    this.name = name;
  }

  /**
   * @param metaData
   * @return this
   */
  public AstfStatistics setCounterNames(MetaData metaData) {
    for (Map.Entry counter : clientCounters.entrySet()) {
      matchedNameAndValuesForClient.put(
          getCounterName(counter.getKey(), metaData), counter.getValue());
    }

    for (Map.Entry counter : serverCounters.entrySet()) {
      matchedNameAndValuesForServer.put(
          getCounterName(counter.getKey(), metaData), counter.getValue());
    }

    return this;
  }

  private static String getCounterName(int id, MetaData metaData) {
    for (CounterMeta meta : metaData.getData()) {
      if (meta.getId() == id) {
        return meta.getName();
      }
    }

    return null;
  }

  public Map getClientStatistics() {
    return matchedNameAndValuesForClient;
  }

  public Map getServerStatistics() {
    return matchedNameAndValuesForServer;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy