bug fix
authorbdemsky <bdemsky>
Tue, 3 Mar 2009 07:16:14 +0000 (07:16 +0000)
committerbdemsky <bdemsky>
Tue, 3 Mar 2009 07:16:14 +0000 (07:16 +0000)
Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpClient.java
Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpServerThread.java

index 6165a236886c5400924e5fad491e78137edb0d95..4d7a677dc8e496cb92d80bef444fa4df94c12443 100644 (file)
@@ -42,7 +42,8 @@ public class LookUpClient {
     InputStream in = null;
     OutputStream out = null;
     try {
-      sock = new Socket("dc-1.calit2..uci.edu",9001);
+      sock = new Socket("dc-1.calit2.uci.edu",9001);
+      sock.setTcpNoDelay(true);
       in = sock.getInputStream();
       out = sock.getOutputStream(); 
     } catch (UnknownHostException e) {
@@ -52,8 +53,9 @@ public class LookUpClient {
       System.out.println("Read failed " + e);
     }
 
+    Random rand = new Random(0);
+
     for (int i = 0; i < lc.numtrans; i++) {
-      Random rand = new Random(i);
       for (int j = 0; j < lc.nLookUp; j++) {
         int rdwr = rand.nextInt(100);
         int rwkey = rand.nextInt(lc.nobjs);
index 512c404e3fa8079876838ba7970df15273a5e269..a8d790e5c9da3abf378baf666908f90dc3ee25e1 100644 (file)
@@ -12,6 +12,12 @@ public class LookUpServerThread extends Thread {
   }
 
   public void run() {
+      try{
+         sock.setTcpNoDelay(true);
+      } catch (Exception e) {
+         e.printStackTrace();
+      }
+      Random r=new Random(0);
     while(true) {
       byte b[] = new byte[1];
       InputStream in = null;
@@ -55,7 +61,7 @@ public class LookUpServerThread extends Thread {
           }
         } else {
           /* update hashmap if opcode sent is "w" */
-          doUpdate(this, keyitem);
+           doUpdate(r, this, keyitem);
         }
       }
     }
@@ -75,9 +81,8 @@ public class LookUpServerThread extends Thread {
   /**
    * Synchromize threads accessing hashmap to update key,value pair
    **/
-  synchronized void doUpdate(LookUpServerThread lusth, Integer key) {
+    synchronized void doUpdate(Random rand, LookUpServerThread lusth, Integer key) {
     //Write into hmap
-    Random rand = new Random(0);
     int val = rand.nextInt(200);
     Integer value = new Integer(val);
     Object oldvalue = lusth.hmap.put(key, value);