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 A42D2200CC9 for ; Sun, 11 Jun 2017 22:03:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A2A34160B9C; Sun, 11 Jun 2017 20:03:36 +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 1292B160C08 for ; Sun, 11 Jun 2017 22:03:31 +0200 (CEST) Received: (qmail 61664 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 61188 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 E4820F4A63; 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:30 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/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/pagemem/FullPageIdTableTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/FullPageIdTableTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/FullPageIdTableTest.java deleted file mode 100644 index df212be..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/FullPageIdTableTest.java +++ /dev/null @@ -1,115 +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.pagemem; - -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import org.apache.ignite.internal.mem.DirectMemoryRegion; -import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.processors.cache.database.pagemem.FullPageIdTable; -import org.apache.ignite.internal.util.typedef.CI2; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.logger.java.JavaLogger; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class FullPageIdTableTest extends GridCommonAbstractTest { - /** */ - private static final int CACHE_ID_RANGE = 10; - - /** */ - private static final int PAGE_ID_RANGE = 1000; - - /** - * @throws Exception if failed. - */ - public void testRandomOperations() throws Exception { - long mem = FullPageIdTable.requiredMemory(CACHE_ID_RANGE * PAGE_ID_RANGE); - - UnsafeMemoryProvider prov = new UnsafeMemoryProvider(new JavaLogger()); - - prov.initialize(new long[] {mem}); - - DirectMemoryRegion region = prov.nextRegion(); - - try { - long seed = U.currentTimeMillis(); - - info("Seed: " + seed + "L; //"); - - Random rnd = new Random(seed); - - FullPageIdTable tbl = new FullPageIdTable(region.address(), region.size(), true); - - Map check = new HashMap<>(); - - for (int i = 0; i < 10_000; i++) { - int cacheId = rnd.nextInt(CACHE_ID_RANGE) + 1; - int pageId = rnd.nextInt(PAGE_ID_RANGE); - - FullPageId fullId = new FullPageId(pageId, cacheId); - - boolean put = rnd.nextInt(3) != -1; - - if (put) { - long val = rnd.nextLong(); - - tbl.put(cacheId, pageId, val, 0); - check.put(fullId, val); - } - else { - tbl.remove(cacheId, pageId, 0); - check.remove(fullId); - } - - verifyLinear(tbl, check); - - if (i > 0 && i % 1000 == 0) - info("Done: " + i); - } - } - finally { - prov.shutdown(); - } - } - - /** - * @param tbl Table to check. - * @param check Expected mapping. - */ - private void verifyLinear(FullPageIdTable tbl, Map check) { - final Map collector = new HashMap<>(); - - tbl.visitAll(new CI2() { - @Override public void apply(FullPageId fullId, Long val) { - if (collector.put(fullId, val) != null) - throw new AssertionError("Duplicate full page ID mapping: " + fullId); - } - }); - - assertEquals("Size check failed", check.size(), collector.size()); - - for (Map.Entry entry : check.entrySet()) - assertEquals("Mapping comparison failed for key: " + entry.getKey(), - entry.getValue(), collector.get(entry.getKey())); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java deleted file mode 100644 index a6e241c..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java +++ /dev/null @@ -1,104 +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.pagemem; - -import java.io.File; -import java.nio.ByteBuffer; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.internal.mem.DirectMemoryProvider; -import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageMemory; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker; -import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager; -import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl; -import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest; -import org.apache.ignite.internal.util.lang.GridInClosure3X; -import org.apache.ignite.internal.util.typedef.CIX3; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.junits.GridTestKernalContext; - -/** - * - */ -public class MetadataStoragePageMemoryImplTest extends MetadataStorageSelfTest{ - /** Make sure page is small enough to trigger multiple pages in a linked list. */ - public static final int PAGE_SIZE = 1024; - - /** */ - private static File allocationPath; - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - allocationPath = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false); - } - - /** - * @param clean Clean flag. If {@code true}, will clean previous memory state and allocate - * new empty page memory. - * @return Page memory instance. - */ - @Override protected PageMemory memory(boolean clean) throws Exception { - long[] sizes = new long[10]; - - for (int i = 0; i < sizes.length; i++) - sizes[i] = 1024 * 1024; - - DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath); - - GridCacheSharedContext sharedCtx = new GridCacheSharedContext<>( - new GridTestKernalContext(log), - null, - null, - null, - new NoOpPageStoreManager(), - new NoOpWALManager(), - new IgniteCacheDatabaseSharedManager(), - null, - null, - null, - null, - null, - null, - null, - null - ); - - return new PageMemoryImpl( - provider, sizes, - sharedCtx, - PAGE_SIZE, - new CIX3() { - @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) { - assert false : "No evictions should happen during the test"; - } - }, - new GridInClosure3X() { - @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) { - } - }, new CheckpointLockStateChecker() { - @Override public boolean checkpointLockIsHeldByThread() { - return true; - } - }, - new MemoryMetricsImpl(new MemoryPolicyConfiguration())); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java deleted file mode 100644 index 144bbef..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java +++ /dev/null @@ -1,200 +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.pagemem; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageIdUtils; -import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; -import org.apache.ignite.internal.processors.cache.CacheGroupContext; -import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.StoredCacheData; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.lang.IgniteFuture; - -/** - * - */ -public class NoOpPageStoreManager implements IgnitePageStoreManager { - /** */ - private ConcurrentMap allocators = new ConcurrentHashMap<>(); - - /** {@inheritDoc} */ - @Override public void beginRecover() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void finishRecover() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void initializeForCache(CacheGroupDescriptor grpDesc, - StoredCacheData cacheData) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void shutdownForCacheGroup(CacheGroupContext grp, boolean destroy) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onPartitionCreated(int grpId, int partId) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onPartitionDestroyed(int cacheId, int partId, int tag) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void read(int cacheId, long pageId, ByteBuffer pageBuf) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public boolean exists(int cacheId, int partId) throws IgniteCheckedException { - return false; - } - - /** {@inheritDoc} */ - @Override public void readHeader(int cacheId, int partId, ByteBuffer buf) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void write(int cacheId, long pageId, ByteBuffer pageBuf, int tag) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void sync(int cacheId, int partId) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void ensure(int cacheId, int partId) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public long pageOffset(int cacheId, long pageId) throws IgniteCheckedException { - return 0; - } - - /** {@inheritDoc} */ - @Override public long allocatePage(int cacheId, int partId, byte flags) throws IgniteCheckedException { - long root = PageIdUtils.pageId(partId, flags, 0); - - FullPageId fullId = new FullPageId(root, cacheId); - - AtomicInteger allocator = allocators.get(fullId); - - if (allocator == null) - allocator = F.addIfAbsent(allocators, fullId, new AtomicInteger(1)); - - return PageIdUtils.pageId(partId, flags, allocator.getAndIncrement()); - } - - /** {@inheritDoc} */ - @Override public int pages(int cacheId, int partId) throws IgniteCheckedException { - long root = PageIdUtils.pageId(partId, (byte)0, 0); - - FullPageId fullId = new FullPageId(root, cacheId); - - AtomicInteger allocator = allocators.get(fullId); - - if (allocator == null) - allocator = F.addIfAbsent(allocators, fullId, new AtomicInteger(2)); - - return allocator.get(); - } - - /** {@inheritDoc} */ - @Override public long metaPageId(int cacheId) { - return 1; - } - - /** {@inheritDoc} */ - @Override public void start(GridCacheSharedContext cctx) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void stop(boolean cancel) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onKernalStart(boolean reconnect) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onKernalStop(boolean cancel) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onDisconnected(IgniteFuture reconnectFut) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void printMemoryStats() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public Map readCacheConfigurations() throws IgniteCheckedException { - return Collections.emptyMap(); - } - - /** {@inheritDoc} */ - @Override public void storeCacheData(CacheGroupDescriptor grpDesc, - StoredCacheData cacheData) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public boolean hasIndexStore(int grpId) { - return false; - } - - /** {@inheritDoc} */ - @Override public void onActivate(GridKernalContext kctx) { - - } - - /** {@inheritDoc} */ - @Override public void onDeActivate(GridKernalContext kctx) { - - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java deleted file mode 100644 index f3e1cd3..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java +++ /dev/null @@ -1,128 +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.pagemem; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.pagemem.wal.StorageException; -import org.apache.ignite.internal.pagemem.wal.WALIterator; -import org.apache.ignite.internal.pagemem.wal.WALPointer; -import org.apache.ignite.internal.pagemem.wal.record.WALRecord; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.lang.IgniteFuture; - -/** - * - */ -public class NoOpWALManager implements IgniteWriteAheadLogManager { - /** {@inheritDoc} */ - @Override public boolean isAlwaysWriteFullPages() { - return true; - } - - /** {@inheritDoc} */ - @Override public boolean isFullSync() { - return false; - } - - /** {@inheritDoc} */ - @Override public void resumeLogging(WALPointer ptr) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public WALPointer log(WALRecord entry) throws IgniteCheckedException, StorageException { - return null; - } - - /** {@inheritDoc} */ - @Override public void fsync(WALPointer ptr) throws IgniteCheckedException, StorageException { - - } - - /** {@inheritDoc} */ - @Override public WALIterator replay(WALPointer start) throws IgniteCheckedException, StorageException { - return null; - } - - /** {@inheritDoc} */ - @Override public boolean reserve(WALPointer start) throws IgniteCheckedException { - return false; - } - - /** {@inheritDoc} */ - @Override public void release(WALPointer start) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public int truncate(WALPointer ptr) { - return 0; - } - - /** {@inheritDoc} */ - @Override public boolean reserved(WALPointer ptr) { - return false; - } - - /** {@inheritDoc} */ - @Override public void start(GridCacheSharedContext cctx) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public void stop(boolean cancel) { - - } - - /** {@inheritDoc} */ - @Override public void onKernalStart(boolean reconnect) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public void onKernalStop(boolean cancel) { - - } - - /** {@inheritDoc} */ - @Override public void onDisconnected(IgniteFuture reconnectFut) { - - } - - /** {@inheritDoc} */ - @Override public void printMemoryStats() { - - } - - /** {@inheritDoc} */ - @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException { - - } - - /** {@inheritDoc} */ - @Override public int walArchiveSegments() { - return 0; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageIdDistributionTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageIdDistributionTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageIdDistributionTest.java deleted file mode 100644 index a37f981..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageIdDistributionTest.java +++ /dev/null @@ -1,234 +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.pagemem; - -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import org.apache.ignite.internal.mem.DirectMemoryRegion; -import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageIdUtils; -import org.apache.ignite.internal.processors.cache.database.pagemem.FullPageIdTable; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl; -import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.logger.java.JavaLogger; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class PageIdDistributionTest extends GridCommonAbstractTest { - /** */ - private static final int[] CACHE_IDS = new int[] { - CU.cacheId("partitioned1"), - CU.cacheId("partitioned2"), - CU.cacheId("partitioned3"), - CU.cacheId("partitioned4"), - CU.cacheId("replicated1"), - CU.cacheId("replicated2"), - CU.cacheId("replicated3"), - CU.cacheId("replicated4"), - }; - - /** */ - private static final int PARTS = 1024; - - /** */ - private static final int PAGES = 10240; - - /** - * - */ - public void testDistributions() { - printPageIdDistribution( - CU.cacheId("partitioned"), 1024, 30_000, 32, 2.5f); - - printPageIdDistribution( - CU.cacheId("partitioned"), 1024, 30_000, 64, 2.5f); - - printPageIdDistribution( - CU.cacheId(null), 1024, 30_000, 32, 2.5f); - } - - /** - * @param cacheId Cache id. - * @param parts Parts. - * @param pagesPerPartition Pages per partition. - * @param segments Segments. - * @param capFactor Capacity factor. - */ - private void printPageIdDistribution( - int cacheId, - int parts, - int pagesPerPartition, - int segments, - float capFactor - ) { - int allIds = parts * pagesPerPartition; - - int perSegmentSize = allIds / segments; - int capacity = (int)(perSegmentSize * capFactor); - - info("Total ids: " + allIds); - - List> collisionsPerSegment = new ArrayList<>(segments); - - for (int i = 0; i < segments; i++) - collisionsPerSegment.add(new HashMap(allIds / segments, 1.0f)); - - int[] numInSegment = new int[segments]; - - for (int p = 0; p < parts; p++) { - for (int i = 0; i < pagesPerPartition; i++) { - long pageId = PageIdUtils.pageId(p, (byte)0, i); - - int segment = PageMemoryImpl.segmentIndex(cacheId, pageId, segments); - - int idxInSegment = U.safeAbs(FullPageId.hashCode(cacheId, pageId)) % capacity; - - Map idxCollisions = collisionsPerSegment.get(segment); - - Integer old = idxCollisions.get(idxInSegment); - idxCollisions.put(idxInSegment, old == null ? 1 : old + 1); - - numInSegment[segment]++; - } - } - - for (int i = 0; i < collisionsPerSegment.size(); i++) { - Map idxCollisions = collisionsPerSegment.get(i); - - int distinctPositions = idxCollisions.size(); - - int totalCnt = 0; - int nonZero = 0; - - for (Map.Entry collision : idxCollisions.entrySet()) { - if (collision.getValue() != null) { - totalCnt += collision.getValue(); - nonZero++; - } - } - - info(String.format("Segment stats [i=%d, total=%d, distinct=%d, spaceUsed=%d%%, avgItCnt=%.1f + ']", - i, numInSegment[i], distinctPositions, distinctPositions * 100 / numInSegment[i], - (float)totalCnt / nonZero)); - } - - info("=========================================================="); - } - - /** - * Uncomment and run this test manually to get data to plot histogram for per-element distance from ideal. - * You can use Octave to plot the histogram: - *
-     *     all = csvread("histo.txt");
-     *     hist(all, 200)
-     * 
- * - * @throws Exception If failed. - */ - public void _testRealHistory() throws Exception { - int capacity = CACHE_IDS.length * PARTS * PAGES; - - info("Capacity: " + capacity); - - long mem = FullPageIdTable.requiredMemory(capacity); - - info(U.readableSize(mem, true)); - - UnsafeMemoryProvider prov = new UnsafeMemoryProvider(new JavaLogger()); - - prov.initialize(new long[] {mem}); - - DirectMemoryRegion region = prov.nextRegion(); - - try { - long seed = U.currentTimeMillis(); - - info("Seed: " + seed + "L; //"); - - Random rnd = new Random(seed); - - FullPageIdTable tbl = new FullPageIdTable(region.address(), region.size(), true); - - Map, Integer> allocated = new HashMap<>(); - - for (int i = 0; i < capacity; i++) { - int cacheId = CACHE_IDS[rnd.nextInt(CACHE_IDS.length)]; - int partId = rnd.nextInt(PARTS); - - T2 key = new T2<>(cacheId, partId); - - Integer pageIdx = allocated.get(key); - - pageIdx = pageIdx == null ? 1 : pageIdx + 1; - - if (pageIdx > PAGES) - continue; - - tbl.put(cacheId, PageIdUtils.pageId(partId, (byte)0, pageIdx), 1, 0); - - allocated.put(key, pageIdx); - - if (i > 0 && i % 100_000 == 0) - info("Done: " + i); - } - - int[] scans = new int[capacity]; - - int cur = 0; - - for (T2 key : allocated.keySet()) { - Integer alloc = allocated.get(key); - - if (alloc != null) { - for (int idx = 1; idx <= alloc; idx++) { - scans[cur] = tbl.distanceFromIdeal(key.get1(), PageIdUtils.pageId(key.get2(), (byte)0, idx), 0); - - assert scans[cur] != -1; - - cur++; - } - } - } - - try (FileOutputStream out = new FileOutputStream("histo.txt")) { - PrintWriter w = new PrintWriter(new OutputStreamWriter(out)); - - for (int scan : scans) { - if (scan != 0) - w.println(scan); - } - - w.flush(); - } - } - finally { - prov.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java deleted file mode 100644 index 38baea8..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java +++ /dev/null @@ -1,100 +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.pagemem; - -import java.io.File; -import java.nio.ByteBuffer; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.internal.mem.DirectMemoryProvider; -import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageMemory; -import org.apache.ignite.internal.pagemem.impl.PageMemoryNoLoadSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker; -import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl; -import org.apache.ignite.internal.util.lang.GridInClosure3X; -import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager; -import org.apache.ignite.internal.util.typedef.CIX3; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.junits.GridTestKernalContext; - -/** - * - */ -public class PageMemoryImplNoLoadTest extends PageMemoryNoLoadSelfTest { - /** - * @return Page memory implementation. - */ - @Override protected PageMemory memory() throws Exception { - File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false); - - long[] sizes = new long[10]; - - for (int i = 0; i < sizes.length; i++) - sizes[i] = 5 * 1024 * 1024; - - DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir); - - GridCacheSharedContext sharedCtx = new GridCacheSharedContext<>( - new GridTestKernalContext(log), - null, - null, - null, - new NoOpPageStoreManager(), - new NoOpWALManager(), - new IgniteCacheDatabaseSharedManager(), - null, - null, - null, - null, - null, - null, - null, - null - ); - - return new PageMemoryImpl( - provider, - sizes, - sharedCtx, - PAGE_SIZE, - new CIX3() { - @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuffer, Integer tag) { - assert false : "No evictions should happen during the test"; - } - }, - new GridInClosure3X() { - @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) { - } - }, - new CheckpointLockStateChecker() { - @Override public boolean checkpointLockIsHeldByThread() { - return true; - } - }, - new MemoryMetricsImpl(new MemoryPolicyConfiguration())); - } - - /** {@inheritDoc} */ - @Override public void testPageHandleDeallocation() throws Exception { - // No-op. - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java deleted file mode 100644 index b5e4549..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java +++ /dev/null @@ -1,121 +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.pagemem; - -import java.nio.ByteBuffer; -import org.apache.ignite.configuration.MemoryPolicyConfiguration; -import org.apache.ignite.internal.mem.DirectMemoryProvider; -import org.apache.ignite.internal.mem.IgniteOutOfMemoryException; -import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider; -import org.apache.ignite.internal.pagemem.FullPageId; -import org.apache.ignite.internal.pagemem.PageIdAllocator; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker; -import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager; -import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx; -import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl; -import org.apache.ignite.internal.util.lang.GridInClosure3X; -import org.apache.ignite.internal.util.typedef.CIX3; -import org.apache.ignite.testframework.junits.GridTestKernalContext; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; - -/** - * - */ -public class PageMemoryImplTest extends GridCommonAbstractTest { - /** Mb. */ - private static final long MB = 1024 * 1024; - - /** Page size. */ - private static final int PAGE_SIZE = 1024; - - /** - * @throws Exception if failed. - */ - public void testThatAllocationTooMuchPagesCauseToOOMException() throws Exception { - PageMemoryImpl memory = createPageMemory(); - - try { - while (!Thread.currentThread().isInterrupted()) - memory.allocatePage(1, PageIdAllocator.INDEX_PARTITION, PageIdAllocator.FLAG_IDX); - } - catch (IgniteOutOfMemoryException ignore) { - //Success - } - - assertFalse(memory.safeToUpdate()); - } - - /** - * - */ - private PageMemoryImpl createPageMemory() throws Exception { - long[] sizes = new long[5]; - - for (int i = 0; i < sizes.length; i++) - sizes[i] = 1024 * MB / 4; - - sizes[4] = 10 * MB; - - DirectMemoryProvider provider = new UnsafeMemoryProvider(log); - - GridCacheSharedContext sharedCtx = new GridCacheSharedContext<>( - new GridTestKernalContext(new GridTestLog4jLogger()), - null, - null, - null, - new NoOpPageStoreManager(), - new NoOpWALManager(), - new IgniteCacheDatabaseSharedManager(), - null, - null, - null, - null, - null, - null, - null, - null - ); - - PageMemoryImpl mem = new PageMemoryImpl( - provider, - sizes, - sharedCtx, - PAGE_SIZE, - new CIX3() { - @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) { - assert false : "No evictions should happen during the test"; - } - }, - new GridInClosure3X() { - @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) { - } - }, new CheckpointLockStateChecker() { - @Override public boolean checkpointLockIsHeldByThread() { - return true; - } - }, - new MemoryMetricsImpl(new MemoryPolicyConfiguration())); - - mem.start(); - - return mem; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/AbstractNodeJoinTemplate.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/AbstractNodeJoinTemplate.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/AbstractNodeJoinTemplate.java deleted file mode 100644 index 112ea03..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/AbstractNodeJoinTemplate.java +++ /dev/null @@ -1,743 +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.standbycluster; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.PersistentStoreConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.lang.IgniteInClosure; -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 org.junit.Assert; - -import static org.apache.ignite.internal.util.IgniteUtils.field; - -/** - * - */ -public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest { - /** Cache 1. */ - protected static final String cache1 = "cache1"; - - /** Cache 2. */ - protected static final String cache2 = "cache2"; - - //Todo Cache with node filter. - protected static final String cache3 = "cache3"; - - protected static final String cache4 = "cache4"; - - protected static final String cache5 = "cache5"; - - /** Caches info. */ - public static final String CACHES_INFO = "cachesInfo"; - - /** Registered caches. */ - public static final String REGISTERED_CACHES = "registeredCaches"; - - /** Caches. */ - public static final String CACHES = "caches"; - - /** - * @param ig Ig. - */ - protected static Map cacheDescriptors(IgniteEx ig) { - return field(field(ig.context().cache(), CACHES_INFO), REGISTERED_CACHES); - } - - /** - * @param ig Ig. - */ - protected static Map caches(IgniteEx ig){ - return field(ig.context().cache(), CACHES); - } - - /** - * - */ - public abstract JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception; - - /** - * - */ - public abstract JoinNodeTestPlanBuilder staticCacheConfigurationOnJoinTemplate() throws Exception; - - /** - * - */ - public abstract JoinNodeTestPlanBuilder staticCacheConfigurationInClusterTemplate() throws Exception; - - /** - * - */ - public abstract JoinNodeTestPlanBuilder staticCacheConfigurationSameOnBothTemplate() throws Exception; - - /** - * - */ - public abstract JoinNodeTestPlanBuilder staticCacheConfigurationDifferentOnBothTemplate() throws Exception; - - // Client node join. - - public abstract JoinNodeTestPlanBuilder joinClientWithOutConfigurationTemplate() throws Exception; - - public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationOnJoinTemplate() throws Exception; - - public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationInClusterTemplate() throws Exception; - - public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationSameOnBothTemplate() throws Exception; - - public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationDifferentOnBothTemplate() throws Exception; - - /** - * - */ - public abstract void testJoinWithOutConfiguration() throws Exception; - - /** - * - */ - public abstract void testStaticCacheConfigurationOnJoin() throws Exception; - - /** - * - */ - public abstract void testStaticCacheConfigurationInCluster() throws Exception; - - /** - * - */ - public abstract void testStaticCacheConfigurationSameOnBoth() throws Exception; - - /** - * - */ - public abstract void testStaticCacheConfigurationDifferentOnBoth() throws Exception; - - /** - * - */ - public abstract void testJoinClientWithOutConfiguration() throws Exception; - - /** - * - */ - public abstract void testJoinClientStaticCacheConfigurationOnJoin() throws Exception; - - /** - * - */ - public abstract void testJoinClientStaticCacheConfigurationInCluster() throws Exception; - - /** - * - */ - public abstract void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception; - - /** - * - */ - public abstract void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception; - - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - stopAllGrids(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAllGrids(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); - } - - /** - * @param idx Index. - */ - protected String name(int idx) { - return getTestIgniteInstanceName(idx); - } - - /** - * @param name Name. - */ - protected IgniteConfiguration cfg(String name) throws Exception { - try { - return getConfiguration(name); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * - */ - protected JoinNodeTestPlanBuilder builder() { - return JoinNodeTestPlanBuilder.builder(); - } - - /** - * @param cfgs Cfgs. - */ - protected static T[] buildConfiguration(T... cfgs) { - return cfgs; - } - - /** - * - */ - protected CacheConfiguration atomicCfg() { - return new CacheConfiguration(cache1) - .setAtomicityMode(CacheAtomicityMode.ATOMIC); - } - - /** - * - */ - protected CacheConfiguration transactionCfg() { - return new CacheConfiguration(cache2) - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - } - - /** - * - */ - protected CacheConfiguration[] allCacheConfigurations() { - return buildConfiguration(atomicCfg(), transactionCfg()); - } - - /** Set client. */ - protected final IgniteClosure setClient = - new IgniteClosure() { - @Override public IgniteConfiguration apply(IgniteConfiguration cfg) { - return cfg.setClientMode(true); - } - }; - - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { - return super.getConfiguration(name) - .setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(ipFinder) - ); - } - - /** {@inheritDoc} */ - protected IgniteConfiguration persistentCfg(IgniteConfiguration cfg) throws Exception { - cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration()); - - return cfg; - } - - /** - * - */ - public static class JoinNodeTestPlanBuilder extends GridCommonAbstractTest { - /** String plan builder. */ - private final StringBuilder strPlanBuilder = new StringBuilder().append("**** Execution plan ****\n"); - - /** Nodes. */ - protected List nodes = new ArrayList<>(4); - - /** Cluster config. */ - private IgniteConfiguration[] clusterCfg; - - /** Node config. */ - private IgniteConfiguration nodeCfg; - - /** State default. */ - private static final Boolean stateDefault = new Boolean(true); - - /** State. */ - private Boolean state = stateDefault; - - /** Noop. */ - private static final Runnable Noop = new Runnable() { - @Override public void run() { - } - }; - - /** After cluster started. */ - private Runnable afterClusterStarted = Noop; - - /** After node join. */ - private Runnable afterNodeJoin = Noop; - - /** After activate. */ - private Runnable afterActivate = Noop; - - /** After de activate. */ - private Runnable afterDeActivate = Noop; - - private IgniteCallable> dynamicCacheStart = - new IgniteCallable>() { - @Override public List call() throws Exception { - return Arrays.asList(new CacheConfiguration(cache4), new CacheConfiguration(cache5)); - } - }; - - private IgniteCallable> dynamicCacheStop = - new IgniteCallable>() { - @Override public List call() throws Exception { - return Arrays.asList(cache4, cache5); - } - }; - - private Runnable afterDynamicCacheStarted = Noop; - - private Runnable afterDynamicCacheStopped = Noop; - - /** End. */ - private Runnable end = Noop; - - /** - * - */ - public JoinNodeTestPlanBuilder clusterConfiguration(IgniteConfiguration... cfgs) throws Exception { - clusterCfg = cfgs; - - strPlanBuilder.append("Start cluster:\n"); - - for (IgniteConfiguration cfg : cfgs) { - strPlanBuilder.append("node: ") - .append(cfg.getIgniteInstanceName()) - .append(" activeOnStart - ") - .append(cfg.isActiveOnStart()) - .append("\n"); - - CacheConfiguration[] ccfgs = cfg.getCacheConfiguration(); - - if (ccfgs != null) { - for (CacheConfiguration ccfg : ccfgs) - strPlanBuilder.append(" cache - ") - .append(ccfg.getName()) - .append("\n"); - } - } - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder nodeConfiguration(IgniteConfiguration cfg) { - nodeCfg = cfg; - - strPlanBuilder.append("Join node:\n") - .append(cfg.getIgniteInstanceName()) - .append(cfg.isClientMode() != null && cfg.isClientMode() ? " (client)" : "") - .append(" activeOnStart - ") - .append(cfg.isActiveOnStart()) - .append("\n"); - - CacheConfiguration[] ccfgs = cfg.getCacheConfiguration(); - - if (ccfgs != null) - for (CacheConfiguration ccfg : ccfgs) - strPlanBuilder.append(" cache - ").append(ccfg.getName()).append("\n"); - - return this; - } - - /** - * @param func Func. - */ - public JoinNodeTestPlanBuilder nodeConfiguration( - IgniteClosure func - ) { - - nodeCfg = func.apply(nodeCfg); - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder afterClusterStarted(Runnable r) { - strPlanBuilder.append("Check after cluster start\n"); - - afterClusterStarted = r; - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder afterNodeJoin(Runnable r) { - strPlanBuilder.append("Check after node join") - .append("\n"); - - afterNodeJoin = r; - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder stateAfterJoin(boolean state) { - strPlanBuilder.append("Check state on all nodes after join, must be ") - .append(state ? "<>" : "<>") - .append(" \n"); - - this.state = state; - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder afterActivate(Runnable r) { - strPlanBuilder.append("Check after activate") - .append("\n"); - - afterActivate = r; - - return this; - } - - /** - * - */ - public JoinNodeTestPlanBuilder afterDeActivate(Runnable r) { - strPlanBuilder.append("Check after deActivate") - .append("\n"); - - afterDeActivate = r; - - return this; - } - - public JoinNodeTestPlanBuilder dynamicCacheStart(IgniteCallable> caches){ - strPlanBuilder.append("Dynamic caches start") - .append("\n"); - - dynamicCacheStart = caches; - - return this; - } - - public JoinNodeTestPlanBuilder afterDynamicCacheStarted(Runnable r){ - strPlanBuilder.append("Check after dynamic caches start") - .append("\n"); - - afterDynamicCacheStarted = r; - - return this; - } - - public JoinNodeTestPlanBuilder dynamicCacheStop(IgniteCallable> caches){ - strPlanBuilder.append("Dynamic caches stop") - .append("\n"); - - dynamicCacheStop = caches; - - return this; - } - - public JoinNodeTestPlanBuilder afterDynamicCacheStopped(Runnable r){ - strPlanBuilder.append("Check after dynamic caches stop") - .append("\n"); - - afterDynamicCacheStopped = r; - - return this; - } - - /** - * @param end End. - */ - public JoinNodeTestPlanBuilder setEnd(Runnable end) { - strPlanBuilder.append("Check before stop") - .append("\n"); - - this.end = end; - - return this; - } - - /** - * - */ - public void execute() throws Exception { - try { - if (state == stateDefault) - fail("State after join must be specific. See JoinNodeTestPlanBuilder.stateAfterJoin(boolean)."); - - System.out.println(strPlanBuilder.append("********************").toString()); - - IgniteConfiguration[] cfgs = clusterCfg; - - System.out.println(">>> Start cluster"); - - for (IgniteConfiguration cfg : cfgs) { - startGrid(cfg); - - nodes.add(cfg.getIgniteInstanceName()); - } - - System.out.println(">>> Check after cluster started"); - - afterClusterStarted.run(); - - System.out.println(">>> Start new node"); - - startGrid(nodeCfg); - - nodes.add(nodeCfg.getIgniteInstanceName()); - - System.out.println(">>> Check after new node join in cluster"); - - afterNodeJoin.run(); - - System.out.println(">>> Check cluster state on all nodes"); - - IgniteEx crd = grid(nodes.get(0)); - - for (IgniteEx ig : grids()) - assertEquals((boolean)state, ig.active()); - - if (!state) { - System.out.println(">>> Activate cluster"); - - crd.active(true); - - System.out.println(">>> Check after cluster activated"); - - afterActivate.run(); - } - else { - System.out.println(">>> DeActivate cluster"); - - crd.active(false); - - System.out.println(">>> Check after cluster deActivated"); - - afterDeActivate.run(); - - System.out.println(">>> Activate cluster"); - - crd.active(true); - } - - AffinityTopologyVersion next0Ver = nextMinorVersion(crd); - - crd.createCaches(dynamicCacheStart.call()); - - awaitTopologyVersion(next0Ver); - - afterDynamicCacheStarted.run(); - - onAllNode(new CI1() { - @Override public void apply(IgniteEx ig) { - if (ig.context().discovery().localNode().isClient()) - return; - - Assert.assertNotNull(ig.context().cache().cache(cache4)); - Assert.assertNotNull(ig.context().cache().cache(cache5)); - - } - }); - - AffinityTopologyVersion next1Ver = nextMinorVersion(crd); - - crd.destroyCaches(dynamicCacheStop.call()); - - afterDynamicCacheStopped.run(); - - awaitTopologyVersion(next1Ver); - - onAllNode(new CI1() { - @Override public void apply(IgniteEx ig) { - if (ig.context().discovery().localNode().isClient()) - return; - - Assert.assertNull(ig.context().cache().cache(cache4)); - Assert.assertNull(ig.context().cache().cache(cache5)); - - } - }); - - System.out.println(">>> Finish check"); - - end.run(); - } - finally { - stopAllGrids(); - } - } - - private AffinityTopologyVersion nextMinorVersion(IgniteEx ig){ - AffinityTopologyVersion cur = ig.context().discovery().topologyVersionEx(); - - return new AffinityTopologyVersion(cur.topologyVersion(), cur.minorTopologyVersion() + 1); - } - - private void awaitTopologyVersion(final AffinityTopologyVersion ver){ - onAllNode(new CI1() { - @Override public void apply(IgniteEx ig) { - while (true) { - AffinityTopologyVersion locTopVer = ig.context().cache().context() - .exchange().readyAffinityVersion(); - - if (locTopVer.compareTo(ver) < 0){ - System.out.println("Top ready " + locTopVer + " on " + ig.localNode().id()); - - try { - Thread.sleep(100); - } - catch (InterruptedException e) { - break; - } - } - else - break; - } - } - }).run(); - - } - - /** - * - */ - protected List grids() { - List res = new ArrayList<>(); - - for (String name : nodes) - res.add(grid(name)); - - return res; - } - - /** - * - */ - public static JoinNodeTestPlanBuilder builder() { - return new JoinNodeTestPlanBuilder(); - } - - /** - * - */ - public Runnable checkCacheOnlySystem() { - return onAllNode(new IgniteInClosure() { - @Override public void apply(IgniteEx ig) { - Map desc = cacheDescriptors(ig); - - Assert.assertEquals(2, desc.size()); - - Assert.assertNull(ig.context().cache().cache(cache1)); - Assert.assertNull(ig.context().cache().cache(cache2)); - - Map caches = caches(ig); - - Assert.assertEquals(2, caches.size()); - } - }); - } - - /** - * - */ - public Runnable checkCacheEmpty() { - return onAllNode(new IgniteInClosure() { - @Override public void apply(IgniteEx ig) { - Map desc = cacheDescriptors(ig); - - Assert.assertTrue(desc.isEmpty()); - - Assert.assertNull(ig.context().cache().cache(cache1)); - Assert.assertNull(ig.context().cache().cache(cache2)); - - Map caches = caches(ig); - - Assert.assertEquals(0, caches.size()); - } - }); - } - - /** - * - */ - public Runnable checkCacheNotEmpty() { - return onAllNode(new IgniteInClosure() { - @Override public void apply(IgniteEx ig) { - Map desc = cacheDescriptors(ig); - - Assert.assertEquals(4, desc.size()); - - Assert.assertNotNull(ig.context().cache().cache(cache1)); - Assert.assertNotNull(ig.context().cache().cache(cache2)); - - Map caches = caches(ig); - - Assert.assertEquals(4, caches.size()); - } - }); - } - - /** - * @param cls Closure. - */ - private Runnable onAllNode(final IgniteInClosure cls) { - return new Runnable() { - @Override public void run() { - for (IgniteEx ig : grids()) { - try { - cls.apply(ig); - } - catch (AssertionError e) { - System.out.println("Assertion on " + ig.name()); - - throw e; - } - } - } - }; - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateAbstractTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateAbstractTest.java deleted file mode 100644 index 5bc5c3a..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateAbstractTest.java +++ /dev/null @@ -1,366 +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.standbycluster; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; -import org.apache.ignite.Ignite; -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.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 abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbstractTest { - /** Primary suffix. */ - private static final String primarySuffix = "-primary"; - - /** BackUp suffix. */ - private static final String backUpSuffix = "-backUp"; - - /** BackUp suffix. */ - private static final String clientSuffix = "-client"; - - /** Primary ip finder. */ - protected final TcpDiscoveryIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true); - - /** Back up ip finder. */ - protected final TcpDiscoveryIpFinder backUpIpFinder = new TcpDiscoveryVmIpFinder(true); - - /** Consistent id count. */ - private int consistentIdCnt; - - /** Nodes. */ - protected Map nodes = new ConcurrentHashMap<>(); - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - nodes.clear(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), testName(), true)); - - startPrimaryNodes(primaryNodes()); - - startPrimaryClientNodes(primaryClientNodes()); - - startBackUpNodes(backUpNodes()); - - startBackUpClientNodes(backUpClientNodes()); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAll(clientSuffix); - - stopAll(primarySuffix); - - stopAll(backUpSuffix); - - nodes.clear(); - - deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), testName(), true)); - } - - /** - * - */ - protected int primaryNodes() { - return 3; - } - - /** - * - */ - protected int primaryClientNodes() { - return 3; - } - - /** - * - */ - protected int backUpNodes() { - return 3; - } - - /** - * - */ - protected int backUpClientNodes() { - return 3; - } - - /** - * @param idx idx. - */ - protected Ignite primary(int idx) { - return nodes.get("node" + idx + primarySuffix); - } - - /** - * @param idx idx. - */ - protected Ignite primaryClient(int idx) { - return nodes.get("node" + idx + primarySuffix + clientSuffix); - } - - /** - * @param idx idx. - */ - protected Ignite backUp(int idx) { - return nodes.get("node" + idx + backUpSuffix); - } - - /** - * @param idx idx. - */ - protected Ignite backUpClient(int idx) { - return nodes.get("node" + idx + backUpSuffix + clientSuffix); - } - - /** - * @param cnt Count. - */ - protected void startPrimaryNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) - startPrimary(i); - } - - /** - * @param idx Index. - */ - protected void startPrimary(int idx) throws Exception { - String node = "node" + idx; - - String name = node + primarySuffix; - - IgniteConfiguration cfg = getConfiguration(name); - cfg.setConsistentId(node); - cfg.setActiveOnStart(true); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(primaryIpFinder); - - Ignite ig = startGrid(name, cfg); - - nodes.put(name, ig); - } - - /** - * @param cnt Count. - */ - protected void startBackUpNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) - startBackUp(i); - } - - /** - * @param idx Index. - */ - protected void startBackUp(int idx) throws Exception { - String node = "node" + idx; - - String name = node + backUpSuffix; - - IgniteConfiguration cfg = getConfiguration(name); - cfg.setConsistentId(node); - cfg.setActiveOnStart(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(backUpIpFinder); - - Ignite ig = startGrid(name, cfg); - - nodes.put(name, ig); - } - - /** - * @param cnt Count. - */ - protected void startPrimaryClientNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) { - String node = "node" + i; - - String name = node + primarySuffix + clientSuffix; - - IgniteConfiguration cfg = getConfiguration(name); - cfg.setConsistentId(node); - cfg.setClientMode(true); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(primaryIpFinder); - - Ignite ig = startGrid(name, cfg); - - nodes.put(name, ig); - } - } - - /** - * @param cnt Count. - */ - protected void startBackUpClientNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) { - String node = "node" + i; - - String name = node + backUpSuffix + clientSuffix; - - IgniteConfiguration cfg = getConfiguration(name); - cfg.setConsistentId(node); - cfg.setActiveOnStart(false); - cfg.setClientMode(true); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(backUpIpFinder); - - Ignite ig = startGrid(name, cfg); - - nodes.put(name, ig); - } - } - - /** - * - */ - protected Iterable allBackUpNodes(){ - List r = new ArrayList<>(); - - for (String name : this.nodes.keySet()) - if (name.contains(backUpSuffix)) - r.add(nodes.get(name)); - - return r; - } - - /** - * - */ - protected Ignite randomBackUp(boolean includeClient) { - int nodes = 0; - - List igs = new ArrayList<>(); - - for (String name : this.nodes.keySet()) - if (name.contains(backUpSuffix)){ - if (includeClient) - igs.add(this.nodes.get(name)); - else { - if (name.contains(clientSuffix)) - continue; - - igs.add(this.nodes.get(name)); - } - } - - int idx = ThreadLocalRandom.current().nextInt(0, igs.size()); - - return igs.get(idx); - } - - - /** - * @param i Idx. - */ - protected void stopPrimary(int i) { - String name = "node" + i + primarySuffix; - - nodes.get(name).close(); - - nodes.remove(name); - } - - /** - * - */ - protected void stopAllPrimary() { - stopAll(primarySuffix); - } - - /** - * - */ - protected void stopAllBackUp() { - stopAll(backUpSuffix); - } - - /** - * - */ - protected void stopAllClient() { - stopAll(clientSuffix); - } - - /** - * @param suffix Suffix. - */ - private void stopAll(String suffix) { - for (String name : nodes.keySet()) - if (name.contains(suffix)) { - Ignite ig = nodes.get(name); - - stopGrid(ig.name()); - - nodes.remove(name); - } - } - - /** - * @param gridName Grid name. - */ - @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception { - final IgniteConfiguration cfg = super.getConfiguration(gridName); - - PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration(); - - pCfg.setPersistentStorePath(testName() + "/db"); - pCfg.setWalArchivePath(testName() + "/db/wal/archive"); - pCfg.setWalStorePath(testName() + "/db/wal"); - - cfg.setPersistentStoreConfiguration(pCfg); - - final MemoryConfiguration memCfg = new MemoryConfiguration(); - - memCfg.setPageSize(1024); - memCfg.setConcurrencyLevel(64); - - MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); - memPlcCfg.setInitialSize(20 * 1024 * 1024); - memPlcCfg.setMaxSize(20 * 1024 * 1024); - memPlcCfg.setName("dfltMemPlc"); - - memCfg.setMemoryPolicies(memPlcCfg); - memCfg.setDefaultMemoryPolicyName("dfltMemPlc"); - - cfg.setMemoryConfiguration(memCfg); - - return cfg; - } - - /** - * - */ - protected String testName() { - return getClass().getSimpleName(); - } - -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateCacheTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateCacheTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateCacheTest.java deleted file mode 100644 index ebbab58..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateCacheTest.java +++ /dev/null @@ -1,168 +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.standbycluster; - -import javax.cache.configuration.Configuration; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.util.typedef.F; - -/** - * - */ -public class IgniteChangeGlobalStateCacheTest extends IgniteChangeGlobalStateAbstractTest { - /** - * - */ - public void testCheckValueAfterActivation(){ - String cacheName = "my-cache"; - - Ignite ig1P = primary(0); - - Ignite ig1B = backUp(0); - Ignite ig2B = backUp(1); - Ignite ig3B = backUp(2); - - IgniteCache cacheP = ig1P.getOrCreateCache(cacheName); - - cacheP.put("key","value"); - - stopAllPrimary(); - - ig1B.active(true); - - IgniteCache cache1B = ig1B.cache(cacheName); - IgniteCache cache2B = ig2B.cache(cacheName); - IgniteCache cache3B = ig3B.cache(cacheName); - - assertTrue(cache1B != null); - assertTrue(cache2B != null); - assertTrue(cache3B != null); - - assertEquals(cache1B.get("key"), "value"); - assertEquals(cache2B.get("key"), "value"); - assertEquals(cache3B.get("key"), "value"); - } - - /** - * - */ - public void testMoreKeyValueAfterActivate() throws Exception { - String cacheName = "my-cache"; - - Ignite ig1P = primary(0); - Ignite ig2P = primary(1); - Ignite ig3P = primary(2); - - Ignite ig1B = backUp(0); - Ignite ig2B = backUp(1); - Ignite ig3B = backUp(2); - - CacheConfiguration cacheCfg = new CacheConfiguration<>(cacheName); - - IgniteCache cache1P = ig1P.getOrCreateCache(cacheCfg); - - for (int i = 0; i < 4_000; i++) - cache1P.put("key" + i, "value" + i); - - IgniteCache cache2P = ig2P.cache(cacheName); - - for (int i = 4_000; i < 8_000; i++) - cache2P.put("key" + i, "value" + i); - - IgniteCache cache3P = ig3P.cache(cacheName); - - for (int i = 8_000; i < 12_000; i++) - cache3P.put("key" + i, "value" + i); - - stopAllPrimary(); - - ig1B.active(true); - - IgniteCache cache1B = ig1B.cache(cacheName); - IgniteCache cache2B = ig2B.cache(cacheName); - IgniteCache cache3B = ig3B.cache(cacheName); - - assertTrue(cache1B != null); - assertTrue(cache2B != null); - assertTrue(cache3B != null); - - for (int i = 0; i < 4_000; i++) - assertEquals("value" + i, cache1B.get("key" + i)); - - for (int i = 4_000; i < 8_000; i++) - assertEquals("value" + i, cache2B.get("key" + i)); - - for (int i = 8_000; i < 12_000; i++) - assertEquals("value" + i, cache3B.get("key" + i)); - } - - /** - * @throws Exception if fail. - */ - public void testDeActivateAndActivateCacheValue() throws Exception { - String chName = "myCache"; - - Ignite ig1 = primary(0); - Ignite ig2 = primary(1); - Ignite ig3 = primary(2); - - IgniteCache cacheExp = ig1.getOrCreateCache(chName); - - Configuration cfgExp = cacheExp.getConfiguration(CacheConfiguration.class); - - cacheExp.put("key", "value"); - - assertTrue(ig1.active()); - assertTrue(ig2.active()); - assertTrue(ig3.active()); - - ig2.active(false); - - IgniteEx ex1 = (IgniteEx)ig1; - IgniteEx ex2 = (IgniteEx)ig2; - IgniteEx ex3 = (IgniteEx)ig3; - - GridCacheProcessor cache1 = ex1.context().cache(); - GridCacheProcessor cache2 = ex2.context().cache(); - GridCacheProcessor cache3 = ex3.context().cache(); - - assertTrue(F.isEmpty(cache1.jcaches())); - assertTrue(F.isEmpty(cache2.jcaches())); - assertTrue(F.isEmpty(cache3.jcaches())); - - assertTrue(!ig1.active()); - assertTrue(!ig2.active()); - assertTrue(!ig3.active()); - - ig3.active(true); - - assertTrue(ig1.active()); - assertTrue(ig2.active()); - assertTrue(ig3.active()); - - IgniteCache cacheAct = ig2.cache(chName); - - Configuration cfgAct = cacheAct.getConfiguration(CacheConfiguration.class); - - assertEquals("value", cacheAct.get("key")); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java deleted file mode 100644 index bd65597..0000000 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java +++ /dev/null @@ -1,112 +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.standbycluster; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; - -/** - * - */ -public class IgniteChangeGlobalStateDataStreamerTest extends IgniteChangeGlobalStateAbstractTest { - /** {@inheritDoc} */ - @Override protected int backUpNodes() { - return 0; - } - - /** {@inheritDoc} */ - @Override protected int backUpClientNodes() { - return 0; - } - - /** - * - */ - public void testDeActivateAndActivateDataStreamer() throws InterruptedException { - - Ignite ig1 = primary(0); - Ignite ig2 = primary(1); - Ignite ig3 = primary(2); - - Ignite ig1C = primaryClient(0); - Ignite ig2C = primaryClient(1); - Ignite ig3C = primaryClient(2); - - assertTrue(ig1.active()); - assertTrue(ig2.active()); - assertTrue(ig3.active()); - - assertTrue(ig1C.active()); - assertTrue(ig2C.active()); - assertTrue(ig3C.active()); - - String cacheName = "myStreamCache"; - - ig2C.getOrCreateCache(cacheName); - - try (IgniteDataStreamer stmr = ig1.dataStreamer(cacheName)) { - for (int i = 0; i < 100; i++) - stmr.addData(i, Integer.toString(i)); - } - - ig2C.active(false); - - assertTrue(!ig1.active()); - assertTrue(!ig2.active()); - assertTrue(!ig3.active()); - - assertTrue(!ig1C.active()); - assertTrue(!ig2C.active()); - assertTrue(!ig3C.active()); - - boolean fail = false; - - try { - IgniteDataStreamer strm2 = ig2.dataStreamer(cacheName); - } - catch (Exception e) { - fail = true; - - assertTrue(e.getMessage().contains("can not perform operation, because cluster inactive")); - } - - if (!fail) - fail("exception was not throw"); - - ig3C.active(true); - - assertTrue(ig1.active()); - assertTrue(ig2.active()); - assertTrue(ig3.active()); - - assertTrue(ig1C.active()); - assertTrue(ig2C.active()); - assertTrue(ig3C.active()); - - try (IgniteDataStreamer stmr2 = ig2.dataStreamer(cacheName)) { - for (int i = 100; i < 200; i++) - stmr2.addData(i, Integer.toString(i)); - } - - IgniteCache cache = ig3.cache(cacheName); - - for (int i = 0; i < 200; i++) - assertEquals(String.valueOf(i), cache.get(i)); - } -}