Skip to content

Adding transport actions for getting and updating data stream settings #127417

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

Merged
merged 3 commits into from
Apr 28, 2025

Conversation

masseyke
Copy link
Member

This builds on #126947 and #127282, adding two new transport actions -- one to get the settings of a data stream and one to update the settings of a data stream. The rest action will come in a follow-up PR.

@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Apr 25, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

Copy link
Contributor

@lukewhiting lukewhiting left a comment

Choose a reason for hiding this comment

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

One question that's mostly for my curiosity but otherwise looks good :-) 👍🏻

Comment on lines +110 to +121
CountDownActionListener countDownListener = new CountDownActionListener(dataStreamNames.size() + 1, new ActionListener<>() {
@Override
public void onResponse(Void unused) {
listener.onResponse(new UpdateDataStreamSettingsAction.Response(dataStreamSettingsResponse));
}

@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
});
countDownListener.onResponse(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not so much a PR comment but I'm interested in this pattern here as I haven't seen it before. What's the advantage of this over a bare CountdownLatch?

It feels a little weird to mimic the listener interface but then to call it will a null payload each time but I'm guessing it's something to do with error handling?

Copy link
Member Author

Choose a reason for hiding this comment

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

The same thing could definitely have been achieved with a CountdownLatch. With the CountDownActionListener though I can just write my code in the onResponse, and like you said, not worry that I've handled errors correctly, or that I remembered to count down in both the onResonpse and onFailure methods. Not that any of that would have been very hard, but CountDownActionListener was there so I used it.

ClusterState clusterState
) throws Exception {

ProjectMetadata projectMetadata = clusterState.projectState(updateSettingsTask.projectId).metadata();
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to convert to ProjectState here

Suggested change
ProjectMetadata projectMetadata = clusterState.projectState(updateSettingsTask.projectId).metadata();
ProjectMetadata projectMetadata = clusterState.metadata().getProject(updateSettingsTask.projectId);

Copy link
Member Author

Choose a reason for hiding this comment

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

I hadn't even realized that there were two ways to do it.

import java.util.List;
import java.util.Map;

public class TransportGetDataStreamSettingsAction extends TransportLocalProjectMetadataAction<
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️ for using the local action, thanks!

@@ -362,6 +407,21 @@ public static ClusterState setRolloverOnWrite(
);
}

public void updateSettings(
ProjectResolver projectResolver,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pass the project ID directly here instead of the project resolver? That avoids a dependency from this class on the resolver and it's in line with what we're doing in other places (both this class and other classes).

@masseyke masseyke merged commit bdb70c0 into elastic:main Apr 28, 2025
16 of 17 checks passed
@masseyke masseyke deleted the data-stream-settings-transport-action branch April 28, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants