Search in sources :

Example 1 with ExpiryMetadata

use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.

the class MapReplicationStateHolder method readRecordStoreData.

protected void readRecordStoreData(String mapName, ObjectDataInput in) throws IOException {
    int numOfRecords = in.readInt();
    List keyRecord = new ArrayList<>(numOfRecords * 3);
    for (int j = 0; j < numOfRecords; j++) {
        Data dataKey = IOUtil.readData(in);
        Record record = Records.readRecord(in);
        ExpiryMetadata expiryMetadata = Records.readExpiry(in);
        keyRecord.add(dataKey);
        keyRecord.add(record);
        keyRecord.add(expiryMetadata);
    }
    LocalRecordStoreStatsImpl stats = new LocalRecordStoreStatsImpl();
    stats.readData(in);
    recordStoreStatsPerMapName.put(mapName, stats);
    data.put(mapName, keyRecord);
}
Also used : LocalRecordStoreStatsImpl(com.hazelcast.internal.monitor.impl.LocalRecordStoreStatsImpl) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 2 with ExpiryMetadata

use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.

the class MapOperation method publishWanUpdateInternal.

private void publishWanUpdateInternal(Data dataKey, Object value, boolean hasLoadProvenance) {
    if (!canPublishWanEvent) {
        return;
    }
    Record<Object> record = recordStore.getRecord(dataKey);
    if (record == null) {
        return;
    }
    Data dataValue = toHeapData(mapServiceContext.toData(value));
    ExpiryMetadata expiryMetadata = recordStore.getExpirySystem().getExpiryMetadata(dataKey);
    WanMapEntryView<Object, Object> entryView = createWanEntryView(toHeapData(dataKey), dataValue, record, expiryMetadata, getNodeEngine().getSerializationService());
    mapEventPublisher.publishWanUpdate(name, entryView, hasLoadProvenance);
}
Also used : ToHeapDataConverter.toHeapData(com.hazelcast.internal.util.ToHeapDataConverter.toHeapData) Data(com.hazelcast.internal.serialization.Data) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 3 with ExpiryMetadata

use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.

the class MapChunk method readChunk.

private void readChunk(ObjectDataInput in) throws IOException {
    this.mapName = in.readString();
    LinkedList keyRecordExpiry = new LinkedList<>();
    do {
        Data dataKey = IOUtil.readData(in);
        // null indicates end of chunk
        if (dataKey == null) {
            break;
        }
        Record record = Records.readRecord(in);
        ExpiryMetadata expiryMetadata = Records.readExpiry(in);
        keyRecordExpiry.add(dataKey);
        keyRecordExpiry.add(record);
        keyRecordExpiry.add(expiryMetadata);
    } while (true);
    this.keyRecordExpiry = keyRecordExpiry;
}
Also used : Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) LinkedList(java.util.LinkedList) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 4 with ExpiryMetadata

use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.

the class MapChunk method putOrUpdateReplicatedData.

private void putOrUpdateReplicatedData(RecordStore recordStore) {
    long nowInMillis = Clock.currentTimeMillis();
    int count = 0;
    do {
        Data dataKey = (Data) keyRecordExpiry.poll();
        Record record = (Record) keyRecordExpiry.poll();
        ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.poll();
        Indexes indexes = recordStore.getMapContainer().getIndexes(recordStore.getPartitionId());
        recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, indexesMustBePopulated(indexes), 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;
        }
        if (++count % DISPOSE_AT_COUNT == 0) {
            recordStore.disposeDeferredBlocks();
        }
    } while (!keyRecordExpiry.isEmpty());
    recordStore.disposeDeferredBlocks();
}
Also used : Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) Indexes(com.hazelcast.query.impl.Indexes) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 5 with ExpiryMetadata

use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.

the class PutAllBackupOperation method writeInternal.

@Override
@SuppressWarnings("checkstyle:magicnumber")
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeInt(keyValueRecordExpiry.size() / 4);
    for (int i = 0; i < keyValueRecordExpiry.size(); i += 4) {
        Data dataKey = (Data) keyValueRecordExpiry.get(i);
        Data dataValue = (Data) keyValueRecordExpiry.get(i + 1);
        Record record = (Record) keyValueRecordExpiry.get(i + 2);
        ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyValueRecordExpiry.get(i + 3);
        IOUtil.writeData(out, dataKey);
        Records.writeRecord(out, record, dataValue);
        Records.writeExpiry(out, expiryMetadata);
    }
    out.writeBoolean(disableWanReplicationEvent);
}
Also used : Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Aggregations

ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)16 Data (com.hazelcast.internal.serialization.Data)13 Record (com.hazelcast.map.impl.record.Record)11 ArrayList (java.util.ArrayList)3 List (java.util.List)3 EvictionConfig (com.hazelcast.config.EvictionConfig)2 Indexes (com.hazelcast.query.impl.Indexes)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 LocalRecordStoreStatsImpl (com.hazelcast.internal.monitor.impl.LocalRecordStoreStatsImpl)1 ToHeapDataConverter.toHeapData (com.hazelcast.internal.util.ToHeapDataConverter.toHeapData)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 ExpiryMetadataImpl (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadataImpl)1 MapMergeTypes (com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes)1 LinkedList (java.util.LinkedList)1