Search in sources :

Example 1 with RequestMessage

use of org.neo4j.bolt.v1.messaging.message.RequestMessage in project neo4j by neo4j.

the class MessageMatchers method messages.

public static List<RequestMessage> messages(byte[] bytes) throws IOException {
    BoltRequestMessageReader unpacker = requestReader(bytes);
    BoltRequestMessageRecorder consumer = new BoltRequestMessageRecorder();
    try {
        while (unpacker.hasNext()) {
            unpacker.read(consumer);
        }
        return consumer.asList();
    } catch (Throwable e) {
        throw new IOException("Failed to deserialize response, '" + e.getMessage() + "'. Messages read so " + "far: \n" + consumer.asList() + "\n" + "Raw data: \n" + HexPrinter.hex(bytes));
    }
}
Also used : BoltRequestMessageReader(org.neo4j.bolt.v1.messaging.BoltRequestMessageReader) BoltRequestMessageRecorder(org.neo4j.bolt.v1.messaging.BoltRequestMessageRecorder) IOException(java.io.IOException)

Example 2 with RequestMessage

use of org.neo4j.bolt.v1.messaging.message.RequestMessage in project neo4j by neo4j.

the class FragmentedMessageDeliveryTest method serialize.

private byte[] serialize(int chunkSize, RequestMessage... msgs) throws IOException {
    byte[][] serialized = new byte[msgs.length][];
    for (int i = 0; i < msgs.length; i++) {
        RecordingByteChannel channel = new RecordingByteChannel();
        BoltRequestMessageWriter writer = new BoltRequestMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(channel)), NO_BOUNDARY_HOOK);
        writer.write(msgs[i]).flush();
        serialized[i] = channel.getBytes();
    }
    return Chunker.chunk(chunkSize, serialized);
}
Also used : RecordingByteChannel(org.neo4j.bolt.v1.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter) Neo4jPack(org.neo4j.bolt.v1.messaging.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.v1.packstream.BufferedChannelOutput)

Example 3 with RequestMessage

use of org.neo4j.bolt.v1.messaging.message.RequestMessage in project neo4j by neo4j.

the class MessageMatchers method serialize.

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

Example 4 with RequestMessage

use of org.neo4j.bolt.v1.messaging.message.RequestMessage in project neo4j by neo4j.

the class BoltRequestMessageTest method serializeAndDeserialize.

private <T extends RequestMessage> T serializeAndDeserialize(T msg) throws IOException {
    RecordingByteChannel channel = new RecordingByteChannel();
    BoltRequestMessageReader reader = new BoltRequestMessageReader(new Neo4jPack.Unpacker(new BufferedChannelInput(16).reset(channel)));
    BoltRequestMessageWriter writer = new BoltRequestMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(channel)), NO_BOUNDARY_HOOK);
    writer.write(msg).flush();
    channel.eof();
    return unpack(reader, channel);
}
Also used : BufferedChannelInput(org.neo4j.bolt.v1.packstream.BufferedChannelInput) BufferedChannelOutput(org.neo4j.bolt.v1.packstream.BufferedChannelOutput)

Example 5 with RequestMessage

use of org.neo4j.bolt.v1.messaging.message.RequestMessage in project neo4j by neo4j.

the class ResetFuzzTest method dispatchRandomSequenceOfMessages.

private void dispatchRandomSequenceOfMessages(BoltMessageRouter messageHandler) {
    List<RequestMessage> sequence = sequences.get(rand.nextInt(sequences.size()));
    for (RequestMessage message : sequence) {
        sent.add(message);
        message.dispatch(messageHandler);
    }
}
Also used : RequestMessage(org.neo4j.bolt.v1.messaging.message.RequestMessage)

Aggregations

BufferedChannelOutput (org.neo4j.bolt.v1.packstream.BufferedChannelOutput)3 BoltRequestMessageWriter (org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter)2 Neo4jPack (org.neo4j.bolt.v1.messaging.Neo4jPack)2 RecordingByteChannel (org.neo4j.bolt.v1.messaging.RecordingByteChannel)2 RequestMessage (org.neo4j.bolt.v1.messaging.message.RequestMessage)2 IOException (java.io.IOException)1 BoltRequestMessageReader (org.neo4j.bolt.v1.messaging.BoltRequestMessageReader)1 BoltRequestMessageRecorder (org.neo4j.bolt.v1.messaging.BoltRequestMessageRecorder)1 BufferedChannelInput (org.neo4j.bolt.v1.packstream.BufferedChannelInput)1