Examples of ReadableDateTime


Examples of org.joda.time.ReadableDateTime

   *
   * @param oldestCounter
   * @return fraction [0, 1]
   */
  protected float getExpiredFraction(EventCounterIf<C> oldestCounter) {
    ReadableDateTime windowStart = getWindowStart();

    //counter.getEnd() >= window.getStart()
    checkArgument(
      !oldestCounter.getEnd().isBefore(windowStart),
      "counter should have end %s >= window start %s", oldestCounter.getEnd(), windowStart
    );

    ReadableDateTime counterStart = oldestCounter.getStart();

    //counter.getstart() < window.getStart()
    checkArgument(
      counterStart.isBefore(windowStart),
      "counter should have start %s <= window start %s", counterStart, windowStart
    );

    //
    long expiredPortionMillis = windowStart.getMillis() - counterStart.getMillis();
    long lengthMillis = oldestCounter.getEnd().getMillis() - counterStart.getMillis();
    float expiredFraction = expiredPortionMillis / (float) lengthMillis;

    checkState(
      expiredFraction >= 0 && expiredFraction <= 1.0,
      "%s not in [0, 1]",
View Full Code Here

Examples of org.joda.time.ReadableDateTime

   *
   * @param oldestCounter
   * @return fraction [0, 1]
   */
  protected float getExpiredFraction(EventCounterIf<C> oldestCounter) {
    ReadableDateTime windowStart = getWindowStart();

    //counter.getEnd() >= window.getStart()
    checkArgument(
      !oldestCounter.getEnd().isBefore(windowStart),
      "counter should have end %s >= window start %s", oldestCounter.getEnd(), windowStart
    );

    ReadableDateTime counterStart = oldestCounter.getStart();

    //counter.getstart() < window.getStart()
    checkArgument(
      counterStart.isBefore(windowStart),
      String.format(
        "counter should have start %s <= window start %s", counterStart, windowStart
      )
    );

    //
    long expiredPortionMillis = windowStart.getMillis() - counterStart.getMillis();
    long lengthMillis = oldestCounter.getEnd().getMillis() - counterStart.getMillis();
    float expiredFraction = expiredPortionMillis / (float) lengthMillis;

    checkState(
      expiredFraction >= 0 && expiredFraction <= 1.0,
      String.format(
View Full Code Here

Examples of org.joda.time.ReadableDateTime

  public Duration getLength() {
    return new Duration(start, end);
  }

  public GaugeCounter merge(GaugeCounter counter) {
    ReadableDateTime mergedStart = start;
    ReadableDateTime mergedEnd = end;

    if (counter.getStart().isBefore(mergedStart)) {
      mergedStart = counter.getStart();
    }
View Full Code Here

Examples of org.joda.time.ReadableDateTime

    return new Duration(start, end);
  }

  @Override
  public EventCounter merge(EventCounter counter) {
    ReadableDateTime mergedStart = start;
    ReadableDateTime mergedEnd = end;

    if (counter.getStart().isBefore(mergedStart)) {
      mergedStart = counter.getStart();
    }
View Full Code Here

Examples of org.joda.time.ReadableDateTime

  public Duration getLength() {
    return new Duration(start, end);
  }

  public GaugeCounter merge(GaugeCounter counter) {
    ReadableDateTime mergedStart = start;
    ReadableDateTime mergedEnd = end;

    if (counter.getStart().isBefore(mergedStart)) {
      mergedStart = counter.getStart();
    }
View Full Code Here

Examples of org.joda.time.ReadableDateTime

    }
  }

  private long calcRate(EventCounterIf<GaugeCounter> counter) {
    long value = counter.getValue();
    ReadableDateTime end = counter.getEnd();
    ReadableDateTime start = counter.getStart();
    ReadableDateTime now = new DateTime();
    Duration duration = now.isBefore(end) ?
      new Duration(start, now) :    // so far
      new Duration(start, end);
    long secs = duration.getStandardSeconds();
    return secs > 0 ? value / secs : value;
  }
View Full Code Here

Examples of org.joda.time.ReadableDateTime

  /*
   * Create a new counter for the next 6 secs and add it to all the
   * composite counters.
   */
  private GaugeCounter nextCurrentCounter() {
    ReadableDateTime now = new DateTime();
    GaugeCounter gaugeCounter = gaugeCounterFactory.create(
      now, now.toDateTime().plusSeconds(6)
    );

    allTimeCounter.addEventCounter(gaugeCounter);
    hourCounter.addEventCounter(gaugeCounter);
    tenMinuteCounter.addEventCounter(gaugeCounter);
View Full Code Here

Examples of org.joda.time.ReadableDateTime

    return counter.getValue() / periodSize.getStandardSeconds();
  }

  private Duration getPeriodSize() {
    // normalize by the time since server start
    ReadableDateTime now = new DateTime();
    Duration periodSize = new Duration(start, now);

    if (periodSize.isLongerThan(windowSize)) {
      return windowSize;
    } else {
View Full Code Here

Examples of org.joda.time.ReadableDateTime

  }

  public static Duration extentOf(
    EventCounterIf counter1, EventCounterIf counter2
  ) {
    ReadableDateTime start = counter1.getStart();
    ReadableDateTime end = counter1.getEnd();

    if (counter2.getStart().isBefore(start)) {
      start = counter2.getStart();
    }
View Full Code Here

Examples of org.joda.time.ReadableDateTime

      }
    }
  }

  private MaxEventCounter addNewCurrentCounter() {
    ReadableDateTime now = new DateTime();

    MaxEventCounter maxEventCounter = new MaxEventCounter(
      now,
      now.toDateTime().plus(COUNTER_GRANULARITY)
    );

    allTimeCounter.addEventCounter(maxEventCounter);
    hourCounter.addEventCounter(maxEventCounter);
    tenMinuteCounter.addEventCounter(maxEventCounter);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.