Package com.dianping.cat.consumer.cross

Examples of com.dianping.cat.consumer.cross.CrossAnalyzer


public class CrossPerformanceTest extends ComponentTestCase {

  @Test
  public void test() throws Exception {
    CrossAnalyzer analyzer = new CrossAnalyzer();

    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setServerConfigManager(new ServerConfigManager());
    analyzer.setReportManager(new MockCrossReportManager());

    MessageTree tree = buildMessage();

    long current = System.currentTimeMillis();

    int size = 10000000;
    for (int i = 0; i < size; i++) {
      analyzer.process(tree);
    }
    System.out.println(analyzer.getReport("cat"));
    System.out.println(analyzer.getReport("server"));
    System.out.println("Cost " + (System.currentTimeMillis() - current) / 1000);
    // cost 26
  }
View Full Code Here


    return tree;
  }

  @Test
  public void testParseOtherTransaction() throws Exception {
    CrossAnalyzer analyzer = new CrossAnalyzer();

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Other", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(true, info == null);
  }
View Full Code Here

    Assert.assertEquals(true, info == null);
  }

  @Test
  public void testParsePigeonClientTransaction() throws Exception {
    CrossAnalyzer analyzer = new CrossAnalyzer();

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Call", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "Unknown");

    Message message = new DefaultEvent("PigeonCall.server", "10.1.1.1", null);
    Message messageApp = new DefaultEvent("PigeonCall.app", "myDomain", null);
    t.addChild(message);
    t.addChild(messageApp);

    info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "10.1.1.1");
    Assert.assertEquals(info.getDetailType(), "PigeonCall");
    Assert.assertEquals(info.getRemoteRole(), "Pigeon.Server");
View Full Code Here

    Assert.assertEquals(info.getApp(), "myDomain");
  }

  @Test
  public void testParsePigeonServerTransaction() throws Exception {
    CrossAnalyzer analyzer = new CrossAnalyzer();

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Service", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "192.168.7.70");

    Message message = new DefaultEvent("PigeonService.client", "192.168.7.71", null);
    Message messageApp = new DefaultEvent("PigeonService.app", "myDomain", null);
    t.addChild(message);
    t.addChild(messageApp);

    info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "192.168.7.71");
    Assert.assertEquals(info.getDetailType(), "PigeonService");
    Assert.assertEquals(info.getRemoteRole(), "Pigeon.Client");
View Full Code Here

    Assert.assertEquals(info.getApp(), "myDomain");
  }

  @Test
  public void testParsePigeonServerTransactionWithPort() throws Exception {
    CrossAnalyzer analyzer = new CrossAnalyzer();

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Service", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Message message = new DefaultEvent("PigeonService.client", "192.168.7.71:29987", null);
    Message messageApp = new DefaultEvent("PigeonService.app", "myDomain", null);
    t.addChild(message);
    t.addChild(messageApp);

    info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "192.168.7.71");
    Assert.assertEquals(info.getDetailType(), "PigeonService");
    Assert.assertEquals(info.getRemoteRole(), "Pigeon.Client");
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.cross.CrossAnalyzer

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.