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; margin-bottom : 2px;
} }
.paraitem { .paraitem {
width: 160px; width: 180px;
text-align:left; text-align:left;
padding-top:8px; padding-top:8px;
padding-left:8px; padding-left:8px;
@ -264,20 +264,28 @@ margin-left: 0;
border-right:1px solid silver; border-right:1px solid silver;
} }
.parasinput { .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-size: 1em;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace; font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
} }
.buttons { .buttons {
width: 300px; width: 300px;
float:left; float:right;
text-align:right; text-align:right;
margin-right:20px; margin-right:40px;
padding-top:8px; padding-top:8px;
height:32px; height:32px;
} }
.parasbutton { .parasbutton {
width:120px; width:120px;
margin-right:20px;
text-align:center; text-align:center;
font-size: 1em; font-size: 1em;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace; 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"> <div class="expout">
<form id="paras"> <form id="paras">
<div class="fluid paras"> <div class="fluid paras">
<div class="fluid paraitem"> <div class="fluid paraitem" style="width:205px;">
<label>para1:</label> <label>Threads:</label>
<input class="parasinput" id="para1"></input> <input class="parasinput" id="para1"></input>
</div> </div>
<div class="fluid paraitem"> <div class="fluid paraitem">
<label>para2:</label> <label>Runs:</label>
<input class="parasinput" id="para2"></input> <input class="parasinput" id="para2"></input>
</div> </div>
<div class="fluid paraitem"> <div class="fluid paraitem" style="width:210px;">
<label>para3:</label> <label>Mode:</label>
<input class="parasinput" id="para3"></input> <select class="modeselect" name="models" id="para3">
</div> <option value="read">Reading</option>
<div class="fluid paraitem"> <option value="browser">Browsing</option>
<label>para4:</label> <option value="shop">Shopping</option>
<input class="parasinput" id="para4"></input> <option value="order">Ordering</option>
</div> <option value="write">Writing</option>
<div class="fluid paraitem"> </select>
<label>para5:</label>
<input class="parasinput" id="para5"></input>
</div> </div>
<div class="fluid buttons"> <div class="fluid buttons">
<input class="parasbutton" id="parabutton" type="button" value="start" onclick="showInfo()"></input> <input class="parasbutton" id="parabutton" type="button" value="start" onclick="showInfo()"></input>
<input class="parasbutton" id="resetbutton" type="button" value="reset" onclick="reset()"></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> </div>
<div class="fluid result"> <div class="fluid result">
<div class="fluid title1">Result</div> <div class="fluid title1">Delay</div>
<div class="fluid resultout"><div class="innerout" id="chart1"></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>
</div> </div>
@ -182,15 +186,14 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
$('#time1').text("0.000"); $('#time1').text("0.000");
var para1 = document.getElementById("para1").value; var para1 = document.getElementById("para1").value;
var para2 = document.getElementById("para2").value; var para2 = document.getElementById("para2").value;
var para3 = document.getElementById("para3").value; var para3 = $('#para3').val();
var para4 = document.getElementById("para4").value;
var para5 = document.getElementById("para5").value; if (para1 == '' || para2 == '' || para3 == ''){
if (para1 == '' || para2 == '' || para3 == '' || para4 == '' || para5 == ''){
alert("必须输入完整的参数!"); alert("必须输入完整的参数!");
return; return;
} }
var paras= 'para1='+para1+'&para2='+para2+'&para3='+para3+'&para4='+para4+'&para5='+para5; var paras= 'para1='+para1+'&para2='+para2+'&para3='+para3;
var url = "servlets/GetInfoServlet?"+paras; var url = "servlets/GetInfoServlet?"+paras;
xmlHttp.onreadystatechange = getResult; xmlHttp.onreadystatechange = getResult;
xmlHttp.open("POST",url,true); xmlHttp.open("POST",url,true);
xmlHttp.send(null); xmlHttp.send(null);
@ -280,12 +283,14 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
}); });
} }
function showBar(arrayObj){ function showBar(arrayObj){
$('#chart1').html(''); $('#chart1-1').html('');
$('#chart1-2').html('');
$('#chart2').html(''); $('#chart2').html('');
$('#chart3').html(''); $('#chart3').html('');
if (arrayObj == null){ if (arrayObj == null){
progresslength1 = 0; 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 innerdata2 = [['Node0000', 0], ['Node0001', 0], ['Node0002', 0], ['Node0003', 0]];
var innerdata3 = [['Node0000', 0], ['Node0001', 0], ['Node0002', 0], ['Node0003', 0]]; var innerdata3 = [['Node0000', 0], ['Node0001', 0], ['Node0002', 0], ['Node0003', 0]];
var data2 = [innerdata2, innerdata2]; var data2 = [innerdata2, innerdata2];
@ -296,7 +301,8 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
$('#time1').text(dataTime); $('#time1').text(dataTime);
progresslength1 = 180; 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]], var innerdata21 = [['Node0000', arrayObj[1]], ['Node0001', arrayObj[3]],
['Node0002', arrayObj[5]], ['Node0003', arrayObj[7]]]; ['Node0002', arrayObj[5]], ['Node0003', arrayObj[7]]];
var innerdata22 = [['Node0000', arrayObj[2]], ['Node0001', arrayObj[4]], var innerdata22 = [['Node0000', arrayObj[2]], ['Node0001', arrayObj[4]],
@ -306,7 +312,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
} }
jQuery.jqplot.config.enablePlugins = true; jQuery.jqplot.config.enablePlugins = true;
var plot1 = $.jqplot('chart1', [data1], { var plot1_1 = $.jqplot('chart1-1', [data1_1], {
title:'R-Memcached VS Memcached', title:'R-Memcached VS Memcached',
seriesDefaults: { seriesDefaults: {
pointLabels: {show: true}, pointLabels: {show: true},
@ -327,7 +333,34 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
} }
}, },
xaxis: { 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 labelRenderer: $.jqplot.CanvasAxisLabelRenderer
} }
} }

View File

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

View File

@ -46,6 +46,8 @@ public class RMemcachedServer {
public static long time = 0; public static long time = 0;
private static Map<Integer, String> localStats = new HashMap<>(); private static Map<Integer, String> localStats = new HashMap<>();
public static JSONArray nodeStats = new JSONArray(); public static JSONArray nodeStats = new JSONArray();
private static final int RESULTTHROLD = 500;
public static void main(String[] args){ public static void main(String[] args){
// for (int i = 0; i < 1; i++){ // for (int i = 0; i < 1; i++){
@ -107,9 +109,9 @@ public class RMemcachedServer {
int threads = Integer.parseInt(args[0]); int threads = Integer.parseInt(args[0]);
int runs = Integer.parseInt(args[1]); int runs = Integer.parseInt(args[1]);
int Nums = Integer.parseInt(args[2]); int Nums = 10000;
int size = Integer.parseInt(args[3]); int size = 64;
double rate = Double.parseDouble(args[4]); double rate = Double.parseDouble(args[2]);
RMemcachedServer.threadCount = threads; RMemcachedServer.threadCount = threads;
RMemcachedServer.requestCount = runs*threads; RMemcachedServer.requestCount = runs*threads;
@ -124,7 +126,11 @@ public class RMemcachedServer {
} }
getStats(); getStats();
DatabaseCon.getInstance().start(); try {
DatabaseCon.getInstance().start();
} catch (Exception e) {
DatabaseCon.getInstance().start(ORIGINPATH);
}
RMemcachedServer.initFlag = true; RMemcachedServer.initFlag = true;
for (int i = 0; i < threads; i++) { for (int i = 0; i < threads; i++) {
@ -163,17 +169,17 @@ public class RMemcachedServer {
JSONArray results = new JSONArray(); JSONArray results = new JSONArray();
JSONArray arrays = webSession.results; JSONArray arrays = webSession.results;
int endIndex = arrays.length(); 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 { try {
JSONObject aResult = (JSONObject) arrays.get(i); JSONObject aResult = (JSONObject) arrays.get(i);
int nodeNum = Integer.parseInt((String) aResult.get("node")); // int nodeNum = Integer.parseInt((String) aResult.get("node"));
aResult.put("node", getOriginNode(nodeNum)); // aResult.put("node", getOriginNode(nodeNum));
results.put(aResult); results.put(aResult);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
startIndex = endIndex < startIndex+1000 ? endIndex : startIndex+1000; startIndex = endIndex < startIndex+RESULTTHROLD ? endIndex : startIndex+RESULTTHROLD;
return results; 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 javax.servlet.http.HttpServletResponse;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import dao.MemcachedServer; import dao.MemcachedServer;
import dao.RMemcachedServer; import dao.RMemcachedServer;
@ -70,13 +72,24 @@ public class GetInfoServlet extends HttpServlet {
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
int type = request.getParameterMap().size(); int type = request.getParameterMap().size();
switch (type) { switch (type) {
case 5:{ case 3:{
System.out.println("Start Run!!!"); 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++) { for (int i = 1; i <= args.length; i++) {
args[i-1] = request.getParameter("para"+i); args[i-1] = request.getParameter("para"+i);
System.out.print("I = " + args[i-1] + "; "); 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(); System.out.println();
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
@ -106,7 +119,8 @@ public class GetInfoServlet extends HttpServlet {
} }
break; break;
case 1:{ case 1:{
while (!RMemcachedServer.initFlag && !RMemcachedServer.status) { while (!RMemcachedServer.initFlag && !RMemcachedServer.status &&
!MemcachedServer.initFlag && !MemcachedServer.status) {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -114,22 +128,40 @@ public class GetInfoServlet extends HttpServlet {
} }
} }
System.out.println("Get Result!!!"); System.out.println("Get Result!!!");
String result = RMemcachedServer.getResult().toString(); JSONArray resultR = RMemcachedServer.getResult();
out.println(result); 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.flush();
out.close(); out.close();
} }
break; break;
case 2:{ case 2:{
float time = RMemcachedServer.time / 1000000000.0f; float timeR = RMemcachedServer.time / 1000000000.0f;
JSONArray stats = RMemcachedServer.nodeStats; JSONArray statsR = RMemcachedServer.nodeStats;
Map <String, String> timeandStats = new HashMap<String, String>(); float timeM = MemcachedServer.time / 1000000000.0f;
timeandStats.put("time", String.format("%.3f", time)); JSONArray statsM = MemcachedServer.nodeStats;
timeandStats.put("stats", stats.toString());
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(); JSONArray jsons = new JSONArray();
jsons.put(timeandStats); jsons.put(timeandStatsR);
jsons.put(timeandStatsM);
String result = jsons.toString(); String result = jsons.toString();
//System.out.println(result); //System.out.println(result);
out.println(result); out.println(result);
out.flush(); out.flush();
out.close(); out.close();