Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a status of Successful when popping FATE repos #4302

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ public void pop() {
verifyReserved(true);

Optional<Integer> top = findTop();
top.ifPresent(
t -> newMutator(fateId).requireStatus(TStatus.FAILED_IN_PROGRESS).deleteRepo(t).mutate());
top.ifPresent(t -> newMutator(fateId)
.requireStatus(TStatus.FAILED_IN_PROGRESS, TStatus.SUCCESSFUL).deleteRepo(t).mutate());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.FateInstanceType;
import org.apache.accumulo.core.fate.FateStore;
import org.apache.accumulo.core.fate.ReadOnlyFateStore;
import org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus;
import org.apache.accumulo.core.fate.accumulo.AccumuloStore;
import org.apache.accumulo.core.fate.accumulo.schema.FateSchema;
import org.apache.accumulo.harness.SharedMiniClusterBase;
Expand Down Expand Up @@ -143,8 +143,8 @@ public void teardown() throws Exception {
}

private void testOperationWithStatuses(Runnable beforeOperation, Executable operation,
Set<ReadOnlyFateStore.TStatus> acceptableStatuses) throws Exception {
for (ReadOnlyFateStore.TStatus status : ReadOnlyFateStore.TStatus.values()) {
Set<TStatus> acceptableStatuses) throws Exception {
for (TStatus status : TStatus.values()) {
// Run any needed setup for the operation before each iteration
beforeOperation.run();

Expand All @@ -164,36 +164,35 @@ private void testOperationWithStatuses(Runnable beforeOperation, Executable oper
public void push() throws Exception {
testOperationWithStatuses(() -> {}, // No special setup needed for push
() -> txStore.push(new FateIT.TestRepo("testOp")),
Set.of(ReadOnlyFateStore.TStatus.IN_PROGRESS, ReadOnlyFateStore.TStatus.NEW));
Set.of(TStatus.IN_PROGRESS, TStatus.NEW));
}

@Test
public void pop() throws Exception {
testOperationWithStatuses(() -> {
// Setup for pop: Ensure there something to pop by first pushing
try {
injectStatus(client, tableName, fateId, ReadOnlyFateStore.TStatus.NEW);
injectStatus(client, tableName, fateId, TStatus.NEW);
txStore.push(new FateIT.TestRepo("testOp"));
} catch (Exception e) {
throw new RuntimeException("Failed to setup for pop", e);
}
}, txStore::pop, Set.of(ReadOnlyFateStore.TStatus.FAILED_IN_PROGRESS));
}, txStore::pop, Set.of(TStatus.FAILED_IN_PROGRESS, TStatus.SUCCESSFUL));
}

@Test
public void delete() throws Exception {
testOperationWithStatuses(() -> {}, // No special setup needed for delete
txStore::delete,
Set.of(ReadOnlyFateStore.TStatus.NEW, ReadOnlyFateStore.TStatus.SUBMITTED,
ReadOnlyFateStore.TStatus.SUCCESSFUL, ReadOnlyFateStore.TStatus.FAILED));
Set.of(TStatus.NEW, TStatus.SUBMITTED, TStatus.SUCCESSFUL, TStatus.FAILED));
}
}

/**
* Inject a status into the status col of the fate store table for a given transaction id.
*/
private void injectStatus(ClientContext client, String table, FateId fateId,
ReadOnlyFateStore.TStatus status) throws TableNotFoundException {
private void injectStatus(ClientContext client, String table, FateId fateId, TStatus status)
throws TableNotFoundException {
try (BatchWriter writer = client.createBatchWriter(table)) {
Mutation mutation = new Mutation(new Text("tx_" + fateId.getHexTid()));
FateSchema.TxColumnFamily.STATUS_COLUMN.put(mutation, new Value(status.name()));
Expand Down