public async Task RefreshConnectionAsync(AgentConnectionType connectionType, TimeSpan timeout) { Trace.Info($"Refresh {connectionType} VssConnection to get on a different AFD node."); switch (connectionType) { case AgentConnectionType.MessageQueue: _hasMessageConnection = false; _messageConnection = await EstablishVssConnection(_messageConnection.Uri, _messageConnection.Credentials, timeout); _messageTaskAgentClient = _messageConnection.GetClient <TaskAgentHttpClient>(); _hasMessageConnection = true; break; case AgentConnectionType.JobRequest: _hasRequestConnection = false; _requestConnection = await EstablishVssConnection(_requestConnection.Uri, _requestConnection.Credentials, timeout); _requestTaskAgentClient = _requestConnection.GetClient <TaskAgentHttpClient>(); _hasRequestConnection = true; break; case AgentConnectionType.Generic: _hasGenericConnection = false; _genericConnection = await EstablishVssConnection(_genericConnection.Uri, _genericConnection.Credentials, timeout); _genericTaskAgentClient = _genericConnection.GetClient <TaskAgentHttpClient>(); _hasGenericConnection = true; break; default: throw new NotSupportedException(connectionType.ToString()); } }
private void CheckConnection(AgentConnectionType connectionType) { switch (connectionType) { case AgentConnectionType.Generic: if (!_hasGenericConnection) { throw new InvalidOperationException($"SetConnection {AgentConnectionType.Generic}"); } break; case AgentConnectionType.JobRequest: if (!_hasRequestConnection) { throw new InvalidOperationException($"SetConnection {AgentConnectionType.JobRequest}"); } break; case AgentConnectionType.MessageQueue: if (!_hasMessageConnection) { throw new InvalidOperationException($"SetConnection {AgentConnectionType.MessageQueue}"); } break; default: throw new NotSupportedException(connectionType.ToString()); } }
public void SetConnectionTimeout(AgentConnectionType connectionType, TimeSpan timeout) { Trace.Info($"Set {connectionType} VssConnection's timeout to {timeout.TotalSeconds} seconds."); switch (connectionType) { case AgentConnectionType.JobRequest: _requestConnection.Settings.SendTimeout = timeout; break; case AgentConnectionType.MessageQueue: _messageConnection.Settings.SendTimeout = timeout; break; case AgentConnectionType.Generic: _genericConnection.Settings.SendTimeout = timeout; break; default: throw new NotSupportedException(connectionType.ToString()); } }