use of com.hazelcast.spi.impl.operationservice.Operation 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.spi.impl.operationservice.Operation 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.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class AbstractPartitionOperation method prepareReplicationOperation.
private Operation prepareReplicationOperation(PartitionReplicationEvent event, ServiceNamespace ns, FragmentedMigrationAwareService service, String serviceName) {
Operation op = service.prepareReplicationOperation(event, singleton(ns));
if (op == null) {
return null;
}
op.setServiceName(serviceName);
return op;
}
use of com.hazelcast.spi.impl.operationservice.Operation 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.spi.impl.operationservice.Operation 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;
}
Aggregations