Search in sources :

Example 1 with BufferedChannelOutput

use of org.neo4j.bolt.packstream.BufferedChannelOutput in project neo4j by neo4j.

the class MessageConditions method serialize.

public static byte[] serialize(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
    BoltRequestMessageWriter writer = new BoltRequestMessageWriterV4(packer);
    for (RequestMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : RequestMessage(org.neo4j.bolt.messaging.RequestMessage) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) BoltRequestMessageWriterV4(org.neo4j.bolt.v4.BoltRequestMessageWriterV4) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 2 with BufferedChannelOutput

use of org.neo4j.bolt.packstream.BufferedChannelOutput in project neo4j by neo4j.

the class BoltResponseMessageTest method serializeAndDeserialize.

private <T extends ResponseMessage> T serializeAndDeserialize(T msg) throws IOException {
    RecordingByteChannel channel = new RecordingByteChannel();
    BoltResponseMessageReader reader = new BoltResponseMessageReader(neo4jPack.newUnpacker(new BufferedChannelInput(16).reset(channel)));
    BufferedChannelOutput output = new BufferedChannelOutput(channel);
    BoltResponseMessageWriterV3 writer = new BoltResponseMessageWriterV3(neo4jPack::newPacker, output, NullLogService.getInstance());
    writer.write(msg);
    writer.flush();
    channel.eof();
    return unpack(reader, channel);
}
Also used : BufferedChannelInput(org.neo4j.bolt.packstream.BufferedChannelInput) BoltResponseMessageWriterV3(org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 3 with BufferedChannelOutput

use of org.neo4j.bolt.packstream.BufferedChannelOutput in project neo4j by neo4j.

the class BoltProtocolV43ComponentFactory method encode.

public static byte[] encode(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
    BoltRequestMessageWriter writer = requestMessageWriter(packer);
    for (RequestMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : RequestMessage(org.neo4j.bolt.messaging.RequestMessage) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 4 with BufferedChannelOutput

use of org.neo4j.bolt.packstream.BufferedChannelOutput in project neo4j by neo4j.

the class BoltProtocolV41ComponentFactory method encode.

public static byte[] encode(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
    BoltRequestMessageWriter writer = requestMessageWriter(packer);
    for (RequestMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : RequestMessage(org.neo4j.bolt.messaging.RequestMessage) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 5 with BufferedChannelOutput

use of org.neo4j.bolt.packstream.BufferedChannelOutput in project neo4j by neo4j.

the class BoltRequestMessageV3Test method serializeAndDeserialize.

private <T extends RequestMessage> T serializeAndDeserialize(T msg) throws Exception {
    RecordingByteChannel channel = new RecordingByteChannel();
    Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(channel));
    BoltRequestMessageWriter writer = new BoltRequestMessageWriterV3(packer);
    writer.write(msg).flush();
    channel.eof();
    return unpack(channel);
}
Also used : RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BoltProtocolV3ComponentFactory.newNeo4jPack(org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Aggregations

BufferedChannelOutput (org.neo4j.bolt.packstream.BufferedChannelOutput)11 RecordingByteChannel (org.neo4j.bolt.messaging.RecordingByteChannel)10 BoltRequestMessageWriter (org.neo4j.bolt.messaging.BoltRequestMessageWriter)6 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)6 RequestMessage (org.neo4j.bolt.messaging.RequestMessage)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 PackStream (org.neo4j.bolt.packstream.PackStream)3 BoltResponseMessageWriterV3 (org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3)2 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)1 ResponseMessage (org.neo4j.bolt.messaging.ResponseMessage)1 BufferedChannelInput (org.neo4j.bolt.packstream.BufferedChannelInput)1 BoltProtocolV3ComponentFactory.newNeo4jPack (org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack)1 BoltRequestMessageWriterV4 (org.neo4j.bolt.v4.BoltRequestMessageWriterV4)1