当前位置: 首页>>代码示例>>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;未经允许,请勿转载。