Search in sources :

Example 11 with GridClientCacheRequest

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);
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 12 with GridClientCacheRequest

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);
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 13 with GridClientCacheRequest

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);
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 14 with GridClientCacheRequest

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);
}
Also used : GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)

Example 15 with GridClientCacheRequest

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());
}
Also used : GridNioSession(org.apache.ignite.internal.util.nio.GridNioSession) GridClientOptimizedMarshaller(org.apache.ignite.internal.client.marshaller.optimized.GridClientOptimizedMarshaller) GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest) ByteBuffer(java.nio.ByteBuffer) GridClientMessage(org.apache.ignite.internal.processors.rest.client.message.GridClientMessage)

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