Search in sources :

Example 1 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class CacheReplicationOperation method prepare.

public final void prepare(CachePartitionSegment segment, Collection<ServiceNamespace> namespaces, int replicaIndex) {
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace ns = (ObjectNamespace) namespace;
        ICacheRecordStore recordStore = segment.getRecordStore(ns.getObjectName());
        if (recordStore == null) {
            continue;
        }
        CacheConfig cacheConfig = recordStore.getConfig();
        if (cacheConfig.getTotalBackupCount() >= replicaIndex) {
            storeRecordsToReplicate(recordStore);
        }
    }
    configs.addAll(segment.getCacheConfigs());
    nearCacheStateHolder.prepare(segment, namespaces);
    classesAlwaysAvailable = segment.getCacheService().getNodeEngine().getTenantControlService().getTenantControlFactory().isClassesAlwaysAvailable();
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) PreJoinCacheConfig(com.hazelcast.cache.impl.PreJoinCacheConfig) CacheConfig(com.hazelcast.config.CacheConfig)

Example 2 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class CacheNearCacheStateHolder method prepare.

void prepare(CachePartitionSegment segment, Collection<ServiceNamespace> namespaces) {
    ICacheService cacheService = segment.getCacheService();
    MetaDataGenerator metaData = getPartitionMetaDataGenerator(cacheService);
    int partitionId = segment.getPartitionId();
    partitionUuid = metaData.getOrCreateUuid(partitionId);
    List<Object> nameSeqPairs = new ArrayList<>(namespaces.size());
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace ns = (ObjectNamespace) namespace;
        String cacheName = ns.getObjectName();
        nameSeqPairs.add(cacheName);
        nameSeqPairs.add(metaData.currentSequence(cacheName, partitionId));
    }
    cacheNameSequencePairs = nameSeqPairs;
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ArrayList(java.util.ArrayList) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 3 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class MapReplicationStateHolder method prepare.

void prepare(PartitionContainer container, Collection<ServiceNamespace> namespaces, int replicaIndex) {
    storesByMapName = createHashMap(namespaces.size());
    loaded = createHashMap(namespaces.size());
    mapIndexInfos = new ArrayList<>(namespaces.size());
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace mapNamespace = (ObjectNamespace) namespace;
        String mapName = mapNamespace.getObjectName();
        RecordStore recordStore = container.getExistingRecordStore(mapName);
        if (recordStore == null) {
            continue;
        }
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex) {
            continue;
        }
        loaded.put(mapName, recordStore.isLoaded());
        storesByMapName.put(mapName, recordStore);
        statsByMapName.put(mapName, mapContainer.getMapServiceContext().getLocalMapStatsProvider().getLocalMapStatsImpl(mapName).getReplicationStats());
        Set<IndexConfig> indexConfigs = new HashSet<>();
        if (mapContainer.isGlobalIndexEnabled()) {
            // global-index
            final Indexes indexes = mapContainer.getIndexes();
            for (Index index : indexes.getIndexes()) {
                indexConfigs.add(index.getConfig());
            }
            indexConfigs.addAll(indexes.getIndexDefinitions());
        } else {
            // partitioned-index
            final Indexes indexes = mapContainer.getIndexes(container.getPartitionId());
            if (indexes != null && indexes.haveAtLeastOneIndexOrDefinition()) {
                for (Index index : indexes.getIndexes()) {
                    indexConfigs.add(index.getConfig());
                }
                indexConfigs.addAll(indexes.getIndexDefinitions());
            }
        }
        MapIndexInfo mapIndexInfo = new MapIndexInfo(mapName);
        mapIndexInfo.addIndexCofigs(indexConfigs);
        mapIndexInfos.add(mapIndexInfo);
    }
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) MapIndexInfo(com.hazelcast.query.impl.MapIndexInfo) InternalIndex(com.hazelcast.query.impl.InternalIndex) Index(com.hazelcast.query.impl.Index) Indexes(com.hazelcast.query.impl.Indexes) MapContainer(com.hazelcast.map.impl.MapContainer) IndexConfig(com.hazelcast.config.IndexConfig) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) HashSet(java.util.HashSet)

Example 4 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class MapNearCacheStateHolder method prepare.

void prepare(PartitionContainer container, Collection<ServiceNamespace> namespaces) {
    MapService mapService = container.getMapService();
    MetaDataGenerator metaData = getPartitionMetaDataGenerator(mapService);
    int partitionId = container.getPartitionId();
    partitionUuid = metaData.getOrCreateUuid(partitionId);
    List<Object> nameSeqPairs = new ArrayList<>(namespaces.size());
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace mapNamespace = (ObjectNamespace) namespace;
        String mapName = mapNamespace.getObjectName();
        nameSeqPairs.add(mapName);
        nameSeqPairs.add(metaData.currentSequence(mapName, partitionId));
    }
    mapNameSequencePairs = nameSeqPairs;
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ArrayList(java.util.ArrayList) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 5 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class RingbufferService method prepareReplicationOperation.

@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces) {
    int partitionId = event.getPartitionId();
    Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(partitionId);
    if (isNullOrEmpty(partitionContainers)) {
        return null;
    }
    Map<ObjectNamespace, RingbufferContainer> migrationData = new HashMap<>();
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace ns = (ObjectNamespace) namespace;
        RingbufferContainer container = partitionContainers.get(ns);
        if (container != null && container.getConfig().getTotalBackupCount() >= event.getReplicaIndex()) {
            migrationData.put(ns, container);
        }
    }
    if (migrationData.isEmpty()) {
        return null;
    }
    return new ReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) DistributedObjectNamespace(com.hazelcast.internal.services.DistributedObjectNamespace) ReplicationOperation(com.hazelcast.ringbuffer.impl.operations.ReplicationOperation)

Aggregations

ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)28 RingbufferContainer (com.hazelcast.ringbuffer.impl.RingbufferContainer)12 RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)10 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 DistributedObjectNamespace (com.hazelcast.internal.services.DistributedObjectNamespace)7 Test (org.junit.Test)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Config (com.hazelcast.config.Config)4 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)3 Map (java.util.Map)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ListenerConfig (com.hazelcast.config.ListenerConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)2 LockSupportService (com.hazelcast.internal.locksupport.LockSupportService)2 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)2