You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/08/13 10:09:30 UTC
ignite git commit: IGNITE-9056 Disallow calling clear() on
ConcurrentLinkedHashMap. - Fixes #4420.
Repository: ignite
Updated Branches:
refs/heads/master 2d63040fd -> d04d76440
IGNITE-9056 Disallow calling clear() on ConcurrentLinkedHashMap. - Fixes #4420.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d04d7644
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d04d7644
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d04d7644
Branch: refs/heads/master
Commit: d04d76440ce86873de7aebc8c03d39484cd1e3e5
Parents: 2d63040
Author: Ilya Kasnacheev <il...@gmail.com>
Authored: Mon Aug 13 13:07:28 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Aug 13 13:07:28 2018 +0300
----------------------------------------------------------------------
.../processors/job/GridJobProcessor.java | 6 +++--
.../ignite/internal/util/GridLogThrottle.java | 6 ++---
.../ignite/marshaller/MarshallerExclusions.java | 6 ++---
.../org/jsr166/ConcurrentLinkedHashMap.java | 26 +-------------------
.../GridCacheWriteBehindStoreSelfTest.java | 6 +++--
.../processors/query/h2/IgniteH2Indexing.java | 4 +--
6 files changed, 17 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index ae9cb7e..bc05cc7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -132,7 +132,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
private final Collection<IgniteUuid> heldJobs = new GridConcurrentHashSet<>();
/** If value is {@code true}, job was cancelled from future. */
- private final GridBoundedConcurrentLinkedHashMap<IgniteUuid, Boolean> cancelReqs =
+ private volatile GridBoundedConcurrentLinkedHashMap<IgniteUuid, Boolean> cancelReqs =
new GridBoundedConcurrentLinkedHashMap<>(FINISHED_JOBS_COUNT,
FINISHED_JOBS_COUNT < 128 ? FINISHED_JOBS_COUNT : 128,
0.75f, 16);
@@ -263,7 +263,9 @@ public class GridJobProcessor extends GridProcessorAdapter {
// Clear collections.
activeJobs.clear();
cancelledJobs.clear();
- cancelReqs.clear();
+ cancelReqs = new GridBoundedConcurrentLinkedHashMap<>(FINISHED_JOBS_COUNT,
+ FINISHED_JOBS_COUNT < 128 ? FINISHED_JOBS_COUNT : 128,
+ 0.75f, 16);
if (log.isDebugEnabled())
log.debug("Job processor stopped.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
index b0b4d80..feae512 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
@@ -48,8 +48,8 @@ public class GridLogThrottle {
private static final int throttleCap = IgniteSystemProperties.getInteger(IGNITE_LOG_THROTTLE_CAPACITY, 128);
/** Errors. */
- private static final ConcurrentMap<IgniteBiTuple<Class<? extends Throwable>, String>, Long> errors =
- new ConcurrentLinkedHashMap<>(throttleCap, 1f, DFLT_CONCUR_LVL, throttleCap);
+ private static volatile ConcurrentMap<IgniteBiTuple<Class<? extends Throwable>, String>, Long> errors =
+ new ConcurrentLinkedHashMap<>(throttleCap, 0.75f, DFLT_CONCUR_LVL, throttleCap);
/**
* Sets system-wide log throttle timeout.
@@ -175,7 +175,7 @@ public class GridLogThrottle {
* Clears all stored data. This will make throttle to behave like a new one.
*/
public static void clear() {
- errors.clear();
+ errors = new ConcurrentLinkedHashMap<>(throttleCap, 0.75f, DFLT_CONCUR_LVL, throttleCap);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerExclusions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerExclusions.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerExclusions.java
index fba35e2..8302427 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerExclusions.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerExclusions.java
@@ -50,7 +50,7 @@ public final class MarshallerExclusions {
};
/** */
- private static final Map<Class<?>, Boolean> cache = new GridBoundedConcurrentLinkedHashMap<>(
+ private static volatile Map<Class<?>, Boolean> cache = new GridBoundedConcurrentLinkedHashMap<>(
512, 512, 0.75f, 16);
/**
@@ -153,6 +153,6 @@ public final class MarshallerExclusions {
* Intended for test purposes only.
*/
public static void clearCache() {
- cache.clear();
+ cache = new GridBoundedConcurrentLinkedHashMap<>(512, 512, 0.75f, 16);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
index 68469b3..5c9b4ac 100644
--- a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
+++ b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
@@ -988,29 +988,6 @@ public class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V> implements
return oldVal;
}
-
- /**
- *
- */
- void clear() {
- if (cnt != 0) {
- writeLock().lock();
-
- try {
- HashEntry<K, V>[] tab = tbl;
-
- for (int i = 0; i < tab.length ; i++)
- tab[i] = null;
-
- ++modCnt;
-
- cnt = 0; // write-volatile
- }
- finally {
- writeLock().unlock();
- }
- }
- }
}
/* ---------------- Public operations -------------- */
@@ -1571,8 +1548,7 @@ public class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V> implements
* Removes all of the mappings from this map.
*/
@Override public void clear() {
- for (Segment<K, V> segment : segments)
- segment.clear();
+ throw new UnsupportedOperationException();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
index af21fc8..538f135 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
@@ -412,7 +412,9 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
* @throws Exception If failed.
*/
private void testBatchApply(boolean writeCoalescing) throws Exception {
- delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>());
+ delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>() {
+ @Override public void clear() { }
+ });
initStore(1, writeCoalescing);
@@ -433,4 +435,4 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
assertTrue("Store map key set: " + underlyingMap.keySet(), F.eqOrdered(underlyingMap.keySet(), intList));
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d04d7644/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index d059306..e70dd42 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -358,7 +358,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
private final ConcurrentHashMap<Thread, H2StatementCache> stmtCache = new ConcurrentHashMap<>();
/** */
- private final GridBoundedConcurrentLinkedHashMap<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery> twoStepCache =
+ private volatile GridBoundedConcurrentLinkedHashMap<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery> twoStepCache =
new GridBoundedConcurrentLinkedHashMap<>(TWO_STEP_QRY_CACHE_SIZE);
/** */
@@ -2953,7 +2953,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* Remove all cached queries from cached two-steps queries.
*/
private void clearCachedQueries() {
- twoStepCache.clear();
+ twoStepCache = new GridBoundedConcurrentLinkedHashMap<>(TWO_STEP_QRY_CACHE_SIZE);
}
/** {@inheritDoc} */