MCPcopy Create free account
hub / github.com/cmu-db/benchbase / doWork

Method doWork

src/main/java/com/oltpbenchmark/api/Worker.java:401–644  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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;

Callers 1

runMethod · 0.95

Calls 14

executeWorkMethod · 0.95
indicatesReadOnlyMethod · 0.95
isConnectionOKMethod · 0.95
isRetryableMethod · 0.95
getMaxRetriesMethod · 0.80
getGlobalStateMethod · 0.80
getIsolationModeMethod · 0.80
formatMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected