Skip to content

Create validation runner #3360

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

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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 @@ -138,6 +138,7 @@ public enum LogMessageKeys {
END_TUPLE,
REAL_END,
RECORDS_SCANNED,
RECORDS_DELETED,
ORIGINAL_RANGE,
SPLIT_RANGES,
REASON,
Expand Down Expand Up @@ -312,6 +313,7 @@ public enum LogMessageKeys {
TOTAL_RECORDS_SCANNED,
TOTAL_RECORDS_SCANNED_DURING_FAILURES,
SCRUB_TYPE,
RETRY_COUNT,

// time limits milliseconds
TIME_LIMIT_MILLIS("time_limit_milliseconds"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,13 @@ public Executor getExecutor() {
return factory.getExecutor();
}

protected Executor newContextExecutor(@Nullable Map<String, String> mdcContext) {
/**
* Create a new executor for the database. This is used internally when creating a transaction or a new runner.
* @param mdcContext if present, the MDC context to be made available within the executors threads
* @return the new executor
*/
@API(API.Status.INTERNAL)
public Executor newContextExecutor(@Nullable Map<String, String> mdcContext) {
return factory.newContextExecutor(mdcContext);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* CursorFactory.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.apple.foundationdb.record.provider.foundationdb.cursors.throttled;

import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.record.RecordCursor;
import com.apple.foundationdb.record.RecordCursorResult;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecordStore;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* Create a cursor with the given store and last result.
* @param <T> the type of item the cursor iterates over.
* This factory method is used by the {@link ThrottledRetryingIterator} to create inner cursors when needed.
* The iterator creates transactions based off of the constraints given, and for each such transaction, a new inner
* cursor gets created.
*/
@API(API.Status.EXPERIMENTAL)
@FunctionalInterface
public interface CursorFactory<T> {
/**
* Create a new inner cursor for the {@link ThrottledRetryingIterator}.
* @param store the record store to use
* @param lastResult the last result processed by the previous cursor (use for continuation). Null is none.
* @param rowLimit the adjusted row limit to use
* @return a newly created cursor with the given continuation and limit
*/
RecordCursor<T> createCursor(@Nonnull FDBRecordStore store, @Nullable RecordCursorResult<T> lastResult, int rowLimit);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* ItemHandler.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.apple.foundationdb.record.provider.foundationdb.cursors.throttled;

import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.record.RecordCursorResult;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecordStore;

import javax.annotation.Nonnull;
import java.util.concurrent.CompletableFuture;

/**
* A handler of an item during the iteration of a {@link ThrottledRetryingIterator}.
* @param <T> the type of element in the iteration
*/
@API(API.Status.EXPERIMENTAL)
@FunctionalInterface
public interface ItemHandler<T> {
/**
* Process an item.
* Once done processing, return a future that controls whether to continue the iteration or stop.
* The quota manager holds the current state of the iteration (per the current transaction). The handler can
* change the state via {@link ThrottledRetryingIterator.QuotaManager#deleteCountAdd(int)},
* {@link ThrottledRetryingIterator.QuotaManager#deleteCountInc()} and
* {@link ThrottledRetryingIterator.QuotaManager#markExhausted()}.
* @param store the record store to use
* @param lastResult the result to process
* @param quotaManager the current quota manager state
* @return Future (Void) for when the operation is complete
*/
@Nonnull
CompletableFuture<Void> handleOneItem(FDBRecordStore store, RecordCursorResult<T> lastResult, ThrottledRetryingIterator.QuotaManager quotaManager);
}
Loading
Loading