|
41 | 41 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
42 | 42 | import org.elasticsearch.cluster.metadata.Metadata; |
43 | 43 | import org.elasticsearch.cluster.metadata.ProjectId; |
| 44 | +import org.elasticsearch.cluster.metadata.ProjectMetadata; |
44 | 45 | import org.elasticsearch.cluster.metadata.RepositoriesMetadata; |
45 | 46 | import org.elasticsearch.cluster.metadata.RepositoryMetadata; |
46 | 47 | import org.elasticsearch.cluster.node.DiscoveryNode; |
@@ -2407,9 +2408,16 @@ private ClusterState getClusterStateWithUpdatedRepositoryGeneration(ClusterState |
2407 | 2408 | throw new RepositoryException(repoMetadata.name(), "Found unexpected initialized repo metadata [" + repoMetadata + "]"); |
2408 | 2409 | } |
2409 | 2410 | final var project = currentState.metadata().getDefaultProject(); |
2410 | | - final var updatedMetadata = RepositoriesMetadata.get(project) |
2411 | | - .withUpdatedGeneration(repoMetadata.name(), repoData.getGenId(), repoData.getGenId()); |
2412 | | - return currentState.copyAndUpdateProject(project.id(), builder -> builder.putCustom(RepositoriesMetadata.TYPE, updatedMetadata)); |
| 2411 | + return ClusterState.builder(currentState) |
| 2412 | + .putProjectMetadata( |
| 2413 | + ProjectMetadata.builder(project) |
| 2414 | + .putCustom( |
| 2415 | + RepositoriesMetadata.TYPE, |
| 2416 | + RepositoriesMetadata.get(project) |
| 2417 | + .withUpdatedGeneration(repoMetadata.name(), repoData.getGenId(), repoData.getGenId()) |
| 2418 | + ) |
| 2419 | + ) |
| 2420 | + .build(); |
2413 | 2421 | } |
2414 | 2422 |
|
2415 | 2423 | /** |
@@ -2926,7 +2934,9 @@ public ClusterState execute(ClusterState currentState) { |
2926 | 2934 | ? withGenerations |
2927 | 2935 | : withGenerations.withUuid(metadata.name(), newRepositoryData.getUuid()); |
2928 | 2936 | final ClusterState newClusterState = stateFilter.apply( |
2929 | | - currentState.copyAndUpdateProject(project.id(), b -> b.putCustom(RepositoriesMetadata.TYPE, withUuid)) |
| 2937 | + ClusterState.builder(currentState) |
| 2938 | + .putProjectMetadata(ProjectMetadata.builder(project).putCustom(RepositoriesMetadata.TYPE, withUuid)) |
| 2939 | + .build() |
2930 | 2940 | ); |
2931 | 2941 | return updateRepositoryGenerationsIfNecessary(newClusterState, expectedGen, newGen); |
2932 | 2942 | } |
|
0 commit comments