Skip to content

Commit b799cb7

Browse files
committed
Rewrite this in terms of project metadata manipulation
1 parent 139bcd9 commit b799cb7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CopyLifecycleIndexMetadataTransportAction.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.cluster.block.ClusterBlockLevel;
2323
import org.elasticsearch.cluster.metadata.IndexMetadata;
2424
import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
25-
import org.elasticsearch.cluster.metadata.Metadata;
25+
import org.elasticsearch.cluster.metadata.ProjectMetadata;
2626
import org.elasticsearch.cluster.service.ClusterService;
2727
import org.elasticsearch.cluster.service.MasterServiceTaskQueue;
2828
import org.elasticsearch.common.Priority;
@@ -90,12 +90,12 @@ protected ClusterBlockException checkBlock(CopyLifecycleIndexMetadataAction.Requ
9090
}
9191

9292
private static ClusterState applyUpdate(ClusterState state, UpdateIndexMetadataTask updateTask) {
93-
94-
IndexMetadata sourceMetadata = state.metadata().getProject().index(updateTask.sourceIndex);
93+
final ProjectMetadata projectMetadata = state.metadata().getProject();
94+
IndexMetadata sourceMetadata = projectMetadata.index(updateTask.sourceIndex);
9595
if (sourceMetadata == null) {
9696
throw new IndexNotFoundException(updateTask.sourceIndex);
9797
}
98-
IndexMetadata destMetadata = state.metadata().getProject().index(updateTask.destIndex);
98+
IndexMetadata destMetadata = projectMetadata.index(updateTask.destIndex);
9999
if (destMetadata == null) {
100100
throw new IndexNotFoundException(updateTask.destIndex);
101101
}
@@ -113,11 +113,11 @@ private static ClusterState applyUpdate(ClusterState state, UpdateIndexMetadataT
113113
// creation date updates settings so must increment settings version
114114
.settingsVersion(destMetadata.getSettingsVersion() + 1);
115115

116-
var indices = new HashMap<>(state.metadata().getProject().indices());
116+
var indices = new HashMap<>(projectMetadata.indices());
117117
indices.put(updateTask.destIndex, newDestMetadata.build());
118118

119-
Metadata newMetadata = Metadata.builder(state.metadata()).indices(indices).build();
120-
return ClusterState.builder(state).metadata(newMetadata).build();
119+
ProjectMetadata newMetadata = ProjectMetadata.builder(projectMetadata).indices(indices).build();
120+
return ClusterState.builder(state).putProjectMetadata(newMetadata).build();
121121
}
122122

123123
static class UpdateIndexMetadataTask extends AckedBatchedClusterStateUpdateTask {

0 commit comments

Comments
 (0)