Ejemplo n.º 1
0
 private bool SetSlave(NodeConfiguration slave, NodeConfiguration master)
 {
     var socket = AssertConnection(slave);
     if (socket == null) return false;
     return SendMessageAndWaitForAck(socket,
                                     new Message("slaveof",
                                                 new[] {master.Host, master.ManagementPort.ToString("G")}));
 }
Ejemplo n.º 2
0
 private TcpClient AssertConnection(NodeConfiguration node)
 {
     try
     {
         TcpClient client;
         if (_nodeConnections.TryGetValue(node, out client)) return client;
         client = new TcpClient(node.Host, node.ManagementPort);
         _nodeConnections[node] = client;
         return client;
     }
     catch (SocketException ex)
     {
         // Can't connect to endpoint at the moment
         return null;
     }
 }
Ejemplo n.º 3
0
 private bool SendMasterMessage(NodeConfiguration master)
 {
     var socket = AssertConnection(master);
     if (socket == null) return false;
     var msg = new Message("master", String.Empty);
     using(var writer = msg.GetContentWriter())
     {
         _config.MasterConfiguration.WriteTo(writer);
     }
     bool masterIsSet = SendMessageAndWaitForAck(socket,msg);
     if (masterIsSet)
     {
         _master = master;
     }
     return masterIsSet;
 }