-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from rchakra3/parallel_responses
Smooth Multi-client handling now supported
- Loading branch information
Showing
11 changed files
with
231 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package edu.tomr.client; | ||
|
||
import network.Connection; | ||
import network.requests.NWRequest; | ||
import network.responses.NWResponse; | ||
import edu.tomr.protocol.ClientInfo; | ||
import edu.tomr.protocol.ClientRequestPayload; | ||
import edu.tomr.protocol.ClientRequestType; | ||
import edu.tomr.protocol.ClientServiceMessage; | ||
import edu.tomr.protocol.DBMessage; | ||
import edu.tomr.utils.Constants; | ||
|
||
public class ClientRunner implements Runnable { | ||
|
||
private String serverIP; | ||
private int lbport; | ||
private int servicerPort; | ||
private String message; | ||
private ClientRequestType requestType=null; | ||
private int id; | ||
private String selfIP; | ||
|
||
@Override | ||
public void run() { | ||
// TODO Auto-generated method stub | ||
ClientServiceMessage serviceMessage = getServiceMessage(); | ||
Connection nodeConnection=new Connection(serviceMessage.getServiceIPAddress(),servicerPort); | ||
DBMessage query=new DBMessage(requestType, new ClientRequestPayload("File-"+id, message.getBytes()), new ClientInfo(selfIP), serviceMessage.getPayloadID()); | ||
NWRequest request=new NWRequest(serviceMessage.getPayloadID(),query); | ||
nodeConnection.send_request(request); | ||
//this is block wait method | ||
NWResponse response=nodeConnection.getnextResponse(); | ||
Constants.globalLog.debug(response.getAckMsg().toString()); | ||
} | ||
|
||
public ClientRunner(String serverIP,int lbport,int servicerPort,String message,ClientRequestType requestType,int id,String selfIP){ | ||
this.serverIP=serverIP; | ||
this.lbport=lbport; | ||
this.servicerPort=servicerPort; | ||
this.message=message; | ||
this.requestType=requestType; | ||
this.id=id; | ||
this.selfIP=selfIP; | ||
} | ||
|
||
private ClientServiceMessage getServiceMessage() { | ||
Connection lbConnection=new Connection(serverIP,lbport); | ||
NWResponse response=lbConnection.getnextResponse(); | ||
return response.getClientServiceMsg(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package network.responses; | ||
|
||
import java.net.Socket; | ||
|
||
public class ClientResponseWrapper { | ||
|
||
private NWResponse response=null; | ||
private Socket socket=null; | ||
|
||
public ClientResponseWrapper(NWResponse response,Socket socket){ | ||
this.response=response; | ||
this.socket=socket; | ||
} | ||
|
||
public NWResponse getResponse() { | ||
return response; | ||
} | ||
|
||
public Socket getSocket() { | ||
return socket; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.