/** * <summary> * Gets list of all addresses available for connection.</summary> * * <param name="proto">Protocol type.</param> * <returns>List of socket addresses.</returns> */ public IList <IPEndPoint> AvailableAddresses(GridClientProtocol proto) { lock (restAddresses) { if (restAddresses.Count == 0) { int port = proto == GridClientProtocol.Tcp ? TcpPort : HttpPort; if (port != 0) { if (proto == GridClientProtocol.Tcp) { foreach (IPAddress addr in ToHostAddresses(TcpAddresses, TcpHostNames)) { restAddresses.Add(new IPEndPoint(addr, port)); } } else { foreach (IPAddress addr in ToHostAddresses(JettyAddresses, JettyHostNames)) { restAddresses.Add(new IPEndPoint(addr, port)); } } } } } return(new List <IPEndPoint>(restAddresses)); }
/** * <summary> * Constructs connection manager.</summary> * * <param name="clientId">Client ID.</param> * <param name="top">Topology.</param> * <param name="credentials">Connection credentials.</param> * <param name="proto">Connection protocol.</param> * <param name="sslCtx">SSL context to enable secured connection or <c>null</c> to use unsecured one.</param> * <param name="connectTimeout">TCP connection timeout.</param> */ public GridClientConnectionManager(Guid clientId, GridClientTopology top, Object credentials, GridClientProtocol proto, IGridClientSslContext sslCtx, int connectTimeout) { Dbg.Assert(clientId != null, "clientId != null"); Dbg.Assert(top != null, "top != null"); Dbg.Assert(connectTimeout >= 0, "connectTimeout > 0"); this.clientId = clientId; this.credentials = credentials; this.top = top; this.proto = proto; this.sslCtx = sslCtx; this.connectTimeout = connectTimeout; }
/** * <summary> * Constructs connection manager.</summary> * * <param name="clientId">Client ID.</param> * <param name="top">Topology.</param> * <param name="routers">Routers or empty collection to use endpoints from topology info.</param> * <param name="credentials">Connection credentials.</param> * <param name="proto">Connection protocol.</param> * <param name="sslCtx">SSL context to enable secured connection or <c>null</c> to use unsecured one.</param> * <param name="connectTimeout">TCP connection timeout.</param> */ public GridClientConnectionManager(Guid clientId, GridClientTopology top, ICollection <IPEndPoint> routers, Object credentials, GridClientProtocol proto, IGridClientSslContext sslCtx, int connectTimeout) { Dbg.Assert(clientId != null, "clientId != null"); Dbg.Assert(top != null, "top != null"); Dbg.Assert(routers != null, "routers != null"); Dbg.Assert(connectTimeout >= 0, "connectTimeout > 0"); this.clientId = clientId; this.credentials = credentials; this.top = top; this.routers = routers; this.proto = proto; this.sslCtx = sslCtx; this.connectTimeout = connectTimeout; }