parent
5c799917e9
commit
c6f914dcad
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -36,6 +36,12 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
|
|||
</div>
|
||||
|
||||
<div class="fluid middle">
|
||||
<div class="fluid exp">
|
||||
<div class="fluid title1">How to Use?</div>
|
||||
<div class="expout" style="background:black; height:780px;">
|
||||
<video src="data/use.mp4" controls="controls" style="width:100%;margin-top:8px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="fluid result">
|
||||
<div class="fluid title1">Structure</div>
|
||||
<div class="introduce" style="text-align:center; height:930px;">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package dao;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
@ -28,7 +31,8 @@ public class MemcachedServer {
|
|||
public static Boolean status = false;
|
||||
public static Boolean initFlag = false;
|
||||
|
||||
private static final int RESULTTHROLD = 1000;
|
||||
private static final int RESULTTHROLD = 500;
|
||||
private static final int DATASETSIZE = 28000;
|
||||
|
||||
public static void main(String[] args) {
|
||||
MemcachedServer.run(new String[]{"100","1000","1","64","0.8"});
|
||||
|
@ -60,7 +64,7 @@ public class MemcachedServer {
|
|||
|
||||
int threads = Integer.parseInt(args[0]);
|
||||
int runs = Integer.parseInt(args[1]);
|
||||
int Nums = 10000;
|
||||
int Nums = DATASETSIZE;
|
||||
int size = 64;
|
||||
double rate = Double.parseDouble(args[2]);
|
||||
threadCount = threads;
|
||||
|
@ -188,6 +192,32 @@ public class MemcachedServer {
|
|||
//System.err.println(time / 1000000000.0);
|
||||
}
|
||||
|
||||
public String getRandomString() {
|
||||
String result = "";
|
||||
String name = "";
|
||||
String base = "abcdefghijklmnopqrstuvwxyz";
|
||||
Random random = new Random();
|
||||
int size = random.nextInt(2) + 4;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int number = random.nextInt(base.length());
|
||||
name += base.charAt(number);
|
||||
}
|
||||
String birthdate = getDate();
|
||||
result = "(" + name.toUpperCase() + ", " + name + ", " + birthdate + ")";
|
||||
return result;
|
||||
}
|
||||
public String getDate() {
|
||||
Random rand = new Random();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(1900, 0, 1);
|
||||
long start = cal.getTimeInMillis();
|
||||
cal.set(2000, 0, 1);
|
||||
long end = cal.getTimeInMillis();
|
||||
Date d = new Date(start + (long)(rand.nextDouble() * (end - start)));
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
public void randReadWrite(MemcachedClient mc, double scale) {
|
||||
final Random randNum = new Random();
|
||||
int getCount = (int) (runs*scale);
|
||||
|
@ -218,6 +248,7 @@ public class MemcachedServer {
|
|||
// mc.set(keyword, value);
|
||||
k ++;
|
||||
} else {
|
||||
object = getRandomString();
|
||||
String keyword = keys[randNum.nextInt(nums)];
|
||||
mc.set(keyword, object);
|
||||
aResult.put("type", "SET");
|
||||
|
|
|
@ -6,6 +6,9 @@ package dao;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -31,6 +34,9 @@ import org.xml.sax.SAXException;
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.myself.database.DatabaseCon;
|
||||
import com.myself.memcached.MemcachedMgr;
|
||||
import com.myself.server.ClientConfig;
|
||||
|
@ -52,7 +58,8 @@ public class RMemcachedServer {
|
|||
private static Map<Integer, String> localStats = new HashMap<>();
|
||||
public static JSONArray nodeStats = new JSONArray();
|
||||
|
||||
private static final int RESULTTHROLD = 1000;
|
||||
private static final int RESULTTHROLD = 500;
|
||||
private static final int DATASETSIZE = 28000;
|
||||
|
||||
public static void main(String[] args){
|
||||
// for (int i = 0; i < 1; i++){
|
||||
|
@ -80,7 +87,7 @@ public class RMemcachedServer {
|
|||
// //System.out.println(webSession.results.length());
|
||||
// }
|
||||
|
||||
RMemcachedServer.run(new String[]{"100","1000","1","64","0.8"});
|
||||
RMemcachedServer.run(new String[]{"100","1000","0.8","64","0.8"});
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
@ -114,7 +121,7 @@ public class RMemcachedServer {
|
|||
|
||||
int threads = Integer.parseInt(args[0]);
|
||||
int runs = Integer.parseInt(args[1]);
|
||||
int Nums = 10000;
|
||||
int Nums = DATASETSIZE;
|
||||
int size = 64;
|
||||
double rate = Double.parseDouble(args[2]);
|
||||
RMemcachedServer.threadCount = threads;
|
||||
|
@ -285,6 +292,32 @@ public class RMemcachedServer {
|
|||
//System.err.println(time / 1000000000.0f);
|
||||
}
|
||||
|
||||
public String getRandomString() {
|
||||
String result = "";
|
||||
String name = "";
|
||||
String base = "abcdefghijklmnopqrstuvwxyz";
|
||||
Random random = new Random();
|
||||
int size = random.nextInt(2) + 4;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int number = random.nextInt(base.length());
|
||||
name += base.charAt(number);
|
||||
}
|
||||
String birthdate = getDate();
|
||||
result = "(" + name.toUpperCase() + ", " + name + ", " + birthdate + ")";
|
||||
return result;
|
||||
}
|
||||
public String getDate() {
|
||||
Random rand = new Random();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(1900, 0, 1);
|
||||
long start = cal.getTimeInMillis();
|
||||
cal.set(2000, 0, 1);
|
||||
long end = cal.getTimeInMillis();
|
||||
Date d = new Date(start + (long)(rand.nextDouble() * (end - start)));
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
public void randReadWrite(double scale) {
|
||||
Random randNum = new Random();
|
||||
int getCount = (int) (runs*scale);
|
||||
|
@ -293,29 +326,9 @@ public class RMemcachedServer {
|
|||
if ((Math.random() < scale || j >= setCount) && k < getCount) {
|
||||
final String keyword = keys[randNum.nextInt(nums)];
|
||||
webSession.getInstance().get(keyword);
|
||||
// if (!webSession.middleOut.containsKey(keyword) || webSession.middleOut.get(keyword) == null
|
||||
// || webSession.middleOut.get(keyword).isEmpty()) {
|
||||
// requestCount ++;
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// //String value = DatabaseCon.getInstance().queryKey(keyword);
|
||||
// String value = null;
|
||||
// if (value == null) {
|
||||
// value = object;
|
||||
// }
|
||||
// webSession.getInstance().set(keyword, value);
|
||||
// }
|
||||
// }).start();
|
||||
// }
|
||||
|
||||
// String value = DatabaseCon.getInstance().queryKey(keyword);
|
||||
// if (value == null) {
|
||||
// value = object;
|
||||
// }
|
||||
// webSession.getInstance().set(keyword, value);
|
||||
k ++;
|
||||
} else {
|
||||
object = getRandomString();
|
||||
webSession.getInstance().set(keys[randNum.nextInt(nums)], object);
|
||||
j ++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue