/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateNodeResponse response = new UpdateNodeResponse(); return(response); }
private Message ProcUpdatePredRequest(Message msg) { Messages.UpdatePredNodeRequest upnrMsg = new Messages.UpdatePredNodeRequest(msg.ToString()); // Update local node relationship ChordNode predNode = new ChordNode(upnrMsg.predIpAddress, upnrMsg.predPort, upnrMsg.predId); this.localNode.predNode = predNode; // The pred communicates with the server component, // so there is no reason to update the client connections upnrMsg.isProcessed = true; // craft a response message Messages.UpdateNodeResponse response = new UpdateNodeResponse(this.localNode, true); response.isProcessed = true; return(response); }
void ProcJoin() { // Connect to arbitrary node in the ring ProcConnect(); // Make a join request OutputManager.Ui.Write("Join Request..."); JoinRequest joinRequest = new JoinRequest(this.localNode); Message joinResponseTmp = localNode.SendMessage(joinRequest); JoinResponse joinResponse = new JoinResponse(joinResponseTmp.ToString()); // Disconnect from the arbitary node in the ring OutputManager.Ui.Write("Disconnecting from node..."); localNode.DisconnectFromNode(); // Update local node connection info OutputManager.Ui.Write("Updating local info..."); localNode.predNode = new ChordNode(joinResponse.predIpAddress, joinResponse.predPort, joinResponse.predId); localNode.succNode = new ChordNode(joinResponse.succIpAddress, joinResponse.succPort, joinResponse.succId); // Connect to pred OutputManager.Ui.Write("Connecting to pred..."); localNode.ConnectToNode(localNode.predNode.IpAddress, localNode.predNode.Port); // Have pred update their succ OutputManager.Ui.Write("Having pred update their succ..."); UpdateSuccNodeRequest uSuccRequest = new UpdateSuccNodeRequest(this.localNode, this.localNode); Message uSuccResponseTmp = localNode.SendMessage(uSuccRequest); UpdateNodeResponse uSuccResponse = new UpdateNodeResponse(uSuccResponseTmp.ToString()); // TODO: Ensure that update was successful // Disconnect from pred OutputManager.Ui.Write("Disconnecting from pred..."); localNode.DisconnectFromNode(); // Connect to succ OutputManager.Ui.Write("Connecting to succ..."); localNode.ConnectToNode(localNode.succNode.IpAddress, localNode.succNode.Port); // Have succ update their pred OutputManager.Ui.Write("Having succ update their pred..."); UpdatePredNodeRequest uPredRequest = new UpdatePredNodeRequest(this.localNode, this.localNode); UpdateNodeResponse uPredResponse = (localNode.SendMessage(uPredRequest)) as UpdateNodeResponse; // TODO: Ensure that update was successful OutputManager.Ui.Write("Successfully joined to ring!"); // TODO: Get resources that should now belong to this node from succ node }
private Message ProcUpdateSuccRequest(Message msg) { Messages.UpdateSuccNodeRequest usnrMsg = new Messages.UpdateSuccNodeRequest(msg.ToString()); // Update local node relationship OutputManager.Server.Write("Updating local node relationship..."); ChordNode succNode = new ChordNode(usnrMsg.succIpAddress, usnrMsg.succPort, usnrMsg.succId); this.localNode.succNode = succNode; // Adjust connection to client node OutputManager.Server.Write("Disconnecting from old succ node..."); this.localNode.DisconnectFromNode(); OutputManager.Server.Write("Connecting to new succ node..."); this.localNode.ConnectToNode(succNode.IpAddress, succNode.Port); usnrMsg.isProcessed = true; // craft a response message OutputManager.Server.Write("Generating a response..."); Messages.UpdateNodeResponse response = new UpdateNodeResponse(this.localNode, true); response.isProcessed = true; OutputManager.Server.Write("Finished processing an update succ request"); return(response); }