opensearch-project/OpenSearch

[Metadata Immutability] Change different indices lookup objects from array type to lists

Open

#8,647 建立於 2023年7月11日

在 GitHub 查看
 (12 留言) (0 反應) (1 負責人)Java (1,505 fork)batch import
Cluster Managerenhancementgood first issue

倉庫指標

Star
 (8,123 star)
PR 合併指標
 (平均合併 5天 9小時) (30 天內合併 266 個 PR)

描述

Is your feature request related to a problem? Please describe. Metadata object as part of ClusterState is supposed to be immutable by design. However, certain objects within Metadata do not reflect this design.

The following arrays should be replaced with lists and should implement Collections.unmodifiableList() or any other immutable implementations. Assigning them as arrays leave them open for mutability. https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/cluster/metadata/Metadata.java#L268

 String[] allIndices,
 String[] visibleIndices,
 String[] allOpenIndices,
 String[] visibleOpenIndices,
 String[] allClosedIndices,
 String[] visibleClosedIndices,

Also, the usage of these arrays is prominently in IndexNameExpressionResolver where before these arrays are utilized, they are converted to lists before they are consumed. It is thus unreasonable to keep these objects as arrays as opposed to lists.

Describe the solution you'd like Store the above objects as lists, and implement them as Collections.unmodifiableList() in the Metadata constructor.

Describe alternatives you've considered Briefly discussed this change here, but this change was out of scope of https://github.com/opensearch-project/OpenSearch/pull/7853

Additional context this change will require changes in how the metadata or its diff is parsed as XContent as well.

貢獻者指南