You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/04/14 12:38:31 UTC
ignite git commit: IGNITE-4915: Removed IgniteCache.randomEntry()
method.
Repository: ignite
Updated Branches:
refs/heads/master 7d90c06f9 -> 0a2dd92f8
IGNITE-4915: Removed IgniteCache.randomEntry() method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0a2dd92f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0a2dd92f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0a2dd92f
Branch: refs/heads/master
Commit: 0a2dd92f87e99da43d0fc6efd0c0f6c2e994be0e
Parents: 7d90c06
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Apr 14 15:38:19 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Apr 14 15:38:19 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 13 --
.../org/apache/ignite/cache/CacheEntry.java | 1 -
.../processors/cache/GridCacheAdapter.java | 20 ---
.../processors/cache/IgniteCacheProxy.java | 21 ---
.../distributed/near/GridNearCacheAdapter.java | 6 -
.../cache/GridCacheConcurrentMapTest.java | 138 -------------------
.../GridCachePreloadingEvictionsSelfTest.java | 3 +-
...acheEntrySetIterationPreloadingSelfTest.java | 6 +-
.../CacheVersionedEntryAbstractTest.java | 11 --
.../multijvm/IgniteCacheProcessProxy.java | 5 -
10 files changed, 5 insertions(+), 219 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 42ece62..97bb6b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -106,19 +106,6 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz);
/**
- * Gets a random entry out of cache. In the worst cache scenario this method
- * has complexity of <pre>O(S * N/64)</pre> where {@code N} is the size of internal hash
- * table and {@code S} is the number of hash table buckets to sample, which is {@code 5}
- * by default. However, if the table is pretty dense, with density factor of {@code N/64},
- * which is true for near fully populated caches, this method will generally perform significantly
- * faster with complexity of O(S) where {@code S = 5}.
- *
- * @return Random entry, or {@code null} if cache is empty.
- */
- @Deprecated
- public Entry<K, V> randomEntry();
-
- /**
* Returns cache with the specified expired policy set. This policy will be used for each operation
* invoked on the returned cache.
* <p>
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
index 19585a3..6284f5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
@@ -33,7 +33,6 @@ import org.apache.ignite.IgniteCache;
* <li>{@link javax.cache.Cache#invoke(Object, EntryProcessor, Object...)}</li>
* <li>{@link javax.cache.Cache#invokeAll(Set, EntryProcessor, Object...)}</li>
* <li>invoke and invokeAll methods of {@link IgniteCache}</li>
- * <li>{@link IgniteCache#randomEntry()}</li>
* </ul>
* <p>
* To get an instance of {@code CacheEntry} directly use {@link IgniteCache#getEntry(Object)} or
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index d791b7c..b9fa6c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3695,26 +3695,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
return fut;
}
- /**
- * @return Random cache entry.
- */
- @Deprecated
- @Nullable public Cache.Entry<K, V> randomEntry() {
- GridCloseableIterator<Cache.Entry<K, V>> it;
-
- try {
- it = ctx.offheap().entriesIterator(true, true, ctx.affinity().affinityTopologyVersion(), ctx.keepBinary());
- }
- catch (IgniteCheckedException e) {
- throw CU.convertToCacheException(e);
- }
-
- if (it.hasNext())
- return it.next();
-
- return null;
- }
-
/** {@inheritDoc} */
@Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException {
if (isLocal())
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index cd53e41..14edcac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -61,7 +61,6 @@ import org.apache.ignite.cache.query.TextQuery;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.AsyncSupportAdapter;
-import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -289,26 +288,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
- @SuppressWarnings("deprecation")
- @Nullable @Override public Cache.Entry<K, V> randomEntry() {
- GridKernalContext kctx = ctx.kernalContext();
-
- if (kctx.isDaemon() || kctx.clientNode())
- throw new UnsupportedOperationException("Not applicable for daemon or client node.");
-
- GridCacheGateway<K, V> gate = this.gate;
-
- CacheOperationContext prev = onEnter(gate, opCtx);
-
- try {
- return ctx.cache().randomEntry();
- }
- finally {
- onLeave(gate, prev);
- }
- }
-
- /** {@inheritDoc} */
@Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
GridCacheGateway<K, V> gate = this.gate;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 0d62985..f4ba043 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -39,7 +39,6 @@ import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheClearAllRunnable;
-import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapImpl;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -384,11 +383,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
}
/** {@inheritDoc} */
- @Nullable @Override public Cache.Entry<K, V> randomEntry() {
- return ctx.affinityNode() && ctx.isNear() ? dht().randomEntry() : super.randomEntry();
- }
-
- /** {@inheritDoc} */
@Override public long offHeapEntriesCount() {
return dht().offHeapEntriesCount();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapTest.java
deleted file mode 100644
index fd649da..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapTest.java
+++ /dev/null
@@ -1,138 +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.Random;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.cache.Cache;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.cache.CacheMode.LOCAL;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- * Grid cache concurrent hash map self test.
- */
-public class GridCacheConcurrentMapTest extends GridCommonAbstractTest {
- /** Random. */
- private static final Random RAND = new Random();
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- CacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setCacheMode(LOCAL);
- cc.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setCacheConfiguration(cc);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrid(0);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- grid(0).cache(null).removeAll();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRandomEntry() throws Exception {
- IgniteCache<String, String> cache = grid(0).cache(null);
-
- for (int i = 0; i < 500; i++)
- cache.put("key" + i, "val" + i);
-
- for (int i = 0; i < 20; i++) {
- Cache.Entry<String, String> entry = cache.randomEntry();
-
- assert entry != null;
-
- info("Random entry key: " + entry.getKey());
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRandomEntryMultiThreaded() throws Exception {
- final IgniteCache<String, String> cache = grid(0).cache(null);
-
- final AtomicBoolean done = new AtomicBoolean();
-
- IgniteInternalFuture<?> fut1 = multithreadedAsync(
- new Callable<Object>() {
- @Nullable @Override public Object call() throws Exception {
- while (!done.get()) {
- int i = RAND.nextInt(500);
-
- boolean rmv = RAND.nextBoolean();
-
- if (rmv)
- cache.remove("key" + i);
- else
- cache.put("key" + i, "val" + i);
- }
-
- return null;
- }
- },
- 3
- );
-
- IgniteInternalFuture<?> fut2 = multithreadedAsync(
- new Callable<Object>() {
- @Nullable @Override public Object call() throws Exception {
- while (!done.get()) {
- Cache.Entry<String, String> entry = cache.randomEntry();
-
- info("Random entry key: " + (entry != null ? entry.getKey() : "N/A"));
- }
-
- return null;
- }
- },
- 1
- );
-
- Thread.sleep( 60 * 1000);
-
- done.set(true);
-
- fut1.get();
- fut2.get();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
index 82d9b41..02023ff 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgniteKernal;
@@ -209,7 +210,7 @@ public class GridCachePreloadingEvictionsSelfTest extends GridCommonAbstractTest
* @return Random entry from cache.
*/
@Nullable private Cache.Entry<Integer, Object> randomEntry(Ignite g) {
- return g.<Integer, Object>cache(null).randomEntry();
+ return g.<Integer, Object>cache(null).iterator().next();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java
index 85a9fde..53d3a7a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java
@@ -72,10 +72,10 @@ public class GridCacheEntrySetIterationPreloadingSelfTest extends GridCacheAbstr
for (int i = 0; i < entryCnt; i++)
cache.put(String.valueOf(i), i);
- Collection<Cache.Entry<String, Integer>> entries = new ArrayList<>(10_000);
+ Collection<Cache.Entry<String, Integer>> entries = new ArrayList<>(entryCnt);
- for (int i = 0; i < 10_000; i++)
- entries.add(cache.randomEntry());
+ for (Cache.Entry<String, Integer> entry : cache)
+ entries.add(entry);
startGrid(1);
startGrid(2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
index e93e52e..38297a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
@@ -26,7 +26,6 @@ import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
/**
@@ -109,16 +108,6 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
/**
* @throws Exception If failed.
*/
- public void testRandomEntry() throws Exception {
- IgniteCache<Integer, String> cache = grid(0).cache(null);
-
- for (int i = 0; i < 5; i++)
- checkVersionedEntry(cache.randomEntry().unwrap(CacheEntry.class));
- }
-
- /**
- * @throws Exception If failed.
- */
public void testLocalPeek() throws Exception {
IgniteCache<Integer, String> cache = grid(0).cache(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a2dd92f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 29ccc29..e37b572 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -117,11 +117,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public Entry<K, V> randomEntry() {
- throw new UnsupportedOperationException("Method should be supported.");
- }
-
- /** {@inheritDoc} */
@Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
return new IgniteCacheProcessProxy<>(cacheName, isAsync, plc, igniteProxy);
}