新闻资讯
Java DeleteIndexRequest类代码示例
Java DeleteIndexRequest类代码示例
本文整理汇总了Java中org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest类的典型用法代码示例。如果您正苦于以下问题:Java DeleteIndexRequest类的具体用法?Java DeleteIndexRequest怎么用?Java DeleteIndexRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteIndexRequest类属于org.elasticsearch.action.admin.indices.delete包,在下文中一共展示了DeleteIndexRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deleteOrphans
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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());
}
}
示例2: deleteOrphanedPartitions
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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);
}
}
示例3: ESDeletePartitionTask
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 public ESDeletePartitionTask(UUID jobId,
TransportDeleteIndexAction transport,
ESDeletePartitionNode node) { super(jobId); this.transport = transport; this.request = new DeleteIndexRequest(node.indices()); if (node.indices().length > 1) { /**
* table is partitioned, in case of concurrent "delete from partitions"
* it could be that some partitions are already deleted,
* so ignore it if some are missing
*/ this.request.indicesOptions(IndicesOptions.lenientExpandOpen());
} else { this.request.indicesOptions(IndicesOptions.strictExpandOpen());
} this.listener = new DeleteIndexListener(result);
}
示例4: update
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 private static void update() { try {
IndicesAdminClient indicesAdminClient = client.admin().indices(); if (indicesAdminClient.prepareExists(INDEX_NAME_v2).execute().actionGet().isExists()) {
indicesAdminClient.delete(new DeleteIndexRequest(INDEX_NAME_v2)).actionGet();
}
indicesAdminClient.prepareCreate(INDEX_NAME_v2).addMapping(INDEX_TYPE,getItemInfoMapping()).execute().actionGet(); //等待集群shard,防止No shard available for 异常 ClusterAdminClient clusterAdminClient = client.admin().cluster();
clusterAdminClient.prepareHealth().setWaitForYellowStatus().execute().actionGet(5000); //0、更新mapping updateMapping(); //1、更新数据 reindexData(indicesAdminClient); //2、realias 重新建立连接 indicesAdminClient.prepareAliases().removeAlias(INDEX_NAME_v1, ALIX_NAME).addAlias(INDEX_NAME_v2, ALIX_NAME).execute().actionGet();
}catch (Exception e){
log.error("beforeUpdate error:{}"+e.getLocalizedMessage());
}
}
示例5: beforeUpdate
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 private static void beforeUpdate() { try {
IndicesAdminClient indicesAdminClient = client.admin().indices();
indicesAdminClient.delete(new DeleteIndexRequest(INDEX_NAME_v1)).actionGet(); if (!indicesAdminClient.prepareExists(INDEX_NAME_v1).execute().actionGet().isExists()) {
indicesAdminClient.prepareCreate(INDEX_NAME_v1).addMapping(INDEX_TYPE,getItemInfoMapping()).execute().actionGet();
} //等待集群shard,防止No shard available for 异常 ClusterAdminClient clusterAdminClient = client.admin().cluster();
clusterAdminClient.prepareHealth().setWaitForYellowStatus().execute().actionGet(5000); //创建别名alias indicesAdminClient.prepareAliases().addAlias(INDEX_NAME_v1, ALIX_NAME).execute().actionGet();
prepareData(indicesAdminClient);
}catch (Exception e){
log.error("beforeUpdate error:{}"+e.getLocalizedMessage());
}
}
示例6: delete
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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;
}
}
}
示例7: main
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 public static void main(String[] args) throws Exception {
Postgres2ElasticsearchIndexer indexer = new Postgres2ElasticsearchIndexer();
indexer.getConfiguration(args);
indexer.initDb(indexer.dbName, indexer.dbUrl, indexer.dbUser, indexer.dbPass);
TransportClient client;
Settings settings = Settings.builder().put("cluster.name", indexer.esClustername).build();
st.setFetchSize(BATCH_SIZE); try {
client = TransportClient.builder().settings(settings).build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(indexer.esHost), Integer.parseInt(indexer.esPort))); // remove existing index client.admin().indices().delete(new DeleteIndexRequest(indexer.esIndex)).actionGet(); // create index with all extracted data indexer.documenIndexer(client, indexer.esIndex, "document");
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
conn.close();
}
示例8: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 /**
* 删除索引
*
* @param index_type
*/ public boolean deleteIndex(String index_type) { try {
AdminClient adminClient = ESClient.getClient().admin(); if (adminClient.indices().prepareExists(index_type).execute().actionGet().isExists()) {
ESClient.getClient().admin().indices().delete(new DeleteIndexRequest(index_type));
} if (adminClient.indices().prepareExists(index_type + "_1").execute().actionGet()
.isExists()) {
ESClient.getClient().admin().indices()
.delete(new DeleteIndexRequest(index_type + "_1"));
} if (adminClient.indices().prepareExists(index_type + "_2").execute().actionGet()
.isExists()) {
ESClient.getClient().admin().indices()
.delete(new DeleteIndexRequest(index_type + "_2"));
} return true;
} catch (Exception e) {
log.error("delete index fail,indexname:{}", index_type);
} return false;
}
示例9: cleanup
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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. }
}
示例10: prepareTest
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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());
};
}
示例11: prepareTest
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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());
};
}
示例12: prepareTest
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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());
};
}
示例13: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的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;
}
示例14: clean
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @AfterClass public static void clean() { if (transportInterpreter != null) {
transportInterpreter.close();
} if (httpInterpreter != null) {
httpInterpreter.close();
} if (elsClient != null) {
elsClient.admin().indices().delete(new DeleteIndexRequest("*")).actionGet();
elsClient.close();
} if (elsNode != null) {
elsNode.close();
}
}
示例15: testBigAndFatResponse
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @Test public void testBigAndFatResponse() throws Exception {
Client client = client("1"); for (int i = 0; i < 10000; i++) {
client.index(new IndexRequest("test", "test", Integer.toString(i))
.source("{\"random\":\""+randomString(32)+ " " + randomString(32) + "\"}")).actionGet();
}
client.admin().indices().refresh(new RefreshRequest("test")).actionGet();
InetSocketTransportAddress httpAddress = findHttpAddress(client); if (httpAddress == null) { throw new IllegalArgumentException("no HTTP address found");
}
URL base = new URL("http://" + httpAddress.getHost() + ":" + httpAddress.getPort());
URL url = new URL(base, "/test/test/_search?xml&pretty&size=10000");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); int count = 0;
String line; while ((line = reader.readLine()) != null) {
count += line.length();
}
assertTrue(count >= 2309156);
reader.close();
client.admin().indices().delete(new DeleteIndexRequest("test"));
}
示例16: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @Override public synchronized BaseIngestTransportClient deleteIndex(String index) { if (client == null) {
logger.warn("no client for delete index"); return this;
} if (index == null) {
logger.warn("no index name given to delete index"); return this;
} try {
client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet();
} catch (Exception e) {
logger.error(e.getMessage(), e);
} return this;
}
示例17: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @Override public BulkNodeClient deleteIndex(String index) { if (closed) { throw new ElasticsearchIllegalStateException("client is closed");
} if (client == null) {
logger.warn("no client"); return this;
} if (index == null) {
logger.warn("no index name given to delete index"); return this;
} try {
client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet();
} catch (Exception e) {
logger.error(e.getMessage(), e);
} return this;
}
示例18: drop
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @Override public void drop(Graph graph) {
Set<String> indexInfosSet = getIndexInfos(graph).keySet(); for (String indexName : indexInfosSet) { try { DeleteIndexRequest deleteRequest = new DeleteIndexRequest(indexName);
getClient().admin().indices().delete(deleteRequest).actionGet();
getIndexInfos(graph).remove(indexName);
} catch (Exception ex) { throw new MemgraphException("Could not delete index " + indexName, ex);
}
ensureIndexCreatedAndInitialized(graph, indexName);
}
}
示例19: tearDown
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @After public void tearDown() throws Exception {
ClusterStatsResponse clusterStatsResponse = esClient.admin().cluster().prepareClusterStats().get(); //be sure it's for unit test clean up if (clusterStatsResponse.getClusterName().value().equals("elasticsearch")
&& clusterStatsResponse.getNodes().size() == 1) {
esClient.admin().indices().delete(new DeleteIndexRequest(INDEX)).actionGet();
}
}
示例20: prepareRequest
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; //导入依赖的package包/类 @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout()));
deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout()));
deleteIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, deleteIndexRequest.indicesOptions())); return channel -> client.admin().indices().delete(deleteIndexRequest, new AcknowledgedRestListener<>(channel));
}
回复列表