use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.
the class GridClientNioTcpConnection method cacheMetrics.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public <K> GridClientFutureAdapter<GridClientDataMetrics> cacheMetrics(String cacheName, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException {
GridClientCacheRequest metrics = new GridClientCacheRequest(METRICS);
metrics.cacheName(cacheName);
metrics.destinationId(destNodeId);
TcpClientFuture fut = new TcpClientFuture() {
@Override
public void onDone(Object res) {
super.onDone(metricsMapToMetrics((Map<String, Number>) res));
}
};
return makeRequest(metrics, fut);
}
use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.
the class GridClientNioTcpConnection method cachePutAll.
/** {@inheritDoc} */
@Override
public <K, V> GridClientFutureAdapter<Boolean> cachePutAll(String cacheName, Map<K, V> entries, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException {
assert entries != null;
GridClientCacheRequest req = new GridClientCacheRequest(PUT_ALL);
req.cacheName(cacheName);
req.values((Map<Object, Object>) entries);
req.cacheFlagsOn(encodeCacheFlags(flags));
return makeRequest(req, destNodeId);
}
use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.
the class GridClientNioTcpConnection method cachePrepend.
/** {@inheritDoc} */
@Override
public <K, V> GridClientFutureAdapter<Boolean> cachePrepend(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException {
assert key != null;
assert val != null;
GridClientCacheRequest prepend = new GridClientCacheRequest(PREPEND);
prepend.cacheName(cacheName);
prepend.key(key);
prepend.value(val);
prepend.cacheFlagsOn(encodeCacheFlags(flags));
return makeRequest(prepend, destNodeId);
}
use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.
the class GridClientNioTcpConnection method cacheReplace.
/** {@inheritDoc} */
@Override
public <K, V> GridClientFutureAdapter<Boolean> cacheReplace(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException {
assert key != null;
assert val != null;
GridClientCacheRequest replace = new GridClientCacheRequest(REPLACE);
replace.cacheName(cacheName);
replace.key(key);
replace.value(val);
replace.cacheFlagsOn(encodeCacheFlags(flags));
return makeRequest(replace, destNodeId);
}
use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest in project ignite by apache.
the class TcpRestParserSelfTest method testCustomMessages.
/**
* @throws Exception If failed.
*/
public void testCustomMessages() throws Exception {
GridClientCacheRequest req = new GridClientCacheRequest(CAS);
req.key("key");
req.value(1);
req.value2(2);
req.clientId(UUID.randomUUID());
ByteBuffer raw = clientRequestPacket(req);
GridNioSession ses = new MockNioSession();
ses.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller());
GridTcpRestParser parser = new GridTcpRestParser(false);
GridClientMessage msg = parser.decode(ses, raw);
assertNotNull(msg);
assertEquals("Parser leaved unparsed bytes", 0, raw.remaining());
assertTrue(msg instanceof GridClientCacheRequest);
GridClientCacheRequest res = (GridClientCacheRequest) msg;
assertEquals("Invalid operation", req.operation(), res.operation());
assertEquals("Invalid clientId", req.clientId(), res.clientId());
assertEquals("Invalid key", req.key(), res.key());
assertEquals("Invalid value 1", req.value(), res.value());
assertEquals("Invalid value 2", req.value2(), res.value2());
}
Aggregations