public void SendRpcCommand(NodeDto connectingNode, DhtProtocolCommandDto protocolCommandDto)
 {
     if (connectingNode == null)
     {
         return;
     }
     Client(connectingNode, protocolCommandDto);
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #8
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);
        }
        public void Client(NodeDto connectingNode,
                           DhtProtocolCommandDto protocolCommandDto)
        {
            var cleanAddress = connectingNode.IpAddress.Replace("127.0.0.1", "localhost");
            var address      = $"tcp://{cleanAddress}:{connectingNode.Port}";

            // client = _clients.FirstOrDefault(socket => socket.Options.LastEndpoint.Equals(address));
            // if (client == null)
            // {
            //     client = new RequestSocket();
            //     _clients.Add(client);
            // }

            try
            {
                client.Connect(address);
                client.TrySendFrame(protocolCommandDto.ToString());
                client?.Disconnect(address);
                // client.TryReceiveSignal(out bool signal);
            }
            catch (NetMQException e)
            {
                Log.Logger.Error(e, e.Message);
                Log.Debug(e.ErrorCode.ToString());
                Log.Debug(e.StackTrace);
                Log.Debug(e.Message);
                Console.WriteLine(e.ErrorCode);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException);
                Console.WriteLine(address);
            }
            catch (Exception exception)
            {
                Log.Logger.Error(exception, exception.Message);
                Log.Debug(exception.Message);
            }
            finally
            {
                // _clients.Remove(client);
                // client?.Disconnect(address);
                // client?.Dispose();
            }
        }
Beispiel #10
0
 public void ForwardRequest(NodeDto connectingNode, DhtProtocolCommandDto request)
 {
     EnqueueRpcCall(connectingNode, request);
 }