Search in sources :

Example 76 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxyImpl method containsValue.

@Override
public boolean containsValue(Object v) {
    checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
    Data value = toData(v);
    return containsValueInternal(value);
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 77 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxyImpl method put.

@Override
public V put(K k, V v, long ttl, TimeUnit timeunit) {
    checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
    checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
    Data key = toData(k, partitionStrategy);
    Data value = toData(v);
    Data result = putInternal(key, value, ttl, timeunit);
    return toObject(result);
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 78 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxySupport method removeAsyncInternal.

protected InternalCompletableFuture<Data> removeAsyncInternal(Data key) {
    int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
    MapOperation operation = operationProvider.createRemoveOperation(name, key, false);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        long startTime = System.currentTimeMillis();
        InternalCompletableFuture<Data> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
        if (statisticsEnabled) {
            future.andThen(new IncrementStatsExecutionCallback<Data>(operation, startTime));
        }
        return future;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 79 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxySupport method loadInternal.

/**
     * Maps keys to corresponding partitions and sends operations to them.
     */
protected void loadInternal(Iterable<Data> dataKeys, boolean replaceExistingValues) {
    Map<Integer, List<Data>> partitionIdToKeys = getPartitionIdToKeysMap(dataKeys);
    Iterable<Entry<Integer, List<Data>>> entries = partitionIdToKeys.entrySet();
    for (Entry<Integer, List<Data>> entry : entries) {
        Integer partitionId = entry.getKey();
        List<Data> correspondingKeys = entry.getValue();
        Operation operation = createLoadAllOperation(correspondingKeys, replaceExistingValues);
        operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
    }
    waitUntilLoaded();
}
Also used : Entry(java.util.Map.Entry) List(java.util.List) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) 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 80 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class MapProxySupport method executeOnKeyInternal.

public Data executeOnKeyInternal(Data key, EntryProcessor entryProcessor) {
    int partitionId = partitionService.getPartitionId(key);
    MapOperation operation = operationProvider.createEntryOperation(name, key, entryProcessor);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        Future future = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).invoke();
        return (Data) future.get();
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Aggregations

Data (com.hazelcast.nio.serialization.Data)773 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)140 Test (org.junit.Test)121 QuickTest (com.hazelcast.test.annotation.QuickTest)118 ParallelTest (com.hazelcast.test.annotation.ParallelTest)108 ArrayList (java.util.ArrayList)81 Map (java.util.Map)64 SerializationService (com.hazelcast.spi.serialization.SerializationService)54 HashMap (java.util.HashMap)54 NodeEngine (com.hazelcast.spi.NodeEngine)50 HashSet (java.util.HashSet)39 Address (com.hazelcast.nio.Address)28 AbstractMap (java.util.AbstractMap)28 Record (com.hazelcast.map.impl.record.Record)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 HeapData (com.hazelcast.internal.serialization.impl.HeapData)26 List (java.util.List)20 Future (java.util.concurrent.Future)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 Operation (com.hazelcast.spi.Operation)18