Package com.dianping.cat.message

Examples of com.dianping.cat.message.Transaction


    event.complete();
  }

  protected Transaction newTransaction(String type, String name) {
    DefaultMessageProducer cat = (DefaultMessageProducer) Cat.getProducer();
    Transaction transaction = cat.newTransaction(m_current, type, name);

    return transaction;
  }
View Full Code Here


  }

  @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);
  }
View Full Code Here

  }

  @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();
    }
  }
View Full Code Here

  }

  @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);
  }
View Full Code Here

  }

  @Override
  public ModelResponse<T> invoke(ModelRequest request) {
    ModelResponse<T> response = new ModelResponse<T>();
    Transaction t = newTransaction("ModelService", getClass().getSimpleName());
    t.addData("thread", Thread.currentThread());

    try {
      T model = buildModel(request);

      response.setModel(model);
      t.setStatus(Message.SUCCESS);
    } catch (Exception e) {
      logError(e);
      t.setStatus(e);
      response.setException(e);
    } finally {
      t.complete();
    }

    return response;
  }
View Full Code Here

  }

  @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);
  }
View Full Code Here

  }

  @Test
  public void sendCacheTransaction() 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();
    }
  }
View Full Code Here

  }

  @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();
    }
  }
View Full Code Here

  }

  @Test
  public void sendLongURLTransaction() throws Exception {
    for (int i = 0; i < 10; i++) {
      Transaction t = Cat.getProducer().newTransaction("URL", "Method6");
      t.addData("key and value");
      Thread.sleep(60);
      t.complete();
    }
  }
View Full Code Here

  }

  @Override
  public ModelResponse<T> invoke(ModelRequest request) {
    ModelResponse<T> response = new ModelResponse<T>();
    Transaction t = newTransaction("ModelService", getClass().getSimpleName());

    try {
      URL url = buildUrl(request);

      t.addData(url.toString());

      InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(5000).openStream(url.toExternalForm());
      GZIPInputStream gzip = new GZIPInputStream(in);
      String xml = Files.forIO().readFrom(gzip, "utf-8");

      int len = xml == null ? 0 : xml.length();

      t.addData("length", len);

      if (len > 0) {
        T report = buildModel(xml);

        response.setModel(report);
        t.setStatus(Message.SUCCESS);
      } else {
        t.setStatus("NoReport");
      }
    } catch (Exception e) {
      t.setStatus(e);
    } finally {
      t.complete();
    }

    return response;
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.Transaction

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.