use of com.hazelcast.internal.partition.FragmentedMigrationAwareService in project hazelcast by hazelcast.
the class AbstractPartitionOperation method createFragmentReplicationOperationsOffload.
/**
* Used for partition replica sync, supporting
* offloaded replication-operation preparation
*/
final Collection<Operation> createFragmentReplicationOperationsOffload(PartitionReplicationEvent event, ServiceNamespace ns) {
assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
Collection<Operation> operations = emptySet();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(FragmentedMigrationAwareService.class);
for (ServiceInfo serviceInfo : services) {
FragmentedMigrationAwareService service = serviceInfo.getService();
if (!service.isKnownServiceNamespace(ns)) {
continue;
}
operations = collectReplicationOperations(event, ns, isRunningOnPartitionThread(), operations, serviceInfo.getName(), service);
}
return operations;
}
use of com.hazelcast.internal.partition.FragmentedMigrationAwareService in project hazelcast by hazelcast.
the class AbstractPartitionOperation method createFragmentReplicationOperationsOffload.
/**
* Used for offloaded replication-operation
* preparation while executing a migration request
*/
final Collection<Operation> createFragmentReplicationOperationsOffload(PartitionReplicationEvent event, ServiceNamespace ns, Collection<String> serviceNames) {
assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
Collection<Operation> operations = emptySet();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
for (String serviceName : serviceNames) {
FragmentedMigrationAwareService service = nodeEngine.getService(serviceName);
assert service.isKnownServiceNamespace(ns) : ns + " should be known by " + service;
operations = collectReplicationOperations(event, ns, isRunningOnPartitionThread(), operations, serviceName, service);
}
return operations;
}
use of com.hazelcast.internal.partition.FragmentedMigrationAwareService in project hazelcast by hazelcast.
the class AbstractPartitionOperation method createFragmentReplicationOperations.
final Collection<Operation> createFragmentReplicationOperations(PartitionReplicationEvent event, ServiceNamespace ns) {
assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
assertRunningOnPartitionThread();
Collection<Operation> operations = emptySet();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(FragmentedMigrationAwareService.class);
for (ServiceInfo serviceInfo : services) {
FragmentedMigrationAwareService service = serviceInfo.getService();
if (!service.isKnownServiceNamespace(ns)) {
continue;
}
operations = prepareAndAppendReplicationOperation(event, ns, service, serviceInfo.getName(), operations);
}
return operations;
}
use of com.hazelcast.internal.partition.FragmentedMigrationAwareService 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);
}
use of com.hazelcast.internal.partition.FragmentedMigrationAwareService in project hazelcast by hazelcast.
the class OperationBackupHandler method checkServiceNamespaces.
private void checkServiceNamespaces(BackupAwareOperation backupAwareOp, Operation backupOp) {
Operation op = (Operation) backupAwareOp;
Object service;
try {
service = op.getService();
} catch (Exception ignored) {
// operation doesn't know its service name
return;
}
if (service instanceof FragmentedMigrationAwareService) {
assert backupAwareOp instanceof ServiceNamespaceAware : service + " is instance of FragmentedMigrationAwareService, " + backupAwareOp + " should implement ServiceNamespaceAware!";
assert backupOp instanceof ServiceNamespaceAware : service + " is instance of FragmentedMigrationAwareService, " + backupOp + " should implement ServiceNamespaceAware!";
} else {
assert !(backupAwareOp instanceof ServiceNamespaceAware) : service + " is NOT instance of FragmentedMigrationAwareService, " + backupAwareOp + " should NOT implement ServiceNamespaceAware!";
assert !(backupOp instanceof ServiceNamespaceAware) : service + " is NOT instance of FragmentedMigrationAwareService, " + backupOp + " should NOT implement ServiceNamespaceAware!";
}
}
Aggregations