Skip to content

Create a utility class for static SnapshotsService methods #127419

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DiannaHohensee
Copy link
Contributor

@DiannaHohensee DiannaHohensee commented Apr 25, 2025

This moves the static methods out of the SnapshotsService to
make the stateful code more visible. This is one step towards
refactoring the SnapshotsService.


I'd like to eventually get the SnapshotsService into a state where it manages MasterService task queues, and submitting work to them, but the executor logic moved out to other files. Classes like SnapshotTaskExecutor (and related code, like SnapshotShardsUpdateContext) and UpdateNodeIdsForRemovalTask would get moved out.

Another future refactor target would be the logic stuffed into SnapshotsService#cloneSnapshot(): there's an anonymous class extension here and here. I'm guessing that can be made easier to follow.

Also can easily boot out UpdateSnapshotStatusAction into its own Transport* file just to get it out of there. Like TransportCloneSnapshotAction already is.

Let me know what you think of ^ @DaveCTurner

@DiannaHohensee DiannaHohensee added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Coordination Meta label for Distributed Coordination team labels Apr 25, 2025
@DiannaHohensee DiannaHohensee self-assigned this Apr 25, 2025
@DiannaHohensee DiannaHohensee force-pushed the 2025/04/25/snapshot-service-refactor-static branch from d0a8866 to 1268eee Compare April 25, 2025 21:05
This moves the static methods out of the SnapshotsService to
make the stateful code more visible. This is one step towards
refactoring the SnapshotsService.
@DiannaHohensee DiannaHohensee force-pushed the 2025/04/25/snapshot-service-refactor-static branch from 1268eee to 76b71c6 Compare April 25, 2025 21:06
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

DiscoveryNodes nodes,
Predicate<String> nodeIdRemovalPredicate,
Map<RepositoryShardId, SnapshotsInProgress.ShardSnapshotStatus> knownFailures,
Logger logger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and a couple other methods I've marked, are the only slight changes I made to the methods: passing in the SnapshotService's logger.

The rest of the changes in this file are purely IDE move operations out of the SnapshotsService file into this one, with a little method ordering done by me.

}
}

static <T> void failListenersIgnoringException(@Nullable List<ActionListener<T>> listeners, Exception failure, Logger logger) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the other change to add the logger from SnapshotsService, along with completeListenersIgnoringException() below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants