/// <summary>
 /// constructor
 /// </summary>
 public Node(NodeInfo nodeInfo, IConnectionProxy proxy, IElectionAlgorithm electionAlgorithm
             , IRicartSyncAlgorithmClient ricartSyncAlgorithmClient, ICentralizedSyncAlgorithmClient centralizedSyncAlgorithmClient)
 {
     _proxy                    = proxy;
     _nodeInfo                 = nodeInfo;
     _electionAlgorithm        = electionAlgorithm;
     _ricartSyncAlgClient      = ricartSyncAlgorithmClient;
     _centralizedSyncAlgClient = centralizedSyncAlgorithmClient;
 }
 /// <summary>
 /// constructor
 /// </summary>
 public Node(NodeInfo nodeInfo, IConnectionProxy proxy, IElectionAlgorithm electionAlgorithm
     , IRicartSyncAlgorithmClient ricartSyncAlgorithmClient, ICentralizedSyncAlgorithmClient centralizedSyncAlgorithmClient)
 {
     _proxy = proxy;
     _nodeInfo = nodeInfo;
     _electionAlgorithm = electionAlgorithm;
     _ricartSyncAlgClient = ricartSyncAlgorithmClient;
     _centralizedSyncAlgClient = centralizedSyncAlgorithmClient;
 }
 /// <summary>
 /// Send election message to target host
 /// </summary>
 public void SendElectionMsg(NodeInfo target, IConnectionProxy proxy)
 {
     //var proxy1 = XmlRpcProxyGen.Create<IConnectionProxy>();
     proxy.Url = target.GetFullUrl();
     if (proxy.ReceiveElectionMsg(_node.Id.ToString()))
     {
         // when target response
         _isThisNodeLost.Set();  // declare this node is lost
     }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public CentralizedSyncAlgorithm(NodeInfo nodeInfo, IConnectionProxy proxy)
        {
            // State and Queue is only for Master Node
            State = AccessState.Released;
            Proxy = proxy;
            LocalNodeInfo = nodeInfo;

            Client = new CentralizedSyncAlgorithmClient(this);
            Server = new CentralizedSyncAlgorithmServer(this);
        }
 /// <summary>
 /// Send election message to target host
 /// </summary>
 public void SendElectionMsg(NodeInfo target, IConnectionProxy proxy)
 {
     //var proxy1 = XmlRpcProxyGen.Create<IConnectionProxy>();
     proxy.Url = target.GetFullUrl();
     if (proxy.ReceiveElectionMsg(_node.Id.ToString()))
     {
         // when target response
         _isThisNodeLost.Set();  // declare this node is lost
     }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public CentralizedSyncAlgorithm(NodeInfo nodeInfo, IConnectionProxy proxy)
        {
            // State and Queue is only for Master Node
            State         = AccessState.Released;
            Proxy         = proxy;
            LocalNodeInfo = nodeInfo;

            Client = new CentralizedSyncAlgorithmClient(this);
            Server = new CentralizedSyncAlgorithmServer(this);
        }
        /// <summary>
        /// constructor
        /// </summary>
        public RicartSyncAlgorithm(NodeInfo nodeInfo, IConnectionProxy proxy)
        {
            State = AccessState.Released;
            LocalId = nodeInfo.Id;
            Proxy = proxy;
            LocalNodeInfo = nodeInfo;
            _clock = new ExtendedLamportClock(LocalId);

            Client = new RicartSyncAlgorithmClient(this);
            Server = new RicartSyncAlgorithmServer(this);
        }
Beispiel #8
0
        /// <summary>
        /// constructor
        /// </summary>
        public RicartSyncAlgorithm(NodeInfo nodeInfo, IConnectionProxy proxy)
        {
            State         = AccessState.Released;
            LocalId       = nodeInfo.Id;
            Proxy         = proxy;
            LocalNodeInfo = nodeInfo;
            _clock        = new ExtendedLamportClock(LocalId);

            Client = new RicartSyncAlgorithmClient(this);
            Server = new RicartSyncAlgorithmServer(this);
        }
        /// <summary>
        /// Send Req message to a node
        /// </summary>
        private void SendSyncMsg(IConnectionProxy proxy1, NodeInfo toNode)
        {
            var logicClockTs = _module.Clock.SendEventHandle();

            _module.AddToAcceptList(toNode.GetIpAndPort());
            var urlToSend = toNode.GetFullUrl();

            //LogHelper.WriteStatus("CLIENT: SEND REQ FROM: [" + _module1.LocalNodeInfo.GetIpAndPort() + "] TO: [" +
            //                      proxy1.Url + "]");
            //.WriteLine("CLIENT: SEND REQ FROM: " + _module1.LocalNodeInfo.GetIpAndPort() + " TO: " + _module1.Proxy1.Url);
            lock (Shared.SendLock)
            {
                proxy1.Url = urlToSend;
                proxy1.GetSyncRequest_RA(logicClockTs.ToString(), _module.LocalNodeInfo.Id.ToString(), _module.LocalNodeInfo.GetIpAndPort());
            }
        }
 public void StartTest()
 {
     _connectionProxyMock = Substitute.For<IConnectionProxy>();
     _httpClientMock = Substitute.For<IHttpClient>();
     _responseMock = Substitute.For<IResponse>();
 }
 /// <summary>
 /// Send Sync Req to Master node
 /// </summary>
 private void SendSyncMsg(IConnectionProxy proxy, NodeInfo toNode)
 {
     proxy.Url = toNode.GetFullUrl();
     _module.Proxy.GetSyncRequest_CT(_module.LocalNodeInfo.Id.ToString(), _module.LocalNodeInfo.GetIpAndPort());
 }
 /// <summary>
 /// Send Sync Req to Master node
 /// </summary>
 private void SendSyncMsg(IConnectionProxy proxy, NodeInfo toNode)
 {
     proxy.Url = toNode.GetFullUrl();
     _module.Proxy.GetSyncRequest_CT(_module.LocalNodeInfo.Id.ToString(), _module.LocalNodeInfo.GetIpAndPort());
 }
 public FakePersistentConnectionPublisher(IConnectionProxy connectionProxy)
     : base(connectionProxy)
 {
 }
 public Bully(NodeInfo node, IConnectionProxy proxy)
 {
     _node       = node;
     _proxy      = proxy;
     _isExecuted = false;
 }
 /// <summary>Initializes a new instance of the <see cref="CloseConnectionListener"/> class.</summary>
 /// <param name="connection">The connection.</param>
 /// <param name="latch">The latch.</param>
 public CloseConnectionListener(IConnectionProxy connection, CountdownEvent latch)
 {
     this.connection = connection.GetTargetConnection();
     this.latch      = latch;
 }
 /// <summary>Initializes a new instance of the <see cref="CloseConnectionListener"/> class.</summary>
 /// <param name="connection">The connection.</param>
 /// <param name="latch">The latch.</param>
 public CloseConnectionListener(IConnectionProxy connection, CountdownEvent latch)
 {
     this.connection = connection.GetTargetConnection();
     this.latch = latch;
 }
 public Bully(NodeInfo node, IConnectionProxy proxy)
 {
     _node = node;
     _proxy = proxy;
     _isExecuted = false;
 }
        /// <summary>
        /// Send Req message to a node
        /// </summary>
        private void SendSyncMsg(IConnectionProxy proxy1, NodeInfo toNode)
        {
            var logicClockTs = _module.Clock.SendEventHandle();

            _module.AddToAcceptList(toNode.GetIpAndPort());
            var urlToSend = toNode.GetFullUrl();

            //LogHelper.WriteStatus("CLIENT: SEND REQ FROM: [" + _module1.LocalNodeInfo.GetIpAndPort() + "] TO: [" +
            //                      proxy1.Url + "]");
            //.WriteLine("CLIENT: SEND REQ FROM: " + _module1.LocalNodeInfo.GetIpAndPort() + " TO: " + _module1.Proxy1.Url);
            lock (Shared.SendLock)
            {
                proxy1.Url = urlToSend;
                proxy1.GetSyncRequest_RA(logicClockTs.ToString(), _module.LocalNodeInfo.Id.ToString(), _module.LocalNodeInfo.GetIpAndPort());
            }
        }