Beispiel #1
0
  @Test
  public void sendDependencyTransaction() throws Exception {
    int size = 10;
    for (int i = 0; i < size; i++) {
      Transaction t = Cat.getProducer().newTransaction("SQL", "User.select" + i % 10);
      Cat.getProducer().newEvent("SQL.Method", "Select").setStatus(Message.SUCCESS);
      Cat.getProducer()
          .newEvent("SQL.Database", "jdbc:mysql://192.168.7.43:3306/database" + i % 4)
          .setStatus(Message.SUCCESS);
      t.addData("select * from hostinfo");
      t.setStatus(Message.SUCCESS);
      t.complete();
    }

    for (int i = 0; i < size; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.64.11:2280");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }

    for (int i = 0; i < size; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonService", "Method6");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.77");
      t.addData("key and value");

      Thread.sleep(51);
      t.complete();
    }
  }
Beispiel #2
0
  private void processExceptionRule() {
    List<ThresholdRule> rules = m_manager.getAllExceptionRules();
    Transaction t = Cat.newTransaction("Alarm", "ProcessExceptionRule");

    for (ThresholdRule rule : rules) {
      try {
        String connectUrl = rule.getConnectUrl();
        ThresholdDataEntity entity = m_connector.fetchAlarmData(connectUrl);

        if (entity != null) {
          entity.setDomain(rule.getDomain());
          Cat.getProducer().logEvent("AlarmUrl", connectUrl, Event.SUCCESS, entity.toString());

          ExceptionDataEvent event = new ExceptionDataEvent(entity);

          m_dispatcher.dispatch(event);
        }
      } catch (Exception e) {
        t.setStatus(e);
        Cat.logError(e);
      }
    }
    t.setStatus(Transaction.SUCCESS);
    t.complete();
  }
  @Override
  public void encode(MessageTree tree, ChannelBuffer buf) {
    Message message = tree.getMessage();

    if (message instanceof Transaction) {
      int count = 0;
      int index = buf.writerIndex();
      BufferHelper helper = m_bufferHelper;
      Transaction t = (Transaction) message;
      Locator locator = new Locator();
      Ruler ruler = new Ruler((int) t.getDurationInMicros());

      ruler.setWidth(1400);
      ruler.setHeight(18 * calculateLines(t) + 10);
      ruler.setOffsetX(200);
      ruler.setOffsetY(10);

      buf.writeInt(0); // place-holder

      count += helper.table1(buf);
      count += helper.crlf(buf);
      count += encodeHeader(tree, buf, ruler);

      count += encodeRuler(buf, locator, ruler);
      count += encodeTransaction(tree, t, buf, locator, ruler);

      count += encodeFooter(tree, buf);
      count += helper.table2(buf);
      buf.setInt(index, count);
    }
  }
Beispiel #4
0
    @Override
    public void run() {
      boolean active = true;

      while (active) {
        Date date = TimeUtil.getCurrentDay();
        long time = date.getTime();

        if (time > m_end) {
          Transaction t = Cat.newTransaction("ReportReload", "Week");
          try {
            reload();
            t.setStatus(Transaction.SUCCESS);
          } catch (Exception e) {
            Cat.logError(e);
            t.setStatus(e);
          } finally {
            t.complete();
          }
        }
        try {
          Thread.sleep(60 * 60 * 1000);
        } catch (InterruptedException e) {
          active = false;
        }
      }
    }
Beispiel #5
0
 @Test
 public void sendLongSQLTransaction() throws Exception {
   for (int i = 0; i < 10; i++) {
     Transaction t = Cat.getProducer().newTransaction("SQL", "Method6");
     t.addData("key and value");
     Thread.sleep(102);
     t.complete();
   }
 }
Beispiel #6
0
  @Test
  public void sendMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("Test", "Test");

      t.addData("key and value");
      t.complete();
    }
    Thread.sleep(1000);
  }
Beispiel #7
0
  @Test
  public void sendPigeonServerTransaction() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonService", "Method6");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.77");
      t.addData("key and value");

      Thread.sleep(51);
      t.complete();
    }
    for (int i = 0; i < 200; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonService", "Method8");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.20");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }

    for (int i = 0; i < 300; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonService", "Method5");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.231");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }
    Thread.sleep(100);
  }
Beispiel #8
0
  @Test
  public void sendSendSqlErrorMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("SQL", "Test");

      t.addData("key and value");
      t.setStatus(new NullPointerException());
      t.complete();
    }
    Thread.sleep(1000);
  }
Beispiel #9
0
  @Test
  public void sendMetric() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("Type", "Name");

      Cat.logMetric("name", "key1", "value1", "key2", "value2");

      t.complete();
    }

    Thread.sleep(1000);
  }
Beispiel #10
0
  @Test
  public void sentHackPigenTransaction() throws Exception {
    for (int i = 0; i < 200; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.7.24:8080");
      Cat.getProducer().logEvent("RemoteCall", "Pigeon", Message.SUCCESS, "MessageID");
      t.addData("key and value");

      Thread.sleep(1);
      Cat.getManager().getThreadLocalMessageTree().setDomain("Pigeon");
      Cat.getManager().getThreadLocalMessageTree().setMessageId("Cat-c0a81a38-374214-1203");
      t.complete();
    }
  }
Beispiel #11
0
  @Test
  public void testTaggedTransaction() throws Exception {
    Transaction t = Cat.newTransaction("TaggedRoot", "Root");
    Cat.newTaggedTransaction("TaggedChild", "Child1", "Tag1");
    Cat.newTaggedTransaction("TaggedChild", "Child2", "Tag2");

    Threads.forGroup().start(new TaggedThread(500, "Tag1"));
    Threads.forGroup().start(new TaggedThread(100, "Tag2"));

    TimeUnit.MILLISECONDS.sleep(200);

    t.setStatus(Message.SUCCESS);
    t.complete();
  }
Beispiel #12
0
  @Test
  public void testForkedTransaction() throws Exception {
    Transaction t = Cat.newTransaction("ForkedRoot", "Root");
    ForkedTransaction t1 = Cat.newForkedTransaction("ForkedChild", "Child1");
    ForkedTransaction t2 = Cat.newForkedTransaction("ForkedChild", "Child2");

    Threads.forGroup().start(new TimedThread(t1, 500)); // will run away
    Threads.forGroup().start(new TimedThread(t2, 100)); // will be back in time

    TimeUnit.MILLISECONDS.sleep(200);

    t.setStatus(Message.SUCCESS);
    t.complete();
  }
Beispiel #13
0
    @Override
    public void run() {
      Transaction t = Cat.newTransaction("TaggedThread", m_tag);

      try {
        TimeUnit.MILLISECONDS.sleep(m_timeout);

        t.setStatus(Message.SUCCESS);
        Cat.getManager().bind(m_tag, "Child Tagged Thread");
      } catch (Exception e) {
        Cat.logError(e);
        t.setStatus(e);
      } finally {
        t.complete();
      }
    }
  private int processLongSql(
      Machine machine, Transaction transaction, MessageTree tree, int count) {
    long duration = transaction.getDurationInMillis();
    String domain = tree.getDomain();

    long nomarizeDuration =
        computeLongDuration(duration, domain, m_defaultLongSqlDuration, m_longSqlThresholds);
    if (nomarizeDuration > 0) {
      String type = ProblemType.LONG_SQL.getName();
      String status = transaction.getName();

      Entry entry = findOrCreateEntry(machine, type, status);
      updateEntry(tree, entry, (int) nomarizeDuration);
      count++;
    }
    return count;
  }
Beispiel #15
0
  @Override
  public void run() {
    boolean active = true;
    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      active = false;
    }
    while (active) {
      Transaction t = Cat.newTransaction("AlertDatabase", TimeHelper.getMinuteStr());
      long current = System.currentTimeMillis();

      try {
        Map<String, ProductLine> productLines =
            m_productLineConfigManager.getCompany().getProductLines();

        for (ProductLine productLine : productLines.values()) {
          try {
            if (productLine.isDatabaseMonitorDashboard()) {
              processProductLine(productLine);
            }
          } catch (Exception e) {
            Cat.logError(e);
          }
        }

        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
      } finally {
        m_currentReports.clear();
        m_lastReports.clear();
        t.complete();
      }
      long duration = System.currentTimeMillis() - current;

      try {
        if (duration < DURATION) {
          Thread.sleep(DURATION - duration);
        }
      } catch (InterruptedException e) {
        active = false;
      }
    }
  }
  private int[] getTransactionDurationSegments(Transaction t) {
    String data = t.getData().toString();

    if (data.startsWith("_m=")) {
      int pos = data.indexOf('&');
      String str;

      if (pos < 0) {
        str = data.substring(3);
      } else {
        str = data.substring(3, pos);
      }

      List<String> parts = Splitters.by(',').split(str);
      int len = parts.size();
      int[] segments = new int[len];

      for (int i = 0; i < len; i++) {
        String part = parts.get(i);

        try {
          segments[i] = Integer.parseInt(part) * 1000;
        } catch (Exception e) {
          // ignore it
        }
      }

      return segments;
    } else if (data.startsWith("_u=")) {
      int pos = data.indexOf('&');
      String str;

      if (pos < 0) {
        str = data.substring(3);
      } else {
        str = data.substring(3, pos);
      }

      List<String> parts = Splitters.by(',').split(str);
      int len = parts.size();
      int[] segments = new int[len];

      for (int i = 0; i < len; i++) {
        String part = parts.get(i);

        try {
          segments[i] = Integer.parseInt(part);
        } catch (Exception e) {
          // ignore it
        }
      }

      return segments;
    } else {
      return null;
    }
  }
  private int processTransaction(Machine machine, Transaction transaction, MessageTree tree) {
    int count = 0;
    String transactionType = transaction.getType();

    if (transactionType.startsWith("Cache.")) {
      count = processLongCache(machine, transaction, tree, count);
    } else if (transactionType.equals("SQL")) {
      count = processLongSql(machine, transaction, tree, count);
    }

    List<Message> messageList = transaction.getChildren();

    for (Message message : messageList) {
      if (message instanceof Transaction) {
        count += processTransaction(machine, (Transaction) message, tree);
      }
    }
    return count;
  }
Beispiel #18
0
  protected int encodeMessage(
      MessageTree tree, Message message, ChannelBuffer buf, int level, LineCounter counter) {
    if (message instanceof Transaction) {
      Transaction transaction = (Transaction) message;
      List<Message> children = transaction.getChildren();

      if (children.isEmpty()) {
        if (transaction.getDurationInMillis() < 0) {
          return encodeLine(tree, transaction, buf, 't', Policy.WITHOUT_STATUS, level, counter);
        } else {
          return encodeLine(tree, transaction, buf, 'A', Policy.WITH_DURATION, level, counter);
        }
      } else {
        int count = 0;

        count += encodeLine(tree, transaction, buf, 't', Policy.WITHOUT_STATUS, level, counter);

        for (Message child : children) {
          count += encodeMessage(tree, child, buf, level + 1, counter);
        }

        count += encodeLine(tree, transaction, buf, 'T', Policy.WITH_DURATION, level, counter);

        return count;
      }
    } else if (message instanceof Event) {
      String type = message.getType();

      if ("RemoteCall".equals(type)) {
        return encodeLogViewLink(tree, message, buf, level, counter);
      } else {
        return encodeLine(tree, message, buf, 'E', Policy.DEFAULT, level, counter);
      }
    } else if (message instanceof Metric) {
      return encodeLine(tree, message, buf, 'M', Policy.DEFAULT, level, counter);
    } else if (message instanceof Heartbeat) {
      return encodeLine(tree, message, buf, 'H', Policy.DEFAULT, level, counter);
    } else {
      throw new RuntimeException(
          String.format("Unsupported message type: %s.", message.getClass()));
    }
  }
Beispiel #19
0
  @Test
  public void sendException() throws Exception {
    for (int i = 0; i < 10; i++) {
      Transaction t = Cat.newTransaction("Midas", "XXName");
      try {
        t.setStatus("Fail");

        DefaultMessageTree tree = (DefaultMessageTree) Cat.getManager().getThreadLocalMessageTree();

        tree.setDomain("rs-mapi-web");
      } catch (Exception e) {
        t.setStatus(Transaction.SUCCESS);
        Cat.logError(e);
        throw e;
      } finally {
        t.complete();
      }
    }
    Thread.sleep(10000);
  }
Beispiel #20
0
  @Override
  public void run() {
    boolean active = true;
    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      active = false;
    }
    while (active) {
      Transaction t = Cat.newTransaction("AlertApp", TimeHelper.getMinuteStr());
      long current = System.currentTimeMillis();

      try {
        MonitorRules monitorRules = m_appRuleConfigManager.getMonitorRules();
        Map<String, Rule> rules = monitorRules.getRules();

        for (Entry<String, Rule> entry : rules.entrySet()) {
          try {
            processRule(entry.getValue());
          } catch (Exception e) {
            Cat.logError(e);
          }
        }
        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
        Cat.logError(e);
      } finally {
        t.complete();
      }
      long duration = System.currentTimeMillis() - current;

      try {
        if (duration < DURATION) {
          Thread.sleep(DURATION - duration);
        }
      } catch (InterruptedException e) {
        active = false;
      }
    }
  }
  protected List<Message> getVisibleChildren(Transaction parent) {
    List<Message> children = new ArrayList<Message>();

    for (Message child : parent.getChildren()) {
      if (child instanceof Transaction) {
        children.add(child);
      } else if (child instanceof Event && "RemoteCall".equals(child.getType())) {
        children.add(child);
      }
    }

    return children;
  }
Beispiel #22
0
  @Test
  public void sendTraceInfo() throws Exception {

    for (int i = 0; i < 10; i++) {
      Transaction t = Cat.newTransaction("Trace", "Test" + i);
      try {
        Cat.logTrace("Trace", "Info");
        Cat.logTrace("Trace", "Dubug", Trace.SUCCESS, "sss");
        Trace trace = Cat.newTrace("Trace", "Error");

        trace.setStatus(Trace.SUCCESS);
        trace.addData("errorTrace");
        t.setStatus("Fail");
      } catch (Exception e) {
        t.setStatus(Transaction.SUCCESS);
        Cat.logError(e);
        throw e;
      } finally {
        t.complete();
      }
    }
    Thread.sleep(10000);
  }
  private int processLongCache(
      Machine machine, Transaction transaction, MessageTree tree, int count) {
    long duration = ((Transaction) transaction).getDurationInMillis();

    if (duration > m_defaultCacheThreshold) {
      String type = ProblemType.LONG_CACHE.getName();
      String status = transaction.getName();

      Entry entry = findOrCreateEntry(machine, type, status);
      updateEntry(tree, entry, 0);
      count++;
    }
    return count;
  }
  protected int calculateLines(Transaction t) {
    int count = 1;

    for (Message child : t.getChildren()) {
      if (child instanceof Transaction) {
        count += calculateLines((Transaction) child);
      } else if (child instanceof Event) {
        if (child.getType().equals("RemoteCall")) {
          count++;
        }
      }
    }

    return count;
  }
Beispiel #25
0
  @Test
  public void sendLongCacheTransaction() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method6");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.77");
      t.addData("key and value");

      Thread.sleep(11);
      Transaction t2 = Cat.getProducer().newTransaction("Cache.local", "Method");
      Cat.getProducer().newEvent("PigeonService.client", "192.168.7.77");
      t2.addData("key and value");

      Thread.sleep(11);
      t2.complete();
      t.complete();
    }
  }
