Commit 421e3afe authored by NILANJAN DAW's avatar NILANJAN DAW

Minor bug fixes

parent 484668c3
......@@ -120,6 +120,7 @@ public class ClientRunner {
String key = Integer.toString((int) (Math.random() * Integer.MAX_VALUE));
StorageModel model = new StorageModel(0, value.length(), key,
MessageConstants.METADATA_ACCESS_PRIVATE, clientID, 0, value);
final long createStart = System.currentTimeMillis();
ListenableFuture<Packet> res = storageService.create(model.getKey(), model.getValue(), model.getAccessType());
res.addListener(() -> {
try {
......@@ -129,18 +130,21 @@ public class ClientRunner {
if (response.getStatus() == MessageConstants.STATUS_OK) {
model.updateData(response.getAck());
generatedPacket.add(model);
} else
System.out.println("error packet " + response);
}
// else
// System.out.println("error packet " + response);
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
this.createTime.add(System.currentTimeMillis() - createStart);
limiter.release();
}, MoreExecutors.directExecutor());
} else if (toss < readBracket) {
// System.out.println("read");
int index = (int) (Math.random() * generatedPacket.size());
StorageModel sendPacket = this.generatedPacket.get(index);
final long readStart = System.currentTimeMillis();
ListenableFuture<Packet> res = storageService.read(sendPacket.getKey());
res.addListener(() -> {
try {
......@@ -155,12 +159,13 @@ public class ClientRunner {
sendPacket.updateData(response.getAck());
}
}
else
System.out.println("error packet " + response);
// else
// System.out.println("error packet " + response);
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
readTime.add(System.currentTimeMillis() - readStart);
limiter.release();
}, MoreExecutors.directExecutor());
} else if (toss < updateBracket) {
......@@ -168,6 +173,7 @@ public class ClientRunner {
int index = (int) (Math.random() * generatedPacket.size());
StorageModel sendPacket = this.generatedPacket.get(index);
final long updateStart = System.currentTimeMillis();
ListenableFuture<Packet> res = storageService.update(sendPacket.getKey(), updatedValue,
sendPacket.getVersion());
res.addListener(() -> {
......@@ -183,9 +189,10 @@ public class ClientRunner {
sendPacket.updateData(response.getAck());
}
}
else
System.out.println("error packet " + response);
// else
// System.out.println("error packet " + response);
}
updateTime.add(System.currentTimeMillis() - updateStart);
limiter.release();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
......@@ -195,6 +202,7 @@ public class ClientRunner {
// System.out.println("delete");
int index = (int) (Math.random() * generatedPacket.size());
StorageModel sendPacket = this.generatedPacket.get(index);
final long deleteStart = System.currentTimeMillis();
ListenableFuture<Packet> res = storageService.delete(sendPacket.getKey(), sendPacket.getVersion());
res.addListener(() -> {
try {
......@@ -209,9 +217,10 @@ public class ClientRunner {
generatedPacket.remove(sendPacket);
}
}
else
System.out.println("error packet " + response);
// else
// System.out.println("error packet " + response);
}
deleteTime.add(System.currentTimeMillis() - deleteStart);
limiter.release();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
......@@ -309,9 +318,12 @@ public class ClientRunner {
System.out.println("Experiment ended");
});
clientRunner.runExperiment(storageService);
// long endTime = System.currentTimeMillis();
// double totalRuntime = endTime - startTime;
//// clientRunner.printStatistics(totalRuntime);
long endTime = System.currentTimeMillis();
System.out.println("Waiting for system to settle down");
Thread.sleep(2000);
double totalRuntime = endTime - startTime;
clientRunner.printStatistics(totalRuntime);
clientRunner.cleanupExperiment(storageService);
executorService.shutdown();
boolean status = executorService.awaitTermination(1000, TimeUnit.MICROSECONDS);
......
......@@ -130,7 +130,8 @@ public class IOHandler {
nack = ResponseBuilder.buildNack(MessageConstants.INVALID_VERSION,
request.getKey());
} else if (readData.getData().getAccessType() == MessageConstants.METADATA_ACCESS_PRIVATE &&
} else if (readData.getData() != null &&
readData.getData().getAccessType() == MessageConstants.METADATA_ACCESS_PRIVATE &&
!request.getClientID().equals(readData.getData().getOwner())) {
status = MessageConstants.STATUS_UNAUTHORIZED_PRIVATE_KEY_ACCESS;
nack = ResponseBuilder.buildNack(MessageConstants.INVALID_VERSION,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment