Search in sources :

Example 16 with OperationFactory

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

the class MapProxySupport method executeOnEntriesInternal.

/**
     * {@link IMap#executeOnEntries(EntryProcessor, Predicate)}
     */
public void executeOnEntriesInternal(EntryProcessor entryProcessor, Predicate predicate, List<Data> result) {
    try {
        OperationFactory operation = operationProvider.createPartitionWideEntryWithPredicateOperationFactory(name, entryProcessor, predicate);
        Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operation);
        for (Object object : results.values()) {
            if (object != null) {
                MapEntries mapEntries = (MapEntries) object;
                for (int i = 0; i < mapEntries.size(); i++) {
                    result.add(mapEntries.getKey(i));
                    result.add(mapEntries.getValue(i));
                }
            }
        }
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) OperationFactory(com.hazelcast.spi.OperationFactory) IsEmptyOperationFactory(com.hazelcast.map.impl.operation.IsEmptyOperationFactory) BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) IsPartitionLoadedOperationFactory(com.hazelcast.map.impl.operation.IsPartitionLoadedOperationFactory)

Example 17 with OperationFactory

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

the class MapProxySupport method containsValueInternal.

public boolean containsValueInternal(Data dataValue) {
    try {
        OperationFactory operationFactory = operationProvider.createContainsValueOperationFactory(name, dataValue);
        Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operationFactory);
        for (Object result : results.values()) {
            Boolean contains = toObject(result);
            if (contains) {
                return true;
            }
        }
        return false;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) OperationFactory(com.hazelcast.spi.OperationFactory) IsEmptyOperationFactory(com.hazelcast.map.impl.operation.IsEmptyOperationFactory) BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) IsPartitionLoadedOperationFactory(com.hazelcast.map.impl.operation.IsPartitionLoadedOperationFactory)

Example 18 with OperationFactory

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

the class AbstractInternalCacheProxy method clearInternal.

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 : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheException(javax.cache.CacheException) OperationService(com.hazelcast.spi.OperationService) OperationFactory(com.hazelcast.spi.OperationFactory)

Aggregations

OperationFactory (com.hazelcast.spi.OperationFactory)18 IsEmptyOperationFactory (com.hazelcast.map.impl.operation.IsEmptyOperationFactory)7 IsPartitionLoadedOperationFactory (com.hazelcast.map.impl.operation.IsPartitionLoadedOperationFactory)7 BinaryOperationFactory (com.hazelcast.spi.impl.BinaryOperationFactory)7 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)6 InitializingObject (com.hazelcast.spi.InitializingObject)6 MapEntries (com.hazelcast.map.impl.MapEntries)4 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)4 CacheException (javax.cache.CacheException)4 Data (com.hazelcast.nio.serialization.Data)3 Operation (com.hazelcast.spi.Operation)3 OperationService (com.hazelcast.spi.OperationService)3 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 OperationFactoryWrapper (com.hazelcast.client.impl.operations.OperationFactoryWrapper)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1