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 12BEB17F1C for ; Mon, 31 Aug 2015 21:24:26 +0000 (UTC) Received: (qmail 73070 invoked by uid 500); 31 Aug 2015 21:24:26 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 73000 invoked by uid 500); 31 Aug 2015 21:24:26 -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 71940 invoked by uid 99); 31 Aug 2015 21:24:25 -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, 31 Aug 2015 21:24:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 536EBE048E; Mon, 31 Aug 2015 21:24:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.apache.org Date: Mon, 31 Aug 2015 21:24:59 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [36/50] [abbrv] 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/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7ed4d15f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7ed4d15f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7ed4d15f Branch: refs/heads/ignite-950 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/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); + } + } +}