3030import org .elasticsearch .cluster .routing .ShardRoutingState ;
3131import org .elasticsearch .cluster .routing .UnassignedInfo ;
3232import org .elasticsearch .cluster .service .ClusterService ;
33- import org .elasticsearch .core .CheckedConsumer ;
3433import org .elasticsearch .common .Priority ;
3534import org .elasticsearch .common .settings .Settings ;
36- import org .elasticsearch .xcontent . XContentFactory ;
35+ import org .elasticsearch .core . CheckedConsumer ;
3736import org .elasticsearch .core .internal .io .IOUtils ;
3837import org .elasticsearch .env .NodeEnvironment ;
3938import org .elasticsearch .env .NodeMetadata ;
4443import org .elasticsearch .test .ESIntegTestCase .ClusterScope ;
4544import org .elasticsearch .test .ESIntegTestCase .Scope ;
4645import org .elasticsearch .test .InternalTestCluster .RestartCallback ;
46+ import org .elasticsearch .xcontent .XContentFactory ;
4747
4848import java .io .IOException ;
4949import java .nio .file .Path ;
@@ -516,11 +516,11 @@ public void testHalfDeletedIndexImport() throws Exception {
516516 final Path [] paths = internalCluster ().getInstance (NodeEnvironment .class ).nodeDataPaths ();
517517 final String nodeId = client ().admin ().cluster ().prepareNodesInfo (nodeName ).clear ().get ().getNodes ().get (0 ).getNode ().getId ();
518518
519- writeBrokenMeta (metaStateService -> {
519+ writeBrokenMeta (nodeEnvironment -> {
520520 for (final Path path : paths ) {
521521 IOUtils .rm (path .resolve (PersistedClusterStateService .METADATA_DIRECTORY_NAME ));
522522 }
523- metaStateService .writeGlobalState ("test" , Metadata .builder (metadata )
523+ MetaStateWriterUtils .writeGlobalState (nodeEnvironment , "test" , Metadata .builder (metadata )
524524 // we remove the manifest file, resetting the term and making this look like an upgrade from 6.x, so must also reset the
525525 // term in the coordination metadata
526526 .coordinationMetadata (CoordinationMetadata .builder (metadata .coordinationMetadata ()).term (0L ).build ())
@@ -534,14 +534,14 @@ public void testHalfDeletedIndexImport() throws Exception {
534534 assertBusy (() -> assertThat (internalCluster ().getInstance (NodeEnvironment .class ).availableIndexFolders (), empty ()));
535535 }
536536
537- private void writeBrokenMeta (CheckedConsumer <MetaStateService , IOException > writer ) throws Exception {
538- Map <String , MetaStateService > metaStateServices = Stream .of (internalCluster ().getNodeNames ())
539- .collect (Collectors .toMap (Function .identity (), nodeName -> internalCluster ().getInstance (MetaStateService .class , nodeName )));
537+ private void writeBrokenMeta (CheckedConsumer <NodeEnvironment , IOException > writer ) throws Exception {
538+ Map <String , NodeEnvironment > nodeEnvironments = Stream .of (internalCluster ().getNodeNames ())
539+ .collect (Collectors .toMap (Function .identity (), nodeName -> internalCluster ().getInstance (NodeEnvironment .class , nodeName )));
540540 internalCluster ().fullRestart (new RestartCallback (){
541541 @ Override
542542 public Settings onNodeStopped (String nodeName ) throws Exception {
543- final MetaStateService metaStateService = metaStateServices .get (nodeName );
544- writer .accept (metaStateService );
543+ final NodeEnvironment nodeEnvironment = nodeEnvironments .get (nodeName );
544+ writer .accept (nodeEnvironment );
545545 return super .onNodeStopped (nodeName );
546546 }
547547 });
0 commit comments