|
63 | 63 | import org.slf4j.Logger;
|
64 | 64 | import org.slf4j.LoggerFactory;
|
65 | 65 |
|
66 |
| -import com.google.common.base.Preconditions; |
67 |
| - |
68 | 66 | /**
|
69 | 67 | * Fault tolerant executor
|
70 | 68 | */
|
@@ -439,57 +437,16 @@ public FateId startTransaction() {
|
439 | 437 | return store.create();
|
440 | 438 | }
|
441 | 439 |
|
442 |
| - public Optional<FateId> seedTransaction(String txName, FateKey fateKey, Repo<T> repo, |
443 |
| - boolean autoCleanUp, String goalMessage) { |
444 |
| - |
445 |
| - Optional<FateTxStore<T>> optTxStore = store.createAndReserve(fateKey); |
446 |
| - |
447 |
| - return optTxStore.map(txStore -> { |
448 |
| - var fateId = txStore.getID(); |
449 |
| - try { |
450 |
| - Preconditions.checkState(txStore.getStatus() == NEW); |
451 |
| - seedTransaction(txName, fateId, repo, autoCleanUp, goalMessage, txStore); |
452 |
| - } finally { |
453 |
| - txStore.unreserve(Duration.ZERO); |
454 |
| - } |
455 |
| - return fateId; |
456 |
| - }); |
457 |
| - } |
458 |
| - |
459 |
| - private void seedTransaction(String txName, FateId fateId, Repo<T> repo, boolean autoCleanUp, |
460 |
| - String goalMessage, FateTxStore<T> txStore) { |
461 |
| - if (txStore.top() == null) { |
462 |
| - try { |
463 |
| - log.info("Seeding {} {}", fateId, goalMessage); |
464 |
| - txStore.push(repo); |
465 |
| - } catch (StackOverflowException e) { |
466 |
| - // this should not happen |
467 |
| - throw new IllegalStateException(e); |
468 |
| - } |
469 |
| - } |
470 |
| - |
471 |
| - if (autoCleanUp) { |
472 |
| - txStore.setTransactionInfo(TxInfo.AUTO_CLEAN, autoCleanUp); |
473 |
| - } |
474 |
| - |
475 |
| - txStore.setTransactionInfo(TxInfo.TX_NAME, txName); |
476 |
| - |
477 |
| - txStore.setStatus(SUBMITTED); |
| 440 | + public void seedTransaction(String txName, FateKey fateKey, Repo<T> repo, boolean autoCleanUp) { |
| 441 | + store.seedTransaction(txName, fateKey, repo, autoCleanUp); |
478 | 442 | }
|
479 | 443 |
|
480 | 444 | // start work in the transaction.. it is safe to call this
|
481 | 445 | // multiple times for a transaction... but it will only seed once
|
482 | 446 | public void seedTransaction(String txName, FateId fateId, Repo<T> repo, boolean autoCleanUp,
|
483 | 447 | String goalMessage) {
|
484 |
| - FateTxStore<T> txStore = store.reserve(fateId); |
485 |
| - try { |
486 |
| - if (txStore.getStatus() == NEW) { |
487 |
| - seedTransaction(txName, fateId, repo, autoCleanUp, goalMessage, txStore); |
488 |
| - } |
489 |
| - } finally { |
490 |
| - txStore.unreserve(Duration.ZERO); |
491 |
| - } |
492 |
| - |
| 448 | + log.info("Seeding {} {}", fateId, goalMessage); |
| 449 | + store.seedTransaction(txName, fateId, repo, autoCleanUp); |
493 | 450 | }
|
494 | 451 |
|
495 | 452 | // check on the transaction
|
|
0 commit comments