Beispiel #26
0
  @Test
  public void sendMaxMessage() throws Exception {
    long time = System.currentTimeMillis();
    int i = 10;

    while (i > 0) {
      i++;
      Transaction total = Cat.newTransaction("Cat", "Test");
      Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method" + i % 10);
      t.setStatus(Message.SUCCESS);
      Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
      t.addData("key and value");

      Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method" + i % 10);
      Cat.getProducer().newEvent("Cache.web", "Method" + i % 10 + ":missed");
      t2.addData("key and value");
      t2.setStatus(Message.SUCCESS);
      t2.complete();

      Transaction t3 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t3.addData("key and value");
      t3.setStatus(Message.SUCCESS);
      t3.complete();

      Transaction t4 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t4.addData("key and value");
      t4.setStatus(Message.SUCCESS);
      t4.complete();

      Transaction t5 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t5.addData("key and value");
      t5.setStatus(Message.SUCCESS);
      t5.complete();

      Transaction t6 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t6.addData("key and value");
      t6.setStatus(Message.SUCCESS);
      t6.complete();

      Transaction t7 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t7.addData("key and value");
      t7.setStatus(Message.SUCCESS);
      t7.complete();

      Transaction t8 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t8.addData("key and value");
      t8.setStatus(Message.SUCCESS);
      t8.complete();

      Transaction t9 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t9.addData("key and value");
      t9.setStatus(Message.SUCCESS);
      t9.complete();
      t.complete();

      total.setStatus(Transaction.SUCCESS);
      t.complete();

      if (i % 10000 == 0) {
        long duration = System.currentTimeMillis() - time;
        System.out.println(
            "[" + duration + "ms]" + "[total]" + i + "[每秒" + i / duration * 1000 + "]");
      }
    }
    Thread.sleep(10 * 1000);
  }
Beispiel #27
0
  @Test
  public void sendCacheTransactionWithMissed() throws Exception {
    for (int i = 0; i < 130; i++) {
      Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method" + i % 10);
      Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
      t.addData("key and value");

      Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method" + i % 10);
      Cat.getProducer().newEvent("Cache.web", "Method" + i % 10 + ":missed");
      t2.addData("key and value");
      Thread.sleep(2);
      t2.complete();
      t.complete();

      Transaction t3 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t3.addData("key and value");
      Thread.sleep(3);
      t3.complete();
    }

    Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method");
    t2.addData("key and value");
    Thread.sleep(2);
    t2.complete();
    Thread.sleep(1000);
  }
  protected int encodeTransactionLine(
      MessageTree tree, Transaction t, ChannelBuffer buf, Locator locator, Ruler ruler) {
    BufferHelper helper = m_bufferHelper;
    XmlBuilder b = new XmlBuilder();
    int width = 6;
    int height = 18;
    int x = 0;
    int y = locator.getLine() * height + ruler.getOffsetY();
    String tid = "t" + locator.getLine();
    long t0 = tree.getMessage().getTimestamp();
    long t1 = t.getTimestamp();
    int rx = ruler.calcX((t1 - t0) * 1000);
    int rw = ruler.calcWidth(t.getDurationInMicros() * 1000);
    int[] segments = getTransactionDurationSegments(t);

    b.branch(locator, x, y, width, height);
    x += locator.getLevel() * width;

    if (t.getStatus().equals("0")) {
      b.tag1("text", "x", x, "y", y - 5, "font-weight", "bold", "stroke-width", "0");
    } else {
      b.tag1("text", "x", x, "y", y - 5, "font-weight", "bold", "stroke-width", "0", "fill", "red");
    }

    b.add(t.getType()).newLine();
    b.tag(
        "set",
        "attributeName",
        "fill",
        "to",
        "red",
        "begin",
        tid + ".mouseover",
        "end",
        tid + ".mouseout");
    b.tag2("text");

    if (segments == null) {
      String durationInMillis =
          String.format("%.2f %s", t.getDurationInMicros() / 1000.0, t.getName());

      b.tag(
          "rect",
          "x",
          rx + 1,
          "y",
          y - 15,
          "width",
          rw,
          "height",
          height - 2,
          "fill",
          "#0066ff",
          "opacity",
          "0.5");
      b.tagWithText(
          "text",
          durationInMillis,
          "x",
          rx + 5,
          "y",
          y - 3,
          "font-size",
          "11",
          "stroke-width",
          "0");
    } else {
      int index = 0;

      for (int segment : segments) {
        int w = ruler.calcWidth(segment);
        String durationInMillis =
            String.format("%.2f %s", segment / 1000.0 / 1000.0, index == 0 ? t.getName() : "");
        String color = m_colors[index % m_colors.length];

        b.tag(
            "rect",
            "x",
            rx + 1,
            "y",
            y - 15,
            "width",
            w,
            "height",
            height - 2,
            "fill",
            color,
            "opacity",
            "0.5");
        b.tagWithText(
            "text",
            durationInMillis,
            "x",
            rx + 5,
            "y",
            y - 3,
            "font-size",
            "11",
            "stroke-width",
            "0");

        index++;
        rx += w;
      }
    }

    b.tag(
        "rect",
        "id",
        tid,
        "x",
        ruler.getOffsetX() + 1,
        "y",
        y - 15,
        "width",
        ruler.getWidth(),
        "height",
        height,
        "fill",
        "#ffffff",
        "stroke-width",
        "0",
        "opacity",
        "0.01");

    return helper.write(buf, b.getResult().toString());
  }
