新闻资讯

新闻资讯 媒体报道

Java DeleteIndexRequest类代码示例

编辑:016     时间:2021-12-16

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

 点赞 3 
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());
    }
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:TableCreator.java

示例2: deleteOrphanedPartitions

 点赞 3 
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);
    }
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:TableCreator.java

示例3: ESDeletePartitionTask

 点赞 3 
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);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:ESDeletePartitionTask.java


示例4: update

 点赞 3 
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());
    }

}
开发者ID:ggj2010,项目名称:javabase,代码行数:23,代码来源:UpdateMappingFieldDemo.java

示例5: beforeUpdate

 点赞 3 
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());
    }
}
开发者ID:ggj2010,项目名称:javabase,代码行数:18,代码来源:UpdateMappingFieldDemo.java


示例6: delete

 点赞 3 
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;
    }
  }
}
开发者ID:c2mon,项目名称:c2mon,代码行数:24,代码来源:Indices.java

示例7: main

 点赞 3 
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();
    }
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:25,代码来源:Postgres2ElasticsearchIndexer.java

示例8: deleteIndex

 点赞 3 
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;
}
开发者ID:hailin0,项目名称:es-service-parent,代码行数:28,代码来源:IndexTransaction.java

示例9: cleanup

 点赞 3 
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. }

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

示例10: prepareTest

 点赞 3 
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());
  };

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

示例11: prepareTest

 点赞 3 
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());
  };
}
开发者ID:apache,项目名称:streams-examples,代码行数:24,代码来源:HdfsElasticsearchIT.java

示例12: prepareTest

 点赞 3 
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());
  };
}
开发者ID:apache,项目名称:streams-examples,代码行数:24,代码来源:TwitterHistoryElasticsearchIT.java

示例13: deleteIndex

 点赞 3 
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;
}
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:21,代码来源:Indexer.java

示例14: clean

 点赞 3 
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();
  }
}
开发者ID:apache,项目名称:zeppelin,代码行数:20,代码来源:ElasticsearchInterpreterTest.java

示例15: testBigAndFatResponse

 点赞 3 
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"));
}
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:25,代码来源:XmlPluginTest.java

示例16: deleteIndex

 点赞 3 
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;
}
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:18,代码来源:BaseIngestTransportClient.java

示例17: deleteIndex

 点赞 3 
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;
}
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:21,代码来源:BulkNodeClient.java

示例18: drop

 点赞 2 
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);
    }
}
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:15,代码来源:Elasticsearch5SearchIndex.java

示例19: tearDown

 点赞 2 
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();
  }
}
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:10,代码来源:ProductDaoTest.java

示例20: prepareRequest

 点赞 2 
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));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RestDeleteIndexAction.java

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

回复列表

相关推荐