提交 8dde8424 编写于 作者: Y youyong

modify the url encode add the test case

上级 7eb9ca02
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dianping.bee</groupId>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-consumer</artifactId>
......
......@@ -68,7 +68,8 @@ public class TransactionReportUrlFilter extends com.dianping.cat.consumer.transa
int length = temp.length();
for (int i = 0; i < length; i++) {
if (temp.charAt(i) > 255 || temp.charAt(i) < 0) {
//invalidate char
if (temp.charAt(i) > 126 || temp.charAt(i) < 33) {
invalidates.add(temp);
continue;
}
......
......@@ -38,7 +38,7 @@ public class TransactionReportFilterTest {
Assert.assertEquals(201, newSize);
String url = "/topic/341739Š¬g&quot;";
String url = "/topic/341739Š¬g&quot;";
size = url.length();
for (int i = 0; i < size; i++) {
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-core</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-data</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-hadoop</artifactId>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-home</artifactId>
......
......@@ -191,6 +191,9 @@ public class Handler implements PageHandler<Context> {
TransactionReport transactionReport = getTransactionHourlyReport(domain, ip, null);
if(transactionReport==null){
return data;
}
Machine transactionMachine = transactionReport.getMachines().get(ip);
if (transactionMachine != null) {
Collection<TransactionType> types = transactionMachine.getTypes().values();
......
.matrix {
width: auto;
width: 100%;
font-size: small;
}
......@@ -18,10 +18,6 @@
text-align:left;
}
.matrix tr .left{
text-align:left;
}
.matrix tr .left{
text-align:left;
}
\ No newline at end of file
......@@ -50,7 +50,7 @@
varStatus="status">
<tr class="${status.index mod 2 != 0 ? 'odd' : 'even'}">
<td class="left">${item.type}</td>
<td class="left longText" >${w:shorten(item.name, 120)}</td>
<td class="left longText" style="white-space:normal" >${w:shorten(item.name, 120)}</td>
<td>${item.count}</td>
<td>${w:format(item.avg,'0.0')}</td>
<td><a href="${model.logViewBaseUri}/${item.url}?domain=${model.domain}">Log View</a></td>
......
......@@ -50,7 +50,7 @@
varStatus="status">
<tr class="${status.index mod 2 != 0 ? 'odd' : 'even'}">
<td class="left">${item.type}</td>
<td class="left longText">${w:shorten(item.name, 120)}</td>
<td class="left longText" style="white-space:normal">${w:shorten(item.name, 120)}</td>
<td>${item.count}</td>
<td>${w:format(item.avg,'0.0')}</td>
<td><a href="${model.logViewBaseUri}/${item.url}?domain=${model.domain}">Log View</a></td>
......
package com.dianping.cat.report.analyzer;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.unidal.lookup.ComponentTestCase;
import org.unidal.lookup.annotation.Inject;
import com.dainping.cat.consumer.dal.report.Report;
import com.dainping.cat.consumer.dal.report.ReportDao;
import com.dainping.cat.consumer.dal.report.ReportEntity;
import com.dianping.cat.Cat;
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.helper.TimeUtil;
import com.dianping.cat.home.dal.report.DailyreportDao;
import com.site.helper.Files;
public class UrlTransactionBugTest extends ComponentTestCase {
@Inject
private DailyreportDao m_dailyreportDao;
@Inject
private ReportDao m_reportDao;
@Before
public void setUp() throws Exception {
super.setUp();
m_dailyreportDao = lookup(DailyreportDao.class);
m_reportDao = lookup(ReportDao.class);
}
public void test() throws Exception {
// fix the transaction xml parse builder
String dateStr = "2012-12-16 07:00:00";
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
List<Report> reports = m_reportDao.findAllByDomainNameDuration(date,
new Date(date.getTime() + TimeUtil.ONE_HOUR), "ShopWeb", "transaction", ReportEntity.READSET_FULL);
File file = new File("text.txt");
for (Report report : reports) {
try {
DefaultSaxParser.parse(report.getContent());
} catch (Exception e) {
System.out.println(e);
Files.forIO().writeTo(file, report.getContent());
}
}
}
public void insert() throws Exception {
String xml = Files.forIO().readFrom(new File("text.xml"), "utf-8");
System.out.println(xml.length());
try {
Report r = m_reportDao.createLocal();
// String xml = new TransactionReportUrlFilter().buildXml(report);
String domain = "CatTest";
r.setName("transaction");
r.setDomain(domain);
r.setPeriod(TimeUtil.getCurrentDay());
r.setIp("127.0.0.1");
r.setType(1);
r.setContent(xml);
System.out.println("insertBefore");
m_reportDao.insert(r);
System.out.println("insert");
} catch (Throwable e) {
System.out.println(e);
Cat.getProducer().logError(e);
}
List<Report> temp = m_reportDao.findAllByPeriodDomainName(TimeUtil.getCurrentDay(), "CatTest", "transaction",
ReportEntity.READSET_FULL);
System.out.println(temp.size());
for (Report re : temp) {
TransactionReport report = DefaultSaxParser.parse(re.getContent());
new Vistor().visitTransactionReport(report);
}
}
static class Vistor extends com.dianping.cat.consumer.transaction.model.transform.BaseVisitor {
@Override
public void visitType(TransactionType type) {
if ("URL".equals(type.getId())) {
super.visitType(type);
}
}
@Override
public void visitName(TransactionName name) {
if (name.getId().indexOf("2529898") > -1) {
System.out.println(name.getId());
}
super.visitName(name);
}
}
@Test
public void testDataBaseOnLine() throws Exception {
byte[] data = Files.forIO().readFrom(new File("report-transaction"));
String all = new String(data, 1946326, 11610469 - 1946326);
String shopWeb = all;
System.out.println(shopWeb.substring(7, 100));
int length = shopWeb.length();
System.out.println(shopWeb.substring(length - 100, length));
System.out.println("Old Length" + shopWeb.length());
String domain = System.currentTimeMillis() + "";
try {
Report r = m_reportDao.createLocal();
// String xml = new TransactionReportUrlFilter().buildXml(report);
r.setName("transaction");
r.setDomain(domain);
r.setPeriod(TimeUtil.getCurrentDay());
r.setIp("127.0.0.1");
r.setType(1);
r.setContent(shopWeb);
m_reportDao.insert(r);
} catch (Throwable e) {
System.out.println(e);
Cat.getProducer().logError(e);
}
Files.forIO().writeTo(new File("sfs.xml"), shopWeb.substring(7, shopWeb.length()).trim());
TransactionReport report1 = DefaultSaxParser.parse(shopWeb);
System.out.println(">>>>>>>" + report1.getMachines().size());
List<Report> temp = m_reportDao.findAllByPeriodDomainName(TimeUtil.getCurrentDay(), domain, "transaction",
ReportEntity.READSET_FULL);
System.out.println("temp size" + temp.size());
for (Report re : temp) {
String content = re.getContent();
System.out.println("New Length:" + content.length());
System.out.println(content.substring(0, 100));
System.out.println(content.substring(length - 100, length));
TransactionReport report = DefaultSaxParser.parse(content);
new Vistor().visitTransactionReport(report);
}
}
}
\ No newline at end of file
package com.dianping.cat.report.analyzer;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.unidal.lookup.ComponentTestCase;
import org.unidal.lookup.annotation.Inject;
import com.dainping.cat.consumer.dal.report.Report;
import com.dainping.cat.consumer.dal.report.ReportDao;
import com.dainping.cat.consumer.dal.report.ReportEntity;
import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser;
import com.dianping.cat.helper.TimeUtil;
import com.dianping.cat.home.dal.report.DailyreportDao;
import com.site.helper.Files;
public class UrlTransasctionBugTest extends ComponentTestCase {
@Inject
private DailyreportDao m_dailyreportDao;
@Inject
private ReportDao m_reportDao;
@Before
public void setUp() throws Exception {
super.setUp();
m_dailyreportDao = lookup(DailyreportDao.class);
m_reportDao = lookup(ReportDao.class);
}
@Test
public void test() throws Exception {
//fix the transaction xml parse builder
String dateStr = "2012-12-14 19:00:00";
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
List<Report> reports = m_reportDao.findAllByDomainNameDuration(date,
new Date(date.getTime() + TimeUtil.ONE_HOUR), "GroupWeb", "transaction", ReportEntity.READSET_FULL);
File file = new File("text.txt");
for (Report report : reports) {
try {
DefaultSaxParser.parse(report.getContent());
} catch (Exception e) {
Files.forIO().writeTo(file, report.getContent());
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<transaction-report domain="Cat" startTime="2012-05-17 13:00:00" endTime="2012-05-17 13:59:59">
<domain>Cat</domain>
<ip>192.168.165.1</ip>
<machine ip="192.168.165.1">
<type id="Task1" totalCount="2" failCount="0" failPercent="0.00" min="21.422" max="28.35" avg="24.9" sum="49.8" sum2="1262.6" std="3.5" tps="0.00" line95Value="28.00" line95Sum="28.00" line95Count="1">
<successMessageUrl>Cat-c0a8a501-1337230848968-0</successMessageUrl>
<name id="Status1" totalCount="2" failCount="0" failPercent="0.00" min="21.422" max="28.35" avg="24.9" sum="49.8" sum2="1262.6" std="3.5" tps="0.00" line95Value="28.00" line95Sum="28.00" line95Count="1">
<successMessageUrl>Cat-c0a8a501-1337230848968-0</successMessageUrl>
<range value="0" count="2" sum="49.772000000000006" avg="24.9" fails="0"/>
<duration value="32" count="2"/>
</name>
</type>
<type id="URL" totalCount="1" failCount="0" failPercent="0.00" min="39780.276" max="39780.276" avg="39780.3" sum="39780.3" sum2="1582470358.6" std="0.0" tps="0.00" line95Value="39780.00" line95Sum="39780.00" line95Count="1">
<successMessageUrl>Cat-c0a8a501-1337230896586-0</successMessageUrl>
<name id="model2" totalCount="1" failCount="0" failPercent="0.00" min="39780.276" max="39780.276" avg="39780.3" sum="39780.3" sum2="1582470358.6" std="0.0" tps="0.00" line95Value="39780.00" line95Sum="39780.00" line95Count="1">
<successMessageUrl>Cat-c0a8a501-1337230896586-0</successMessageUrl>
<range value="0" count="1" sum="39780.276" avg="39780.3" fails="0"/>
<duration value="65536" count="1"/>
</name>
</type>
</machine>
</transaction-report>
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-job</artifactId>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.5.1.1</version>
<version>0.5.1.2</version>
<name>arch-cat</name>
<description>Central Application Tracking</description>
<packaging>pom</packaging>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册