Package com.dianping.cat.analysis

Examples of com.dianping.cat.analysis.PeriodStrategy


 
  public static long EXTRATIME = 3 * 60 * 1000L;

  public PeriodManager(long duration,  MessageAnalyzerManager analyzerManager,
        ServerStatisticManager serverStateManager, Logger logger) {
    m_strategy = new PeriodStrategy(duration, EXTRATIME, EXTRATIME);
    m_active = true;
    m_latch = new CountDownLatch(1);
    m_analyzerManager = analyzerManager;
    m_serverStateManager = serverStateManager;
    m_logger = logger;
View Full Code Here


import com.dianping.cat.analysis.PeriodStrategy;

public class PeriodStrategyTest {
  @Test
  public void test1() {
    PeriodStrategy strategy = new PeriodStrategy(60, 5, 3);

    Assert.assertEquals(60, strategy.getDuration());
    Assert.assertEquals(0, strategy.next(4));
    Assert.assertEquals(0, strategy.next(5));
    Assert.assertEquals(0, strategy.next(6));
    Assert.assertEquals(0, strategy.next(56));
    Assert.assertEquals(60, strategy.next(57));
    Assert.assertEquals(0, strategy.next(58));
    Assert.assertEquals(0, strategy.next(64));
    Assert.assertEquals(-0, strategy.next(65));
    Assert.assertEquals(120, strategy.next(117));
    Assert.assertEquals(-60, strategy.next(125));
    Assert.assertEquals(180, strategy.next(177));
    Assert.assertEquals(-120, strategy.next(185));
    Assert.assertEquals(0, strategy.next(236));
    Assert.assertEquals(240, strategy.next(237));
    Assert.assertEquals(-180, strategy.next(245));
    Assert.assertEquals(360, strategy.next(400));
    Assert.assertEquals(-240, strategy.next(401));
    Assert.assertEquals(420, strategy.next(417));
    Assert.assertEquals(-360, strategy.next(425));
    Assert.assertEquals(1380, strategy.next(1400));
    Assert.assertEquals(-420, strategy.next(1401));
  }
View Full Code Here

    Assert.assertEquals(-420, strategy.next(1401));
  }

  @Test
  public void test2() {
    PeriodStrategy strategy = new PeriodStrategy(60, 5, 3);

    Assert.assertEquals(60, strategy.next(104));
    Assert.assertEquals(0, strategy.next(105));
    Assert.assertEquals(120, strategy.next(117));
    Assert.assertEquals(-60, strategy.next(125));
    Assert.assertEquals(180, strategy.next(177));
    Assert.assertEquals(-120, strategy.next(185));
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.analysis.PeriodStrategy

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.