當前位置: 首頁>>代碼示例>>Java>>正文


Java BulkProcessor.Listener方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.bulk.BulkProcessor.Listener方法的典型用法代碼示例。如果您正苦於以下問題:Java BulkProcessor.Listener方法的具體用法?Java BulkProcessor.Listener怎麽用?Java BulkProcessor.Listener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.bulk.BulkProcessor的用法示例。


在下文中一共展示了BulkProcessor.Listener方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBulkProcessor

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
public BulkProcessor getBulkProcessor(Client client, BulkProcessor.Listener listener) {
  BulkProcessor.Builder builder = BulkProcessor.builder(client, listener);

  // Concurrent requests set to 0 to ensure ordering of documents is maintained in batches.
  // This also means BulkProcessor#flush() is blocking as is also required.
  builder.setConcurrentRequests(0);

  if (config.getBulkFlushMaxActions().isPresent()) {
    builder.setBulkActions(config.getBulkFlushMaxActions().get());
  }
  if (config.getBulkFlushMaxSizeMB().isPresent()) {
    builder.setBulkSize(new ByteSizeValue(config.getBulkFlushMaxSizeMB().get(), ByteSizeUnit.MB));
  }
  if (config.getBulkFlushIntervalMS().isPresent()) {
    builder.setFlushInterval(TimeValue.timeValueMillis(config.getBulkFlushIntervalMS().get()));
  }

  return builder.build();
}
 
開發者ID:apache,項目名稱:samza,代碼行數:20,代碼來源:BulkProcessorFactory.java

示例2: testIgnoreVersionConficts

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
@Test
public void testIgnoreVersionConficts() throws Exception {
  ArgumentCaptor<BulkProcessor.Listener> listenerCaptor =
          ArgumentCaptor.forClass(BulkProcessor.Listener.class);

  when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture()))
          .thenReturn(processorOne);
  producer.register(SOURCE_ONE);

  BulkResponse response = getRespWithFailedDocument(RestStatus.CONFLICT);

  listenerCaptor.getValue().afterBulk(0, null, response);
  assertEquals(1, metrics.conflicts.getCount());

  producer.flush(SOURCE_ONE);
}
 
開發者ID:apache,項目名稱:samza,代碼行數:17,代碼來源:ElasticsearchSystemProducerTest.java

示例3: getConnection

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
public static ElasticSearchConnection getConnection(Map stormConf,
        String boltType, BulkProcessor.Listener listener) {

    String flushIntervalString = ConfUtils.getString(stormConf, "es."
            + boltType + ".flushInterval", "5s");

    TimeValue flushInterval = TimeValue.parseTimeValue(flushIntervalString,
            TimeValue.timeValueSeconds(5));

    int bulkActions = ConfUtils.getInt(stormConf, "es." + boltType
            + ".bulkActions", 50);

    Client client = getClient(stormConf, boltType);

    BulkProcessor bulkProcessor = BulkProcessor.builder(client, listener)
            .setFlushInterval(flushInterval).setBulkActions(bulkActions)
            .setConcurrentRequests(1).build();

    return new ElasticSearchConnection(client, bulkProcessor);
}
 
開發者ID:zaizi,項目名稱:alfresco-apache-storm-demo,代碼行數:21,代碼來源:ElasticSearchConnection.java

示例4: getConnection

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
public static ElasticSearchConnection getConnection(Map stormConf,
        String boltType, BulkProcessor.Listener listener) {

    String flushIntervalString = ConfUtils.getString(stormConf, "es."
            + boltType + ".flushInterval", "5s");

    TimeValue flushInterval = TimeValue.parseTimeValue(flushIntervalString,
            TimeValue.timeValueSeconds(5), "flushInterval");

    int bulkActions = ConfUtils.getInt(stormConf, "es." + boltType
            + ".bulkActions", 50);

    int concurrentRequests = ConfUtils.getInt(stormConf, "es." + boltType
            + ".concurrentRequests", 1);

    Client client = getClient(stormConf, boltType);

    BulkProcessor bulkProcessor = BulkProcessor.builder(client, listener)
            .setFlushInterval(flushInterval).setBulkActions(bulkActions)
            .setConcurrentRequests(concurrentRequests).build();

    return new ElasticSearchConnection(client, bulkProcessor);
}
 
開發者ID:DigitalPebble,項目名稱:storm-crawler,代碼行數:24,代碼來源:ElasticSearchConnection.java

