Class GridClientConnectionManagerAdapter
- java.lang.Object
-
- org.apache.ignite.internal.client.impl.connection.GridClientConnectionManagerAdapter
-
- All Implemented Interfaces:
GridClientConnectionManager
- Direct Known Subclasses:
GridClientConnectionManagerOsImpl
public abstract class GridClientConnectionManagerAdapter extends Object implements GridClientConnectionManager
Cached connections manager.
-
-
Field Summary
Fields Modifier and Type Field Description protected GridClientConfigurationcfgClient configuration.
-
Constructor Summary
Constructors Modifier Constructor Description protectedGridClientConnectionManagerAdapter(UUID clientId, SSLContext sslCtx, GridClientConfiguration cfg, Collection<InetSocketAddress> routers, GridClientTopology top, @Nullable Byte marshId, boolean routerClient, boolean beforeNodeStart)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected GridClientConnectionconnect(@Nullable UUID nodeId, InetSocketAddress addr)Create new connection to specified server.protected GridClientConnectionconnect(@Nullable UUID nodeId, Collection<InetSocketAddress> srvs)Creates a connected facade and returns it.GridClientConnectionconnection(@Nullable UUID nodeId, Collection<InetSocketAddress> srvs)Returns connection to one of the given addresses.GridClientConnectionconnection(Collection<InetSocketAddress> srvs)Returns connection to node using given server addresses.GridClientConnectionconnection(GridClientNode node)Gets active communication facade.voidinit(Collection<InetSocketAddress> srvs)Tries to open initial connection and fetch topology using given server addresses.protected abstract voidinit0()Additional initialization.voidstop(boolean waitCompletion)Closes all opened connections.voidterminateConnection(GridClientConnection conn, GridClientNode node, Throwable e)Callback method, which should be called by clients when they get connectivity errors.
-
-
-
Field Detail
-
cfg
protected final GridClientConfiguration cfg
Client configuration.
-
-
Constructor Detail
-
GridClientConnectionManagerAdapter
protected GridClientConnectionManagerAdapter(UUID clientId, SSLContext sslCtx, GridClientConfiguration cfg, Collection<InetSocketAddress> routers, GridClientTopology top, @Nullable @Nullable Byte marshId, boolean routerClient, boolean beforeNodeStart) throws GridClientException
- Parameters:
clientId- Client ID.sslCtx- SSL context to enable secured connection ornullto use unsecured one.cfg- Client configuration.routers- Routers or empty collection to use endpoints from topology info.top- Topology.marshId- Marshaller ID.beforeNodeStart- Connecting to a node before starting it without getting/updating topology.- Throws:
GridClientException- In case of error.
-
-
Method Detail
-
init
public void init(Collection<InetSocketAddress> srvs) throws GridClientException, InterruptedException
Tries to open initial connection and fetch topology using given server addresses.- Specified by:
initin interfaceGridClientConnectionManager- Parameters:
srvs- Collectionserver addresses. - Throws:
GridClientAuthenticationException- If connection failed to authenticate on server.GridClientException- If manager failed to initialise,InterruptedException- If manager was interrupted while waiting for connection.
-
init0
protected abstract void init0() throws GridClientExceptionAdditional initialization.- Throws:
GridClientException- In case of error.
-
connection
public GridClientConnection connection(GridClientNode node) throws GridClientClosedException, GridServerUnreachableException, InterruptedException
Gets active communication facade.- Specified by:
connectionin interfaceGridClientConnectionManager- Parameters:
node- Remote node to which connection should be established.- Returns:
- Connection to use for operations, targeted for the given node.
- Throws:
GridServerUnreachableException- If none of the servers can be reached after the exception.GridClientClosedException- If client was closed manually.InterruptedException- If connection was interrupted.
-
connection
public GridClientConnection connection(@Nullable @Nullable UUID nodeId, Collection<InetSocketAddress> srvs) throws GridServerUnreachableException, GridClientClosedException, InterruptedException
Returns connection to one of the given addresses.- Parameters:
nodeId-UUIDof node for mapping with connection.nullif no need of mapping.srvs- Collection of addresses to connect to.- Returns:
- Connection to use for operations, targeted for the given node.
- Throws:
GridServerUnreachableException- If connection can't be established.GridClientClosedException- If connections manager has been closed already.InterruptedException- If connection was interrupted.
-
connect
protected GridClientConnection connect(@Nullable @Nullable UUID nodeId, Collection<InetSocketAddress> srvs) throws GridServerUnreachableException, InterruptedException
Creates a connected facade and returns it. Called either from constructor or inside a write lock.- Parameters:
nodeId-UUIDof node for mapping with connection.nullif no need of mapping.srvs- List of server addresses that this method will try to connect to.- Returns:
- Established connection.
- Throws:
GridServerUnreachableException- If none of the servers can be reached.InterruptedException- If connection was interrupted.
-
connect
protected GridClientConnection connect(@Nullable @Nullable UUID nodeId, InetSocketAddress addr) throws IOException, GridClientException, InterruptedException
Create new connection to specified server.- Parameters:
nodeId-UUIDof node for mapping with connection.nullif no need of mapping.addr- Remote socket to connect.- Returns:
- Established connection.
- Throws:
IOException- If connection failed.GridClientException- If protocol error happened.InterruptedException- If thread was interrupted before connection was established.
-
terminateConnection
public void terminateConnection(GridClientConnection conn, GridClientNode node, Throwable e)
Callback method, which should be called by clients when they get connectivity errors. It's main purpose is to allow connection manager to terminate broken connection early and, try to establish a new one for the consequentGridClientConnectionManager.connection(GridClientNode)calls.- Specified by:
terminateConnectionin interfaceGridClientConnectionManager- Parameters:
conn- Failed connection.node- Connected node.e- Error that caused connection termination.
-
stop
public void stop(boolean waitCompletion)
Closes all opened connections.- Specified by:
stopin interfaceGridClientConnectionManager- Parameters:
waitCompletion- Iftruewaits for all pending requests to be proceeded.
-
connection
public GridClientConnection connection(Collection<InetSocketAddress> srvs) throws GridClientException, InterruptedException
Returns connection to node using given server addresses.- Specified by:
connectionin interfaceGridClientConnectionManager- Parameters:
srvs- Server addresses.- Returns:
- Established connection.
- Throws:
GridClientException- If failed.InterruptedException- If was interrupted while waiting for connection to be established.
-
-