Commit b535b3ce authored by NILANJAN DAW's avatar NILANJAN DAW

Added random read from replicaset

parent a5d9a657
app.name="HPDOS-Client"
app.version="0.1.4"
app.thread_count=12
app.runtime=15
app.runtime=30
app.cycle_create=1
app.cycle_read=4
app.cycle_update=3
......
......@@ -14,6 +14,7 @@ service NetworkService {
rpc createMetadata(Packet) returns (Packet) {}
rpc updateMetadata(Packet) returns (Packet) {}
rpc deleteMetadata(Packet) returns (Packet) {}
rpc getReadReplicaList(RequestList) returns (ResponseList) {}
}
......@@ -54,3 +55,18 @@ message Nack {
string key = 2;
int32 version = 3;
}
message RequestList {}
message ResponseList {
int32 operationType = 1;
int32 status = 2;
repeated Follower follower = 3;
}
message Follower {
string ip = 1;
int32 port = 2;
string followerID = 3;
int64 lastSeen = 4;
}
\ No newline at end of file
......@@ -2,12 +2,14 @@ package hpdos.handler;
import com.google.common.base.Stopwatch;
import hpdos.grpc.*;
import hpdos.lib.MasterFollower;
import hpdos.lib.ReplicationService;
import hpdos.message.RequestBuilder;
import hpdos.message.ResponseBuilder;
import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
public class NetworkHandler extends NetworkServiceGrpc.NetworkServiceImplBase {
......@@ -75,6 +77,24 @@ public class NetworkHandler extends NetworkServiceGrpc.NetworkServiceImplBase {
responseObserver.onCompleted();
}
@Override
public void getReadReplicaList(RequestList requestList,
StreamObserver<ResponseList> responseListStreamObserver) {
HashMap<String, MasterFollower> followers = replicationService.getFollowers();
ResponseList.Builder responseList = ResponseList.newBuilder();
for (MasterFollower follower: followers.values()) {
Follower.Builder replica = Follower.newBuilder();
replica.setIp(follower.getIp());
replica.setPort(follower.getPort());
replica.setFollowerID(follower.getFollowerID());
replica.setLastSeen(follower.getLastSeen());
replica.build();
responseList.addFollower(replica);
}
responseListStreamObserver.onNext(responseList.build());
responseListStreamObserver.onCompleted();
}
private Packet replicate(Packet requestPacket) {
ReplicationRequest replicationRequest = RequestBuilder.
buildReplicationRequest(new ArrayList<>(requestPacket.getRequestList()));
......
......@@ -104,6 +104,11 @@ public class InlineReplicationService implements ReplicationService {
ListenableFuture<ReplicationResponse> res = stub.replicateMetadata(replicationRequest);
}
return null;
throw new UnsupportedOperationException("Implementation not complete");
}
@Override
public HashMap<String, MasterFollower> getFollowers() {
return followers;
}
}
......@@ -3,10 +3,12 @@ package hpdos.lib;
import hpdos.grpc.ReplicationRequest;
import hpdos.grpc.ReplicationResponse;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
public interface ReplicationService {
abstract ReplicationResponse replicateMetadata(ReplicationRequest replicationRequest) throws InterruptedException, ExecutionException;
abstract ReplicationResponse replicateMetadataAsync(ReplicationRequest replicationRequest);
abstract void cleanup() throws InterruptedException;
abstract HashMap<String, MasterFollower> getFollowers();
}
......@@ -14,6 +14,7 @@ service NetworkService {
rpc createMetadata(Packet) returns (Packet) {}
rpc updateMetadata(Packet) returns (Packet) {}
rpc deleteMetadata(Packet) returns (Packet) {}
rpc getReadReplicaList(RequestList) returns (ResponseList) {}
}
......@@ -54,3 +55,18 @@ message Nack {
string key = 2;
int32 version = 3;
}
message RequestList {}
message ResponseList {
int32 operationType = 1;
int32 status = 2;
repeated Follower follower = 3;
}
message Follower {
string ip = 1;
int32 port = 2;
string followerID = 3;
int64 lastSeen = 4;
}
\ No newline at end of file
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