当前位置: 首页>>代码示例>>Java>>正文


Java DeleteIndexResponse类代码示例

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


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

示例1: testDeleteIndex

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Test
public void testDeleteIndex() {
    //Test data
    final String indexName = "index";
    final AdminClient adminClient = createMock(AdminClient.class);
    final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
    final DeleteIndexRequestBuilder deleteIndexRequestBuilder = createMock(DeleteIndexRequestBuilder.class);
    final DeleteIndexResponse deleteIndexResponse = createMock(DeleteIndexResponse.class);
    //Reset
    resetAll();
    //Expectations
    expect(esClient.admin()).andReturn(adminClient);
    expect(adminClient.indices()).andReturn(indicesAdminClient);
    expect(indicesAdminClient.prepareDelete(indexName)).andReturn(deleteIndexRequestBuilder);
    expect(deleteIndexRequestBuilder.get()).andReturn(deleteIndexResponse);
    //Replay
    replayAll();
    //Run test scenario
    final boolean result = elasticsearchClientWrapper.deleteIndex(indexName);
    //Verify
    verifyAll();
    assertEquals(deleteIndexResponse.isAcknowledged(), result);
}
 
开发者ID:Biacode,项目名称:escommons,代码行数:24,代码来源:ElasticsearchClientWrapperImplTest.java

