Пример #1
0
        async Task GetNodeClodeInfo(FetchQueueItem qinfo)
        {
            var node = qinfo.Node;

            try
            {
                var turi = new Uri(new Uri(node.Url), "clouds");
                var resp = await GetNodeWebResp(turi).ConfigureAwait(false);

                if ((resp != null) && resp.IsSuccessStatusCode)
                {
                    qinfo.LocalNode.Url     = qinfo.Node.Url;
                    qinfo.LocalNode.Fetched = true;
                    await OnNewNodeDiscovered(qinfo.LocalNode, resp).ConfigureAwait(false);
                }
                else
                {//do nothing
                }
            }
            catch (Exception exception)
            {
                if (exception.HResult != -2147467259)
                {
                    logger.LogError(exception, $"Error getting info for node: {node.Url}");
                }
            }finally
            {
                qinfo.FinishTask?.SetResult(0);
            }
        }
Пример #2
0
        private void NodeInfoForOneNode(NodeInfoInNet x)
        {
            LocalNodeInfo nod = null;

            lock (LocalNodes)
            {
                nod = LocalNodes.FirstOrDefault(y => y.NodeId == x.NodeGuid);
                if (nod == null)
                {
                    nod = new LocalNodeInfo {
                        NodeId          = x.NodeGuid,
                        Fetched         = false,
                        PCVersion       = x.PCVersion,
                        StatusTimeStamp = x.TimeStamp,
                    };
                    LocalNodes.Add(nod);
                }
                else
                {
                    if (nod.StatusTimeStamp > x.TimeStamp)
                    {
                        return;
                    }
                    if (nod.StatusTimeStamp == x.TimeStamp)
                    {
                        if (nod.Fetched)
                        {
                            return;
                        }
                    }
                    else
                    {
                        nod.Fetched         = false;
                        nod.StatusTimeStamp = x.TimeStamp;
                    }
                    //do not set LocalNodeInfo.Url in this block
                }
            }
            if (nod.NodeId == ThisNodeID)//self
            {
                nod.Url = x.Url = $"http://localhost:{WebServerPort}/";
            }

            var t = new FetchQueueItem {
                Node       = x,
                LocalNode  = nod,
                FinishTask = new TaskCompletionSource <int>()
            };

            fetchCloudInfo.Post(t);
            t.FinishTask.Task.Wait(10 * 1000);
        }
Пример #3
0
        public void SyncPCNodes(string PcId)
        {
            List <LocalNodeInfo> nods;

            lock (LocalNodes)
            {
                nods = LocalNodes.Where(x => x.PcIds.Contains(PcId)).ToList();
            }

            foreach (var nod in nods)
            {
                var t = new FetchQueueItem {
                    Node = new NodeInfoInNet {
                        NodeGuid = nod.NodeId, PCVersion = nod.PCVersion, TimeStamp = nod.StatusTimeStamp, Url = nod.Url
                    },
                    LocalNode  = nod,
                    FinishTask = null
                };
                fetchCloudInfo.Post(t);
            }
        }