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;
}
Aggregations