提交 adce6854 编写于 作者: Y youyong205

refactor code

上级 fd405a66
......@@ -61,7 +61,7 @@ public class DefaultClientConfigManager implements LogEnabled, ClientConfigManag
@Override
public int getMaxMessageLength() {
if (m_config == null) {
return 2000;
return 5000;
} else {
return getDomain().getMaxMessageSize();
}
......
......@@ -202,7 +202,6 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
final String ID = ProblemAnalyzer.ID;
all.add(C(ProblemHandler.class, DefaultProblemHandler.ID, DefaultProblemHandler.class)//
.config(E("failureType").value("URL,SQL,Call,PigeonCall,Cache"))//
.config(E("errorType").value("Error,RuntimeException,Exception"))//
.req(ServerConfigManager.class));
......
......@@ -93,18 +93,14 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
}
public CrossInfo parseCorssTransaction(Transaction t, MessageTree tree) {
if (m_serverConfigManager.discardTransaction(t)) {
return null;
} else {
String type = t.getType();
String type = t.getType();
if (m_serverConfigManager.isRpcClient(type)) {
return parsePigeonClientTransaction(t, tree);
} else if (m_serverConfigManager.isRpcServer(type)) {
return parsePigeonServerTransaction(t, tree);
}
return null;
if (m_serverConfigManager.isRpcClient(type)) {
return parsePigeonClientTransaction(t, tree);
} else if (m_serverConfigManager.isRpcServer(type)) {
return parsePigeonServerTransaction(t, tree);
}
return null;
}
private CrossInfo parsePigeonClientTransaction(Transaction t, MessageTree tree) {
......
......@@ -61,9 +61,6 @@ public class MatrixAnalyzer extends AbstractMessageAnalyzer<MatrixReport> implem
if (message instanceof Transaction) {
String messageType = message.getType();
if (m_serverConfigManager.discardTransaction((Transaction) message)) {
return;
}
if (messageType.equals("URL") || messageType.equals("Service") || messageType.equals("PigeonService")) {
Matrix matrix = report.findOrCreateMatrix(message.getName());
matrix.setType(message.getType());
......
......@@ -25,9 +25,6 @@ public class DefaultProblemHandler extends ProblemHandler {
@Inject
private Set<String> m_errorTypes;
@Inject
private Set<String> m_failureTypes;
@Override
public void handle(Machine machine, MessageTree tree) {
Message message = tree.getMessage();
......@@ -68,16 +65,8 @@ public class DefaultProblemHandler extends ProblemHandler {
if (!transactionStatus.equals(Transaction.SUCCESS)) {
String type = transaction.getType();
String name = transaction.getName();
String status = "";
if (m_failureTypes.contains(type)) {
status = name;
} else {
status = type + ":" + name;
type = ProblemType.FAILURE.getName();
}
Entity entity = findOrCreateEntity(machine, type, status);
Entity entity = findOrCreateEntity(machine, type, name);
updateEntity(tree, entity, 0);
}
......@@ -98,7 +87,4 @@ public class DefaultProblemHandler extends ProblemHandler {
m_errorTypes = new HashSet<String>(Splitters.by(',').noEmptyItem().split(type));
}
public void setFailureType(String type) {
m_failureTypes = new HashSet<String>(Splitters.by(',').noEmptyItem().split(type));
}
}
\ No newline at end of file
......@@ -173,7 +173,7 @@ public class LongExecutionProblemHandler extends ProblemHandler implements Initi
processLongSql(machine, transaction, tree);
} else if (m_configManager.isRpcClient(type)) {
processLongCall(machine, transaction, tree);
} else if ("Service".equals(type) || "PigeonService".equals(type)) {
} else if (m_configManager.isRpcServer(type)) {
processLongService(machine, transaction, tree);
} else if ("URL".equals(type)) {
processLongUrl(machine, transaction, tree);
......
......@@ -141,17 +141,14 @@ public class StorageAnalyzer extends AbstractMessageAnalyzer<StorageReport> impl
}
private void processTransaction(MessageTree tree, Transaction t) {
if (m_serverConfigManager.discardTransaction(t)) {
return;
} else {
String type = t.getType();
String type = t.getType();
if (m_serverConfigManager.isSQLTransaction(type)) {
processSQLTransaction(tree, t);
} else if (m_serverConfigManager.isCacheTransaction(type)) {
processCacheTransaction(tree, t);
}
if (m_serverConfigManager.isSQLTransaction(type)) {
processSQLTransaction(tree, t);
} else if (m_serverConfigManager.isCacheTransaction(type)) {
processCacheTransaction(tree, t);
}
List<Message> children = t.getChildren();
for (Message child : children) {
......
......@@ -126,7 +126,6 @@
<role-hint>default-problem</role-hint>
<implementation>com.dianping.cat.consumer.problem.DefaultProblemHandler</implementation>
<configuration>
<failureType>URL,SQL,Call,PigeonCall,Cache</failureType>
<errorType>Error,RuntimeException,Exception</errorType>
</configuration>
<requirements>
......
......@@ -29,7 +29,6 @@ import com.dianping.cat.configuration.server.entity.Property;
import com.dianping.cat.configuration.server.entity.ServerConfig;
import com.dianping.cat.configuration.server.entity.StorageConfig;
import com.dianping.cat.configuration.server.transform.DefaultSaxParser;
import com.dianping.cat.message.Transaction;
public class ServerConfigManager implements Initializable, LogEnabled {
private static final long DEFAULT_HDFS_FILE_MAX_SIZE = 128 * 1024 * 1024L; // 128M
......@@ -48,16 +47,6 @@ public class ServerConfigManager implements Initializable, LogEnabled {
public static final String DUMP_DIR = "dump";
public boolean discardTransaction(Transaction t) {
String type = t.getType();
String name = t.getName();
if (m_unusedTypes.contains(type) && m_unusedNames.contains(name)) {
return true;
}
return false;
}
public boolean discardTransaction(String type,String name){
if (m_unusedTypes.contains(type) && m_unusedNames.contains(name)) {
return true;
......
......@@ -8,8 +8,6 @@ import org.junit.Test;
import org.unidal.lookup.ComponentTestCase;
import com.dianping.cat.configuration.ServerConfigManager;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.internal.DefaultTransaction;
public class ServerConfigManagerTest extends ComponentTestCase {
......@@ -40,8 +38,7 @@ public class ServerConfigManagerTest extends ComponentTestCase {
Assert.assertEquals(true, manager.isRpcServer("PigeonService"));
Assert.assertEquals(false, manager.validateDomain("All"));
Transaction t = new DefaultTransaction("Service", "piegonService:heartTaskService:heartBeat", null);
Assert.assertEquals(true, manager.discardTransaction(t));
Assert.assertEquals(true, manager.discardTransaction("Service", "piegonService:heartTaskService:heartBeat"));
manager.initialize(null);
......
......@@ -20,7 +20,7 @@ public class Payload extends AbstractReportPayload<Action> {
private String m_sort;
@FieldMeta("show")
private boolean m_show = false;
private boolean m_show = true;
public Payload() {
super(ReportPage.STATE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册