Search in sources :

Example 1 with KeyCacheObjectImpl

use of org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl 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)1 DirectMessageReader (org.apache.ignite.internal.direct.DirectMessageReader)1 DirectMessageWriter (org.apache.ignite.internal.direct.DirectMessageWriter)1 GridIoMessageFactory (org.apache.ignite.internal.managers.communication.GridIoMessageFactory)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