Пример #1
0
 public NodeService(string tcpAddress, int tcpPort, string pipeName)
     : this()
 {
     Info = new NetworkNodeInfo("net.tcp://" + tcpAddress + ":" + tcpPort + "/NodeService", "net.pipe://" + "127.0.0.1" + "/NodeService/" + pipeName);
     KnownNodes.Add(Info);
     PsoManager = new PsoRingManager(Info.Id);
 }
Пример #2
0
 public void Run(PsoParameters psoParameters, NetworkNodeInfo mainNodeInfo)
 {
     _mainNodeInfo = mainNodeInfo;
     if (!_psoController.CalculationsRunning)
     {
         _psoController.Run(psoParameters, PsoRingManager.GetProxyParticles());
     }
 }
Пример #3
0
        public VCpuManager(string tcpAddress, int tcpPort, string pipeName, IPsoController psoController = null, IPsoManager psoRingManager = null)
        {
            NetworkNodeManager = new NetworkNodeManager(tcpAddress, tcpPort, pipeName);
            _psoController     = psoController ?? new PsoController(NetworkNodeManager.NodeService.Info.Id);
            PsoRingManager     = psoRingManager ?? new PsoRingManager(NetworkNodeManager.NodeService.Info.Id);
            NetworkNodeManager.NodeService.Info.ProxyParticlesAddresses = PsoRingManager.GetProxyParticlesAddresses();
            var uris = new List <Uri>();

            foreach (var address in NetworkNodeManager.NodeService.Info.ProxyParticlesAddresses)
            {
                var str = address.AbsoluteUri.Replace("0.0.0.0", tcpAddress);
                uris.Add(new Uri(str));
            }
            NetworkNodeManager.NodeService.Info.ProxyParticlesAddresses = uris.ToArray();

            NetworkNodeManager.NodeService.NeighborhoodChanged += PsoRingManager.UpdatePsoNeighborhood;
            NetworkNodeManager.NodeService.RegisterNode        += RunOnNode;
            NetworkNodeManager.NodeService.StartCalculations   += Run;
            NetworkNodeManager.NodeService.StopCalculations    += () => _psoController.Stop();
            PsoRingManager.CommunicationLost     += NetworkNodeManager.NodeService.Deregister;
            _psoController.CalculationsCompleted += Finish;
            NetworkNodeManager.NodeService.RemoteCalculationsFinished += _psoController.RemoteControllerFinished;
        }