{"action":"created","comment":{"url":"https://api.github.com/repos/apache/ignite/pulls/comments/124478037","pull_request_review_id":46763123,"id":124478037,"diff_hunk":"@@ -0,0 +1,423 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.ignite.internal.processors.cache.distributed;\n+\n+import java.util.concurrent.Callable;\n+import org.apache.ignite.Ignite;\n+import org.apache.ignite.IgniteCache;\n+import org.apache.ignite.IgniteCheckedException;\n+import org.apache.ignite.IgniteTransactions;\n+import org.apache.ignite.cache.CacheAtomicityMode;\n+import org.apache.ignite.cache.CacheMode;\n+import org.apache.ignite.internal.IgniteInternalFuture;\n+import org.apache.ignite.internal.IgniteInterruptedCheckedException;\n+import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;\n+import org.apache.ignite.internal.util.lang.GridAbsPredicate;\n+import org.apache.ignite.lang.IgniteClosure;\n+import org.apache.ignite.testframework.GridTestUtils;\n+import org.apache.ignite.transactions.Transaction;\n+import org.apache.ignite.transactions.TransactionConcurrency;\n+import org.apache.ignite.transactions.TransactionIsolation;\n+import org.apache.ignite.transactions.TransactionState;\n+import org.junit.Assert;\n+\n+/**\n+ *\n+ */\n+public class TransactionsInMultipleThreadsTest extends AbstractTransactionsInMultipleThreadsTest {\n+    /**\n+     * @throws Exception  if failed.\n+     */\n+    public void testSimpleTransactionInAnotherThread() throws IgniteCheckedException {\n+        withAllIsolationsAndConcurrencies(new IgniteClosure<Object, Void>() {\n+            @Override public Void apply(Object o) {\n+                try {\n+                    simpleTransactionInAnotherThread();\n+                }\n+                catch (Exception ignore) {\n+                    assert false : \"Impossible situation\";\n+                }\n+\n+                return null;\n+            }\n+        });\n+    }\n+\n+    /**\n+     * @throws Exception if failed.\n+     */\n+    private void simpleTransactionInAnotherThread() throws Exception {\n+        final IgniteCache<String, Integer> cache = jcache(grid(0), cacheConfiguration(null).setName(\"testCache\"), String.class, Integer.class);\n+        final IgniteTransactions transactions = transactions();\n+\n+        assertNull(cache.get(\"key1\"));\n+\n+        final Transaction tx = transactions.txStart(transactionConcurrency, transactionIsolation);\n+\n+        cache.put(\"key1\", 1);\n+        cache.put(\"key2\", 2);\n+\n+        tx.suspend();\n+\n+        assertNull(cache.get(\"key1\"));\n+\n+        IgniteInternalFuture<Boolean> fut = GridTestUtils.runAsync(new Callable<Boolean>() {\n+            @Override public Boolean call() throws Exception {\n+                Assert.assertNull(transactions.tx());\n+                Assert.assertEquals(TransactionState.SUSPENDED, tx.state());\n+\n+                tx.resume();\n+\n+                Assert.assertEquals(TransactionState.ACTIVE, tx.state());\n+\n+                cache.put(\"key3\", 3);\n+                cache.remove(\"key2\");\n+\n+                tx.commit();\n+\n+                return true;\n+            }\n+        });\n+\n+        try {\n+            fut.get();\n+        }\n+        catch (IgniteCheckedException e) {\n+            e.printStackTrace();\n+            fail(\"Transaction in another thread failed\");\n+        }\n+\n+        Assert.assertEquals(TransactionState.COMMITTED, tx.state());\n+        Assert.assertEquals((long)1, (long)cache.get(\"key1\"));\n+        Assert.assertEquals((long)3, (long)cache.get(\"key3\"));\n+        Assert.assertFalse(cache.containsKey(\"key2\"));\n+\n+        cache.removeAll();\n+    }\n+\n+    /**\n+     * @throws IgniteCheckedException\n+     */\n+    public void testSimpleTransactionInAnotherThreadContinued() throws IgniteCheckedException {\n+        withAllIsolationsAndConcurrencies(new IgniteClosure<Object, Void>() {\n+            @Override public Void apply(Object o) {\n+                try {\n+                    simpleTransactionInAnotherThreadContinued();\n+                }\n+                catch (Exception ignore) {\n+                    assert false : \"Impossible situation\";\n+                }\n+\n+                return null;\n+            }\n+        });\n+    }\n+\n+    /**\n+     * @throws Exception if failed.\n+     */\n+    private void simpleTransactionInAnotherThreadContinued() throws Exception {\n+        final IgniteCache<String, Integer> cache = jcache(grid(0), cacheConfiguration(null).setName(\"testCache\"), String.class, Integer.class);\n+        final IgniteTransactions transactions = transactions();\n+\n+        final Transaction tx = transactions.txStart(transactionConcurrency, transactionIsolation);\n+\n+        cache.put(\"key1\", 1);\n+        cache.put(\"key2\", 2);\n+        cache.put(\"key1'\", 1);\n+\n+        tx.suspend();\n+\n+        IgniteInternalFuture<Boolean> fut = GridTestUtils.runAsync(new Callable<Boolean>() {\n+            @Override public Boolean call() throws Exception {\n+                Assert.assertNull(transactions.tx());\n+                Assert.assertEquals(TransactionState.SUSPENDED, tx.state());\n+\n+                tx.resume();\n+\n+                Assert.assertEquals(TransactionState.ACTIVE, tx.state());\n+\n+                cache.put(\"key3\", 3);\n+                cache.put(\"key2'\", 2);\n+                cache.remove(\"key2\", 2);\n+\n+                tx.suspend();\n+\n+                return true;\n+            }\n+        });\n+\n+        try {\n+            fut.get();\n+        }\n+        catch (IgniteCheckedException e) {\n+            e.printStackTrace();\n+            fail(\"Transaction in another thread failed\");\n+        }\n+\n+        Assert.assertNull(transactions.tx());\n+        Assert.assertEquals(TransactionState.SUSPENDED, tx.state());\n+\n+        tx.resume();\n+\n+        Assert.assertEquals(TransactionState.ACTIVE, tx.state());\n+\n+        cache.remove(\"key1'\", 1);\n+        cache.remove(\"key2'\", 2);\n+        cache.put(\"key3'\", 3);\n+\n+        tx.commit();\n+\n+        Assert.assertEquals(TransactionState.COMMITTED, tx.state());\n+        Assert.assertEquals((long)1, (long)cache.get(\"key1\"));\n+        Assert.assertEquals((long)3, (long)cache.get(\"key3\"));\n+        Assert.assertEquals((long)3, (long)cache.get(\"key3'\"));\n+        Assert.assertFalse(cache.containsKey(\"key2\"));\n+        Assert.assertFalse(cache.containsKey(\"key1'\"));\n+        Assert.assertFalse(cache.containsKey(\"key2'\"));\n+\n+        cache.removeAll();\n+    }\n+\n+    /**\n+     * @throws Exception If failed.\n+     */\n+    public void testCrossCacheTransactionInAnotherThread() throws Exception {\n+        withAllIsolationsAndConcurrencies(new IgniteClosure<Object, Void>() {\n+            @Override public Void apply(Object o) {\n+                try {\n+                    crossCacheTransactionInAnotherThread();\n+                }\n+                catch (Exception ignore) {","path":"modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/TransactionsInMultipleThreadsTest.java","position":204,"original_position":206,"commit_id":"76b385de8539abcd22ad218c92b9dda70527c3c6","original_commit_id":"e4536518ca0157655c3059796dff9f6136606902","user":{"login":"daradurvs","id":11329797,"avatar_url":"https://avatars0.githubusercontent.com/u/11329797?v=3","gravatar_id":"","url":"https://api.github.com/users/daradurvs","html_url":"https://github.com/daradurvs","followers_url":"https://api.github.com/users/daradurvs/followers","following_url":"https://api.github.com/users/daradurvs/following{/other_user}","gists_url":"https://api.github.com/users/daradurvs/gists{/gist_id}","starred_url":"https://api.github.com/users/daradurvs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daradurvs/subscriptions","organizations_url":"https://api.github.com/users/daradurvs/orgs","repos_url":"https://api.github.com/users/daradurvs/repos","events_url":"https://api.github.com/users/daradurvs/events{/privacy}","received_events_url":"https://api.github.com/users/daradurvs/received_events","type":"User","site_admin":false},"body":"Let's rename \"e\" to \"ignored\"\r\nPlease use fail()\r\nhttp://junit.sourceforge.net/junit3.8.1/javadoc/junit/framework/Assert.html#fail(java.lang.String)","created_at":"2017-06-28T08:14:08Z","updated_at":"2017-06-28T08:28:07Z","html_url":"https://github.com/apache/ignite/pull/2061#discussion_r124478037","pull_request_url":"https://api.github.com/repos/apache/ignite/pulls/2061","_links":{"self":{"href":"https://api.github.com/repos/apache/ignite/pulls/comments/124478037"},"html":{"href":"https://github.com/apache/ignite/pull/2061#discussion_r124478037"},"pull_request":{"href":"https://api.github.com/repos/apache/ignite/pulls/2061"}}},"pull_request":{"url":"https://api.github.com/repos/apache/ignite/pulls/2061","id":123520902,"html_url":"https://github.com/apache/ignite/pull/2061","diff_url":"https://github.com/apache/ignite/pull/2061.diff","patch_url":"https://github.com/apache/ignite/pull/2061.patch","issue_url":"https://api.github.com/repos/apache/ignite/issues/2061","number":2061,"state":"open","locked":false,"title":"IGNITE-4887 Support for starting transaction in another thread","user":{"login":"voipp","id":5221372,"avatar_url":"https://avatars2.githubusercontent.com/u/5221372?v=3","gravatar_id":"","url":"https://api.github.com/users/voipp","html_url":"https://github.com/voipp","followers_url":"https://api.github.com/users/voipp/followers","following_url":"https://api.github.com/users/voipp/following{/other_user}","gists_url":"https://api.github.com/users/voipp/gists{/gist_id}","starred_url":"https://api.github.com/users/voipp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voipp/subscriptions","organizations_url":"https://api.github.com/users/voipp/orgs","repos_url":"https://api.github.com/users/voipp/repos","events_url":"https://api.github.com/users/voipp/events{/privacy}","received_events_url":"https://api.github.com/users/voipp/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-01T15:00:40Z","updated_at":"2017-06-28T08:28:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4fc1d594f5f221239fab482f90a8c67c35dccc4d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/ignite/pulls/2061/commits","review_comments_url":"https://api.github.com/repos/apache/ignite/pulls/2061/comments","review_comment_url":"https://api.github.com/repos/apache/ignite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/ignite/issues/2061/comments","statuses_url":"https://api.github.com/repos/apache/ignite/statuses/76b385de8539abcd22ad218c92b9dda70527c3c6","head":{"label":"voipp:IGNITE-4887","ref":"IGNITE-4887","sha":"76b385de8539abcd22ad218c92b9dda70527c3c6","user":{"login":"voipp","id":5221372,"avatar_url":"https://avatars2.githubusercontent.com/u/5221372?v=3","gravatar_id":"","url":"https://api.github.com/users/voipp","html_url":"https://github.com/voipp","followers_url":"https://api.github.com/users/voipp/followers","following_url":"https://api.github.com/users/voipp/following{/other_user}","gists_url":"https://api.github.com/users/voipp/gists{/gist_id}","starred_url":"https://api.github.com/users/voipp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voipp/subscriptions","organizations_url":"https://api.github.com/users/voipp/orgs","repos_url":"https://api.github.com/users/voipp/repos","events_url":"https://api.github.com/users/voipp/events{/privacy}","received_events_url":"https://api.github.com/users/voipp/received_events","type":"User","site_admin":false},"repo":{"id":79925338,"name":"ignite","full_name":"voipp/ignite","owner":{"login":"voipp","id":5221372,"avatar_url":"https://avatars2.githubusercontent.com/u/5221372?v=3","gravatar_id":"","url":"https://api.github.com/users/voipp","html_url":"https://github.com/voipp","followers_url":"https://api.github.com/users/voipp/followers","following_url":"https://api.github.com/users/voipp/following{/other_user}","gists_url":"https://api.github.com/users/voipp/gists{/gist_id}","starred_url":"https://api.github.com/users/voipp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voipp/subscriptions","organizations_url":"https://api.github.com/users/voipp/orgs","repos_url":"https://api.github.com/users/voipp/repos","events_url":"https://api.github.com/users/voipp/events{/privacy}","received_events_url":"https://api.github.com/users/voipp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/voipp/ignite","description":"Mirror of Apache Ignite","fork":true,"url":"https://api.github.com/repos/voipp/ignite","forks_url":"https://api.github.com/repos/voipp/ignite/forks","keys_url":"https://api.github.com/repos/voipp/ignite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/voipp/ignite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/voipp/ignite/teams","hooks_url":"https://api.github.com/repos/voipp/ignite/hooks","issue_events_url":"https://api.github.com/repos/voipp/ignite/issues/events{/number}","events_url":"https://api.github.com/repos/voipp/ignite/events","assignees_url":"https://api.github.com/repos/voipp/ignite/assignees{/user}","branches_url":"https://api.github.com/repos/voipp/ignite/branches{/branch}","tags_url":"https://api.github.com/repos/voipp/ignite/tags","blobs_url":"https://api.github.com/repos/voipp/ignite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/voipp/ignite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/voipp/ignite/git/refs{/sha}","trees_url":"https://api.github.com/repos/voipp/ignite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/voipp/ignite/statuses/{sha}","languages_url":"https://api.github.com/repos/voipp/ignite/languages","stargazers_url":"https://api.github.com/repos/voipp/ignite/stargazers","contributors_url":"https://api.github.com/repos/voipp/ignite/contributors","subscribers_url":"https://api.github.com/repos/voipp/ignite/subscribers","subscription_url":"https://api.github.com/repos/voipp/ignite/subscription","commits_url":"https://api.github.com/repos/voipp/ignite/commits{/sha}","git_commits_url":"https://api.github.com/repos/voipp/ignite/git/commits{/sha}","comments_url":"https://api.github.com/repos/voipp/ignite/comments{/number}","issue_comment_url":"https://api.github.com/repos/voipp/ignite/issues/comments{/number}","contents_url":"https://api.github.com/repos/voipp/ignite/contents/{+path}","compare_url":"https://api.github.com/repos/voipp/ignite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/voipp/ignite/merges","archive_url":"https://api.github.com/repos/voipp/ignite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/voipp/ignite/downloads","issues_url":"https://api.github.com/repos/voipp/ignite/issues{/number}","pulls_url":"https://api.github.com/repos/voipp/ignite/pulls{/number}","milestones_url":"https://api.github.com/repos/voipp/ignite/milestones{/number}","notifications_url":"https://api.github.com/repos/voipp/ignite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/voipp/ignite/labels{/name}","releases_url":"https://api.github.com/repos/voipp/ignite/releases{/id}","deployments_url":"https://api.github.com/repos/voipp/ignite/deployments","created_at":"2017-01-24T15:41:04Z","updated_at":"2017-01-24T15:41:26Z","pushed_at":"2017-06-28T08:24:24Z","git_url":"git://github.com/voipp/ignite.git","ssh_url":"git@github.com:voipp/ignite.git","clone_url":"https://github.com/voipp/ignite.git","svn_url":"https://github.com/voipp/ignite","homepage":"","size":227515,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"8445b315663710507e6e3996223f01748f9674a6","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":31006158,"name":"ignite","full_name":"apache/ignite","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/ignite","description":"Mirror of Apache Ignite","fork":false,"url":"https://api.github.com/repos/apache/ignite","forks_url":"https://api.github.com/repos/apache/ignite/forks","keys_url":"https://api.github.com/repos/apache/ignite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/ignite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/ignite/teams","hooks_url":"https://api.github.com/repos/apache/ignite/hooks","issue_events_url":"https://api.github.com/repos/apache/ignite/issues/events{/number}","events_url":"https://api.github.com/repos/apache/ignite/events","assignees_url":"https://api.github.com/repos/apache/ignite/assignees{/user}","branches_url":"https://api.github.com/repos/apache/ignite/branches{/branch}","tags_url":"https://api.github.com/repos/apache/ignite/tags","blobs_url":"https://api.github.com/repos/apache/ignite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/ignite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/ignite/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/ignite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/ignite/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/ignite/languages","stargazers_url":"https://api.github.com/repos/apache/ignite/stargazers","contributors_url":"https://api.github.com/repos/apache/ignite/contributors","subscribers_url":"https://api.github.com/repos/apache/ignite/subscribers","subscription_url":"https://api.github.com/repos/apache/ignite/subscription","commits_url":"https://api.github.com/repos/apache/ignite/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/ignite/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/ignite/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/ignite/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/ignite/contents/{+path}","compare_url":"https://api.github.com/repos/apache/ignite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/ignite/merges","archive_url":"https://api.github.com/repos/apache/ignite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/ignite/downloads","issues_url":"https://api.github.com/repos/apache/ignite/issues{/number}","pulls_url":"https://api.github.com/repos/apache/ignite/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/ignite/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/ignite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/ignite/labels{/name}","releases_url":"https://api.github.com/repos/apache/ignite/releases{/id}","deployments_url":"https://api.github.com/repos/apache/ignite/deployments","created_at":"2015-02-19T08:00:05Z","updated_at":"2017-06-28T07:12:43Z","pushed_at":"2017-06-28T08:24:24Z","git_url":"git://github.com/apache/ignite.git","ssh_url":"git@github.com:apache/ignite.git","clone_url":"https://github.com/apache/ignite.git","svn_url":"https://github.com/apache/ignite","homepage":"","size":233561,"stargazers_count":1017,"watchers_count":1017,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":599,"mirror_url":"git://git.apache.org/ignite.git","open_issues_count":569,"forks":599,"open_issues":569,"watchers":1017,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/ignite/pulls/2061"},"html":{"href":"https://github.com/apache/ignite/pull/2061"},"issue":{"href":"https://api.github.com/repos/apache/ignite/issues/2061"},"comments":{"href":"https://api.github.com/repos/apache/ignite/issues/2061/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/ignite/pulls/2061/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/ignite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/ignite/pulls/2061/commits"},"statuses":{"href":"https://api.github.com/repos/apache/ignite/statuses/76b385de8539abcd22ad218c92b9dda70527c3c6"}}}}
{"actor":{"display_login":"daradurvs"}}