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 9C30518CC8 for ; Mon, 18 Jan 2016 15:16:48 +0000 (UTC) Received: (qmail 9658 invoked by uid 500); 18 Jan 2016 15:16:48 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 9618 invoked by uid 500); 18 Jan 2016 15:16:48 -0000 Mailing-List: contact commits-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 commits@ignite.apache.org Received: (qmail 9609 invoked by uid 99); 18 Jan 2016 15:16:48 -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 Jan 2016 15:16:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5EFAFE03CD; Mon, 18 Jan 2016 15:16:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Mon, 18 Jan 2016 15:16:48 -0000 Message-Id: <34bb49ac759545fc9d2d7a6fb97c599b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] ignite git commit: ignite-1811 Optimized cache 'get' on affinity node. (cherry picked from commit 83b2bf5e1f287dc83343945b0e47b83ee7724a8e) Repository: ignite Updated Branches: refs/heads/ignite-1.5.4 6482dc80b -> 4b31f4e66 ignite-1811 Optimized cache 'get' on affinity node. (cherry picked from commit 83b2bf5e1f287dc83343945b0e47b83ee7724a8e) Conflicts: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4ba6574d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4ba6574d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4ba6574d Branch: refs/heads/ignite-1.5.4 Commit: 4ba6574dfa8077f8de23c8c2663826f81c7fd187 Parents: 6482dc8 Author: sboikov Authored: Mon Jan 18 18:15:04 2016 +0300 Committer: sboikov Committed: Mon Jan 18 18:15:04 2016 +0300 ---------------------------------------------------------------------- .../cache/IgniteCacheStoreCollectionTest.java | 175 +++++++++++++++++++ 1 file changed, 175 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4ba6574d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java new file mode 100644 index 0000000..48acdfc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java @@ -0,0 +1,175 @@ +/* + * 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 java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; + +/** + * + */ +public class IgniteCacheStoreCollectionTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + CacheConfiguration ccfg1 = new CacheConfiguration<>(); + ccfg1.setName("cache1"); + ccfg1.setAtomicityMode(ATOMIC); + ccfg1.setWriteSynchronizationMode(FULL_SYNC); + + CacheConfiguration ccfg2 = new CacheConfiguration<>(); + ccfg2.setName("cache2"); + ccfg2.setAtomicityMode(TRANSACTIONAL); + ccfg2.setWriteSynchronizationMode(FULL_SYNC); + + cfg.setCacheConfiguration(ccfg1, ccfg2); + + cfg.setMarshaller(null); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** + * @throws Exception If failed. + */ + public void testStoreMap() throws Exception { + IgniteCache cache1 = ignite(0).cache("cache1"); + IgniteCache cache2 = ignite(0).cache("cache2"); + + checkStoreMap(cache1); + checkStoreMap(cache2); + } + + /** + * @param cache Cache. + */ + private void checkStoreMap(IgniteCache cache) { + cache.put(1, new MyMap()); + cache.put(2, new MyMap()); + + MyMap map = (MyMap)cache.get(1); + + assertNotNull(map); + + Map vals = (Map)cache.getAll(F.asSet(1, 2)); + + assertEquals(2, vals.size()); + assertTrue("Unexpected value: " + vals.get(1), vals.get(1) instanceof MyMap); + assertTrue("Unexpected value: " + vals.get(2), vals.get(2) instanceof MyMap); + } + + /** + * + */ + public static class MyMap implements Map { + /** {@inheritDoc} */ + @Override public int size() { + return 0; + } + + /** {@inheritDoc} */ + @Override public boolean isEmpty() { + return true; + } + + /** {@inheritDoc} */ + @Override public boolean containsKey(Object key) { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean containsValue(Object val) { + return false; + } + + /** {@inheritDoc} */ + @Override public Object get(Object key) { + return null; + } + + /** {@inheritDoc} */ + @Override public Object put(Object key, Object val) { + return null; + } + + /** {@inheritDoc} */ + @Override public Object remove(Object key) { + return null; + } + + /** {@inheritDoc} */ + @Override public void putAll(Map m) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void clear() { + // No-op. + } + + /** {@inheritDoc} */ + @Override public Set keySet() { + return Collections.emptySet(); + } + + /** {@inheritDoc} */ + @Override public Collection values() { + return Collections.emptySet(); + } + + /** {@inheritDoc} */ + @Override public Set entrySet() { + return Collections.emptySet(); + } + } +}