mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
address review comments
This commit is contained in:
@@ -75,7 +75,7 @@ public class JDBCOpMapper implements OpMapper<JDBCOp> {
|
||||
|
||||
// CREATE|DROP TABLE|VIEW uses 'execute' (as opposed to 'executeQuery' which returns a 'ResultSet')
|
||||
// https://jdbc.postgresql.org/documentation/query/#example54dropping-a-table-in-jdbc
|
||||
case jdbcQuery -> new JDBCExecuteOpDispenser(adapter, connectionLongFunc, op, opType.targetFunction);
|
||||
case query -> new JDBCExecuteOpDispenser(adapter, connectionLongFunc, op, opType.targetFunction);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ package io.nosqlbench.adapter.jdbc;
|
||||
*/
|
||||
public enum JDBCOpType {
|
||||
//See https://jdbc.postgresql.org/documentation/query/
|
||||
jdbcQuery,
|
||||
query,
|
||||
}
|
||||
|
||||
@@ -52,28 +52,15 @@ public class JDBCSpace implements AutoCloseable {
|
||||
private HikariDataSource createClient(NBConfiguration cfg) {
|
||||
hikariConfig = new HikariConfig();
|
||||
|
||||
Optional<String> url = cfg.getOptional("url");
|
||||
if (url.isEmpty()) {
|
||||
throw new OpConfigError("url option is required.");
|
||||
} else {
|
||||
hikariConfig.setJdbcUrl(url.get());
|
||||
}
|
||||
|
||||
Optional<String> serverNames = cfg.getOptional("serverName");
|
||||
if (serverNames.isPresent()) {
|
||||
hikariConfig.addDataSourceProperty("serverName", serverNames.get());
|
||||
} else {
|
||||
throw new OpConfigError("Server name option is required.");
|
||||
}
|
||||
hikariConfig.setJdbcUrl(cfg.get("url"));
|
||||
hikariConfig.addDataSourceProperty("serverName", cfg.get("serverName"));
|
||||
|
||||
Optional<String> databaseName = cfg.getOptional("databaseName");
|
||||
if (databaseName.isPresent()) {
|
||||
hikariConfig.addDataSourceProperty("databaseName", databaseName.get());
|
||||
} else {
|
||||
throw new OpConfigError("Database name option is required.");
|
||||
}
|
||||
|
||||
int portNumber = Integer.parseInt(cfg.getOptional("portNumber").orElse("26257"));
|
||||
int portNumber = Integer.parseInt(cfg.get("portNumber"));
|
||||
hikariConfig.addDataSourceProperty("portNumber", portNumber);
|
||||
|
||||
Optional<String> user = cfg.getOptional("user");
|
||||
@@ -90,23 +77,17 @@ public class JDBCSpace implements AutoCloseable {
|
||||
} else {
|
||||
if (user.isPresent()) {
|
||||
throw new OpConfigError("Both user and password options are required. Only user is supplied in this case.");
|
||||
// Maybe simply ignore user and move on as opposed to throwing an error?
|
||||
//logger.warn(() -> "Both user and password options are required. Only user is supplied in this case and it will be ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
Optional<Boolean> ssl = cfg.getOptional(Boolean.class, "ssl");
|
||||
if (ssl.isPresent()) {
|
||||
hikariConfig.addDataSourceProperty("ssl", ssl.get());
|
||||
} else {
|
||||
hikariConfig.addDataSourceProperty("ssl", false);
|
||||
}
|
||||
hikariConfig.addDataSourceProperty("ssl", ssl.orElse(false));
|
||||
|
||||
Optional<String> sslMode = cfg.getOptional("sslmode");
|
||||
if (sslMode.isPresent()) {
|
||||
hikariConfig.addDataSourceProperty("sslmode", sslMode.get());
|
||||
} else {
|
||||
hikariConfig.addDataSourceProperty("sslmode", "verify-full");
|
||||
hikariConfig.addDataSourceProperty("sslmode", "prefer");
|
||||
}
|
||||
|
||||
Optional<String> sslCert = cfg.getOptional("sslcert");
|
||||
@@ -121,25 +102,22 @@ public class JDBCSpace implements AutoCloseable {
|
||||
hikariConfig.addDataSourceProperty("sslrootcert", sslRootCert.get());
|
||||
}
|
||||
|
||||
Optional<String> applicationName = cfg.getOptional("applicationName");
|
||||
hikariConfig.addDataSourceProperty("applicationName", applicationName.orElse("NoSQLBench"));
|
||||
hikariConfig.addDataSourceProperty("applicationName", cfg.get("applicationName"));
|
||||
hikariConfig.addDataSourceProperty("rewriteBatchedInserts", cfg.getOrDefault("rewriteBatchedInserts", true));
|
||||
|
||||
Optional<Boolean> rewriteBatchedInserts = cfg.getOptional(Boolean.class, "rewriteBatchedInserts");
|
||||
hikariConfig.addDataSourceProperty("rewriteBatchedInserts", rewriteBatchedInserts.orElse(true));
|
||||
// We're managing the auto-commit behavior of connections ourselves and hence disabling the auto-commit.
|
||||
//Optional<Boolean> autoCommit = cfg.getOptional(Boolean.class, "autoCommit");
|
||||
hikariConfig.setAutoCommit(false);
|
||||
|
||||
//Maybe always disable auto-commit since we manage ourselves?
|
||||
Optional<Boolean> autoCommit = cfg.getOptional(Boolean.class, "autoCommit");
|
||||
hikariConfig.setAutoCommit(autoCommit.orElse(false));
|
||||
|
||||
int maximumPoolSize = Integer.parseInt(cfg.getOptional("maximumPoolSize").orElse("40"));
|
||||
hikariConfig.setMaximumPoolSize(maximumPoolSize);
|
||||
|
||||
int keepaliveTime = Integer.parseInt(cfg.getOptional("keepaliveTime").orElse("150000"));
|
||||
hikariConfig.setKeepaliveTime(keepaliveTime);
|
||||
hikariConfig.setMaximumPoolSize(Integer.parseInt(cfg.get("maximumPoolSize")));
|
||||
hikariConfig.setKeepaliveTime(Integer.parseInt(cfg.get("keepaliveTime")));
|
||||
hikariConfig.setMaximumPoolSize(Integer.parseInt(cfg.get("maximumPoolSize")));
|
||||
|
||||
HikariDataSource hds = new HikariDataSource(hikariConfig);
|
||||
try {
|
||||
this.connection = hds.getConnection();
|
||||
// We're taking an opinionated approach here and managing the commit ourselves.
|
||||
this.getConnection().setAutoCommit(false);
|
||||
} catch (Exception ex) {
|
||||
String exp = "Exception occurred while attempting to create a connection using the HikariDataSource";
|
||||
logger.error(exp, ex);
|
||||
@@ -155,41 +133,41 @@ public class JDBCSpace implements AutoCloseable {
|
||||
.add(Param.defaultTo("serverName", "localhost").setDescription("The host name of the server. Defaults to 'localhost'"))
|
||||
.add(Param.optional("databaseName").setDescription("The database name. The default is to connect to a database with the same name as the user name used to connect to the server."))
|
||||
// See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby & https://jdbc.postgresql.org/documentation/use/
|
||||
.add(Param.defaultTo("portNumber", 5432).setDescription("The port number the server is listening on. Defaults to the PostgreSQL® standard port number (5432)"))
|
||||
.add(Param.optional("user"))
|
||||
.add(Param.optional("password"))
|
||||
.add(Param.optional("ssl"))
|
||||
.add(Param.optional("sslmode"))
|
||||
.add(Param.optional("sslcert"))
|
||||
.add(Param.optional("sslrootcert"))
|
||||
.add(Param.optional("applicationName"))
|
||||
.add(Param.optional("rewriteBatchedInserts"))
|
||||
.add(Param.optional("autoCommit"))
|
||||
.add(Param.optional("connectionTimeout"))
|
||||
.add(Param.optional("idleTimeout"))
|
||||
.add(Param.optional("keepaliveTime"))
|
||||
.add(Param.optional("maxLifetime"))
|
||||
.add(Param.optional("connectionTestQuery"))
|
||||
.add(Param.optional("minimumIdle"))
|
||||
.add(Param.optional("maximumPoolSize"))
|
||||
.add(Param.optional("metricRegistry"))
|
||||
.add(Param.optional("healthCheckRegistry"))
|
||||
.add(Param.optional("poolName"))
|
||||
.add(Param.optional("initializationFailTimeout"))
|
||||
.add(Param.optional("isolateInternalQueries"))
|
||||
.add(Param.optional("allowPoolSuspension"))
|
||||
.add(Param.optional("readOnly"))
|
||||
.add(Param.optional("registerMbeans"))
|
||||
.add(Param.optional("catalog"))
|
||||
.add(Param.optional("connectionInitSql"))
|
||||
.add(Param.optional("driverClassName"))
|
||||
.add(Param.optional("transactionIsolation"))
|
||||
.add(Param.optional("validationTimeout"))
|
||||
.add(Param.optional("leakDetectionThreshold"))
|
||||
.add(Param.optional("dataSource"))
|
||||
.add(Param.optional("schema"))
|
||||
.add(Param.optional("threadFactory"))
|
||||
.add(Param.optional("scheduledExecutor"))
|
||||
.add(Param.defaultTo("portNumber", "5432").setDescription("The port number the server is listening on. Defaults to the PostgreSQL® standard port number (5432)."))
|
||||
.add(Param.optional("user").setDescription("The database user on whose behalf the connection is being made."))
|
||||
.add(Param.optional("password").setDescription("The database user’s password."))
|
||||
.add(Param.optional("ssl").setDescription("Whether to connect using SSL. Default is false."))
|
||||
.add(Param.optional("sslmode").setDescription("Possible values include disable , allow , prefer , require , verify-ca and verify-full . require , allow and prefer all default to a non-validating SSL factory and do not check the validity of the certificate or the host name. verify-ca validates the certificate, but does not verify the hostname. verify-full will validate that the certificate is correct and verify the host connected to has the same hostname as the certificate. Default is prefer."))
|
||||
.add(Param.optional("sslcert").setDescription("Provide the full path for the certificate file. Defaults to defaultdir/postgresql.crt, where defaultdir is ${user.home}/.postgresql/ in *nix systems and %appdata%/postgresql/ on windows."))
|
||||
.add(Param.optional("sslrootcert").setDescription("File name of the SSL root certificate."))
|
||||
.add(Param.defaultTo("applicationName", "NoSQLBench").setDescription("The application name to be used. Default is 'NoSQLBench'."))
|
||||
.add(Param.optional("rewriteBatchedInserts").setDescription("This will change batch inserts from insert into foo (col1, col2, col3) values (1, 2, 3) into insert into foo (col1, col2, col3) values (1, 2, 3), (4, 5, 6) this provides 2-3x performance improvement. Default is true"))
|
||||
.add(Param.optional("autoCommit").setDescription("This property controls the default auto-commit behavior of connections returned from the pool. It is a boolean value. Default: false. This cannot be changed."))
|
||||
.add(Param.optional("connectionTimeout").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("idleTimeout").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.defaultTo("keepaliveTime", "150000").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("maxLifetime").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("connectionTestQuery").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("minimumIdle").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.defaultTo("maximumPoolSize", "40").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. Default value is 40 and cannot be changed."))
|
||||
.add(Param.optional("metricRegistry").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("healthCheckRegistry").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("poolName").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("initializationFailTimeout").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("isolateInternalQueries").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("allowPoolSuspension").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("readOnly").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("registerMbeans").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("catalog").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("connectionInitSql").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("driverClassName").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("transactionIsolation").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("validationTimeout").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("leakDetectionThreshold").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("dataSource").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("schema").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("threadFactory").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.add(Param.optional("scheduledExecutor").setDescription("See https://github.com/brettwooldridge/HikariCP/tree/dev#gear-configuration-knobs-baby for details. This property is not exposed and hence cannot be changed."))
|
||||
.asReadOnly();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,27 +24,33 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class JDBCExecuteOp extends JDBCOp {
|
||||
private final static Logger logger = LogManager.getLogger(JDBCExecuteOp.class);
|
||||
private static final Logger logger = LogManager.getLogger(JDBCExecuteOp.class);
|
||||
private static final String LOG_COMMIT_SUCCESS = "Executed the JDBC statement & committed the connection successfully";
|
||||
private final String LOG_QUERY_STRING;
|
||||
private final String LOG_SELECT_QUERY_STRING;
|
||||
private int finalResultCount;
|
||||
private String LOG_ROWS_PROCESSED = "Total number of rows processed is [" + finalResultCount + "]";
|
||||
|
||||
public JDBCExecuteOp(Connection connection, Statement statement, String queryString) {
|
||||
super(connection, statement, queryString);
|
||||
LOG_QUERY_STRING = "JDBC Query is: " + this.getQueryString();
|
||||
LOG_SELECT_QUERY_STRING = "Executed a SELECT operation [" + LOG_QUERY_STRING + "]";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(() -> LOG_QUERY_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug(() -> "Executing JDBCExecuteOp for the given cycle.");
|
||||
try {
|
||||
this.getConnection().setAutoCommit(false);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(() -> "JDBC Query is: " + this.getQueryString());
|
||||
}
|
||||
boolean isResultSet = this.getStatement().execute(this.getQueryString());
|
||||
|
||||
if (isResultSet) {
|
||||
logger.debug(() -> ">>>>>>>>>>Executed a SELECT operation [" + this.getQueryString() + "]<<<<<<<<<<");
|
||||
logger.debug(() -> LOG_SELECT_QUERY_STRING);
|
||||
} else if (!isResultSet) {
|
||||
logger.debug(() -> {
|
||||
try {
|
||||
return ">>>>>>>>>>Executed a normal DDL/DML (non-SELECT) operation. Objects affected is [" + this.getStatement().getUpdateCount() + "]<<<<<<<<<<";
|
||||
return "Executed a normal DDL/DML (non-SELECT) operation. Objects affected is [" + this.getStatement().getUpdateCount() + "]";
|
||||
} catch (SQLException e) {
|
||||
String err_msg = "Exception occurred while attempting to fetch the update count of the query operation";
|
||||
logger.error(err_msg, e);
|
||||
@@ -55,20 +61,23 @@ public class JDBCExecuteOp extends JDBCOp {
|
||||
int countResults = 0;
|
||||
ResultSet rs = this.getStatement().getResultSet();
|
||||
countResults += rs.getRow();
|
||||
|
||||
while (!this.getStatement().getMoreResults() && 0 < this.getStatement().getUpdateCount()) {
|
||||
rs = this.getStatement().getResultSet();
|
||||
countResults += rs.getRow();
|
||||
//rs.close(); Optional as getMoreResults() will already close it.
|
||||
}
|
||||
int finalCountResults = countResults;
|
||||
logger.debug(() -> ">>>>>>>>>>Total number of rows processed is [" + finalCountResults + "]<<<<<<<<<<");
|
||||
|
||||
finalResultCount = countResults;
|
||||
logger.debug(() -> LOG_ROWS_PROCESSED);
|
||||
}
|
||||
this.getConnection().commit();
|
||||
logger.debug(() -> "Executed the JDBC statement & committed the connection successfully");
|
||||
logger.debug(() -> LOG_COMMIT_SUCCESS);
|
||||
} catch (SQLException sqlException) {
|
||||
logger.error("ERROR: { state => {}, cause => {}, message => {} }\n",
|
||||
sqlException.getSQLState(), sqlException.getCause(), sqlException.getMessage(), sqlException);
|
||||
throw new RuntimeException(sqlException);
|
||||
String exMsg = String.format("ERROR: [ state => %s, cause => %s, message => %s ]",
|
||||
sqlException.getSQLState(), sqlException.getCause(), sqlException.getMessage());
|
||||
logger.error(exMsg, sqlException);
|
||||
throw new RuntimeException(exMsg, sqlException);
|
||||
} catch (Exception ex) {
|
||||
String exMsg = String.format("Exception while attempting to run the jdbc statement %s", getStatement());
|
||||
logger.error(exMsg, ex);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# run driver=jdbc workload="/path/to/cockroachdb-keyvalue.yaml" tags="block:schema" threads=AUTO cycles=4 url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName=insectdb sslrootcert="/path/to/postgresql_certs/root.crt" -vv --show-stacktraces
|
||||
# run driver=jdbc workload="/path/to/postgresql-keyvalue.yaml" tags="block:schema" threads=AUTO cycles=4 url="jdbc:postgresql://host:port/database" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName=insectdb sslrootcert="/path/to/postgresql_certs/root.crt" -vv --show-stacktraces
|
||||
min_version: "5.17.1"
|
||||
|
||||
description: |
|
||||
@@ -7,9 +7,12 @@ description: |
|
||||
|
||||
scenarios:
|
||||
default:
|
||||
schema: run driver=jdbc workload="/path/to/cockroachdb-keyvalue.yaml" tags==block:schema threads=1 cycles==UNDEF url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
rampup: run driver=jdbc workload="/path/to/cockroachdb-keyvalue.yaml" tags==block:rampup threads=AUTO cycles===TEMPLATE(rampup-cycles,10000000) url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
main: run driver=jdbc workload="/path/to/cockroachdb-keyvalue.yaml" tags=="block:main.*" threads=AUTO cycles===TEMPLATE(main-cycles,10000000) url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
schema: run driver=jdbc workload="/path/to/postgresql-keyvalue.yaml" tags==block:schema threads=1 cycles==UNDEF url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
rampup: run driver=jdbc workload="/path/to/postgresql-keyvalue.yaml" tags==block:rampup threads=AUTO cycles===TEMPLATE(rampup-cycles,10000000) url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
main: run driver=jdbc workload="/path/to/postgresql-keyvalue.yaml" tags==block:'main.*' threads=AUTO cycles===TEMPLATE(main-cycles,10000000) url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
|
||||
params:
|
||||
instrument: TEMPLATE(instrument,false)
|
||||
|
||||
bindings:
|
||||
seq_key: Mod(TEMPLATE(keycount,1000000000)); ToString() -> String
|
||||
@@ -21,23 +24,24 @@ blocks:
|
||||
schema:
|
||||
ops:
|
||||
drop-database:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
DROP DATABASE IF EXISTS TEMPLATE(database,baselines);
|
||||
create-database:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
CREATE DATABASE IF NOT EXISTS TEMPLATE(database,baselines);
|
||||
drop-table:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
DROP TABLE IF EXISTS TEMPLATE(database,baselines).TEMPLATE(table,keyvalue);
|
||||
create-table:
|
||||
jdbcQuery: |
|
||||
CREATE TABLE IF NOT EXISTS TEMPLATE(database,baselines).TEMPLATE(table,keyvalue) (key STRING PRIMARY KEY, value STRING);
|
||||
query: |
|
||||
CREATE TABLE IF NOT EXISTS TEMPLATE(database,baselines).TEMPLATE(table,keyvalue)
|
||||
(key STRING PRIMARY KEY, value STRING);
|
||||
|
||||
rampup:
|
||||
params:
|
||||
ops:
|
||||
rampup-insert:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(database,baselines).TEMPLATE(table,keyvalue)
|
||||
(key, value) VALUES ({seq_key},{seq_value});
|
||||
|
||||
@@ -46,13 +50,13 @@ blocks:
|
||||
ratio: TEMPLATE(read_ratio,5)
|
||||
ops:
|
||||
main-select:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue) WHERE key='{rw_key}';
|
||||
main-write:
|
||||
params:
|
||||
ratio: TEMPLATE(write_ratio,5)
|
||||
ops:
|
||||
main-insert:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue)
|
||||
(key, value) VALUES ('{rw_key}', '{rw_value}');
|
||||
|
||||
@@ -27,12 +27,12 @@ description: |
|
||||
|
||||
scenarios:
|
||||
default:
|
||||
schema: run driver=jdbc tags==block:schema threads==1 cycles==UNDEF
|
||||
rampup: run driver=jdbc tags==block:rampup cycles===TEMPLATE(rampup-cycles,10B) threads=auto
|
||||
main: run driver=jdbc tags==block:"main.*" cycles===TEMPLATE(main-cycles,100M) threads=auto
|
||||
schema: run driver=jdbc tags==block:schema cycles==UNDEF threads==1
|
||||
rampup: run driver=jdbc tags==block:rampup cycles===TEMPLATE(rampup-cycles,10B) threads=auto
|
||||
main: run driver=jdbc tags==block:'main.*' cycles===TEMPLATE(main-cycles,100M) threads=auto
|
||||
|
||||
params:
|
||||
instrument: true
|
||||
instrument: TEMPLATE(instrument,false)
|
||||
|
||||
bindings:
|
||||
# for ramp-up and verify phases
|
||||
@@ -66,16 +66,16 @@ blocks:
|
||||
prepared: false
|
||||
ops:
|
||||
#drop-database:
|
||||
# jdbcQuery: |
|
||||
# query: |
|
||||
# DROP DATABASE IF EXISTS TEMPLATE(database,baselines);
|
||||
create-database:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
CREATE DATABASE IF NOT EXISTS TEMPLATE(database,baselines);
|
||||
drop-table:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
DROP TABLE IF EXISTS TEMPLATE(database,baselines).TEMPLATE(table,tabular);
|
||||
create-table:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
CREATE TABLE IF NOT EXISTS TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) (
|
||||
part STRING,
|
||||
clust STRING,
|
||||
@@ -87,51 +87,68 @@ blocks:
|
||||
params:
|
||||
ops:
|
||||
rampup-insert:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
(part,clust,data0,data1,data2,data3,data4,data5,data6,data7)
|
||||
VALUES ('{part_layout}','{clust_layout}','{data0}','{data1}','{data2}','{data3}','{data4}','{data5}','{data6}','{data7}')
|
||||
VALUES (
|
||||
'{part_layout}','{clust_layout}','{data0}','{data1}','{data2}',
|
||||
'{data3}','{data4}','{data5}','{data6}','{data7}'
|
||||
);
|
||||
verify:
|
||||
params:
|
||||
cl: TEMPLATE(read_cl,LOCAL_QUORUM)
|
||||
ops:
|
||||
verify-select:
|
||||
jdbcQuery: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_layout}' AND clust='{clust_layout}'
|
||||
query: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_layout}'
|
||||
AND clust='{clust_layout}'
|
||||
main-read:
|
||||
params:
|
||||
ratio: TEMPLATE(read_ratio,1)
|
||||
ops:
|
||||
main-select-all:
|
||||
jdbcQuery: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-01:
|
||||
jdbcQuery: |
|
||||
SELECT data0,data1 from TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data0,data1 from TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-0246:
|
||||
jdbcQuery: |
|
||||
SELECT data0,data2,data4,data6 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data0,data2,data4,data6 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-1357:
|
||||
jdbcQuery: |
|
||||
SELECT data1,data3,data5,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data1,data3,data5,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-0123:
|
||||
jdbcQuery: |
|
||||
SELECT data0,data1,data2,data3 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data0,data1,data2,data3 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-4567:
|
||||
jdbcQuery: |
|
||||
SELECT data4,data5,data6,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data4,data5,data6,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select-67:
|
||||
jdbcQuery: |
|
||||
SELECT data6,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data6,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-select:
|
||||
jdbcQuery: |
|
||||
SELECT data0,data1,data2,data3,data4,data5,data6,data7 FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular) WHERE part='{part_read}' LIMIT {limit};
|
||||
query: |
|
||||
SELECT data0,data1,data2,data3,data4,data5,data6,data7
|
||||
FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
WHERE part='{part_read}' LIMIT {limit};
|
||||
main-write:
|
||||
params:
|
||||
ratio: TEMPLATE(write_ratio,8)
|
||||
ops:
|
||||
main-write:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(keyspace,baselines).TEMPLATE(table,tabular)
|
||||
(part, clust, data0,data1,data2,data3,data4,data5,data6,data7)
|
||||
VALUES ('{part_write}','{clust_write}','{data0}','{data1}','{data2}','{data3}','{data4}','{data5}','{data6}','{data7}')
|
||||
VALUES (
|
||||
'{part_write}','{clust_write}','{data0}','{data1}','{data2}',
|
||||
'{data3}','{data4}','{data5}','{data6}','{data7}'
|
||||
);
|
||||
|
||||
@@ -6,9 +6,9 @@ description: |
|
||||
|
||||
scenarios:
|
||||
default:
|
||||
schema: run driver=jdbc tags==block:schema threads==1 cycles==UNDEF url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
rampup: run driver=jdbc tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
main: run driver=jdbc tags==block:"main.*" cycles===TEMPLATE(main-cycles,10000000) threads=auto url="jdbc:postgresql://crdb0-3153.g8z.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-ca&password=CHANGE_ME&user=newuser" databaseName="defaultdb" portNumber=26257 user="newuser" password="CHANGE_ME" sslmode="verify-full" serverName="crdb" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
schema: run driver=jdbc tags==block:schema cycles==UNDEF threads==1 url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
rampup: run driver=jdbc tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
main: run driver=jdbc tags==block:'main.*' cycles===TEMPLATE(main-cycles,10000000) threads=auto url="jdbc:postgresql://host:port/" databaseName="defaultdb" portNumber=5432 user="newuser" password="CHANGE_ME" sslmode="prefer" serverName="pgsql" sslrootcert="/path/to/postgresql_certs/root.crt"
|
||||
|
||||
params:
|
||||
instrument: TEMPLATE(instrument,false)
|
||||
@@ -27,16 +27,16 @@ blocks:
|
||||
params:
|
||||
ops:
|
||||
drop-database:
|
||||
#jdbcQuery: |
|
||||
#query: |
|
||||
# DROP DATABASE IF EXISTS TEMPLATE(database,baselines);
|
||||
create-database:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
CREATE DATABASE IF NOT EXISTS TEMPLATE(database,baselines);
|
||||
drop-table:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
DROP TABLE IF EXISTS TEMPLATE(database,baselines).TEMPLATE(table,iot);
|
||||
create-table:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
CREATE TABLE IF NOT EXISTS TEMPLATE(keyspace,baselines).TEMPLATE(table,iot) (
|
||||
machine_id UUID,
|
||||
sensor_name STRING,
|
||||
@@ -51,10 +51,12 @@ blocks:
|
||||
params:
|
||||
ops:
|
||||
insert-rampup:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(keyspace,baselines).TEMPLATE(table,iot)
|
||||
(machine_id, sensor_name, time, sensor_value, station_id, data)
|
||||
VALUES ('{machine_id}', '{sensor_name}', '{time}', {sensor_value}, '{station_id}', '{data}')
|
||||
VALUES (
|
||||
'{machine_id}', '{sensor_name}', '{time}', {sensor_value}, '{station_id}', '{data}'
|
||||
);
|
||||
|
||||
#using timestamp {cell_timestamp}
|
||||
|
||||
@@ -63,18 +65,20 @@ blocks:
|
||||
ratio: TEMPLATE(read_ratio,1)
|
||||
ops:
|
||||
select-read:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
SELECT * FROM TEMPLATE(keyspace,baselines).TEMPLATE(table,iot)
|
||||
WHERE machine_id='{machine_id}' and sensor_name='{sensor_name}'
|
||||
LIMIT TEMPLATE(limit,10)
|
||||
LIMIT TEMPLATE(limit,10);
|
||||
main-write:
|
||||
params:
|
||||
ratio: TEMPLATE(write_ratio,9)
|
||||
ops:
|
||||
insert-main:
|
||||
jdbcQuery: |
|
||||
query: |
|
||||
INSERT INTO TEMPLATE(keyspace,baselines).TEMPLATE(table,iot)
|
||||
(machine_id, sensor_name, time, sensor_value, station_id, data)
|
||||
VALUES ('{machine_id}', '{sensor_name}', '{time}', {sensor_value}, '{station_id}', '{data}')
|
||||
VALUES (
|
||||
'{machine_id}', '{sensor_name}', '{time}', {sensor_value}, '{station_id}', '{data}'
|
||||
);
|
||||
|
||||
#using timestamp {cell_timestamp}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
---
|
||||
weight: 0
|
||||
title: jdbc
|
||||
---
|
||||
|
||||
# JDBC driver
|
||||
This JDBC driver leverages [Hikari Connection Pool](https://github.com/brettwooldridge/HikariCP/wiki) for connection pool and works with PostgreSQL®. This leverages NoSQLBench based workload generation and performance testing against any PostgreSQL-compatible database cluster. Example: CockroachDB® or YugabyteDB® (YSQL API).
|
||||
|
||||
@@ -26,6 +21,6 @@ Other NB engine parameters are straight forward:
|
||||
# Configuration
|
||||
There is really one main configuration with which we could issue a query and process the results back based on the [PostgreSQL® Query](https://jdbc.postgresql.org/documentation/query/) pattern.
|
||||
## Config Sources
|
||||
* `jdbcQuery`: This is to issue DML statement such as `SELECT` operation which would return a `ResultSet` object to process. This is to issue any DDL statements such `CREATE DATABASE|TABLE` or `DROP DATABASE|TABLE` operations which returns nothing. This is to issue DML statements such as `INSERT|UPDATE|DELETE` operations that will return how many number of rows were affected by that operation.
|
||||
* `query`: This is to issue DML statement such as `SELECT` operation which would return a `ResultSet` object to process. This is to issue any DDL statements such `CREATE DATABASE|TABLE` or `DROP DATABASE|TABLE` operations which returns nothing. This is to issue DML statements such as `INSERT|UPDATE|DELETE` operations that will return how many number of rows were affected by that operation.
|
||||
### Examples
|
||||
Check out the default activities under the [activities.baselinesv2](./activities.baselinesv2) directory.
|
||||
|
||||
Reference in New Issue
Block a user