Package org.pjdbc.drivers
Class ChaosDriver
java.lang.Object
org.pjdbc.sql.AbstractDriver
org.pjdbc.sql.AbstractProxyDriver
org.pjdbc.drivers.ChaosDriver
- All Implemented Interfaces:
Driver
@DriverCapability(prefix="chaos",
description="Injects configurable failures and latency for resilience testing",
capabilities={"testing","resilience"})
@DriverParameter(name="failureRate",type=FLOAT,description="Probability of throwing SQLException per query",defaultValue="0.0") @DriverParameter(name="latency",type=INTEGER,description="Fixed delay in milliseconds before each query",defaultValue="0",min=0L) @DriverParameter(name="latencyVariance",type=INTEGER,description="Random additional delay up to this value in ms",defaultValue="0",min=0L) @DriverParameter(name="connectionDropRate",type=FLOAT,description="Probability of closing connection unexpectedly",defaultValue="0.0") @DriverParameter(name="resultSetLatency",type=INTEGER,description="Delay in ms for each ResultSet.next() call",defaultValue="0",min=0L) @DriverParameter(name="exceptionMessage",type=STRING,description="Custom exception message",defaultValue="ChaosDriver: Induced failure")
public class ChaosDriver
extends AbstractProxyDriver
ChaosDriver injects configurable failures and latency for resilience testing.
URL format: jdbc:chaos[param=value,...]:jdbc:target:...
Example URLs:
jdbc:chaos[failureRate=0.1]:jdbc:postgresql://localhost/mydb jdbc:chaos[latency=100,latencyVariance=50]:jdbc:h2:mem:test jdbc:chaos[failureRate=0.05,connectionDropRate=0.01]:jdbc:mysql://localhost/db
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration holder for chaos parameters, parsed once at connection time. -
Driver Parameters
URL format:
jdbc:chaos[param=value,...]:<target-url>Parameter Type Default Constraints Description failureRatefloat 0.0- Probability of throwing SQLException per query latencyinteger 0≥ 0 Fixed delay in milliseconds before each query latencyVarianceinteger 0≥ 0 Random additional delay up to this value in ms connectionDropRatefloat 0.0- Probability of closing connection unexpectedly resultSetLatencyinteger 0≥ 0 Delay in ms for each ResultSet.next() call exceptionMessagestring ChaosDriver: Induced failure- Custom exception message Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptsSubName(String subname) protected booleanacceptsSubProtocol(String subprotocol) connect(String url, Properties info) protected CallableStatementproxyCallableStatement(CallableStatement delegate, Connection conn) protected ConnectionproxyConnection(Connection delegate, String url, Properties info, Driver driver) protected PreparedStatementproxyPreparedStatement(PreparedStatement delegate, Connection conn) proxyResultSet(Statement stmt, ResultSet delegate) protected StatementproxyStatement(Statement delegate, Connection conn) Methods inherited from class org.pjdbc.sql.AbstractProxyDriver
getPropertyInfo, isCompositionValidationEnabled, isValidateParametersEnabled, proxyCallableStatement, proxyConnection, proxyConnection, proxyPreparedStatementMethods inherited from class org.pjdbc.sql.AbstractDriver
acceptsProtocol, acceptsURL, getMajorVersion, getMinorVersion, getParentLogger, getUrlParameter, getUrlParameter, getUrlParameters, jdbcCompliant, parseUrl, protocol, subname, subprotocol, validateParameters
-
Constructor Details
-
ChaosDriver
public ChaosDriver()
-
-
Method Details
-
acceptsSubProtocol
- Specified by:
acceptsSubProtocolin classAbstractDriver
-
acceptsSubName
- Overrides:
acceptsSubNamein classAbstractProxyDriver
-
connect
- Specified by:
connectin interfaceDriver- Overrides:
connectin classAbstractProxyDriver- Throws:
SQLException
-
proxyConnection
protected Connection proxyConnection(Connection delegate, String url, Properties info, Driver driver) throws SQLException - Overrides:
proxyConnectionin classAbstractProxyDriver- Throws:
SQLException
-
proxyStatement
- Overrides:
proxyStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyPreparedStatement
protected PreparedStatement proxyPreparedStatement(PreparedStatement delegate, Connection conn) throws SQLException - Overrides:
proxyPreparedStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyCallableStatement
protected CallableStatement proxyCallableStatement(CallableStatement delegate, Connection conn) throws SQLException - Overrides:
proxyCallableStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyResultSet
- Overrides:
proxyResultSetin classAbstractProxyDriver- Throws:
SQLException
-