Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E383C1812F for ; Mon, 18 May 2015 09:40:13 +0000 (UTC) Received: (qmail 6507 invoked by uid 500); 18 May 2015 09:40:13 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 6478 invoked by uid 500); 18 May 2015 09:40:13 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 6469 invoked by uid 99); 18 May 2015 09:40:13 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2015 09:40:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 4B6E9C0052 for ; Mon, 18 May 2015 09:40:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id yIpqq5hhFUmC for ; Mon, 18 May 2015 09:40:10 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 7AC67262C8 for ; Mon, 18 May 2015 09:39:57 +0000 (UTC) Received: (qmail 5115 invoked by uid 99); 18 May 2015 09:39:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2015 09:39:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 59CCEE0613; Mon, 18 May 2015 09:39:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Mon, 18 May 2015 09:40:37 -0000 Message-Id: <5e83a106d52a4a30bdef392a2eb61222@git.apache.org> In-Reply-To: <8aca28a158514c4ab666c4b7e612f103@git.apache.org> References: <8aca28a158514c4ab666c4b7e612f103@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/45] incubator-ignite git commit: # added test # added test Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a27a35d8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a27a35d8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a27a35d8 Branch: refs/heads/ignite-745 Commit: a27a35d8bfd4954b5f6b912e2d5dd54f75c31f3c Parents: da5a228 Author: sboikov Authored: Sat May 16 06:56:15 2015 +0300 Committer: sboikov Committed: Sat May 16 06:56:15 2015 +0300 ---------------------------------------------------------------------- .../near/IgniteCacheNearOnlyTxTest.java | 140 +++++++++++++++++++ 1 file changed, 140 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a27a35d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java new file mode 100644 index 0000000..06a4bfc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.distributed.near; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.transactions.*; + +import java.util.concurrent.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.transactions.TransactionConcurrency.*; +import static org.apache.ignite.transactions.TransactionIsolation.*; + +/** + * + */ +public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 2; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return null; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + if (getTestGridName(1).equals(gridName)) { + cfg.setClientMode(true); + + cfg.setCacheConfiguration(); + } + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testNearOnlyPutMultithreaded() throws Exception { + final Ignite ignite1 = ignite(1); + + assertTrue(ignite1.configuration().isClientMode()); + + ignite1.createNearCache(null, new NearCacheConfiguration<>()); + + GridTestUtils.runMultiThreaded(new Callable() { + @Override public Object call() throws Exception { + IgniteCache cache = ignite1.cache(null); + + int key = 1; + + for (int i = 0; i < 100; i++) + cache.put(key, 1); + + return null; + } + }, 5, "put-thread"); + } + + /** + * @throws Exception If failed. + */ + public void testOptimisticTx() throws Exception { + txMultithreaded(true); + } + + /** + * @throws Exception If failed. + */ + public void testPessimisticTx() throws Exception { + txMultithreaded(false); + } + + /** + * @throws Exception If failed. + */ + private void txMultithreaded(final boolean optimistic) throws Exception { + final Ignite ignite1 = ignite(1); + + assertTrue(ignite1.configuration().isClientMode()); + + ignite1.createNearCache(null, new NearCacheConfiguration<>()); + + GridTestUtils.runMultiThreaded(new Callable() { + @Override public Object call() throws Exception { + IgniteCache cache = ignite1.cache(null); + + int key = 1; + + IgniteTransactions txs = ignite1.transactions(); + + for (int i = 0; i < 100; i++) { + try (Transaction tx = txs.txStart(optimistic ? OPTIMISTIC : PESSIMISTIC, REPEATABLE_READ)) { + cache.get(key); + + cache.put(key, 1); + + tx.commit(); + } + } + + return null; + } + }, 5, "put-thread"); + } +}