Search in sources :

Example 51 with RecordStore

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();
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore)

Example 52 with RecordStore

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);
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) IPartition(com.hazelcast.internal.partition.IPartition)

Example 53 with RecordStore

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);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 54 with RecordStore

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Data(com.hazelcast.internal.serialization.Data) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) SplitBrainMergePolicy(com.hazelcast.spi.merge.SplitBrainMergePolicy) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PutIfAbsentMergePolicy(com.hazelcast.spi.merge.PutIfAbsentMergePolicy) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) MapService(com.hazelcast.map.impl.MapService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 55 with RecordStore

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();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) SplitBrainMergePolicy(com.hazelcast.spi.merge.SplitBrainMergePolicy) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PassThroughMergePolicy(com.hazelcast.spi.merge.PassThroughMergePolicy) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) Data(com.hazelcast.internal.serialization.Data) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)66 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)21 MapService (com.hazelcast.map.impl.MapService)20 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)10 Data (com.hazelcast.internal.serialization.Data)9 MapContainer (com.hazelcast.map.impl.MapContainer)8 DefaultRecordStore (com.hazelcast.map.impl.recordstore.DefaultRecordStore)8 Indexes (com.hazelcast.query.impl.Indexes)8 Map (java.util.Map)8 NodeEngine (com.hazelcast.spi.impl.NodeEngine)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 MapConfig (com.hazelcast.config.MapConfig)6 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6 Record (com.hazelcast.map.impl.record.Record)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 ArrayList (java.util.ArrayList)6