Search in sources :

Example 61 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class ReplicaSyncRequest method createReplicationOperations.

private List<Operation> createReplicationOperations() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
    PartitionReplicationEvent event = new PartitionReplicationEvent(getPartitionId(), getReplicaIndex());
    List<Operation> tasks = new LinkedList<Operation>();
    for (ServiceInfo serviceInfo : services) {
        MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
        Operation op = service.prepareReplicationOperation(event);
        if (op != null) {
            op.setServiceName(serviceInfo.getName());
            tasks.add(op);
        }
    }
    return tasks;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) MigrationAwareService(com.hazelcast.spi.MigrationAwareService) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) Operation(com.hazelcast.spi.Operation) PartitionReplicationEvent(com.hazelcast.spi.PartitionReplicationEvent) LinkedList(java.util.LinkedList)

Example 62 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class ReplicaSyncResponse method executeTasks.

private void executeTasks() {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    if (tasks != null && !tasks.isEmpty()) {
        logApplyReplicaSync(partitionId, replicaIndex);
        for (Operation op : tasks) {
            prepareOperation(op);
            try {
                op.beforeRun();
                op.run();
                op.afterRun();
            } catch (Throwable e) {
                onOperationFailure(op, e);
                logException(op, e);
            }
        }
    } else {
        logEmptyTaskList(partitionId, replicaIndex);
    }
}
Also used : UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) Operation(com.hazelcast.spi.Operation) BackupOperation(com.hazelcast.spi.BackupOperation)

Example 63 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class MigrationOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeLongArray(replicaVersions);
    int size = tasks != null ? tasks.size() : 0;
    out.writeInt(size);
    if (size > 0) {
        for (Operation task : tasks) {
            out.writeObject(task);
        }
    }
}
Also used : Operation(com.hazelcast.spi.Operation) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 64 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class MigrationOperation method doRun.

private void doRun() throws Exception {
    if (migrationInfo.startProcessing()) {
        try {
            executeBeforeMigrations();
            for (Operation op : tasks) {
                runMigrationOperation(op);
            }
            success = true;
        } catch (Throwable e) {
            success = false;
            failureReason = e;
            getLogger().severe("Error while executing replication operations " + migrationInfo, e);
        } finally {
            afterMigrate();
        }
    } else {
        success = false;
        logMigrationCancelled();
    }
}
Also used : Operation(com.hazelcast.spi.Operation)

Example 65 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class AbstractInternalCacheProxy method removeAsyncInternal.

<T> InternalCompletableFuture<T> removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean isGet, boolean withCompletionEvent) {
    ensureOpen();
    if (hasOldValue) {
        validateNotNull(key, oldValue);
        CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, oldValue);
    } else {
        validateNotNull(key);
        CacheProxyUtil.validateConfiguredTypes(cacheConfig, key);
    }
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(oldValue);
    Operation operation;
    if (isGet) {
        operation = operationProvider.createGetAndRemoveOperation(keyData, IGNORE_COMPLETION);
    } else {
        operation = operationProvider.createRemoveOperation(keyData, valueData, IGNORE_COMPLETION);
    }
    return invoke(operation, keyData, withCompletionEvent);
}
Also used : Data(com.hazelcast.nio.serialization.Data) MutableOperation(com.hazelcast.cache.impl.operation.MutableOperation) Operation(com.hazelcast.spi.Operation)

Aggregations

Operation (com.hazelcast.spi.Operation)94 OperationService (com.hazelcast.spi.OperationService)14 Member (com.hazelcast.core.Member)13 Address (com.hazelcast.nio.Address)11 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)8 ArrayList (java.util.ArrayList)8 ILogger (com.hazelcast.logging.ILogger)7 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)7 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 AcquireOperation (com.hazelcast.concurrent.semaphore.operations.AcquireOperation)6 AvailableOperation (com.hazelcast.concurrent.semaphore.operations.AvailableOperation)6 DrainOperation (com.hazelcast.concurrent.semaphore.operations.DrainOperation)6 InitOperation (com.hazelcast.concurrent.semaphore.operations.InitOperation)6 ReduceOperation (com.hazelcast.concurrent.semaphore.operations.ReduceOperation)6 ReleaseOperation (com.hazelcast.concurrent.semaphore.operations.ReleaseOperation)6 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)6 NodeEngine (com.hazelcast.spi.NodeEngine)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6