提交 708a2fe6 编写于 作者: Y youyong205

modify the transaction alert

上级 fa66068a
......@@ -135,14 +135,14 @@ public class Handler implements PageHandler<Context> {
.setProperty("ip", ipAddress);
TransactionReport transactionReport = null;
if (StringUtils.isEmpty(type)) {
ModelResponse<TransactionReport> response = m_transactionService.invoke(request);
transactionReport = response.getModel();
} else {
if (StringUtils.isNotEmpty(type)) {
request.setProperty("type", type);
ModelResponse<TransactionReport> response = m_transactionService.invoke(request);
transactionReport = response.getModel();
}
ModelResponse<TransactionReport> response = m_transactionService.invoke(request);
transactionReport = response.getModel();
if (Constants.ALL.equalsIgnoreCase(ipAddress)) {
MergeAllMachine all = new MergeAllMachine();
......
......@@ -20,9 +20,9 @@ public class MergeAllName extends BaseVisitor {
public String m_currentName;
public Integer m_currentRange;
public int m_currentRange;
public Integer m_currentDuration;
public int m_currentDuration;
public TransactionReportMerger m_merger = new TransactionReportMerger(new TransactionReport());
......
......@@ -89,7 +89,6 @@ public class TransactionAlert extends BaseAlert {
}
if (minute >= maxMinute - 1) {
TransactionReport report = fetchTransactionReport(domain, type, name, ModelPeriod.CURRENT);
report = m_mergeManager.mergerAllName(report, Constants.ALL, name);
if (report != null) {
int start = minute + 1 - maxMinute;
......@@ -115,10 +114,9 @@ public class TransactionAlert extends BaseAlert {
if (currentReport != null && lastReport != null) {
int currentStart = 0, currentEnd = minute;
double[] currentValue = buildArrayData(currentStart, currentEnd, type, name, monitor, currentReport);
int lastStart = 60 + 1 - (maxMinute - minute);
int lastEnd = 59;
double[] lastValue = buildArrayData(lastStart, lastEnd, type, name, monitor, currentReport);
double[] lastValue = buildArrayData(lastStart, lastEnd, type, name, monitor, lastReport);
double[] data = mergerArray(lastValue, currentValue);
results.addAll(m_dataChecker.checkData(data, conditions));
......@@ -136,7 +134,8 @@ public class TransactionAlert extends BaseAlert {
ModelResponse<TransactionReport> response = m_service.invoke(request);
TransactionReport report = response.getModel();
return report;
return m_mergeManager.mergerAllName(report, Constants.ALL, name);
}
@Override
......@@ -175,7 +174,7 @@ public class TransactionAlert extends BaseAlert {
@Override
public void run() {
boolean active = TimeHelper.sleepToNextMinute();
while (active) {
Transaction t = Cat.newTransaction("AlertTransaction", TimeHelper.getMinuteStr());
long current = System.currentTimeMillis();
......
package com.dianping.cat.report.alert;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.unidal.lookup.ComponentTestCase;
import com.dianping.cat.configuration.ServerConfigManager;
import com.dianping.cat.report.task.alert.heartbeat.HeartbeatAlert;
import com.dianping.cat.report.task.alert.transaction.TransactionAlert;
public class AlertTest extends ComponentTestCase {
@Before
public void before() throws Exception{
ServerConfigManager manager = lookup(ServerConfigManager.class);
manager.initialize(new File("/data/appdatas/cat/server.xml"));
}
@Test
public void testHeartbeat() {
HeartbeatAlert alert = lookup(HeartbeatAlert.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册