Search in sources :

Example 26 with Record

use of com.hazelcast.map.impl.record.Record 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 27 with Record

use of com.hazelcast.map.impl.record.Record 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 28 with Record

use of com.hazelcast.map.impl.record.Record 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)

Example 29 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class PutAllBackupOperation method runInternal.

@Override
@SuppressWarnings("checkstyle:magicnumber")
protected void runInternal() {
    List keyRecordExpiry = this.keyRecordExpiry;
    if (keyRecordExpiry != null) {
        for (int i = lastIndex; i < keyRecordExpiry.size(); i += 3) {
            Data key = (Data) keyRecordExpiry.get(i);
            Record record = (Record) keyRecordExpiry.get(i + 1);
            ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.get(i + 2);
            putBackup(key, record, expiryMetadata);
            lastIndex = i;
        }
    } else {
        // If dataKeyRecord is null and we are in
        // `runInternal` method, means this operation
        // has not been serialized/deserialized
        // and is running directly on caller node
        List keyValueRecordExpiry = this.keyValueRecordExpiry;
        for (int i = lastIndex; i < keyValueRecordExpiry.size(); i += 4) {
            Data key = (Data) keyValueRecordExpiry.get(i);
            Record record = (Record) keyValueRecordExpiry.get(i + 2);
            ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyValueRecordExpiry.get(i + 3);
            putBackup(key, record, expiryMetadata);
            lastIndex = i;
        }
    }
}
Also used : 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 30 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class PutAllBackupOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    int size = in.readInt();
    List keyRecordExpiry = new ArrayList<>(size * 3);
    for (int i = 0; i < size; i++) {
        Data dataKey = IOUtil.readData(in);
        Record record = Records.readRecord(in);
        ExpiryMetadata expiryMetadata = Records.readExpiry(in);
        keyRecordExpiry.add(dataKey);
        keyRecordExpiry.add(record);
        keyRecordExpiry.add(expiryMetadata);
    }
    this.keyRecordExpiry = keyRecordExpiry;
    this.disableWanReplicationEvent = in.readBoolean();
}
Also used : 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)

Aggregations

Record (com.hazelcast.map.impl.record.Record)109 Data (com.hazelcast.internal.serialization.Data)27 Data (com.hazelcast.nio.serialization.Data)22 Map (java.util.Map)13 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)11 ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)11 EntryView (com.hazelcast.core.EntryView)8 Indexes (com.hazelcast.query.impl.Indexes)8 ArrayList (java.util.ArrayList)7 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)6 MapContainer (com.hazelcast.map.impl.MapContainer)6 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)6 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)6 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)5 MapService (com.hazelcast.map.impl.MapService)5 List (java.util.List)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapEntries (com.hazelcast.map.impl.MapEntries)3