Commit 731e788d authored by Paras Garg's avatar Paras Garg

updated files

parent a155b14c
app.HOST=192.168.200.20
app.NO_OF_MASTERS=1
app.MASTER_HOST1=192.168.200.20
#app.MASTER_HOST2=192.168.200.51
app.MASTER_HOST2=192.168.200.40
app.INVALIDATION_PORT=1922
app.CACHE_SIZE=1
......@@ -40,8 +40,8 @@ apply plugin: "application"
apply plugin: "java-library"
//mainClassName = "MetadataClient"
mainClassName = "BenchmarkingClient"
//mainClassName= "StandaloneRDMAClient"
//mainClassName = "BenchmarkingClient"
mainClassName= "StandaloneRDMAClient"
version '1.0-SNAPSHOT'
repositories {
......
......@@ -23,7 +23,7 @@ public class MetadataClient
public MetadataClient(Property properties) throws Exception
{
String invalidationServerIP = properties.invalidationServerIP;
logger.debug("Invalidation server ip: " + invalidationServerIP);
logger.info("Invalidation server ip: " + invalidationServerIP);
this.cache = Caffeine.newBuilder()
.expireAfterWrite(300, TimeUnit.SECONDS)
......@@ -37,14 +37,15 @@ public class MetadataClient
public byte[] get(byte[] key) throws Exception
{
logger.debug("Getting From local cache");
logger.info("Getting From local cache");
byte[] value = this.cache.getIfPresent(new ByteArray(key));
if(value != null)
return value;
logger.debug("Not found in cache Getting from server");
logger.info("Not found in cache Getting from server");
var futureResponse = networkHandlerM.get(key).get(100, TimeUnit.MILLISECONDS);
//var futureResponse = networkHandlerM.get(key).get(1000, TimeUnit.MILLISECONDS);
var futureResponse = networkHandlerM.get(key).get();
if(futureResponse.getAck() == AckType.SUCCESS_WITH_VALUE){
System.out.println("Adding to cache");
this.cache.put(new ByteArray(key), futureResponse.getValue());
......@@ -55,8 +56,9 @@ public class MetadataClient
public int put(byte[] key,byte[] value) throws Exception
{
var response = networkHandlerM.put(key,value).get(100, TimeUnit.MILLISECONDS);
logger.debug("Putting KV pair on server ....");
//var response = networkHandlerM.put(key,value).get(1000, TimeUnit.MILLISECONDS);
var response = networkHandlerM.put(key,value).get();
logger.info("Putting KV pair on server ....");
if(response.getAck() == AckType.SUCCESS){
this.cache.put(new ByteArray(key), value);
System.out.println("Updating cache..");
......@@ -66,9 +68,10 @@ public class MetadataClient
public int delete(byte[] key) throws Exception
{
logger.debug("Invalidating Local Cache and sending delete request to server");
logger.info("Invalidating Local Cache and sending delete request to server");
//this.cache.invalidate(key);
var response = this.networkHandlerM.delete(key).get(100,TimeUnit.MILLISECONDS);
return response.getAck();
// var response = this.networkHandlerM.delete(key).get(1000,TimeUnit.MILLISECONDS);
var response = this.networkHandlerM.delete(key).get();
return response.getAck();
}
}
\ No newline at end of file
......@@ -10,13 +10,12 @@ public class StandaloneRDMAClient {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter Invalidation Server IP to bind");
Property properties = new Property(args[0]);
// String address = scanner.nextLine();
System.out.println("prepare");
MetadataClient client = new MetadataClient(properties);
System.out.println("starting");
int option;
while (true) {
System.out.println("Enter 1. for read and 2 for write 3 for delete: ");
......
......@@ -24,6 +24,8 @@ public class NetworkHandlerM {
public NetworkHandlerM( Property properties) throws Exception
{
streams = new ArrayList<>();
eps = new ArrayList<>();
RpcProtocol rpcProtocol = new RpcProtocol();
group = DaRPCClientGroup.createClientGroup(rpcProtocol, 100, 0, 16, 16);
for(var ip : properties.masters)
......
......@@ -49,12 +49,12 @@ public class InvalidationServer
try
{
int conns = numOfConnections;
logger.debug("Waiting for server to send connection request for invalidation");
logger.info("Waiting for server to send connection request for invalidation");
while (conns>0) {
serverEp.accept();
conns -- ;
}
logger.debug("Got Connected for Invalidation");
logger.info("Got Connected for Invalidation");
}
catch(Exception e){
e.printStackTrace();
......@@ -63,7 +63,7 @@ public class InvalidationServer
var t= new Thread(runnable);
t.setName("Server Connection");
t.start();
logger.debug("started Invalidation server");
logger.info("started Invalidation server");
}
public void sendInvalidationRegistrationRequest(String masterIpAddress, String hostIpAddress,NetworkHandler networkHandler) throws IOException, ClassNotFoundException{
......
......@@ -25,24 +25,24 @@ public class BenchmarkingProperties {
final static Logger logger = Logger.getLogger(BenchmarkingProperties.class);
public void printStatistics(){
logger.debug("Total writes: " + writeCount);
logger.debug("Total reads: " + readCount);
logger.debug("Total deletes: " + deleteCount);
logger.info("Total writes: " + writeCount);
logger.info("Total reads: " + readCount);
logger.info("Total deletes: " + deleteCount);
logger.debug("Total write time: " + writeTime);
logger.debug("Total read time: " + readTime);
logger.debug("Total delete time: " + deleteTime);
logger.info("Total write time: " + writeTime);
logger.info("Total read time: " + readTime);
logger.info("Total delete time: " + deleteTime);
logger.debug("Average write time in microseconds: " + (writeTime / writeCount));
logger.debug("Average read time in microseconds: " + (readTime / readCount));
logger.debug("Average delete time in microseconds: " + (deleteTime / deleteCount));
logger.info("Average write time in microseconds: " + (writeTime / writeCount));
logger.info("Average read time in microseconds: " + (readTime / readCount));
logger.info("Average delete time in microseconds: " + (deleteTime / deleteCount));
// logger.debug("Average Time/Request : " + timePerRequest/(writeCount + readCount + deleteCount));
// logger.info("Average Time/Request : " + timePerRequest/(writeCount + readCount + deleteCount));
// long avgTimePerReq = timePerRequest/(writeCount + readCount + deleteCount);
// logger.debug("Actual Requests/second : " + (1000000/avgTimePerReq));
// logger.info("Actual Requests/second : " + (1000000/avgTimePerReq));
}
public void collectExperimentStatistics(long time, int type){
// logger.debug("Time: " + time);
// logger.info("Time: " + time);
if (type == 100) {
writeCount ++;
writeTime = writeTime + time;
......
......@@ -3,9 +3,12 @@ package hpdos.protocol;
public class ByteArray {
public byte[] key;
private int h;
public ByteArray(byte[] key)
{
this.key = key;
System.out.println("new butearray");
h = 0;
}
@Override
public boolean equals(Object other)
......@@ -13,19 +16,29 @@ public class ByteArray {
if( other == null || !(other instanceof ByteArray))
return false;
if(this.key == other)
return true;
return true;
ByteArray b = (ByteArray)other;
int length = b.key.length;
if (this.key.length != length)
return false;
for (int i=0; i<length; i++)
if (this.key[i] != b.key[i])
return false;
return true;
}
@Override
public int hashCode()
{
if(h == 0 && key.length > 0)
{
for(int i = 0;i<key.length;i++)
{
h = 31 * h + key[i];
}
}
return h;
}
}
......@@ -25,7 +25,7 @@ public class Property {
masters = new String[numberOfMasters];
for(int i=1;i<=numberOfMasters;i++)
{
masters[i] = properties.getProperty("app.MASTER_HOST"+i);
masters[i-1] = properties.getProperty("app.MASTER_HOST"+i);
}
}
......
......@@ -27,7 +27,7 @@ public class InvalidationService extends InvalidationRpcProtocol implements DaRP
@Override
public void processServerEvent(DaRPCServerEvent<InvalidationRequest, InvalidationResponse> event) throws IOException
{
logger.debug("Got Invalidation Request");
logger.info("Got Invalidation Request");
InvalidationRequest request = event.getReceiveMessage();
InvalidationResponse response = event.getSendMessage();
try
......@@ -46,17 +46,17 @@ public class InvalidationService extends InvalidationRpcProtocol implements DaRP
public void open(DaRPCServerEndpoint<InvalidationRequest,InvalidationResponse> serverEp)
{
logger.debug("Recieved New Connection for invalidation");
logger.info("Recieved New Connection for invalidation");
try{
logger.debug(serverEp.getDstAddr());
logger.info(serverEp.getDstAddr());
}catch(Exception e){}
}
public void close(DaRPCServerEndpoint<InvalidationRequest,InvalidationResponse> serverEp)
{
logger.debug("Closing Connection for invalidation");
logger.info("Closing Connection for invalidation");
try{
logger.debug(serverEp.getDstAddr());
logger.info(serverEp.getDstAddr());
}catch(Exception e){}
}
}
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