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


Java VersionType.EXTERNAL属性代码示例

本文整理汇总了Java中org.elasticsearch.index.VersionType.EXTERNAL属性的典型用法代码示例。如果您正苦于以下问题:Java VersionType.EXTERNAL属性的具体用法?Java VersionType.EXTERNAL怎么用?Java VersionType.EXTERNAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.elasticsearch.index.VersionType的用法示例。


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

示例1: testExternalVersioningIndexConflictWithFlush

public void testExternalVersioningIndexConflictWithFlush() throws IOException {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 12, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    Engine.IndexResult indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(12L));

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 14, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(14L));

    engine.flush();

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 13, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalEngineTests.java

示例2: testExternalVersioningIndexConflict

public void testExternalVersioningIndexConflict() throws IOException {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 12, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    Engine.IndexResult indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(12L));

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 14, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(14L));

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 13, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:InternalEngineTests.java

示例3: testExternalVersioningNewIndex

public void testExternalVersioningNewIndex() throws IOException {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 12, VersionType.EXTERNAL, PRIMARY, 0, -1, false);
    Engine.IndexResult indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(12L));

    index = new Engine.Index(newUid(doc), doc, indexResult.getSeqNo(), index.primaryTerm(), indexResult.getVersion(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, 0, -1, false);
    indexResult = replicaEngine.index(index);
    assertThat(indexResult.getVersion(), equalTo(12L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:InternalEngineTests.java

示例4: randomAppendOnly

public Engine.Index randomAppendOnly(ParsedDocument doc, boolean retry, final long autoGeneratedIdTimestamp) {
    if (randomBoolean()) {
        return new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, Versions.MATCH_ANY,
            VersionType.INTERNAL, Engine.Operation.Origin.PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, retry);
    }
    return new Engine.Index(newUid(doc), doc, 0, 0, 1, VersionType.EXTERNAL,
        Engine.Operation.Origin.REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, retry);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:InternalEngineTests.java

示例5: testOutOfOrderSequenceNumbersWithVersionConflict

public void testOutOfOrderSequenceNumbersWithVersionConflict() throws IOException {
    final List<Engine.Operation> operations = new ArrayList<>();

    final int numberOfOperations = randomIntBetween(16, 32);
    final Document document = testDocumentWithTextField();
    final AtomicLong sequenceNumber = new AtomicLong();
    final Engine.Operation.Origin origin = randomFrom(LOCAL_TRANSLOG_RECOVERY, PEER_RECOVERY, PRIMARY, REPLICA);
    final LongSupplier sequenceNumberSupplier =
        origin == PRIMARY ? () -> SequenceNumbersService.UNASSIGNED_SEQ_NO : sequenceNumber::getAndIncrement;
    document.add(new Field(SourceFieldMapper.NAME, BytesReference.toBytes(B_1), SourceFieldMapper.Defaults.FIELD_TYPE));
    final ParsedDocument doc = testParsedDocument("1", "test", null, document, B_1, null);
    final Term uid = newUid(doc);
    for (int i = 0; i < numberOfOperations; i++) {
        if (randomBoolean()) {
            final Engine.Index index = new Engine.Index(
                uid,
                doc,
                sequenceNumberSupplier.getAsLong(),
                1,
                i,
                VersionType.EXTERNAL,
                origin,
                System.nanoTime(),
                IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP,
                false);
            operations.add(index);
        } else {
            final Engine.Delete delete = new Engine.Delete(
                "test",
                "1",
                uid,
                sequenceNumberSupplier.getAsLong(),
                1,
                i,
                VersionType.EXTERNAL,
                origin,
                System.nanoTime());
            operations.add(delete);
        }
    }

    final boolean exists = operations.get(operations.size() - 1) instanceof Engine.Index;
    Randomness.shuffle(operations);

    for (final Engine.Operation operation : operations) {
        if (operation instanceof Engine.Index) {
            engine.index((Engine.Index) operation);
        } else {
            engine.delete((Engine.Delete) operation);
        }
    }

    final long expectedLocalCheckpoint;
    if (origin == PRIMARY) {
        // we can only advance as far as the number of operations that did not conflict
        int count = 0;

        // each time the version increments as we walk the list, that counts as a successful operation
        long version = -1;
        for (int i = 0; i < numberOfOperations; i++) {
            if (operations.get(i).version() >= version) {
                count++;
                version = operations.get(i).version();
            }
        }

        // sequence numbers start at zero, so the expected local checkpoint is the number of successful operations minus one
        expectedLocalCheckpoint = count - 1;
    } else {
        expectedLocalCheckpoint = numberOfOperations - 1;
    }

    assertThat(engine.seqNoService().getLocalCheckpoint(), equalTo(expectedLocalCheckpoint));
    try (Engine.GetResult result = engine.get(new Engine.Get(true, uid))) {
        assertThat(result.exists(), equalTo(exists));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:77,代码来源:InternalEngineTests.java


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