Class FailoverProxy
- java.lang.Object
-
- org.mariadb.jdbc.internal.failover.FailoverProxy
-
- All Implemented Interfaces:
InvocationHandler
public class FailoverProxy extends Object implements InvocationHandler
-
-
Field Summary
Fields Modifier and Type Field Description ReentrantLocklockLruTraceCachetraceCache
-
Constructor Summary
Constructors Constructor Description FailoverProxy(Listener listener, ReentrantLock lock, LruTraceCache traceCache)Proxy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListenergetListener()booleanhasToHandleFailover(SQLException exception)Check if this Sqlerror is a connection exception.Objectinvoke(Object proxy, Method method, Object[] args)Proxy that catch Protocol call, to permit to catch errors and handle failover when multiple hosts.voidreconnect()Launch reconnect implementation.
-
-
-
Field Detail
-
lock
public final ReentrantLock lock
-
traceCache
public final LruTraceCache traceCache
-
-
Constructor Detail
-
FailoverProxy
public FailoverProxy(Listener listener, ReentrantLock lock, LruTraceCache traceCache) throws SQLException
Proxy constructor.- Parameters:
listener- failover implementation.lock- synchronisation locktraceCache- trace cache- Throws:
SQLException- if connection error occur
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Proxy that catch Protocol call, to permit to catch errors and handle failover when multiple hosts.- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- the current protocolmethod- the called method on the protocolargs- methods parameters- Returns:
- protocol method result
- Throws:
Throwable- the method throwed error if not catch by failover
-
hasToHandleFailover
public boolean hasToHandleFailover(SQLException exception)
Check if this Sqlerror is a connection exception. if that's the case, must be handle by failovererror codes : 08000 : connection exception 08001 : SQL client unable to establish SQL connection 08002 : connection name in use 08003 : connection does not exist 08004 : SQL server rejected SQL connection 08006 : connection failure 08007 : transaction resolution unknown 70100 : connection was killed if error code is "1927"
- Parameters:
exception- the Exception- Returns:
- true if there has been a connection error that must be handled by failover
-
reconnect
public void reconnect() throws SQLExceptionLaunch reconnect implementation.- Throws:
SQLException- exception
-
getListener
public Listener getListener()
-
-