• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CloseIndexResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.admin.indices.close.CloseIndexResponse的典型用法代码示例。如果您正苦于以下问题:Java CloseIndexResponse类的具体用法?Java CloseIndexResponse怎么用?Java CloseIndexResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CloseIndexResponse类属于org.elasticsearch.action.admin.indices.close包,在下文中一共展示了CloseIndexResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCloseOpenMultipleIndices

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOpenMultipleIndices() {
    Client client = client();
    createIndex("test1", "test2", "test3");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    CloseIndexResponse closeIndexResponse1 = client.admin().indices().prepareClose("test1").execute().actionGet();
    assertThat(closeIndexResponse1.isAcknowledged(), equalTo(true));
    CloseIndexResponse closeIndexResponse2 = client.admin().indices().prepareClose("test2").execute().actionGet();
    assertThat(closeIndexResponse2.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");
    assertIndexIsOpened("test3");

    OpenIndexResponse openIndexResponse1 = client.admin().indices().prepareOpen("test1").execute().actionGet();
    assertThat(openIndexResponse1.isAcknowledged(), equalTo(true));
    OpenIndexResponse openIndexResponse2 = client.admin().indices().prepareOpen("test2").execute().actionGet();
    assertThat(openIndexResponse2.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2", "test3");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:OpenCloseIndexIT.java


示例2: testCloseAlreadyClosedIndex

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseAlreadyClosedIndex() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    //closing the index
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");

    //no problem if we try to close an index that's already in close state
    closeIndexResponse = client.admin().indices().prepareClose("test1").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:OpenCloseIndexIT.java


示例3: testSimpleCloseOpenAlias

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testSimpleCloseOpenAlias() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    IndicesAliasesResponse aliasesResponse = client.admin().indices().prepareAliases().addAlias("test1", "test1-alias").execute().actionGet();
    assertThat(aliasesResponse.isAcknowledged(), equalTo(true));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:OpenCloseIndexIT.java


示例4: testCloseOpenAliasMultipleIndices

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOpenAliasMultipleIndices() {
    Client client = client();
    createIndex("test1", "test2");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    IndicesAliasesResponse aliasesResponse1 = client.admin().indices().prepareAliases().addAlias("test1", "test-alias").execute().actionGet();
    assertThat(aliasesResponse1.isAcknowledged(), equalTo(true));
    IndicesAliasesResponse aliasesResponse2 = client.admin().indices().prepareAliases().addAlias("test2", "test-alias").execute().actionGet();
    assertThat(aliasesResponse2.isAcknowledged(), equalTo(true));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:OpenCloseIndexIT.java


示例5: testSimpleCloseOpen

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testSimpleCloseOpen() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:OpenCloseIndexIT.java


示例6: testCloseOneMissingIndexIgnoreMissing

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOneMissingIndexIgnoreMissing() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1", "test2")
            .setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:OpenCloseIndexIT.java


示例7: testCloseOpenWildcard

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOpenWildcard() {
    Client client = client();
    createIndex("test1", "test2", "a");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test*").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");
    assertIndexIsOpened("a");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test*").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2", "a");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:OpenCloseIndexIT.java


示例8: testCloseOpenAll

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOpenAll() {
    Client client = client();
    createIndex("test1", "test2", "test3");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("_all").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2", "test3");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("_all").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2", "test3");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:OpenCloseIndexIT.java


示例9: testCloseOpenAllWildcard

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseOpenAllWildcard() {
    Client client = client();
    createIndex("test1", "test2", "test3");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("*").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2", "test3");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("*").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2", "test3");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:OpenCloseIndexIT.java


示例10: testCloseIndexNoAcknowledgement

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testCloseIndexNoAcknowledgement() {
    createIndex("test");
    ensureGreen();

    CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test").setTimeout("0s").get();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(false));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:AckIT.java


示例11: testOpenIndexNoAcknowledgement

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testOpenIndexNoAcknowledgement() {
    createIndex("test");
    ensureGreen();
    removePublishTimeout();
    CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));

    OpenIndexResponse openIndexResponse = client().admin().indices().prepareOpen("test").setTimeout("0s").get();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(false));
    ensureGreen("test"); // make sure that recovery from disk has completed, so that check index doesn't fail.
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:AckClusterUpdateSettingsIT.java


示例12: handleRequest

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    CloseIndexRequest closeIndexRequest = new CloseIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
    closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout()));
    closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
    closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
    client.admin().indices().close(closeIndexRequest, new AcknowledgedRestListener<CloseIndexResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:RestCloseIndexAction.java


示例13: closeAllIndices

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void closeAllIndices() {
	CloseIndexResponse closeIndexResponse = internalClient.admin().indices().prepareClose("_all")//
			.setIndicesOptions(IndicesOptions.fromOptions(false, true, true, true))//
			.get();

	if (!closeIndexResponse.isAcknowledged())
		throw Exceptions.runtime(//
				"close all indices not acknowledged by the cluster");
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:10,代码来源:ElasticClient.java


示例14: should_open_index

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
@Test
public void should_open_index() throws Exception {
    CloseIndexResponse closeIndexResponse = transportClient.admin().indices().close(new CloseIndexRequest(THE_INDEX)).actionGet();
    Assertions.assertThat(closeIndexResponse.isAcknowledged()).isTrue();

    OpenIndexResponse openIndexResponse = httpClient.admin().indices().open(new OpenIndexRequest(THE_INDEX)).get();
    Assertions.assertThat(openIndexResponse.isAcknowledged()).isTrue();

    transportClient.admin().indices().recoveries(new RecoveryRequest(THE_INDEX)).actionGet();
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:11,代码来源:OpenIndexActionHandlerTest.java


示例15: should_fail_when_no_index_specified

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
@Test
public void should_fail_when_no_index_specified() throws Exception {
    CloseIndexResponse closeIndexResponse = transportClient.admin().indices().close(new CloseIndexRequest(THE_INDEX)).actionGet();
    Assertions.assertThat(closeIndexResponse.isAcknowledged()).isTrue();

    try {
        httpClient.admin().indices().open(new OpenIndexRequest()).get();
    } catch (Exception e) {
        Assertions.assertThat(e).hasMessageContaining("ActionRequestValidationException");
        Assertions.assertThat(e).hasMessageContaining("index is missing");
    }
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:13,代码来源:OpenIndexActionHandlerTest.java


示例16: closeIndex

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public CloseIndexResponse closeIndex(final String index,
        final BuilderCallback<CloseIndexRequestBuilder> builder) {
    final CloseIndexResponse actionGet = builder
            .apply(client().admin().indices().prepareClose(index)).execute()
            .actionGet();
    if (!actionGet.isAcknowledged()) {
        onFailure("Failed to close " + index + ".", actionGet);
    }
    return actionGet;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:11,代码来源:ElasticsearchClusterRunner.java


示例17: mergeIndexSettings

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
/**
 * Create a new index in ElasticSearch
 * @param index Index name
 * @throws Exception
 */
private void mergeIndexSettings(String index) throws Exception {
	if (logger.isTraceEnabled()){
		logger.trace("mergeIndexSettings("+index+")");
	}
	if (logger.isDebugEnabled()){
		logger.debug("Index " + index + " already exists. Trying to merge settings.");
	}
	
	checkClient();

       // If there are settings for this index, we use it. If not, using Elasticsearch defaults.
       String source = readUpdateIndexSettings(index);
       if (source != null) {
           if (logger.isTraceEnabled()){
           	logger.trace("Found settings for index "+index+" : " + source);
           }

           CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose(index).execute().actionGet();
           if (!closeIndexResponse.isAcknowledged()){
           	throw new Exception("Could not close index ["+index+"].");
           }

           client.admin().indices().prepareUpdateSettings(index).setSettings(source).execute().actionGet();

           OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen(index).execute().actionGet();
           if (!openIndexResponse.isAcknowledged()){
           	throw new Exception("Could not open index ["+index+"].");
           }
	}
	

	if (logger.isTraceEnabled()){
		logger.trace("/mergeIndexSettings("+index+")");
	}
}
 
开发者ID:yamingd,项目名称:argo,代码行数:41,代码来源:ElasticsearchAbstractClientFactoryBean.java


示例18: toXContent

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(CloseIndexRequest request, CloseIndexResponse response, XContentBuilder builder) throws IOException {
    return builder.startObject()
            .field(Fields.OK, true)
            .field(Fields.ACKNOWLEDGED, response.isAcknowledged())
            .endObject();
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:8,代码来源:CloseIndexRequestBuilder.java


示例19: close

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
@Override
public ActionFuture<CloseIndexResponse> close(final CloseIndexRequest request) {
    return execute(CloseIndexAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例20: testSimpleOpenClose

import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; //导入依赖的package包/类
public void testSimpleOpenClose() {
    logger.info("--> creating test index");
    createIndex("test");

    logger.info("--> waiting for green status");
    ensureGreen();

    NumShards numShards = getNumShards("test");

    ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get();
    assertThat(stateResponse.getState().metaData().index("test").getState(), equalTo(IndexMetaData.State.OPEN));
    assertThat(stateResponse.getState().routingTable().index("test").shards().size(), equalTo(numShards.numPrimaries));
    assertEquals(stateResponse.getState().routingTable().index("test").shardsWithState(ShardRoutingState.STARTED).size()
        , numShards.totalNumShards);

    logger.info("--> indexing a simple document");
    client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();

    logger.info("--> closing test index...");
    CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test").get();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));

    stateResponse = client().admin().cluster().prepareState().get();
    assertThat(stateResponse.getState().metaData().index("test").getState(), equalTo(IndexMetaData.State.CLOSE));
    assertThat(stateResponse.getState().routingTable().index("test"), nullValue());

    logger.info("--> trying to index into a closed index ...");
    try {
        client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
        fail();
    } catch (IndexClosedException e) {
        // all is well
    }

    logger.info("--> opening index...");
    OpenIndexResponse openIndexResponse = client().admin().indices().prepareOpen("test").get();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));

    logger.info("--> waiting for green status");
    ensureGreen();

    stateResponse = client().admin().cluster().prepareState().get();
    assertThat(stateResponse.getState().metaData().index("test").getState(), equalTo(IndexMetaData.State.OPEN));

    assertThat(stateResponse.getState().routingTable().index("test").shards().size(), equalTo(numShards.numPrimaries));
    assertEquals(stateResponse.getState().routingTable().index("test").shardsWithState(ShardRoutingState.STARTED).size(),
        numShards.totalNumShards);

    logger.info("--> indexing a simple document");
    client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:52,代码来源:SimpleIndexStateIT.java



注:本文中的org.elasticsearch.action.admin.indices.close.CloseIndexResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LatLongUtils类代码示例发布时间:2022-05-22
下一篇:
Java ContentType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap