use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class ClearExpiredOperation method run.
@Override
public void run() throws Exception {
final MapService mapService = getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId());
final ConcurrentMap<String, RecordStore> recordStores = partitionContainer.getMaps();
final boolean backup = !isOwner();
for (final RecordStore recordStore : recordStores.values()) {
if (recordStore.size() > 0 && recordStore.isExpirable()) {
recordStore.evictExpiredEntries(expirationPercentage, backup);
recordStore.disposeDeferredBlocks();
}
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class StoreWorker method runInternal.
private void runInternal() {
final long now = Clock.currentTimeMillis();
// if this node is the owner of a partition, we use this criteria time.
final long ownerHighestStoreTime = calculateHighestStoreTime(lastHighestStoreTime, now);
// if this node is the backup of a partition, we use this criteria time because backups are processed after delay.
final long backupHighestStoreTime = ownerHighestStoreTime - backupDelayMillis;
lastHighestStoreTime = ownerHighestStoreTime;
List<DelayedEntry> ownersList = null;
List<DelayedEntry> backupsList = null;
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if (currentThread().isInterrupted()) {
break;
}
RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
if (!hasEntryInWriteBehindQueue(recordStore)) {
continue;
}
boolean localPartition = isPartitionLocal(partitionId);
if (!localPartition) {
backupsList = initListIfNull(backupsList, partitionCount);
selectEntriesToStore(recordStore, backupsList, backupHighestStoreTime);
} else {
ownersList = initListIfNull(ownersList, partitionCount);
selectEntriesToStore(recordStore, ownersList, ownerHighestStoreTime);
}
}
if (!isEmpty(ownersList)) {
Map<Integer, List<DelayedEntry>> failuresPerPartition = writeBehindProcessor.process(ownersList);
removeFinishedStoreOperationsFromQueues(mapName, ownersList);
reAddFailedStoreOperationsToQueues(mapName, failuresPerPartition);
}
if (!isEmpty(backupsList)) {
doInBackup(backupsList);
}
notifyFlush();
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapNearCacheStateHolder method prepare.
void prepare(PartitionContainer container, int replicaIndex) {
MapService mapService = container.getMapService();
MetaDataGenerator metaData = getPartitionMetaDataGenerator(mapService);
int partitionId = container.getPartitionId();
partitionUuid = metaData.getUuidOrNull(partitionId);
ConcurrentMap<String, RecordStore> maps = container.getMaps();
for (Map.Entry<String, RecordStore> entry : maps.entrySet()) {
if (mapNameSequencePairs == emptyList()) {
mapNameSequencePairs = new ArrayList(container.getMaps().size());
}
String mapName = entry.getKey();
mapNameSequencePairs.add(mapName);
mapNameSequencePairs.add(metaData.currentSequence(mapName, partitionId));
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapReplicationStateHolder method applyState.
void applyState() {
if (data != null) {
for (Map.Entry<String, Set<RecordReplicationInfo>> dataEntry : data.entrySet()) {
Set<RecordReplicationInfo> recordReplicationInfos = dataEntry.getValue();
final String mapName = dataEntry.getKey();
RecordStore recordStore = mapReplicationOperation.getRecordStore(mapName);
recordStore.reset();
recordStore.setPreMigrationLoadedStatus(loaded.get(mapName));
for (RecordReplicationInfo recordReplicationInfo : recordReplicationInfos) {
Data key = recordReplicationInfo.getKey();
final Data value = recordReplicationInfo.getValue();
Record newRecord = recordStore.createRecord(value, -1L, Clock.currentTimeMillis());
applyRecordInfo(newRecord, recordReplicationInfo);
recordStore.putRecord(key, newRecord);
}
}
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapReplicationStateHolder method prepare.
void prepare(PartitionContainer container, int replicaIndex) {
data = new HashMap<String, Set<RecordReplicationInfo>>(container.getMaps().size());
loaded = new HashMap<String, Boolean>(container.getMaps().size());
for (Map.Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
RecordStore recordStore = entry.getValue();
MapContainer mapContainer = recordStore.getMapContainer();
MapConfig mapConfig = mapContainer.getMapConfig();
if (mapConfig.getTotalBackupCount() < replicaIndex) {
continue;
}
MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
String mapName = entry.getKey();
loaded.put(mapName, recordStore.isLoaded());
// now prepare data to migrate records
Set<RecordReplicationInfo> recordSet = new HashSet<RecordReplicationInfo>(recordStore.size());
final Iterator<Record> iterator = recordStore.iterator();
while (iterator.hasNext()) {
Record record = iterator.next();
Data key = record.getKey();
RecordReplicationInfo recordReplicationInfo = mapReplicationOperation.createRecordReplicationInfo(key, record, mapServiceContext);
recordSet.add(recordReplicationInfo);
}
data.put(mapName, recordSet);
}
}
Aggregations