private void CheckPredecessorHandler(object?sender, System.EventArgs e)
        {
            CheckPredecessorEventArgs eventArgs = (CheckPredecessorEventArgs)e;
            NodeDto destinationNode             = eventArgs.DestinationNode;

            _dhtActions.CheckPredecessorResponse(destinationNode, Node.Id, Node);
        }
Example #2
0
        public void PutResponse(NodeDto connectingNode, NodeDto destinationNode, uint key, string value)
        {
            var protocolCommandDto = new DhtProtocolCommandDto
            {
                Command = DhtCommand.PUT_RESPONSE, NodeDto = connectingNode, Key = key, Value = value,
            };

            EnqueueRpcCall(destinationNode, protocolCommandDto);
        }
Example #3
0
        public void FoundSuccessor(NodeDto destinationNode, uint key, NodeDto foundSuccessor)
        {
            var protocolCommandDto =
                new DhtProtocolCommandDto {
                Command = DhtCommand.FOUND_SUCCESSOR, Key = key, NodeDto = foundSuccessor
            };

            EnqueueRpcCall(destinationNode, protocolCommandDto);
        }
Example #4
0
        public void Stabilize(NodeDto connectingNode, uint key, NodeDto destinationNode)
        {
            var protocolCommandDto =
                new DhtProtocolCommandDto {
                Command = DhtCommand.STABILIZE, Key = key, NodeDto = destinationNode
            };

            EnqueueRpcCall(connectingNode, protocolCommandDto);
        }
Example #5
0
        public void Notify(NodeDto connectingNode, uint key, NodeDto destinationNode)
        {
            var protocolCommandDto =
                new DhtProtocolCommandDto {
                NodeDto = destinationNode, Key = key, Command = DhtCommand.NOTIFY
            };

            EnqueueRpcCall(connectingNode, protocolCommandDto);
        }
Example #6
0
        public void CheckPredecessorResponse(NodeDto destinationNode, uint key, NodeDto myPredecessor)
        {
            var protocolCommandDto =
                new DhtProtocolCommandDto
            {
                Command = DhtCommand.CHECK_PREDECESSOR_RESPONSE, Key = key, NodeDto = myPredecessor
            };

            EnqueueRpcCall(destinationNode, protocolCommandDto);
        }
Example #7
0
        public void FindSuccessor(NodeDto connectingNode, uint key, NodeDto destinationNode)
        {
            var protocolCommandDto = new DhtProtocolCommandDto
            {
                Command = DhtCommand.FIND_SUCCESSOR, Key = key, NodeDto = destinationNode
            };

            Log.Debug(protocolCommandDto.ToString());
            EnqueueRpcCall(connectingNode, protocolCommandDto);
        }
Example #8
0
        /// <summary>
        /// Initialize fingertable by calling FindSuccessor for the start value of fingertable entries.
        /// <param name="id"></param>
        /// <param name="connectionNode"></param>
        /// <param name="destinationNode"></param>
        /// <param name="relayServiceAdapter"></param>
        /// <returns>"void"</returns>
        public void FixFingers(uint id, NodeDto connectionNode, Node destinationNode,
                               IDhtRelayServiceAdapter relayServiceAdapter)
        {
            FingerTableEntries[0].Successor = connectionNode;

            for (int i = 1; i < _numberOfFingerTableEntries; i++)
            {
                destinationNode.FindSuccessor(FingerTableEntries[i].Start, connectionNode, destinationNode);
            }
        }
Example #9
0
 /// <summary>
 /// Add entry to the fingertable. The parameter 'node' is added to the fingerTable entry by its id (start) value.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="id"></param>
 /// <returns>"void"</returns>
 public void AddEntry(NodeDto node, uint id)
 {
     for (int i = 0; i < _numberOfFingerTableEntries; i++)
     {
         if (FingerTableEntries[i].Start == id)
         {
             FingerTableEntries[i].Successor = node;
             return;
         }
     }
 }
Example #10
0
        public void Put(NodeDto connectingNode, NodeDto destinationNode, uint key, string value,
                        int currentNumberOfReplicas, uint keyToAdd)
        {
            var protocolCommandDto = new DhtProtocolCommandDto
            {
                Command  = DhtCommand.PUT,
                NodeDto  = destinationNode,
                Key      = key,
                Value    = value,
                KeyToAdd = keyToAdd,
                CurrentNumberOfReplicas = currentNumberOfReplicas,
            };

            EnqueueRpcCall(connectingNode, protocolCommandDto);
        }
Example #11
0
 public void AddEntries(NodeDto successor, uint id)
 {
     for (int i = 0; i < _numberOfFingerTableEntries; i++)
     {
         if (FingerTableEntries[i].Successor == null)
         {
             FingerTableEntries[i].Successor = successor;
         }
         else if (FingerTableEntries[i].Start == id)
         {
             FingerTableEntries[i].Successor = successor;
             return;
         }
     }
 }
        private void OnTimeOutStabilizeHandler()
        {
            // Log.Debug($"Stabilize timeout {Node}");
            NodeDto nextClosestSuccessor = null;

            //TODO: fix connecting node, should be closest successor node from finger table!
            Node.Successor = Node.BootStrapNode;
            _dhtActions.Notify(Node.Successor, Node.Id, Node);

            return;

            if (Node.BootStrapNode.Id.Equals(Node.Id))
            {
                if (nextClosestSuccessor == null || nextClosestSuccessor.Id == Node.Id)
                {
                    Node.Successor = Node.Predecessor;
                }
                else
                {
                    Node.Successor = nextClosestSuccessor;
                }
            }
            else
            {
                //TODO: fix next closest preceding successor in order to relaibly fail nodes, otherwise they will go back to their previous successor who might be offline, so fingertable needs to be updates aswell.
                if (nextClosestSuccessor == null || Node.Successor == null || nextClosestSuccessor?.Id == Node.Id ||
                    nextClosestSuccessor?.Id == Node.Successor?.Id)
                {
                    Node.Successor = Node.BootStrapNode;
                }
                else
                {
                    Node.Successor = nextClosestSuccessor;
                }
            }

            // Log.Debug($"Stabilize timeout successor is {Node.Successor}");
            _dhtActions.Notify(Node.Successor, Node.Id, Node);
        }
Example #13
0
 public void ForwardRequest(NodeDto connectingNode, DhtProtocolCommandDto request)
 {
     EnqueueRpcCall(connectingNode, request);
 }