示例2: deleteOrphans

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
private void deleteOrphans(final CreateTableResponseListener listener, final CreateTableAnalyzedStatement statement) {
    if (clusterService.state().metaData().hasAlias(statement.tableIdent().fqn())
        && PartitionName.isPartition(
            clusterService.state().metaData().getAliasAndIndexLookup().get(statement.tableIdent().fqn()).getIndices().iterator().next().getIndex())) {
        logger.debug("Deleting orphaned partitions with alias: {}", statement.tableIdent().fqn());
        transportActionProvider.transportDeleteIndexAction().execute(new DeleteIndexRequest(statement.tableIdent().fqn()), new ActionListener<DeleteIndexResponse>() {
            @Override
            public void onResponse(DeleteIndexResponse response) {
                if (!response.isAcknowledged()) {
                    warnNotAcknowledged("deleting orphaned alias");
                }
                deleteOrphanedPartitions(listener, statement.tableIdent());
            }

            @Override
            public void onFailure(Throwable e) {
                listener.onFailure(e);
            }
        });
    } else {
        deleteOrphanedPartitions(listener, statement.tableIdent());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:TableCreator.java

示例3: deleteOrphanedPartitions

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
/**
 * if some orphaned partition with the same table name still exist,
 * delete them beforehand as they would create unwanted and maybe invalid
 * initial data.
 *
 * should never delete partitions of existing partitioned tables
 */
private void deleteOrphanedPartitions(final CreateTableResponseListener listener, TableIdent tableIdent) {
    String partitionWildCard = PartitionName.templateName(tableIdent.schema(), tableIdent.name()) + "*";
    String[] orphans = indexNameExpressionResolver.concreteIndices(clusterService.state(), IndicesOptions.strictExpand(), partitionWildCard);
    if (orphans.length > 0) {
        if (logger.isDebugEnabled()) {
            logger.debug("Deleting orphaned partitions: {}", Joiner.on(", ").join(orphans));
        }
        transportActionProvider.transportDeleteIndexAction().execute(new DeleteIndexRequest(orphans), new ActionListener<DeleteIndexResponse>() {
            @Override
            public void onResponse(DeleteIndexResponse response) {
                if (!response.isAcknowledged()) {
                    warnNotAcknowledged("deleting orphans");
                }
                listener.onResponse(SUCCESS_RESULT);
            }

            @Override
            public void onFailure(Throwable e) {
                listener.onFailure(e);
            }
        });
    } else {
        listener.onResponse(SUCCESS_RESULT);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:TableCreator.java

示例4: testCreateIndex

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
/**
     * index作成.
     */
    @Test
    public void testCreateIndex() throws Exception {
        // index名は英数小文字のみ。記号はハイフンであれば許容されるよう
        String index = "9-1234-5";
//        String index = "01test-create-index";

        try {
            CreateIndexResponse response = createIndex(index);
            assertThat(response.isAcknowledged(), is(true));
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            // 後始末
            DeleteIndexResponse deleteIndexResponse = deleteIndex(index);
            assertThat(deleteIndexResponse.isAcknowledged(), is(true));
        }
    }
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:22,代码来源:ElasticSearchTest.java

示例5: delete

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
/**
 * Delete an index in Elasticsearch.
 *
 * @param indexName
 *
 * @return true if the request was acknowledged.
 */
public static boolean delete(String indexName) {
  synchronized (Indices.class) {
    try {
      DeleteIndexResponse response = self.client.getClient().admin().indices().delete(new DeleteIndexRequest(indexName)).get();
      if (response.isAcknowledged()) {
        self.indexCache.remove(indexName);
        return true;
      } else {
        return false;
      }
    } catch (InterruptedException|ExecutionException e) {
      log.error("Error while deleting index", e);
      return false;
    }
  }
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:24,代码来源:Indices.java

示例6: addDataTag

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Test
public void addDataTag() throws Exception {
  DataTagCacheObject tag = (DataTagCacheObject) EntityUtils.createDataTag();

  TagConfigDocument document = converter.convert(tag)
          .orElseThrow(()->new Exception("Tag conversion failed"));
  String index = Indices.indexFor(document);

  indexer.indexTagConfig(document);
  assertTrue(Indices.exists(index));

  // Refresh the index to make sure the document is searchable
  client.getClient().admin().indices().prepareRefresh(index).get();
  client.getClient().admin().cluster().prepareHealth().setIndices(index).setWaitForYellowStatus().get();

  // Make sure the tag exists in the index
  SearchResponse response = client.getClient().prepareSearch(index).setRouting(tag.getId().toString()).get();
  assertEquals(1, response.getHits().totalHits());

  // Clean up
  DeleteIndexResponse deleteResponse = client.getClient().admin().indices().prepareDelete(index).get();
  assertTrue(deleteResponse.isAcknowledged());
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:24,代码来源:TagConfigDocumentIndexerTests.java

示例7: indexTags

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Test
public void indexTags() throws IDBPersistenceException, InterruptedException {
  DataTagCacheObject tag = (DataTagCacheObject) EntityUtils.createDataTag();

  TagDocument document = converter.convert(tag).orElseThrow(() -> new IllegalArgumentException("TagDocument conversion failed"));
  indexer.storeData(document);

  // Refresh the index to make sure the document is searchable
  String index = Indices.indexFor(document);
  client.getClient().admin().indices().prepareRefresh(index).get();
  client.getClient().admin().cluster().prepareHealth().setIndices(index).setWaitForYellowStatus().get();
  client.waitForYellowStatus();

  // Make sure the index was created
  assertTrue(Indices.exists(index));

  // Make sure the tag exists in the index
  SearchResponse response = client.getClient().prepareSearch(index).setRouting(tag.getId().toString()).get();
  assertEquals(1, response.getHits().totalHits());

  // Clean up
  DeleteIndexResponse deleteResponse = client.getClient().admin().indices().prepareDelete(index).get();
  assertTrue(deleteResponse.isAcknowledged());
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:25,代码来源:TagDocumentIndexerTests.java

示例8: indexAlarm

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Test
public void indexAlarm() throws IDBPersistenceException {
  AlarmCacheObject alarm = (AlarmCacheObject) EntityUtils.createAlarm();
  alarm.setTimestamp(new Timestamp(0));

  AlarmDocument document = new AlarmDocumentConverter().convert(alarm);
  indexer.storeData(document);

  // Refresh the index to make sure the document is searchable
  String index = Indices.indexFor(document);
  client.getClient().admin().indices().prepareRefresh(index).execute().actionGet();

  // Make sure the index was created
  assertTrue(Indices.exists(index));

  // Make sure the alarm exists in the index
  SearchResponse response = client.getClient().prepareSearch(index).setTypes("alarm").execute().actionGet();
  assertEquals(response.getHits().totalHits(), 1);

  // Clean up
  DeleteIndexResponse deleteResponse = client.getClient().admin().indices().prepareDelete(index).execute().actionGet();
  assertTrue(deleteResponse.isAcknowledged());
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:24,代码来源:AlarmDocumentIndexerTests.java

示例9: logSupervisionEvent

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Test
public void logSupervisionEvent() throws IDBPersistenceException {
  SupervisionEvent event = EntityUtils.createSupervisionEvent();

  SupervisionEventDocument document = new SupervisionEventDocumentConverter().convert(event);
  indexer.storeData(document);

  // Refresh the index to make sure the document is searchable
  String index = Indices.indexFor(document);
  client.getClient().admin().indices().prepareRefresh(index).execute().actionGet();

  // Make sure the index was created
  assertTrue(Indices.exists(index));

  // Make sure the alarm exists in the index
  SearchResponse response = client.getClient().prepareSearch(index).setTypes("supervision").execute().actionGet();
  assertEquals(response.getHits().totalHits(), 1);

  // Clean up
  DeleteIndexResponse deleteResponse = client.getClient().admin().indices().prepareDelete(index).execute().actionGet();
  assertTrue(deleteResponse.isAcknowledged());
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:23,代码来源:SupervisionEventDocumentIndexerTests.java

示例10: cleanup

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@After
public void cleanup() throws IOException
{
  try {
    DeleteIndexResponse delete = store.client.admin().indices().delete(new DeleteIndexRequest(INDEX_NAME)).actionGet();
    if (!delete.isAcknowledged()) {
      logger.error("Index wasn't deleted");
    }

    store.disconnect();
  } catch (NoNodeAvailableException e) {
    //This indicates that elasticsearch is not running on a particular machine.
    //Silently ignore in this case.
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:ElasticSearchPercolateTest.java

示例11: prepareTest

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@BeforeClass
public void prepareTest() throws Exception {

  Config reference  = ConfigFactory.load();
  File conf_file = new File("target/test-classes/TwitterUserstreamElasticsearchIT.conf");
  assert(conf_file.exists());
  Config testResourceConfig  = ConfigFactory.parseFileAnySyntax(conf_file, ConfigParseOptions.defaults().setAllowMissing(false));
  Config typesafe  = testResourceConfig.withFallback(reference).resolve();
  testConfiguration = new ComponentConfigurator<>(TwitterUserstreamElasticsearchConfiguration.class).detectConfiguration(typesafe);
  testClient = ElasticsearchClientManager.getInstance(testConfiguration.getElasticsearch()).client();

  ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
  ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
  assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);

  IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getElasticsearch().getIndex());
  IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
  if(indicesExistsResponse.isExists()) {
    DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getElasticsearch().getIndex());
    DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
    assertTrue(deleteIndexResponse.isAcknowledged());
  };

}
 
开发者ID:apache,项目名称:streams-examples,代码行数:25,代码来源:TwitterUserstreamElasticsearchIT.java

示例12: prepareTest

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@BeforeClass
public void prepareTest() throws Exception {

  Config reference  = ConfigFactory.load();
  File conf_file = new File("target/test-classes/HdfsElasticsearchIT.conf");
  assert(conf_file.exists());
  Config testResourceConfig  = ConfigFactory.parseFileAnySyntax(conf_file, ConfigParseOptions.defaults().setAllowMissing(false));
  Config typesafe  = testResourceConfig.withFallback(reference).resolve();
  testConfiguration = new ComponentConfigurator<>(HdfsElasticsearchConfiguration.class).detectConfiguration(typesafe);
  testClient = ElasticsearchClientManager.getInstance(testConfiguration.getDestination()).client();

  ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
  ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
  assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);

  IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getDestination().getIndex());
  IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
  if(indicesExistsResponse.isExists()) {
    DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getDestination().getIndex());
    DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
    assertTrue(deleteIndexResponse.isAcknowledged());
  };
}
 
开发者ID:apache,项目名称:streams-examples,代码行数:24,代码来源:HdfsElasticsearchIT.java

示例13: prepareTest

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@BeforeClass
public void prepareTest() throws Exception {

  Config reference  = ConfigFactory.load();
  File conf_file = new File("target/test-classes/TwitterHistoryElasticsearchIT.conf");
  assert(conf_file.exists());
  Config testResourceConfig  = ConfigFactory.parseFileAnySyntax(conf_file, ConfigParseOptions.defaults().setAllowMissing(false));
  Config typesafe  = testResourceConfig.withFallback(reference).resolve();
  testConfiguration = new ComponentConfigurator<>(TwitterHistoryElasticsearchConfiguration.class).detectConfiguration(typesafe);
  testClient = ElasticsearchClientManager.getInstance(testConfiguration.getElasticsearch()).client();

  ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
  ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
  assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);

  IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getElasticsearch().getIndex());
  IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
  if(indicesExistsResponse.isExists()) {
    DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getElasticsearch().getIndex());
    DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
    assertTrue(deleteIndexResponse.isAcknowledged());
  };
}
 
开发者ID:apache,项目名称:streams-examples,代码行数:24,代码来源:TwitterHistoryElasticsearchIT.java

示例14: deleteIndex

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
/**
 *
 */
private boolean deleteIndex(String indexName) {
    boolean val = false;
    try {
        DeleteIndexResponse deleteResponse = this.client.admin().indices().delete(new DeleteIndexRequest(indexName)).actionGet();

        if (deleteResponse.isAcknowledged()) {
            logger.info("Index {} deleted", indexName);
            val = true;
        } else {
            logger.error("Could not delete index " + indexName);
        }
    } catch (IndexNotFoundException e) {
        logger.info("Index " + indexName + " not found.");

    }
    return val;
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:21,代码来源:Indexer.java

示例15: setUp

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    if (client.admin().indices().prepareExists(getIndexName()).execute().actionGet().isExists()) {
        DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(getIndexName())
                .execute().actionGet();
        Assert.assertTrue(deleteIndexResponse.isAcknowledged());
    }
    CreateIndexResponse createIndexResponse = client.admin().indices().prepareCreate(getIndexName())
            .execute().actionGet();
    Assert.assertTrue(createIndexResponse.isAcknowledged());
    for (Map.Entry<String, String> esMapping : getEsMappings().entrySet()) {
        String esMappingSource = IOUtils.toString(
                AbstractEsTest.class.getClassLoader().getResourceAsStream(esMapping.getValue()));
        PutMappingResponse putMappingResponse = client.admin().indices().preparePutMapping(getIndexName())
                .setType(esMapping.getKey()).setSource(esMappingSource).execute().actionGet();
        Assert.assertTrue(putMappingResponse.isAcknowledged());
    }
}
 
开发者ID:presidentio,项目名称:test-data-generator,代码行数:19,代码来源:AbstractEsTest.java


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