Search in sources :

Example 61 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class EntryProcessorTest method assertTtlFromLocalRecordStore.

private void assertTtlFromLocalRecordStore(HazelcastInstance instance, Data key, long expectedTtl) {
    @SuppressWarnings("unchecked") MapProxyImpl<Integer, Integer> map = (MapProxyImpl) instance.getMap(MAP_NAME);
    MapService mapService = map.getNodeEngine().getService(MapService.SERVICE_NAME);
    PartitionContainer[] partitionContainers = mapService.getMapServiceContext().getPartitionContainers();
    for (PartitionContainer partitionContainer : partitionContainers) {
        RecordStore rs = partitionContainer.getExistingRecordStore(MAP_NAME);
        if (rs != null) {
            Record record = rs.getRecordOrNull(key);
            if (record != null) {
                assertEquals(expectedTtl, rs.getExpirySystem().getExpiryMetadata(key).getTtl());
                return;
            }
        }
    }
    fail("Backup not found.");
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Record(com.hazelcast.map.impl.record.Record) MapService(com.hazelcast.map.impl.MapService)

Example 62 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class EvictionTest method testMaxIdle_backupEntryShouldNotBeReachableAfterMaxIdle.

@Test
public void testMaxIdle_backupEntryShouldNotBeReachableAfterMaxIdle() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance instanceA = factory.newHazelcastInstance(getConfig());
    final HazelcastInstance instanceB = factory.newHazelcastInstance(getConfig());
    final String keyOwnedByInstanceA = generateKeyOwnedBy(instanceA);
    instanceA.getMap("Test").put(keyOwnedByInstanceA, "value0", 0, SECONDS, 3, SECONDS);
    assertTrueEventually(() -> {
        RecordStore owner = getRecordStore(instanceA, keyOwnedByInstanceA);
        RecordStore backup = getRecordStore(instanceB, keyOwnedByInstanceA);
        assertEquals(0, owner.size());
        assertEquals(0, backup.size());
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 63 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class DynamicMapConfigTest method isRecordStoreExpirable.

private boolean isRecordStoreExpirable(IMap map) {
    MapProxyImpl mapProxy = (MapProxyImpl) map;
    MapService mapService = (MapService) mapProxy.getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    PartitionContainer container = mapServiceContext.getPartitionContainer(0);
    RecordStore recordStore = container.getExistingRecordStore(map.getName());
    return requireNonNull(recordStore).isExpirable();
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 64 with RecordStore

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

Example 65 with RecordStore

use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.

the class MapLoaderFuturesTest method loadingFutureCount.

private static int loadingFutureCount(String mapName, HazelcastInstance node) {
    int count = 0;
    NodeEngineImpl nodeEngine = getNode(node).getNodeEngine();
    MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
        RecordStore recordStore = mapServiceContext.getExistingRecordStore(i, mapName);
        if (recordStore != null) {
            count += ((DefaultRecordStore) recordStore).getLoadingFutures().size();
        }
    }
    return count;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore)

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