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/03/21 11:30:02 UTC
[13/33] ignite git commit: IGNITE-2552 EvictionPolicies refactored,
logic changed
IGNITE-2552 EvictionPolicies refactored, logic changed
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/19566fbc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/19566fbc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/19566fbc
Branch: refs/heads/ignite-4565-ddl
Commit: 19566fbc0a683e5a72cf91ee0f8de987c524c01d
Parents: d4b87f4
Author: voipp <al...@gmail.com>
Authored: Wed Feb 15 11:54:48 2017 +0300
Committer: agura <ag...@apache.org>
Committed: Fri Mar 10 14:50:25 2017 +0300
----------------------------------------------------------------------
.../cache/eviction/AbstractEvictionPolicy.java | 210 +++++++++++++++++++
.../ignite/cache/eviction/EvictionPolicy.java | 2 -
.../cache/eviction/fifo/FifoEvictionPolicy.java | 158 +-------------
.../cache/eviction/lru/LruEvictionPolicy.java | 159 ++------------
.../eviction/random/RandomEvictionPolicy.java | 124 -----------
.../random/RandomEvictionPolicyMBean.java | 42 ----
.../eviction/sorted/SortedEvictionPolicy.java | 160 ++------------
.../internal/visor/util/VisorTaskUtils.java | 8 +-
.../resources/META-INF/classnames.properties | 1 -
...idCacheConfigurationConsistencySelfTest.java | 6 +-
.../cache/eviction/EvictionAbstractTest.java | 4 +-
11 files changed, 264 insertions(+), 610 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicy.java
new file mode 100644
index 0000000..eca58e6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicy.java
@@ -0,0 +1,210 @@
+/*
+ * 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.eviction;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jsr166.LongAdder8;
+
+/**
+ * Common functionality implementation for eviction policies
+ */
+public abstract class AbstractEvictionPolicy<K, V> implements EvictionPolicy<K, V> {
+ /** Memory size occupied by elements in container. */
+ private final LongAdder8 memSize = new LongAdder8();
+
+ /** Max memory size occupied by elements in container. */
+ private volatile long maxMemSize;
+
+ /** Maximum elements in container. */
+ private volatile int max;
+
+ /** Batch size. */
+ private volatile int batchSize = 1;
+
+ /**
+ * Shrinks backed container to maximum allowed size.
+ */
+ protected void shrink() {
+ long maxMem = this.maxMemSize;
+
+ if (maxMem > 0) {
+ long startMemSize = memSize.longValue();
+
+ if (startMemSize >= maxMem)
+ for (long i = maxMem; i < startMemSize && memSize.longValue() > maxMem; ) {
+ int size = shrink0();
+
+ if (size == -1)
+ break;
+
+ i += size;
+ }
+ }
+
+ int max = this.max;
+
+ if (max > 0) {
+ int startSize = getCurrentSize();
+
+ if (startSize >= max + (maxMem > 0 ? 1 : this.batchSize))
+ for (int i = max; i < startSize && getCurrentSize() > max; i++)
+ if (shrink0() == -1)
+ break;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) {
+ if (!rmv) {
+ if (!entry.isCached())
+ return;
+
+ if (touch(entry))
+ shrink();
+ }
+ else {
+ Object node = entry.removeMeta();
+
+ if (node != null) {
+ removeMeta(node);
+
+ addToMemorySize(-entry.size());
+ }
+
+ }
+ }
+
+ /**
+ * @param x Changing memory size by adding the value.
+ */
+ protected void addToMemorySize(int x) {
+ memSize.add(x);
+ }
+
+ /**
+ *
+ * @return Size of the container.
+ */
+ protected abstract int getCurrentSize();
+
+ /**
+ *
+ * @return Size of the memory which was shrinked0.
+ */
+ protected abstract int shrink0();
+
+ /**
+ *
+ * @param meta Meta-information shipped to an entry.
+ * @return {@code True} if meta was successfully removed from the container.
+ */
+ protected abstract boolean removeMeta(Object meta);
+
+ /**
+ * @param entry Entry to touch.
+ * @return {@code True} if container has been changed by this call.
+ */
+ protected abstract boolean touch(EvictableEntry<K, V> entry);
+
+ /**
+ * Sets maximum allowed cache size in bytes.
+ */
+ public void setMaxMemorySize(long maxMemSize) {
+ A.ensure(maxMemSize >= 0, "maxMemSize >= 0");
+
+ this.maxMemSize = maxMemSize;
+ }
+
+ /**
+ * Gets maximum allowed cache size in bytes.
+ *
+ * @return maximum allowed cache size in bytes.
+ */
+ public long getMaxMemorySize() {
+ return maxMemSize;
+ }
+
+ /**
+ * Gets current queue size in bytes.
+ *
+ * @return current queue size in bytes.
+ */
+ public long getCurrentMemorySize() {
+ return memSize.longValue();
+ }
+
+ /**
+ * Sets maximum allowed size of cache before entry will start getting evicted.
+ *
+ * @param max Maximum allowed size of cache before entry will start getting evicted.
+ */
+ public void setMaxSize(int max) {
+ A.ensure(max >= 0, "max >= 0");
+
+ this.max = max;
+ }
+
+ /**
+ * Gets maximum allowed size of cache before entry will start getting evicted.
+ *
+ * @return Maximum allowed size of cache before entry will start getting evicted.
+ */
+ public int getMaxSize() {
+ return max;
+ }
+
+ /**
+ * Sets batch size.
+ *
+ * @param batchSize Batch size.
+ */
+ public void setBatchSize(int batchSize) {
+ A.ensure(batchSize > 0, "batchSize > 0");
+
+ this.batchSize = batchSize;
+ }
+
+ /**
+ * Gets batch size.
+ *
+ * @return batch size.
+ */
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ public LongAdder8 getMemSize() {
+ return memSize;
+ }
+
+ /** {@inheritDoc} */
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(max);
+ out.writeInt(batchSize);
+ out.writeLong(maxMemSize);
+ }
+ /** {@inheritDoc} */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ max = in.readInt();
+ batchSize = in.readInt();
+ maxMemSize = in.readLong();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java
index a77514a..6125b50 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java
@@ -19,7 +19,6 @@ package org.apache.ignite.cache.eviction;
import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
-import org.apache.ignite.cache.eviction.random.RandomEvictionPolicy;
import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy;
/**
@@ -31,7 +30,6 @@ import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy;
* Ignite comes with following eviction policies out-of-the-box:
* <ul>
* <li>{@link LruEvictionPolicy}</li>
- * <li>{@link RandomEvictionPolicy}</li>
* <li>{@link FifoEvictionPolicy}</li>
* <li>{@link SortedEvictionPolicy}</li>
* </ul>
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
index 4d1c3f1..dd7ba0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
@@ -18,20 +18,13 @@
package org.apache.ignite.cache.eviction.fifo;
import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Collections;
+import org.apache.ignite.cache.eviction.AbstractEvictionPolicy;
import org.apache.ignite.cache.eviction.EvictableEntry;
-import org.apache.ignite.cache.eviction.EvictionPolicy;
-import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jsr166.ConcurrentLinkedDeque8;
import org.jsr166.ConcurrentLinkedDeque8.Node;
-import org.jsr166.LongAdder8;
-
-import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE;
/**
* Eviction policy based on {@code First In First Out (FIFO)} algorithm and supports batch eviction.
@@ -51,22 +44,10 @@ import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE
* table-like data structures. The {@code FIFO} ordering information is
* maintained by attaching ordering metadata to cache entries.
*/
-public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvictionPolicyMBean, Externalizable {
+public class FifoEvictionPolicy<K, V> extends AbstractEvictionPolicy<K, V> implements FifoEvictionPolicyMBean, Externalizable {
/** */
private static final long serialVersionUID = 0L;
- /** Maximum size. */
- private volatile int max = DFLT_CACHE_SIZE;
-
- /** Batch size. */
- private volatile int batchSize = 1;
-
- /** Max memory size. */
- private volatile long maxMemSize;
-
- /** Memory size. */
- private final LongAdder8 memSize = new LongAdder8();
-
/** FIFO queue. */
private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue =
new ConcurrentLinkedDeque8<>();
@@ -84,9 +65,7 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
* @param max Maximum allowed size of cache before entry will start getting evicted.
*/
public FifoEvictionPolicy(int max) {
- A.ensure(max >= 0, "max >= 0");
-
- this.max = max;
+ setMaxSize(max);
}
/**
@@ -96,43 +75,8 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
* @param batchSize Batch size.
*/
public FifoEvictionPolicy(int max, int batchSize) {
- A.ensure(max >= 0, "max >= 0");
- A.ensure(batchSize > 0, "batchSize > 0");
-
- this.max = max;
- this.batchSize = batchSize;
- }
-
- /**
- * Gets maximum allowed size of cache before entry will start getting evicted.
- *
- * @return Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public int getMaxSize() {
- return max;
- }
-
- /**
- * Sets maximum allowed size of cache before entry will start getting evicted.
- *
- * @param max Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public void setMaxSize(int max) {
- A.ensure(max >= 0, "max >= 0");
-
- this.max = max;
- }
-
- /** {@inheritDoc} */
- @Override public int getBatchSize() {
- return batchSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setBatchSize(int batchSize) {
- A.ensure(batchSize > 0, "batchSize > 0");
-
- this.batchSize = batchSize;
+ setMaxSize(max);
+ setBatchSize(batchSize);
}
/** {@inheritDoc} */
@@ -140,23 +84,6 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
return queue.size();
}
- /** {@inheritDoc} */
- @Override public long getMaxMemorySize() {
- return maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setMaxMemorySize(long maxMemSize) {
- A.ensure(maxMemSize >= 0, "maxMemSize >= 0");
-
- this.maxMemSize = maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public long getCurrentMemorySize() {
- return memSize.longValue();
- }
-
/**
* Gets read-only view on internal {@code FIFO} queue in proper order.
*
@@ -167,31 +94,15 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
}
/** {@inheritDoc} */
- @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) {
- if (!rmv) {
- if (!entry.isCached())
- return;
-
- // Shrink only if queue was changed.
- if (touch(entry))
- shrink();
- }
- else {
- Node<EvictableEntry<K, V>> node = entry.removeMeta();
-
- if (node != null) {
- queue.unlinkx(node);
-
- memSize.add(-entry.size());
- }
- }
+ @Override protected boolean removeMeta(Object meta) {
+ return queue.unlinkx((Node<EvictableEntry<K, V>>)meta);
}
/**
* @param entry Entry to touch.
* @return {@code True} if queue has been changed by this call.
*/
- private boolean touch(EvictableEntry<K, V> entry) {
+ protected boolean touch(EvictableEntry<K, V> entry) {
Node<EvictableEntry<K, V>> node = entry.meta();
// Entry has not been enqueued yet.
@@ -214,7 +125,7 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
return false;
}
- memSize.add(entry.size());
+ addToMemorySize(entry.size());
return true;
}
@@ -229,44 +140,11 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
}
/**
- * Shrinks FIFO queue to maximum allowed size.
- */
- private void shrink() {
- long maxMem = this.maxMemSize;
-
- if (maxMem > 0) {
- long startMemSize = memSize.longValue();
-
- if (startMemSize >= maxMem)
- for (long i = maxMem; i < startMemSize && memSize.longValue() > maxMem;) {
- int size = shrink0();
-
- if (size == -1)
- break;
-
- i += size;
- }
- }
-
- int max = this.max;
-
- if (max > 0) {
- int startSize = queue.sizex();
-
- // Shrink only if queue is full.
- if (startSize >= max + (maxMem > 0 ? 1 : this.batchSize))
- for (int i = max; i < startSize && queue.sizex() > max; i++)
- if (shrink0() == -1)
- break;
- }
- }
-
- /**
* Tries to remove one item from queue.
*
* @return number of bytes that was free. {@code -1} if queue is empty.
*/
- private int shrink0() {
+ @Override protected int shrink0() {
EvictableEntry<K, V> entry = queue.poll();
if (entry == null)
@@ -279,7 +157,7 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
if (meta != null) {
size = entry.size();
- memSize.add(-size);
+ addToMemorySize(-size);
if (!entry.evict())
touch(entry);
@@ -289,20 +167,6 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, FifoEvict
}
/** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(max);
- out.writeInt(batchSize);
- out.writeLong(maxMemSize);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- max = in.readInt();
- batchSize = in.readInt();
- maxMemSize = in.readLong();
- }
-
- /** {@inheritDoc} */
@Override public String toString() {
return S.toString(FifoEvictionPolicy.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
index f321764..caa4b3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
@@ -18,20 +18,13 @@
package org.apache.ignite.cache.eviction.lru;
import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Collections;
+import org.apache.ignite.cache.eviction.AbstractEvictionPolicy;
import org.apache.ignite.cache.eviction.EvictableEntry;
-import org.apache.ignite.cache.eviction.EvictionPolicy;
-import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jsr166.ConcurrentLinkedDeque8;
import org.jsr166.ConcurrentLinkedDeque8.Node;
-import org.jsr166.LongAdder8;
-
-import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE;
/**
* Eviction policy based on {@code Least Recently Used (LRU)} algorithm and supports batch eviction.
@@ -50,22 +43,10 @@ import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE
* This implementation is very efficient since it is lock-free and does not create any additional table-like
* data structures. The {@code LRU} ordering information is maintained by attaching ordering metadata to cache entries.
*/
-public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictionPolicyMBean, Externalizable {
+public class LruEvictionPolicy<K, V> extends AbstractEvictionPolicy<K, V> implements LruEvictionPolicyMBean, Externalizable {
/** */
private static final long serialVersionUID = 0L;
- /** Maximum size. */
- private volatile int max = DFLT_CACHE_SIZE;
-
- /** Batch size. */
- private volatile int batchSize = 1;
-
- /** Max memory size. */
- private volatile long maxMemSize;
-
- /** Memory size. */
- private final LongAdder8 memSize = new LongAdder8();
-
/** Queue. */
private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue =
new ConcurrentLinkedDeque8<>();
@@ -83,41 +64,7 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
* @param max Maximum allowed size of cache before entry will start getting evicted.
*/
public LruEvictionPolicy(int max) {
- A.ensure(max >= 0, "max >= 0");
-
- this.max = max;
- }
-
- /**
- * Gets maximum allowed size of cache before entry will start getting evicted.
- *
- * @return Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public int getMaxSize() {
- return max;
- }
-
- /**
- * Sets maximum allowed size of cache before entry will start getting evicted.
- *
- * @param max Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public void setMaxSize(int max) {
- A.ensure(max >= 0, "max >= 0");
-
- this.max = max;
- }
-
- /** {@inheritDoc} */
- @Override public int getBatchSize() {
- return batchSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setBatchSize(int batchSize) {
- A.ensure(batchSize > 0, "batchSize > 0");
-
- this.batchSize = batchSize;
+ setMaxSize(max);
}
/** {@inheritDoc} */
@@ -125,23 +72,6 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
return queue.size();
}
- /** {@inheritDoc} */
- @Override public long getMaxMemorySize() {
- return maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setMaxMemorySize(long maxMemSize) {
- A.ensure(maxMemSize >= 0, "maxMemSize >= 0");
-
- this.maxMemSize = maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public long getCurrentMemorySize() {
- return memSize.longValue();
- }
-
/**
* Gets read-only view on internal {@code FIFO} queue in proper order.
*
@@ -152,30 +82,15 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
}
/** {@inheritDoc} */
- @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) {
- if (!rmv) {
- if (!entry.isCached())
- return;
-
- if (touch(entry))
- shrink();
- }
- else {
- Node<EvictableEntry<K, V>> node = entry.removeMeta();
-
- if (node != null) {
- queue.unlinkx(node);
-
- memSize.add(-entry.size());
- }
- }
+ @Override protected boolean removeMeta(Object meta) {
+ return queue.unlinkx((Node<EvictableEntry<K, V>>)meta);
}
/**
* @param entry Entry to touch.
* @return {@code True} if new node has been added to queue by this call.
*/
- private boolean touch(EvictableEntry<K, V> entry) {
+ @Override protected boolean touch(EvictableEntry<K, V> entry) {
Node<EvictableEntry<K, V>> node = entry.meta();
// Entry has not been enqueued yet.
@@ -185,7 +100,7 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
if (entry.putMetaIfAbsent(node) != null) {
// Was concurrently added, need to clear it from queue.
- queue.unlinkx(node);
+ removeMeta(node);
// Queue has not been changed.
return false;
@@ -193,12 +108,12 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
else if (node.item() != null) {
if (!entry.isCached()) {
// Was concurrently evicted, need to clear it from queue.
- queue.unlinkx(node);
+ removeMeta(node);
return false;
}
- memSize.add(entry.size());
+ addToMemorySize(entry.size());
return true;
}
@@ -207,13 +122,13 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
return false;
}
}
- else if (queue.unlinkx(node)) {
+ else if (removeMeta(node)) {
// Move node to tail.
Node<EvictableEntry<K, V>> newNode = queue.offerLastx(entry);
if (!entry.replaceMeta(node, newNode))
// Was concurrently added, need to clear it from queue.
- queue.unlinkx(newNode);
+ removeMeta(newNode);
}
// Entry is already in queue.
@@ -221,43 +136,11 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
}
/**
- * Shrinks queue to maximum allowed size.
- */
- private void shrink() {
- long maxMem = this.maxMemSize;
-
- if (maxMem > 0) {
- long startMemSize = memSize.longValue();
-
- if (startMemSize >= maxMem)
- for (long i = maxMem; i < startMemSize && memSize.longValue() > maxMem;) {
- int size = shrink0();
-
- if (size == -1)
- break;
-
- i += size;
- }
- }
-
- int max = this.max;
-
- if (max > 0) {
- int startSize = queue.sizex();
-
- if (startSize >= max + (maxMem > 0 ? 1 : this.batchSize))
- for (int i = max; i < startSize && queue.sizex() > max; i++)
- if (shrink0() == -1)
- break;
- }
- }
-
- /**
* Tries to remove one item from queue.
*
* @return number of bytes that was free. {@code -1} if queue is empty.
*/
- private int shrink0() {
+ @Override protected int shrink0() {
EvictableEntry<K, V> entry = queue.poll();
if (entry == null)
@@ -270,7 +153,7 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
if (meta != null) {
size = entry.size();
- memSize.add(-size);
+ addToMemorySize(-size);
if (!entry.evict())
touch(entry);
@@ -280,21 +163,7 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, LruEvictio
}
/** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(max);
- out.writeInt(batchSize);
- out.writeLong(maxMemSize);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- max = in.readInt();
- batchSize = in.readInt();
- maxMemSize = in.readLong();
- }
-
- /** {@inheritDoc} */
@Override public String toString() {
- return S.toString(LruEvictionPolicy.class, this, "size", queue.sizex());
+ return S.toString(LruEvictionPolicy.class, this, "size", getCurrentSize());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
deleted file mode 100644
index f77551d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
+++ /dev/null
@@ -1,124 +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.eviction.random;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import javax.cache.Cache;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.eviction.EvictableEntry;
-import org.apache.ignite.cache.eviction.EvictionPolicy;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE;
-
-/**
- * Cache eviction policy which will select random cache entry for eviction if cache
- * size exceeds the {@link #getMaxSize()} parameter. This implementation is
- * extremely light weight, lock-free, and does not create any data structures to maintain
- * any order for eviction.
- * <p>
- * Random eviction will provide the best performance over any key queue in which every
- * key has the same probability of being accessed.
- *
- * @deprecated This eviction policy implementation doesn't support near cache
- * and doesn't work on client nodes. Also it seems that random eviction doesn't make sense.
- */
-@Deprecated
-public class RandomEvictionPolicy<K, V> implements EvictionPolicy<K, V>, RandomEvictionPolicyMBean, Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Maximum size. */
- private volatile int max = DFLT_CACHE_SIZE;
-
- /**
- * Constructs random eviction policy with all defaults.
- */
- public RandomEvictionPolicy() {
- // No-op.
- }
-
- /**
- * Constructs random eviction policy with maximum size.
- *
- * @param max Maximum allowed size of cache before entry will start getting evicted.
- */
- public RandomEvictionPolicy(int max) {
- A.ensure(max > 0, "max > 0");
-
- this.max = max;
- }
-
- /**
- * Gets maximum allowed size of cache before entry will start getting evicted.
- *
- * @return Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public int getMaxSize() {
- return max;
- }
-
- /**
- * Sets maximum allowed size of cache before entry will start getting evicted.
- *
- * @param max Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public void setMaxSize(int max) {
- A.ensure(max > 0, "max > 0");
-
- this.max = max;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) {
- if (!entry.isCached())
- return;
-
- IgniteCache<K, V> cache = entry.unwrap(IgniteCache.class);
-
- int size = cache.localSize(CachePeekMode.ONHEAP);
-
- for (int i = max; i < size; i++) {
- Cache.Entry<K, V> e = cache.randomEntry();
-
- if (e != null)
- e.unwrap(EvictableEntry.class).evict();
- }
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(max);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- max = in.readInt();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(RandomEvictionPolicy.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
deleted file mode 100644
index 3193483..0000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.eviction.random;
-
-import org.apache.ignite.mxbean.MXBeanDescription;
-
-/**
- * MBean for {@code random} eviction policy.
- */
-@MXBeanDescription("MBean for random cache eviction policy.")
-public interface RandomEvictionPolicyMBean {
- /**
- * Gets maximum allowed cache size.
- *
- * @return Maximum allowed cache size.
- */
- @MXBeanDescription("Maximum allowed cache size.")
- public int getMaxSize();
-
- /**
- * Sets maximum allowed cache size.
- *
- * @param max Maximum allowed cache size.
- */
- @MXBeanDescription("Sets maximum allowed cache size.")
- public void setMaxSize(int max);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
index 6189552..47f8479 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
@@ -29,8 +29,8 @@ import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.ignite.cache.eviction.AbstractEvictionPolicy;
import org.apache.ignite.cache.eviction.EvictableEntry;
-import org.apache.ignite.cache.eviction.EvictionPolicy;
import org.apache.ignite.internal.util.GridConcurrentSkipListSet;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.jetbrains.annotations.Nullable;
@@ -59,22 +59,10 @@ import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE
* <p>
* User defined comparator should implement {@link Serializable} interface.
*/
-public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedEvictionPolicyMBean, Externalizable {
+public class SortedEvictionPolicy<K, V> extends AbstractEvictionPolicy<K, V> implements SortedEvictionPolicyMBean, Externalizable {
/** */
private static final long serialVersionUID = 0L;
- /** Maximum size. */
- private volatile int max = DFLT_CACHE_SIZE;
-
- /** Batch size. */
- private volatile int batchSize = 1;
-
- /** Max memory size. */
- private volatile long maxMemSize;
-
- /** Memory size. */
- private final LongAdder8 memSize = new LongAdder8();
-
/** Comparator. */
private Comparator<Holder<K, V>> comp;
@@ -118,11 +106,8 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
* @param comp Entries comparator.
*/
public SortedEvictionPolicy(int max, int batchSize, @Nullable Comparator<EvictableEntry<K, V>> comp) {
- A.ensure(max >= 0, "max >= 0");
- A.ensure(batchSize > 0, "batchSize > 0");
-
- this.max = max;
- this.batchSize = batchSize;
+ setMaxSize(max);
+ setBatchSize(batchSize);
this.comp = comp == null ? new DefaultHolderComparator<K, V>() : new HolderComparator<>(comp);
this.set = new GridConcurrentSkipListSetEx<>(this.comp);
}
@@ -138,60 +123,6 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
}
/**
- * Gets maximum allowed size of cache before entry will start getting evicted.
- *
- * @return Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public int getMaxSize() {
- return max;
- }
-
- /**
- * Sets maximum allowed size of cache before entry will start getting evicted.
- *
- * @param max Maximum allowed size of cache before entry will start getting evicted.
- */
- @Override public void setMaxSize(int max) {
- A.ensure(max >= 0, "max >= 0");
-
- this.max = max;
- }
-
- /** {@inheritDoc} */
- @Override public int getBatchSize() {
- return batchSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setBatchSize(int batchSize) {
- A.ensure(batchSize > 0, "batchSize > 0");
-
- this.batchSize = batchSize;
- }
-
- /** {@inheritDoc} */
- @Override public int getCurrentSize() {
- return set.sizex();
- }
-
- /** {@inheritDoc} */
- @Override public long getMaxMemorySize() {
- return maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public void setMaxMemorySize(long maxMemSize) {
- A.ensure(maxMemSize >= 0, "maxMemSize >= 0");
-
- this.maxMemSize = maxMemSize;
- }
-
- /** {@inheritDoc} */
- @Override public long getCurrentMemorySize() {
- return memSize.longValue();
- }
-
- /**
* Gets read-only view of backed queue in proper order.
*
* @return Read-only view of backed queue.
@@ -205,31 +136,11 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
return Collections.unmodifiableCollection(cp);
}
- /** {@inheritDoc} */
- @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) {
- if (!rmv) {
- if (!entry.isCached())
- return;
-
- if (touch(entry))
- shrink();
- }
- else {
- Holder<K, V> holder = entry.removeMeta();
-
- if (holder != null) {
- removeHolder(holder);
-
- memSize.add(-entry.size());
- }
- }
- }
-
/**
* @param entry Entry to touch.
* @return {@code True} if backed queue has been changed by this call.
*/
- private boolean touch(EvictableEntry<K, V> entry) {
+ @Override protected boolean touch(EvictableEntry<K, V> entry) {
Holder<K, V> holder = entry.meta();
// Entry has not been added yet to backed queue.
@@ -245,12 +156,12 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
if (holder.order > 0) {
if (!entry.isCached()) {
// Was concurrently evicted, need to remove it from queue.
- removeHolder(holder);
+ removeMeta(holder);
return false;
}
- memSize.add(entry.size());
+ addToMemorySize(entry.size());
return true;
}
@@ -264,38 +175,9 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
return false;
}
- /**
- * Shrinks backed queue to maximum allowed size.
- */
- private void shrink() {
- long maxMem = this.maxMemSize;
-
- if (maxMem > 0) {
- long startMemSize = memSize.longValue();
-
- if (startMemSize >= maxMem)
- for (long i = maxMem; i < startMemSize && memSize.longValue() > maxMem;) {
- int size = shrink0();
-
- if (size == -1)
- break;
-
- i += size;
- }
- }
-
- int max = this.max;
-
- if (max > 0) {
- int startSize = set.sizex();
-
- if (startSize >= max + (maxMem > 0 ? 1 : this.batchSize)) {
- for (int i = max; i < startSize && set.sizex() > max; i++) {
- if (shrink0() == -1)
- break;
- }
- }
- }
+ /** {@inheritDoc} */
+ @Override public int getCurrentSize() {
+ return set.size();
}
/**
@@ -303,7 +185,7 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
*
* @return number of bytes that was free. {@code -1} if queue is empty.
*/
- private int shrink0() {
+ @Override protected int shrink0() {
Holder<K, V> h = set.pollFirst();
if (h == null)
@@ -313,10 +195,10 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
EvictableEntry<K, V> entry = h.entry;
- if (h.order > 0 && entry.removeMeta(h)) {
+ if (entry != null && h.order > 0 && entry.removeMeta(h)) {
size = entry.size();
- memSize.add(-size);
+ addToMemorySize(-size);
if (!entry.evict())
touch(entry);
@@ -327,33 +209,31 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K, V>, SortedE
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(max);
- out.writeInt(batchSize);
- out.writeLong(maxMemSize);
+ super.writeExternal(out);
out.writeObject(comp);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- max = in.readInt();
- batchSize = in.readInt();
- maxMemSize = in.readLong();
+ super.readExternal(in);
comp = (Comparator<Holder<K, V>>)in.readObject();
}
/**
* Removes holder from backed queue and marks holder as removed.
*
- * @param holder Holder.
+ * @param meta Holder.
*/
- private void removeHolder(Holder<K, V> holder) {
+ @Override protected boolean removeMeta(Object meta) {
+ Holder<K, V> holder = (Holder<K, V>)meta;
+
long order0 = holder.order;
if (order0 > 0)
holder.order = -order0;
- set.remove(holder);
+ return set.remove(holder);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
index 3f5003a..8e4590e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
@@ -53,7 +53,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.eviction.EvictionPolicy;
import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyMBean;
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicyMBean;
-import org.apache.ignite.cache.eviction.random.RandomEvictionPolicyMBean;
+import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicyMBean;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
@@ -693,12 +693,12 @@ public class VisorTaskUtils {
if (plc instanceof LruEvictionPolicyMBean)
return ((LruEvictionPolicyMBean)plc).getMaxSize();
- if (plc instanceof RandomEvictionPolicyMBean)
- return ((RandomEvictionPolicyMBean)plc).getMaxSize();
-
if (plc instanceof FifoEvictionPolicyMBean)
return ((FifoEvictionPolicyMBean)plc).getMaxSize();
+ if (plc instanceof SortedEvictionPolicyMBean)
+ return ((SortedEvictionPolicyMBean)plc).getMaxSize();
+
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 8cfed3a..eb8bfad 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -67,7 +67,6 @@ org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy
org.apache.ignite.cache.eviction.igfs.IgfsEvictionFilter
org.apache.ignite.cache.eviction.igfs.IgfsPerBlockLruEvictionPolicy
org.apache.ignite.cache.eviction.lru.LruEvictionPolicy
-org.apache.ignite.cache.eviction.random.RandomEvictionPolicy
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy$DefaultHolderComparator
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy$GridConcurrentSkipListSetEx
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
index a1f917f..7157531 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
@@ -31,7 +31,7 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.eviction.EvictionFilter;
import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
-import org.apache.ignite.cache.eviction.random.RandomEvictionPolicy;
+import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DeploymentMode;
@@ -382,7 +382,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac
new C1<CacheConfiguration, Void>() {
/** {@inheritDoc} */
@Override public Void apply(CacheConfiguration cfg) {
- cfg.setEvictionPolicy(new RandomEvictionPolicy());
+ cfg.setEvictionPolicy(new SortedEvictionPolicy());
return null;
}
},
@@ -632,7 +632,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac
@Override public Void apply(CacheConfiguration cfg) {
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
- nearCfg.setNearEvictionPolicy(new RandomEvictionPolicy());
+ nearCfg.setNearEvictionPolicy(new LruEvictionPolicy());
cfg.setNearConfiguration(nearCfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/19566fbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java
index 4acf1af..cee04ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java
@@ -1030,7 +1030,7 @@ public abstract class EvictionAbstractTest<T extends EvictionPolicy<?, ?>>
*/
public long getCurrentMemorySize() {
try {
- return (Long)plc.getClass().getDeclaredMethod("getCurrentMemorySize").invoke(plc);
+ return (Long)plc.getClass().getMethod("getCurrentMemorySize").invoke(plc);
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
@@ -1056,7 +1056,7 @@ public abstract class EvictionAbstractTest<T extends EvictionPolicy<?, ?>>
@Override public void onEntryAccessed(boolean rmv, EvictableEntry entry) {
try {
plc.getClass()
- .getDeclaredMethod("onEntryAccessed", boolean.class, EvictableEntry.class)
+ .getMethod("onEntryAccessed", boolean.class, EvictableEntry.class)
.invoke(plc, rmv, entry);
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {