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();
}
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();
}
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();
}
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();
}
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);
}
Aggregations