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;
}
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();
}
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);
}
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;
}
}
}
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();
}
Aggregations