Package com.yammer.metrics.stats

Examples of com.yammer.metrics.stats.ExponentiallyDecayingSample


    this.min = new AtomicLong();
    this.max = new AtomicLong();
    this.sum = new AtomicLong();
    this.sample = forwardBiased ?
        new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA)
    : new UniformSample(DEFAULT_SAMPLE_SIZE);

    this.variance =  new AtomicReference<double[]>(new double[]{-1, 0});
    this.count = new AtomicLong();
View Full Code Here


    public void receiveTiming(InetAddress host, long latency) // this is cheap
    {
        lastReceived.put(host, System.currentTimeMillis());

        ExponentiallyDecayingSample sample = samples.get(host);
        if (sample == null)
        {
            ExponentiallyDecayingSample maybeNewSample = new ExponentiallyDecayingSample(WINDOW_SIZE, ALPHA);
            sample = samples.putIfAbsent(host, maybeNewSample);
            if (sample == null)
                sample = maybeNewSample;
        }
        sample.update(latency);
View Full Code Here

    public List<Double> dumpTimings(String hostname) throws UnknownHostException
    {
        InetAddress host = InetAddress.getByName(hostname);
        ArrayList<Double> timings = new ArrayList<Double>();
        ExponentiallyDecayingSample sample = samples.get(host);
        if (sample != null)
        {
            for (double time: sample.getSnapshot().getValues())
                timings.add(time);
        }
        return timings;
    }
View Full Code Here

            return 1;
    }

    public void receiveTiming(InetAddress host, long latency) // this is cheap
    {
        ExponentiallyDecayingSample sample = samples.get(host);
        if (sample == null)
        {
            ExponentiallyDecayingSample maybeNewSample = new ExponentiallyDecayingSample(WINDOW_SIZE, ALPHA);
            sample = samples.putIfAbsent(host, maybeNewSample);
            if (sample == null)
                sample = maybeNewSample;
        }
        sample.update(latency);
View Full Code Here

    public List<Double> dumpTimings(String hostname) throws UnknownHostException
    {
        InetAddress host = InetAddress.getByName(hostname);
        ArrayList<Double> timings = new ArrayList<Double>();
        ExponentiallyDecayingSample sample = samples.get(host);
        if (sample != null)
        {
            for (double time: sample.getSnapshot().getValues())
                timings.add(time);
        }
        return timings;
    }
View Full Code Here

  private final AtomicLong count;


  public MetricMutableHistogram(String name, String description) {
    super(name, description);
    sample = new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA);
    count = new AtomicLong();
    min = new AtomicLong(Long.MAX_VALUE);
    max = new AtomicLong(Long.MIN_VALUE);
    sum = new AtomicLong();
  }
View Full Code Here

@Category(SmallTests.class)
public class TestExponentiallyDecayingSample {
 
  @Test
  public void testBasic() {
      final ExponentiallyDecayingSample sample =
          new ExponentiallyDecayingSample(100, 0.99);
     
      for (int i = 0; i < 1000; i++) {
          sample.update(i);
      }
      Assert.assertEquals(100, sample.size());
     
      final Snapshot snapshot = sample.getSnapshot();
      Assert.assertEquals(100, snapshot.size());

      for (double i : snapshot.getValues()) {
        Assert.assertTrue(i >= 0.0 && i < 1000.0);
      }
View Full Code Here

      }
  }

  @Test
  public void testTooBig() throws Exception {
      final ExponentiallyDecayingSample sample =
          new ExponentiallyDecayingSample(100, 0.99);
      for (int i = 0; i < 10; i++) {
          sample.update(i);
      }
      Assert.assertEquals(10, sample.size());

      final Snapshot snapshot = sample.getSnapshot();
      Assert.assertEquals(10, sample.size());

      for (double i : snapshot.getValues()) {
        Assert.assertTrue(i >= 0.0 && i < 1000.0);
      }
  }
View Full Code Here

  }

  public MutableHistogram(String name, String description) {
    this.name = StringUtils.capitalize(name);
    this.desc = StringUtils.uncapitalize(description);
    sample = new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA);
    count = new AtomicLong();
    min = new AtomicLong(Long.MAX_VALUE);
    max = new AtomicLong(Long.MIN_VALUE);
    sum = new AtomicLong();
  }
View Full Code Here

            return 1;
    }

    public void receiveTiming(InetAddress host, long latency) // this is cheap
    {
        ExponentiallyDecayingSample sample = samples.get(host);
        if (sample == null)
        {
            ExponentiallyDecayingSample maybeNewSample = new ExponentiallyDecayingSample(WINDOW_SIZE, ALPHA);
            sample = samples.putIfAbsent(host, maybeNewSample);
            if (sample == null)
                sample = maybeNewSample;
        }
        sample.update(latency);
View Full Code Here

TOP

Related Classes of com.yammer.metrics.stats.ExponentiallyDecayingSample

Copyright © 2018 www.massapicom. 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.