1. fix interface in *Server.java

2. fix the experience.jsp page
  2.1. delete 2 unuseful paras
  2.2. add Throughput chart
  2.3. add select to choose the rate
3. bug fix
This commit is contained in:
martji 2014-09-01 15:01:08 +08:00
parent 5f5626daf2
commit 33dbff74d5
14 changed files with 152 additions and 57 deletions

View File

@ -0,0 +1,5 @@
url = jdbc:mysql://192.168.3.218:3306/tpcw
username = root
password = 1234
sqlget = select c_id, c_uname, c_passwd, c_birthdate from customer where c_id = ?
sqlset = replace into customer(c_id, c_birthdaye) values(?, ?)

View File

@ -256,7 +256,7 @@ margin-left: 0;
margin-bottom : 2px;
}
.paraitem {
width: 160px;
width: 180px;
text-align:left;
padding-top:8px;
padding-left:8px;
@ -264,20 +264,28 @@ margin-left: 0;
border-right:1px solid silver;
}
.parasinput {
width:80px;
width:100px;
font-size: 1em;
padding-left:2px;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
}
.modeselect {
width:120px;
height:25px;
font-size: 1em;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
}
.buttons {
width: 300px;
float:left;
float:right;
text-align:right;
margin-right:20px;
margin-right:40px;
padding-top:8px;
height:32px;
}
.parasbutton {
width:120px;
margin-right:20px;
text-align:center;
font-size: 1em;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;

View File

@ -50,26 +50,25 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
<div class="expout">
<form id="paras">
<div class="fluid paras">
<div class="fluid paraitem">
<label>para1:</label>
<div class="fluid paraitem" style="width:205px;">
<label>Threads:</label>
<input class="parasinput" id="para1"></input>
</div>
<div class="fluid paraitem">
<label>para2:</label>
<label>Runs:</label>
<input class="parasinput" id="para2"></input>
</div>
<div class="fluid paraitem">
<label>para3:</label>
<input class="parasinput" id="para3"></input>
</div>
<div class="fluid paraitem">
<label>para4:</label>
<input class="parasinput" id="para4"></input>
</div>
<div class="fluid paraitem">
<label>para5:</label>
<input class="parasinput" id="para5"></input>
<div class="fluid paraitem" style="width:210px;">
<label>Mode:</label>
<select class="modeselect" name="models" id="para3">
<option value="read">Reading</option>
<option value="browser">Browsing</option>
<option value="shop">Shopping</option>
<option value="order">Ordering</option>
<option value="write">Writing</option>
</select>
</div>
<div class="fluid buttons">
<input class="parasbutton" id="parabutton" type="button" value="start" onclick="showInfo()"></input>
<input class="parasbutton" id="resetbutton" type="button" value="reset" onclick="reset()"></input>
@ -116,8 +115,13 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
</div>
</div>
<div class="fluid result">
<div class="fluid title1">Result</div>
<div class="fluid resultout"><div class="innerout" id="chart1"></div>
<div class="fluid title1">Delay</div>
<div class="fluid resultout"><div class="innerout" id="chart1-1"></div>
</div>
</div>
<div class="fluid result">
<div class="fluid title1">Throughput</div>
<div class="fluid resultout"><div class="innerout" id="chart1-2"></div>
</div>
</div>
@ -182,15 +186,14 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
$('#time1').text("0.000");
var para1 = document.getElementById("para1").value;
var para2 = document.getElementById("para2").value;
var para3 = document.getElementById("para3").value;
var para4 = document.getElementById("para4").value;
var para5 = document.getElementById("para5").value;
if (para1 == '' || para2 == '' || para3 == '' || para4 == '' || para5 == ''){
var para3 = $('#para3').val();
if (para1 == '' || para2 == '' || para3 == ''){
alert("必须输入完整的参数!");
return;
}
var paras= 'para1='+para1+'&para2='+para2+'&para3='+para3+'&para4='+para4+'&para5='+para5;
var url = "servlets/GetInfoServlet?"+paras;
var paras= 'para1='+para1+'&para2='+para2+'&para3='+para3;
var url = "servlets/GetInfoServlet?"+paras;
xmlHttp.onreadystatechange = getResult;
xmlHttp.open("POST",url,true);
xmlHttp.send(null);
@ -280,12 +283,14 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
});
}
function showBar(arrayObj){
$('#chart1').html('');
$('#chart1-1').html('');
$('#chart1-2').html('');
$('#chart2').html('');
$('#chart3').html('');
if (arrayObj == null){
progresslength1 = 0;
var data1 = [[0,'Memcached'], [0,'R-Memcached']];
var data1_1 = [[0,'Memcached'], [0,'R-Memcached']];
var data1_2 = [[0,'Memcached'], [0,'R-Memcached']];
var innerdata2 = [['Node0000', 0], ['Node0001', 0], ['Node0002', 0], ['Node0003', 0]];
var innerdata3 = [['Node0000', 0], ['Node0001', 0], ['Node0002', 0], ['Node0003', 0]];
var data2 = [innerdata2, innerdata2];
@ -296,7 +301,8 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
$('#time1').text(dataTime);
progresslength1 = 180;
var data1 = [[dataTime*2,'Memcached'], [dataTime,'R-Memcached']];
var data1_1 = [[dataTime*2,'Memcached'], [dataTime,'R-Memcached']];
var data1_2 = [[dataTime*2,'Memcached'], [dataTime,'R-Memcached']];
var innerdata21 = [['Node0000', arrayObj[1]], ['Node0001', arrayObj[3]],
['Node0002', arrayObj[5]], ['Node0003', arrayObj[7]]];
var innerdata22 = [['Node0000', arrayObj[2]], ['Node0001', arrayObj[4]],
@ -306,7 +312,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
}
jQuery.jqplot.config.enablePlugins = true;
var plot1 = $.jqplot('chart1', [data1], {
var plot1_1 = $.jqplot('chart1-1', [data1_1], {
title:'R-Memcached VS Memcached',
seriesDefaults: {
pointLabels: {show: true},
@ -327,7 +333,34 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
}
},
xaxis: {
label: 'Time Cost',
label: 'Time Cost / ms',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
}
});
var plot1_2 = $.jqplot('chart1-2', [data1_2], {
title:'R-Memcached VS Memcached',
seriesDefaults: {
pointLabels: {show: true},
shadow: false,showMarker: true,
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barDirection: 'horizontal', barWidth: 60, barMargin:50
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
fontFamily: 'Courier New',
fontSize: '12pt'
}
},
xaxis: {
label: 'Throughout Capacity',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
}

View File

@ -8,7 +8,7 @@ import java.util.Map;
import java.util.Random;
import com.meetup.memcached.*;
import com.meetup.memcaheded.db.DatabaseCon;
import com.myself.database.DatabaseCon;
import com.myself.server.webSession;
import org.apache.log4j.PropertyConfigurator;
@ -29,6 +29,8 @@ public class MemcachedServer {
public static Boolean status = false;
public static Boolean initFlag = false;
private static final int RESULTTHROLD = 500;
public static void main(String[] args) {
MemcachedServer.run(new String[]{"10","1000","1000","64","0.8"});
}
@ -59,9 +61,9 @@ public class MemcachedServer {
int threads = Integer.parseInt(args[0]);
int runs = Integer.parseInt(args[1]);
int Nums = Integer.parseInt(args[2]);
int size = Integer.parseInt(args[3]);
double rate = Double.parseDouble(args[4]);
int Nums = 10000;
int size = 64;
double rate = Double.parseDouble(args[2]);
threadCount = threads;
byte[] obj = new byte[size];
@ -75,7 +77,11 @@ public class MemcachedServer {
}
oldStats = getStats();
DatabaseCon.getInstance().start();
try {
DatabaseCon.getInstance().start();
} catch (Exception e) {
DatabaseCon.getInstance().start(ORIGINPATH);
}
MemcachedServer.initFlag = true;
for (int i = 0; i < threads; i++) {
@ -138,7 +144,7 @@ public class MemcachedServer {
JSONArray results = new JSONArray();
JSONArray arrays = webSession.results;
int endIndex = arrays.length();
for (int i = startIndex; i < endIndex && i < startIndex + 1000; i++){
for (int i = startIndex; i < endIndex && i < startIndex + RESULTTHROLD; i++){
try {
JSONObject aResult = (JSONObject) arrays.get(i);
results.put(aResult);
@ -146,7 +152,7 @@ public class MemcachedServer {
e.printStackTrace();
}
}
startIndex = endIndex < startIndex+1000 ? endIndex : startIndex+1000;
startIndex = endIndex < startIndex+RESULTTHROLD ? endIndex : startIndex+RESULTTHROLD;
return results;
}

View File

@ -46,6 +46,8 @@ public class RMemcachedServer {
public static long time = 0;
private static Map<Integer, String> localStats = new HashMap<>();
public static JSONArray nodeStats = new JSONArray();
private static final int RESULTTHROLD = 500;
public static void main(String[] args){
// for (int i = 0; i < 1; i++){
@ -107,9 +109,9 @@ public class RMemcachedServer {
int threads = Integer.parseInt(args[0]);
int runs = Integer.parseInt(args[1]);
int Nums = Integer.parseInt(args[2]);
int size = Integer.parseInt(args[3]);
double rate = Double.parseDouble(args[4]);
int Nums = 10000;
int size = 64;
double rate = Double.parseDouble(args[2]);
RMemcachedServer.threadCount = threads;
RMemcachedServer.requestCount = runs*threads;
@ -124,7 +126,11 @@ public class RMemcachedServer {
}
getStats();
DatabaseCon.getInstance().start();
try {
DatabaseCon.getInstance().start();
} catch (Exception e) {
DatabaseCon.getInstance().start(ORIGINPATH);
}
RMemcachedServer.initFlag = true;
for (int i = 0; i < threads; i++) {
@ -163,17 +169,17 @@ public class RMemcachedServer {
JSONArray results = new JSONArray();
JSONArray arrays = webSession.results;
int endIndex = arrays.length();
for (int i = startIndex; i < endIndex && i < startIndex + 1000; i++){
for (int i = startIndex; i < endIndex && i < startIndex + RESULTTHROLD; i++){
try {
JSONObject aResult = (JSONObject) arrays.get(i);
int nodeNum = Integer.parseInt((String) aResult.get("node"));
aResult.put("node", getOriginNode(nodeNum));
// int nodeNum = Integer.parseInt((String) aResult.get("node"));
// aResult.put("node", getOriginNode(nodeNum));
results.put(aResult);
} catch (Exception e) {
e.printStackTrace();
}
}
startIndex = endIndex < startIndex+1000 ? endIndex : startIndex+1000;
startIndex = endIndex < startIndex+RESULTTHROLD ? endIndex : startIndex+RESULTTHROLD;
return results;
}

View File

@ -0,0 +1,5 @@
url = jdbc:mysql://192.168.3.218:3306/tpcw
username = root
password = 1234
sqlget = select c_id, c_uname, c_passwd, c_birthdate from customer where c_id = ?
sqlset = replace into customer(c_id, c_birthdaye) values(?, ?)

View File

@ -14,6 +14,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import dao.MemcachedServer;
import dao.RMemcachedServer;
@ -70,13 +72,24 @@ public class GetInfoServlet extends HttpServlet {
PrintWriter out = response.getWriter();
int type = request.getParameterMap().size();
switch (type) {
case 5:{
case 3:{
System.out.println("Start Run!!!");
final String[] args = new String[5];
final String[] args = new String[3];
for (int i = 1; i <= args.length; i++) {
args[i-1] = request.getParameter("para"+i);
System.out.print("I = " + args[i-1] + "; ");
}
if (args[2].equals("read")){
args[2] = "1";
} else if (args[2].equals("browser")){
args[2] = "0.95";
} else if (args[2].equals("shop")){
args[2] = "0.8";
} else if (args[2].equals("order")){
args[2] = "0.5";
} else {
args[2] = "0";
}
System.out.println();
new Thread(new Runnable() {
@Override
@ -106,7 +119,8 @@ public class GetInfoServlet extends HttpServlet {
}
break;
case 1:{
while (!RMemcachedServer.initFlag && !RMemcachedServer.status) {
while (!RMemcachedServer.initFlag && !RMemcachedServer.status &&
!MemcachedServer.initFlag && !MemcachedServer.status) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
@ -114,22 +128,40 @@ public class GetInfoServlet extends HttpServlet {
}
}
System.out.println("Get Result!!!");
String result = RMemcachedServer.getResult().toString();
out.println(result);
JSONArray resultR = RMemcachedServer.getResult();
JSONArray resultM = MemcachedServer.getResult();
JSONObject result = new JSONObject();
try {
result.put("R", resultR);
result.put("M", resultM);
} catch (JSONException e) {
e.printStackTrace();
}
out.println(result.toString());
out.flush();
out.close();
}
break;
case 2:{
float time = RMemcachedServer.time / 1000000000.0f;
JSONArray stats = RMemcachedServer.nodeStats;
Map <String, String> timeandStats = new HashMap<String, String>();
timeandStats.put("time", String.format("%.3f", time));
timeandStats.put("stats", stats.toString());
float timeR = RMemcachedServer.time / 1000000000.0f;
JSONArray statsR = RMemcachedServer.nodeStats;
float timeM = MemcachedServer.time / 1000000000.0f;
JSONArray statsM = MemcachedServer.nodeStats;
Map <String, String> timeandStatsR = new HashMap<String, String>();
timeandStatsR.put("time", String.format("%.3f", timeR));
timeandStatsR.put("stats", statsR.toString());
Map <String, String> timeandStatsM = new HashMap<String, String>();
timeandStatsM.put("time", String.format("%.3f", timeM));
timeandStatsM.put("stats", statsM.toString());
JSONArray jsons = new JSONArray();
jsons.put(timeandStats);
jsons.put(timeandStatsR);
jsons.put(timeandStatsM);
String result = jsons.toString();
//System.out.println(result);
out.println(result);
out.flush();
out.close();