提交 a83bf315 编写于 作者: Y You Yong

modify the analyzer

上级 b939f435
......@@ -6,7 +6,6 @@ import com.dianping.cat.consumer.heartbeat.HeartbeatAnalyzer;
import com.dianping.cat.consumer.ip.TopIpAnalyzer;
import com.dianping.cat.consumer.matrix.MatrixAnalyzer;
import com.dianping.cat.consumer.problem.ProblemAnalyzer;
import com.dianping.cat.consumer.remote.RemoteIdAnalyzer;
import com.dianping.cat.consumer.transaction.TransactionAnalyzer;
import com.dianping.cat.message.spi.MessageAnalyzer;
import com.site.lookup.ContainerHolder;
......@@ -34,13 +33,7 @@ public class DefaultAnalyzerFactory extends ContainerHolder implements AnalyzerF
analyzer.setAnalyzerInfo(start, duration, extraTime);
return analyzer;
} else if (name.equals("remoteId")) {
RemoteIdAnalyzer analyzer = lookup(RemoteIdAnalyzer.class);
analyzer.setAnalyzerInfo(start, duration, extraTime);
return analyzer;
}
else if (name.equals("ip")) {
} else if (name.equals("ip")) {
TopIpAnalyzer analyzer = lookup(TopIpAnalyzer.class);
analyzer.setAnalyzerInfo(start, duration, extraTime);
......
......@@ -28,7 +28,6 @@ import com.dianping.cat.consumer.problem.handler.Handler;
import com.dianping.cat.consumer.problem.handler.HeartbeatHandler;
import com.dianping.cat.consumer.problem.handler.LongSqlHandler;
import com.dianping.cat.consumer.problem.handler.LongUrlHandler;
import com.dianping.cat.consumer.remote.RemoteIdAnalyzer;
import com.dianping.cat.consumer.remote.RemoteIdChannelManager;
import com.dianping.cat.consumer.remote.RemoteIdUploader;
import com.dianping.cat.consumer.transaction.TransactionAnalyzer;
......@@ -53,7 +52,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all.add(C(MessageConsumer.class, "realtime", RealtimeConsumer.class) //
.req(AnalyzerFactory.class, LogviewUploader.class) //
.config(E("extraTime").value(property("extraTime", "180000"))//
, E("analyzers").value("problem,transaction,event,heartbeat,matrix,dump,remoteId")));
, E("analyzers").value("problem,transaction,event,heartbeat,matrix,dump")));
String errorTypes = "Error,RuntimeException,Exception";
String failureTypes = "URL,SQL,Call,Cache";
......@@ -74,13 +73,16 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all.add(C(ProblemAnalyzer.class).is(PER_LOOKUP) //
.req(Handler.class, new String[] { FAILURE.getName(), ERROR.getName(), LONG_URL.getName(), LONG_SQL.getName(), HEARTBEAT.getName() }, "m_handlers") //
.req(BucketManager.class, ReportDao.class, TaskDao.class));
.req(BucketManager.class, ReportDao.class, TaskDao.class)//
.req(MessagePathBuilder.class,RemoteIdChannelManager.class));
all.add(C(TransactionAnalyzer.class).is(PER_LOOKUP) //
.req(BucketManager.class, ReportDao.class, TaskDao.class));
.req(BucketManager.class, ReportDao.class, TaskDao.class)//
.req(MessagePathBuilder.class,RemoteIdChannelManager.class));
all.add(C(EventAnalyzer.class).is(PER_LOOKUP) //
.req(BucketManager.class, ReportDao.class, TaskDao.class));
.req(BucketManager.class, ReportDao.class, TaskDao.class)//
.req(MessagePathBuilder.class,RemoteIdChannelManager.class));
all.add(C(MatrixAnalyzer.class).is(PER_LOOKUP) //
.req(BucketManager.class, ReportDao.class, TaskDao.class));
......@@ -93,11 +95,12 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all.add(C(DumpAnalyzer.class).is(PER_LOOKUP) //
.req(ServerConfigManager.class, MessagePathBuilder.class) //
.req(DumpUploader.class, DumpChannelManager.class));
.req(DumpUploader.class, DumpChannelManager.class)//
.req(RemoteIdUploader.class));
all.add(C(RemoteIdAnalyzer.class).is(PER_LOOKUP) //
.req(ServerConfigManager.class, MessagePathBuilder.class) //
.req(RemoteIdUploader.class, RemoteIdChannelManager.class));
// all.add(C(RemoteIdAnalyzer.class).is(PER_LOOKUP) //
// .req(ServerConfigManager.class, MessagePathBuilder.class) //
// .req(RemoteIdUploader.class, RemoteIdChannelManager.class));
all.add(C(RemoteIdChannelManager.class));
......@@ -108,7 +111,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.req(ServerConfigManager.class, FileSystemManager.class)); //
all.add(C(RemoteIdUploader.class) //
.req(ServerConfigManager.class, FileSystemManager.class) //
.req( MessagePathBuilder.class));
.req(MessagePathBuilder.class));
all.add(C(LogviewUploader.class) //
.req(ServerConfigManager.class, FileSystemManager.class) //
.req(BucketManager.class, LogviewDao.class));
......
......@@ -11,6 +11,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import com.dianping.cat.configuration.NetworkInterfaceManager;
import com.dianping.cat.configuration.ServerConfigManager;
import com.dianping.cat.consumer.remote.RemoteIdUploader;
import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
......@@ -29,6 +30,9 @@ public class DumpAnalyzer extends AbstractMessageAnalyzer<Object> implements Ini
@Inject
private DumpUploader m_uploader;
@Inject
private RemoteIdUploader m_remoteUploader;
public DumpUploader getDumpUploader() {
return m_uploader;
}
......@@ -110,6 +114,7 @@ public class DumpAnalyzer extends AbstractMessageAnalyzer<Object> implements Ini
if (!m_localMode) {
m_uploader.start();
m_remoteUploader.start();
}
}
}
......@@ -19,6 +19,8 @@ import com.dianping.cat.consumer.event.model.entity.EventType;
import com.dianping.cat.consumer.event.model.entity.Range;
import com.dianping.cat.consumer.event.model.transform.DefaultSaxParser;
import com.dianping.cat.consumer.event.model.transform.DefaultXmlBuilder;
import com.dianping.cat.consumer.remote.RemoteIdChannel;
import com.dianping.cat.consumer.remote.RemoteIdChannelManager;
import com.dianping.cat.hadoop.dal.Report;
import com.dianping.cat.hadoop.dal.ReportDao;
import com.dianping.cat.hadoop.dal.Task;
......@@ -27,6 +29,7 @@ import com.dianping.cat.message.Event;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
import com.dianping.cat.storage.Bucket;
import com.dianping.cat.storage.BucketManager;
......@@ -42,6 +45,12 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
@Inject
private TaskDao m_taskDao;
@Inject
private MessagePathBuilder m_builder;
@Inject
private RemoteIdChannelManager m_manager;
private Map<String, EventReport> m_reports = new HashMap<String, EventReport>();
private long m_extraTime;
......@@ -49,12 +58,17 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
private long m_startTime;
private long m_duration;
private String m_remoteIdPath;
private Logger m_logger;
@Override
public void doCheckpoint(boolean atEnd) {
storeReports(atEnd);
if (atEnd) {
m_manager.closeAllChannels(m_startTime);
}
}
@Override
......@@ -218,9 +232,19 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
m_duration = duration;
loadReports();
String ipAddress = NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
m_remoteIdPath = m_builder.getMessageRemoteIdPath(ipAddress, new Date(m_startTime));
}
private void storeMessage(MessageTree tree) {
try {
RemoteIdChannel m_channel = m_manager.openChannel(m_remoteIdPath, m_startTime);
m_channel.write(tree);
} catch (Exception e) {
e.printStackTrace();
}
String messageId = tree.getMessageId();
String domain = tree.getDomain();
......
package com.dianping.cat.consumer.logview;
import com.dianping.cat.message.spi.MessageTree;
public class LogviewTaskCreator {
public void write(MessageTree tree){
}
}
......@@ -16,6 +16,8 @@ import com.dianping.cat.consumer.problem.model.entity.Machine;
import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
import com.dianping.cat.consumer.problem.model.transform.DefaultSaxParser;
import com.dianping.cat.consumer.problem.model.transform.DefaultXmlBuilder;
import com.dianping.cat.consumer.remote.RemoteIdChannel;
import com.dianping.cat.consumer.remote.RemoteIdChannelManager;
import com.dianping.cat.hadoop.dal.Report;
import com.dianping.cat.hadoop.dal.ReportDao;
import com.dianping.cat.hadoop.dal.Task;
......@@ -23,6 +25,7 @@ import com.dianping.cat.hadoop.dal.TaskDao;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
import com.dianping.cat.storage.Bucket;
import com.dianping.cat.storage.BucketManager;
......@@ -40,6 +43,12 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
@Inject
private List<Handler> m_handlers;
@Inject
private MessagePathBuilder m_builder;
@Inject
private RemoteIdChannelManager m_manager;
private Map<String, ProblemReport> m_reports = new HashMap<String, ProblemReport>();
......@@ -51,6 +60,8 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
private long m_duration;
private String m_remoteIdPath;
private void closeMessageBuckets() {
Date timestamp = new Date(m_startTime);
......@@ -73,6 +84,9 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
public void doCheckpoint(boolean atEnd) {
storeReports(atEnd);
closeMessageBuckets();
if (atEnd) {
m_manager.closeAllChannels(m_startTime);
}
}
@Override
......@@ -158,9 +172,19 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
m_duration = duration;
loadReports();
String ipAddress = NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
m_remoteIdPath = m_builder.getMessageRemoteIdPath(ipAddress, new Date(m_startTime));
}
private void storeMessage(MessageTree tree) {
try {
RemoteIdChannel m_channel = m_manager.openChannel(m_remoteIdPath, m_startTime);
m_channel.write(tree);
} catch (Exception e) {
e.printStackTrace();
}
String messageId = tree.getMessageId();
String domain = tree.getDomain();
......
/**
*
*/
package com.dianping.cat.consumer.remote;
import java.util.Collections;
import java.util.Date;
import java.util.Set;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import com.dianping.cat.configuration.NetworkInterfaceManager;
import com.dianping.cat.configuration.ServerConfigManager;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
import com.site.lookup.annotation.Inject;
/**
* @author sean.wang
* @since Jun 21, 2012
*/
public class RemoteIdAnalyzer extends AbstractMessageAnalyzer<Object> implements Initializable, LogEnabled {
@Inject
private ServerConfigManager m_configManager;
@Inject
private RemoteIdUploader m_uploader;
@Inject
private MessagePathBuilder m_builder;
@Inject
private RemoteIdChannelManager m_manager;
private static Logger m_logger;
private boolean m_localMode = true;
private long m_extraTime;
private long m_startTime;
private long m_duration;
@Override
public void doCheckpoint(boolean atEnd) {
if (atEnd) {
m_manager.closeAllChannels(m_startTime);
}
}
@Override
public void enableLogging(Logger logger) {
m_logger = logger;
}
@Override
public Set<String> getDomains() {
return Collections.emptySet();
}
@Override
public Object getReport(String domain) {
throw new UnsupportedOperationException("This should not be called!");
}
@Override
public void initialize() throws InitializationException {
m_localMode = m_configManager.isLocalMode();
if (!m_localMode) {
m_uploader.start();
}
}
@Override
protected boolean isTimeout() {
long currentTime = System.currentTimeMillis();
long endTime = m_startTime + m_duration + m_extraTime;
return currentTime > endTime;
}
@Override
protected void process(MessageTree tree) {
if (m_localMode || tree.getMessage() == null) {
return;
}
if (!(tree.getMessage() instanceof Transaction)) {
return;
}
try {
String ipAddress = NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
long timestamp = tree.getMessage().getTimestamp();
String path = m_builder.getMessageRemoteIdPath(ipAddress, new Date(timestamp));
RemoteIdChannel channel = m_manager.openChannel(path, m_startTime);
channel.write(tree);
} catch (Exception e) {
m_logger.error("Error when write to local file system!", e);
}
}
public void setAnalyzerInfo(long startTime, long duration, long extraTime) {
m_extraTime = extraTime;
m_startTime = startTime;
m_duration = duration;
}
}
......@@ -6,12 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import com.dianping.cat.message.Event;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.MessageTree;
import com.site.helper.Files;
......@@ -67,67 +62,14 @@ public class RemoteIdChannel {
}
}
private static class BooleanWrap {
private boolean boo;
}
public void write(MessageTree tree) throws IOException {
List<String> remoteIds = new ArrayList<String>();
Transaction t = (Transaction) tree.getMessage();
BooleanWrap booWrap = new BooleanWrap();
booWrap.boo = true; // default success
doTransactionChilds(remoteIds, t, booWrap);
StringBuilder sb = new StringBuilder((remoteIds.size() + 1) * 32);
if (booWrap.boo) {
sb.append('0');
} else {
sb.append('1');
}
sb.append('\t');
StringBuilder sb = new StringBuilder();
sb.append(tree.getMessageId());
sb.append('\t');
sb.append(tree.getParentMessageId());
sb.append('\t');
sb.append(tree.getRootMessageId());
for (String id : remoteIds) {
sb.append('\t');
sb.append(id);
}
sb.append('\n');
m_output.write(sb.toString().getBytes());
}
public static final String PIGEON_REQUEST_NAME = "PigeonRequest";
public static final String PIGEON_RESPONSE_NAME = "PigeonRespone";
public static final String PIGEON_REQUEST_TYPE = "RemoteCall";
private void doTransactionChilds(List<String> remoteIds, Transaction t, BooleanWrap booWrap) {
if (!t.hasChildren()) {
return;
}
for (Message m : t.getChildren()) {
if (m instanceof Event) {
Event e = (Event) m;
if (!e.isSuccess()) {
booWrap.boo = false;
}
if (PIGEON_REQUEST_TYPE.equals(m.getType()) && (PIGEON_REQUEST_NAME.equals(m.getName()) // is pigeon request
)) {
String requestMessageId = (String) e.getData();
remoteIds.add(requestMessageId);
}
} else if (m instanceof Transaction) {
Transaction tt = (Transaction) m;
if (!tt.isSuccess()) {
booWrap.boo = false;
}
doTransactionChilds(remoteIds, tt, booWrap);
}
synchronized (m_output) {
m_output.write(sb.toString().getBytes());
}
}
}
......@@ -19,6 +19,8 @@ import org.codehaus.plexus.logging.Logger;
import com.dianping.cat.Cat;
import com.dianping.cat.configuration.NetworkInterfaceManager;
import com.dianping.cat.consumer.remote.RemoteIdChannel;
import com.dianping.cat.consumer.remote.RemoteIdChannelManager;
import com.dianping.cat.consumer.transaction.model.entity.AllDuration;
import com.dianping.cat.consumer.transaction.model.entity.Duration;
import com.dianping.cat.consumer.transaction.model.entity.Machine;
......@@ -27,7 +29,6 @@ import com.dianping.cat.consumer.transaction.model.entity.TransactionName;
import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import com.dianping.cat.consumer.transaction.model.entity.TransactionType;
import com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser;
import com.dianping.cat.consumer.transaction.model.transform.DefaultXmlBuilder;
import com.dianping.cat.hadoop.dal.Report;
import com.dianping.cat.hadoop.dal.ReportDao;
import com.dianping.cat.hadoop.dal.Task;
......@@ -35,6 +36,7 @@ import com.dianping.cat.hadoop.dal.TaskDao;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
import com.dianping.cat.storage.Bucket;
import com.dianping.cat.storage.BucketManager;
......@@ -50,6 +52,12 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
@Inject
private TaskDao m_taskDao;
@Inject
private MessagePathBuilder m_builder;
@Inject
private RemoteIdChannelManager m_manager;
private Map<String, TransactionReport> m_reports = new HashMap<String, TransactionReport>();
private long m_extraTime;
......@@ -58,6 +66,8 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
private long m_duration;
private String m_remoteIdPath;
private Logger m_logger;
private void clearAllDuration(TransactionReport report) {
......@@ -310,9 +320,18 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
m_duration = duration;
loadReports();
String ipAddress = NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
m_remoteIdPath = m_builder.getMessageRemoteIdPath(ipAddress, new Date(m_startTime));
}
private void storeMessage(MessageTree tree) {
try {
RemoteIdChannel m_channel = m_manager.openChannel(m_remoteIdPath, m_startTime);
m_channel.write(tree);
} catch (Exception e) {
e.printStackTrace();
}
String messageId = tree.getMessageId();
String domain = tree.getDomain();
......@@ -326,7 +345,7 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
}
private void storeReports(boolean atEnd) {
DefaultXmlBuilder builder = new DefaultXmlBuilder(true);
//DefaultXmlBuilder builder = new DefaultXmlBuilder(true);
Transaction t = Cat.getProducer().newTransaction("Checkpoint", getClass().getSimpleName());
Bucket<String> reportBucket = null;
......@@ -340,7 +359,8 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
set95Line(report);
clearAllDuration(report);
String xml = builder.buildXml(report);
//String xml = builder.buildXml(report);
String xml = new TransactionReportFilter().buildXml(report);
String domain = report.getDomain();
reportBucket.storeById(domain, xml);
......@@ -353,7 +373,8 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
for (TransactionReport report : m_reports.values()) {
try {
Report r = m_reportDao.createLocal();
String xml = builder.buildXml(report);
//String xml = builder.buildXml(report);
String xml = new TransactionReportFilter().buildXml(report);
String domain = report.getDomain();
r.setName("transaction");
......@@ -393,4 +414,28 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
}
}
}
static class TransactionReportFilter extends com.dianping.cat.consumer.transaction.model.transform.DefaultXmlBuilder {
public TransactionReportFilter() {
}
@Override
public void visitType(TransactionType type) {
if ("URL".equals(type.getId())) {
List<String> names = new ArrayList<String>();
Map<String, TransactionName> transactionNames = type.getNames();
for (TransactionName transactionName : transactionNames.values()) {
if (transactionName.getTotalCount() <= 1) {
names.add(transactionName.getId());
}
}
for (String name : names) {
transactionNames.remove(name);
}
}
super.visitType(type);
}
}
}
......@@ -10,7 +10,7 @@
<implementation>com.dianping.cat.consumer.RealtimeConsumer</implementation>
<configuration>
<extraTime>180000</extraTime>
<analyzers>problem,transaction,event,heartbeat,matrix,dump,remoteId</analyzers>
<analyzers>problem,transaction,event,heartbeat,matrix,dump</analyzers>
</configuration>
<requirements>
<requirement>
......@@ -87,6 +87,12 @@
<requirement>
<role>com.dianping.cat.hadoop.dal.TaskDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.message.spi.MessagePathBuilder</role>
</requirement>
<requirement>
<role>com.dianping.cat.consumer.remote.RemoteIdChannelManager</role>
</requirement>
</requirements>
</component>
<component>
......@@ -103,6 +109,12 @@
<requirement>
<role>com.dianping.cat.hadoop.dal.TaskDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.message.spi.MessagePathBuilder</role>
</requirement>
<requirement>
<role>com.dianping.cat.consumer.remote.RemoteIdChannelManager</role>
</requirement>
</requirements>
</component>
<component>
......@@ -119,6 +131,12 @@
<requirement>
<role>com.dianping.cat.hadoop.dal.TaskDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.message.spi.MessagePathBuilder</role>
</requirement>
<requirement>
<role>com.dianping.cat.consumer.remote.RemoteIdChannelManager</role>
</requirement>
</requirements>
</component>
<component>
......@@ -183,25 +201,9 @@
<requirement>
<role>com.dianping.cat.consumer.dump.DumpChannelManager</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.consumer.remote.RemoteIdAnalyzer</role>
<implementation>com.dianping.cat.consumer.remote.RemoteIdAnalyzer</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
<requirements>
<requirement>
<role>com.dianping.cat.configuration.ServerConfigManager</role>
</requirement>
<requirement>
<role>com.dianping.cat.message.spi.MessagePathBuilder</role>
</requirement>
<requirement>
<role>com.dianping.cat.consumer.remote.RemoteIdUploader</role>
</requirement>
<requirement>
<role>com.dianping.cat.consumer.remote.RemoteIdChannelManager</role>
</requirement>
</requirements>
</component>
<component>
......
......@@ -9,6 +9,8 @@ import java.util.Map;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import com.dianping.cat.configuration.server.entity.ConsoleConfig;
import com.dianping.cat.configuration.server.entity.Domain;
......@@ -205,8 +207,11 @@ public class ServerConfigManager implements LogEnabled {
public boolean isLocalMode() {
if (m_config != null) {
System.out.println("Local Model in ServerConfigManager"+m_config.isLocalMode() );
System.out.println(m_config);
return m_config.isLocalMode();
} else {
System.out.println("Config is Null!!!");
return true;
}
}
......@@ -292,4 +297,13 @@ public class ServerConfigManager implements LogEnabled {
public void configure(ServerConfigManager manager, boolean firstTime);
}
// @Override
// public void initialize() throws InitializationException {
// try {
// initialize(new File("/data/appdatas/cat/server.xml"));
// } catch (Exception e) {
// throw new RuntimeException("Error where loading cat server.xml!",e);
// }
// }
}
......@@ -19,6 +19,7 @@ import com.dianping.cat.consumer.transaction.model.entity.AllDuration;
import com.dianping.cat.consumer.transaction.model.entity.Duration;
import com.dianping.cat.consumer.transaction.model.entity.Range;
import com.dianping.cat.consumer.transaction.model.entity.TransactionName;
import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import com.dianping.cat.consumer.transaction.model.entity.TransactionType;
import com.dianping.cat.helper.CatString;
import com.dianping.cat.report.ReportPage;
......@@ -271,6 +272,10 @@ public class Handler extends ContainerHolder implements PageHandler<Context> {
private String m_ipAddress;
private String m_currentType;
private String m_currentDomain;
public TransactionReportFilter(String type, String name, String ip) {
m_type = type;
m_name = name;
......@@ -305,9 +310,19 @@ public class Handler extends ContainerHolder implements PageHandler<Context> {
if (m_type == null) {
// skip it
} else if (m_name != null && name.getId().equals(m_name)) {
super.visitName(name);
visitTransactionName(name);
} else if ("*".equals(m_name)) {
super.visitName(name);
visitTransactionName(name);
} else {
visitTransactionName(name);
}
}
private void visitTransactionName(TransactionName name) {
if ("URL".equals(m_currentType) && !"Cat".equals(m_currentDomain)) {
if (name.getTotalCount() > 1) {
super.visitName(name);
}
} else {
super.visitName(name);
}
......@@ -323,16 +338,24 @@ public class Handler extends ContainerHolder implements PageHandler<Context> {
@Override
public void visitType(TransactionType type) {
if (m_type == null) {
m_currentType = type.getId();
super.visitType(type);
} else if (m_type != null && type.getId().equals(m_type)) {
type.setSuccessMessageUrl(null);
type.setFailMessageUrl(null);
m_currentType = type.getId();
super.visitType(type);
} else {
// skip it
}
}
@Override
public void visitTransactionReport(TransactionReport transactionReport) {
m_currentDomain = transactionReport.getDomain();
super.visitTransactionReport(transactionReport);
}
}
static class HeartBeatReportFilter extends com.dianping.cat.consumer.heartbeat.model.transform.DefaultXmlBuilder {
......
......@@ -31,6 +31,7 @@ public abstract class BaseHistoricalModelService<T> extends ModelServiceWithCalS
ServerConfigManager manager = lookup(ServerConfigManager.class);
m_localMode = manager.isLocalMode();
System.out.println(this.getClass().getName() + ">>>>>>>>>>>>>>>>Local Mode :" +m_localMode);
}
@Override
......
......@@ -4,23 +4,9 @@
<short-name>res</short-name>
<uri>http://www.unidal.org/webres</uri>
<tag>
<description><![CDATA[Resource Bean Tag to define resource bean variable as bootstrap]]></description>
<name>bean</name>
<tag-class>org.unidal.webres.taglib.basic.BeanTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[A valid id for Bean.]]></description>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[cssSlot Resource Tag]]></description>
<name>cssSlot</name>
<tag-class>org.unidal.webres.taglib.basic.CssSlotTagHandler</tag-class>
<description><![CDATA[jsSlot Resource Tag]]></description>
<name>jsSlot</name>
<tag-class>org.unidal.webres.taglib.basic.JsSlotTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
......@@ -30,7 +16,7 @@
<type>boolean</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for CssSlot.]]></description>
<description><![CDATA[The reference id for JsSlot.]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
......@@ -46,26 +32,40 @@
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[Image Resource Tag]]></description>
<name>img</name>
<tag-class>org.unidal.webres.taglib.basic.ImageTagHandler</tag-class>
<description><![CDATA[Resource Bean Tag to define resource bean variable as bootstrap]]></description>
<name>bean</name>
<tag-class>org.unidal.webres.taglib.basic.BeanTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[The value for image, could be a expression or a image path.]]></description>
<name>value</name>
<description><![CDATA[A valid id for Bean.]]></description>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[useCss Resource Tag]]></description>
<name>useCss</name>
<tag-class>org.unidal.webres.taglib.basic.UseCssTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Set the css value with EL or a css ref.]]></description>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[Identify whether the image URL is secure or not.]]></description>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for img.]]></description>
<description><![CDATA[The reference id for Css.]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
......@@ -78,45 +78,66 @@
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Target placement for this css resource to render]]></description>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[jsSlot Resource Tag]]></description>
<name>jsSlot</name>
<tag-class>org.unidal.webres.taglib.basic.JsSlotTagHandler</tag-class>
<description><![CDATA[Resource token tag for page resources]]></description>
<name>token</name>
<tag-class>org.unidal.webres.taglib.basic.TokenTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
<name>secure</name>
<description><![CDATA[Customized tag render type]]></description>
<name>renderType</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for JsSlot.]]></description>
<name>id</name>
<required>false</required>
<description><![CDATA[Token type of resource: js, css]]></description>
<name>type</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[Set tag to define a page attribute with id as name]]></description>
<name>set</name>
<tag-class>org.unidal.webres.taglib.basic.SetTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Customized tag render type]]></description>
<name>renderType</name>
<required>false</required>
<description><![CDATA[The value]]></description>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[The name.]]></description>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
<dynamic-attributes>false</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[Link Resource Tag]]></description>
<name>link</name>
<tag-class>org.unidal.webres.taglib.basic.LinkTagHandler</tag-class>
<description><![CDATA[useJs Resource Tag]]></description>
<name>useJs</name>
<tag-class>org.unidal.webres.taglib.basic.UseJsTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[The value for link, could be a expression or a link ref.]]></description>
<description><![CDATA[Set the js value with EL or a js ref.]]></description>
<name>value</name>
<required>true</required>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
......@@ -128,40 +149,47 @@
<type>boolean</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for Js.]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Customized tag render type]]></description>
<name>renderType</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Target placement for this js resource to render]]></description>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[Set tag to define a page attribute with id as name]]></description>
<name>set</name>
<tag-class>org.unidal.webres.taglib.basic.SetTagHandler</tag-class>
<description><![CDATA[Link Resource Tag]]></description>
<name>link</name>
<tag-class>org.unidal.webres.taglib.basic.LinkTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[The value]]></description>
<description><![CDATA[The value for link, could be a expression or a link ref.]]></description>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[The name.]]></description>
<name>id</name>
<required>true</required>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
<type>boolean</type>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[Resource token tag for page resources]]></description>
<name>token</name>
<tag-class>org.unidal.webres.taglib.basic.TokenTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Customized tag render type]]></description>
<name>renderType</name>
......@@ -169,36 +197,29 @@
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Token type of resource: js, css]]></description>
<name>type</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[useCss Resource Tag]]></description>
<name>useCss</name>
<tag-class>org.unidal.webres.taglib.basic.UseCssTagHandler</tag-class>
<description><![CDATA[Image Resource Tag]]></description>
<name>img</name>
<tag-class>org.unidal.webres.taglib.basic.ImageTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Set the css value with EL or a css ref.]]></description>
<description><![CDATA[The value for image, could be a expression or a image path.]]></description>
<name>value</name>
<required>false</required>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
<description><![CDATA[Identify whether the image URL is secure or not.]]></description>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for Css.]]></description>
<description><![CDATA[The reference id for img.]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
......@@ -211,28 +232,14 @@
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Target placement for this css resource to render]]></description>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description><![CDATA[useJs Resource Tag]]></description>
<name>useJs</name>
<tag-class>org.unidal.webres.taglib.basic.UseJsTagHandler</tag-class>
<description><![CDATA[cssSlot Resource Tag]]></description>
<name>cssSlot</name>
<tag-class>org.unidal.webres.taglib.basic.CssSlotTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Set the js value with EL or a js ref.]]></description>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[Identify whether the link URL is secure or not.]]></description>
<name>secure</name>
<required>false</required>
......@@ -240,7 +247,7 @@
<type>boolean</type>
</attribute>
<attribute>
<description><![CDATA[The reference id for Js.]]></description>
<description><![CDATA[The reference id for CssSlot.]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
......@@ -253,13 +260,6 @@
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Target placement for this js resource to render]]></description>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
</taglib>
......@@ -28,7 +28,6 @@ public class JobApp extends Configured implements Tool {
return lookup(role, null);
}
@SuppressWarnings("unchecked")
public static <T> T lookup(Class<T> role, String roleHint) {
try {
return (T) s_instance.m_container.lookup(role, roleHint == null ? "default" : roleHint.toString());
......
......@@ -14,12 +14,10 @@ public enum ContainerBootstrap {
m_container = ContainerLoader.getDefaultContainer();
}
@SuppressWarnings("unchecked")
public <T> T lookup(Class<T> role) throws ComponentLookupException {
return (T) m_container.lookup(role);
}
@SuppressWarnings("unchecked")
public <T> T lookup(Class<T> role, String roleHint) throws ComponentLookupException {
return (T) m_container.lookup(role, roleHint);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册