コード例 #1
0
 public SerializableAgentInformation(AgentInformation agentInfo)
     : base(agentInfo.PeerNode, agentInfo.AgentId, agentInfo.Contracts, agentInfo.IsInternal)
 {
     _isLocal        = agentInfo.IsLocal;
     _isReachable    = agentInfo.IsReachable;
     _displayData    = agentInfo.DisplayData;
     _lastKnownState = agentInfo.LastKnownState;
 }
コード例 #2
0
        internal RemoteAgentInformation(PeerNode peerNode, string agentId, AgentDisplayData displayData, IEnumerable <string> contracts, bool isInternal, ServiceClientFactory serviceClientFactory)
            : base(peerNode, agentId, contracts, isInternal)
        {
            if (displayData == null)
            {
                throw new ArgumentNullException("displayData");
            }
            if (serviceClientFactory == null)
            {
                throw new ArgumentNullException("serviceClientFactory");
            }

            _displayData = displayData;
            this.ServiceClientFactory = serviceClientFactory;
        }
コード例 #3
0
        private RemoteAgentInformation GetOrRegisterRemoteAgent(PeerNode peer, string agentId, AgentDisplayData displayData, IEnumerable <string> contracts, bool isInternal, bool forceRegister = false)
        {
            if (peer == null)
            {
                throw new ArgumentNullException("peer");
            }
            if (string.IsNullOrEmpty(agentId))
            {
                throw new ArgumentNullException("agentId");
            }
            if (displayData == null)
            {
                throw new ArgumentNullException("displayData");
            }
            if (contracts == null)
            {
                throw new ArgumentNullException("contracts");
            }

            var newLazyRemote = new Lazy <RemoteAgentInformation>(
                () =>
            {
                var serviceClientFactory = new ServiceClientFactory(GetAgentUri(peer, agentId));
                return(new RemoteAgentInformation(peer, agentId, displayData, contracts, isInternal, serviceClientFactory));
            });

            Lazy <RemoteAgentInformation> lazyRemote;

            if (!forceRegister)
            {
                lazyRemote = _remoteAgents.GetOrAdd(agentId, newLazyRemote);
            }
            else
            {
                lazyRemote = _remoteAgents.AddOrUpdate(agentId, newLazyRemote, (id, old) => newLazyRemote);
            }

            // do not broadcast agent immediately, it will be done on next heartbeat (see StartHeartbeat)

            return(lazyRemote.Value);
        }