提交 246ae2ef 编写于 作者: Y youyong

Merge branch 'master' of ssh://192.168.8.22:58422/cat

......@@ -36,6 +36,10 @@ public class ClientConfigManager implements LogEnabled {
}
}
public ClientConfig getClientConfig() {
return m_config;
}
public Domain getFirstDomain() {
if (m_config == null) {
return new Domain("UNKNOWN").setEnabled(false);
......@@ -54,10 +58,6 @@ public class ClientConfigManager implements LogEnabled {
return m_config.getServers();
}
}
public ClientConfig getClientConfig(){
return m_config;
}
public void initialize(File configFile) throws Exception {
ClientConfig globalConfig = null;
......@@ -117,8 +117,15 @@ public class ClientConfigManager implements LogEnabled {
}
}
public boolean isDumpLocked() {
if (m_config == null) {
return false;
} else {
return m_config.isDumpLocked();
}
}
public boolean isInitialized() {
return m_config != null;
}
}
......@@ -29,6 +29,8 @@ import com.dianping.cat.status.model.transform.BaseVisitor;
class StatusInfoCollector extends BaseVisitor {
private MessageStatistics m_statistics;
private boolean m_dumpLocked;
public StatusInfoCollector(MessageStatistics statistics) {
m_statistics = statistics;
}
......@@ -96,6 +98,11 @@ class StatusInfoCollector extends BaseVisitor {
return isInstanceOfInterface(clazz.getSuperclass(), interfaceName);
}
public StatusInfoCollector setDumpLocked(boolean dumpLocked) {
m_dumpLocked = dumpLocked;
return this;
}
@Override
public void visitDisk(DiskInfo disk) {
Transaction t =Cat.newTransaction("Disk", "Disk");
......@@ -221,15 +228,23 @@ class StatusInfoCollector extends BaseVisitor {
@Override
public void visitThread(ThreadsInfo thread) {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo[] threads = bean.dumpAllThreads(true, true);
bean.setThreadContentionMonitoringEnabled(true);
ThreadInfo[] threads;
if (m_dumpLocked) {
threads = bean.dumpAllThreads(true, true);
} else {
threads = bean.dumpAllThreads(false, false);
}
thread.setCount(bean.getThreadCount());
thread.setDaemonCount(bean.getDaemonThreadCount());
thread.setPeekCount(bean.getPeakThreadCount());
thread.setTotalStartedCount((int) bean.getTotalStartedThreadCount());
thread.setCatThreadCount(countThreadsByPrefix(threads, "Cat-"));
thread.setPigeonThreadCount(countThreadsByPrefix(threads, "Pigeon-", "DPSF-", "Netty-",
"Client-ResponseProcessor"));
thread.setPigeonThreadCount(countThreadsByPrefix(threads, "Pigeon-", "DPSF-", "Netty-", "Client-ResponseProcessor"));
int jbossThreadsCount = countThreadsByPrefix(threads, "http-");
int jettyThreadsCount = countThreadsBySubstring(threads, "@qtp");
......
......@@ -21,7 +21,7 @@ import com.site.lookup.annotation.Inject;
public class StatusUpdateTask implements Task, Initializable {
@Inject
private MessageStatistics m_statistics;
@Inject
private ClientConfigManager m_manager;
......@@ -69,23 +69,26 @@ public class StatusUpdateTask implements Task, Initializable {
while (m_active) {
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();
try {
status.accept(new StatusInfoCollector(m_statistics));
h.addData(status.toString());
h.setStatus(Message.SUCCESS);
} catch (Throwable e) {
h.setStatus(e);
cat.logError(e);
} finally {
h.complete();
}
t.setStatus(Message.SUCCESS);
t.complete();
}
Transaction t = cat.newTransaction("System", "Status");
Heartbeat h = cat.newHeartbeat("Heartbeat", m_ipAddress);
StatusInfo status = new StatusInfo();
t.addData("dumpLocked", m_manager.isDumpLocked());
try {
status.accept(new StatusInfoCollector(m_statistics).setDumpLocked(m_manager.isDumpLocked()));
h.addData(status.toString());
h.setStatus(Message.SUCCESS);
} catch (Throwable e) {
h.setStatus(e);
cat.logError(e);
} finally {
h.complete();
}
t.setStatus(Message.SUCCESS);
t.complete();
}
long elapsed = MilliSecondTimer.currentTimeMillis() - start;
if (elapsed < m_interval) {
......
......@@ -3,6 +3,7 @@
<entity name="config" root="true">
<attribute name="mode" value-type="String" />
<attribute name="enabled" value-type="boolean" />
<attribute name="dump-locked" value-type="boolean" />
<entity-ref name="server" type="list" names="servers" xml-indent="true" />
<entity-ref name="domain" type="list" names="domains" />
<entity-ref name="bind" />
......
......@@ -23,6 +23,7 @@
</xs:sequence>
<xs:attribute name="mode" type="xs:string" use="required"/>
<xs:attribute name="enabled" type="xs:boolean" default="true"/>
<xs:attribute name="dump-locked" type="xs:boolean"/>
<xs:anyAttribute processContents="lax"/>
</xs:complexType>
<xs:complexType name="ServerType">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册