use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapChunk method beforeRun.
@Override
public final void beforeRun() {
RecordStore recordStore = getRecordStore(mapName);
recordStore.beforeOperation();
}
use of com.hazelcast.map.impl.recordstore.RecordStore 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.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapIndexLifecycleTest method assertAllPartitionContainersAreInitialized.
private void assertAllPartitionContainersAreInitialized(HazelcastInstance instance) {
MapServiceContext context = getMapServiceContext(instance);
int partitionCount = getPartitionCount(instance);
final AtomicInteger authorRecordsCounter = new AtomicInteger();
final AtomicInteger yearRecordsCounter = new AtomicInteger();
String authorOwned = findAuthorOwnedBy(instance);
Integer yearOwned = findYearOwnedBy(instance);
for (int i = 0; i < partitionCount; i++) {
if (!getNode(instance).getPartitionService().isPartitionOwner(i)) {
continue;
}
PartitionContainer container = context.getPartitionContainer(i);
ConcurrentMap<String, RecordStore> maps = container.getMaps();
RecordStore recordStore = maps.get(mapName);
assertNotNull("record store is null: ", recordStore);
if (!globalIndex()) {
// also assert contents of partition indexes when NATIVE memory format
ConcurrentMap<String, Indexes> indexes = container.getIndexes();
final Indexes index = indexes.get(mapName);
assertNotNull("indexes is null", indexes);
assertEquals(2, index.getIndexes().length);
assertNotNull("There should be a partition index for attribute 'author'", index.getIndex("author"));
assertNotNull("There should be a partition index for attribute 'year'", index.getIndex("year"));
authorRecordsCounter.getAndAdd(numberOfPartitionQueryResults(instance, i, "author", authorOwned));
yearRecordsCounter.getAndAdd(numberOfPartitionQueryResults(instance, i, "year", yearOwned));
}
}
if (!globalIndex()) {
assertTrue("Author index should contain records", authorRecordsCounter.get() > 0);
assertTrue("Year index should contain records", yearRecordsCounter.get() > 0);
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMergePolicySerializationTest 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 = getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
MyObject myObject = new MyObject();
Data dataKey = mapServiceContext.toData("key");
Data dataValue = mapServiceContext.toData(myObject);
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
SplitBrainMergePolicy mergePolicy = mergePolicyProvider.getMergePolicy(PutIfAbsentMergePolicy.class.getName());
EntryView<Data, Data> mergingEntryView = new SimpleEntryView<>(dataKey, dataValue);
recordStore.merge(createMergingEntry(nodeEngine.getSerializationService(), mergingEntryView), mergePolicy, CallerProvenance.NOT_WAN);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMergePolicyQuickTest method testPassThroughMapMergePolicy.
@Test
public void testPassThroughMapMergePolicy() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
String name = randomString();
IMap<String, String> map = instance.getMap(name);
MapServiceContext mapServiceContext = getMapServiceContext(instance);
Data dataKey = mapServiceContext.toData("key");
Data dataValue = mapServiceContext.toData("value1");
Data dataValue2 = mapServiceContext.toData("value2");
RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
recordStore.beforeOperation();
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
SplitBrainMergePolicy mergePolicy = mergePolicyProvider.getMergePolicy(PassThroughMergePolicy.class.getName());
SimpleEntryView<Data, Data> initialEntry = new SimpleEntryView<>(dataKey, dataValue);
recordStore.merge(createMergingEntry(nodeEngine.getSerializationService(), initialEntry), mergePolicy, CallerProvenance.NOT_WAN);
SimpleEntryView<Data, Data> mergingEntry = new SimpleEntryView<>(dataKey, dataValue2);
recordStore.merge(createMergingEntry(nodeEngine.getSerializationService(), mergingEntry), mergePolicy, CallerProvenance.NOT_WAN);
assertEquals("value2", map.get("key"));
recordStore.afterOperation();
}
Aggregations