You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/04/07 08:06:32 UTC
[6/6] ignite git commit: ignite-2630 Minor
ignite-2630 Minor
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b4d997da
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b4d997da
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b4d997da
Branch: refs/heads/ignite-2630
Commit: b4d997dae5f15509fa2817f672c8f3a01a9904d8
Parents: e4fae00
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 7 09:01:35 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 7 09:01:35 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/CacheInterceptorEntry.java | 4 +-
.../cache/query/CacheQueryEntryEvent.java | 12 +--
.../processors/cache/CacheLazyEntry.java | 3 +-
...torPartitionCounterRandomOperationsTest.java | 78 +++++++++++---------
4 files changed, 52 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d997da/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorEntry.java
index a9bd8f5..61be00a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorEntry.java
@@ -22,8 +22,8 @@ import javax.cache.Cache;
/**
* A cache interceptor map entry.
*
- * @param <K> the type of key
- * @param <V> the type of value
+ * @param <K> The type of key.
+ * @param <V> The type of value.
*/
public abstract class CacheInterceptorEntry<K, V> implements Cache.Entry<K, V> {
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d997da/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryEntryEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryEntryEvent.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryEntryEvent.java
index 2c1c5e6..3a7994f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryEntryEvent.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryEntryEvent.java
@@ -24,18 +24,18 @@ import javax.cache.event.EventType;
/**
* A Cache continuous query entry event.
*
- * @param <K> the type of key
- * @param <V> the type of value
+ * @param <K> The type of key.
+ * @param <V> The type of value.
*/
public abstract class CacheQueryEntryEvent<K, V> extends CacheEntryEvent<K, V> {
/**
* Constructs a cache entry event from a given cache as source.
*
- * @param source the cache that originated the event
- * @param eventType Event type.
+ * @param src The cache that originated the event.
+ * @param evtType Event type.
*/
- public CacheQueryEntryEvent(Cache source, EventType eventType) {
- super(source, eventType);
+ public CacheQueryEntryEvent(Cache src, EventType evtType) {
+ super(src, evtType);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d997da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index c641322..c8cfc99 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -81,6 +81,7 @@ public class CacheLazyEntry<K, V> extends CacheInterceptorEntry<K, V> {
* @param key Key value.
* @param valObj Cache object
* @param keepBinary Keep binary flag.
+ * @param updateCntr Partition update counter.
* @param val Cache value.
*/
public CacheLazyEntry(GridCacheContext ctx,
@@ -108,7 +109,7 @@ public class CacheLazyEntry<K, V> extends CacheInterceptorEntry<K, V> {
* @param keepBinary Keep binary flag.
* @param val Cache value.
*/
- public CacheLazyEntry(GridCacheContext<K, V> ctx,
+ public CacheLazyEntry(GridCacheContext ctx,
KeyCacheObject keyObj,
K key,
CacheObject valObj,
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d997da/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java
index d034af0..055374d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java
@@ -97,11 +97,11 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
private boolean client;
/** */
- private static ConcurrentMap<UUID, BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>>
+ private static ConcurrentMap<UUID, BlockingQueue<Cache.Entry<TestKey, TestValue>>>
afterPutEvts = new ConcurrentHashMap<>();
/** */
- private static ConcurrentMap<UUID, BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>>
+ private static ConcurrentMap<UUID, BlockingQueue<Cache.Entry<TestKey, TestValue>>>
afterRmvEvts = new ConcurrentHashMap<>();
/** {@inheritDoc} */
@@ -140,9 +140,9 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
for (int i = 0; i < NODES; i++) {
afterRmvEvts.put(grid(i).cluster().localNode().id(),
- new BlockingArrayQueue<Cache.Entry<QueryTestKey, QueryTestValue>>());
+ new BlockingArrayQueue<Cache.Entry<TestKey, TestValue>>());
afterPutEvts.put(grid(i).cluster().localNode().id(),
- new BlockingArrayQueue<Cache.Entry<QueryTestKey, QueryTestValue>>());
+ new BlockingArrayQueue<Cache.Entry<TestKey, TestValue>>());
}
}
@@ -451,7 +451,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
Map<Integer, Long> partCntr,
IgniteCache<Object, Object> cache)
throws Exception {
- Object key = new QueryTestKey(rnd.nextInt(KEYS));
+ Object key = new TestKey(rnd.nextInt(KEYS));
Object newVal = value(rnd);
Object oldVal = expData.get(key);
@@ -689,7 +689,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
* @param rmv Remove operation.
* @return Queues.
*/
- @NotNull private List<BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>> getInterceptorQueues(
+ @NotNull private List<BlockingQueue<Cache.Entry<TestKey, TestValue>>> getInterceptorQueues(
IgniteCache<Object, Object> cache,
Object key,
boolean rmv
@@ -697,9 +697,11 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
Collection<ClusterNode> nodes =
cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL ?
affinity(cache).mapKeyToPrimaryAndBackups(key) :
- Collections.singletonList(affinity(cache).mapKeyToPrimaryAndBackups(key).iterator().next());
+ Collections.singletonList(affinity(cache).mapKeyToNode(key));
- List<BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>> queues = new ArrayList<>();
+ assert nodes.size() > 0;
+
+ List<BlockingQueue<Cache.Entry<TestKey, TestValue>>> queues = new ArrayList<>();
for (ClusterNode node : nodes)
queues.add(rmv ? afterRmvEvts.get(node.id()) : afterPutEvts.get(node.id()));
@@ -753,7 +755,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
* @return Cache value.
*/
private static Object value(Random rnd) {
- return new QueryTestValue(rnd.nextInt(VALS));
+ return new TestValue(rnd.nextInt(VALS));
}
/**
@@ -766,7 +768,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
* @param rmv Remove operation.
* @throws Exception If failed.
*/
- private void waitAndCheckEvent(IgniteCache cache,
+ private void waitAndCheckEvent(IgniteCache<Object, Object> cache,
Map<Integer, Long> partCntrs,
Affinity<Object> aff,
Object key,
@@ -774,29 +776,33 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
Object oldVal,
boolean rmv)
throws Exception {
- Collection<BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>> entries = getInterceptorQueues(cache, key,
+ Collection<BlockingQueue<Cache.Entry<TestKey, TestValue>>> entries = getInterceptorQueues(cache, key,
rmv);
+ assert !entries.isEmpty();
+
if (val == null && oldVal == null) {
checkNoEvent(entries);
return;
}
- for (BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> evtsQueue : entries) {
- Cache.Entry<QueryTestKey, QueryTestValue> entry = evtsQueue.poll(5, SECONDS);
+ for (BlockingQueue<Cache.Entry<TestKey, TestValue>> evtsQueue : entries) {
+ Cache.Entry<TestKey, TestValue> entry = evtsQueue.poll(5, SECONDS);
assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']', entry);
assertEquals(key, entry.getKey());
assertEquals(rmv ? oldVal : val, entry.getValue());
long cntr = partCntrs.get(aff.partition(key));
- CacheInterceptorEntry qryEntryEvt = entry.unwrap(CacheInterceptorEntry.class);
+ CacheInterceptorEntry interceptorEntry = entry.unwrap(CacheInterceptorEntry.class);
assertNotNull(cntr);
- assertNotNull(qryEntryEvt);
+ assertNotNull(interceptorEntry);
+
+ assertEquals(cntr, interceptorEntry.getPartitionUpdateCounter());
- assertEquals(cntr, qryEntryEvt.getPartitionUpdateCounter());
+ assertNull(evtsQueue.peek());
}
}
@@ -804,10 +810,10 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
* @param evtsQueues Event queue.
* @throws Exception If failed.
*/
- private void checkNoEvent(Collection<BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>>> evtsQueues)
+ private void checkNoEvent(Collection<BlockingQueue<Cache.Entry<TestKey, TestValue>>> evtsQueues)
throws Exception {
- for (BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> evtsQueue : evtsQueues) {
- Cache.Entry<QueryTestKey, QueryTestValue> evt = evtsQueue.poll(50, MILLISECONDS);
+ for (BlockingQueue<Cache.Entry<TestKey, TestValue>> evtsQueue : evtsQueues) {
+ Cache.Entry<TestKey, TestValue> evt = evtsQueue.poll(50, MILLISECONDS);
assertTrue(evt == null || evt.getValue() == null);
}
@@ -828,7 +834,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
CacheAtomicityMode atomicityMode,
CacheMemoryMode memoryMode,
boolean store) {
- CacheConfiguration<QueryTestKey, QueryTestValue> ccfg = new CacheConfiguration<>();
+ CacheConfiguration<TestKey, TestValue> ccfg = new CacheConfiguration<>();
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
@@ -876,14 +882,14 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
/**
*
*/
- public static class QueryTestKey implements Serializable, Comparable {
+ public static class TestKey implements Serializable, Comparable {
/** */
private final Integer key;
/**
* @param key Key.
*/
- public QueryTestKey(Integer key) {
+ public TestKey(Integer key) {
this.key = key;
}
@@ -895,7 +901,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
if (o == null || getClass() != o.getClass())
return false;
- QueryTestKey that = (QueryTestKey)o;
+ TestKey that = (TestKey)o;
return key.equals(that.key);
}
@@ -907,32 +913,32 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(QueryTestKey.class, this);
+ return S.toString(TestKey.class, this);
}
/** {@inheritDoc} */
@Override public int compareTo(Object o) {
- return key - ((QueryTestKey)o).key;
+ return key - ((TestKey)o).key;
}
}
/**
*
*/
- private static class TestInterceptor extends CacheInterceptorAdapter<QueryTestKey, QueryTestValue> {
+ private static class TestInterceptor extends CacheInterceptorAdapter<TestKey, TestValue> {
/** {@inheritDoc} */
- @Override public void onAfterPut(Cache.Entry<QueryTestKey, QueryTestValue> e) {
+ @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> e) {
e.getKey();
e.getValue();
UUID id = e.unwrap(Ignite.class).cluster().localNode().id();
- BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> ents = afterPutEvts.get(id);
+ BlockingQueue<Cache.Entry<TestKey, TestValue>> ents = afterPutEvts.get(id);
if (ents == null) {
ents = new BlockingArrayQueue<>();
- BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> oldVal = afterPutEvts.putIfAbsent(id, ents);
+ BlockingQueue<Cache.Entry<TestKey, TestValue>> oldVal = afterPutEvts.putIfAbsent(id, ents);
ents = oldVal == null ? ents : oldVal;
}
@@ -941,18 +947,18 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
}
/** {@inheritDoc} */
- @Override public void onAfterRemove(Cache.Entry<QueryTestKey, QueryTestValue> e) {
+ @Override public void onAfterRemove(Cache.Entry<TestKey, TestValue> e) {
e.getKey();
e.getValue();
UUID id = e.unwrap(Ignite.class).cluster().localNode().id();
- BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> ents = afterRmvEvts.get(id);
+ BlockingQueue<Cache.Entry<TestKey, TestValue>> ents = afterRmvEvts.get(id);
if (ents == null) {
ents = new BlockingArrayQueue<>();
- BlockingQueue<Cache.Entry<QueryTestKey, QueryTestValue>> oldVal = afterRmvEvts.putIfAbsent(id, ents);
+ BlockingQueue<Cache.Entry<TestKey, TestValue>> oldVal = afterRmvEvts.putIfAbsent(id, ents);
ents = oldVal == null ? ents : oldVal;
}
@@ -964,7 +970,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
/**
*
*/
- public static class QueryTestValue implements Serializable {
+ public static class TestValue implements Serializable {
/** */
@GridToStringInclude
protected final Integer val1;
@@ -976,7 +982,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
/**
* @param val Value.
*/
- public QueryTestValue(Integer val) {
+ public TestValue(Integer val) {
this.val1 = val;
this.val2 = String.valueOf(val);
}
@@ -989,7 +995,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
if (o == null || getClass() != o.getClass())
return false;
- QueryTestValue that = (QueryTestValue) o;
+ TestValue that = (TestValue) o;
return val1.equals(that.val1) && val2.equals(that.val2);
}
@@ -1005,7 +1011,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(QueryTestValue.class, this);
+ return S.toString(TestValue.class, this);
}
}