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


Java Client.close方法代码示例

本文整理汇总了Java中org.elasticsearch.client.Client.close方法的典型用法代码示例。如果您正苦于以下问题:Java Client.close方法的具体用法?Java Client.close怎么用?Java Client.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.client.Client的用法示例。


在下文中一共展示了Client.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    Log4jESLoggerFactory.getRootLogger().setLevel("ERROR");
    Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "ciphergateway").build();
    //Use one and only one Client in your JVM. It's threadsafe.
    Client client = new TransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

    Long start = System.currentTimeMillis();
//    exportES(client);
//    deleteES(client);
//    importES(client);
//    searchES(client);
    exportAndDeleteES(client);
    client.close();
    Long end = System.currentTimeMillis();
    System.out.println("用时: " + (end - start) + " ms");
  }
 
开发者ID:MoneZhao,项目名称:elasticsearch,代码行数:18,代码来源:App.java

示例2: testBulkProcessorConcurrentRequestsNoNodeAvailableException

import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public void testBulkProcessorConcurrentRequestsNoNodeAvailableException() throws Exception {
    //we create a transport client with no nodes to make sure it throws NoNodeAvailableException
    Settings settings = Settings.builder()
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
            .build();
    Client transportClient = new MockTransportClient(settings);

    int bulkActions = randomIntBetween(10, 100);
    int numDocs = randomIntBetween(bulkActions, bulkActions + 100);
    int concurrentRequests = randomIntBetween(0, 10);

    int expectedBulkActions = numDocs / bulkActions;

    final CountDownLatch latch = new CountDownLatch(expectedBulkActions);
    int totalExpectedBulkActions = numDocs % bulkActions == 0 ? expectedBulkActions : expectedBulkActions + 1;
    final CountDownLatch closeLatch = new CountDownLatch(totalExpectedBulkActions);

    BulkProcessorTestListener listener = new BulkProcessorTestListener(latch, closeLatch);

    try (BulkProcessor processor = BulkProcessor.builder(transportClient, listener)
            .setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions)
            //set interval and size to high values
            .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) {

        indexDocs(transportClient, processor, numDocs);

        latch.await();

        assertThat(listener.beforeCounts.get(), equalTo(expectedBulkActions));
        assertThat(listener.afterCounts.get(), equalTo(expectedBulkActions));
        assertThat(listener.bulkFailures.size(), equalTo(expectedBulkActions));
        assertThat(listener.bulkItems.size(), equalTo(0));
    }

    closeLatch.await();

    assertThat(listener.bulkFailures.size(), equalTo(totalExpectedBulkActions));
    assertThat(listener.bulkItems.size(), equalTo(0));
    transportClient.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:BulkProcessorIT.java

示例3: main

import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {


        Client client = EsClient.getClient();

//      CreateIndex(client);

//      GetResponse(client);

//      DeleteResponse(client);

//      UpdateRequest(client);
        client.close();

//      MultiGet(client);

//      BulkIndex(client);

//        SearchIndex(client);


    }
 
开发者ID:hs-web,项目名称:hsweb-learning,代码行数:23,代码来源:ElasticSearch.java


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