Package org.elasticsearch.common.io.stream

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput.bytes()


                    new MappingMetaData.Id(null), new MappingMetaData.Routing(false, null), timestamp, false);

            BytesStreamOutput out = new BytesStreamOutput();
            MappingMetaData.writeTo(expected, out);
            out.close();
            BytesReference bytes = out.bytes();

            MappingMetaData metaData = MappingMetaData.readFrom(new BytesStreamInput(bytes));

            assertThat(metaData, is(expected));
        }
View Full Code Here


                out.append(" ");
            }
            out.append("\n");
        }
        out.close();
        return new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, bytesOut.bytes(), true);
    }

    private static List<DisplayHeader> buildDisplayHeaders(Table table, RestRequest request) {
        String pHeaders = request.param("h");
        List<DisplayHeader> display = new ArrayList<>();
View Full Code Here

        }

        public static byte[] toBytes(ClusterState state) throws IOException {
            BytesStreamOutput os = new BytesStreamOutput();
            writeTo(state, os);
            return os.bytes().toBytes();
        }

        /**
         * @param data               input bytes
         * @param localNode          used to set the local node in the cluster state.
View Full Code Here

        jsonGen.writeEndObject();

        xsonGen.close();
        jsonGen.close();

        verifySameTokens(XContentFactory.xContent(XContentType.JSON).createParser(jsonOs.bytes().toBytes()), XContentFactory.xContent(XContentType.SMILE).createParser(xsonOs.bytes().toBytes()));
    }

    private void verifySameTokens(XContentParser parser1, XContentParser parser2) throws IOException {
        while (true) {
            XContentParser.Token token1 = parser1.nextToken();
View Full Code Here

        AllocationService strategy = createAllocationService();
        RoutingTable source = strategy.reroute(clusterState).routingTable();

        BytesStreamOutput outStream = new BytesStreamOutput();
        RoutingTable.Builder.writeTo(source, outStream);
        BytesStreamInput inStream = new BytesStreamInput(outStream.bytes().toBytes(), false);
        RoutingTable target = RoutingTable.Builder.readFrom(inStream);

        assertThat(target.prettyPrint(), equalTo(source.prettyPrint()));
    }
View Full Code Here

        out.writeSharedString(test4);
        out.writeSharedString(test4);
        out.writeSharedString(test5);
        out.writeSharedString(test6);

        BytesStreamInput bin = new BytesStreamInput(bout.bytes());
        HandlesStreamInput in = new HandlesStreamInput(bin);
        String s1 = in.readString();
        String s2 = in.readString();
        String s3 = in.readString();
        String s4 = in.readString();
View Full Code Here

    public void testEmpty() throws Exception {
        BytesStreamOutput out = new BytesStreamOutput();

        // test empty stream to array
        assertEquals(0, out.size());
        assertEquals(0, out.bytes().toBytes().length);

        out.close();
    }

    @Test
View Full Code Here

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

            BytesStreamInput in = new BytesStreamInput(out.bytes());
            in.setVersion(out.getVersion());
            OriginalIndices originalIndices2 = OriginalIndices.readOriginalIndices(in);

            if (out.getVersion().onOrAfter(Version.V_1_4_0_Beta1)) {
                assertThat(originalIndices2.indices(), equalTo(originalIndices.indices()));
View Full Code Here

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

            BytesStreamInput in = new BytesStreamInput(out.bytes());
            in.setVersion(out.getVersion());
            OriginalIndices originalIndices2 = OriginalIndices.readOptionalOriginalIndices(in);

            if (out.getVersion().onOrAfter(Version.V_1_4_0_Beta1)) {
                assertThat(originalIndices2.indices(), equalTo(originalIndices.indices()));
View Full Code Here

        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(randomVersion());
        multiGetShardRequest.writeTo(out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        in.setVersion(out.getVersion());
        MultiGetShardRequest multiGetShardRequest2 = new MultiGetShardRequest();
        multiGetShardRequest2.readFrom(in);

        assertThat(multiGetShardRequest2.index(), equalTo(multiGetShardRequest.index()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.