Skip to content

Commit

Permalink
Modify FateStore to introduce a Seeder API
Browse files Browse the repository at this point in the history
This adds a new Seeder API that can be used to seed transactions with a
FateKey. The purpose of this new API is to allow for eventual batching
of multiple seeding attempts together into one conditional mutation to
improve performance. This change just updates the api and all calls to
the seeder to attempt seeding will be performed individually. A future
update will support the new functionality of batching and commiting all
the changes together when the Seeder is closed.

This change is for Part 1 of apache#5160
  • Loading branch information
cshannon committed Mar 1, 2025
1 parent 75e3a00 commit 69d84f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/accumulo/core/fate/Fate.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public FateId startTransaction() {
public void seedTransaction(FateOperation fateOp, FateKey fateKey, Repo<T> repo,
boolean autoCleanUp) {
try (var seeder = store.beginSeeding()) {
seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp);
var unused = seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp);
}
}

Expand Down
16 changes: 10 additions & 6 deletions core/src/main/java/org/apache/accumulo/core/fate/FateStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ public interface FateStore<T> extends ReadOnlyFateStore<T> {
interface Seeder<T> extends AutoCloseable {

/**
* Seeds a transaction with the given repo if it does not exist. A fateId will be derived from
* the fateKey. If seeded, sets the following data for the fateId in the store.
* Attempts to seed a transaction with the given repo if it does not exist. A fateId will be
* derived from the fateKey. If seeded, sets the following data for the fateId in the store.
*
* TODO: Support completing futures later in close method The current version will always return
* with a CompleteableFuture that is already completed. Future version will process will
* complete in the close() method for the User store.
*
* <ul>
* <li>Set the fate op</li>
Expand All @@ -70,13 +74,13 @@ interface Seeder<T> extends AutoCloseable {
* and empty optional otherwise. If there was a failure this could return an empty
* optional when it actually succeeded.
*/
// For UserFateStore this would create a conditional mutation and add it to the conditional
// writer
CompletableFuture<Optional<FateId>> attemptToSeedTransaction(Fate.FateOperation fateOp,
FateKey fateKey, Repo<T> repo, boolean autoCleanUp);

// This would check the status of all added conditional mutations, retry unknown, and then close
// the conditional writer.
// TODO: Right now all implementations do nothing
// Eventually this would check the status of all added conditional mutations,
// retry unknown, and then close the conditional writer.
@Override
void close();
}

Expand Down

0 comments on commit 69d84f4

Please sign in to comment.