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


Java BulkProcessor类代码示例

本文整理汇总了Java中org.elasticsearch.action.bulk.BulkProcessor的典型用法代码示例。如果您正苦于以下问题:Java BulkProcessor类的具体用法?Java BulkProcessor怎么用?Java BulkProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: buildBulkProcessor

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
public BulkProcessor buildBulkProcessor(Context context, TransportClient client) {
    bulkActions = context.getInteger(ES_BULK_ACTIONS,
            DEFAULT_ES_BULK_ACTIONS);
    bulkProcessorName = context.getString(ES_BULK_PROCESSOR_NAME,
            DEFAULT_ES_BULK_PROCESSOR_NAME);
    bulkSize = Util.getByteSizeValue(context.getInteger(ES_BULK_SIZE),
            context.getString(ES_BULK_SIZE_UNIT));
    concurrentRequest = context.getInteger(ES_CONCURRENT_REQUEST,
            DEFAULT_ES_CONCURRENT_REQUEST);
    flushIntervalTime = Util.getTimeValue(context.getString(ES_FLUSH_INTERVAL_TIME),
            DEFAULT_ES_FLUSH_INTERVAL_TIME);
    backoffPolicyTimeInterval = context.getString(ES_BACKOFF_POLICY_TIME_INTERVAL,
            DEFAULT_ES_BACKOFF_POLICY_START_DELAY);
    backoffPolicyRetries = context.getInteger(ES_BACKOFF_POLICY_RETRIES,
            DEFAULT_ES_BACKOFF_POLICY_RETRIES);
    return build(client);
}
 
开发者ID:cognitree,项目名称:flume-elasticsearch-sink,代码行数:18,代码来源:BulkProcessorBuilder.java

示例2: build

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
private BulkProcessor build(TransportClient client) {
    logger.trace("Bulk processor name: [{}]  bulkActions: [{}], bulkSize: [{}], flush interval time: [{}]," +
                    " concurrent Request: [{}], backoffPolicyTimeInterval: [{}], backoffPolicyRetries: [{}] ",
            new Object[]{bulkProcessorName, bulkActions, bulkSize, flushIntervalTime,
                    concurrentRequest, backoffPolicyTimeInterval, backoffPolicyRetries});
    return BulkProcessor.builder(client, getListener())
            .setName(bulkProcessorName)
            .setBulkActions(bulkActions)
            .setBulkSize(bulkSize)
            .setFlushInterval(flushIntervalTime)
            .setConcurrentRequests(concurrentRequest)
            .setBackoffPolicy(BackoffPolicy.exponentialBackoff(
                    Util.getTimeValue(backoffPolicyTimeInterval,
                            DEFAULT_ES_BACKOFF_POLICY_START_DELAY),
                    backoffPolicyRetries))
            .build();
}
 
开发者ID:cognitree,项目名称:flume-elasticsearch-sink,代码行数:18,代码来源:BulkProcessorBuilder.java

示例3: configureBulkProcessorBackoff

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
@Override
public void configureBulkProcessorBackoff(
	BulkProcessor.Builder builder,
	@Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) {

	BackoffPolicy backoffPolicy;
	if (flushBackoffPolicy != null) {
		switch (flushBackoffPolicy.getBackoffType()) {
			case CONSTANT:
				backoffPolicy = BackoffPolicy.constantBackoff(
					new TimeValue(flushBackoffPolicy.getDelayMillis()),
					flushBackoffPolicy.getMaxRetryCount());
				break;
			case EXPONENTIAL:
			default:
				backoffPolicy = BackoffPolicy.exponentialBackoff(
					new TimeValue(flushBackoffPolicy.getDelayMillis()),
					flushBackoffPolicy.getMaxRetryCount());
		}
	} else {
		backoffPolicy = BackoffPolicy.noBackoff();
	}

	builder.setBackoffPolicy(backoffPolicy);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:Elasticsearch2ApiCallBridge.java

示例4: execute

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
private void execute(DocumentFactory<String> factory, InsertProperties properties, int from) throws InterruptedException {
	final int threads = properties.getNumOfThreads();
	ExecutorService service = Executors.newFixedThreadPool(threads);
	int perThread = properties.getDocPerIteration() / threads;
	int to = 0;
	Timer.Context insert = metrics.timer("insert-total").time();
	for(int i = 0; i < threads; i++) {
		BulkProcessor bulkProcessor = BulkProcessor.builder(client, new BulkListener(metrics))
				.setBulkActions(properties.getBulkActions())
				.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
				.setConcurrentRequests(properties.getBulkThreads())
				.build();
		from = to;
		to = from + perThread;
		SenderAction action = new SenderAction(metrics, properties, factory, bulkProcessor, from, to);
		service.execute(action);
	}
	service.shutdown();
	service.awaitTermination(60, TimeUnit.MINUTES);
	insert.stop();
	reporter.report();
}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:23,代码来源:DocumentSenderImpl.java

示例5: 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

示例6: setUp

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  metrics = new ElasticsearchSystemProducerMetrics("es", new MetricsRegistryMap());
  producer = new ElasticsearchSystemProducer(SYSTEM_NAME,
                                             BULK_PROCESSOR_FACTORY,
                                             CLIENT,
                                             INDEX_REQUEST_FACTORY,
                                             metrics);

  processorOne = mock(BulkProcessor.class);
  processorTwo = mock(BulkProcessor.class);

  when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), any(BulkProcessor.Listener.class)))
      .thenReturn(processorOne);
  producer.register(SOURCE_ONE);

  when(BULK_PROCESSOR_FACTORY.getBulkProcessor(eq(CLIENT), any(BulkProcessor.Listener.class)))
      .thenReturn(processorTwo);
  producer.register(SOURCE_TWO);
}
 
