diff --git a/cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml b/cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
index ac029c5bc21664d21e622aaac03bda03016e6c47..68cf8d4e84cf0a8447972164e70e630daa1d023b 100644
--- a/cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
+++ b/cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
@@ -22,20 +22,20 @@
-
-
-
+
+
+
-
+
-
-
-
+
+
+
diff --git a/cat-core/src/main/java/com/dianping/cat/Cat.java b/cat-core/src/main/java/com/dianping/cat/Cat.java
index 137f4ce83e03f13619600d1fc21cb3eb2a30c171..9cd55796f6cffdf9470e954aef14b0cbc5a202e8 100644
--- a/cat-core/src/main/java/com/dianping/cat/Cat.java
+++ b/cat-core/src/main/java/com/dianping/cat/Cat.java
@@ -57,6 +57,7 @@ public class Cat {
public static MessageProducer getProducer() {
if (!isInitialized()) {
initializeForDev();
+ System.out.println(">>>>>>>>>>>>>>>>>>> for Dev");
}
return getInstance().m_producer;
diff --git a/cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java b/cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
index 6b844af62e84bec48f860ce082c22037eb87a390..48585cf461c976678f15f111988eac2856ed832b 100644
--- a/cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
+++ b/cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
@@ -221,10 +221,14 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
boolean shouldThrottle(MessageTree tree) {
+ if(!isCatEnabled()){
+ return true;
+ }
+
if (tree.getMessage() != null && "Heartbeat".equals(tree.getMessage().getName())) {
return false;
}
-
+
int threadCount = ManagementFactory.getThreadMXBean().getThreadCount();
return threadCount > m_domain.getMaxThreads();
diff --git a/cat-core/src/main/java/com/dianping/cat/message/io/InMemoryQueue.java b/cat-core/src/main/java/com/dianping/cat/message/io/InMemoryQueue.java
index 1ea39009e5487d3443a64a19f7853c108beb91cf..78176716ba71118260d357d608ccce1726e9a2ee 100644
--- a/cat-core/src/main/java/com/dianping/cat/message/io/InMemoryQueue.java
+++ b/cat-core/src/main/java/com/dianping/cat/message/io/InMemoryQueue.java
@@ -26,7 +26,7 @@ public class InMemoryQueue implements LogEnabled, Initializable {
@Override
public void initialize() throws InitializationException {
if (m_queueSize <= 0) {
- m_queue = new LinkedBlockingQueue();
+ m_queue = new LinkedBlockingQueue(1000);
} else {
m_queue = new LinkedBlockingQueue(m_queueSize);
}
diff --git a/cat-core/src/main/java/com/dianping/cat/message/io/InMemorySender.java b/cat-core/src/main/java/com/dianping/cat/message/io/InMemorySender.java
index 888b591d1f52231aba38c51b1f723b1a86e72d2d..a4d38e3a9d01f321c35f9803689df16d3a946ea6 100644
--- a/cat-core/src/main/java/com/dianping/cat/message/io/InMemorySender.java
+++ b/cat-core/src/main/java/com/dianping/cat/message/io/InMemorySender.java
@@ -31,6 +31,7 @@ public class InMemorySender implements MessageSender {
}
public void setQueue(InMemoryQueue queue) {
+ System.out.println("sdfsdf");
m_queue = queue;
}
diff --git a/cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java b/cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java
index 9417a4e8ca290f4bd98fe6838df15d9ca2ab72f2..c7a79997a6a1ebbaecce95a6c91990453a6bc7ed 100644
--- a/cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java
+++ b/cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java
@@ -71,7 +71,7 @@ public class Handler implements PageHandler {
String domain = payload.getDomain();
String date = String.valueOf(payload.getDate());
ModelRequest request = new ModelRequest(domain, payload.getPeriod()) //
- .setProperty("date", date);
+ .setProperty("date", date).setProperty("ip", payload.getIpAddress());
if (m_service.isEligable(request)) {
ModelResponse response = m_service.invoke(request);
diff --git a/cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java b/cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java
index 75c240792a4b0136172e90d413d987041fa40142..8291ba664a7fd26527663d3cec35a54939b8ea98 100755
--- a/cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java
+++ b/cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java
@@ -1,6 +1,7 @@
package com.dianping.cat.report.page.model;
import java.io.IOException;
+import java.util.Set;
import javax.servlet.ServletException;
@@ -8,6 +9,7 @@ import org.apache.commons.lang.StringUtils;
import com.dianping.cat.consumer.event.model.entity.EventName;
import com.dianping.cat.consumer.event.model.entity.EventType;
+import com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport;
import com.dianping.cat.consumer.problem.model.entity.JavaThread;
import com.dianping.cat.consumer.problem.model.entity.Machine;
import com.dianping.cat.consumer.transaction.model.IEntity;
@@ -27,6 +29,7 @@ import com.dianping.cat.report.page.model.spi.ModelRequest;
import com.dianping.cat.report.page.model.spi.ModelResponse;
import com.dianping.cat.report.page.model.spi.ModelService;
import com.dianping.cat.report.page.model.transaction.LocalTransactionService;
+import com.dianping.cat.report.view.StringSortHelper;
import com.site.lookup.ContainerHolder;
import com.site.lookup.annotation.Inject;
import com.site.web.mvc.PageHandler;
@@ -58,20 +61,30 @@ public class Handler extends ContainerHolder implements PageHandler {
private String doFilter(Payload payload, Object dataModel) {
String report = payload.getReport();
-
+ String ipAddress = payload.getIpAddress();
if ("transaction".equals(report)) {
- TransactionReportFilter filter = new TransactionReportFilter(payload.getType(), payload.getName(),
- payload.getIpAddress());
+ TransactionReportFilter filter = new TransactionReportFilter(payload.getType(), payload.getName(), ipAddress);
return filter.buildXml((IEntity>) dataModel);
} else if ("event".equals(report)) {
- EventReportFilter filter = new EventReportFilter(payload.getType(), payload.getName(), payload.getIpAddress());
+ EventReportFilter filter = new EventReportFilter(payload.getType(), payload.getName(), ipAddress);
return filter.buildXml((com.dianping.cat.consumer.event.model.IEntity>) dataModel);
} else if ("problem".equals(report)) {
- ProblemReportFilter filter = new ProblemReportFilter(payload.getIpAddress(), payload.getThreadId());
+ ProblemReportFilter filter = new ProblemReportFilter(ipAddress, payload.getThreadId());
return filter.buildXml((com.dianping.cat.consumer.problem.model.IEntity>) dataModel);
+ } else if ("heartbeat".equals(report)) {
+ if (StringUtils.isEmpty(ipAddress)) {
+ HeartbeatReport reportModel = (HeartbeatReport) dataModel;
+ Set ips = reportModel.getIps();
+ if (ips.size() > 0) {
+ ipAddress = StringSortHelper.sort(ips).get(0);
+ }
+ }
+ HeartBeatReportFilter filter = new HeartBeatReportFilter(ipAddress);
+
+ return filter.buildXml((com.dianping.cat.consumer.heartbeat.model.IEntity>) dataModel);
} else {
return String.valueOf(dataModel);
}
@@ -257,10 +270,10 @@ public class Handler extends ContainerHolder implements PageHandler {
}
@Override
- public void visitAllDuration(AllDuration duration){
-
+ public void visitAllDuration(AllDuration duration) {
+
}
-
+
@Override
public void visitName(TransactionName name) {
if (m_type == null) {
@@ -295,4 +308,19 @@ public class Handler extends ContainerHolder implements PageHandler {
}
}
}
+
+ static class HeartBeatReportFilter extends com.dianping.cat.consumer.heartbeat.model.transform.DefaultXmlBuilder {
+ private String m_ip;
+
+ public HeartBeatReportFilter(String ip) {
+ m_ip = ip;
+ }
+
+ @Override
+ public void visitMachine(com.dianping.cat.consumer.heartbeat.model.entity.Machine machine) {
+ if (machine.getIp().equals(m_ip)) {
+ super.visitMachine(machine);
+ }
+ }
+ }
}