Package com.yahoo.vespa.config
Class JRTConnectionPool
- java.lang.Object
-
- com.yahoo.vespa.config.JRTConnectionPool
-
- All Implemented Interfaces:
ConnectionPool
,AutoCloseable
public class JRTConnectionPool extends Object implements ConnectionPool
A pool of JRT connections to a config source (either a config server or a config proxy). The current connection is chosen randomly when callingswitchConnection(Connection)
(it will continue to use the same connection if there is only one source). The current connection is available withgetCurrent()
.- Author:
- Gunnar Gauslaa Bergem, hmusum
-
-
Constructor Summary
Constructors Constructor Description JRTConnectionPool(ConfigSourceSet sourceSet)
JRTConnectionPool(ConfigSourceSet sourceSet, com.yahoo.jrt.Supervisor supervisor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSources(ConfigSourceSet sourceSet)
void
close()
JRTConnection
getCurrent()
Returns the current JRTConnection instanceint
getSize()
protected List<JRTConnection>
getSources()
JRTConnection
initialize()
protected JRTConnection
pickNewConnectionRandomly(List<JRTConnection> sources)
JRTConnection
switchConnection(Connection failingConnection)
Switches to another (healthy, if possible) Connection instance.String
toString()
JRTConnectionPool
updateSources(ConfigSourceSet sourceSet)
JRTConnectionPool
updateSources(List<String> addresses)
-
-
-
Constructor Detail
-
JRTConnectionPool
public JRTConnectionPool(ConfigSourceSet sourceSet)
-
JRTConnectionPool
public JRTConnectionPool(ConfigSourceSet sourceSet, com.yahoo.jrt.Supervisor supervisor)
-
-
Method Detail
-
addSources
public void addSources(ConfigSourceSet sourceSet)
-
getCurrent
public JRTConnection getCurrent()
Returns the current JRTConnection instance- Specified by:
getCurrent
in interfaceConnectionPool
- Returns:
- a JRTConnection
-
switchConnection
public JRTConnection switchConnection(Connection failingConnection)
Description copied from interface:ConnectionPool
Switches to another (healthy, if possible) Connection instance.ConnectionPool.getCurrent()
will return this instance afterwards, which is also the return value.- Specified by:
switchConnection
in interfaceConnectionPool
- Returns:
- a Connection
-
initialize
public JRTConnection initialize()
-
pickNewConnectionRandomly
protected JRTConnection pickNewConnectionRandomly(List<JRTConnection> sources)
-
getSources
protected List<JRTConnection> getSources()
-
updateSources
public JRTConnectionPool updateSources(List<String> addresses)
-
updateSources
public JRTConnectionPool updateSources(ConfigSourceSet sourceSet)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnectionPool
-
getSize
public int getSize()
- Specified by:
getSize
in interfaceConnectionPool
-
-