Search in sources :

Example 16 with GridClientCacheRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.

the class TestBinaryClient method cacheGetAll.

/**
     * @param cacheName Cache name.
     * @param keys Keys.
     * @return Entries.
     * @throws IgniteCheckedException In case of error.
     */
public <K, V> Map<K, V> cacheGetAll(@NotNull String cacheName, K... keys) throws IgniteCheckedException {
    assert keys != null;
    GridClientCacheRequest req = new GridClientCacheRequest(GET_ALL);
    req.requestId(idCntr.getAndIncrement());
    req.cacheName(cacheName);
    req.keys((Iterable<Object>) Arrays.asList(keys));
    return makeRequest(req).getObject();
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 17 with GridClientCacheRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.

the class TestBinaryClient method cachePrepend.

/**
     * @param cacheName Cache name.
     * @param key Key.
     * @param val Value.
     * @return Whether entry was prepended.
     * @throws IgniteCheckedException In case of error.
     */
public <K, V> boolean cachePrepend(@NotNull String cacheName, K key, V val) throws IgniteCheckedException {
    assert key != null;
    assert val != null;
    GridClientCacheRequest add = new GridClientCacheRequest(PREPEND);
    add.requestId(idCntr.getAndIncrement());
    add.cacheName(cacheName);
    add.key(key);
    add.value(val);
    return makeRequest(add).<Boolean>getObject();
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 18 with GridClientCacheRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.

the class TestBinaryClient method cacheGet.

/**
     * @param cacheName Cache name.
     * @param key Key.
     * @return Value.
     * @throws IgniteCheckedException In case of error.
     */
public <K, V> V cacheGet(@NotNull String cacheName, K key) throws IgniteCheckedException {
    assert key != null;
    GridClientCacheRequest req = new GridClientCacheRequest(GET);
    req.requestId(idCntr.getAndIncrement());
    req.cacheName(cacheName);
    req.key(key);
    return makeRequest(req).getObject();
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 19 with GridClientCacheRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.

the class TestBinaryClient method cacheAppend.

/**
     * @param cacheName Cache name.
     * @param key Key.
     * @param val Value.
     * @return Whether entry was appended.
     * @throws IgniteCheckedException In case of error.
     */
public <K, V> boolean cacheAppend(@NotNull String cacheName, K key, V val) throws IgniteCheckedException {
    assert key != null;
    assert val != null;
    GridClientCacheRequest add = new GridClientCacheRequest(APPEND);
    add.requestId(idCntr.getAndIncrement());
    add.cacheName(cacheName);
    add.key(key);
    add.value(val);
    return makeRequest(add).<Boolean>getObject();
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 20 with GridClientCacheRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.

the class ClientMarshallerBenchmarkTest method testCacheRequestTime.

/**
     * @throws Exception If failed.
     */
public void testCacheRequestTime() throws Exception {
    GridClientCacheRequest req = new GridClientCacheRequest(CAS);
    req.clientId(UUID.randomUUID());
    req.cacheName("CacheName");
    req.requestId(1024);
    req.key("key");
    req.value(1L);
    req.value2(2L);
    Map<Object, Object> additional = new HashMap<>();
    for (int i = 0; i < 1000; i++) additional.put("key" + i, (long) i);
    req.values(additional);
    // Warm up.
    for (GridClientMarshaller marshaller : marshallers) {
        GridClientCacheRequest res = runMarshallUnmarshalLoop(req, 1, marshaller);
        assertEquals(req.operation(), res.operation());
        // requestId is not marshalled.
        assertEquals(0, res.requestId());
        // clientId is not marshalled.
        assertEquals(null, res.clientId());
        // destinationId is not marshalled.
        assertEquals(null, res.destinationId());
        assertEquals(req.cacheName(), res.cacheName());
        assertEquals(req.key(), res.key());
        assertEquals(req.value(), res.value());
        assertEquals(req.value2(), res.value2());
        for (Map.Entry<Object, Object> e : req.values().entrySet()) assertEquals(e.getValue(), res.values().get(e.getKey()));
    }
    // Now real test.
    for (GridClientMarshaller marshaller : marshallers) runMarshallUnmarshalLoop(req, 1000, marshaller);
}
Also used : GridClientMarshaller(org.apache.ignite.internal.client.marshaller.GridClientMarshaller) HashMap(java.util.HashMap) GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

GridClientCacheRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)24 ByteBuffer (java.nio.ByteBuffer)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GridClientOptimizedMarshaller (org.apache.ignite.internal.client.marshaller.optimized.GridClientOptimizedMarshaller)3 GridNioSession (org.apache.ignite.internal.util.nio.GridNioSession)3 GridClientMessage (org.apache.ignite.internal.processors.rest.client.message.GridClientMessage)2 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 GridClientMarshaller (org.apache.ignite.internal.client.marshaller.GridClientMarshaller)1 GridClientAuthenticationRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientAuthenticationRequest)1 GridClientStateRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest)1 GridClientTaskRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientTaskRequest)1 GridClientTopologyRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientTopologyRequest)1 GridRestCacheRequest (org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest)1 GridRestChangeStateRequest (org.apache.ignite.internal.processors.rest.request.GridRestChangeStateRequest)1 GridRestRequest (org.apache.ignite.internal.processors.rest.request.GridRestRequest)1 GridRestTaskRequest (org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest)1