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 BF09418FEF for ; Fri, 31 Jul 2015 10:32:53 +0000 (UTC) Received: (qmail 64563 invoked by uid 500); 31 Jul 2015 10:32:53 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 64532 invoked by uid 500); 31 Jul 2015 10:32:53 -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 64523 invoked by uid 99); 31 Jul 2015 10:32:53 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Jul 2015 10:32:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 3E7ED195F50 for ; Fri, 31 Jul 2015 10:32:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, 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 (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id GCqpd8InZIov for ; Fri, 31 Jul 2015 10:32:45 +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 0225D2142D for ; Fri, 31 Jul 2015 10:32:44 +0000 (UTC) Received: (qmail 64308 invoked by uid 99); 31 Jul 2015 10:32:44 -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; Fri, 31 Jul 2015 10:32:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B88A3E17ED; Fri, 31 Jul 2015 10:32:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yzhdanov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 31 Jul 2015 10:32:45 -0000 Message-Id: In-Reply-To: <1c4472ad99f64e37bc22932af576b9ec@git.apache.org> References: <1c4472ad99f64e37bc22932af576b9ec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] incubator-ignite git commit: #ignite-1175: Add test for dht local partition map. #ignite-1175: Add test for dht local partition map. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7ed4d15f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7ed4d15f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7ed4d15f Branch: refs/heads/ignite-752-2 Commit: 7ed4d15f16c71e1683fd659865653a383d99259e Parents: 5288b2d Author: ivasilinets Authored: Thu Jul 30 14:12:27 2015 +0300 Committer: ivasilinets Committed: Thu Jul 30 14:12:27 2015 +0300 ---------------------------------------------------------------------- ...cheDhtLocalPartitionAfterRemoveSelfTest.java | 107 +++++++++++++++++++ 1 file changed, 107 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7ed4d15f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java new file mode 100644 index 0000000..b04e41a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java @@ -0,0 +1,107 @@ +/* + * 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.internal.processors.cache.distributed.dht.*; +import org.apache.ignite.testframework.junits.common.*; + +/** + * Test for remove operation. + */ +public class CacheDhtLocalPartitionAfterRemoveSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + ccfg.setEvictSynchronized(false); + ccfg.setNearConfiguration(null); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGrids(1); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testMemoryUsage() throws Exception { + IgniteCache cache = grid(0).cache(null); + + for (int i = 0; i < 1000; ++i) + cache.put(new TestKey("" + i), i); + + for (int i = 0; i < 1000; ++i) + assert cache.getAndRemove(new TestKey("" + i)).equals(i); + + assertEquals(0, cache.size()); + + int size = 0; + + for (GridDhtLocalPartition p : dht(cache).topology().localPartitions()) { + int pSize = p.size(); + + size += pSize; + } + + System.out.println("All size: " + size); + } + + /** + * Test key. + */ + private static class TestKey { + /** Key. */ + private String key; + + /** + * @param key Key. + */ + public TestKey(String key) { + this.key = key; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return key.hashCode(); + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object obj) { + if (obj == null || !(obj instanceof TestKey)) + return false; + + return key.equals(((TestKey)obj).key); + } + } +}