Re: IgniteFuture adapters

2017-03-27 Thread Sergei Egorov
True, I just prefer functional style over static methods.

Regarding "why should this method be a part of the future API" - why not?
It helps to chain such calls instead of call nesting.

Of course, if Java had extension methods it wouldn't be needed, but we
don't have them.

On Mon, Mar 27, 2017 at 4:06 PM Alexey Goncharuk <alexey.goncha...@gmail.com>
wrote:

> Sergei,
>
> Why should this method be a part of the future API? The only implementation
> will do "return func(this);"
>
> I can achieve the same result the following way:
> rx(compute.runAsync(runnable)).timeout(5_000).subscribe();
>
>
>
> 2017-03-27 15:54 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
>
> > Take a look at my initial code.
> >
> > public  IgniteFuture chain(IgniteClosure > IgniteFuture, T> doneCb);
> >
> > vs
> >
> > public  R to(IgniteClosure, R> transformer);
> >
> >
> > The result of "chain" is IgniteFuture.
> >
> > The result of "to" is the object returned from transformer. It would
> > be CompletableFuture, Rx's Observable, Reactor's Mono, etc...
> >
> >
> > On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <somefire...@gmail.com>
> > wrote:
> >
> > > Em... When you get result of your future, closure will produce new
> future
> > > with completely different type.
> > >
> > > 2017-03-27 13:43 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
> > >
> > > > It doesn't :)
> > > >
> > > > It returns another IgniteFuture where I want to transform it to
> > > completely
> > > > different type.
> > > >
> > > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <somefire...@gmail.com
> >
> > > > wrote:
> > > >
> > > > > IgniteFuture have method
> > > > >
> > > > > public  IgniteFuture chain(IgniteClosure > IgniteFuture,
> > > > T>
> > > > > doneCb);
> > > > >
> > > > > which do this.
> > > > >
> > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
> > > > >
> > > > > > Hi!
> > > > > >
> > > > > > Would be nice if igniteFuture would provide a small but very
> usable
> > > > > method:
> > > > > >
> > > > > > public  R to(Function<IgniteFuture, R> transformer)
> > > > > >
> > > > > > it will allow to chain it like:
> > > > > >
> > > > > >
>  compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> > > > > >
> > > > > > Where rx() is just a static function with something like:
> > > > > >
> > > > > >public static  Function<IgniteFuture, Observable>
> rx()
> > > > > >
> > > > > >
> > > > > > WDYT?
> > > > > >
> > > > >
> > > > >
> > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
> > > > >
> > > > > > Hi!
> > > > > >
> > > > > > Would be nice if igniteFuture would provide a small but very
> usable
> > > > > method:
> > > > > >
> > > > > > public  R to(Function<IgniteFuture, R> transformer)
> > > > > >
> > > > > > it will allow to chain it like:
> > > > > >
> > > > > >
>  compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> > > > > >
> > > > > > Where rx() is just a static function with something like:
> > > > > >
> > > > > >public static  Function<IgniteFuture, Observable>
> rx()
> > > > > >
> > > > > >
> > > > > > WDYT?
> > > > > >
> > > > >
> > > >
> > >
> >
>


Re: IgniteFuture adapters

2017-03-27 Thread Sergei Egorov
Take a look at my initial code.

public  IgniteFuture chain(IgniteClosure, T> doneCb);

vs

public  R to(IgniteClosure, R> transformer);


The result of "chain" is IgniteFuture.

The result of "to" is the object returned from transformer. It would
be CompletableFuture, Rx's Observable, Reactor's Mono, etc...


On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <somefire...@gmail.com> wrote:

> Em... When you get result of your future, closure will produce new future
> with completely different type.
>
> 2017-03-27 13:43 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
>
> > It doesn't :)
> >
> > It returns another IgniteFuture where I want to transform it to
> completely
> > different type.
> >
> > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <somefire...@gmail.com>
> > wrote:
> >
> > > IgniteFuture have method
> > >
> > > public  IgniteFuture chain(IgniteClosure,
> > T>
> > > doneCb);
> > >
> > > which do this.
> > >
> > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
> > >
> > > > Hi!
> > > >
> > > > Would be nice if igniteFuture would provide a small but very usable
> > > method:
> > > >
> > > > public  R to(Function<IgniteFuture, R> transformer)
> > > >
> > > > it will allow to chain it like:
> > > >
> > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> > > >
> > > > Where rx() is just a static function with something like:
> > > >
> > > >public static  Function<IgniteFuture, Observable> rx()
> > > >
> > > >
> > > > WDYT?
> > > >
> > >
> > >
> > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
> > >
> > > > Hi!
> > > >
> > > > Would be nice if igniteFuture would provide a small but very usable
> > > method:
> > > >
> > > > public  R to(Function<IgniteFuture, R> transformer)
> > > >
> > > > it will allow to chain it like:
> > > >
> > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> > > >
> > > > Where rx() is just a static function with something like:
> > > >
> > > >public static  Function<IgniteFuture, Observable> rx()
> > > >
> > > >
> > > > WDYT?
> > > >
> > >
> >
>


Re: IgniteFuture adapters

2017-03-27 Thread Sergei Egorov
It doesn't :)

It returns another IgniteFuture where I want to transform it to completely
different type.

On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <somefire...@gmail.com> wrote:

> IgniteFuture have method
>
> public  IgniteFuture chain(IgniteClosure, T>
> doneCb);
>
> which do this.
>
> 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
>
> > Hi!
> >
> > Would be nice if igniteFuture would provide a small but very usable
> method:
> >
> > public  R to(Function<IgniteFuture, R> transformer)
> >
> > it will allow to chain it like:
> >
> > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> >
> > Where rx() is just a static function with something like:
> >
> >public static  Function<IgniteFuture, Observable> rx()
> >
> >
> > WDYT?
> >
>
>
> 2017-03-27 13:30 GMT+03:00 Sergei Egorov <bsid...@gmail.com>:
>
> > Hi!
> >
> > Would be nice if igniteFuture would provide a small but very usable
> method:
> >
> > public  R to(Function<IgniteFuture, R> transformer)
> >
> > it will allow to chain it like:
> >
> > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()
> >
> > Where rx() is just a static function with something like:
> >
> >public static  Function<IgniteFuture, Observable> rx()
> >
> >
> > WDYT?
> >
>


Re: Make async API great again

2017-03-27 Thread Sergei Egorov
Cool!

Please check my neighboring thread about special .to() method on
IgniteFuture to make it even better :)

On Mon, Mar 27, 2017 at 1:32 PM Vladimir Ozerov 
wrote:

> Igniters,
>
> I am glad to announce that old async-style is finally deprecated and now
> all asynchronous methods are defined explicitly! Woohoo! Thanks to Taras
> for this important contribution.
>
> On Mon, Jan 23, 2017 at 6:12 PM, Taras Ledkov 
> wrote:
>
> > Each compute method produces task. For 'run', 'call' etc. methods the
> > classes of tasks are internal.
> > There are tests checking the task session by ComputeTaskFuture for these
> > methods.
> > I think we have to leave real class of future is
> > ComputeTaskInternalFuture#ComputeFuture to compatibility.
> >
> > The class of the future at the public API may be changed.
> >
> >
> >
> > On 20.01.2017 17:54, Vladimir Ozerov wrote:
> >
> >> IgniteCompute was designed this way initially. See
> IgniteCompute.future()
> >> override. May be it makes sense to leave this type only for execute(...)
> >> methods.
> >>
> >> On Fri, Jan 20, 2017 at 5:45 PM, Semyon Boikov 
> >> wrote:
> >>
> >> Hi Taras,
> >>>
> >>> Why 'async' methods return ComputeTaskFuture, not just IgniteFuture? It
> >>> seems that ComputeTaskFuture is needed only for tasks?
> >>>
> >>>
> >>>
> >>>
> >>> On Fri, Jan 20, 2017 at 5:18 PM, Taras Ledkov 
> >>> wrote:
> >>>
> >>> Gents
> 
>  I've done changes of the IgniteCompute as a subtask of the whole async
> 
> >>> API
> >>>
>  refactoring (https://issues.apache.org/jira/browse/IGNITE-4580).
>  Please check the new version of the public API (
>  https://github.com/gridgain/apache-ignite/blob/b81621bf2e8a
>  35b20989f95ff52c0f6d91dd75d6/modules/core/src/main/java/
>  org/apache/ignite/IgniteCompute.java)
> 
>  Please look through the new API and let me know any comments.
> 
>  --
>  Taras Ledkov
>  Mail-To: tled...@gridgain.com
> 
> 
> 
> > --
> > Taras Ledkov
> > Mail-To: tled...@gridgain.com
> >
> >
>


IgniteFuture adapters

2017-03-27 Thread Sergei Egorov
Hi!

Would be nice if igniteFuture would provide a small but very usable method:

public  R to(Function transformer)

it will allow to chain it like:

compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe()

Where rx() is just a static function with something like:

   public static  Function rx()


WDYT?


Reactive APIs

2017-01-26 Thread Sergei Egorov
Hi all,

I'm going to implement Reactive bindings.

I see a task for RxJava: https://issues.apache.org/jira/browse/IGNITE-2331

Has anyone started it already?


BR,
Sergei