예제 #1
0
 public void SendRpcCommand(NodeDto connectingNode, DhtProtocolCommandDto protocolCommandDto)
 {
     if (connectingNode == null)
     {
         return;
     }
     Client(connectingNode, protocolCommandDto);
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #9
0
        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();
            }
        }
예제 #10
0
 public void ForwardRequest(NodeDto connectingNode, DhtProtocolCommandDto request)
 {
     EnqueueRpcCall(connectingNode, request);
 }