コード例 #1
0
ファイル: DefaultStatsLogger.java プロジェクト: ggeda/moskito
 /**
  * Creates a new DefaultStatsLogger.
  *
  * @param aTarget the stats producer to monitor.
  * @param anOutput the output logger.
  * @param anOutputIntervalInSeconds output interval in seconds.
  */
 public DefaultStatsLogger(
     IStatsProducer aTarget, ILogOutput anOutput, int anOutputIntervalInSeconds) {
   target = aTarget;
   output = anOutput;
   id = IdCodeGenerator.generateCode(10);
   outputIntervalInSeconds = anOutputIntervalInSeconds;
   UpdateTriggerServiceFactory.getUpdateTriggerService()
       .addUpdateable(this, outputIntervalInSeconds);
   output.out("Started default interval logger for " + aTarget.getProducerId() + " / " + id);
 }
コード例 #2
0
ファイル: DefaultStatsLogger.java プロジェクト: ggeda/moskito
  @Override
  public void update() {
    output.out("===============================================================================");
    output.out("=== SNAPSHOT Interval DEFAULT " + outputIntervalInSeconds + "s, Entity: " + id);
    output.out("=== Timestamp: " + Date.currentDate() + ", ServiceId: " + target.getProducerId());
    output.out("===============================================================================");
    try {
      for (IStats stat : target.getStats()) {
        output.out(stat.toStatsString());
      }
    } catch (ConcurrentModificationException e) {
      LoggerFactory.getLogger(DefaultStatsLogger.class)
          .warn(
              "Error during iteration over stats from producer "
                  + target
                  + " ("
                  + target.getClass()
                  + "), concurrent modification of stats detected.");
    }

    output.out("===============================================================================");
    output.out("== END: DEFAULT Interval " + outputIntervalInSeconds + "s update, Entity: " + id);
    output.out("===============================================================================");
  }
コード例 #3
0
 @Override
 protected String getTargetStringFromProducer(IStatsProducer<?> statsProducer) {
   return statsProducer.getCategory();
 }