From 92d99a0fbf4fede2eb96aefdb3f33daa3ea15161 Mon Sep 17 00:00:00 2001 From: adash Date: Mon, 9 Mar 2009 15:09:00 +0000 Subject: [PATCH] new script files and some bug fixes...LookUpservice java still not working well --- .../LookUpService/dsm/DistributedHashMap.java | 28 +---------- .../Distributed/LookUpService/dsm/makefile | 2 - .../LookUpService/java/LookUpClient.java | 45 ++++++++++++++--- .../java/LookUpServerExample.java | 3 ++ .../java/LookUpServerThread.java | 34 ++++++++++--- .../Distributed/LookUpService/java/makefile | 4 +- .../Distributed/RainForest/dsm/makefile | 4 +- .../RainForest/java/RainForestClient.java | 49 ++++++++++++++++--- .../java/RainForestServerExample.java | 13 ++--- .../Distributed/RainForest/java/makefile | 4 +- Robust/src/Benchmarks/Distributed/bm_args.txt | 2 + Robust/src/Benchmarks/Distributed/runall.sh | 2 + Robust/src/Benchmarks/Distributed/runjava.sh | 2 +- 13 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 Robust/src/Benchmarks/Distributed/bm_args.txt create mode 100755 Robust/src/Benchmarks/Distributed/runall.sh diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/DistributedHashMap.java b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/DistributedHashMap.java index b3e6c9e8..30b73bbb 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/DistributedHashMap.java +++ b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/DistributedHashMap.java @@ -78,37 +78,13 @@ public class DistributedHashMap { Object get(Object key) { int hashcode=key.hashCode(); int index1=hash1(hashcode, table.length); - /****** Add Manual Prefetch *****/ - //table[index1].array - Object obj = table; - short[] offsets = new short[4]; - offsets[0] = (short) index1; - offsets[1] = (short) 0; - offsets[2] = getoffset {DistributedHashEntry, array}; - offsets[3] = (short) 0; - System.rangePrefetch(obj,offsets); - /********************************/ - + DistributedHashEntry dhe=table[index1]; if (dhe==null) return null; int index2=hash2(hashcode, table.length, dhe.array.length); - /****** Add Manual Prefetch *****/ - //dhe.array[index2].next(5).key - Object obj1 = dhe; - short[] offsets1 = new short[8]; - offsets1[0] = getoffset {DistributedHashEntry, array}; - offsets1[1] = (short) 0; - offsets1[2] = (short) index2; - offsets1[3] = (short) 0; - offsets1[4] = getoffset {DHashEntry, next}; - offsets1[5] = (short) 5; - offsets1[6] = getoffset {DHashEntry, key}; - offsets1[7] = (short) 0; - System.rangePrefetch(obj1, offsets1); - /********************************/ - + DHashEntry ptr=dhe.array[index2]; while(ptr!=null) { diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile index 57225532..f31b9b6c 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile +++ b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile @@ -1,14 +1,12 @@ MAINCLASS=LookUpService SRC1=${MAINCLASS}.java \ DistributedHashMap.java -FLAGS1=-dsm -dsmcaching -rangeprefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.95 FLAGS2=-dsm -dsmcaching -prefetch -optimize -excprefetch String.hashCode -excprefetch DistributedHashMap.resize -excprefetch String.equals -excprefetch LookUpService.main -mainclass ${MAINCLASS} -trueprob 0.95 FLAGS3=-dsm -optimize -mainclass ${MAINCLASS} FLAGS4=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS} default: ../../../../buildscript ${FLAGS3} -o ${MAINCLASS}NPNC ${SRC1} ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}N ${SRC1} - ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}RangeN ${SRC1} ../../../../buildscript ${FLAGS4} -o ${MAINCLASS}NPC ${SRC1} clean: rm -rf tmpbuilddirectory diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpClient.java b/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpClient.java index b26ea5d5..12c7e912 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpClient.java +++ b/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpClient.java @@ -20,14 +20,18 @@ public class LookUpClient { **/ private int nLookUp; + + private int seed; + public LookUpClient() { } - public LookUpClient(int numtrans, int nobjs, int rdprob, int nLookUp) { + public LookUpClient(int numtrans, int nobjs, int rdprob, int nLookUp, int seed) { this.numtrans = numtrans; this.nobjs = nobjs; this.rdprob = rdprob; this.nLookUp = nLookUp; + this.seed = seed; } public static void main(String[] args) { @@ -35,8 +39,8 @@ public class LookUpClient { LookUpClient.parseCmdLine(args, lc); Socket sock = new Socket("dc-1.calit2.uci.edu",9001); - Random rand = new Random(0); - + Random rand = new Random(lc.seed); + SocketInputStream sin = new SocketInputStream(sock); for (int i = 0; i < lc.numtrans; i++) { for (int j = 0; j < lc.nLookUp; j++) { @@ -48,23 +52,24 @@ public class LookUpClient { } else { operation = 2;//update hashmap } - lc.doLookUp(operation, sock, rwkey); + lc.doLookUp(operation, sock, rwkey, sin); } } /** Special character to terminate computation **/ String op = new String("t"); sock.write(op.getBytes()); + sock.close(); } /** * Call to do a read/ write on socket **/ - public void doLookUp(int operation, Socket sock, int key){ + public void doLookUp(int operation, Socket sock, int key, SocketInputStream sin){ String op; if (operation == 1) { sock.write(fillBytes(operation, key)); byte b[] = new byte[4]; - int numbytes = sock.read(b); + String str1 = readFromSock(sin, 4); } else { sock.write(fillBytes(operation, key)); } @@ -84,6 +89,10 @@ public class LookUpClient { int offset = (3-(i-1)) * 8; b[i] = (byte) ((key >> offset) & 0xFF); } + // + // Debug + // System.println("Sending b[0]= "+ (char) b[0]); + // return b; } @@ -112,12 +121,16 @@ public class LookUpClient { if(i < args.length) { lc.nLookUp = new Integer(args[i++]).intValue(); } + } else if(arg.equals("-seed")) { + if(i < args.length) { + lc.seed = new Integer(args[i++]).intValue(); + } } else if(arg.equals("-h")) { lc.usage(); } } - if(lc.nobjs == 0 || lc.numtrans == 0) + if(lc.nobjs == 0 || lc.numtrans == 0 || lc.nLookUp == 0) lc.usage(); } @@ -125,11 +138,27 @@ public class LookUpClient { * The usage routine which describes the program options. **/ public void usage() { - System.printString("usage: ./Client.bin -nObjs -nTrans -probRead -nLookUp \n"); + System.printString("usage: ./Client.bin -nObjs -nTrans -probRead -nLookUp -seed \n"); System.printString(" -nObjs the number of objects to be inserted into distributed hashmap\n"); System.printString(" -nTrans the number of transactions to run\n"); System.printString(" -probRead the probability of read given a transaction\n"); System.printString(" -nLookUp the number of lookups per transaction\n"); + System.printString(" -seed the seed value for Random\n"); System.printString(" -h help with usage\n"); } + + /** + ** Repeated read until you get all bytes + **/ + String readFromSock(SocketInputStream si, int maxBytes) { + byte []b=new byte[maxBytes]; + int numbytes; + if ((numbytes = si.readAll(b))<0) + System.out.println("Error\n"); + // + // Debug + // System.println("numbytes received= " + numbytes); + // + return new String(b); + } } diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerExample.java b/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerExample.java index 0228cf4d..31d2ee49 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerExample.java +++ b/Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerExample.java @@ -47,7 +47,10 @@ public class LookUpServerExample { for(int i=0; i\n"); + System.printString(" -seed the seed value for Random\n"); + System.printString(" -h help with usage\n"); + } } diff --git a/Robust/src/Benchmarks/Distributed/RainForest/java/RainForestServerExample.java b/Robust/src/Benchmarks/Distributed/RainForest/java/RainForestServerExample.java index df1a5400..8f9d3f56 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/java/RainForestServerExample.java +++ b/Robust/src/Benchmarks/Distributed/RainForest/java/RainForestServerExample.java @@ -2,17 +2,18 @@ #define COLUMN 100 /* rows of in the map */ public class RainForestServerExample { - private int numThreads; + /** + ** Number of threads + **/ + int numThreads; public RainForestServerExample() { } public static int main(String args[]) { - int numThreads; - if(args.length>0) { - numThreads = Integer.parseInt(args[0]); - } + RainForestServerExample rfe = new RainForestServerExample(); + RainForestServerExample.parseCmdLine(args, rfe); /** * Create shared Map @@ -35,7 +36,7 @@ public class RainForestServerExample { } ServerSocket ss = new ServerSocket(9002); - acceptConnection(ss, world, numThreads); + acceptConnection(ss, world, rfe.numThreads); } public static void acceptConnection(ServerSocket ss, GameMap[][] world, int numThreads) { diff --git a/Robust/src/Benchmarks/Distributed/RainForest/java/makefile b/Robust/src/Benchmarks/Distributed/RainForest/java/makefile index cbe1ecaf..d11257dd 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/java/makefile +++ b/Robust/src/Benchmarks/Distributed/RainForest/java/makefile @@ -19,8 +19,8 @@ SRC1=tmp${MAINCLASS2}.java \ AStarPathFinder.java \ BarrierNonDSM.java -FLAGS1= -thread -nooptimize -debug -mainclass ${MAINCLASS1} -FLAGS2= -thread -nooptimize -debug -mainclass ${MAINCLASS2} +FLAGS1= -thread -optimize -mainclass ${MAINCLASS1} +FLAGS2= -thread -optimize -mainclass ${MAINCLASS2} default: cpp RainForestServerExample.java > tmp1RainForestServerExample.java diff --git a/Robust/src/Benchmarks/Distributed/bm_args.txt b/Robust/src/Benchmarks/Distributed/bm_args.txt new file mode 100644 index 00000000..33d42217 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/bm_args.txt @@ -0,0 +1,2 @@ +LookUpService:-nObjs 160:-nObjs 160 -nTrans 1000 -probRead 96 -nLookUp 10:LookUpServerExample:LookUpClient +RainForest:::: diff --git a/Robust/src/Benchmarks/Distributed/runall.sh b/Robust/src/Benchmarks/Distributed/runall.sh new file mode 100755 index 00000000..b064f7d0 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/runall.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./runjava.sh 6 diff --git a/Robust/src/Benchmarks/Distributed/runjava.sh b/Robust/src/Benchmarks/Distributed/runjava.sh index 193dc2c1..d9e90262 100755 --- a/Robust/src/Benchmarks/Distributed/runjava.sh +++ b/Robust/src/Benchmarks/Distributed/runjava.sh @@ -72,7 +72,7 @@ function runjvm { done } -exec < bm_jargs.txt +exec < bm_args.txt while read line do BM_NAME=`echo $line | cut -f1 -d":"` -- 2.34.1