Search in sources :

Example 1 with OutboundEncoder

use of org.apache.ignite.internal.network.netty.OutboundEncoder in project ignite-3 by apache.

the class MarshallableTest method write.

/**
 * Writes a map to a buffer through the {@link MessageWithMarshallable}.
 */
private ByteBuffer write(Map<String, SimpleSerializableObject> testMap) throws Exception {
    var serializers = new Serialization();
    var writer = new DirectMessageWriter(serializers.perSessionSerializationService, ConnectionManager.DIRECT_PROTOCOL_VERSION);
    MessageWithMarshallable msg = msgFactory.messageWithMarshallable().marshallableMap(testMap).build();
    IntSet ids = new IntOpenHashSet();
    msg.prepareMarshal(ids, serializers.userObjectSerializer);
    MessageSerializer<NetworkMessage> serializer = registry.createSerializer(msg.groupType(), msg.messageType());
    var catcher = new OutboundByteBufCatcher();
    var channel = new EmbeddedChannel(catcher, new ChunkedWriteHandler(), new OutboundEncoder(serializers.perSessionSerializationService));
    List<ClassDescriptorMessage> classDescriptorsMessages = PerSessionSerializationService.createClassDescriptorsMessages(ids, serializers.descriptorRegistry);
    channel.writeAndFlush(new OutNetworkObject(msg, classDescriptorsMessages));
    channel.flushOutbound();
    ByteBuffer nioBuffer = catcher.buf;
    return nioBuffer;
}
Also used : IntSet(it.unimi.dsi.fastutil.ints.IntSet) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ByteBuffer(java.nio.ByteBuffer) ClassDescriptorMessage(org.apache.ignite.internal.network.message.ClassDescriptorMessage) IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) DirectMessageWriter(org.apache.ignite.internal.network.direct.DirectMessageWriter) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) OutboundEncoder(org.apache.ignite.internal.network.netty.OutboundEncoder) NetworkMessage(org.apache.ignite.network.NetworkMessage) OutNetworkObject(org.apache.ignite.network.OutNetworkObject)

Aggregations

EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)1 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1 IntSet (it.unimi.dsi.fastutil.ints.IntSet)1 ByteBuffer (java.nio.ByteBuffer)1 DirectMessageWriter (org.apache.ignite.internal.network.direct.DirectMessageWriter)1 ClassDescriptorMessage (org.apache.ignite.internal.network.message.ClassDescriptorMessage)1 OutboundEncoder (org.apache.ignite.internal.network.netty.OutboundEncoder)1 NetworkMessage (org.apache.ignite.network.NetworkMessage)1 OutNetworkObject (org.apache.ignite.network.OutNetworkObject)1