use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMigrationAwareService method commitMigration.
@Override
public void commitMigration(PartitionMigrationEvent event) {
migrateIndex(event);
if (SOURCE == event.getMigrationEndpoint()) {
clearMapsHavingLesserBackupCountThan(event.getPartitionId(), event.getNewReplicaIndex());
getMetaDataGenerator().removeUuidAndSequence(event.getPartitionId());
} else if (DESTINATION == event.getMigrationEndpoint()) {
if (event.getNewReplicaIndex() != 0) {
getMetaDataGenerator().regenerateUuid(event.getPartitionId());
}
}
PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(event.getPartitionId());
for (RecordStore recordStore : partitionContainer.getAllRecordStores()) {
// in case the record store has been created without loading during migration trigger again
// if loading has been already started this call will do nothing
recordStore.startLoading();
}
mapServiceContext.reloadOwnedPartitions();
QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
PublisherContext publisherContext = queryCacheContext.getPublisherContext();
if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
int partitionId = event.getPartitionId();
flushAccumulator(publisherContext, partitionId);
removeAccumulator(publisherContext, partitionId);
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMigrationAwareService method migrateIndex.
private void migrateIndex(PartitionMigrationEvent event) {
final long now = getNow();
final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
for (RecordStore recordStore : container.getMaps().values()) {
final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
final Indexes indexes = mapContainer.getIndexes();
if (!indexes.hasIndex()) {
continue;
}
final Iterator<Record> iterator = recordStore.iterator(now, false);
while (iterator.hasNext()) {
Record record = iterator.next();
Data key = record.getKey();
if (event.getMigrationEndpoint() == SOURCE) {
assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event;
Object value = Records.getValueOrCachedValue(record, serializationService);
indexes.removeEntryIndex(key, value);
} else if (event.getNewReplicaIndex() == 0) {
Object value = Records.getValueOrCachedValue(record, serializationService);
if (value != null) {
QueryableEntry queryEntry = mapContainer.newQueryEntry(record.getKey(), value);
indexes.saveEntryIndex(queryEntry, null);
}
}
}
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class LocalMapStatsProvider method createAllLocalMapStats.
public Map<String, LocalMapStats> createAllLocalMapStats() {
Map statsPerMap = new HashMap();
PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
for (PartitionContainer partitionContainer : partitionContainers) {
IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
Collection<RecordStore> allRecordStores = partitionContainer.getAllRecordStores();
for (RecordStore recordStore : allRecordStores) {
if (!isStatsCalculationEnabledFor(recordStore)) {
continue;
}
if (partition.isLocal()) {
addPrimaryStatsOf(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
} else {
addReplicaStatsOf(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
}
}
}
// reuse same HashMap to return calculated LocalMapStats.
for (Object object : statsPerMap.entrySet()) {
Map.Entry entry = (Map.Entry) object;
String mapName = ((String) entry.getKey());
LocalMapStatsImpl existingStats = getLocalMapStatsImpl(mapName);
LocalMapOnDemandCalculatedStats onDemand = ((LocalMapOnDemandCalculatedStats) entry.getValue());
addNearCacheStats(mapName, existingStats, onDemand);
LocalMapStatsImpl updatedStats = onDemand.updateAndGet(existingStats);
entry.setValue(updatedStats);
}
addStatsOfNoDataIncludedMaps(statsPerMap);
return statsPerMap;
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class RecordStoreTest method getRecordStore.
private DefaultRecordStore getRecordStore(IMap<Object, Object> map, int key) {
MapServiceContext mapServiceContext = getMapServiceContext((MapProxyImpl) map);
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
int partitionId = partitionService.getPartitionId(key);
PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId);
RecordStore recordStore = container.getRecordStore(map.getName());
return (DefaultRecordStore) recordStore;
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class PartitionContainer method createRecordStore.
private RecordStore createRecordStore(String name) {
MapServiceContext serviceContext = mapService.getMapServiceContext();
MapContainer mapContainer = serviceContext.getMapContainer(name);
MapConfig mapConfig = mapContainer.getMapConfig();
NodeEngine nodeEngine = serviceContext.getNodeEngine();
IPartitionService ps = nodeEngine.getPartitionService();
OperationService opService = nodeEngine.getOperationService();
ExecutionService execService = nodeEngine.getExecutionService();
HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData());
keyLoader.setMaxBatch(hazelcastProperties.getInteger(GroupProperty.MAP_LOAD_CHUNK_SIZE));
keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getMaxSizeConfig()));
keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
recordStore.init();
return recordStore;
}
Aggregations