當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。