Search in sources :

Example 1 with GridIoMessageFactory

use of org.apache.ignite.internal.managers.communication.GridIoMessageFactory in project ignite by apache.

the class GridMessageCollectionTest method doTestMarshal.

/**
     * @param m Message.
     */
private void doTestMarshal(Message m) {
    ByteBuffer buf = ByteBuffer.allocate(8 * 1024);
    m.writeTo(buf, writer(proto));
    buf.flip();
    byte b0 = buf.get();
    byte b1 = buf.get();
    short type = (short) ((b1 & 0xFF) << 8 | b0 & 0xFF);
    assertEquals(m.directType(), type);
    GridIoMessageFactory msgFactory = new GridIoMessageFactory(null);
    Message mx = msgFactory.create(type);
    mx.readFrom(buf, reader(msgFactory, proto));
    assertEquals(m, mx);
}
Also used : UUIDCollectionMessage(org.apache.ignite.internal.util.UUIDCollectionMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) ByteBuffer(java.nio.ByteBuffer)

Example 2 with GridIoMessageFactory

use of org.apache.ignite.internal.managers.communication.GridIoMessageFactory in project ignite by apache.

the class IgniteCacheContinuousQueryImmutableEntryTest method testCacheContinuousQueryEntrySerialization.

/**
     *
     */
public void testCacheContinuousQueryEntrySerialization() {
    CacheContinuousQueryEntry e0 = new CacheContinuousQueryEntry(1, EventType.UPDATED, new KeyCacheObjectImpl(1, new byte[] { 0, 0, 0, 1 }, 1), new CacheObjectImpl(2, new byte[] { 0, 0, 0, 2 }), new CacheObjectImpl(2, new byte[] { 0, 0, 0, 3 }), true, 1, 1L, new AffinityTopologyVersion(1L), (byte) 0);
    e0.markFiltered();
    ByteBuffer buf = ByteBuffer.allocate(4096);
    DirectMessageWriter writer = new DirectMessageWriter((byte) 1);
    // Skip write class header.
    writer.onHeaderWritten();
    e0.writeTo(buf, writer);
    CacheContinuousQueryEntry e1 = new CacheContinuousQueryEntry();
    e1.readFrom(ByteBuffer.wrap(buf.array()), new DirectMessageReader(new GridIoMessageFactory(null), (byte) 1));
    assertEquals(e0.cacheId(), e1.cacheId());
    assertEquals(e0.eventType(), e1.eventType());
    assertEquals(e0.isFiltered(), e1.isFiltered());
    assertEquals(e0.isBackup(), e1.isBackup());
    assertEquals(e0.isKeepBinary(), e1.isKeepBinary());
    assertEquals(e0.partition(), e1.partition());
    assertEquals(e0.updateCounter(), e1.updateCounter());
    // Key and value shouldn't be serialized in case an event is filtered.
    assertNull(e1.key());
    assertNotNull(e0.key());
    assertNull(e1.oldValue());
    assertNotNull(e0.oldValue());
    assertNull(e1.value());
    assertNotNull(e0.value());
}
Also used : DirectMessageReader(org.apache.ignite.internal.direct.DirectMessageReader) DirectMessageWriter(org.apache.ignite.internal.direct.DirectMessageWriter) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) KeyCacheObjectImpl(org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl) CacheObjectImpl(org.apache.ignite.internal.processors.cache.CacheObjectImpl) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) KeyCacheObjectImpl(org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)2 GridIoMessageFactory (org.apache.ignite.internal.managers.communication.GridIoMessageFactory)2 DirectMessageReader (org.apache.ignite.internal.direct.DirectMessageReader)1 DirectMessageWriter (org.apache.ignite.internal.direct.DirectMessageWriter)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 CacheObjectImpl (org.apache.ignite.internal.processors.cache.CacheObjectImpl)1 KeyCacheObjectImpl (org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl)1 UUIDCollectionMessage (org.apache.ignite.internal.util.UUIDCollectionMessage)1 Message (org.apache.ignite.plugin.extensions.communication.Message)1