Skip to content
Merged
Changes from 1 commit
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 @@ -21,6 +21,7 @@
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetadataDataStreamsService;
import org.elasticsearch.cluster.metadata.ProjectId;
import org.elasticsearch.cluster.project.ProjectResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -82,7 +83,7 @@ protected void masterOperation(
ActionListener<UpdateDataStreamMappingsAction.Response> listener
) throws Exception {
List<String> dataStreamNames = indexNameExpressionResolver.dataStreamNames(
state.projectState(projectResolver.getProjectId()).metadata(),
projectResolver.getProjectMetadata(state),
IndicesOptions.DEFAULT,
request.indices()
);
Expand Down Expand Up @@ -143,8 +144,9 @@ private void updateSingleDataStream(
);
return;
}
ProjectId projectId = projectResolver.getProjectId();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a pretty small nit, but we usually prefer to resolve the project ID only once, to avoid any confusion whatsoever (and to save a thread context lookup, although that's pretty minor).

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'm only getting the project ID once, right? Where is the other time?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I meant "using the project resolver", as the project resolver is getting the project ID from thread context. I'm referring to projectResolver.getProjectMetadata(state) above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, ok. I've changed that now. I never thought of projectId as something I need to be careful about accessing. It's possible there are other places where I'm accessing it frequently.

metadataDataStreamsService.updateMappings(
projectResolver.getProjectId(),
projectId,
masterNodeTimeout,
ackTimeout,
dataStreamName,
Expand All @@ -159,9 +161,7 @@ private void updateSingleDataStream(
true,
null,
mappingsOverrides,
dataStream.getEffectiveMappings(
clusterService.state().projectState(projectResolver.getProjectId()).metadata()
)
dataStream.getEffectiveMappings(clusterService.state().projectState(projectId).metadata())
)
);
} catch (IOException e) {
Expand Down