Merge with master - WIP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/86cac7ae Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/86cac7ae Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/86cac7ae Branch: refs/heads/ignite-3477 Commit: 86cac7ae2f151dd31a7fc2a53f04c952c2e13de8 Parents: d5e9a3b Author: Ilya Lantukh <[email protected]> Authored: Thu Dec 22 15:21:04 2016 +0300 Committer: Ilya Lantukh <[email protected]> Committed: Thu Dec 22 15:21:04 2016 +0300 ---------------------------------------------------------------------- .../streams/BinaryByteBufferInputStream.java | 10 ++ .../ignite/internal/util/IgniteUtils.java | 107 ++++++++---- .../util/nio/GridSelectorNioSessionImpl.java | 3 - .../CacheSwapUnswapGetTestSmallQueueSize.java | 35 ---- .../cache/GridCacheOffHeapCleanupTest.java | 169 ------------------- .../cache/GridCacheSwapCleanupTest.java | 99 ----------- .../GridCacheTtlManagerEvictionSelfTest.java | 24 ++- .../IgniteCacheConfigVariationsFullApiTest.java | 2 +- .../cache/OffheapCacheOnClientsTest.java | 143 ---------------- .../IgniteCachePartitionLossPolicySelfTest.java | 2 +- .../ignite/testsuites/IgniteCacheTestSuite.java | 2 - .../testsuites/IgniteCacheTestSuite2.java | 2 - .../testsuites/IgniteCacheTestSuite4.java | 1 - .../testsuites/IgniteCacheTestSuite5.java | 3 - 14 files changed, 97 insertions(+), 505 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryByteBufferInputStream.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryByteBufferInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryByteBufferInputStream.java index d4eba83..d277948 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryByteBufferInputStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryByteBufferInputStream.java @@ -261,6 +261,16 @@ public class BinaryByteBufferInputStream implements BinaryInputStream { } /** {@inheritDoc} */ + @Override public long rawOffheapPointer() { + return 0; + } + + /** {@inheritDoc} */ + @Override public int capacity() { + return buf.capacity(); + } + + /** {@inheritDoc} */ @Override public byte[] array() { return buf.array(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index e21838b..4a8a33c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -571,7 +571,7 @@ public abstract class IgniteUtils { mac = true; else { // UNIXs flavors tokens. - for (CharSequence os : new String[]{"ix", "inux", "olaris", "un", "ux", "sco", "bsd", "att"}) + for (CharSequence os : new String[] {"ix", "inux", "olaris", "un", "ux", "sco", "bsd", "att"}) if (osLow.contains(os)) { unix = true; @@ -683,7 +683,7 @@ public abstract class IgniteUtils { } // Event names initialization. - Class<?>[] evtHolderClasses = new Class[]{EventType.class, DiscoveryCustomEvent.class}; + Class<?>[] evtHolderClasses = new Class[] {EventType.class, DiscoveryCustomEvent.class}; for (Class<?> cls : evtHolderClasses) { for (Field field : cls.getFields()) { @@ -769,7 +769,8 @@ public abstract class IgniteUtils { * @param clazz Class. * @return The IgniteClosure mapped to this exception class, or null if none. */ - public static C1<IgniteCheckedException, IgniteException> getExceptionConverter(Class<? extends IgniteCheckedException> clazz) { + public static C1<IgniteCheckedException, IgniteException> getExceptionConverter( + Class<? extends IgniteCheckedException> clazz) { return exceptionConverters.get(clazz); } @@ -779,7 +780,7 @@ public abstract class IgniteUtils { * @return Exception converters. */ private static Map<Class<? extends IgniteCheckedException>, C1<IgniteCheckedException, IgniteException>> - exceptionConverters() { + exceptionConverters() { Map<Class<? extends IgniteCheckedException>, C1<IgniteCheckedException, IgniteException>> m = new HashMap<>(); m.put(IgniteInterruptedCheckedException.class, new C1<IgniteCheckedException, IgniteException>() { @@ -1258,7 +1259,7 @@ public abstract class IgniteUtils { warn(log, "No deadlocked threads detected."); else warn(log, "Deadlocked threads detected (see thread dump below) " + - "[deadlockedThreadsCnt=" + deadlockedThreadsIds.size() + ']'); + "[deadlockedThreadsCnt=" + deadlockedThreadsIds.size() + ']'); ThreadInfo[] threadInfos = mxBean.dumpAllThreads(mxBean.isObjectMonitorUsageSupported(), mxBean.isSynchronizerUsageSupported()); @@ -1504,7 +1505,8 @@ public abstract class IgniteUtils { } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new IgniteCheckedException("Failed to create new instance for class: " + cls, e); - } finally { + } + finally { if (ctor != null && set) ctor.setAccessible(false); } @@ -1538,7 +1540,8 @@ public abstract class IgniteUtils { } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new IgniteCheckedException("Failed to create new instance for class: " + cls, e); - } finally { + } + finally { if (set) ctor.setAccessible(false); } @@ -1890,11 +1893,13 @@ public abstract class IgniteUtils { for (Future<?> fut : futs) { try { fut.get(); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IgniteException("Thread has been interrupted.", e); - } catch (ExecutionException e) { + } + catch (ExecutionException e) { throw new IgniteException(e); } } @@ -2239,7 +2244,8 @@ public abstract class IgniteUtils { } catch (NoSuchAlgorithmException | KeyManagementException e) { throw new IOException("Failed to open HTTPs connection [url=" + url.toString() + ", msg=" + e + ']', e); - } finally { + } + finally { close(in, null); close(out, null); } @@ -2253,7 +2259,7 @@ public abstract class IgniteUtils { * @return Array with one X509TrustManager implementation of trust manager. */ private static TrustManager[] getTrustManagers() { - return new TrustManager[]{ + return new TrustManager[] { new X509TrustManager() { @Nullable @Override public X509Certificate[] getAcceptedIssuers() { return null; @@ -3308,7 +3314,7 @@ public abstract class IgniteUtils { int cnt = 0; - for (int n; (n = in.read(buf)) > 0;) { + for (int n; (n = in.read(buf)) > 0; ) { out.write(buf, 0, n); cnt += n; @@ -3333,7 +3339,7 @@ public abstract class IgniteUtils { int cnt = 0; - for (int n; (n = in.read(buf)) > 0;) { + for (int n; (n = in.read(buf)) > 0; ) { out.write(buf, 0, n); cnt += n; @@ -4440,7 +4446,7 @@ public abstract class IgniteUtils { * @param sb Sb. */ private static void appendJvmId(SB sb) { - if (getBoolean(IGNITE_MBEAN_APPEND_JVM_ID)){ + if (getBoolean(IGNITE_MBEAN_APPEND_JVM_ID)) { String jvmId = ManagementFactory.getRuntimeMXBean().getName(); sb.a("jvmId=").a(jvmId).a(','); @@ -5147,7 +5153,8 @@ public abstract class IgniteUtils { * @throws ClassNotFoundException If deserialized class could not be found. */ @SuppressWarnings({"unchecked"}) - @Nullable public static <K, V> TreeMap<K, V> readTreeMap(ObjectInput in) throws IOException, ClassNotFoundException { + @Nullable public static <K, V> TreeMap<K, V> readTreeMap( + ObjectInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); if (size == -1) @@ -5422,7 +5429,7 @@ public abstract class IgniteUtils { Set<E> set = new HashSet(size, 1.0f); for (int i = 0; i < size; i++) - set.add((E) in.readObject()); + set.add((E)in.readObject()); return set; } @@ -5827,7 +5834,7 @@ public abstract class IgniteUtils { // We need to find common classloader for all elements AND the collection itself Collection<Object> tmpC = new ArrayList<>(); - for (Object e: c) + for (Object e : c) tmpC.add(e); tmpC.add(c); @@ -6566,7 +6573,7 @@ public abstract class IgniteUtils { String p2 = part2[idx]; int cmp = (p1.matches("\\d+") && p2.matches("\\d+")) - ? Integer.valueOf(p1).compareTo(Integer.valueOf(p2)) : p1.compareTo(p2); + ? Integer.valueOf(p1).compareTo(Integer.valueOf(p2)) : p1.compareTo(p2); if (cmp != 0) return cmp; @@ -7774,7 +7781,7 @@ public abstract class IgniteUtils { } catch (IllegalStateException ignored) { error(log, "Failed to add cause to the end of cause chain (cause is printed here but will " + - "not be propagated to callee): " + e, + "not be propagated to callee): " + e, "Failed to add cause to the end of cause chain: " + e, cause); } @@ -7838,11 +7845,11 @@ public abstract class IgniteUtils { * @return Segment index. */ public static int concurrentMapSegment(int hash, int concurLvl) { - hash += (hash << 15) ^ 0xffffcd7d; + hash += (hash << 15) ^ 0xffffcd7d; hash ^= (hash >>> 10); - hash += (hash << 3); - hash ^= (hash >>> 6); - hash += (hash << 2) + (hash << 14); + hash += (hash << 3); + hash ^= (hash >>> 6); + hash += (hash << 2) + (hash << 14); int shift = 0; int size = 1; @@ -8406,7 +8413,7 @@ public abstract class IgniteUtils { sb.append(" ["); for (int i = 0; i < args.length / 2; i++) { - sb.append(args[ i * 2]).append('=').append(args[i * 2 + 1]); + sb.append(args[i * 2]).append('=').append(args[i * 2 + 1]); sb.append(", "); } @@ -8533,11 +8540,11 @@ public abstract class IgniteUtils { public static int hash(int h) { // Spread bits to regularize both segment and index locations, // using variant of single-word Wang/Jenkins hash. - h += (h << 15) ^ 0xffffcd7d; + h += (h << 15) ^ 0xffffcd7d; h ^= (h >>> 10); - h += (h << 3); - h ^= (h >>> 6); - h += (h << 2) + (h << 14); + h += (h << 3); + h ^= (h >>> 6); + h += (h << 2) + (h << 14); return h ^ (h >>> 16); } @@ -8943,7 +8950,7 @@ public abstract class IgniteUtils { Collection<InetSocketAddress> resolved = new HashSet<>(); - for (InetSocketAddress address :sockAddr) + for (InetSocketAddress address : sockAddr) resolved.addAll(resolveAddress(addrRslvr, address)); return resolved; @@ -9141,6 +9148,41 @@ public abstract class IgniteUtils { */ public static File resolveWorkDirectory(String workDir, String path, boolean delIfExist) throws IgniteCheckedException { + File dir = new File(path); + + if (!dir.isAbsolute()) { + if (F.isEmpty(workDir)) + throw new IgniteCheckedException("Failed to resolve path (work directory has not been set): " + path); + + dir = new File(workDir, dir.getPath()); + } + + if (delIfExist && dir.exists()) { + if (!U.delete(dir)) + throw new IgniteCheckedException("Failed to delete directory: " + dir); + } + + if (!mkdirs(dir)) + throw new IgniteCheckedException("Directory does not exist and cannot be created: " + dir); + + if (!dir.canRead()) + throw new IgniteCheckedException("Cannot read from directory: " + dir); + + if (!dir.canWrite()) + throw new IgniteCheckedException("Cannot write to directory: " + dir); + + return dir; + } + + /** + * Resolves work directory. + * + * @param path Path to resolve. + * @param delIfExist Flag indicating whether to delete the specify directory or not. + * @return Resolved work directory. + * @throws IgniteCheckedException If failed. + */ + public static File resolveWorkDirectory(String path, boolean delIfExist) throws IgniteCheckedException { if (path == null) { String ggWork0 = igniteWork; @@ -9208,7 +9250,8 @@ public abstract class IgniteUtils { * @param suppressed The collections of suppressed exceptions. * @return {@code IgniteCheckedException}. */ - public static IgniteCheckedException exceptionWithSuppressed(String msg, @Nullable Collection<Throwable> suppressed) { + public static IgniteCheckedException exceptionWithSuppressed(String msg, + @Nullable Collection<Throwable> suppressed) { IgniteCheckedException e = new IgniteCheckedException(msg); if (suppressed != null) { @@ -9916,7 +9959,6 @@ public abstract class IgniteUtils { return t0.compareTo(t1) > 0 ? t0 : t1; } - /** * Unmarshals object from the input stream using given class loader. * This method should not close given input stream. @@ -9952,7 +9994,8 @@ public abstract class IgniteUtils { * @return Unmarshalled object. * @throws IgniteCheckedException */ - public static <T> T unmarshalZip(Marshaller marsh, byte[] zipBytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { + public static <T> T unmarshalZip(Marshaller marsh, byte[] zipBytes, + @Nullable ClassLoader clsLdr) throws IgniteCheckedException { assert marsh != null; assert zipBytes != null; http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java index c257a8c..66f9176 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java @@ -48,9 +48,6 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl { /** Current worker thread. */ private volatile GridNioWorker worker; - /** Worker index for server */ - private final int selectorIdx; - /** Semaphore. */ @GridToStringExclude private final Semaphore sem; http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTestSmallQueueSize.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTestSmallQueueSize.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTestSmallQueueSize.java deleted file mode 100644 index 8d189fe..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTestSmallQueueSize.java +++ /dev/null @@ -1,35 +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.internal.processors.cache; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi; - -/** - * - */ -public class CacheSwapUnswapGetTestSmallQueueSize extends CacheSwapUnswapGetTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((FileSwapSpaceSpi)cfg.getSwapSpaceSpi()).setMaxWriteQueueSize(2); - - return cfg; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapCleanupTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapCleanupTest.java deleted file mode 100644 index ae94073..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapCleanupTest.java +++ /dev/null @@ -1,169 +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.internal.processors.cache; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheMemoryMode; -import org.apache.ignite.cache.eviction.EvictionPolicy; -import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; -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.CacheMemoryMode.OFFHEAP_TIERED; -import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES; -import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED; - -/** - * Check offheap allocations are freed after cache destroy. - */ -public class GridCacheOffHeapCleanupTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final String CACHE_NAME = "testCache"; - - /** Memory mode. */ - private CacheMemoryMode memoryMode; - - /** Eviction policy. */ - private EvictionPolicy evictionPlc; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - - /** - * Checks offheap resources are freed after cache destroy - ONHEAP_TIERED memory mode - * - * @throws Exception If failed. - */ - public void testCleanupOffheapAfterCacheDestroyOnheapTiered() throws Exception { - memoryMode = ONHEAP_TIERED; - - FifoEvictionPolicy evictionPlc0 = new FifoEvictionPolicy(); - evictionPlc0.setMaxSize(1); - - evictionPlc = evictionPlc0; - - checkCleanupOffheapAfterCacheDestroy(); - } - - /** - * Checks offheap resources are freed after cache destroy - OFFHEAP_TIERED memory mode - * - * @throws Exception If failed. - */ - public void testCleanupOffheapAfterCacheDestroyOffheapTiered() throws Exception { - memoryMode = OFFHEAP_TIERED; - evictionPlc = null; - - checkCleanupOffheapAfterCacheDestroy(); - } - - /** - * TODO: IGNITE-2714. - * - * Checks offheap resources are freed after cache destroy - OFFHEAP_VALUES memory mode - * - * @throws Exception If failed. - */ - public void _testCleanupOffheapAfterCacheDestroyOffheapValues() throws Exception { - memoryMode = OFFHEAP_VALUES; - evictionPlc = null; - - try (Ignite g = startGrid(0)) { - IgniteCache<Integer, String> cache = g.getOrCreateCache(createCacheConfiguration()); - - cache.put(1, "value_1"); - cache.put(2, "value_2"); - - GridCacheContext ctx = GridTestUtils.cacheContext(cache); - GridUnsafeMemory unsafeMemory = ctx.unsafeMemory(); - - g.destroyCache(null); - - if (unsafeMemory != null) - assertEquals("Unsafe memory not freed", 0, unsafeMemory.allocatedSize()); - } - } - - /** - * Creates cache configuration. - * - * @return cache configuration. - * */ - private CacheConfiguration<Integer, String> createCacheConfiguration() { - CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>(); - - ccfg.setName(CACHE_NAME); - ccfg.setOffHeapMaxMemory(0); - ccfg.setMemoryMode(memoryMode); - ccfg.setEvictionPolicy(evictionPlc); - - return ccfg; - } - - /** - * Check offheap resources are freed after cache destroy. - * - * @throws Exception If failed. - */ - private void checkCleanupOffheapAfterCacheDestroy() throws Exception { - final String spaceName = "gg-swap-cache-" + CACHE_NAME; - - try (Ignite g = startGrid(0)) { - checkOffheapAllocated(spaceName, false); - - IgniteCache<Integer, String> cache = g.getOrCreateCache(createCacheConfiguration()); - - cache.put(1, "value_1"); - cache.put(2, "value_2"); - - checkOffheapAllocated(spaceName, true); - - g.destroyCache(cache.getName()); - - checkOffheapAllocated(spaceName, false); - } - } - - /** - * Check is offheap allocated for given space name using internal API. - * - * @param spaceName Space name. - * @param allocated true, if we expected that offheap is allocated; false, otherwise. - * @throws Exception If failed. - * */ - private void checkOffheapAllocated(String spaceName, boolean allocated) throws Exception { - long offheapSize = grid(0).context().offheap().allocatedSize(spaceName); - - assertEquals("Unexpected offheap allocated size", allocated, (offheapSize >= 0)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapCleanupTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapCleanupTest.java deleted file mode 100644 index 5835ef0..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapCleanupTest.java +++ /dev/null @@ -1,99 +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.internal.processors.cache; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager; -import org.apache.ignite.internal.util.typedef.internal.CU; -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.spi.swapspace.file.FileSwapSpaceSpi; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * Check swap is cleaned after cache destroy. - */ -public class GridCacheSwapCleanupTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** Cache name. */ - private static final String CACHE_NAME = "swapCleanupCache"; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); - - return cfg; - } - - /** - * Creates cache configuration. - * - * @return Cache configuration. - * */ - private CacheConfiguration createCacheConfiguration() { - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setName(CACHE_NAME); - ccfg.setEvictionPolicy(new LruEvictionPolicy(10)); - ccfg.setSwapEnabled(true); - - return ccfg; - } - - /** - * Checks swap is cleaned after cache destroy. - * - * @throws Exception If failed. - * */ - public void testSwapCleanupAfterCacheDestroy() throws Exception { - try (Ignite g = startGrid()) { - for (int iter = 0; iter < 3; iter++) { - IgniteCache cache = g.getOrCreateCache(createCacheConfiguration()); - - for (int i = 0; i < 20; i++) { - assertNull(cache.get(i)); - - cache.put(i, i); - } - - String spaceName = CU.swapSpaceName(internalCache(cache).context()); - - GridSwapSpaceManager swapSpaceMgr = ((IgniteEx)g).context().swap(); - - assertEquals(10, swapSpaceMgr.swapKeys(spaceName)); - - g.destroyCache(cache.getName()); - - assertEquals(0, swapSpaceMgr.swapKeys(spaceName)); - assertEquals(0, swapSpaceMgr.swapSize(spaceName)); - } - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java index 4c7c1c0..0d96e17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteException; import org.apache.ignite.Ignition; import org.apache.ignite.cache.CacheMemoryMode; import org.apache.ignite.cache.CacheMode; @@ -70,7 +71,6 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest ccfg.setCacheMode(cacheMode); ccfg.setMemoryMode(cacheMemoryMode); ccfg.setEagerTtl(true); - ccfg.setSwapEnabled(false); ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100)); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12))); @@ -128,9 +128,12 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { - return (cctx.isSwapOrOffheapEnabled()) ? - ENTRIES_TO_PUT == cctx.ttl().pendingSize() : - ENTRIES_LIMIT == cctx.ttl().pendingSize(); + try { + return ENTRIES_LIMIT == cctx.ttl().pendingSize(); + } + catch (Exception e) { + throw new IgniteException(e); + } } }, 3_000); @@ -140,18 +143,11 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest final String firstKey = "Some test entry key#0"; final String lastKey = "Some test entry key#" + ENTRIES_TO_PUT; - if (cctx.isSwapOrOffheapEnabled()) { - assertTrue("last key should NOT be evicted", cache.containsKey(lastKey)); + assertFalse("first key should be evicted", cache.containsKey(firstKey)); - assertEquals(ENTRIES_TO_PUT, cctx.ttl().pendingSize()); - } - else { - assertFalse("first key should be evicted", cache.containsKey(firstKey)); - - assertTrue("last key should NOT be evicted", cache.containsKey(lastKey)); + assertTrue("last key should NOT be evicted", cache.containsKey(lastKey)); - assertEquals("Ttl Manager should NOT track evicted entries", ENTRIES_LIMIT, cctx.ttl().pendingSize()); - } + assertEquals("Ttl Manager should NOT track evicted entries", ENTRIES_LIMIT, cctx.ttl().pendingSize()); } finally { Ignition.stopAll(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java index 3a07532..1582dbc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java @@ -3339,7 +3339,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar boolean wait = waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { for (int i = 0; i < gridCount(); i++) { - if (peek(jcache(i), key) != null) + if (jcache(i).localPeek(key) != null) return false; } http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java deleted file mode 100644 index 90985b6..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.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.internal.processors.cache; - -import java.util.concurrent.ConcurrentMap; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheMemoryMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor; -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.CacheMemoryMode.*; -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class OffheapCacheOnClientsTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final String CACHE_NAME = "CACHE_NAME"; - - /** */ - private boolean client; - - /** */ - private boolean forceSrvMode; - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); - - startGrid(0); - - client = true; - - startGrid(1); - - forceSrvMode = true; - - startGrid(2); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - if (client) { - cfg.setClientMode(true); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(forceSrvMode); - } - - return cfg; - } - /** - * @throws Exception If failed. - */ - public void testOffheapCacheOnClient() throws Exception { - try { - Ignite client = grid(1); - - testStartCacheOnClient(client, OFFHEAP_TIERED); - testStartCacheOnClient(client, OFFHEAP_VALUES); - testStartCacheOnClient(client, ONHEAP_TIERED); - - client = grid(2); - - testStartCacheOnClient(client, OFFHEAP_TIERED); - testStartCacheOnClient(client, OFFHEAP_VALUES); - testStartCacheOnClient(client, ONHEAP_TIERED); - } - finally { - grid(0).destroyCache(CACHE_NAME); - } - } - - /** - * @param client Node. - * @param memMode Memory mode. - * @throws Exception If failed. - */ - private void testStartCacheOnClient(Ignite client, CacheMemoryMode memMode) throws Exception { - assertTrue(client.configuration().isClientMode()); - - try { - client.createCache(new CacheConfiguration(CACHE_NAME) - .setCacheMode(REPLICATED) - .setOffHeapMaxMemory(1024 * 1024) - .setMemoryMode(memMode)); - - IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME); - - assertNotNull(cache); - - cache.put(1, 1); - assertEquals((Integer)1, cache.get(1)); - - GridOffHeapProcessor offheap = ((IgniteKernal)client).cachex(CACHE_NAME).context().offheap(); - - assertNotNull(offheap); - - ConcurrentMap offheapMaps = GridTestUtils.getFieldValue(offheap, "offheap"); - assertNotNull(offheapMaps); - - assertEquals(0,offheapMaps.size()); - } - finally { - client.destroyCache(CACHE_NAME); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java index a726932..5951ba3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java @@ -202,7 +202,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe ignite(0).cache(CACHE_NAME).resetLostPartitions(); - awaitPartitionMapExchange(true, true); + awaitPartitionMapExchange(true, true, null); for (Ignite ig : G.allGrids()) { IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index 56c10ae..bb72459 100755 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -84,7 +84,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheReplicatedTxStoreExc import org.apache.ignite.internal.processors.cache.GridCacheStopSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheStorePutxSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheStoreValueBytesSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheSwapCleanupTest; import org.apache.ignite.internal.processors.cache.GridCacheSwapPreloadSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerEvictionSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerSelfTest; @@ -236,7 +235,6 @@ public class IgniteCacheTestSuite extends TestSuite { // Swap tests. suite.addTestSuite(GridCacheSwapPreloadSelfTest.class); - suite.addTestSuite(GridCacheSwapCleanupTest.class); // Common tests. suite.addTestSuite(CacheNamesSelfTest.class); http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java index 16017ea..6e63225 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java @@ -39,7 +39,6 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorNode import org.apache.ignite.internal.processors.cache.IgniteCacheIncrementTxTest; import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdateTest; import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheAndNodeStop; -import org.apache.ignite.internal.processors.cache.OffheapCacheOnClientsTest; import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTestAllowOverwrite; import org.apache.ignite.internal.processors.cache.distributed.CacheLockReleaseNodeLeaveTest; @@ -269,7 +268,6 @@ public class IgniteCacheTestSuite2 extends TestSuite { suite.addTest(new TestSuite(IgniteNoCustomEventsOnNodeStart.class)); suite.addTest(new TestSuite(CacheExchangeMessageDuplicatedStateTest.class)); - suite.addTest(new TestSuite(OffheapCacheOnClientsTest.class)); return suite; } http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index fd32147..541edd2 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -42,7 +42,6 @@ import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynam import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartAtomicTest; import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartTxTest; import org.apache.ignite.internal.processors.cache.CacheSwapUnswapGetTest; -import org.apache.ignite.internal.processors.cache.CacheSwapUnswapGetTestSmallQueueSize; import org.apache.ignite.internal.processors.cache.CacheTxNotAllowReadFromBackupTest; import org.apache.ignite.internal.processors.cache.CrossCacheLockTest; import org.apache.ignite.internal.processors.cache.GridCacheMarshallingNodeJoinSelfTest; http://git-wip-us.apache.org/repos/asf/ignite/blob/86cac7ae/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java index 29a7771..e579aa6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.cache.CacheSerializableTransactions import org.apache.ignite.internal.processors.cache.ClusterStatePartitionedSelfTest; import org.apache.ignite.internal.processors.cache.ClusterStateReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.EntryVersionConsistencyReadThroughTest; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapCleanupTest; import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheReadThroughEvictionsVariationsSuite; import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest; @@ -65,8 +64,6 @@ public class IgniteCacheTestSuite5 extends TestSuite { suite.addTest(IgniteCacheReadThroughEvictionsVariationsSuite.suite()); suite.addTestSuite(IgniteCacheTxIteratorSelfTest.class); - suite.addTestSuite(GridCacheOffHeapCleanupTest.class); - suite.addTestSuite(CacheRebalancingSelfTest.class); suite.addTestSuite(ClusterStatePartitionedSelfTest.class);
