Search in sources :

Example 21 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer 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 22 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.

the class MapIndexLifecycleTest method assertAllPartitionContainersAreEmpty.

private void assertAllPartitionContainersAreEmpty(HazelcastInstance instance) {
    MapServiceContext context = getMapServiceContext(instance);
    int partitionCount = getPartitionCount(instance);
    for (int i = 0; i < partitionCount; i++) {
        PartitionContainer container = context.getPartitionContainer(i);
        Map<String, ?> maps = container.getMaps().entrySet().stream().filter(e -> !e.getKey().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        assertTrue("record stores not empty", maps.isEmpty());
        Map<String, Indexes> indexes = container.getIndexes().entrySet().stream().filter(e -> !e.getKey().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        assertTrue("indexes not empty", indexes.isEmpty());
    }
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Query(com.hazelcast.map.impl.query.Query) Indexes(com.hazelcast.query.impl.Indexes) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) Member(com.hazelcast.cluster.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) ConcurrentMap(java.util.concurrent.ConcurrentMap) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) IndexType(com.hazelcast.config.IndexType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Map(java.util.Map) Accessors.getNode(com.hazelcast.test.Accessors.getNode) ConfigAccessor(com.hazelcast.config.ConfigAccessor) JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) QueryResult(com.hazelcast.map.impl.query.QueryResult) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) MapContainer(com.hazelcast.map.impl.MapContainer) Assert.assertNotNull(org.junit.Assert.assertNotNull) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ServiceConfig(com.hazelcast.config.ServiceConfig) MapService(com.hazelcast.map.impl.MapService) Category(org.junit.experimental.categories.Category) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Collectors(java.util.stream.Collectors) Node(com.hazelcast.instance.impl.Node) IndexConfig(com.hazelcast.config.IndexConfig) ClusterProperty(com.hazelcast.spi.properties.ClusterProperty) Serializable(java.io.Serializable) PostJoinAwareService(com.hazelcast.internal.services.PostJoinAwareService) Predicates(com.hazelcast.query.Predicates) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) CoreService(com.hazelcast.internal.services.CoreService) IterationType(com.hazelcast.internal.util.IterationType) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Arrays.copyOfRange(java.util.Arrays.copyOfRange) Assert.assertEquals(org.junit.Assert.assertEquals) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Indexes(com.hazelcast.query.impl.Indexes) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 23 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer 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 24 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.

the class MapBackupAccessor method get.

@Override
public V get(K key) {
    IPartition partition = getPartitionForKey(key);
    HazelcastInstance hz = getHazelcastInstance(partition);
    Node node = getNode(hz);
    SerializationService serializationService = node.getSerializationService();
    MapService mapService = node.getNodeEngine().getService(MapService.SERVICE_NAME);
    MapServiceContext context = mapService.getMapServiceContext();
    int partitionId = partition.getPartitionId();
    PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
    return runOnPartitionThread(hz, new GetValueCallable(serializationService, partitionContainer, key), partitionId);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) SerializationService(com.hazelcast.internal.serialization.SerializationService) MapService(com.hazelcast.map.impl.MapService) IPartition(com.hazelcast.internal.partition.IPartition) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 25 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.

the class MapBackupAccessor method size.

@Override
public int size() {
    InternalPartitionService partitionService = getNode(cluster[0]).getPartitionService();
    IPartition[] partitions = partitionService.getPartitions();
    int count = 0;
    for (IPartition partition : partitions) {
        Address replicaAddress = partition.getReplicaAddress(replicaIndex);
        if (replicaAddress == null) {
            continue;
        }
        HazelcastInstance hz = getInstanceWithAddress(replicaAddress);
        NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
        MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
        MapServiceContext context = mapService.getMapServiceContext();
        int partitionId = partition.getPartitionId();
        PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
        count += runOnPartitionThread(hz, new SizeCallable(partitionContainer), partitionId);
    }
    return count;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MapService(com.hazelcast.map.impl.MapService) IPartition(com.hazelcast.internal.partition.IPartition) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Aggregations

PartitionContainer (com.hazelcast.map.impl.PartitionContainer)28 MapService (com.hazelcast.map.impl.MapService)15 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)13 MapContainer (com.hazelcast.map.impl.MapContainer)8 Map (java.util.Map)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 IPartition (com.hazelcast.internal.partition.IPartition)5 Indexes (com.hazelcast.query.impl.Indexes)5 Node (com.hazelcast.instance.impl.Node)4 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)4 Record (com.hazelcast.map.impl.record.Record)4 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)4 Accessors.getNode (com.hazelcast.test.Accessors.getNode)4 IndexConfig (com.hazelcast.config.IndexConfig)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Address (com.hazelcast.cluster.Address)2 Config (com.hazelcast.config.Config)2