Commit ddd249f2 by eqy Committed by Tianqi Chen

perfom full rpc tracker handshake (#1500)

parent bcc17658
......@@ -201,6 +201,12 @@ public class ConnectTrackerServerProcessor implements ServerProcessor {
if (trackerMagic != RPC.RPC_TRACKER_MAGIC) {
throw new SocketException("failed to connect to tracker (WRONG MAGIC)");
}
String infoJSON = generateCinfo(key);
Utils.sendString(trackerOut, infoJSON);
int recvCode = Integer.parseInt(Utils.recvString(trackerIn));
if (recvCode != RPC.TrackerCode.SUCCESS) {
throw new SocketException("failed to connect to tracker (not SUCCESS)");
}
return trackerSocket;
}
......@@ -239,6 +245,12 @@ public class ConnectTrackerServerProcessor implements ServerProcessor {
}
// handcrafted JSON
private String generateCinfo(String key) {
String cinfo = "{\"key\" : " + "\"server:" + key + "\"}";
return "[" + RPC.TrackerCode.UPDATE_INFO + ", " + cinfo + "]";
}
// handcrafted JSON
private String generatePut(int code, String key, int port, String matchKey) {
return "[" + code + ", " + "\"" + key + "\"" + ", " + "[" + port + ", "
+ "\"" + matchKey + "\"" + "]" + ", " + "null" + "]";
......
......@@ -32,6 +32,7 @@ public class RPC {
public class TrackerCode {
public static final int PUT = 3;
public static final int UPDATE_INFO = 5;
public static final int GET_PENDING_MATCHKEYS = 7;
public static final int SUCCESS = 0;
}
......
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