From 25156dee1834d39c48d3cbda4afa796efdaa7fc0 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 3 Mar 2009 07:16:14 +0000 Subject: [PATCH] bug fix --- .../Distributed/LookUpService/jvm/LookUpClient.java | 6 ++++-- .../LookUpService/jvm/LookUpServerThread.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpClient.java b/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpClient.java index 6165a236..4d7a677d 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpClient.java +++ b/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpClient.java @@ -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); diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpServerThread.java b/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpServerThread.java index 512c404e..a8d790e5 100644 --- a/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpServerThread.java +++ b/Robust/src/Benchmarks/Distributed/LookUpService/jvm/LookUpServerThread.java @@ -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); -- 2.34.1