Search in sources :

Example 11 with CacheRecord

use of com.hazelcast.cache.impl.record.CacheRecord in project hazelcast by hazelcast.

the class CachePutAllBackupOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeBoolean(cacheRecords != null);
    if (cacheRecords != null) {
        out.writeInt(cacheRecords.size());
        for (Map.Entry<Data, CacheRecord> entry : cacheRecords.entrySet()) {
            final Data key = entry.getKey();
            final CacheRecord record = entry.getValue();
            out.writeData(key);
            out.writeObject(record);
        }
    }
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) Data(com.hazelcast.nio.serialization.Data) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with CacheRecord

use of com.hazelcast.cache.impl.record.CacheRecord in project hazelcast by hazelcast.

the class CachePutAllBackupOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    final boolean recordNotNull = in.readBoolean();
    if (recordNotNull) {
        int size = in.readInt();
        cacheRecords = new HashMap<Data, CacheRecord>(size);
        for (int i = 0; i < size; i++) {
            final Data key = in.readData();
            final CacheRecord record = in.readObject();
            cacheRecords.put(key, record);
        }
    }
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) Data(com.hazelcast.nio.serialization.Data)

Example 13 with CacheRecord

use of com.hazelcast.cache.impl.record.CacheRecord in project hazelcast by hazelcast.

the class CacheSerializationTest method testCacheRecord_withObjectInMemoryData.

@Test
public void testCacheRecord_withObjectInMemoryData() {
    String value = randomString();
    CacheRecord cacheRecord = createRecord(InMemoryFormat.OBJECT, value);
    Data cacheRecordData = service.toData(cacheRecord);
    CacheRecord deserialized = service.toObject(cacheRecordData);
    assertEquals(value, deserialized.getValue());
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) Data(com.hazelcast.nio.serialization.Data) CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 14 with CacheRecord

use of com.hazelcast.cache.impl.record.CacheRecord in project hazelcast by hazelcast.

the class CacheSerializationTest method testCacheRecord_withBinaryInMemoryData.

@Test
public void testCacheRecord_withBinaryInMemoryData() {
    String value = randomString();
    CacheRecord cacheRecord = createRecord(InMemoryFormat.BINARY, value);
    Data cacheRecordData = service.toData(cacheRecord);
    CacheRecord deserialized = service.toObject(cacheRecordData);
    assertEquals(value, service.toObject(deserialized.getValue()));
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) Data(com.hazelcast.nio.serialization.Data) CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)14 Data (com.hazelcast.nio.serialization.Data)14 HashMap (java.util.HashMap)7 Map (java.util.Map)6 ICacheService (com.hazelcast.cache.impl.ICacheService)3 CachePartitionEventData (com.hazelcast.cache.impl.CachePartitionEventData)2 CacheConfig (com.hazelcast.config.CacheConfig)2 IPartitionService (com.hazelcast.spi.partition.IPartitionService)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 CacheClearResponse (com.hazelcast.cache.impl.CacheClearResponse)1 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)1 Address (com.hazelcast.nio.Address)1 AbstractMap (java.util.AbstractMap)1 CacheException (javax.cache.CacheException)1