• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ReplicationType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: store

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
@Override
public void store(RelatedItemStorageLocationMapper indexLocationMapper, List<RelatedItem> relatedItems) {
    BulkRequestBuilder bulkRequest = elasticClient.prepareBulk();
    bulkRequest.setReplicationType(ReplicationType.ASYNC).setRefresh(false);

    int requestAdded = 0;
    for(RelatedItem product : relatedItems) {
        int added = addRelatedItem(indexLocationMapper, bulkRequest, product);
        if(relatedItemsDocumentIndexingEnabled && added==1) {
            added+=addRelatedItemDocument(bulkRequest, product);
        }
        requestAdded+=added;
    }

    if(requestAdded>0) {
        log.info("Sending Relating Product Index Requests to Elastic: {}",requestAdded);
        BulkResponse bulkResponse = bulkRequest.execute().actionGet();

        if(bulkResponse.hasFailures()) {
            log.warn(bulkResponse.buildFailureMessage());
        }
    }
}
 
开发者ID:tootedom,项目名称:related,代码行数:24,代码来源:ElasticSearchRelatedItemIndexingRepository.java


示例2: save

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
/**
 * Slower save, but high protected save.
 */
public void save() {
	IndexRequestBuilder create = Elasticsearch.getClient().prepareIndex(ES_INDEX, ES_TYPE, _id).setRefresh(true);
	create.setSource(MyDMAM.gson_kit.getGsonSimple().toJson(this));
	
	if (_id == null) {
		create.setCreate(true).setOpType(OpType.CREATE).setConsistencyLevel(WriteConsistencyLevel.ALL).setReplicationType(ReplicationType.SYNC);
		
		createAutogeneratedId();
		create.setId(_id);
		while (create.get().isCreated() == false) {
			createAutogeneratedId();
			create.setId(_id);
		}
	} else {
		create.get();
	}
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:21,代码来源:InternalId.java


示例3: parse

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
/**
 * Mostly just write the data you got from BigQuery into ElasticSearch.
 * 
 * @throws ElasticsearchException
 * @throws IOException
 * @throws InterruptedException
 */
private void parse(@Nonnull final List<TableRow> rows) throws ElasticsearchException, IOException, InterruptedException {
	final int size = rows.size();
	int count = 0;
	final String timestamp = String.valueOf(System.currentTimeMillis());
	int progress = 0;
	logger.info("Got {} results from BigQuery database", size);

	while (!stopThread && !rows.isEmpty()) {
		final TableRow row = rows.remove(0);
		final String[] jsonResult = getJson(row);
		final String source = jsonResult[0];
		final IndexRequestBuilder builder = esClient.prepareIndex(index, type);
		if (jsonResult[1] != null) {
			builder.setId(jsonResult[1]);
		}
		try {
			builder.setOpType(OpType.CREATE)
				.setReplicationType(ReplicationType.ASYNC)
				.setOperationThreaded(true)
				.setTimestamp(timestamp)
				.setSource(source)
				.setCreate(create)
				.execute()
				.actionGet();
			count++;
		} catch (DocumentAlreadyExistsException daee) {
			logger.trace("Document already exists, create flag is {}", daee, create);
		}
		if (++progress % 100 == 0) {
			logger.debug("Processed {} entries ({} percent done)", progress, Math.round((float) progress / (float) size * 100f));
		}
	}
	logger.info("Imported {} entries into ElasticSeach from BigQuery (some duplicates may have been skipped)", count);
	return;
}
 
开发者ID:mallocator,项目名称:Elasticsearch-BigQuery-River,代码行数:43,代码来源:BigQueryRiver.java


示例4: dataSetImport

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
/**
 * Imports dataset
 *
 * @throws java.io.IOException
 */
private static void dataSetImport()
        throws IOException, ExecutionException, IOException, InterruptedException, ParseException {

    JSONParser parser = new JSONParser();
    URL url = Resources.getResource(DATA_SET_NAME);
    Object obj = parser.parse(new FileReader(url.getFile()));

    JSONObject jsonObject = (JSONObject) obj;

    IndexResponse responseBook = client.prepareIndex(ES_INDEX_BOOK, ES_TYPE_INPUT, "id")
            .setSource(jsonObject.toJSONString())
            .execute()
            .actionGet();

    String json2 = "{" +

            "\"message\":\"" + MESSAGE_TEST + "\"" +
            "}";

    IndexResponse response2 = client.prepareIndex(ES_INDEX_MESSAGE, ES_TYPE_MESSAGE).setCreate(true)
            .setSource(json2).setReplicationType(ReplicationType.ASYNC)
            .execute()
            .actionGet();

    String json = "{" +
            "\"user\":\"kimchy\"," +
            "\"postDate\":\"2013-01-30\"," +
            "\"message\":\"trying out Elasticsearch\"" +
            "}";

    IndexResponse response = client.prepareIndex(ES_INDEX, ES_TYPE).setCreate(true)
            .setSource(json)
            .execute()
            .actionGet();

    String index = response.getIndex();
    String _type = response.getType();
    String _id = response.getId();
    try {
        CountResponse countResponse = client.prepareCount(ES_INDEX).setTypes(ES_TYPE)
                .execute()
                .actionGet();

        SearchResponse searchResponse = client.prepareSearch(ES_INDEX_BOOK).setTypes(ES_TYPE_INPUT)
                .execute()
                .actionGet();

        //searchResponse.getHits().hits();
        //assertEquals(searchResponse.getCount(), 1);
    } catch (AssertionError | Exception e) {
        cleanup();
        e.printStackTrace();
    }
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:60,代码来源:ESJavaRDDFT.java


示例5: setReplicationType

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
/**
 * Set the replication type for this operation.
 */
public JestBulkRequestBuilder setReplicationType(ReplicationType replicationType) {
    this.replicationType = replicationType;
    return this;
}
 
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:8,代码来源:JestBulkRequestBuilder.java


示例6: setReplicationType

import org.elasticsearch.action.support.replication.ReplicationType; //导入依赖的package包/类
public BulkConfiguration setReplicationType(ReplicationType replicationType) {
	bulk_request_builder.setReplicationType(replicationType);
	refresh();
	return this;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:6,代码来源:ElasticsearchBulkOperation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ITeleportType类代码示例发布时间:2022-05-22
下一篇:
Java DDMTemplateConstants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap