read record falg html from file

This commit is contained in:
hmm 2014-08-27 10:16:20 +08:00
parent 56a302cb4d
commit a66f0ec758
4 changed files with 53 additions and 26 deletions

View File

@ -51,4 +51,8 @@ generator.isac.timer=ConstantTimer
#extra properties for a negative exponential law distribution
#generator.isac.timer.random.dist=negexpo
#generator.isac.timer.random.delta=10
#generator.isac.timer.random.delta=10
##########################################
#file append to record html
##########################################
record.flag.file=recordFlag.html

View File

@ -0,0 +1 @@
<div id="hemeimei" style="cursor: default;vertical-align: top;text-decoration: none;display: inline-block;width: 22px;height: 22px;margin-top: 8px;border: none;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA6dJREFUeNrUlV9oW3UUx8/v3iQ3ubk3q0mXm2xZa0oximKXtqNOBhMq60NQoeCzjO1pVAWh4FsJTFAfJqgMffBpjz7JGHtYCzoYdC6YqW2Zbik1XZubJQ1dbnJzc//9PL+2YV3/yR724IEvv5vfPb9PTs7vnBNCKYXnYRw8J/Mc9JIQwuMSQvmZZABBA2jjs7GlOv5i55nACJUQdOR7gPfjhJwWAQZ4Sg87hDxqAfz+kNKfLwD8iH4qwhu7zu+VY0mSlI8BXn9H1789PDTU253JCL6eHvB0d4O9tgbm8jJUb9xoV27dWvxJFD/6BuDPRqNRPhCcTCa7JqvVsTds+4cXJyZE6eRJ0i6VwKnXwWk2gRME4INBEI4eBX1ujv5z6ZL+C8d98HU0Ol0oFB7vCR4eHvb263rqk3v3Zl7OZqOeWAxa9+8DtW0A5sfkugCOA5QQEFMpcNbX4a9sVv0ilXp7KRD4O5fLWbuqQlGUyIVC4dMjmUzYixE183lwNbwuw3iidntTGH0zlwNvJALK6GhkYnFxUpblyJ7lFgqF/EHLejdy5oxHv3sXQNf3hFK2miZAqwXa9DREBga8kmm+F4vF/LvA2WzW81axGPceOiRwgQDY5TJQPLgdSnBlopUK2AsLYN6+DQaKcBx4BEF8c2Ulyjg7y83Xs7z8ihiP29b8vM8uFICXpI3LoiyvLEIGrdXAtSxgd0Nwn8NcO7gnJRJO/9LSa78CzCHL3g52iSxrFsspHnSxEgAjoSgWEdbrphDIsX1c2bW7CCc+H1iGQTGXdba1M8dmc2xswVBVge/qAs7rfQJDcZ0v4PnN584++vGhELRWV33VTGaecZ4CT01NueTUqccYSdnC/Ap9fRsHYQd8O5S9Y37MH3h+NTgyojHOrqoYHx9/6PT1fbZy7ZoRHBoCDhvhqai31PnMGiUwOAgr168bZjL5eTgcbhzY0r/J8oySTp9+4cQJvjU7C46qAocp2IgSjV0mpyjgHxmB9Tt3HDWfnyE3b55Np9Ml9nrfITSoaaN5v3+hpapJbBa/i/Xs4oygjQZwsgwcNgURRShdvWpoxeJi8OLFyVQ6Xe1A9424Y3/09n5Jy+UP5f5+GozHBV84zJm1mquXSu36gweEKMpXL83Ofld1nEoikWj953TbbpXLl4+vXbly3CwW09BovIoRz3mOHcuHz53LR8+fX0WXWqfEngmMxoa9wBpI0zQPzgN7q6TYwHf2nef/u/+8fwUYAGyMtUnmcOi+AAAAAElFTkSuQmCC') no-repeat top left"></div>

View File