Beispiel #29
0
  @Test
  public void sendPigeonClientTransaction() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.64." + i + ":2280");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.64.11:2280");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }
    for (int i = 0; i < 200; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.7.24:8080");
      Cat.getProducer().logEvent("RemoteCall", "Test", Message.SUCCESS, "MessageID");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }

    for (int i = 0; i < 300; i++) {
      Transaction t = Cat.getProducer().newTransaction("PigeonCall", "Method3");
      Cat.getProducer().newEvent("PigeonCall.server", "192.168.7.39:8080");
      t.addData("key and value");

      Thread.sleep(1);
      t.complete();
    }
    Thread.sleep(100);
  }
Beispiel #30
0
  @Test
  public void sendOtherDomainSqlTransaction() throws Exception {
    for (int k = 0; k < 5; k++) {
      for (int i = 0; i < 100; i++) {
        Transaction t = Cat.getProducer().newTransaction("SQL", "User.select" + i % 10);
        Cat.getProducer().newEvent("SQL.Method", "Select").setStatus(Message.SUCCESS);
        Cat.getProducer()
            .newEvent("SQL.Database", "jdbc:mysql://192.168.7.43:3306/database" + k)
            .setStatus(Message.SUCCESS);
        t.addData("select * from hostinfo");
        t.setStatus(Message.SUCCESS);
        Cat.getManager().getThreadLocalMessageTree().setDomain("CatDemo");
        t.complete();

        Transaction t2 = Cat.getProducer().newTransaction("SQL", "User.insert" + i % 10);
        Cat.getProducer().newEvent("SQL.Method", "Update").setStatus(Message.SUCCESS);
        Cat.getProducer()
            .newEvent("SQL.Database", "jdbc:mysql://192.168.7.43:3306/database" + k)
            .setStatus(Message.SUCCESS);
        t2.addData("update * from hostinfo");
        Cat.getManager().getThreadLocalMessageTree().setDomain("CatDemo");
        t2.complete();

        Transaction t3 = Cat.getProducer().newTransaction("SQL", "User.delete" + i % 10);
        Cat.getProducer().newEvent("SQL.Method", "Delete").setStatus(Message.SUCCESS);
        Cat.getProducer()
            .newEvent("SQL.Database", "jdbc:mysql://192.168.7.43:3306/database" + k)
            .setStatus(Message.SUCCESS);
        t3.addData("delete * from hostinfo");
        t3.setStatus(Message.SUCCESS);
        Cat.getManager().getThreadLocalMessageTree().setDomain("CatDemo");
        t3.complete();
      }
    }
    Thread.sleep(1000);
  }