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

Simplify SnapshotsService Cluster State Updates #37966

Conversation

original-brownbear
Copy link
Member

  • Dried up redundant conditionals without changing the logic
  • Other obvious/static simplifications

* Dried up redundant conditionals without changing the logic
* Other obvious/static simplifications
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

*/
private void removeFinishedSnapshotFromClusterState(ClusterChangedEvent event) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Inlined as a one-liner into applyClusterState

processSnapshotsOnRemovedNodes(event);
final boolean newMaster = event.previousState().nodes().isLocalNodeElectedMaster() == false;
final SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE);
if (snapshotsInProgress != null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This check was nested in all the operations this condition now covers, much easier to understand that this method pretty much only takes effect when there's a SnapshotsInProgress in the state now imo.

}
}
}
private static boolean removedNodesCleanupNeeded(SnapshotsInProgress snapshotsInProgress, List<DiscoveryNode> removedNodes,
Copy link
Member Author

Choose a reason for hiding this comment

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

Moving all the checks into this method and split up the two cases handled by the loop into separate blocks.

}
}
if (changed) {
return ClusterState.builder(currentState)
Copy link
Member Author

Choose a reason for hiding this comment

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

cleaned up all these verbose instantiations, we're safe escaping entries here imo and not copying to array.

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/2

@original-brownbear
Copy link
Member Author

Closing in favor of #38368 that incorporates this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants