You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by ALEKSEY KUZNETSOV <al...@gmail.com> on 2017/03/02 09:42:02 UTC

code refactoring suggestion

Hi all ! During pessimistic transaction we execute prepare phase at
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal#commitAsync
after executing prepareAsync();
We bind listener on prepare future.
Perhaps its better initially bind listener and then execute fut.prepare(); ?
-- 

*Best Regards,*

*Kuznetsov Aleksey*

Re: code refactoring suggestion

Posted by Andrey Gura <ag...@apache.org>.
Aleksey,

once again, listener will be called directly in
GridFutureAdapter.listen() method if future already completed.

1. execute prepareAsync()
2. prepare phase answer got
3. listener binded (actually not binded but called)

@Override public void listen(IgniteInClosure<? super
IgniteInternalFuture<R>> lsnr0) {
    assert lsnr0 != null;

    boolean done = isDone();

    if (!done) {
        synchronized (this) {
            done = isDone(); // Double check.

            if (!done) {
                if (lsnr == null)
                    lsnr = lsnr0;
                else if (lsnr instanceof ArrayListener)
                    ((ArrayListener)lsnr).add(lsnr0);
                else
                    lsnr = (IgniteInClosure)new
ArrayListener<IgniteInternalFuture>(lsnr, lsnr0);

                return;
            }
        }
    }

    assert done;

    notifyListener(lsnr0); // HERE: notify listener if future is completed.
}



On Thu, Mar 2, 2017 at 5:25 PM, voipp <al...@gmail.com> wrote:
> Hi all ! During pessimistic transaction we execute prepare phase at
> org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal#commitAsync
> after executing prepareAsync();
> We bind listener on prepare future.
> Perhaps its better initially bind listener and then execute fut.prepare(); ?
>
> No, what im talking about is at first place prepareAsync() is got executed,
> then listener got binded.
> Imagine the following flow :
> 1. execute prepareAsync();
> 2. prepare phase answer got
> 3. listener binded
> So, listener would not be called.
>
>
>
> --
> View this message in context: http://apache-ignite-developers.2346864.n4.nabble.com/code-refactoring-suggestion-tp15045p15073.html
> Sent from the Apache Ignite Developers mailing list archive at Nabble.com.

Re: code refactoring suggestion

Posted by voipp <al...@gmail.com>.
Hi all ! During pessimistic transaction we execute prepare phase at 
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal#commitAsync 
after executing prepareAsync(); 
We bind listener on prepare future. 
Perhaps its better initially bind listener and then execute fut.prepare(); ? 

No, what im talking about is at first place prepareAsync() is got executed,
then listener got binded.
Imagine the following flow :
1. execute prepareAsync();
2. prepare phase answer got
3. listener binded
So, listener would not be called.



--
View this message in context: http://apache-ignite-developers.2346864.n4.nabble.com/code-refactoring-suggestion-tp15045p15073.html
Sent from the Apache Ignite Developers mailing list archive at Nabble.com.

Re: code refactoring suggestion

Posted by Andrey Gura <ag...@apache.org>.
Aleksey,

if you talk about fut.listen() then it doesn't make sense. listen()
call checks whether future is already completed and if it completed
invokes passed listener from current thread.

On Thu, Mar 2, 2017 at 12:42 PM, ALEKSEY KUZNETSOV
<al...@gmail.com> wrote:
> Hi all ! During pessimistic transaction we execute prepare phase at
> org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal#commitAsync
> after executing prepareAsync();
> We bind listener on prepare future.
> Perhaps its better initially bind listener and then execute fut.prepare(); ?
> --
>
> *Best Regards,*
>
> *Kuznetsov Aleksey*