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

Denis Magda commented on IGNITE-945:
------------------------------------

[~samaitra], 

1) {{EntryProcessor}} already returns you an entry for the requested key - 
{{MutableEntry<Object, Object> entry}}. You mustn't execute any cache related 
operations inside of your {{EntryProcessor}} implementation and should perform 
the following instead:
- get current entry's value using {{entry.getValue()}} call. If the value is 
null then return {{false}} right away.
- if the value is not null execute {{appendOrPrepend}} operation creating the 
new value and apply it to the entry using {{entry.setValue(newValue)}}.

2) there is no need to execute the check below because the value can be added 
in between and this is already check with {{EntryProcessor}}. Please remove the 
code.

{code}
        if (!cache.containsKey(key)) {
            if (prepend) {
                throw new IgniteCheckedException("Failing prepend operation 
(Invalid key is not allowed).");
            } else if (!prepend) {
                throw new IgniteCheckedException("Failing append operation 
(Invalid key is not allowed).");
            }
        } 
{code}

3) {{GridCacheCommandHandlerSelfTest}} is still executed only for 
{{TRANSACTIONAL}} cache. Do the following 
- add {{protected CacheAtomicityMode atomicityMode()}} method to 
{{GridCacheCommandHandlerSelfTest}} and return {{TRANSACTIONAL}} mode in the 
default implementation.
- introduce new test class {{GridAtomicCacheCommandHandlerSelfTest}} that will 
extend {{GridCacheCommandHandlerSelfTest}} overriding {{atomicityMode()}} 
method by returning {{ATOMIC}} mode instead.
- {{atomicityMode()}} method must be called in 
{{GridCacheCommandHandlerSelfTest.getConfiguration()}} right after the line 
with {{cacheCfg.setCacheMode(CacheMode.LOCAL)}}.


> HTTP REST prepend/append commands failed
> ----------------------------------------
>
>                 Key: IGNITE-945
>                 URL: https://issues.apache.org/jira/browse/IGNITE-945
>             Project: Ignite
>          Issue Type: Bug
>          Components: newbie
>    Affects Versions: sprint-5
>            Reporter: Sergey Kozlov
>            Assignee: Saikat Maitra
>              Labels: newbie
>             Fix For: 1.7
>
>
> Requests 
> http://localhost:8080/ignite?cacheName=partitioned_cache&key=1&cmd=prepend&val=p
> http://localhost:8080/ignite?cacheName=partitioned_cache&key=1&cmd=append&val=a
> returns same error:
> {noformat}
> {"error":"Failed to start transaction on non-transactional cache: 
> partitioned_cache","response":null,"sessionToken":"","successStatus":1}
> {noformat}
> Node output is following:
> {noformat}
> [14:01:32,555][SEVERE][ignite-#12%pub-null%][GridRestProcessor] Failed to 
> handle request: CACHE_PREPEND
> class org.apache.ignite.IgniteCheckedException: Failed to start transaction 
> on non-transactional cache: partitioned_cache
>       at 
> org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:6732)
>       at 
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:901)
>       at 
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:108)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>       at java.lang.Thread.run(Thread.java:745)
> Caused by: class org.apache.ignite.IgniteException: Failed to start 
> transaction on non-transactional cache: partitioned_cache
>       at 
> org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl.checkTransactional(IgniteTransactionsImpl.java:193)
>       at 
> org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl.txStartEx(IgniteTransactionsImpl.java:121)
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheAdapter.txStartEx(GridCacheAdapter.java:3239)
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.txStartEx(GridCacheProxyImpl.java:808)
>       at 
> org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$1.call(GridCacheCommandHandler.java:405)
>       at 
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6124)
>       at 
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:893)
>       ... 4 more
> {noformat}
> Is there a limitation for use non-transactional caches for prepend/append 
> commands?



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

Reply via email to