开发者ID:apache,项目名称:samza,代码行数:21,代码来源:ElasticsearchSystemProducerTest.java

示例7: 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

示例8: 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

示例9: flush

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
public static void flush(BulkProcessor bulkProcessor) {
    try {
        Field field = bulkProcessor.getClass().getDeclaredField("bulkRequest");
        if (field != null) {
            field.setAccessible(true);
            BulkRequest bulkRequest = (BulkRequest) field.get(bulkProcessor);
            if (bulkRequest.numberOfActions() > 0) {
                Method method = bulkProcessor.getClass().getDeclaredMethod("execute");
                if (method != null) {
                    method.setAccessible(true);
                    method.invoke(bulkProcessor);
                }
            }
        }
    } catch (Throwable e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:19,代码来源:BulkProcessorHelper.java

示例10: writeDataset

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
public void writeDataset(String indexName, String documentType, long numOfDocs, long numOfFields, BulkProcessor bulkProcessor){
  
  log.debug (String.format("*** Writing data to index %s", indexName));
  //TODO: create index with default schema
  if(this.templateBuilder!=null){
    Map<String, Object> mapping = new LinkedHashMap<String, Object> ();
    mapping.put("dynamic_templates", this.templateBuilder.build ());
    adminHelper.createIndex (indexName, documentType, mapping);
  }else{
    adminHelper.createIndex (indexName);
  }
  
  for(Integer i=0;i<numOfDocs;i++){
    IndexRequestBuilder indexRequestBuilder = client.prepareIndex (indexName, documentType, i.toString ())
            .setSource (generateRandomDoc (numOfFields));
    bulkProcessor.add (indexRequestBuilder.request ());
  } 
  bulkProcessor.flush ();    
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:20,代码来源:MockDataGenerator.java

示例11: processDocumentActions

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
public void processDocumentActions(Stream<DocumentAction> documentActions)
{
	LOG.trace("Processing document actions ...");
	BulkProcessor bulkProcessor = bulkProcessorFactory.create(client);
	try
	{
		documentActions.forEachOrdered(documentAction ->
		{
			DocWriteRequest docWriteRequest = toDocWriteRequest(documentAction);
			bulkProcessor.add(docWriteRequest);
		});
	}
	finally
	{
		waitForCompletion(bulkProcessor);
		LOG.debug("Processed document actions.");
	}
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:19,代码来源:ClientFacade.java

示例12: waitForCompletion

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
private void waitForCompletion(BulkProcessor bulkProcessor)
{
	try
	{
		boolean isCompleted = bulkProcessor.awaitClose(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
		if (!isCompleted)
		{
			throw new MolgenisDataException("Failed to complete bulk request within the given time");
		}
	}
	catch (InterruptedException e)
	{
		Thread.currentThread().interrupt();
		throw new RuntimeException(e);
	}
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:17,代码来源:ClientFacade.java

示例13: 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

示例14: dumpRestore

import org.elasticsearch.action.bulk.BulkProcessor; //导入依赖的package包/类
protected void dumpRestore(Client client, Builder builder) throws IOException {

        BulkProcessor bulkProcessor = buildBulkProcessor(client);
        BufferedReader reader = null;
        try {
            FileInputStream fis = new FileInputStream(builder.path());
            reader = new BufferedReader(new InputStreamReader(fis, builder.charset()));
            String line;
            while( (line=reader.readLine()) != null) {
                indexLine(bulkProcessor, builder.index(), builder.type(), line);
            }

        } finally {
            bulkProcessor.close();
            if (reader != null) {
                reader.close();
            }
        }
    }
 
开发者ID:javanna,项目名称:elasticshell,代码行数:20,代码来源:DumpRestorer.java

示例15: 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


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