Search in sources :

Example 91 with ClientMessage

use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.

the class ClientMapProxy method containsValue.

@Override
public boolean containsValue(Object value) {
    checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
    Data valueData = toData(value);
    ClientMessage request = MapContainsValueCodec.encodeRequest(name, valueData);
    ClientMessage response = invoke(request);
    MapContainsValueCodec.ResponseParameters resultParameters = MapContainsValueCodec.decodeResponse(response);
    return resultParameters.response;
}
Also used : MapContainsValueCodec(com.hazelcast.client.impl.protocol.codec.MapContainsValueCodec) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 92 with ClientMessage

use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.

the class ClientMapProxy method entrySet.

@Override
@SuppressWarnings("unchecked")
public Set<Entry<K, V>> entrySet(Predicate predicate) {
    if (predicate instanceof PagingPredicate) {
        return entrySetWithPagingPredicate((PagingPredicate) predicate);
    }
    ClientMessage request = MapEntriesWithPredicateCodec.encodeRequest(name, toData(predicate));
    ClientMessage response = invoke(request);
    MapEntriesWithPredicateCodec.ResponseParameters resultParameters = MapEntriesWithPredicateCodec.decodeResponse(response);
    InflatableSet.Builder<Entry<K, V>> setBuilder = InflatableSet.newBuilder(resultParameters.response.size());
    InternalSerializationService serializationService = ((InternalSerializationService) getContext().getSerializationService());
    for (Entry<Data, Data> row : resultParameters.response) {
        LazyMapEntry entry = new LazyMapEntry(row.getKey(), row.getValue(), serializationService);
        setBuilder.add(entry);
    }
    return setBuilder.build();
}
Also used : InflatableSet(com.hazelcast.util.collection.InflatableSet) PagingPredicate(com.hazelcast.query.PagingPredicate) LazyMapEntry(com.hazelcast.map.impl.LazyMapEntry) MapEntriesWithPredicateCodec(com.hazelcast.client.impl.protocol.codec.MapEntriesWithPredicateCodec) LazyMapEntry(com.hazelcast.map.impl.LazyMapEntry) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 93 with ClientMessage

use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.

the class ClientMapProxy method valuesForPagingPredicate.

private Collection<V> valuesForPagingPredicate(PagingPredicate pagingPredicate) {
    pagingPredicate.setIterationType(IterationType.VALUE);
    ClientMessage request = MapValuesWithPagingPredicateCodec.encodeRequest(name, toData(pagingPredicate));
    ClientMessage response = invoke(request);
    MapValuesWithPagingPredicateCodec.ResponseParameters resultParameters = MapValuesWithPagingPredicateCodec.decodeResponse(response);
    List<Entry> resultList = new ArrayList<Entry>(resultParameters.response.size());
    for (Entry<Data, Data> entry : resultParameters.response) {
        K key = toObject(entry.getKey());
        V value = toObject(entry.getValue());
        resultList.add(new AbstractMap.SimpleImmutableEntry<K, V>(key, value));
    }
    return (Collection) getSortedQueryResultSet(resultList, pagingPredicate, IterationType.VALUE);
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) AbstractMap(java.util.AbstractMap) LazyMapEntry(com.hazelcast.map.impl.LazyMapEntry) CollectionUtil.objectToDataCollection(com.hazelcast.util.CollectionUtil.objectToDataCollection) Collection(java.util.Collection) MapValuesWithPagingPredicateCodec(com.hazelcast.client.impl.protocol.codec.MapValuesWithPagingPredicateCodec)

Example 94 with ClientMessage

use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.

the class ClientMapProxy method putTransientInternal.

protected void putTransientInternal(long ttl, TimeUnit timeunit, Data keyData, Data valueData) {
    ClientMessage request = MapPutTransientCodec.encodeRequest(name, keyData, valueData, getThreadId(), getTimeInMillis(ttl, timeunit));
    invoke(request, keyData);
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 95 with ClientMessage

use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.

the class ClientMapProxy method values.

@Override
public Collection<V> values() {
    ClientMessage request = MapValuesCodec.encodeRequest(name);
    ClientMessage response = invoke(request);
    MapValuesCodec.ResponseParameters resultParameters = MapValuesCodec.decodeResponse(response);
    return new UnmodifiableLazyList<V>(resultParameters.response, getSerializationService());
}
Also used : MapValuesCodec(com.hazelcast.client.impl.protocol.codec.MapValuesCodec) UnmodifiableLazyList(com.hazelcast.spi.impl.UnmodifiableLazyList) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Aggregations

ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)377 Data (com.hazelcast.nio.serialization.Data)140 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)47 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)37 SafeBuffer (com.hazelcast.client.impl.protocol.util.SafeBuffer)29 Address (com.hazelcast.nio.Address)25 QuickTest (com.hazelcast.test.annotation.QuickTest)24 Test (org.junit.Test)24 ClientDelegatingFuture (com.hazelcast.client.util.ClientDelegatingFuture)21 DataInputStream (java.io.DataInputStream)20 InputStream (java.io.InputStream)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 ParallelTest (com.hazelcast.test.annotation.ParallelTest)19 Member (com.hazelcast.core.Member)18 SerializationService (com.hazelcast.spi.serialization.SerializationService)18 ExecutionException (java.util.concurrent.ExecutionException)18 UnmodifiableLazyList (com.hazelcast.spi.impl.UnmodifiableLazyList)16 ArrayList (java.util.ArrayList)16 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)13 CacheException (javax.cache.CacheException)13