Search in sources :

Example 26 with PartitionContainer

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

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

the class MapDestroyTest 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(maps.isEmpty());
    }
}
Also used : JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MapService(com.hazelcast.map.impl.MapService) Category(org.junit.experimental.categories.Category) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) Collectors(java.util.stream.Collectors) Node(com.hazelcast.instance.impl.Node) ClusterProperty(com.hazelcast.spi.properties.ClusterProperty) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Map(java.util.Map) Accessors.getNode(com.hazelcast.test.Accessors.getNode) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) AssertTask(com.hazelcast.test.AssertTask) Before(org.junit.Before) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Map(java.util.Map) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 28 with PartitionContainer

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

the class Accessors method getAllIndexes.

/**
 * Obtains a list of {@link Indexes} for the given map local to the node
 * associated with it.
 * <p>
 * There may be more than one indexes instance associated with a map if its
 * indexes are partitioned.
 *
 * @param map the map to obtain the indexes for.
 * @return the obtained indexes list.
 */
public static List<Indexes> getAllIndexes(IMap map) {
    MapProxyImpl mapProxy = (MapProxyImpl) map;
    String mapName = mapProxy.getName();
    NodeEngine nodeEngine = mapProxy.getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Indexes maybeGlobalIndexes = mapContainer.getIndexes();
    if (maybeGlobalIndexes != null) {
        return Collections.singletonList(maybeGlobalIndexes);
    }
    PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
    List<Indexes> allIndexes = new ArrayList<>();
    for (PartitionContainer partitionContainer : partitionContainers) {
        IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
        if (!partition.isLocal()) {
            continue;
        }
        Indexes partitionIndexes = partitionContainer.getIndexes().get(mapName);
        if (partitionIndexes == null) {
            continue;
        }
        assert !partitionIndexes.isGlobal();
        allIndexes.add(partitionIndexes);
    }
    return allIndexes;
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ArrayList(java.util.ArrayList) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) IPartition(com.hazelcast.internal.partition.IPartition)

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