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 MergePolicySerializationTest method testIssue2665.
@Test
public void testIssue2665() {
String name = randomString();
String serviceName = "hz:impl:mapService";
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, MyObject> map = instance.getMap(name);
MyObject myObjectExisting = new MyObject();
map.put("key", myObjectExisting);
NodeEngineImpl nodeEngine = HazelcastTestSupport.getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
EntryView<String, MyObject> mergingEntryView = new SimpleEntryView<String, MyObject>("key", new MyObject());
recordStore.merge(dataKey, mergingEntryView, mergePolicy);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMigrationAwareService method commitMigration.
@Override
public void commitMigration(PartitionMigrationEvent event) {
if (event.getMigrationEndpoint() == DESTINATION) {
populateIndexes(event, TargetIndexes.GLOBAL, "commitMigration");
} else {
depopulateIndexes(event, "commitMigration");
}
if (SOURCE == event.getMigrationEndpoint()) {
// Do not change order of below methods
removeWbqCountersHavingLesserBackupCountThan(event.getPartitionId(), event.getNewReplicaIndex());
removeRecordStoresHavingLesserBackupCountThan(event.getPartitionId(), event.getNewReplicaIndex());
}
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.nullifyOwnedPartitions();
removeOrRegenerateNearCacheUuid(event);
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapService method onBeforeLock.
@Override
public void onBeforeLock(String distributedObjectName, Data key) {
int partitionId = mapServiceContext.getNodeEngine().getPartitionService().getPartitionId(key);
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, distributedObjectName);
// we have no use for the return value, invoked just for the side-effects
recordStore.beforeOperation();
try {
recordStore.getRecordOrNull(key);
} finally {
recordStore.afterOperation();
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapServiceContextImpl method removeWbqCountersFromMatchingPartitionsWith.
@Override
public void removeWbqCountersFromMatchingPartitionsWith(Predicate<RecordStore> predicate, int partitionId) {
PartitionContainer container = partitionContainers[partitionId];
if (container == null) {
return;
}
Iterator<RecordStore> partitionIterator = container.getMaps().values().iterator();
while (partitionIterator.hasNext()) {
RecordStore partition = partitionIterator.next();
if (predicate.test(partition)) {
partition.getMapDataStore().getTxnReservedCapacityCounter().releaseAllReservations();
}
}
}
Aggregations