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();
}
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;
}
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);
}
}
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);
}
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();
}
}
}
Aggregations