Package com.dianping.cat.status.model.entity

Examples of com.dianping.cat.status.model.entity.StatusInfo


import com.dianping.cat.status.model.entity.StatusInfo;

public class StatusInfoCollectorTest {
  @Test
  public void test() {
    StatusInfo status = new StatusInfo();

    status.accept(new StatusInfoCollector(null, null));

    Assert.assertEquals(true, status.getDisk() != null);
    Assert.assertEquals(true, status.getMemory() != null);
    Assert.assertEquals(true, status.getMessage().getBytes() >= 0);
    Assert.assertEquals(true, status.getMessage().getOverflowed() >= 0);
    Assert.assertEquals(true, status.getMessage().getProduced() >= 0);
    Assert.assertEquals(true, status.getOs() != null);
    Assert.assertEquals(true, status.getRuntime() != null);
    Assert.assertEquals(true, status.getThread() != null);
  }
View Full Code Here


public class StatusInfoTest {
  @Test
  public void testXml() throws Exception {
    String source = Files.forIO().readFrom(getClass().getResourceAsStream("status.xml"), "utf-8");
    StatusInfo root = DefaultSaxParser.parse(source);
    String xml = new DefaultXmlBuilder().buildXml(root);
    String expected = source;

    Assert.assertEquals("XML is not well parsed!", expected.replace("\r", ""), xml.replace("\r", ""));
  }
View Full Code Here

    return m_reportManager.getHourlyReport(getStartTime(), domain, true);
  }

  private Period getHeartBeatInfo(Heartbeat heartbeat, long timestamp) {
    String xml = (String) heartbeat.getData();
    StatusInfo info = null;

    try {
      info = com.dianping.cat.status.model.transform.DefaultSaxParser.parse(xml);
    } catch (Exception e) {
      m_logger.error(xml);
      m_logger.error(e.getMessage(), e);
      return null;
    }

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(timestamp);
    int minute = cal.get(Calendar.MINUTE);
    Period period = new Period(minute);

    try {
      ThreadsInfo thread = info.getThread();

      period.setThreadCount(thread.getCount());
      period.setDaemonCount(thread.getDaemonCount());
      period.setTotalStartedCount(thread.getTotalStartedCount());
      period.setCatThreadCount(thread.getCatThreadCount());
      period.setPigeonThreadCount(thread.getPigeonThreadCount());
      period.setHttpThreadCount(thread.getHttpThreadCount());

      MessageInfo catInfo = info.getMessage();

      period.setCatMessageProduced(catInfo.getProduced());
      period.setCatMessageOverflow(catInfo.getOverflowed());
      period.setCatMessageSize(catInfo.getBytes());

      MemoryInfo memeryInfo = info.getMemory();
      List<GcInfo> gcs = info.getMemory().getGcs();

      for (GcInfo gc : gcs) {
        String name = gc.getName();

        if ("ParNew".equals(name) || "PS Scavenge".equals(name)) {
          period.setNewGcCount(gc.getCount());
        } else if ("ConcurrentMarkSweep".equals(name) || "PS MarkSweep".equals(name)) {
          period.setOldGcCount(gc.getCount());
        }
      }

      period.setHeapUsage(memeryInfo.getHeapUsage());
      period.setNoneHeapUsage(memeryInfo.getNonHeapUsage());
      period.setMemoryFree(memeryInfo.getFree());
      period.setSystemLoadAverage(info.getOs().getSystemLoadAverage());

      DiskInfo diskInfo = info.getDisk();

      if (diskInfo != null) {
        for (DiskVolumeInfo volumeInfo : diskInfo.getDiskVolumes()) {
          Disk disk = new Disk(volumeInfo.getId());

          disk.setTotal(volumeInfo.getTotal());
          disk.setFree(volumeInfo.getFree());
          disk.setUsable(volumeInfo.getUsable());
          period.addDisk(disk);
        }
      }

      for (Entry<String, Extension> entry : info.getExtensions().entrySet()) {
        String id = entry.getKey();
        Extension ext = entry.getValue();

        com.dianping.cat.consumer.heartbeat.model.entity.Extension extension = period.findOrCreateExtension(id);
        for (Entry<String, String> kv : ext.getDynamicAttributes().entrySet()) {
View Full Code Here

      long start = MilliSecondTimer.currentTimeMillis();

      if (m_manager.isCatEnabled()) {
        Transaction t = cat.newTransaction("System", "Status");
        Heartbeat h = cat.newHeartbeat("Heartbeat", m_ipAddress);
        StatusInfo status = new StatusInfo();

        t.addData("dumpLocked", m_manager.isDumpLocked());
        try {
          StatusInfoCollector statusInfoCollector = new StatusInfoCollector(m_statistics, m_jars);

          status.accept(statusInfoCollector.setDumpLocked(m_manager.isDumpLocked()));

          buildExtensionData(status);
          h.addData(status.toString());
          h.setStatus(Message.SUCCESS);
        } catch (Throwable e) {
          h.setStatus(e);
          cat.logError(e);
        } finally {
View Full Code Here

TOP

Related Classes of com.dianping.cat.status.model.entity.StatusInfo

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.