Package com.yahoo.vespa.config
Class JRTConnectionPool
- java.lang.Object
-
- com.yahoo.vespa.config.JRTConnectionPool
-
- All Implemented Interfaces:
ConnectionPool
,java.lang.AutoCloseable
public class JRTConnectionPool extends java.lang.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 calling {#linkswitchConnection()
} (it will continue to use the same connection if there is only one source). The current connection is available withgetCurrent()
. When callingsetError(Connection, int)
,switchConnection()
will always be called.- Author:
- Gunnar Gauslaa Bergem, hmusum
-
-
Constructor Summary
Constructors Constructor Description JRTConnectionPool(ConfigSourceSet sourceSet)
JRTConnectionPool(ConfigSourceSet sourceSet, java.lang.String poolName)
-
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()
com.yahoo.jrt.Supervisor
getSupervisor()
JRTConnection
initialize()
void
setError(Connection connection, int errorCode)
Sets the supplied Connection to have an error, implementations are expected to callConnectionPool.switchConnection(Connection)
after setting state for the supplied Connection.JRTConnection
switchConnection(Connection failingConnection)
Switches to another (healthy, if one exists) Connection instance.java.lang.String
toString()
JRTConnectionPool
updateSources(ConfigSourceSet sourceSet)
JRTConnectionPool
updateSources(java.util.List<java.lang.String> addresses)
-
-
-
Constructor Detail
-
JRTConnectionPool
public JRTConnectionPool(ConfigSourceSet sourceSet)
-
JRTConnectionPool
public JRTConnectionPool(ConfigSourceSet sourceSet, java.lang.String poolName)
-
-
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 one exists) Connection instance. Returns the resulting Connection. See alsoConnectionPool.setError(Connection, int)
- Specified by:
switchConnection
in interfaceConnectionPool
- Returns:
- a Connection
-
initialize
public JRTConnection initialize()
-
setError
public void setError(Connection connection, int errorCode)
Description copied from interface:ConnectionPool
Sets the supplied Connection to have an error, implementations are expected to callConnectionPool.switchConnection(Connection)
after setting state for the supplied Connection.- Specified by:
setError
in interfaceConnectionPool
-
updateSources
public JRTConnectionPool updateSources(java.util.List<java.lang.String> addresses)
-
updateSources
public JRTConnectionPool updateSources(ConfigSourceSet sourceSet)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceConnectionPool
-
getSize
public int getSize()
- Specified by:
getSize
in interfaceConnectionPool
-
getSupervisor
public com.yahoo.jrt.Supervisor getSupervisor()
- Specified by:
getSupervisor
in interfaceConnectionPool
-
-