Called in a loop in the thread to exercise the system under test. Each implementing worker should return the TransactionType handle that was executed. @param databaseType TODO @param transactionType TODO
(DatabaseType databaseType, TransactionType transactionType)
| 399 | * @param transactionType TODO |
| 400 | */ |
| 401 | protected final void doWork(DatabaseType databaseType, TransactionType transactionType) { |
| 402 | |
| 403 | try { |
| 404 | int retryCount = 0; |
| 405 | int maxRetryCount = configuration.getMaxRetries(); |
| 406 | |
| 407 | while (retryCount < maxRetryCount && this.workloadState.getGlobalState() != State.DONE) { |
| 408 | |
| 409 | TransactionStatus status = TransactionStatus.UNKNOWN; |
| 410 | |
| 411 | if (this.conn == null) { |
| 412 | try { |
| 413 | if (!this.configuration.getNewConnectionPerTxn()) { |
| 414 | if (retryCount > 0) { |
| 415 | Duration delay = Duration.ofSeconds(Math.min(retryCount, 5)); |
| 416 | LOG.info("Backing off {} seconds before reconnecting.", delay.toSeconds()); |
| 417 | try { |
| 418 | Thread.sleep(delay); |
| 419 | } catch (InterruptedException ex) { |
| 420 | // pass |
| 421 | } |
| 422 | } else { |
| 423 | LOG.info("(Re)connecting to database."); |
| 424 | } |
| 425 | } |
| 426 | this.conn = this.benchmark.makeConnection(); |
| 427 | this.conn.setAutoCommit(false); |
| 428 | this.conn.setTransactionIsolation(this.configuration.getIsolationMode()); |
| 429 | } catch (SQLException ex) { |
| 430 | if (LOG.isDebugEnabled()) { |
| 431 | LOG.debug(String.format("%s failed to open a connection...", this)); |
| 432 | } |
| 433 | retryCount++; |
| 434 | continue; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | try { |
| 439 | |
| 440 | if (LOG.isDebugEnabled()) { |
| 441 | LOG.debug(String.format("%s %s attempting...", this, transactionType)); |
| 442 | } |
| 443 | |
| 444 | status = this.executeWork(conn, transactionType); |
| 445 | |
| 446 | if (LOG.isDebugEnabled()) { |
| 447 | LOG.debug( |
| 448 | String.format( |
| 449 | "%s %s completed with status [%s]...", this, transactionType, status.name())); |
| 450 | } |
| 451 | |
| 452 | if (LOG.isDebugEnabled()) { |
| 453 | LOG.debug(String.format("%s %s committing...", this, transactionType)); |
| 454 | } |
| 455 | |
| 456 | conn.commit(); |
| 457 | |
| 458 | break; |
no test coverage detected