-
Notifications
You must be signed in to change notification settings - Fork 0
SOLR-17877: Move distributedCollectionCommandRunner from CoreContainer to ZkController #2
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
Conversation
…oller Co-authored-by: dsmiley <[email protected]>
…mmandRunner Co-authored-by: dsmiley <[email protected]>
…ollectionCommandRunner Co-authored-by: dsmiley <[email protected]>
| } | ||
| if (!distributedCollectionCommandRunner.isPresent()) { | ||
| if (!zkSys.getZkController().getDistributedCollectionCommandRunner().isPresent()) { | ||
| zkSys.getZkController().checkOverseerDesignate(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot we needn't do this conditionally; just call zkSys.getZkController().checkOverseerDesignate() no matter what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed the conditional check and now calling checkOverseerDesignate() unconditionally. (1d31b1b)
| public void shutdown() { | ||
|
|
||
| ZkController zkController = getZkController(); | ||
| if (zkController != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This logic of waiting for pending tasks to complete should be moved to ZkController -- a new method maybe named waitForPendingTasksToComplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added waitForPendingTasksToComplete() method to ZkController and updated CoreContainer.shutdown() to use it. This cleanly encapsulates the pending task logic within ZkController. (1d31b1b)
| NamedList<Object> results = new NamedList<>(); | ||
| boolean isDistributedApi = | ||
| h.coreContainer.getDistributedCollectionCommandRunner().isPresent(); | ||
| h.coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null in SolrCloud mode, which the CollectionsHandler is associated with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check and updated CollectionsHandler.submitCollectionApiCommand to get the runner directly from ZkController. (1d31b1b)
| CollectionsHandler.submitCollectionApiCommand( | ||
| coreContainer, | ||
| coreContainer.getDistributedCollectionCommandRunner(), | ||
| coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check. (1d31b1b)
| CollectionsHandler.submitCollectionApiCommand( | ||
| coreContainer, | ||
| coreContainer.getDistributedCollectionCommandRunner(), | ||
| coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check. (1d31b1b)
| CollectionsHandler.submitCollectionApiCommand( | ||
| coreContainer, | ||
| coreContainer.getDistributedCollectionCommandRunner(), | ||
| coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check. (1d31b1b)
| CollectionsHandler.submitCollectionApiCommand( | ||
| coreContainer, | ||
| coreContainer.getDistributedCollectionCommandRunner(), | ||
| coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check. (1d31b1b)
| CollectionsHandler.submitCollectionApiCommand( | ||
| coreContainer, | ||
| coreContainer.getDistributedCollectionCommandRunner(), | ||
| coreContainer.getZkController() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ZkController will not be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Let's increase the scope a little so that org.apache.solr.handler.admin.CollectionsHandler#submitCollectionApiCommand no longer needs to be passed the distributedCollectionConfigSetCommandRunner. Obviously it can get it from the coreContainer.getZkController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed null check and updated submitCollectionApiCommand to get distributedCollectionConfigSetCommandRunner directly from ZkController rather than being passed as a parameter. (1d31b1b)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated submitCollectionApiCommand to get distributedCollectionConfigSetCommandRunner directly from coreContainer.getZkController() rather than being passed as a parameter. Removed the field from CollectionsHandler as it's no longer needed. (1d31b1b)
|
|
||
| public Optional<DistributedCollectionConfigSetCommandRunner> | ||
| getDistributedCollectionCommandRunner() { | ||
| return this.distributedCollectionCommandRunner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use Objects.requireNonNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use Objects.requireNonNull in the getter method. (1d31b1b)
| } finally { | ||
|
|
||
| sysPropsCacher.close(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot No need to do this here since stopAndWaitForPendingTasksToComplete is already called earlier before close is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the duplicate cleanup logic since stopAndWaitForPendingTasksToComplete is already called earlier. (1d31b1b)
…ization, and eliminate null checks Co-authored-by: dsmiley <[email protected]>
ConfigSetAPIBase: don't need a field for the runner
…a1f9-b3c0c4991c8f
This PR implements the refactoring requested in JIRA SOLR-17877 to move the
distributedCollectionCommandRunnerfield fromCoreContainertoZkController, removing CoreContainer's knowledge of this ZooKeeper-specific functionality.Problem
Previously,
CoreContainerwas responsible for managing theDistributedCollectionConfigSetCommandRunnerinstance, which violated separation of concerns since this functionality is specific to ZooKeeper operations and should be owned byZkController.Solution
Moved the field and its lifecycle to ZkController:
distributedCollectionCommandRunnerfield toZkControllerwith appropriate getter methodZkController.init()after ZooKeeper is fully initializedZkController.close()to properly shut down the command runnerRemoved CoreContainer's knowledge:
CoreContainerCoreContainer.loadInternal()CoreContainerto access viaZkControllerUpdated all consumers:
CollectionsHandlerand all admin API classes to access viaZkController.getDistributedCollectionCommandRunner()OverseerStatusCmdto use the new locationZkControllerinstead ofCoreContainerfor this functionalityKey Changes
Verification
CoreContainer.getDistributedCollectionCommandRunner()method remainThis change makes the codebase cleaner by ensuring that ZooKeeper-related functionality is properly contained within
ZkControllerrather than being exposed throughCoreContainer.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.