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


Java StreamInput.setVersion方法代码示例

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


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

示例1: testDiscoveryNodeSerializationToOldVersion

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testDiscoveryNodeSerializationToOldVersion() throws Exception {
    InetAddress inetAddress = InetAddress.getByAddress("name1", new byte[] { (byte) 192, (byte) 168, (byte) 0, (byte) 1});
    TransportAddress transportAddress = new TransportAddress(inetAddress, randomIntBetween(0, 65535));
    DiscoveryNode node = new DiscoveryNode("name1", "id1", transportAddress, emptyMap(), emptySet(), Version.CURRENT);

    BytesStreamOutput streamOutput = new BytesStreamOutput();
    streamOutput.setVersion(Version.V_5_0_0);
    node.writeTo(streamOutput);

    StreamInput in = StreamInput.wrap(streamOutput.bytes().toBytesRef().bytes);
    in.setVersion(Version.V_5_0_0);
    DiscoveryNode serialized = new DiscoveryNode(in);
    assertEquals(transportAddress.address().getHostString(), serialized.getHostName());
    assertEquals(transportAddress.address().getHostString(), serialized.getAddress().address().getHostString());
    assertEquals(transportAddress.getAddress(), serialized.getHostAddress());
    assertEquals(transportAddress.getAddress(), serialized.getAddress().getAddress());
    assertEquals(transportAddress.getPort(), serialized.getAddress().getPort());
    assertFalse("if the minimum compatibility version moves past 5.0.3, remove the special casing in DiscoverNode(StreamInput) and " +
            "the TransportAddress(StreamInput, String) constructor",
        Version.CURRENT.minimumCompatibilityVersion().onOrAfter(Version.V_5_0_3_UNRELEASED));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:DiscoveryNodeTests.java

示例2: testSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
    int iterations = randomIntBetween(5, 20);
    for (int i = 0; i < iterations; i++) {

        IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
        ClusterStateRequest clusterStateRequest = new ClusterStateRequest().routingTable(randomBoolean()).metaData(randomBoolean())
                .nodes(randomBoolean()).blocks(randomBoolean()).indices("testindex", "testindex2").indicesOptions(indicesOptions);

        Version testVersion = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
        BytesStreamOutput output = new BytesStreamOutput();
        output.setVersion(testVersion);
        clusterStateRequest.writeTo(output);

        StreamInput streamInput = output.bytes().streamInput();
        streamInput.setVersion(testVersion);
        ClusterStateRequest deserializedCSRequest = new ClusterStateRequest();
        deserializedCSRequest.readFrom(streamInput);

        assertThat(deserializedCSRequest.routingTable(), equalTo(clusterStateRequest.routingTable()));
        assertThat(deserializedCSRequest.metaData(), equalTo(clusterStateRequest.metaData()));
        assertThat(deserializedCSRequest.nodes(), equalTo(clusterStateRequest.nodes()));
        assertThat(deserializedCSRequest.blocks(), equalTo(clusterStateRequest.blocks()));
        assertThat(deserializedCSRequest.indices(), equalTo(clusterStateRequest.indices()));
        assertOptionsMatch(deserializedCSRequest.indicesOptions(), clusterStateRequest.indicesOptions());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ClusterStateRequestTests.java

示例3: testSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
    int iterations = randomIntBetween(5, 20);
    for (int i = 0; i < iterations; i++) {
        IndicesOptions indicesOptions = IndicesOptions.fromOptions(
            randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());

        BytesStreamOutput output = new BytesStreamOutput();
        Version outputVersion = randomVersion(random());
        output.setVersion(outputVersion);
        indicesOptions.writeIndicesOptions(output);

        StreamInput streamInput = output.bytes().streamInput();
        streamInput.setVersion(randomVersion(random()));
        IndicesOptions indicesOptions2 = IndicesOptions.readIndicesOptions(streamInput);

        assertThat(indicesOptions2.ignoreUnavailable(), equalTo(indicesOptions.ignoreUnavailable()));
        assertThat(indicesOptions2.allowNoIndices(), equalTo(indicesOptions.allowNoIndices()));
        assertThat(indicesOptions2.expandWildcardsOpen(), equalTo(indicesOptions.expandWildcardsOpen()));
        assertThat(indicesOptions2.expandWildcardsClosed(), equalTo(indicesOptions.expandWildcardsClosed()));

        assertThat(indicesOptions2.forbidClosedIndices(), equalTo(indicesOptions.forbidClosedIndices()));
        assertThat(indicesOptions2.allowAliasesToMultipleIndices(), equalTo(indicesOptions.allowAliasesToMultipleIndices()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:IndicesOptionsTests.java

示例4: testOriginalIndicesSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testOriginalIndicesSerialization() throws IOException {
    int iterations = iterations(10, 30);
    for (int i = 0; i < iterations; i++) {
        OriginalIndices originalIndices = randomOriginalIndices();

        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(randomVersion(random()));
        OriginalIndices.writeOriginalIndices(originalIndices, out);

        StreamInput in = out.bytes().streamInput();
        in.setVersion(out.getVersion());
        OriginalIndices originalIndices2 = OriginalIndices.readOriginalIndices(in);

        assertThat(originalIndices2.indices(), equalTo(originalIndices.indices()));
        assertThat(originalIndices2.indicesOptions(), equalTo(originalIndices.indicesOptions()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:OriginalIndicesTests.java

示例5: roundTrip

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
private void roundTrip(Version version, Streamable example, Streamable empty) throws IOException {
    BytesStreamOutput out = new BytesStreamOutput();
    out.setVersion(version);
    example.writeTo(out);
    StreamInput in = out.bytes().streamInput();
    in.setVersion(version);
    empty.readFrom(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RoundTripTests.java

示例6: assertSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
private void assertSerialization(FieldStats stats, Version version) throws IOException {
    BytesStreamOutput output = new BytesStreamOutput();
    output.setVersion(version);
    stats.writeTo(output);
    output.flush();
    StreamInput input = output.bytes().streamInput();
    input.setVersion(version);
    FieldStats deserializedStats = FieldStats.readFrom(input);
    assertEquals(stats, deserializedStats);
    assertEquals(stats.hashCode(), deserializedStats.hashCode());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:FieldStatsTests.java

示例7: serialize

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
private <T extends Exception> T serialize(T exception, Version version) throws IOException {
    ElasticsearchAssertions.assertVersionSerializable(version, exception);
    BytesStreamOutput out = new BytesStreamOutput();
    out.setVersion(version);
    out.writeException(exception);

    StreamInput in = out.bytes().streamInput();
    in.setVersion(version);
    return in.readException();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ExceptionSerializationTests.java

示例8: testSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
    int iterations = randomIntBetween(10, 100);
    for (int i = 0; i < iterations; i++) {
        // Get a random version
        Version version = randomVersion(random());

        // Get a random list of ClusterBlockLevels
        EnumSet<ClusterBlockLevel> levels = EnumSet.noneOf(ClusterBlockLevel.class);
        int nbLevels = randomIntBetween(1, ClusterBlockLevel.values().length);
        for (int j = 0; j < nbLevels; j++) {
            levels.add(randomFrom(ClusterBlockLevel.values()));
        }

        ClusterBlock clusterBlock = new ClusterBlock(randomInt(), "cluster block #" + randomInt(), randomBoolean(),
                randomBoolean(), randomFrom(RestStatus.values()), levels);

        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(version);
        clusterBlock.writeTo(out);

        StreamInput in = out.bytes().streamInput();
        in.setVersion(version);
        ClusterBlock result = ClusterBlock.readClusterBlock(in);

        assertThat(result.id(), equalTo(clusterBlock.id()));
        assertThat(result.status(), equalTo(clusterBlock.status()));
        assertThat(result.description(), equalTo(clusterBlock.description()));
        assertThat(result.retryable(), equalTo(clusterBlock.retryable()));
        assertThat(result.disableStatePersistence(), equalTo(clusterBlock.disableStatePersistence()));
        assertArrayEquals(result.levels().toArray(), clusterBlock.levels().toArray());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:ClusterBlockTests.java

示例9: testGetIndexedScriptRequestSerialization

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testGetIndexedScriptRequestSerialization() throws IOException {
    GetStoredScriptRequest request = new GetStoredScriptRequest("lang", "id");

    BytesStreamOutput out = new BytesStreamOutput();
    out.setVersion(randomVersion(random()));
    request.writeTo(out);

    StreamInput in = out.bytes().streamInput();
    in.setVersion(out.getVersion());
    GetStoredScriptRequest request2 = new GetStoredScriptRequest();
    request2.readFrom(in);

    assertThat(request2.id(), equalTo(request.id()));
    assertThat(request2.lang(), equalTo(request.lang()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:GetStoredScriptRequestTests.java

示例10: testFieldStatsBWC

import org.elasticsearch.common.io.stream.StreamInput; //导入方法依赖的package包/类
public void testFieldStatsBWC() throws Exception {
    int size = randomIntBetween(5, 20);
    Map<String, FieldStats<?> > stats = new HashMap<> ();
    for (int i = 0; i < size; i++) {
        stats.put(Integer.toString(i), FieldStatsTests.randomFieldStats(true));
    }

    FieldStatsShardResponse response = new FieldStatsShardResponse(new ShardId("test", "test", 0), stats);
    for (int i = 0; i < 10; i++) {
        Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.CURRENT);
        BytesStreamOutput output = new BytesStreamOutput();
        output.setVersion(version);
        response.writeTo(output);
        output.flush();
        StreamInput input = output.bytes().streamInput();
        input.setVersion(version);
        FieldStatsShardResponse deserialized = new FieldStatsShardResponse();
        deserialized.readFrom(input);
        final Map<String, FieldStats<?>> expected;
        if (version.before(Version.V_5_2_0_UNRELEASED)) {
            expected = deserialized.filterNullMinMax();
        } else {
            expected = deserialized.getFieldStats();
        }
        assertEquals(expected.size(), deserialized.getFieldStats().size());
        assertThat(expected, equalTo(deserialized.getFieldStats()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:FieldStatsRequestTests.java


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