Search in sources :

Example 66 with Operation

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

the class AbstractInternalCacheProxy method replaceAsyncInternal.

<T> InternalCompletableFuture<T> replaceAsyncInternal(K key, V oldValue, V newValue, ExpiryPolicy expiryPolicy, boolean hasOldValue, boolean isGet, boolean withCompletionEvent) {
    ensureOpen();
    if (hasOldValue) {
        validateNotNull(key, oldValue, newValue);
        CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, oldValue, newValue);
    } else {
        validateNotNull(key, newValue);
        CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, newValue);
    }
    Data keyData = serializationService.toData(key);
    Data oldValueData = serializationService.toData(oldValue);
    Data newValueData = serializationService.toData(newValue);
    Operation operation;
    if (isGet) {
        operation = operationProvider.createGetAndReplaceOperation(keyData, newValueData, expiryPolicy, IGNORE_COMPLETION);
    } else {
        operation = operationProvider.createReplaceOperation(keyData, oldValueData, newValueData, expiryPolicy, 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)

Example 67 with Operation

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

the class AbstractInternalCacheProxy method putIfAbsentAsyncInternal.

InternalCompletableFuture<Boolean> putIfAbsentAsyncInternal(K key, V value, ExpiryPolicy expiryPolicy, boolean withCompletionEvent) {
    ensureOpen();
    validateNotNull(key, value);
    CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, value);
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(value);
    Operation operation = operationProvider.createPutIfAbsentOperation(keyData, valueData, expiryPolicy, 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)

Example 68 with Operation

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

the class AbstractInternalCacheProxy method putAsyncInternal.

<T> InternalCompletableFuture<T> putAsyncInternal(K key, V value, ExpiryPolicy expiryPolicy, boolean isGet, boolean withCompletionEvent) {
    ensureOpen();
    validateNotNull(key, value);
    CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, value);
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(value);
    Operation op = operationProvider.createPutOperation(keyData, valueData, expiryPolicy, isGet, IGNORE_COMPLETION);
    return invoke(op, keyData, withCompletionEvent);
}
Also used : Data(com.hazelcast.nio.serialization.Data) MutableOperation(com.hazelcast.cache.impl.operation.MutableOperation) Operation(com.hazelcast.spi.Operation)

Example 69 with Operation

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

the class ClusterWideIterator method fetch.

protected List fetch() {
    final OperationService operationService = cacheProxy.getNodeEngine().getOperationService();
    if (prefetchValues) {
        Operation operation = cacheProxy.operationProvider.createEntryIteratorOperation(lastTableIndex, fetchSize);
        final InternalCompletableFuture<CacheEntryIterationResult> f = operationService.invokeOnPartition(CacheService.SERVICE_NAME, operation, partitionIndex);
        CacheEntryIterationResult iteratorResult = f.join();
        if (iteratorResult != null) {
            setLastTableIndex(iteratorResult.getEntries(), iteratorResult.getTableIndex());
            return iteratorResult.getEntries();
        }
    } else {
        Operation operation = cacheProxy.operationProvider.createKeyIteratorOperation(lastTableIndex, fetchSize);
        final InternalCompletableFuture<CacheKeyIterationResult> f = operationService.invokeOnPartition(CacheService.SERVICE_NAME, operation, partitionIndex);
        CacheKeyIterationResult iteratorResult = f.join();
        if (iteratorResult != null) {
            setLastTableIndex(iteratorResult.getKeys(), iteratorResult.getTableIndex());
            return iteratorResult.getKeys();
        }
    }
    return null;
}
Also used : OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation)

Example 70 with Operation

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

the class CacheProxy method updateCacheListenerConfigOnOtherNodes.

private void updateCacheListenerConfigOnOtherNodes(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean isRegister) {
    OperationService operationService = getNodeEngine().getOperationService();
    Collection<Member> members = getNodeEngine().getClusterService().getMembers();
    for (Member member : members) {
        if (!member.localMember()) {
            Operation op = new CacheListenerRegistrationOperation(getDistributedObjectName(), cacheEntryListenerConfiguration, isRegister);
            operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, member.getAddress());
        }
    }
}
Also used : CacheListenerRegistrationOperation(com.hazelcast.cache.impl.operation.CacheListenerRegistrationOperation) OperationService(com.hazelcast.spi.OperationService) CacheListenerRegistrationOperation(com.hazelcast.cache.impl.operation.CacheListenerRegistrationOperation) Operation(com.hazelcast.spi.Operation) Member(com.hazelcast.core.Member)

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