Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ABC9E200BE7 for ; Tue, 20 Dec 2016 15:17:28 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id AA56F160B29; Tue, 20 Dec 2016 14:17:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EF207160B1B for ; Tue, 20 Dec 2016 15:17:27 +0100 (CET) Received: (qmail 97797 invoked by uid 500); 20 Dec 2016 14:17:27 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 97785 invoked by uid 99); 20 Dec 2016 14:17:26 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2016 14:17:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 48A4DCA961 for ; Tue, 20 Dec 2016 14:17:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -2.518 X-Spam-Level: X-Spam-Status: No, score=-2.518 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FROM_LOCAL_DIGITS=0.001, FROM_LOCAL_HEX=0.331, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RP_MATCHES_RCVD=-2.999, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=163.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Qwbrs9R2AVcd for ; Tue, 20 Dec 2016 14:17:23 +0000 (UTC) Received: from mproxyhzb1.163.com (mproxyhzb1.163.com [123.58.178.201]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id E66A35FE3F for ; Tue, 20 Dec 2016 14:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Subject:From:Message-ID:Date:MIME-Version; bh=usjKy itpasSHDsLINyT4AsTPU+LIJHvWGiNMtVlAm4I=; b=Ddim6qfiJHMZrAAZHxTTz 2cCGXmHshAf7TfeXj+E+vjcVv7gcUA7CxHFttGvFOLERHhcbJth4mEpANTYU8kPH xnLDd1Gf6dfjjdbt+YZvss8qsTx68twDVKAu5oVK4bDJzpxv2ImFzydu3BM46Hoy QyO/grTdWSOAm3gdI/rhho= Received: from liyujuematoMacBook-Air.local (unknown [113.225.136.54]) by smtp5 (Coremail) with SMTP id D9GowADHJrMyOVlYIxMSKg--.65289S2; Tue, 20 Dec 2016 21:59:15 +0800 (CST) Subject: Re: Make async API great again To: dev@ignite.apache.org References: From: =?UTF-8?B?5p2O546J54+PQDE2Mw==?= <18624049226@163.com> Message-ID: <0326bca8-0290-154f-e52d-92d1981f8f63@163.com> Date: Tue, 20 Dec 2016 21:59:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: D9GowADHJrMyOVlYIxMSKg--.65289S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uw48XF4UAw45tryDAFWfAFb_yoW8urWfpF WkGanxt39rXFy3CrnIq3WIga1rtrWxArWUGwn8X3WxCrW7Wr1vyr1jkayruF18Cr10ya47 Zr40kw1rZa45AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jsUUUUUUUU= X-Originating-IP: [113.225.136.54] X-CM-SenderInfo: pvdktzbdstjqqrwthudrp/1tbiThZGjVUCv+db7QAAsq archived-at: Tue, 20 Dec 2016 14:17:28 -0000 +1 在 2016/12/20 18:05, Pavel Tupitsyn 写道: > Huge +1 on this. Current API is very confusing. > > On Tue, Dec 20, 2016 at 11:56 AM, Vladimir Ozerov > wrote: > >> Igniters, >> >> We have complaints about design of our async API, and upcoming Ignite 2.0 >> release is a good candidate to fix it. >> >> Problems: >> >> 1) API is verbose and error prone: >> >> Ignite asyncCache = cache.withAsync(); >> asyncCache.get(key); >> IgniteFuture fut = asyncCache.future(); >> >> 2) Hard to reason which methods support async execution and which are not. >> @IgniteAsyncSupported is not user friendly because it forces users to read >> JavaDocs thoroughly. >> >> 3) No control on where IgniteFuture.listen() and IgniteFuture.chain() >> methods are executed. User can easily inadvertently add some code which >> will lead to starvation. E.g.: >> >> IgniteFuture fut = asyncCache.future(); >> fut.listen((fut) -> { cache.put(...); }); // Starvation because callback >> might be executed in sys pool. >> >> 4) We have incorrect IO optimization: if message is to be send to local >> node, it will be executed synchronously. See GridIoManager.send() method. >> This is wrong, because it breaks pool semantics. E.g. cache operations must >> be executed in sys pool, but can be executed in public pool. >> >> I propose to fix all that problems in Apache Ignite 2.0: >> >> 1) Let's have simple and straightforward API: >> IgniteFuture fut = cache.getAsync(key); >> >> 2) Fix local node "optimization" in GridIoManager - messages should not be >> processed synchronously. >> >> 3) User continuations must never be executed synchronously, always delegate >> them to public pool by default (or may be to Java FJP?). >> >> 4) Allow users to specify thread pool for their continuations: >> IgniteFuture.listen(Closure, ExecutorService); >> IgniteFufure.chain(Closure, ExecutorService); >> >> See Akka "Dispatcher" [1] as example of similar concept. >> >> Thoughts? >> >> [1] http://doc.akka.io/docs/akka/current/scala/dispatchers.html >> >> Vladimir. >>