use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class ReplicationOperation method fetchReplicatedMapRecords.
private void fetchReplicatedMapRecords(PartitionContainer container) {
int storeCount = container.getStores().size();
data = new HashMap<String, Set<RecordMigrationInfo>>(storeCount);
versions = new HashMap<String, Long>(storeCount);
for (Map.Entry<String, ReplicatedRecordStore> entry : container.getStores().entrySet()) {
String name = entry.getKey();
ReplicatedRecordStore store = entry.getValue();
Set<RecordMigrationInfo> recordSet = new HashSet<RecordMigrationInfo>(store.size());
Iterator<ReplicatedRecord> iterator = store.recordIterator();
while (iterator.hasNext()) {
ReplicatedRecord record = iterator.next();
Data dataKey = serializationService.toData(record.getKeyInternal());
Data dataValue = serializationService.toData(record.getValueInternal());
RecordMigrationInfo migrationInfo = new RecordMigrationInfo();
migrationInfo.setKey(dataKey);
migrationInfo.setValue(dataValue);
migrationInfo.setTtl(record.getTtlMillis());
migrationInfo.setHits(record.getHits());
migrationInfo.setCreationTime(record.getCreationTime());
migrationInfo.setLastAccessTime(record.getLastAccessTime());
migrationInfo.setLastUpdateTime(record.getUpdateTime());
recordSet.add(migrationInfo);
}
data.put(name, recordSet);
versions.put(name, store.getVersion());
}
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class RequestMapDataOperation method getRecordSet.
private Set<RecordMigrationInfo> getRecordSet(ReplicatedRecordStore store) {
Set<RecordMigrationInfo> recordSet = new HashSet<RecordMigrationInfo>(store.size());
Iterator<ReplicatedRecord> iterator = store.recordIterator();
while (iterator.hasNext()) {
ReplicatedRecord record = iterator.next();
SerializationService serializationService = getNodeEngine().getSerializationService();
Data dataKey = serializationService.toData(record.getKeyInternal());
Data dataValue = serializationService.toData(record.getValueInternal());
recordSet.add(new RecordMigrationInfo(dataKey, dataValue, record.getTtlMillis()));
}
return recordSet;
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class SyncReplicatedMapDataOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
out.writeUTF(name);
out.writeLong(version);
out.writeInt(recordSet.size());
for (RecordMigrationInfo record : recordSet) {
record.writeData(out);
}
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class SyncReplicatedMapDataOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getLogger();
if (logger.isFineEnabled()) {
logger.fine("Syncing " + recordSet.size() + " records and version: " + version + " for map: " + name + " partitionId=" + getPartitionId() + " from: " + getCallerAddress() + " to: " + getNodeEngine().getThisAddress());
}
ReplicatedMapService service = getService();
AbstractReplicatedRecordStore store = (AbstractReplicatedRecordStore) service.getReplicatedRecordStore(name, true, getPartitionId());
InternalReplicatedMapStorage<K, V> newStorage = new InternalReplicatedMapStorage<K, V>();
for (RecordMigrationInfo record : recordSet) {
K key = (K) store.marshall(record.getKey());
V value = (V) store.marshall(record.getValue());
ReplicatedRecord<K, V> replicatedRecord = buildReplicatedRecord(key, value, record.getTtl());
ReplicatedRecord oldRecord = store.getReplicatedRecord(key);
if (oldRecord != null) {
replicatedRecord.setHits(oldRecord.getHits());
}
newStorage.put(key, replicatedRecord);
if (record.getTtl() > 0) {
store.scheduleTtlEntry(record.getTtl(), key, value);
}
}
newStorage.syncVersion(version);
AtomicReference<InternalReplicatedMapStorage<K, V>> storageRef = store.getStorageRef();
storageRef.set(newStorage);
store.setLoaded(true);
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class SyncReplicatedMapDataOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
name = in.readUTF();
version = in.readLong();
int size = in.readInt();
recordSet = new HashSet<RecordMigrationInfo>(size);
for (int j = 0; j < size; j++) {
RecordMigrationInfo record = new RecordMigrationInfo();
record.readData(in);
recordSet.add(record);
}
}
Aggregations