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; }
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; }
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); }