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 B41B317D22 for ; Wed, 1 Apr 2015 08:38:29 +0000 (UTC) Received: (qmail 29740 invoked by uid 500); 1 Apr 2015 08:38:12 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 29697 invoked by uid 500); 1 Apr 2015 08:38:12 -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 29688 invoked by uid 99); 1 Apr 2015 08:38:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 08:38:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 01 Apr 2015 08:38:10 +0000 Received: (qmail 27429 invoked by uid 99); 1 Apr 2015 08:37:47 -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; Wed, 01 Apr 2015 08:37:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6A1F9E2F34; Wed, 1 Apr 2015 08:37:47 +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: Wed, 01 Apr 2015 08:38:21 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [35/49] incubator-ignite git commit: ignite-629: Revert GridCacheReturnValueTransferSelfTest. X-Virus-Checked: Checked by ClamAV on apache.org ignite-629: Revert GridCacheReturnValueTransferSelfTest. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/885643ac Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/885643ac Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/885643ac Branch: refs/heads/ignite-645 Commit: 885643ac03f52a4b4d97f1535be3c6a1e344a100 Parents: a9996d8 Author: ivasilinets Authored: Tue Mar 31 12:11:39 2015 +0300 Committer: ivasilinets Committed: Tue Mar 31 12:11:39 2015 +0300 ---------------------------------------------------------------------- .../GridCacheReturnValueTransferSelfTest.java | 191 +++++++++++++++++++ 1 file changed, 191 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/885643ac/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java new file mode 100644 index 0000000..4761e21 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java @@ -0,0 +1,191 @@ +/* + * 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; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.testframework.junits.common.*; + +import javax.cache.processor.*; +import java.io.*; +import java.util.*; + +import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Tests transform for extra traffic. + */ +public class GridCacheReturnValueTransferSelfTest extends GridCommonAbstractTest { + /** Distribution mode. */ + private boolean cache; + + /** Atomicity mode. */ + private CacheAtomicityMode atomicityMode; + + /** Atomic write order mode. */ + private CacheAtomicWriteOrderMode writeOrderMode; + + /** Number of backups. */ + private int backups; + + /** Fail deserialization flag. */ + private static volatile boolean failDeserialization; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setBackups(backups); + ccfg.setCacheMode(PARTITIONED); + ccfg.setAtomicityMode(atomicityMode); + ccfg.setAtomicWriteOrderMode(writeOrderMode); + + cfg.setCacheConfiguration(ccfg); + + if (!cache) + cfg.setClientMode(true); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testTransformAtomicPrimaryNoBackups() throws Exception { + checkTransform(ATOMIC, PRIMARY, 0); + } + + /** + * @throws Exception If failed. + */ + public void testTransformAtomicClockNoBackups() throws Exception { + checkTransform(ATOMIC, CLOCK, 0); + } + + /** + * @throws Exception If failed. + * TODO gg-8273 enable when fixed + */ + public void _testTransformTransactionalNoBackups() throws Exception { + checkTransform(TRANSACTIONAL, PRIMARY, 0); + } + + /** + * @throws Exception If failed. + * TODO gg-8273 enable when fixed + */ + public void _testTransformTransactionalOneBackup() throws Exception { + checkTransform(TRANSACTIONAL, PRIMARY, 1); + } + + /** + * @param mode Atomicity mode. + * @param order Atomic cache write order mode. + * @param b Number of backups. + * @throws Exception If failed. + */ + private void checkTransform(CacheAtomicityMode mode, CacheAtomicWriteOrderMode order, int b) + throws Exception { + try { + atomicityMode = mode; + + backups = b; + + writeOrderMode = order; + + cache = true; + + startGrids(2); + + cache = false; + + startGrid(2); + + failDeserialization = false; + + // Get client grid. + IgniteCache cache = grid(2).cache(null); + + for (int i = 0; i < 100; i++) + cache.put(i, new TestObject()); + + failDeserialization = true; + + info(">>>>>> Transforming"); + + // Transform (check non-existent keys also). + for (int i = 0; i < 200; i++) + cache.invoke(i, new Transform()); + + Set keys = new HashSet<>(); + + // Check transformAll. + for (int i = 0; i < 300; i++) + keys.add(i); + + cache.invokeAll(keys, new Transform()); + + // Avoid errors during stop. + failDeserialization = false; + } + finally { + stopAllGrids(); + } + } + + /** + * + */ + private static class Transform implements EntryProcessor, Serializable { + /** {@inheritDoc} */ + @Override public Void process(MutableEntry entry, Object... args) { + entry.setValue(new TestObject()); + + return null; + } + } + + /** + * + */ + @IgniteImmutable + private static class TestObject implements Externalizable { + /** + * + */ + public TestObject() { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + assert !failDeserialization; + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + assert !failDeserialization; + } + } +}