Search in sources :

Example 6 with IndexGraveyard

use of org.elasticsearch.cluster.metadata.IndexGraveyard in project crate by crate.

the class DanglingIndicesStateTests method testDanglingIndicesNotImportedWhenTombstonePresent.

public void testDanglingIndicesNotImportedWhenTombstonePresent() throws Exception {
    try (NodeEnvironment env = newNodeEnvironment()) {
        MetaStateService metaStateService = new MetaStateService(env, xContentRegistry());
        DanglingIndicesState danglingState = createDanglingIndicesState(env, metaStateService);
        final Settings.Builder settings = Settings.builder().put(indexSettings).put(IndexMetadata.SETTING_INDEX_UUID, "test1UUID");
        IndexMetadata dangledIndex = IndexMetadata.builder("test1").settings(settings).build();
        metaStateService.writeIndex("test_write", dangledIndex);
        final IndexGraveyard graveyard = IndexGraveyard.builder().addTombstone(dangledIndex.getIndex()).build();
        final Metadata metadata = Metadata.builder().indexGraveyard(graveyard).build();
        assertThat(danglingState.findNewDanglingIndices(metadata).size(), equalTo(0));
    }
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment) IndexGraveyard(org.elasticsearch.cluster.metadata.IndexGraveyard) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

IndexGraveyard (org.elasticsearch.cluster.metadata.IndexGraveyard)6 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)4 Index (org.elasticsearch.index.Index)4 HashSet (java.util.HashSet)3 Settings (org.elasticsearch.common.settings.Settings)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 IndexMetadata (org.elasticsearch.cluster.metadata.IndexMetadata)2 MetaData (org.elasticsearch.cluster.metadata.MetaData)2 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)2 ArrayList (java.util.ArrayList)1 ClusterName (org.elasticsearch.cluster.ClusterName)1 ClusterState (org.elasticsearch.cluster.ClusterState)1 Metadata (org.elasticsearch.cluster.metadata.Metadata)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1