use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class RecordReaderWriterTest method written_and_read_data_record_with_stats_are_equal.
@Test
public void written_and_read_data_record_with_stats_are_equal() throws IOException {
ExpiryMetadata expiryMetadata = newExpiryMetadata();
Record<Data> writtenRecord = populateAndGetRecord(new DataRecordWithStats(), expiryMetadata);
Record<Data> readRecord = writeReadAndGet(writtenRecord, writtenRecord.getValue(), expiryMetadata);
assertEquals(writtenRecord, readRecord);
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class RecordReaderWriterTest method written_and_read_object_record_with_stats_are_equal.
@Test
public void written_and_read_object_record_with_stats_are_equal() throws IOException {
ExpiryMetadata expiryMetadata = newExpiryMetadata();
Record writtenRecord = populateAndGetRecord(new ObjectRecordWithStats(), expiryMetadata);
Data dataValue = ss.toData(writtenRecord.getValue());
Record<Data> readRecord = writeReadAndGet(writtenRecord, dataValue, expiryMetadata);
assertEquals(asDataRecordWithStats(writtenRecord, dataValue), readRecord);
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class MapReplicationStateHolder method forEachReplicatedRecord.
private void forEachReplicatedRecord(List keyRecordExpiry, MapContainer mapContainer, RecordStore recordStore, boolean populateIndexes, long nowInMillis) {
long ownedEntryCountOnThisNode = entryCountOnThisNode(mapContainer);
EvictionConfig evictionConfig = mapContainer.getMapConfig().getEvictionConfig();
boolean perNodeEvictionConfigured = mapContainer.getEvictor() != Evictor.NULL_EVICTOR && evictionConfig.getMaxSizePolicy() == PER_NODE;
for (int i = 0; i < keyRecordExpiry.size(); i += 3) {
Data dataKey = (Data) keyRecordExpiry.get(i);
Record record = (Record) keyRecordExpiry.get(i + 1);
ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.get(i + 2);
if (perNodeEvictionConfigured) {
if (ownedEntryCountOnThisNode >= evictionConfig.getSize()) {
if (operation.getReplicaIndex() == 0) {
recordStore.doPostEvictionOperations(dataKey, record.getValue(), ExpiryReason.NOT_EXPIRED);
}
} else {
recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, populateIndexes, nowInMillis);
ownedEntryCountOnThisNode++;
}
} else {
recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, populateIndexes, nowInMillis);
if (recordStore.shouldEvict()) {
// No need to continue replicating records anymore.
// We are already over eviction threshold, each put record will cause another eviction.
recordStore.evictEntries(dataKey);
break;
}
}
recordStore.disposeDeferredBlocks();
}
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class MapChunk method putOrUpdateReplicatedDataWithPerNodeEviction.
// owned or backup
private void putOrUpdateReplicatedDataWithPerNodeEviction(RecordStore recordStore) {
MapContainer mapContainer = recordStore.getMapContainer();
EvictionConfig evictionConfig = mapContainer.getMapConfig().getEvictionConfig();
long ownedEntryCountOnThisNode = entryCountOnThisNode(mapContainer);
int count = 0;
long nowInMillis = Clock.currentTimeMillis();
do {
Data dataKey = (Data) keyRecordExpiry.poll();
Record record = (Record) keyRecordExpiry.poll();
ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.poll();
if (ownedEntryCountOnThisNode >= evictionConfig.getSize()) {
if (getReplicaIndex() == 0) {
recordStore.doPostEvictionOperations(dataKey, record.getValue(), ExpiryReason.NOT_EXPIRED);
}
} else {
Indexes indexes = mapContainer.getIndexes(recordStore.getPartitionId());
recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, indexesMustBePopulated(indexes), nowInMillis);
ownedEntryCountOnThisNode++;
}
if (++count % DISPOSE_AT_COUNT == 0) {
recordStore.disposeDeferredBlocks();
}
} while (!keyRecordExpiry.isEmpty());
recordStore.disposeDeferredBlocks();
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class Records method readExpiry.
public static ExpiryMetadata readExpiry(ObjectDataInput in) throws IOException {
ExpiryMetadata expiryMetadata = ExpiryMetadata.NULL;
boolean hasExpiry = in.readBoolean();
if (hasExpiry) {
expiryMetadata = new ExpiryMetadataImpl();
expiryMetadata.read(in);
}
return expiryMetadata;
}
Aggregations