Package org.elasticsearch.cluster.metadata

Examples of org.elasticsearch.cluster.metadata.AliasMetaData$Builder


        stopWatch.start();
        assertThat(client2.admin().indices().prepareAliases().addAlias("test", "alias1", termFilter("name", "bar")).setTimeout(timeout).execute().actionGet().acknowledged(), equalTo(true));
        assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));

        logger.info("--> verify that filter was updated");
        AliasMetaData aliasMetaData = ((InternalNode) node("server1")).injector().getInstance(ClusterService.class).state().metaData().aliases().get("alias1").get("test");
        assertThat(aliasMetaData.getFilter().toString(), equalTo("{\"term\":{\"name\":\"bar\"}}"));

        logger.info("--> deleting alias1");
        stopWatch.start();
        assertThat(client2.admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout).execute().actionGet().acknowledged(), equalTo(true));
        assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
View Full Code Here


        assertThat((Long) response.rows()[0][0], is(3L));

        GetIndexTemplatesResponse indexTemplatesResponse =
                client().admin().indices().prepareGetTemplates(".partitioned.t.").execute().actionGet();
        IndexTemplateMetaData indexTemplateMetaData = indexTemplatesResponse.getIndexTemplates().get(0);
        AliasMetaData t = indexTemplateMetaData.aliases().get("t");
        assertThat(t.alias(), is("t"));

        execute("select partitioned_by from information_schema.tables where table_name = 't'");
        assertThat(((String[]) response.rows()[0][0])[0], is("p"));
    }
View Full Code Here

    }

    private void processAliases(String index, ObjectContainer<AliasMetaData> aliases, IndexAliasesService indexAliasesService) {
        HashMap<String, IndexAlias> newAliases = newHashMap();
        for (ObjectCursor<AliasMetaData> cursor : aliases) {
            AliasMetaData aliasMd = cursor.value;
            String alias = aliasMd.alias();
            CompressedString filter = aliasMd.filter();
            try {
                if (!indexAliasesService.hasAlias(alias)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[{}] adding alias [{}], filter [{}]", index, alias, filter);
                    }
View Full Code Here

        assertThat(aliases, notNullValue());
        assertThat(aliases.size(), equalTo(1));
        ImmutableList<AliasMetaData> indexAliases = aliases.get(indexName);
        assertThat(indexAliases, notNullValue());
        assertThat(indexAliases.size(), equalTo(1));
        AliasMetaData alias = indexAliases.get(0);
        assertThat(alias, notNullValue());
        assertThat(alias.alias(), equalTo("alias_idx"));
    }
View Full Code Here

        //as the previous operation was acknowledged
        for (int i = 0; i < 2; i++) {
            assertAcked(client().admin().indices().prepareAliases().addAlias("test", "alias"));

            for (Client client : clients()) {
                AliasMetaData aliasMetaData = getLocalClusterState(client).metaData().aliases().get("alias").get("test");
                assertThat(aliasMetaData.alias(), equalTo("alias"));
            }
        }
    }
View Full Code Here

        stopWatch.start();
        assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termFilter("name", "bar")).setTimeout(timeout)));
        assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));

        logger.info("--> verify that filter was updated");
        AliasMetaData aliasMetaData = internalCluster().clusterService().state().metaData().aliases().get("alias1").get("test");
        assertThat(aliasMetaData.getFilter().toString(), equalTo("{\"term\":{\"name\":\"bar\"}}"));

        logger.info("--> deleting alias1");
        stopWatch.start();
        assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)));
        assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
View Full Code Here

    }
   
    private void checkAliases() {
        GetAliasesResponse getAliasesResponse = admin().indices().prepareGetAliases("alias1").get();
        assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
        AliasMetaData aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
        assertThat(aliasMetaData.alias(), equalTo("alias1"));
        assertThat(aliasMetaData.filter(), nullValue());
        assertThat(aliasMetaData.indexRouting(), nullValue());
        assertThat(aliasMetaData.searchRouting(), nullValue());

        getAliasesResponse = admin().indices().prepareGetAliases("alias2").get();
        assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
        aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
        assertThat(aliasMetaData.alias(), equalTo("alias2"));
        assertThat(aliasMetaData.filter(), notNullValue());
        assertThat(aliasMetaData.indexRouting(), nullValue());
        assertThat(aliasMetaData.searchRouting(), nullValue());

        getAliasesResponse = admin().indices().prepareGetAliases("alias3").get();
        assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
        aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
        assertThat(aliasMetaData.alias(), equalTo("alias3"));
        assertThat(aliasMetaData.filter(), nullValue());
        assertThat(aliasMetaData.indexRouting(), equalTo("index"));
        assertThat(aliasMetaData.searchRouting(), equalTo("search"));
    }
View Full Code Here

        assertThat(aliasesMap, notNullValue());
        assertThat(aliasesMap.size(), equalTo(1));
        ImmutableList<AliasMetaData> aliasesList = aliasesMap.get("test");
        assertThat(aliasesList, notNullValue());
        assertThat(aliasesList.size(), equalTo(1));
        AliasMetaData alias = aliasesList.get(0);
        assertThat(alias, notNullValue());
        assertThat(alias.alias(), equalTo("testAlias"));
    }
View Full Code Here

        for (ObjectCursor<String> alias : aliases.keys()) {
            builder.startObject(alias.value);
            builder.startArray("aliasMetadata");
            for (ObjectCursor<String> s : aliases.get(alias.value).keys()) {
                builder.startObject();
                AliasMetaData amd = aliases.get(alias.value).get(s.value);
                builder.field("alias", amd.getAlias());
                builder.field("filter", amd.getFilter().string());
                builder.field("indexRouting", amd.getIndexRouting());
                builder.field("searchRouting", amd.getSearchRouting());
                builder.endObject();
            }
            builder.endArray();
            builder.endObject();
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.metadata.AliasMetaData$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.