Search in sources :

Example 31 with IndicesOptions

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions in project elasticsearch by elastic.

the class IndicesOptionsIntegrationIT method testSpecifiedIndexUnavailableSnapshotRestore.

public void testSpecifiedIndexUnavailableSnapshotRestore() throws Exception {
    createIndex("test1");
    ensureGreen("test1");
    waitForRelocation();
    PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("dummy-repo").setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
    client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get();
    verify(snapshot("snap2", "test1", "test2"), true);
    verify(restore("snap1", "test1", "test2"), true);
    IndicesOptions options = IndicesOptions.strictExpandOpen();
    verify(snapshot("snap2", "test1", "test2").setIndicesOptions(options), true);
    verify(restore("snap1", "test1", "test2").setIndicesOptions(options), true);
    options = IndicesOptions.lenientExpandOpen();
    verify(snapshot("snap2", "test1", "test2").setIndicesOptions(options), false);
    verify(restore("snap2", "test1", "test2").setIndicesOptions(options), false);
    options = IndicesOptions.strictExpandOpen();
    createIndex("test2");
    //TODO: temporary work-around for #5531
    ensureGreen("test2");
    waitForRelocation();
    verify(snapshot("snap3", "test1", "test2").setIndicesOptions(options), false);
    verify(restore("snap3", "test1", "test2").setIndicesOptions(options), false);
}
Also used : PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Example 32 with IndicesOptions

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions in project elasticsearch by elastic.

the class IndexNameExpressionResolverTests method testIndexOptionsStrict.

public void testIndexOptionsStrict() {
    MetaData.Builder mdBuilder = MetaData.builder().put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar"))).put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar"))).put(indexBuilder("foofoo-closed").state(IndexMetaData.State.CLOSE)).put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndicesOptions[] indicesOptions = new IndicesOptions[] { IndicesOptions.strictExpandOpen(), IndicesOptions.strictExpand() };
    for (IndicesOptions options : indicesOptions) {
        IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, options);
        String[] results = indexNameExpressionResolver.concreteIndexNames(context, "foo");
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "bar");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("bar"));
        }
        results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo", "foobar");
        assertEquals(2, results.length);
        assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar"));
        results = indexNameExpressionResolver.concreteIndexNames(context, "foofoobar");
        assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")), new HashSet<>(Arrays.asList(results)));
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "bar");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("bar"));
        }
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "foo", "bar");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("bar"));
        }
        results = indexNameExpressionResolver.concreteIndexNames(context, "barbaz", "foobar");
        assertEquals(2, results.length);
        assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar"));
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "barbaz", "bar");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("bar"));
        }
        results = indexNameExpressionResolver.concreteIndexNames(context, "baz*");
        assertThat(results, emptyArray());
        results = indexNameExpressionResolver.concreteIndexNames(context, "foo", "baz*");
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);
    }
    IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpandOpen());
    String[] results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(3, results.length);
    results = indexNameExpressionResolver.concreteIndexNames(context, (String[]) null);
    assertEquals(3, results.length);
    context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpand());
    results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(4, results.length);
    results = indexNameExpressionResolver.concreteIndexNames(context, (String[]) null);
    assertEquals(4, results.length);
    context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpandOpen());
    results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo*");
    assertEquals(3, results.length);
    assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo"));
    context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpand());
    results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo*");
    assertEquals(4, results.length);
    assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo", "foofoo-closed"));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) Matchers.containsString(org.hamcrest.Matchers.containsString) ClusterName(org.elasticsearch.cluster.ClusterName) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Example 33 with IndicesOptions

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions in project elasticsearch by elastic.

the class IndexNameExpressionResolverTests method testIndexOptionsAllowUnavailableDisallowEmpty.

public void testIndexOptionsAllowUnavailableDisallowEmpty() {
    MetaData.Builder mdBuilder = MetaData.builder().put(indexBuilder("foo")).put(indexBuilder("foobar")).put(indexBuilder("foofoo-closed").state(IndexMetaData.State.CLOSE)).put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndicesOptions expandOpen = IndicesOptions.fromOptions(true, false, true, false);
    IndicesOptions expand = IndicesOptions.fromOptions(true, false, true, true);
    IndicesOptions[] indicesOptions = new IndicesOptions[] { expandOpen, expand };
    for (IndicesOptions options : indicesOptions) {
        IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, options);
        String[] results = indexNameExpressionResolver.concreteIndexNames(context, "foo");
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "bar");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("bar"));
        }
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "baz*");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("baz*"));
        }
        try {
            indexNameExpressionResolver.concreteIndexNames(context, "foo", "baz*");
            fail();
        } catch (IndexNotFoundException e) {
            assertThat(e.getIndex().getName(), equalTo("baz*"));
        }
    }
    IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, expandOpen);
    String[] results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(3, results.length);
    context = new IndexNameExpressionResolver.Context(state, expand);
    results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(4, results.length);
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterName(org.elasticsearch.cluster.ClusterName) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) Matchers.containsString(org.hamcrest.Matchers.containsString) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Example 34 with IndicesOptions

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions in project elasticsearch by elastic.

the class IndexNameExpressionResolverTests method testDedupConcreteIndices.

public void testDedupConcreteIndices() {
    MetaData.Builder mdBuilder = MetaData.builder().put(indexBuilder("index1").putAlias(AliasMetaData.builder("alias1")));
    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndicesOptions[] indicesOptions = new IndicesOptions[] { IndicesOptions.strictExpandOpen(), IndicesOptions.strictExpand(), IndicesOptions.lenientExpandOpen(), IndicesOptions.strictExpandOpenAndForbidClosed() };
    for (IndicesOptions options : indicesOptions) {
        IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, options);
        String[] results = indexNameExpressionResolver.concreteIndexNames(context, "index1", "index1", "alias1");
        assertThat(results, equalTo(new String[] { "index1" }));
    }
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterName(org.elasticsearch.cluster.ClusterName) Matchers.containsString(org.hamcrest.Matchers.containsString) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Example 35 with IndicesOptions

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.IndicesOptions in project elasticsearch by elastic.

the class IndexNameExpressionResolverTests method testIndexOptionsLenient.

public void testIndexOptionsLenient() {
    MetaData.Builder mdBuilder = MetaData.builder().put(indexBuilder("foo").putAlias(AliasMetaData.builder("foofoobar"))).put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar"))).put(indexBuilder("foofoo-closed").state(IndexMetaData.State.CLOSE)).put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndicesOptions lenientExpand = IndicesOptions.fromOptions(true, true, true, true);
    IndicesOptions[] indicesOptions = new IndicesOptions[] { IndicesOptions.lenientExpandOpen(), lenientExpand };
    for (IndicesOptions options : indicesOptions) {
        IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, options);
        String[] results = indexNameExpressionResolver.concreteIndexNames(context, "foo");
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);
        results = indexNameExpressionResolver.concreteIndexNames(context, "bar");
        assertThat(results, emptyArray());
        results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo", "foobar");
        assertEquals(2, results.length);
        assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar"));
        results = indexNameExpressionResolver.concreteIndexNames(context, "foofoobar");
        assertEquals(2, results.length);
        assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")), new HashSet<>(Arrays.asList(results)));
        results = indexNameExpressionResolver.concreteIndexNames(context, "foo", "bar");
        assertEquals(1, results.length);
        assertThat(results, arrayContainingInAnyOrder("foo"));
        results = indexNameExpressionResolver.concreteIndexNames(context, "barbaz", "foobar");
        assertEquals(2, results.length);
        assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar"));
        results = indexNameExpressionResolver.concreteIndexNames(context, "barbaz", "bar");
        assertEquals(1, results.length);
        assertThat(results, arrayContainingInAnyOrder("foofoo"));
        results = indexNameExpressionResolver.concreteIndexNames(context, "baz*");
        assertThat(results, emptyArray());
        results = indexNameExpressionResolver.concreteIndexNames(context, "foo", "baz*");
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);
    }
    IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.lenientExpandOpen());
    String[] results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(3, results.length);
    context = new IndexNameExpressionResolver.Context(state, lenientExpand);
    results = indexNameExpressionResolver.concreteIndexNames(context, Strings.EMPTY_ARRAY);
    assertEquals(Arrays.toString(results), 4, results.length);
    context = new IndexNameExpressionResolver.Context(state, IndicesOptions.lenientExpandOpen());
    results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo*");
    assertEquals(3, results.length);
    assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo"));
    context = new IndexNameExpressionResolver.Context(state, lenientExpand);
    results = indexNameExpressionResolver.concreteIndexNames(context, "foofoo*");
    assertEquals(4, results.length);
    assertThat(results, arrayContainingInAnyOrder("foo", "foobar", "foofoo", "foofoo-closed"));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterName(org.elasticsearch.cluster.ClusterName) Matchers.containsString(org.hamcrest.Matchers.containsString) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Aggregations

IndicesOptions (org.elasticsearch.action.support.IndicesOptions)39 ClusterState (org.elasticsearch.cluster.ClusterState)11 IndexNotFoundException (org.elasticsearch.index.IndexNotFoundException)11 ClusterName (org.elasticsearch.cluster.ClusterName)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 HashSet (java.util.HashSet)6 Set (java.util.Set)6 Arrays (java.util.Arrays)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)4 SearchRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest)4 SearchSourceBuilder (org.graylog.shaded.elasticsearch7.org.elasticsearch.search.builder.SearchSourceBuilder)4 Row (io.crate.data.Row)3 Row1 (io.crate.data.Row1)3 RowConsumer (io.crate.data.RowConsumer)3 OneRowActionListener (io.crate.execution.support.OneRowActionListener)3 DependencyCarrier (io.crate.planner.DependencyCarrier)3 Plan (io.crate.planner.Plan)3 PlannerContext (io.crate.planner.PlannerContext)3