示例#1
0
        private Message ProcJoinRequest(Message msg)
        {
            OutputManager.Server.Write("Processing join request...");
            Messages.JoinRequest jrMsg = new JoinRequest(msg.ToString());
            OutputManager.Server.Write("Finding join point...");
            Messages.ResourceOwnerRequest joinPointRequest = new Messages.ResourceOwnerRequest(this.localNode, jrMsg.senderID);
            OutputManager.Server.Write("Awaiting to process...");
            Message tmp = ProcResourceOwnerRequest(joinPointRequest);

            OutputManager.Server.Write("process awaited");
            Messages.ResourceOwnerResponse joinPointResponse = tmp as Messages.ResourceOwnerResponse;
            Messages.JoinResponse          rMsg; // Used to create the response message later

            if (joinPointResponse == null)
            {
                OutputManager.Server.Write("No join point found." + (tmp == null ? "null" : tmp.ToString()));
                OutputManager.Server.Write("Join request failed!");
                rMsg             = new Messages.JoinResponse(this.localNode, this.localNode, this.localNode);
                rMsg.isProcessed = false;
            }
            else
            {
                OutputManager.Server.Write("Generating Pred and Succ nodes...");
                ChordNode succNode = new ChordNode(joinPointResponse.ownerIpAddress, joinPointResponse.ownerPort, joinPointResponse.ownerId);
                ChordNode predNode = new ChordNode(joinPointResponse.predIpAddress, joinPointResponse.predPort, joinPointResponse.predId);
                OutputManager.Server.Write("Generating a response...");
                rMsg             = new Messages.JoinResponse(this.localNode, succNode, predNode);
                rMsg.isProcessed = true;
                OutputManager.Server.Write("Join request processed!");
            }
            return(rMsg);
        }
示例#2
0
 private Message ProcResourceOwnerRequest(Message msg)
 {
     Messages.ResourceOwnerRequest rorMsg = new Messages.ResourceOwnerRequest(msg.ToString());
     OutputManager.Server.Write("Processing resource owner request...");
     if (IsResponsibleForResource(rorMsg.resourceId))
     {
         OutputManager.Server.Write("Is responsible for resource...");
         msg             = new Messages.ResourceOwnerResponse(this.localNode, rorMsg.resourceId, this.localNode, this.localNode.predNode, this.localNode.succNode);
         msg.isProcessed = true;
     }
     else
     {
         OutputManager.Server.Write("Not responsible for resource...");
     }
     OutputManager.Server.Write("Resource owner request processed!");
     return(msg);
 }