Examples of copiedByteArray()


Examples of org.elasticsearch.common.io.FastByteArrayOutputStream.copiedByteArray()

        jsonGen.writeEndObject();

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

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

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

Examples of org.elasticsearch.common.io.FastByteArrayOutputStream.copiedByteArray()

        bos.write(", source : { test : \"value\" }".getBytes("UTF8"));
        gen.writeStringField("name2", "something2");
        gen.writeEndObject();
        gen.close();

        byte[] data = bos.copiedByteArray();
        String sData = new String(data, "UTF8");
        System.out.println("DATA: " + sData);
    }

    @Test public void testFieldCaseConversion() throws Exception {
View Full Code Here

Examples of org.elasticsearch.common.io.FastByteArrayOutputStream.copiedByteArray()

        gen.writeEndObject();

        gen.close();

        byte[] data = os.copiedByteArray();
        JsonParser parser = new JsonFactory().createJsonParser(data);

        assertThat(parser.nextToken(), equalTo(JsonToken.START_OBJECT));
        assertThat(parser.nextToken(), equalTo(JsonToken.FIELD_NAME)); // "index"
        assertThat(parser.nextToken(), equalTo(JsonToken.VALUE_STRING));
View Full Code Here

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

        out.writeInt(1);
        out.writeUTF("else");
        out.writeUTF(higherThresholdValue);
        out.writeUTF(lowerThresholdValue);

        HandlesStreamInput in = new HandlesStreamInput(new BytesStreamInput(bytesOut.copiedByteArray()));
        assertThat(in.readUTF(), equalTo(lowerThresholdValue));
        assertThat(in.readUTF(), equalTo(higherThresholdValue));
        assertThat(in.readInt(), equalTo(1));
        assertThat(in.readUTF(), equalTo("else"));
        assertThat(in.readUTF(), equalTo(higherThresholdValue));
View Full Code Here

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

        out.writeFloat(1.1f);
        out.writeDouble(2.2);
        out.writeUTF("hello");
        out.writeUTF("goodbye");

        BytesStreamInput in = new BytesStreamInput(out.copiedByteArray());
        assertThat(in.readBoolean(), equalTo(false));
        assertThat(in.readByte(), equalTo((byte) 1));
        assertThat(in.readShort(), equalTo((short) -1));
        assertThat(in.readInt(), equalTo(-1));
        assertThat(in.readVInt(), equalTo(2));
View Full Code Here

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

        ShardsAllocation strategy = new ShardsAllocation();
        RoutingTable source = strategy.reroute(clusterState).routingTable();

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

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

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

    public static byte[] copyToByteArray(InputStream in) throws IOException {
        CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry();
        try {
            BytesStreamOutput out = cachedEntry.cachedBytes();
            copy(in, out);
            return out.copiedByteArray();
        } finally {
            CachedStreamOutput.pushEntry(cachedEntry);
        }
    }
View Full Code Here

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

                RemoteTransportException tx = new RemoteTransportException(targetTransport.nodeName(), targetTransport.boundAddress().boundAddress(), action, new NotSerializableTransportException(error));
                ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream);
                too.writeObject(tx);
                too.close();
            }
            final byte[] data = stream.copiedByteArray();
            targetTransport.threadPool().cached().execute(new Runnable() {
                @Override public void run() {
                    targetTransport.messageReceived(data, action, sourceTransport, null);
                }
            });
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.