[ 
https://issues.apache.org/jira/browse/IGNITE-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15124708#comment-15124708
 ] 

Oddo commented on IGNITE-1144:
------------------------------

Before I go on and submit pull requests etc. - would you comment on the path I 
am taking with this? As I said I am not a JAVA developer but I am trying to 
teach myself the language and contribute at the same time ;)

Here are my thoughts on implementing this for the queue 
(GridCacheQueueAdapter.java). I have also declared the following in 
IgniteQueue.java:

@IgniteAsyncSupported
public void affinityRun(IgniteRunnable job) throws IgniteException;

@IgniteAsyncSupported
public <R> R affinityCall(IgniteCallable<R> job) throws IgniteException;

Here is what is in GridCacheQueueAdapter.java

/** {@inheritDoc} */
public void affinityRun(IgniteRunnable job) {
if (!collocated)
throw new IgniteException("Illegal operation requested on non-collocated 
queue:affinityRun().");

try {
compute.affinityRun(cache.name(),queueKey,job);
}
catch (IgniteException e) {
throw e;
}
}

/** {@inheritDoc} */
public <R> R affinityCall(IgniteCallable<R> job) {
if (!collocated)
throw new IgniteException("Illegal operation requested on non-collocated 
queue:affinityCall().");

try {
return compute.affinityCall(cache.name(),queueKey,job);
}
catch (IgniteException e) {
throw e;
}
}

I have included the following at the top of the class GridCacheQueueAdapter:
private final IgniteCompute compute;

this.compute = cctx.kernalContext().grid().compute();

Let me know what you think!

> Need to have a capability to run a closure collocated with a queue/set
> ----------------------------------------------------------------------
>
>                 Key: IGNITE-1144
>                 URL: https://issues.apache.org/jira/browse/IGNITE-1144
>             Project: Ignite
>          Issue Type: Improvement
>          Components: cache
>    Affects Versions: 1.1.4
>            Reporter: Valentin Kulichenko
>            Assignee: Oddo
>            Priority: Critical
>
> Currently there is no way to do this since all collocated queues and sets are 
> stored in special system cache. This makes {{affinityRun()}} and 
> {{affinityCall()}} methods useless because it requires to explicitly provide 
> cache name which user doesn't know in this case.
> I suggest to add {{affinityRun()}} and {{affinityCall()}} methods on 
> {{IgniteQueue}} and {{IgniteSet}}. They will:
> * take only closure as a parameter
> * throw exception for non-collocated mode
> * properly delegate to sibling methods in {{Ignite}} with proper cache name
> Alternatively we can add these methods on {{Ignite}} interface, which is more 
> consistent with the current API. But I'm not sure how to call them.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to