Search in sources :

Example 26 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapProxySupport method evictInternal.

/**
 * Evicts a key from a map.
 *
 * @param key the key to evict
 * @return {@code true} if eviction was successful, {@code false} otherwise
 */
protected boolean evictInternal(Object key) {
    Data keyData = toDataWithStrategy(key);
    MapOperation operation = operationProvider.createEvictOperation(name, keyData, false);
    return (Boolean) invokeOperation(keyData, operation);
}
Also used : Data(com.hazelcast.internal.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 27 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapProxySupport method setAsyncInternal.

protected InternalCompletableFuture<Data> setAsyncInternal(Object key, Data valueData, long ttl, TimeUnit timeunit, long maxIdle, TimeUnit maxIdleUnit) {
    Data keyData = toDataWithStrategy(key);
    int partitionId = partitionService.getPartitionId(keyData);
    MapOperation operation = newSetOperation(keyData, valueData, ttl, timeunit, maxIdle, maxIdleUnit);
    operation.setThreadId(getThreadId());
    try {
        final InvocationFuture<Data> result;
        if (statisticsEnabled) {
            long startTimeNanos = Timer.nanos();
            result = operationService.invokeOnPartitionAsync(SERVICE_NAME, operation, partitionId);
            result.whenCompleteAsync(new IncrementStatsExecutionCallback<>(operation, startTimeNanos), CALLER_RUNS);
        } else {
            result = operationService.invokeOnPartitionAsync(SERVICE_NAME, operation, partitionId);
        }
        return result;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Data(com.hazelcast.internal.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 28 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapProxySupport method setInternal.

// WARNING: when UpdateEvent is fired it does *NOT* contain the oldValue
// see this: https://github.com/hazelcast/hazelcast/pull/6088#issuecomment-136025968
protected void setInternal(Object key, Data valueData, long ttl, TimeUnit timeunit, long maxIdle, TimeUnit maxIdleUnit) {
    Data keyData = toDataWithStrategy(key);
    MapOperation operation = newSetOperation(keyData, valueData, ttl, timeunit, maxIdle, maxIdleUnit);
    invokeOperation(keyData, operation);
}
Also used : Data(com.hazelcast.internal.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 29 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapProxySupport method containsKeyInternal.

protected boolean containsKeyInternal(Object key) {
    Data keyData = toDataWithStrategy(key);
    int partitionId = partitionService.getPartitionId(keyData);
    MapOperation containsKeyOperation = operationProvider.createContainsKeyOperation(name, keyData);
    containsKeyOperation.setThreadId(getThreadId());
    containsKeyOperation.setServiceName(SERVICE_NAME);
    try {
        Future future = operationService.invokeOnPartition(SERVICE_NAME, containsKeyOperation, partitionId);
        Object object = future.get();
        incrementOtherOperationsStat();
        return (Boolean) toObject(object);
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) CompletableFuture(java.util.concurrent.CompletableFuture) Data(com.hazelcast.internal.serialization.Data) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.impl.InitializingObject) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 30 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapProxySupport method setTtlInternal.

protected boolean setTtlInternal(Object key, long ttl, TimeUnit timeUnit) {
    long ttlInMillis = timeUnit.toMillis(ttl);
    Data keyData = serializationService.toData(key);
    MapOperation operation = operationProvider.createSetTtlOperation(name, keyData, ttlInMillis);
    return (Boolean) invokeOperation(keyData, operation);
}
Also used : Data(com.hazelcast.internal.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Aggregations

MapOperation (com.hazelcast.map.impl.operation.MapOperation)80 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)25 Data (com.hazelcast.internal.serialization.Data)23 Future (java.util.concurrent.Future)16 Data (com.hazelcast.nio.serialization.Data)6 ArrayList (java.util.ArrayList)5 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)4 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 MapService (com.hazelcast.map.impl.MapService)3 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)3 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)3 AbstractDistributedObject (com.hazelcast.spi.impl.AbstractDistributedObject)3 InitializingObject (com.hazelcast.spi.impl.InitializingObject)3 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)3 InvocationFuture (com.hazelcast.spi.impl.operationservice.impl.InvocationFuture)3 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)3 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 EntryView (com.hazelcast.core.EntryView)2 EntryProcessor (com.hazelcast.map.EntryProcessor)2