From 045a983dfc6bbeb19d2739f3c1988a1d03280230 Mon Sep 17 00:00:00 2001 From: Rohan Chakravarthy Date: Fri, 1 May 2015 11:42:55 -0400 Subject: [PATCH] Small changes to the client code --- src/edu/tomr/client/InitializeClient.java | 10 +++++++--- src/edu/tomr/queue/NodeQueueProcessor.java | 7 +------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/edu/tomr/client/InitializeClient.java b/src/edu/tomr/client/InitializeClient.java index ffe3766..0985a88 100644 --- a/src/edu/tomr/client/InitializeClient.java +++ b/src/edu/tomr/client/InitializeClient.java @@ -50,7 +50,7 @@ private static void generateRequests(ClientRequestType requestType, int requestL e.printStackTrace(); } String randomString = generateString(requestLength); - ExecutorService executor = Executors.newFixedThreadPool(5); + ExecutorService executor = Executors.newFixedThreadPool(10); for(int i=1; i<=numOfRequests; i++){ //ClientServiceMessage serviceMessage = getServiceMessage(); //Connection nodeConnection=new Connection(serviceMessage.getServiceIPAddress(),servicerNodePort); @@ -81,7 +81,11 @@ private static String generateString(int requestLength) { } public static void main(String[] args) { - - generateRequests(ClientRequestType.ADD, 50, 5); + serverIP = ConfigParams.getProperty("LB_IP"); + long startTime = System.nanoTime(); + //generateRequests(ClientRequestType.ADD, 1000, 2000); + generateRequests(ClientRequestType.GET, 50, 2000); + long endTime = System.nanoTime(); + System.out.println("Took "+((endTime - startTime)/1000000) + " ms"); } } diff --git a/src/edu/tomr/queue/NodeQueueProcessor.java b/src/edu/tomr/queue/NodeQueueProcessor.java index 2d9a1d0..66c1872 100644 --- a/src/edu/tomr/queue/NodeQueueProcessor.java +++ b/src/edu/tomr/queue/NodeQueueProcessor.java @@ -27,16 +27,11 @@ public void run() { boolean running = true; while(running) { - try { - Thread.sleep(50); + if(!queue.isEmpty()){ DBMessage msg = (DBMessage)queue.dequeueMessage(); handleMessage(msg); } - } catch (InterruptedException e) { - running = false; - e.printStackTrace(); - } } }