use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapClearExpiredRecordsTask method notHaveAnyExpirableRecord.
/**
* Here we check if that partition has any expirable record or not,
* if no expirable record exists in that partition no need to fire
* an expiration operation.
*
* @param partitionContainer corresponding partition container.
* @return <code>true</code> if no expirable record in that
* partition <code>false</code> otherwise.
*/
@Override
protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) {
boolean notExist = true;
final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps();
for (RecordStore store : maps.values()) {
if (store.isExpirable()) {
notExist = false;
break;
}
}
return notExist;
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapReplicationStateHolder method applyState.
@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:methodlength", "checkstyle:cyclomaticcomplexity", "checkstyle:nestedifdepth" })
void applyState() {
ThreadUtil.assertRunningOnPartitionThread();
applyIndexesState();
if (!isNullOrEmpty(data)) {
for (Map.Entry<String, List> dataEntry : data.entrySet()) {
String mapName = dataEntry.getKey();
List keyRecordExpiry = dataEntry.getValue();
RecordStore recordStore = operation.getRecordStore(mapName);
recordStore.beforeOperation();
try {
initializeRecordStore(mapName, recordStore);
recordStore.setPreMigrationLoadedStatus(loaded.get(mapName));
MapContainer mapContainer = recordStore.getMapContainer();
PartitionContainer partitionContainer = recordStore.getMapContainer().getMapServiceContext().getPartitionContainer(operation.getPartitionId());
for (Map.Entry<String, IndexConfig> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) {
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
indexes.addOrGetIndex(indexDefinition.getValue());
}
final Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
final boolean populateIndexes = indexesMustBePopulated(indexes, operation);
InternalIndex[] indexesSnapshot = null;
if (populateIndexes) {
// defensively clear possible stale leftovers in non-global indexes from
// the previous failed promotion attempt
indexesSnapshot = indexes.getIndexes();
Indexes.beginPartitionUpdate(indexesSnapshot);
indexes.clearAll();
}
long nowInMillis = Clock.currentTimeMillis();
forEachReplicatedRecord(keyRecordExpiry, mapContainer, recordStore, populateIndexes, nowInMillis);
if (populateIndexes) {
Indexes.markPartitionAsIndexed(partitionContainer.getPartitionId(), indexesSnapshot);
}
} finally {
recordStore.afterOperation();
}
}
}
for (Map.Entry<String, LocalRecordStoreStats> statsEntry : recordStoreStatsPerMapName.entrySet()) {
String mapName = statsEntry.getKey();
LocalRecordStoreStats stats = statsEntry.getValue();
RecordStore recordStore = operation.getRecordStore(mapName);
recordStore.setStats(stats);
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapReplicationStateHolder method entryCountOnThisNode.
// owned or backup
private long entryCountOnThisNode(MapContainer mapContainer) {
int replicaIndex = operation.getReplicaIndex();
long owned = 0;
if (mapContainer.getEvictor() != Evictor.NULL_EVICTOR && PER_NODE == mapContainer.getMapConfig().getEvictionConfig().getMaxSizePolicy()) {
MapService mapService = operation.getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
int partitionCount = partitionService.getPartitionCount();
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if (replicaIndex == 0 ? partitionService.isPartitionOwner(partitionId) : !partitionService.isPartitionOwner(partitionId)) {
RecordStore store = mapServiceContext.getExistingRecordStore(partitionId, mapContainer.getName());
if (store != null) {
owned += store.size();
}
}
}
}
return owned;
}
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 MapChunk method run.
@Override
public final void run() throws Exception {
RecordStore recordStore = getRecordStore(mapName);
if (firstChunk) {
addIndexes(recordStore, mapIndexInfo.getIndexConfigs());
initializeRecordStore(mapName, recordStore);
recordStore.setStats(stats);
recordStore.setPreMigrationLoadedStatus(loaded);
applyWriteBehindState(recordStore);
applyNearCacheState(recordStore);
applyIndexStateBefore(recordStore);
}
if (isNotEmpty(keyRecordExpiry)) {
putInto(recordStore);
logProgress(recordStore);
}
if (lastChunk) {
applyIndexStateAfter(recordStore);
}
}
Aggregations