@ -54,10 +54,9 @@ public class Config {
String maxqDir = System.getProperty("maxq.dir");
String pathSep = System.getProperty("file.separator");
// "\\src\\main\\resources\\org\\bench4q\\master\\config\\httpCaptureConfig\\maxq.properties";
String propertiesFileName = System.getProperty("user.dir") + "src"
+ pathSep + "main" + pathSep + "resources" + pathSep + "org"
+ pathSep + "bench4q" + pathSep + "master" + pathSep + "config"
+ pathSep + "httpCaptureConfig" + pathSep + "maxq.properties";
String propertiesFileName = "org" + pathSep + "bench4q" + pathSep
+ "master" + pathSep + "config" + pathSep + "httpCaptureConfig"
+ pathSep + "maxq.properties";
InputStream propertiesStream = Config.class.getClassLoader()
.getResourceAsStream(propertiesFileName);

View File

@ -1,9 +1,12 @@
package org.bench4q.recorder.httpcapture.generator;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.bench4q.recorder.httpcapture.Config;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -12,24 +15,39 @@ import org.jsoup.select.Elements;
public class HtmlDocumentParser {
private Document document;
private static Logger logger = Logger.getLogger(HtmlDocumentParser.class);
private static String recordFlagHtml = "<div id=\"hemeimei\" style=\"cursor: default;vertical-align: top;"
+ "text-decoration: none;display: inline-block;width: 22px;height: 22px;"
+ "margin-top: 8px;border: none;"
+ "url('data:image/png;"
+ "base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5"
+ "ccllPAAAA6dJREFUeNrUlV9oW3UUx8/v3iQ3ubk3q0mXm2xZa0oximKXtqNOBhMq60NQoeCzjO1pVAWh4FsJTFAfJqgMffBp"
+ "jz7JGHtYCzoYdC6YqW2Zbik1XZubJQ1dbnJzc//9PL+2YV3/yR724IEvv5vfPb9PTs7vnBNCKYXnYRw8J/Mc9JIQwuMSQvmZZ"
+ "ABBA2jjs7GlOv5i55nACJUQdOR7gPfjhJwWAQZ4Sg87hDxqAfz+kNKfLwD8iH4qwhu7zu+VY0mSlI8BXn9H1789PDTU253JCL"
+ "6eHvB0d4O9tgbm8jJUb9xoV27dWvxJFD/6BuDPRqNRPhCcTCa7JqvVsTds+4cXJyZE6eRJ0i6VwKnXwWk2gRME4INBEI4eBX1"
+ "ujv5z6ZL+C8d98HU0Ol0oFB7vCR4eHvb263rqk3v3Zl7OZqOeWAxa9+8DtW0A5sfkugCOA5QQEFMpcNbX4a9sVv0ilXp7KRD4O"
+ "5fLWbuqQlGUyIVC4dMjmUzYixE183lwNbwuw3iidntTGH0zlwNvJALK6GhkYnFxUpblyJ7lFgqF/EHLejdy5oxHv3sXQNf3hFK"
+ "2miZAqwXa9DREBga8kmm+F4vF/LvA2WzW81axGPceOiRwgQDY5TJQPLgdSnBlopUK2AsLYN6+DQaKcBx4BEF8c2Ulyjg7y83Xs7z"
+ "8ihiP29b8vM8uFICXpI3LoiyvLEIGrdXAtSxgd0Nwn8NcO7gnJRJO/9LSa78CzCHL3g52iSxrFsspHnSxEgAjoSgWEdbrphDIsX1"
+ "c2bW7CCc+H1iGQTGXdba1M8dmc2xswVBVge/qAs7rfQJDcZ0v4PnN584++vGhELRWV33VTGaecZ4CT01NueTUqccYSdnC/Ap9fR"
+ "sHYQd8O5S9Y37MH3h+NTgyojHOrqoYHx9/6PT1fbZy7ZoRHBoCDhvhqai31PnMGiUwOAgr168bZjL5eTgcbhzY0r/J8oySTp9+4"
+ "cQJvjU7C46qAocp2IgSjV0mpyjgHxmB9Tt3HDWfnyE3b55Np9Ml9nrfITSoaaN5v3+hpapJbBa/i/Xs4oygjQZwsgwcNgURRShdvW"
+ "poxeJi8OLFyVQ6Xe1A9424Y3/09n5Jy+UP5f5+GozHBV84zJm1mquXSu36gweEKMpXL83Ofld1nEoikWj953TbbpXLl4+vXbly3CwW"
+ "09BovIoRz3mOHcuHz53LR8+fX0WXWqfEngmMxoa9wBpI0zQPzgN7q6TYwHf2nef/u/+8fwUYAGyMtUnmcOi+AAAAAElFTkSuQmCC') no-repeat top left\"></div>";
private static String recordFlagHtml = null;
private static void initRecordFlagHtml() {
String pathSep = System.getProperty("file.separator");
String recordFlagFilePath = "org" + pathSep + "bench4q" + pathSep
+ "master" + pathSep + "config" + pathSep + "httpCaptureConfig"
+ pathSep + Config.getConfig().getProperty("record.flag.file");
InputStream is = HtmlDocumentParser.class.getClassLoader()
.getResourceAsStream(recordFlagFilePath);
if (is == null)
return;
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
int n;
try {
while ((n = is.read(b)) != -1) {
out.append(new String(b, 0, n));
}
recordFlagHtml = out.toString();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static String getRecordFlagHtml() {
if (recordFlagHtml == null) {
initRecordFlagHtml();
}
return recordFlagHtml;
}
private Document getDocument() {
return document;
@ -43,18 +61,23 @@ public class HtmlDocumentParser {
this.setDocument(Jsoup.parse(htmlContent, baseUrl));
}
public String toString(){
public String toString() {
return this.getDocument().toString();
}
public void beginParse() {
}
/**
*
*/
public void appendRecordFlag(){
this.getDocument().body().append(recordFlagHtml);
public void appendRecordFlag() {
String recordFlagHtml = getRecordFlagHtml();
if (recordFlagHtml != null)
this.getDocument().body().append(recordFlagHtml);
}
public List<ChildrenUrl> buildParentChildrenRelationship(int parentBatchId) {
List<ChildrenUrl> result = new ArrayList<ChildrenUrl>();
if (parentBatchId == -1) {