use of com.hazelcast.map.impl.PartitionContainer 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.PartitionContainer in project hazelcast by hazelcast.
the class MapOperation method getRecordStoreOrNull.
private RecordStore getRecordStoreOrNull() {
int partitionId = getPartitionId();
if (partitionId == -1) {
return null;
}
PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
if (createRecordStoreOnDemand) {
return partitionContainer.getRecordStore(name);
} else {
return partitionContainer.getExistingRecordStore(name);
}
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapChunk method applyIndexStateBefore.
private void applyIndexStateBefore(RecordStore recordStore) {
MapContainer mapContainer = recordStore.getMapContainer();
PartitionContainer partitionContainer = mapContainer.getMapServiceContext().getPartitionContainer(getPartitionId());
for (Map.Entry<String, IndexConfig> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) {
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
indexes.addOrGetIndex(indexDefinition.getValue());
}
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
boolean populateIndexes = indexesMustBePopulated(indexes);
if (populateIndexes) {
// defensively clear possible stale
// leftovers in non-global indexes from
// the previous failed promotion attempt
Indexes.beginPartitionUpdate(indexes.getIndexes());
indexes.clearAll();
}
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapProxySupport method readBackupDataOrNull.
private Data readBackupDataOrNull(Data key) {
int partitionId = partitionService.getPartitionId(key);
IPartition partition = partitionService.getPartition(partitionId, false);
if (!partition.isOwnerOrBackup(thisAddress)) {
return null;
}
PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
RecordStore recordStore = partitionContainer.getExistingRecordStore(name);
if (recordStore == null) {
return null;
}
return recordStore.readBackupData(key);
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MetadataResolver method resolveFromHeap.
@Nullable
@SuppressWarnings("rawtypes")
private Metadata resolveFromHeap(String name, MapServiceContext context) {
for (PartitionContainer partitionContainer : context.getPartitionContainers()) {
RecordStore<?> recordStore = partitionContainer.getExistingRecordStore(name);
if (recordStore == null) {
continue;
}
Iterator<Entry<Data, Record>> recordStoreIterator = recordStore.iterator();
if (!recordStoreIterator.hasNext()) {
continue;
}
Entry<Data, Record> entry = recordStoreIterator.next();
return resolveMetadata(entry.getKey(), entry.getValue().getValue());
}
return null;
}
Aggregations