當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。