Search in sources :

Example 1 with BinaryOperationFactory

use of com.hazelcast.spi.impl.BinaryOperationFactory in project hazelcast by hazelcast.

the class MapProxySupport method clearInternal.

public void clearInternal() {
    try {
        Operation clearOperation = operationProvider.createClearOperation(name);
        clearOperation.setServiceName(SERVICE_NAME);
        BinaryOperationFactory factory = new BinaryOperationFactory(clearOperation, getNodeEngine());
        Map<Integer, Object> resultMap = operationService.invokeOnAllPartitions(SERVICE_NAME, factory);
        int clearedCount = 0;
        for (Object object : resultMap.values()) {
            clearedCount += (Integer) object;
        }
        if (clearedCount > 0) {
            publishMapEvent(clearedCount, CLEAR_ALL);
        }
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) Operation(com.hazelcast.spi.Operation) IsKeyLoadFinishedOperation(com.hazelcast.map.impl.operation.IsKeyLoadFinishedOperation) AddIndexOperation(com.hazelcast.map.impl.operation.AddIndexOperation) AwaitMapFlushOperation(com.hazelcast.map.impl.operation.AwaitMapFlushOperation) AddInterceptorOperation(com.hazelcast.map.impl.operation.AddInterceptorOperation) RemoveInterceptorOperation(com.hazelcast.map.impl.operation.RemoveInterceptorOperation) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 2 with BinaryOperationFactory

use of com.hazelcast.spi.impl.BinaryOperationFactory in project hazelcast by hazelcast.

the class MapProxySupport method addIndex.

public void addIndex(String attribute, boolean ordered) {
    validateIndexAttribute(attribute);
    try {
        AddIndexOperation addIndexOperation = new AddIndexOperation(name, attribute, ordered);
        operationService.invokeOnAllPartitions(SERVICE_NAME, new BinaryOperationFactory(addIndexOperation, getNodeEngine()));
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : AddIndexOperation(com.hazelcast.map.impl.operation.AddIndexOperation) BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory)

Example 3 with BinaryOperationFactory

use of com.hazelcast.spi.impl.BinaryOperationFactory in project hazelcast by hazelcast.

the class MapProxySupport method evictAllInternal.

protected void evictAllInternal() {
    try {
        Operation operation = operationProvider.createEvictAllOperation(name);
        BinaryOperationFactory factory = new BinaryOperationFactory(operation, getNodeEngine());
        Map<Integer, Object> resultMap = operationService.invokeOnAllPartitions(SERVICE_NAME, factory);
        int evictedCount = 0;
        for (Object object : resultMap.values()) {
            evictedCount += (Integer) object;
        }
        if (evictedCount > 0) {
            publishMapEvent(evictedCount, EntryEventType.EVICT_ALL);
        }
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) Operation(com.hazelcast.spi.Operation) IsKeyLoadFinishedOperation(com.hazelcast.map.impl.operation.IsKeyLoadFinishedOperation) AddIndexOperation(com.hazelcast.map.impl.operation.AddIndexOperation) AwaitMapFlushOperation(com.hazelcast.map.impl.operation.AwaitMapFlushOperation) AddInterceptorOperation(com.hazelcast.map.impl.operation.AddInterceptorOperation) RemoveInterceptorOperation(com.hazelcast.map.impl.operation.RemoveInterceptorOperation) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 4 with BinaryOperationFactory

use of com.hazelcast.spi.impl.BinaryOperationFactory in project hazelcast by hazelcast.

the class MapProxySupport method flush.

// TODO: add a feature to mancenter to sync cache to db completely
public void flush() {
    try {
        MapOperation mapFlushOperation = operationProvider.createMapFlushOperation(name);
        BinaryOperationFactory operationFactory = new BinaryOperationFactory(mapFlushOperation, getNodeEngine());
        Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operationFactory);
        List<Future> futures = new ArrayList<Future>();
        for (Entry<Integer, Object> entry : results.entrySet()) {
            Integer partitionId = entry.getKey();
            Long count = ((Long) entry.getValue());
            if (count != 0) {
                Operation operation = new AwaitMapFlushOperation(name, count);
                futures.add(operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId));
            }
        }
        for (Future future : futures) {
            future.get();
        }
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : ArrayList(java.util.ArrayList) BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) Operation(com.hazelcast.spi.Operation) IsKeyLoadFinishedOperation(com.hazelcast.map.impl.operation.IsKeyLoadFinishedOperation) AddIndexOperation(com.hazelcast.map.impl.operation.AddIndexOperation) AwaitMapFlushOperation(com.hazelcast.map.impl.operation.AwaitMapFlushOperation) AddInterceptorOperation(com.hazelcast.map.impl.operation.AddInterceptorOperation) RemoveInterceptorOperation(com.hazelcast.map.impl.operation.RemoveInterceptorOperation) MapOperation(com.hazelcast.map.impl.operation.MapOperation) MapOperation(com.hazelcast.map.impl.operation.MapOperation) MutableLong(com.hazelcast.util.MutableLong) Future(java.util.concurrent.Future) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) AwaitMapFlushOperation(com.hazelcast.map.impl.operation.AwaitMapFlushOperation)

Aggregations

AddIndexOperation (com.hazelcast.map.impl.operation.AddIndexOperation)4 BinaryOperationFactory (com.hazelcast.spi.impl.BinaryOperationFactory)4 AddInterceptorOperation (com.hazelcast.map.impl.operation.AddInterceptorOperation)3 AwaitMapFlushOperation (com.hazelcast.map.impl.operation.AwaitMapFlushOperation)3 IsKeyLoadFinishedOperation (com.hazelcast.map.impl.operation.IsKeyLoadFinishedOperation)3 MapOperation (com.hazelcast.map.impl.operation.MapOperation)3 RemoveInterceptorOperation (com.hazelcast.map.impl.operation.RemoveInterceptorOperation)3 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)3 InitializingObject (com.hazelcast.spi.InitializingObject)3 Operation (com.hazelcast.spi.Operation)3 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)1 MutableLong (com.hazelcast.util.MutableLong)1 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1