示例5: getConnection

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
private static ElasticConnection getConnection(String hostname, int transportPort, String flushIntervalString, BulkProcessor.Listener listener) {
    System.setProperty("es.set.netty.runtime.available.processors", "false");

    TimeValue flushInterval = TimeValue.parseTimeValue(flushIntervalString, TimeValue.timeValueSeconds(5), "flush");

    Client client = getClient(hostname, transportPort);

    BulkProcessor bulkProcessor = BulkProcessor.builder(client, listener)
            .setFlushInterval(flushInterval)
            .setBulkActions(10)
            .setConcurrentRequests(10)
            .build();

    return new ElasticConnection(client, bulkProcessor);
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:16,代碼來源:ElasticConnection.java

示例6: no_value_inserted_when_not_enough_requests

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
@Test
public void no_value_inserted_when_not_enough_requests() {

    // Create Mocks:
    Client mockedTransportClient = mock(Client.class);
    BulkProcessor.Listener mockedBulkProcessorListener = mock(BulkProcessor.Listener.class);

    // Configure the BulkProcessor to use:
    BulkProcessorConfiguration configuration = new BulkProcessorConfiguration(new BulkProcessingOptionsBuilder().build(), mockedBulkProcessorListener);

    // And create a fake index builder:
    IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(mockedTransportClient, IndexAction.INSTANCE);

    // The mapping to use:
    IElasticSearchMapping localWeatherDataMapper = new LocalWeatherDataMapper();

    // Index to insert to:
    String indexName = "weather_data";

    // Initialize it with the default settings:
    when(mockedTransportClient.settings())
            .thenReturn(Settings.builder().build());

    when(mockedTransportClient.prepareIndex())
            .thenReturn(indexRequestBuilder);

    // Create the Test subject:
    ElasticSearchClient<LocalWeatherData> elasticSearchClient = new ElasticSearchClient<>(mockedTransportClient, indexName, localWeatherDataMapper, configuration);

    // Create more entities, than Bulk insertion threshold:
    Stream<LocalWeatherData> entitiesStream = getData(configuration.getBulkProcessingOptions().getBulkActions() - 1).stream();

    // Index the Data:
    elasticSearchClient.index(entitiesStream);

    // Verify, that the TransportClient bulk insert has been called:
    verify(mockedTransportClient, times(0)).bulk(anyObject(), anyObject());
    verify(mockedBulkProcessorListener, times(0)).beforeBulk(anyLong(), anyObject());
}
 
開發者ID:bytefish,項目名稱:ElasticUtils,代碼行數:40,代碼來源:ElasticSearchClientTest.java

示例7: buildBulkProcessor

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
/**
 * Build the {@link BulkProcessor}.
 *
 * <p>Note: this is exposed for testing purposes.
 */
@VisibleForTesting
protected BulkProcessor buildBulkProcessor(BulkProcessor.Listener listener) {
	checkNotNull(listener);

	BulkProcessor.Builder bulkProcessorBuilder = BulkProcessor.builder(client, listener);

	// This makes flush() blocking
	bulkProcessorBuilder.setConcurrentRequests(0);

	if (bulkProcessorFlushMaxActions != null) {
		bulkProcessorBuilder.setBulkActions(bulkProcessorFlushMaxActions);
	}

	if (bulkProcessorFlushMaxSizeMb != null) {
		bulkProcessorBuilder.setBulkSize(new ByteSizeValue(bulkProcessorFlushMaxSizeMb, ByteSizeUnit.MB));
	}

	if (bulkProcessorFlushIntervalMillis != null) {
		bulkProcessorBuilder.setFlushInterval(TimeValue.timeValueMillis(bulkProcessorFlushIntervalMillis));
	}

	// if backoff retrying is disabled, bulkProcessorFlushBackoffPolicy will be null
	callBridge.configureBulkProcessorBackoff(bulkProcessorBuilder, bulkProcessorFlushBackoffPolicy);

	return bulkProcessorBuilder.build();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:32,代碼來源:ElasticsearchSinkBase.java

示例8: testFlushFailedSendFromException

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
@Test(expected=SamzaException.class)
public void testFlushFailedSendFromException() throws Exception {
  ArgumentCaptor<BulkProcessor.Listener> listenerCaptor =
      ArgumentCaptor.forClass(BulkProcessor.Listener.class);

  when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture()))
      .thenReturn(processorOne);
  producer.register(SOURCE_ONE);

  listenerCaptor.getValue().afterBulk(0, null, new Throwable());

  producer.flush(SOURCE_ONE);
}
 
開發者ID:apache,項目名稱:samza,代碼行數:14,代碼來源:ElasticsearchSystemProducerTest.java

示例9: testFlushFailedSendFromFailedDocument

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
@Test(expected=SamzaException.class)
public void testFlushFailedSendFromFailedDocument() throws Exception {
  ArgumentCaptor<BulkProcessor.Listener> listenerCaptor =
      ArgumentCaptor.forClass(BulkProcessor.Listener.class);

  when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), listenerCaptor.capture()))
      .thenReturn(processorOne);
  producer.register(SOURCE_ONE);

  BulkResponse response = getRespWithFailedDocument(RestStatus.BAD_REQUEST);

  listenerCaptor.getValue().afterBulk(0, null, response);

  producer.flush(SOURCE_ONE);
}
 
開發者ID:apache,項目名稱:samza,代碼行數:16,代碼來源:ElasticsearchSystemProducerTest.java

示例10: BulkProcessorConfiguration

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
public BulkProcessorConfiguration(BulkProcessingOptions options, BulkProcessor.Listener listener) {
    this.options = options;
    this.listener = listener;
}
 
開發者ID:bytefish,項目名稱:ElasticUtils,代碼行數:5,代碼來源:BulkProcessorConfiguration.java

示例11: getBulkProcessorListener

import org.elasticsearch.action.bulk.BulkProcessor; //導入方法依賴的package包/類
public BulkProcessor.Listener getBulkProcessorListener() {
    return listener;
}
 
開發者ID:bytefish,項目名稱:ElasticUtils,代碼行數:4,代碼來源:BulkProcessorConfiguration.java


注:本文中的org.elasticsearch.action.bulk.BulkProcessor.Listener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。