use of com.hazelcast.internal.partition.PartitionReplicationEvent 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.partition.PartitionReplicationEvent in project hazelcast by hazelcast.
the class MigrationRequestOperation method createAllReplicaFragmentsMigrationState.
private ReplicaFragmentMigrationState createAllReplicaFragmentsMigrationState() {
PartitionReplicationEvent event = getPartitionReplicationEvent();
Collection<Operation> operations = createAllReplicationOperations(event);
return createReplicaFragmentMigrationState(namespacesContext.allNamespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.
the class MigrationRequestOperation method createReplicaFragmentMigrationStateFor.
private ReplicaFragmentMigrationState createReplicaFragmentMigrationStateFor(ServiceNamespace ns) {
PartitionReplicationEvent event = getPartitionReplicationEvent();
Collection<String> serviceNames = namespacesContext.getServiceNames(ns);
Collection<Operation> operations = createFragmentReplicationOperationsOffload(event, ns, serviceNames);
return createReplicaFragmentMigrationState(singleton(ns), operations, emptyList(), maxTotalChunkedDataInBytes);
}
use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.
the class PartitionReplicaSyncRequest method sendOperationsForNamespaces.
/**
* Send responses for first number of {@code permits} namespaces and remove them from the list.
*/
protected void sendOperationsForNamespaces(int permits) {
InternalPartitionServiceImpl partitionService = getService();
try {
PartitionReplicationEvent event = new PartitionReplicationEvent(getCallerAddress(), partitionId(), getReplicaIndex());
Iterator<ServiceNamespace> iterator = namespaces.iterator();
for (int i = 0; i < permits; i++) {
ServiceNamespace namespace = iterator.next();
Collection<Operation> operations = Collections.emptyList();
Collection<ChunkSupplier> chunkSuppliers = Collections.emptyList();
if (NonFragmentedServiceNamespace.INSTANCE.equals(namespace)) {
operations = createNonFragmentedReplicationOperations(event);
} else {
chunkSuppliers = isChunkedMigrationEnabled() ? collectChunkSuppliers(event, namespace) : chunkSuppliers;
if (isEmpty(chunkSuppliers)) {
operations = createFragmentReplicationOperations(event, namespace);
}
}
sendOperations(operations, chunkSuppliers, namespace);
while (hasRemainingChunksToSend(chunkSuppliers)) {
sendOperations(operations, chunkSuppliers, namespace);
}
iterator.remove();
}
} finally {
partitionService.getReplicaManager().releaseReplicaSyncPermits(permits);
}
}
use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.
the class AbstractPartitionPrimaryReplicaAntiEntropyTask method retainAndGetNamespaces.
// works only on primary. backups are retained
// in PartitionBackupReplicaAntiEntropyTask
final Collection<ServiceNamespace> retainAndGetNamespaces() {
PartitionReplicationEvent event = new PartitionReplicationEvent(null, partitionId, 0);
Collection<FragmentedMigrationAwareService> services = nodeEngine.getServices(FragmentedMigrationAwareService.class);
Collection<ServiceNamespace> namespaces = new HashSet<>();
for (FragmentedMigrationAwareService service : services) {
Collection<ServiceNamespace> serviceNamespaces = service.getAllServiceNamespaces(event);
if (serviceNamespaces != null) {
namespaces.addAll(serviceNamespaces);
}
}
namespaces.add(NonFragmentedServiceNamespace.INSTANCE);
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
replicaManager.retainNamespaces(partitionId, namespaces);
ILogger logger = nodeEngine.getLogger(getClass());
if (logger.isFinestEnabled()) {
logger.finest("Retained namespaces for partitionId=" + partitionId + ". Service namespaces=" + namespaces + ", retained namespaces=" + replicaManager.getNamespaces(partitionId));
}
return replicaManager.getNamespaces(partitionId);
}
Aggregations