Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F3C30200CB3 for ; Sun, 11 Jun 2017 22:03:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F259A160B9C; Sun, 11 Jun 2017 20:03:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DE9C7160C04 for ; Sun, 11 Jun 2017 22:03:31 +0200 (CEST) Received: (qmail 61427 invoked by uid 500); 11 Jun 2017 20:03:31 -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 61016 invoked by uid 99); 11 Jun 2017 20:03:30 -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; Sun, 11 Jun 2017 20:03:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E1DADF4A4C; Sun, 11 Jun 2017 20:03:27 +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: Sun, 11 Jun 2017 20:03:34 -0000 Message-Id: <6bcd593f78864383ab9806c8c1a867b5@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [08/47] ignite git commit: IGNITE-5267 - Moved ignite-ps module to ignite-core archived-at: Sun, 11 Jun 2017 20:03:36 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsContinuousRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsContinuousRestartTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsContinuousRestartTest.java deleted file mode 100644 index a149836..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsContinuousRestartTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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.cache.database; - -import java.util.Map; -import java.util.Random; -import java.util.TreeMap; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class IgnitePdsContinuousRestartTest extends GridCommonAbstractTest { - /** */ - private static final int GRID_CNT = 4; - - /** */ - private static final int ENTRIES_COUNT = 10_000; - - /** */ - public static final String CACHE_NAME = "cache1"; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - MemoryConfiguration memCfg = new MemoryConfiguration(); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName("dfltMemPlc"); - memPlcCfg.setMaxSize(400 * 1024 * 1024); - memPlcCfg.setInitialSize(400 * 1024 * 1024); - - memCfg.setMemoryPolicies(memPlcCfg); - memCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - - cfg.setMemoryConfiguration(memCfg); - - CacheConfiguration ccfg1 = new CacheConfiguration(); - - ccfg1.setName(CACHE_NAME); - ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - ccfg1.setAffinity(new RendezvousAffinityFunction(false, 128)); - ccfg1.setBackups(2); - - cfg.setCacheConfiguration(ccfg1); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - stopAllGrids(); - - deleteWorkFiles(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - deleteWorkFiles(); - } - - /** - * @throws IgniteCheckedException If failed. - */ - private void deleteWorkFiles() throws IgniteCheckedException { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_500_1_1() throws Exception { - checkRebalancingDuringLoad(1000, 500, 1, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_500_1_1() throws Exception { - checkRebalancingDuringLoad(8000, 500, 1, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_20000_1_1() throws Exception { - checkRebalancingDuringLoad(1000, 20000, 1, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_8000_1_1() throws Exception { - checkRebalancingDuringLoad(8000, 8000, 1, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_500_8_1() throws Exception { - checkRebalancingDuringLoad(1000, 500, 8, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_500_8_1() throws Exception { - checkRebalancingDuringLoad(8000, 500, 8, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_20000_8_1() throws Exception { - checkRebalancingDuringLoad(1000, 20000, 8, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_8000_8_1() throws Exception { - checkRebalancingDuringLoad(8000, 8000, 8, 1); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_500_8_16() throws Exception { - checkRebalancingDuringLoad(1000, 500, 8, 16); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_500_8_16() throws Exception { - checkRebalancingDuringLoad(8000, 500, 8, 16); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_1000_20000_8_16() throws Exception { - checkRebalancingDuringLoad(1000, 20000, 8, 16); - } - - /** - * @throws Exception if failed. - */ - public void testRebalancingDuringLoad_8000_8000_8_16() throws Exception { - checkRebalancingDuringLoad(8000, 8000, 8, 16); - } - - /** - * @throws Exception if failed. - */ - private void checkRebalancingDuringLoad( - int restartDelay, - int checkpointDelay, - int threads, - final int batch - ) throws Exception { - - startGrids(GRID_CNT); - - final Ignite load = ignite(0); - - try (IgniteDataStreamer s = load.dataStreamer(CACHE_NAME)) { - s.allowOverwrite(true); - - for (int i = 0; i < ENTRIES_COUNT; i++) - s.addData(i, i); - } - - final AtomicBoolean done = new AtomicBoolean(false); - - IgniteInternalFuture busyFut = GridTestUtils.runMultiThreadedAsync(new Callable() { - /** {@inheritDoc} */ - @Override public Object call() throws Exception { - IgniteCache cache = load.cache(CACHE_NAME); - Random rnd = ThreadLocalRandom.current(); - - while (!done.get()) { - Map map = new TreeMap<>(); - - for (int i = 0; i < batch; i++) - map.put(rnd.nextInt(ENTRIES_COUNT), rnd.nextInt()); - - cache.putAll(map); - } - - return null; - } - }, threads, "updater"); - - long end = System.currentTimeMillis() + 90_000; - - Random rnd = ThreadLocalRandom.current(); - - while (System.currentTimeMillis() < end) { - int idx = rnd.nextInt(GRID_CNT - 1) + 1; - - stopGrid(idx); - - U.sleep(restartDelay); - - startGrid(idx); - - U.sleep(restartDelay); - } - - done.set(true); - - busyFut.get(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsDynamicCacheTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsDynamicCacheTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsDynamicCacheTest.java deleted file mode 100644 index 63bf557..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsDynamicCacheTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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.cache.database; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager; -import org.apache.ignite.internal.processors.database.IgniteDbDynamicCacheSelfTest; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * - */ -public class IgnitePdsDynamicCacheTest extends IgniteDbDynamicCacheSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - MemoryConfiguration dbCfg = new MemoryConfiguration(); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName("dfltMemPlc"); - memPlcCfg.setInitialSize(200 * 1024 * 1024); - memPlcCfg.setMaxSize(200 * 1024 * 1024); - - dbCfg.setMemoryPolicies(memPlcCfg); - dbCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - - cfg.setMemoryConfiguration(dbCfg); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - if ("client".equals(gridName)) - cfg.setClientMode(true); - - return cfg; - } - - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - System.setProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC, "true"); - - super.beforeTest(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); - - deleteWorkFiles(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - System.clearProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC); - - deleteWorkFiles(); - } - - /** - * @throws Exception If failed. - */ - public void testRestartAndCreate() throws Exception { - startGrids(3); - - Ignite ignite = ignite(0); - - CacheConfiguration ccfg1 = new CacheConfiguration(); - - ccfg1.setName("cache1"); - ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - ccfg1.setRebalanceMode(CacheRebalanceMode.NONE); - ccfg1.setAffinity(new RendezvousAffinityFunction(false, 32)); - - CacheConfiguration ccfg2 = new CacheConfiguration(); - - ccfg2.setName("cache2"); - ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - ccfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - ccfg2.setRebalanceMode(CacheRebalanceMode.NONE); - ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32)); - - ignite.createCache(ccfg1); - ignite.createCache(ccfg2); - - int iterations = 20; - - long stopTime = U.currentTimeMillis() + 20_000; - - for (int k = 0; k < iterations && U.currentTimeMillis() < stopTime; k++) { - log.info("Iteration: " + k); - - stopAllGrids(); - - startGrids(3); - - ignite = ignite(0); - - ignite.getOrCreateCache(ccfg1); - - ignite.getOrCreateCache(ccfg2); - - ignite.destroyCache(ccfg2.getName()); - - ignite.getOrCreateCache(ccfg2); - - ignite.destroyCache(ccfg1.getName()); - } - } - - /** - * @throws IgniteCheckedException If failed. - */ - private void deleteWorkFiles() throws IgniteCheckedException { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsMultiNodePutGetRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsMultiNodePutGetRestartTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsMultiNodePutGetRestartTest.java deleted file mode 100644 index d4d9eb6..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsMultiNodePutGetRestartTest.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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.cache.database; - -import java.io.File; -import java.io.Serializable; -import java.util.List; -import java.util.UUID; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.cache.query.annotations.QuerySqlField; -import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -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; - -/** - * - */ -public class IgnitePdsMultiNodePutGetRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final int GRID_CNT = 3; - - /** */ - private final File allocPath; - - /** - * Default constructor. - */ - public IgnitePdsMultiNodePutGetRestartTest() { - String home = U.getIgniteHome(); - - allocPath = new File(home, "work/db/" + UUID.randomUUID()); - - allocPath.mkdirs(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - MemoryConfiguration memCfg = new MemoryConfiguration(); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName("dfltMemPlc"); - memPlcCfg.setInitialSize(100 * 1024 * 1024); - memPlcCfg.setMaxSize(100 * 1024 * 1024); - - memCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - memCfg.setMemoryPolicies(memPlcCfg); - - cfg.setMemoryConfiguration(memCfg); - - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setIndexedTypes(Integer.class, DbValue.class); - - ccfg.setRebalanceMode(CacheRebalanceMode.NONE); - - ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); - - ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - - cfg.setCacheConfiguration(ccfg); - - cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration()); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - - cfg.setMarshaller(null); - - BinaryConfiguration bCfg = new BinaryConfiguration(); - - bCfg.setCompactFooter(false); - - cfg.setBinaryConfiguration(bCfg); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - - super.beforeTest(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - /** - * @throws Exception if failed. - */ - public void testPutGetSimple() throws Exception { - info(">>> Will use path: " + allocPath); - - startGrids(GRID_CNT); - - try { - IgniteEx ig = grid(0); - - checkPutGetSql(ig, true); - } - finally { - stopAllGrids(); - } - - info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - - startGrids(GRID_CNT); - - try { - IgniteEx ig = grid(0); - - checkPutGetSql(ig, false); - } - finally { - stopAllGrids(); - } - } - - /** - * @param ig Ig. - * @param write Write. - */ - private void checkPutGetSql(IgniteEx ig, boolean write) { - IgniteCache cache = ig.cache(null); - - if (write) { - try (IgniteDataStreamer streamer = ig.dataStreamer(null)) { - for (int i = 0; i < 10_000; i++) - streamer.addData(i, new DbValue(i, "value-" + i, i)); - } - } - - List> res = cache.query(new SqlFieldsQuery("select ival from dbvalue where ival < ? order by ival asc") - .setArgs(10_000)).getAll(); - - assertEquals(10_000, res.size()); - - for (int i = 0; i < 10_000; i++) { - assertEquals(1, res.get(i).size()); - assertEquals(i, res.get(i).get(0)); - } - - assertEquals(1, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival = 7899")).getAll().size()); - assertEquals(5000, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival >= 5000 and ival < 10000")) - .getAll().size()); - - for (int i = 0; i < 10_000; i++) - assertEquals(new DbValue(i, "value-" + i, i), cache.get(i)); - } - - /** - * - */ - private static class DbValue implements Serializable { - /** */ - @QuerySqlField(index = true) - private int iVal; - - /** */ - @QuerySqlField(index = true) - private String sVal; - - /** */ - @QuerySqlField - private long lVal; - - /** - * @param iVal Integer value. - * @param sVal String value. - * @param lVal Long value. - */ - public DbValue(int iVal, String sVal, long lVal) { - this.iVal = iVal; - this.sVal = sVal; - this.lVal = lVal; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - DbValue dbVal = (DbValue)o; - - return iVal == dbVal.iVal && lVal == dbVal.lVal && - !(sVal != null ? !sVal.equals(dbVal.sVal) : dbVal.sVal != null); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = iVal; - - res = 31 * res + (sVal != null ? sVal.hashCode() : 0); - res = 31 * res + (int)(lVal ^ (lVal >>> 32)); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(DbValue.class, this); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsPageSizesTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsPageSizesTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsPageSizesTest.java deleted file mode 100644 index a15b96c..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsPageSizesTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.cache.database; - -import java.util.Random; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class IgnitePdsPageSizesTest extends GridCommonAbstractTest { - /** Cache name. */ - private final String cacheName = "cache"; - - /** */ - private int pageSize; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - MemoryConfiguration memCfg = new MemoryConfiguration(); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName("dfltMemPlc"); - memPlcCfg.setInitialSize(100 * 1024 * 1024); - memPlcCfg.setMaxSize(100 * 1024 * 1024); - - memCfg.setMemoryPolicies(memPlcCfg); - memCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - - memCfg.setPageSize(pageSize); - - cfg.setMemoryConfiguration(memCfg); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - cfg.setCacheConfiguration( - new CacheConfiguration(cacheName) - .setAffinity(new RendezvousAffinityFunction(false, 32)) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - /** - * @throws Exception if failed. - */ - public void testPageSize_1k() throws Exception { - checkPageSize(1024); - } - - /** - * @throws Exception if failed. - */ - public void testPageSize_2k() throws Exception { - checkPageSize(2 * 1024); - } - - /** - * @throws Exception if failed. - */ - public void testPageSize_4k() throws Exception { - checkPageSize(4 * 1024); - } - - /** - * @throws Exception if failed. - */ - public void testPageSize_8k() throws Exception { - checkPageSize(8 * 1024); - } - - /** - * @throws Exception if failed. - */ - public void testPageSize_16k() throws Exception { - checkPageSize(16 * 1024); - } - - /** - * @throws Exception if failed. - */ - private void checkPageSize(int pageSize) throws Exception { - this.pageSize = pageSize; - - IgniteEx ignite = startGrid(0); - - try { - final IgniteCache cache = ignite.cache(cacheName); - final long endTime = System.currentTimeMillis() + 60_000; - - GridTestUtils.runMultiThreaded(new Callable() { - @Override public Object call() throws Exception { - Random rnd = ThreadLocalRandom.current(); - - while (System.currentTimeMillis() < endTime) { - for (int i = 0; i < 500; i++) - cache.put(rnd.nextInt(100_000), rnd.nextInt()); - } - - return null; - } - }, 16, "runner"); - } - finally { - stopAllGrids(); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRecoveryAfterFileCorruptionTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRecoveryAfterFileCorruptionTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRecoveryAfterFileCorruptionTest.java deleted file mode 100644 index eb3662d..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRecoveryAfterFileCorruptionTest.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * 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.cache.database; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.channels.FileChannel; -import java.util.Collection; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageIdAllocator; -import org.apache.ignite.internal.pagemem.PageIdUtils; -import org.apache.ignite.internal.pagemem.PageMemory; -import org.apache.ignite.internal.pagemem.PageUtils; -import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; -import org.apache.ignite.internal.pagemem.store.PageStore; -import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.pagemem.wal.WALPointer; -import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager; -import org.apache.ignite.internal.processors.cache.database.file.FilePageStore; -import org.apache.ignite.internal.processors.cache.database.file.FilePageStoreManager; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl; -import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO; -import org.apache.ignite.internal.util.typedef.internal.U; -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; - -/** - * - */ -public class IgnitePdsRecoveryAfterFileCorruptionTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** Total pages. */ - private static final int totalPages = 1024; - - /** Cache name. */ - private final String cacheName = "cache"; - - /** Policy name. */ - private final String policyName = "dfltMemPlc"; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration ccfg = new CacheConfiguration(cacheName); - ccfg.setAffinity(new RendezvousAffinityFunction(true, 1)); - - ccfg.setRebalanceMode(CacheRebalanceMode.NONE); - - cfg.setCacheConfiguration(ccfg); - - MemoryConfiguration dbCfg = new MemoryConfiguration(); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName(policyName); - memPlcCfg.setInitialSize(1024 * 1024 * 1024); - memPlcCfg.setMaxSize(1024 * 1024 * 1024); - - dbCfg.setMemoryPolicies(memPlcCfg); - dbCfg.setDefaultMemoryPolicyName(policyName); - - cfg.setMemoryConfiguration(dbCfg); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setCheckpointingFrequency(500) - .setAlwaysWriteFullPages(true) - ); - - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(ipFinder) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - stopAllGrids(); - - deleteWorkFiles(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - deleteWorkFiles(); - } - - /** - * @throws Exception if failed. - */ - public void testPageRecoveryAfterFileCorruption() throws Exception { - IgniteEx ig = startGrid(0); - - IgniteCache cache = ig.cache(cacheName); - - // Put for create data store and init meta page. - cache.put(1, 1); - - GridCacheSharedContext sharedCtx = ig.context().cache().context(); - - GridCacheDatabaseSharedManager psMgr = (GridCacheDatabaseSharedManager)sharedCtx.database(); - - FilePageStoreManager pageStore = (FilePageStoreManager)sharedCtx.pageStore(); - - U.sleep(1_000); - - // Disable integrated checkpoint thread. - psMgr.enableCheckpoints(false).get(); - - PageMemory mem = sharedCtx.database().memoryPolicy(policyName).pageMemory(); - - int cacheId = sharedCtx.cache().cache(cacheName).context().cacheId(); - - FullPageId[] pages = new FullPageId[totalPages]; - - for (int i = 0; i < totalPages; i++) - pages[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId); - - generateWal( - (PageMemoryImpl)mem, - sharedCtx.pageStore(), - sharedCtx.wal(), - cacheId, - pages - ); - - eraseDataFromDisk(pageStore, cacheId, pages[0]); - - stopAllGrids(); - - ig = startGrid(0); - - checkRestore(ig, pages); - } - - /** - * @param pageStore Page store. - * @param cacheId Cache id. - * @param page Page. - */ - private void eraseDataFromDisk( - FilePageStoreManager pageStore, - int cacheId, - FullPageId page - ) throws IgniteCheckedException, IOException { - PageStore store = pageStore.getStore( - cacheId, - PageIdUtils.partId(page.pageId()) - ); - - FilePageStore filePageStore = (FilePageStore)store; - - FileChannel ch = U.field(filePageStore, "ch"); - - long size = ch.size(); - - ch.write(ByteBuffer.allocate((int)size - FilePageStore.HEADER_SIZE), FilePageStore.HEADER_SIZE); - - ch.force(false); - } - - /** - * @param ig Ig. - * @param pages Pages. - */ - private void checkRestore(IgniteEx ig, FullPageId[] pages) throws IgniteCheckedException { - GridCacheSharedContext shared = ig.context().cache().context(); - - GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database(); - - dbMgr.enableCheckpoints(false).get(); - - PageMemory mem = shared.database().memoryPolicy(null).pageMemory(); - - for (FullPageId fullId : pages) { - long page = mem.acquirePage(fullId.cacheId(), fullId.pageId()); - - try { - long pageAddr = mem.readLock(fullId.cacheId(), fullId.pageId(), page); - - for (int j = PageIO.COMMON_HEADER_END; j < mem.pageSize(); j += 4) - assertEquals(j + (int)fullId.pageId(), PageUtils.getInt(pageAddr, j)); - - mem.readUnlock(fullId.cacheId(), fullId.pageId(), page); - } - finally { - mem.releasePage(fullId.cacheId(), fullId.pageId(), page); - } - } - } - - /** - * @param mem Mem. - * @param storeMgr Store manager. - * @param wal Wal. - * @param cacheId Cache id. - * @param pages Pages. - */ - private void generateWal( - final PageMemoryImpl mem, - final IgnitePageStoreManager storeMgr, - final IgniteWriteAheadLogManager wal, - final int cacheId, FullPageId[] pages - ) throws Exception { - // Mark the start position. - CheckpointRecord cpRec = new CheckpointRecord(null, false); - - WALPointer start = wal.log(cpRec); - - wal.fsync(start); - - for (int i = 0; i < totalPages; i++) { - FullPageId fullId = pages[i]; - - long page = mem.acquirePage(fullId.cacheId(), fullId.pageId()); - - try { - long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page); - - PageIO.setPageId(pageAddr, fullId.pageId()); - - try { - for (int j = PageIO.COMMON_HEADER_END; j < mem.pageSize(); j += 4) - PageUtils.putInt(pageAddr, j, j + (int)fullId.pageId()); - } - finally { - mem.writeUnlock(fullId.cacheId(), fullId.pageId(), page, null, true); - } - } - finally { - mem.releasePage(fullId.cacheId(), fullId.pageId(), page); - } - } - - Collection pageIds = mem.beginCheckpoint(); - - info("Acquired pages for checkpoint: " + pageIds.size()); - - try { - ByteBuffer tmpBuf = ByteBuffer.allocate(mem.pageSize()); - - tmpBuf.order(ByteOrder.nativeOrder()); - - long begin = System.currentTimeMillis(); - - long cp = 0; - - long write = 0; - - for (int i = 0; i < totalPages; i++) { - FullPageId fullId = pages[i]; - - if (pageIds.contains(fullId)) { - long cpStart = System.nanoTime(); - - Integer tag = mem.getForCheckpoint(fullId, tmpBuf, null); - - if (tag == null) - continue; - - long cpEnd = System.nanoTime(); - - cp += cpEnd - cpStart; - tmpBuf.rewind(); - - for (int j = PageIO.COMMON_HEADER_END; j < mem.pageSize(); j += 4) - assertEquals(j + (int)fullId.pageId(), tmpBuf.getInt(j)); - - tmpBuf.rewind(); - - long writeStart = System.nanoTime(); - - storeMgr.write(cacheId, fullId.pageId(), tmpBuf, tag); - - long writeEnd = System.nanoTime(); - - write += writeEnd - writeStart; - - tmpBuf.rewind(); - } - } - - long syncStart = System.currentTimeMillis(); - - storeMgr.sync(cacheId, 0); - - long end = System.currentTimeMillis(); - - info("Written pages in " + (end - begin) + "ms, copy took " + (cp / 1_000_000) + "ms, " + - "write took " + (write / 1_000_000) + "ms, sync took " + (end - syncStart) + "ms"); - } - finally { - info("Finishing checkpoint..."); - - mem.finishCheckpoint(); - - info("Finished checkpoint"); - } - - wal.fsync(wal.log(new CheckpointRecord(null, false))); - - for (FullPageId fullId : pages) { - long page = mem.acquirePage(fullId.cacheId(), fullId.pageId()); - - try { - assertFalse("Page has a temp heap copy after the last checkpoint: [cacheId=" + - fullId.cacheId() + ", pageId=" + fullId.pageId() + "]", mem.hasTempCopy(page)); - - assertFalse("Page is dirty after the last checkpoint: [cacheId=" + - fullId.cacheId() + ", pageId=" + fullId.pageId() + "]", mem.isDirty(fullId.cacheId(), fullId.pageId(), page)); - } - finally { - mem.releasePage(fullId.cacheId(), fullId.pageId(), page); - } - } - } - - /** - * - */ - private void deleteWorkFiles() throws IgniteCheckedException { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRemoveDuringRebalancingTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRemoveDuringRebalancingTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRemoveDuringRebalancingTest.java deleted file mode 100644 index 79d8e40..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsRemoveDuringRebalancingTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.cache.database; - -import java.io.File; -import java.util.concurrent.Callable; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.internal.util.typedef.internal.U; -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.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class IgnitePdsRemoveDuringRebalancingTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setCacheConfiguration( - new CacheConfiguration() - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) - .setBackups(1) - .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) - .setRebalanceMode(CacheRebalanceMode.SYNC) - ); - - MemoryConfiguration dbCfg = new MemoryConfiguration(); - - dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4); - dbCfg.setPageSize(1024); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - - memPlcCfg.setName("dfltMemPlc"); - memPlcCfg.setInitialSize(100 * 1024 * 1024); - memPlcCfg.setMaxSize(100 * 1024 * 1024); - memPlcCfg.setSwapFilePath("db"); - - dbCfg.setMemoryPolicies(memPlcCfg); - dbCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - - cfg.setMemoryConfiguration(dbCfg); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(IP_FINDER) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - stopAllGrids(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - - U.delete(new File(U.getIgniteHome(), "db")); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - G.stopAll(true); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - - U.delete(new File(U.getIgniteHome(), "db")); - } - - /** - * @throws Exception if failed. - */ - public void testRemovesDuringRebalancing() throws Exception { - IgniteEx ig = startGrid(0); - - try (IgniteDataStreamer streamer = ig.dataStreamer(null)) { - streamer.allowOverwrite(true); - - for (int i = 0; i < 100_000; i++) - streamer.addData(i, i); - } - - final IgniteCache cache = ig.cache(null); - - IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { - @Override public Object call() throws Exception { - return startGrid(1); - } - }); - - for (int i = 0; i < 100_000; i++) - cache.remove(i); - - fut.get(); - - IgniteEx another = grid(1); - - IgniteCache cache1 = another.cache(null); - - for (int i = 0; i < 100_000; i++) - assertNull(cache1.localPeek(i)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodePutGetPersistenceTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodePutGetPersistenceTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodePutGetPersistenceTest.java deleted file mode 100644 index d92ac25..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodePutGetPersistenceTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.cache.database; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.processors.database.IgniteDbSingleNodePutGetTest; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * - */ -public class IgnitePdsSingleNodePutGetPersistenceTest extends IgniteDbSingleNodePutGetTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - - super.beforeTest(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java deleted file mode 100644 index 257e0e8..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.cache.database; - -import org.apache.ignite.cache.affinity.AffinityFunction; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; - -/** - * - */ -public class IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest - extends IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest { - /** {@inheritDoc} */ - @Override protected void configure(IgniteConfiguration cfg) { - super.configure(cfg); - - for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { - AffinityFunction aff = ccfg.getAffinity(); - - int parts = aff != null ? aff.partitions() : RendezvousAffinityFunction.DFLT_PARTITION_COUNT; - - ccfg.setGroupName("testGroup-parts" + parts); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.java deleted file mode 100644 index a18ba75..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.cache.database; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingPutGetTest; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * - */ -public class IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest extends IgniteDbSingleNodeWithIndexingPutGetTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setPersistentStoreConfiguration( - new PersistentStoreConfiguration() - .setWalMode(WALMode.LOG_ONLY) - ); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - - super.beforeTestsStarted(); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - super.afterTestsStopped(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsTxCacheRebalancingTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsTxCacheRebalancingTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsTxCacheRebalancingTest.java deleted file mode 100644 index f29807e..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePdsTxCacheRebalancingTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.cache.database; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.configuration.CacheConfiguration; - -/** - * - */ -public class IgnitePdsTxCacheRebalancingTest extends IgnitePdsCacheRebalancingAbstractTest { - /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String cacheName) { - CacheConfiguration ccfg = new CacheConfiguration(cacheName); - - ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - ccfg.setCacheMode(CacheMode.PARTITIONED); - ccfg.setRebalanceMode(CacheRebalanceMode.SYNC); - ccfg.setBackups(1); - ccfg.setRebalanceDelay(10_000); - ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); - ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - - return ccfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - explicitTx = false; - } - - /** - * @throws Exception If failed. - */ - public void testTopologyChangesWithConstantLoadExplicitTx() throws Exception { - explicitTx = true; - - testTopologyChangesWithConstantLoad(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java deleted file mode 100644 index 79d4a4d..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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.cache.database; - -import java.io.Serializable; -import java.util.Objects; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.MemoryMetrics; -import org.apache.ignite.PersistenceMetrics; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.query.annotations.QuerySqlField; -import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.PAX; -import org.apache.ignite.internal.util.typedef.internal.S; -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.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * - */ -public class IgnitePersistenceMetricsSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final String GROUP1 = "grp1"; - - /** */ - private boolean activeOnStart = true; - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - GridTestUtils.deleteDbFiles(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - GridTestUtils.deleteDbFiles(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setConsistentId(gridName); - - cfg.setActiveOnStart(activeOnStart); - - MemoryConfiguration memCfg = new MemoryConfiguration(); - memCfg.setPageSize(1024); - - memCfg.setDefaultMemoryPolicyName("dflt-plc"); - - MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration(); - memPlc.setName("dflt-plc"); - memPlc.setMaxSize(10 * 1024 * 1024); - memPlc.setMetricsEnabled(true); - - memCfg.setMemoryPolicies(memPlc); - - cfg.setMemoryConfiguration(memCfg); - - cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration() - .setMetricsEnabled(true).setWalMode(WALMode.LOG_ONLY)); - - cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false)); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - cfg.setCacheConfiguration(cacheConfiguration(GROUP1, "cache", PARTITIONED, ATOMIC, 1)); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - GridTestUtils.deleteDbFiles(); - - super.afterTest(); - } - - /** - * @param grpName Cache group name. - * @param name Cache name. - * @param cacheMode Cache mode. - * @param atomicityMode Atomicity mode. - * @param backups Backups number. - * @return Cache configuration. - */ - private CacheConfiguration cacheConfiguration( - String grpName, - String name, - CacheMode cacheMode, - CacheAtomicityMode atomicityMode, - int backups - ) { - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setName(name); - ccfg.setGroupName(grpName); - ccfg.setAtomicityMode(atomicityMode); - ccfg.setBackups(backups); - ccfg.setCacheMode(cacheMode); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - - return ccfg; - } - - /** - * @throws Exception if failed. - */ - public void testPersistenceMetrics() throws Exception { - final IgniteEx ig = startGrid(0); - - try { - IgniteCache cache = ig.cache("cache"); - - for (int i = 0; i < 10; i++) - cache.put(i, new Person("first-" + i, "last-" + i)); - - { - MemoryMetrics memMetrics = ig.memoryMetrics("dflt-plc"); - - assertNotNull(memMetrics); - assertTrue(memMetrics.getDirtyPages() > 0); - } - - ig.context().cache().context().database().waitForCheckpoint("test"); - - GridTestUtils.waitForCondition(new PAX() { - @Override public boolean applyx() { - PersistenceMetrics pMetrics = ig.persistentStoreMetrics(); - - assertNotNull(pMetrics); - - return pMetrics.getLastCheckpointTotalPagesNumber() != 0 && - pMetrics.getLastCheckpointDataPagesNumber() != 0; - } - }, 5_000); - } - finally { - stopAllGrids(); - } - } - - /** - * - */ - static class Person implements Serializable { - /** */ - @GridToStringInclude - @QuerySqlField(index = true, groups = "full_name") - private String fName; - - /** */ - @GridToStringInclude - @QuerySqlField(index = true, groups = "full_name") - private String lName; - - /** - * @param fName First name. - * @param lName Last name. - */ - public Person(String fName, String lName) { - this.fName = fName; - this.lName = lName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(Person.class, this); - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - Person person = (Person)o; - - return Objects.equals(fName, person.fName) && - Objects.equals(lName, person.lName); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return Objects.hash(fName, lName); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreCacheGroupsTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreCacheGroupsTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreCacheGroupsTest.java deleted file mode 100644 index 4a0ae15..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreCacheGroupsTest.java +++ /dev/null @@ -1,508 +0,0 @@ -/* - * 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.cache.database; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; -import javax.cache.Cache; -import javax.cache.expiry.ExpiryPolicy; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.query.SqlQuery; -import org.apache.ignite.cache.query.annotations.QuerySqlField; -import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.MemoryConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.internal.S; -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.GridTestUtils; -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.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * - */ -public class IgnitePersistentStoreCacheGroupsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final String GROUP1 = "grp1"; - - /** */ - private static final String GROUP2 = "grp2"; - - /** */ - private CacheConfiguration[] ccfgs; - - /** */ - private boolean activeOnStart = true; - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - GridTestUtils.deleteDbFiles(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - GridTestUtils.deleteDbFiles(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setConsistentId(gridName); - - cfg.setActiveOnStart(activeOnStart); - - MemoryConfiguration memCfg = new MemoryConfiguration(); - memCfg.setPageSize(1024); - memCfg.setDefaultMemoryPolicySize(10 * 1024 * 1024); - - cfg.setMemoryConfiguration(memCfg); - - cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration().setWalMode(WALMode.LOG_ONLY)); - - cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false)); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - if (ccfgs != null) { - cfg.setCacheConfiguration(ccfgs); - - ccfgs = null; - } - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - GridTestUtils.deleteDbFiles(); - - super.afterTest(); - } - - /** - * @throws Exception If failed. - */ - public void testClusterRestartStaticCaches1() throws Exception { - clusterRestart(1, true); - } - - /** - * @throws Exception If failed. - */ - public void testClusterRestartStaticCaches2() throws Exception { - clusterRestart(3, true); - } - - /** - * @throws Exception If failed. - */ - public void testClusterRestartDynamicCaches1() throws Exception { - clusterRestart(1, false); - } - - /** - * @throws Exception If failed. - */ - public void testClusterRestartDynamicCaches2() throws Exception { - clusterRestart(3, false); - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - public void testClusterRestartCachesWithH2Indexes() throws Exception { - CacheConfiguration[] ccfgs1 = new CacheConfiguration[5]; - - // Several caches with the same indexed type (and index names). - ccfgs1[0] = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1). - setIndexedTypes(Integer.class, Person.class); - ccfgs1[1] = cacheConfiguration(GROUP1, "c2", PARTITIONED, TRANSACTIONAL, 1). - setIndexedTypes(Integer.class, Person.class); - ccfgs1[2] = cacheConfiguration(GROUP2, "c3", PARTITIONED, ATOMIC, 1). - setIndexedTypes(Integer.class, Person.class); - ccfgs1[3] = cacheConfiguration(GROUP2, "c4", PARTITIONED, TRANSACTIONAL, 1). - setIndexedTypes(Integer.class, Person.class); - ccfgs1[4] = cacheConfiguration(null, "c5", PARTITIONED, ATOMIC, 1). - setIndexedTypes(Integer.class, Person.class); - - String[] caches = {"c1", "c2", "c3", "c4", "c5"}; - - startGrids(3); - - Ignite node = ignite(0); - - node.createCaches(Arrays.asList(ccfgs1)); - - putPersons(caches, node); - - checkPersons(caches, node); - checkPersonsQuery(caches, node); - - stopAllGrids(); - - startGrids(3); - - awaitPartitionMapExchange(); - - node = ignite(0); - - checkPersons(caches, node); - checkPersonsQuery(caches, node); - - Random rnd = ThreadLocalRandom.current(); - - int idx = rnd.nextInt(caches.length); - - String cacheName = caches[idx]; - CacheConfiguration cacheCfg = ccfgs1[idx]; - - node.destroyCache(cacheName); - - node.createCache(cacheCfg); - - putPersons(new String[]{cacheName}, node); - - checkPersons(caches, node); - checkPersonsQuery(caches, node); - } - - /** - * @throws Exception If failed. - */ - public void _testExpiryPolicy() throws Exception { - long ttl = 10000; - - activeOnStart = false; - - CacheConfiguration[] ccfgs1 = new CacheConfiguration[5]; - - ccfgs1[0] = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1); - ccfgs1[1] = cacheConfiguration(GROUP1, "c2", PARTITIONED, TRANSACTIONAL, 1); - ccfgs1[2] = cacheConfiguration(GROUP2, "c3", PARTITIONED, ATOMIC, 1); - ccfgs1[3] = cacheConfiguration(GROUP2, "c4", PARTITIONED, TRANSACTIONAL, 1); - ccfgs1[4] = cacheConfiguration(null, "c5", PARTITIONED, ATOMIC, 1); - - String[] caches = {"c1", "c2", "c3", "c4", "c5"}; - - startGrids(3); - - Ignite node = ignite(0); - - node.active(true); - - node.createCaches(Arrays.asList(ccfgs1)); - - ExpiryPolicy plc = new PlatformExpiryPolicy(ttl, -2, -2); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName).withExpiryPolicy(plc); - - for (int i = 0; i < 10; i++) - cache.put(i, cacheName + i); - } - - long deadline = System.currentTimeMillis() + (long)(ttl * 1.2); - - stopAllGrids(); - - startGrids(3); - - node = ignite(0); - - node.active(true); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - for (int i = 0; i < 10; i++) - assertEquals(cacheName + i, cache.get(i)); - - assertEquals(10, cache.size()); - } - - // Wait for expiration. - Thread.sleep(Math.max(deadline - System.currentTimeMillis(), 0)); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - assertEquals(0, cache.size()); - } - } - - /** - * @throws Exception If failed. - */ - public void testCreateDropCache() throws Exception { - ccfgs = new CacheConfiguration[]{cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1) - .setIndexedTypes(Integer.class, Person.class)}; - - Ignite ignite = startGrid(); - - ignite.cache("c1").destroy(); - - stopGrid(); - } - - /** - * @throws Exception If failed. - */ - public void testCreateDropCache1() throws Exception { - CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1); - - CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, "c2", PARTITIONED, ATOMIC, 1); - - Ignite ignite = startGrid(); - - ignite.createCaches(Arrays.asList(ccfg1, ccfg2)); - - - ignite.cache("c1").destroy(); - - ignite.cache("c2").destroy(); - - ignite.createCache(ccfg1); - ignite.createCache(ccfg2); - - stopGrid(); - } - - /** - * @throws Exception If failed. - */ - public void testCreateDropCache2() throws Exception { - CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1) - .setIndexedTypes(Integer.class, Person.class); - - CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, "c2", PARTITIONED, ATOMIC, 1) - .setIndexedTypes(Integer.class, Person.class); - - Ignite ignite = startGrid(); - - ignite.createCaches(Arrays.asList(ccfg1, ccfg2)); - - ignite.cache("c1").destroy(); - - ignite.createCache(ccfg1); - - stopGrid(); - } - - /** - * @param caches Cache names to put data into. - * @param node Ignite node. - */ - private void putPersons(String[] caches, Ignite node) { - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - for (int i = 0; i < 10; i++) - cache.put(i, new Person("" + i, cacheName)); - } - } - - /** - * @param caches Cache names to invoke a query against to. - * @param node Ignite node. - */ - private void checkPersons(String[] caches, Ignite node) { - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - for (int i = 0; i < 10; i++) - assertEquals(new Person("" + i, cacheName), cache.get(i)); - - assertEquals(10, cache.size()); - } - } - - /** - * @param caches Cache names to invoke a query against to. - * @param node Ignite node. - */ - private void checkPersonsQuery(String[] caches, Ignite node) { - SqlQuery qry = new SqlQuery<>( - Person.class, "SELECT p.* FROM Person p WHERE p.lname=? ORDER BY p.fname"); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - List> persons = cache.query(qry.setArgs(cacheName)).getAll(); - - for (int i = 0; i < 10; i++) - assertEquals(new Person("" + i, cacheName), persons.get(i).getValue()); - - assertEquals(10, persons.size()); - } - } - - /** - * @param nodes Nodes number. - * @param staticCaches {@code True} if caches should be statically configured. - * @throws Exception If failed. - */ - private void clusterRestart(int nodes, boolean staticCaches) throws Exception { - CacheConfiguration[] ccfgs = new CacheConfiguration[5]; - - ccfgs[0] = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1); - ccfgs[1] = cacheConfiguration(GROUP1, "c2", PARTITIONED, TRANSACTIONAL, 1); - ccfgs[2] = cacheConfiguration(GROUP2, "c3", PARTITIONED, ATOMIC, 1); - ccfgs[3] = cacheConfiguration(GROUP2, "c4", PARTITIONED, TRANSACTIONAL, 1); - ccfgs[4] = cacheConfiguration(null, "c5", PARTITIONED, ATOMIC, 1); - - String[] caches = {"c1", "c2", "c3", "c4", "c5"}; - - for (int i = 0; i < nodes; i++) { - if (staticCaches) - this.ccfgs = ccfgs; - - startGrid(i); - } - - Ignite node = ignite(0); - - if (!staticCaches) - node.createCaches(Arrays.asList(ccfgs)); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - for (int i = 0; i < 10; i++) { - cache.put(i, cacheName + i); - - assertEquals(cacheName + i, cache.get(i)); - } - - assertEquals(10, cache.size()); - } - - stopAllGrids(); - - node = startGrids(nodes); - - awaitPartitionMapExchange(); - - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - for (int i = 0; i < 10; i++) - assertEquals(cacheName + i, cache.get(i)); - - assertEquals(10, cache.size()); - } - } - - /** - * @param grpName Cache group name. - * @param name Cache name. - * @param cacheMode Cache mode. - * @param atomicityMode Atomicity mode. - * @param backups Backups number. - * @return Cache configuration. - */ - private CacheConfiguration cacheConfiguration( - String grpName, - String name, - CacheMode cacheMode, - CacheAtomicityMode atomicityMode, - int backups - ) { - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setName(name); - ccfg.setGroupName(grpName); - ccfg.setAtomicityMode(atomicityMode); - ccfg.setBackups(backups); - ccfg.setCacheMode(cacheMode); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - - return ccfg; - } - - /** - * - */ - static class Person implements Serializable { - /** */ - @GridToStringInclude - @QuerySqlField(index = true, groups = "full_name") - String fName; - - /** */ - @GridToStringInclude - @QuerySqlField(index = true, groups = "full_name") - String lName; - - /** - * @param fName First name. - * @param lName Last name. - */ - public Person(String fName, String lName) { - this.fName = fName; - this.lName = lName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(Person.class, this); - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Person person = (Person)o; - return Objects.equals(fName, person.fName) && - Objects.equals(lName, person.lName); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return Objects.hash(fName, lName); - } - } -}