IDIEP-122
Author
Sponsor
Created

  

Status

COMPLETED


Motivation

Thin clients should be able to call invoke/invokeAll cache operations, which now available only for thick clients.

Description

Operations invoke [1] and invokeAll [2] are specified by JCache (JSR-107),  these operations Invoke an EntryProcessor against Cache.Entry's specified by the provided key/keys.

For thin client we can apply the same approach to pass EntryProcessor as we use for continuous query server-side filters (see IEP-50):

  • EntryProcessor should be serialized to BinaryObject
  • EntryProcessor's class  should be already deployed to the cluster (Deployment of entry processors code to the cluster is out of scope of this IEP)

Protocol changes

Operation codes

Two new client cache operations are required:

Name

Code

OP_CACHE_INVOKE1024
OP_CACHE_INVOKE_ALL1025

OP_CACHE_INVOKE message format

Request
intCache Id
byteFlags: standard cache flags, see ClientCacheRequest. Only KEEP_BINARY is applicable. When KEEP_BINARY is set, the entry processor should receive key/val in binary form.
BinaryObjectEntry processor
byteEntry processor platform (see ClientPlatform class, 1 = Java)
intEntry processor argument count
(Object) * countEntry processor arguments


Response
ObjectResult, returned by entry processor

In case of such response we need some new error code to distinguish entry processor exceptions and and general client/server exceptions.

Alternatively, we can slightly extend response format (also for similarity with OP_CACHE_INVOKE_ALL response):

Response
booleanSuccess flag
ObjectResult, returned by entry processor, or error message in case of failure

In this case introduction of the new error code is not required, entry processor exceptions will be indicated by success flag = false, and general client/server exceptions will be handled by response header flag and error code.   

OP_CACHE_INVOKE_ALL message format

Request
intCache Id
byteFlags: standard cache flags, see ClientCacheRequest. Only KEEP_BINARY is applicable. When KEEP_BINARY is set, the entry processor should receive key/val in binary form.
intKeys count
(Object) * countKeys
BinaryObjectEntry processor
byteEntry processor platform (see ClientPlatform class, 1 = Java)
intEntry processor argument count
(Object) * countEntry processor arguments


Response
intCount of entry processor results
(EntryProcessorResult) * count
ObjectKey
booleanSuccess flag
ObjectResult, returned by entry processor, or error message in case of failure

Client-side API (java thin client)

The new methods should be added to ClientCache interface:

ClientCache
public interface ClientCache<K, V> {
	// ...

    public <T> T invoke(
        K key,
        EntryProcessor<K, V, T> entryProc,
        Object... arguments
    ) throws EntryProcessorException, ClientException;
    
    public <T> IgniteClientFuture<T> invokeAsync(
        K key,
        EntryProcessor<K, V, T> entryProc,
        Object... arguments
    ) throws ClientException;

    public <T> Map<K, EntryProcessorResult<T>> invokeAll(
        Set<? extends K> keys,
        EntryProcessor<K, V, T> entryProc,
        Object... args
    ) throws ClientException;

    public <T> IgniteClientFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
        Set<? extends K> keys,
        EntryProcessor<K, V, T> entryProc,
        Object... args
    ) throws ClientException;

	// ...
}


Risks and Assumptions

// Describe project risks, such as API or binary compatibility issues, major protocol changes, etc.

Discussion Links

https://lists.apache.org/thread/qrxmzcg5tvgot1tl2ko5x4qk08t51slf

Reference Links

[1] JCache invoke javadoc

[2] JCache invokeAll javadoc

Tickets

Key Summary T Created Updated Due Assignee Reporter Priority Priority Priority Priority P Status Resolution
Loading...
Refresh

  • No labels