Search in sources :

Example 1 with ServiceNamespace

use of com.hazelcast.internal.services.ServiceNamespace 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 ServiceNamespace

use of com.hazelcast.internal.services.ServiceNamespace 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 ServiceNamespace

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

the class FinalizePromotionOperation method shiftUpReplicaVersions.

/**
 * Sets replica versions up to this replica to the version of the last lost replica and
 * sends a {@link IPartitionLostEvent}.
 */
private void shiftUpReplicaVersions() {
    int partitionId = getPartitionId();
    int currentReplicaIndex = migrationInfo.getDestinationCurrentReplicaIndex();
    int lostReplicaIndex = currentReplicaIndex - 1;
    try {
        InternalPartitionServiceImpl partitionService = getService();
        PartitionReplicaVersionManager partitionReplicaVersionManager = partitionService.getPartitionReplicaVersionManager();
        for (ServiceNamespace namespace : partitionReplicaVersionManager.getNamespaces(partitionId)) {
            // returns the internal array itself, not the copy
            long[] versions = partitionReplicaVersionManager.getPartitionReplicaVersions(partitionId, namespace);
            if (currentReplicaIndex > 1) {
                long[] versionsCopy = Arrays.copyOf(versions, versions.length);
                long version = versions[lostReplicaIndex];
                Arrays.fill(versions, 0, lostReplicaIndex, version);
                if (logger.isFinestEnabled()) {
                    logger.finest("Partition replica is lost! partitionId=" + partitionId + " namespace: " + namespace + " lost replicaIndex=" + lostReplicaIndex + " replica versions before shift up=" + Arrays.toString(versionsCopy) + " replica versions after shift up=" + Arrays.toString(versions));
                }
            } else if (logger.isFinestEnabled()) {
                logger.finest("PROMOTE partitionId=" + getPartitionId() + " namespace: " + namespace + " from currentReplicaIndex=" + currentReplicaIndex);
            }
        }
        PartitionEventManager partitionEventManager = partitionService.getPartitionEventManager();
        partitionEventManager.sendPartitionLostEvent(partitionId, lostReplicaIndex);
    } catch (Throwable e) {
        logger.warning("Promotion failed. partitionId=" + partitionId + " replicaIndex=" + currentReplicaIndex, e);
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) PartitionEventManager(com.hazelcast.internal.partition.impl.PartitionEventManager) PartitionReplicaVersionManager(com.hazelcast.internal.partition.PartitionReplicaVersionManager)

Example 4 with ServiceNamespace

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

the class MigrationRequestOperation method createNonFragmentedReplicaFragmentMigrationState.

private ReplicaFragmentMigrationState createNonFragmentedReplicaFragmentMigrationState() {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<Operation> operations = createNonFragmentedReplicationOperations(event);
    Collection<ServiceNamespace> namespaces = Collections.singleton(NonFragmentedServiceNamespace.INSTANCE);
    return createReplicaFragmentMigrationState(namespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
Also used : NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Example 5 with ServiceNamespace

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

the class PartitionPrimaryReplicaAntiEntropyTask method run.

@Override
public void run() {
    try {
        InternalPartition partition = partitionService.getPartition(partitionId, false);
        if (!partition.isLocal() || partition.isMigrating()) {
            return;
        }
        Collection<ServiceNamespace> namespaces = retainAndGetNamespaces();
        for (int index = 1; index < MAX_REPLICA_COUNT; index++) {
            PartitionReplica replica = partition.getReplica(index);
            if (replica != null) {
                invokePartitionBackupReplicaAntiEntropyOp(index, replica, namespaces, null);
            }
        }
    } finally {
        if (afterRun != null) {
            afterRun.run();
        }
    }
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Aggregations

ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)40 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)11 NonFragmentedServiceNamespace (com.hazelcast.internal.partition.NonFragmentedServiceNamespace)10 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)8 HashMap (java.util.HashMap)7 PartitionReplicaManager (com.hazelcast.internal.partition.impl.PartitionReplicaManager)6 ILogger (com.hazelcast.logging.ILogger)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 MigrationEndpoint (com.hazelcast.internal.partition.MigrationEndpoint)4 PartitionReplicaVersionManager (com.hazelcast.internal.partition.PartitionReplicaVersionManager)4 PartitionReplicationEvent (com.hazelcast.internal.partition.PartitionReplicationEvent)4 HashSet (java.util.HashSet)4 Address (com.hazelcast.cluster.Address)3 ChunkSupplier (com.hazelcast.internal.partition.ChunkSupplier)3 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 CachePartitionSegment (com.hazelcast.cache.impl.CachePartitionSegment)2 CacheService (com.hazelcast.cache.impl.CacheService)2 CacheConfig (com.hazelcast.config.CacheConfig)2