private void CheckPredecessorHandler(object?sender, System.EventArgs e) { CheckPredecessorEventArgs eventArgs = (CheckPredecessorEventArgs)e; NodeDto destinationNode = eventArgs.DestinationNode; _dhtActions.CheckPredecessorResponse(destinationNode, Node.Id, Node); }
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); }
public void FoundSuccessor(NodeDto destinationNode, uint key, NodeDto foundSuccessor) { var protocolCommandDto = new DhtProtocolCommandDto { Command = DhtCommand.FOUND_SUCCESSOR, Key = key, NodeDto = foundSuccessor }; EnqueueRpcCall(destinationNode, protocolCommandDto); }
public void Stabilize(NodeDto connectingNode, uint key, NodeDto destinationNode) { var protocolCommandDto = new DhtProtocolCommandDto { Command = DhtCommand.STABILIZE, Key = key, NodeDto = destinationNode }; EnqueueRpcCall(connectingNode, protocolCommandDto); }
public void Notify(NodeDto connectingNode, uint key, NodeDto destinationNode) { var protocolCommandDto = new DhtProtocolCommandDto { NodeDto = destinationNode, Key = key, Command = DhtCommand.NOTIFY }; EnqueueRpcCall(connectingNode, protocolCommandDto); }
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); }
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); }
/// <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); } }
/// <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; } } }
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); }
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); }
public void ForwardRequest(NodeDto connectingNode, DhtProtocolCommandDto request) { EnqueueRpcCall(connectingNode, request); }