Search in sources :

Example 86 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CacheProxySupport method updateCacheListenerConfigOnOtherNodes.

protected 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.impl.operationservice.OperationService) MutableOperation(com.hazelcast.cache.impl.operation.MutableOperation) CacheListenerRegistrationOperation(com.hazelcast.cache.impl.operation.CacheListenerRegistrationOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Example 87 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CacheProxySupport method invokeInternal.

protected <T> T invokeInternal(Data keyData, EntryProcessor<K, V, T> entryProcessor, Object... arguments) throws EntryProcessorException {
    Integer completionId = listenerCompleter.registerCompletionLatch(1);
    Operation op = operationProvider.createEntryProcessorOperation(keyData, completionId, entryProcessor, arguments);
    try {
        OperationService operationService = getNodeEngine().getOperationService();
        int partitionId = getPartitionId(keyData);
        InvocationFuture<T> future = operationService.invokeOnPartition(getServiceName(), op, partitionId);
        T safely = future.joinInternal();
        listenerCompleter.waitCompletionLatch(completionId);
        return safely;
    } catch (CacheException ce) {
        listenerCompleter.deregisterCompletionLatch(completionId);
        throw ce;
    } catch (Exception e) {
        listenerCompleter.deregisterCompletionLatch(completionId);
        throw new EntryProcessorException(e);
    }
}
Also used : EntryProcessorException(javax.cache.processor.EntryProcessorException) CacheException(javax.cache.CacheException) MutableOperation(com.hazelcast.cache.impl.operation.MutableOperation) CacheListenerRegistrationOperation(com.hazelcast.cache.impl.operation.CacheListenerRegistrationOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) EntryProcessorException(javax.cache.processor.EntryProcessorException) CacheException(javax.cache.CacheException)

Example 88 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CacheProxySupport method clearInternal.

protected void clearInternal() {
    try {
        OperationService operationService = getNodeEngine().getOperationService();
        OperationFactory operationFactory = operationProvider.createClearOperationFactory();
        Map<Integer, Object> results = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
        for (Object result : results.values()) {
            if (result != null && result instanceof CacheClearResponse) {
                Object response = ((CacheClearResponse) result).getResponse();
                if (response instanceof Throwable) {
                    throw (Throwable) response;
                }
            }
        }
    } catch (Throwable t) {
        throw rethrowAllowedTypeFirst(t, CacheException.class);
    }
}
Also used : CacheException(javax.cache.CacheException) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) OperationFactory(com.hazelcast.spi.impl.operationservice.OperationFactory)

Example 89 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class HazelcastServerCacheManager method enableStatisticManagementOnOtherNodes.

private void enableStatisticManagementOnOtherNodes(String cacheName, boolean statOrMan, boolean enabled) {
    String cacheNameWithPrefix = getCacheNameWithPrefix(cacheName);
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> futures = new ArrayList<Future>();
    for (Member member : nodeEngine.getClusterService().getMembers()) {
        if (!member.localMember()) {
            CacheManagementConfigOperation op = new CacheManagementConfigOperation(cacheNameWithPrefix, statOrMan, enabled);
            Future future = operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, member.getAddress());
            futures.add(future);
        }
    }
    waitWithDeadline(futures, CacheProxyUtil.AWAIT_COMPLETION_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
Also used : ArrayList(java.util.ArrayList) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) Future(java.util.concurrent.Future) CacheManagementConfigOperation(com.hazelcast.cache.impl.operation.CacheManagementConfigOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member)

Example 90 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CacheIterator method fetch.

protected List fetch() {
    final OperationService operationService = cacheProxy.getNodeEngine().getOperationService();
    if (prefetchValues) {
        Operation operation = cacheProxy.operationProvider.createFetchEntriesOperation(pointers, fetchSize);
        CacheEntriesWithCursor iteratorResult = invoke(operationService, operation);
        setIterationPointers(iteratorResult.getEntries(), iteratorResult.getPointers());
        return iteratorResult.getEntries();
    } else {
        Operation operation = cacheProxy.operationProvider.createFetchKeysOperation(pointers, fetchSize);
        CacheKeysWithCursor iteratorResult = invoke(operationService, operation);
        setIterationPointers(iteratorResult.getKeys(), iteratorResult.getPointers());
        return iteratorResult.getKeys();
    }
}
Also used : OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6