You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/08/18 18:11:55 UTC
[06/46] incubator-ignite git commit: ignite-946: supported
VersionedEntry for IgniteCache.localEntries() when OFF_HEAP mode is used
ignite-946: supported VersionedEntry for IgniteCache.localEntries() when OFF_HEAP mode is used
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2d200a31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2d200a31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2d200a31
Branch: refs/heads/ignite-843
Commit: 2d200a31b9903a165c9d70ec84b687e7bcc55c44
Parents: 719161f
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Jul 31 11:39:47 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Fri Jul 31 15:49:12 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CacheEntryImpl0.java | 5 +++
.../processors/cache/GridCacheSwapManager.java | 8 ++++-
.../cache/version/GridVersionedMapEntry.java | 33 +++++++++++++++++++
.../CacheVersionedEntryAbstractTest.java | 34 ++++++--------------
4 files changed, 55 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2d200a31/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
index d2b1923..a5e27d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
@@ -17,6 +17,9 @@
package org.apache.ignite.internal.processors.cache;
+import org.apache.ignite.cache.version.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+
import javax.cache.*;
import java.util.*;
@@ -49,6 +52,8 @@ public class CacheEntryImpl0<K, V> implements Cache.Entry<K, V> {
@Override public <T> T unwrap(Class<T> cls) {
if(cls.isAssignableFrom(getClass()))
return cls.cast(this);
+ else if (cls.isAssignableFrom(VersionedEntry.class) && e instanceof GridVersionedMapEntry)
+ return (T)new CacheVersionedEntryImpl<>(e.getKey(), e.getValue(), ((GridVersionedMapEntry)e).version());
throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2d200a31/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 9e9c958..0530c19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -1513,7 +1513,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
@Override protected Map.Entry<K, V> onNext() {
final Map.Entry<byte[], byte[]> cur0 = it.next();
- cur = new Map.Entry<K, V>() {
+ cur = new GridVersionedMapEntry<K, V>() {
@Override public K getKey() {
try {
KeyCacheObject key = cctx.toCacheKeyObject(cur0.getKey());
@@ -1538,6 +1538,12 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
}
+ @Override public GridCacheVersion version() {
+ GridCacheSwapEntry e = unmarshalSwapEntry(cur0.getValue());
+
+ return e.version();
+ }
+
@Override public V setValue(V val) {
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2d200a31/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
new file mode 100644
index 0000000..f653fac
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
@@ -0,0 +1,33 @@
+/*
+ * 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.version;
+
+import java.util.*;
+
+/**
+ * This interface extends {@link java.util.Map.Entry} by adding the method that returns entry's
+ * {@link GridCacheVersion}.
+ */
+public interface GridVersionedMapEntry<K, V> extends Map.Entry<K, V> {
+ /**
+ * Gets entry version.
+ *
+ * @return Entry version.
+ */
+ public GridCacheVersion version();
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2d200a31/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 4cfacb7..25a2a42 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
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.*;
*/
public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractSelfTest {
/** Entries number to store in a cache. */
- private static final int ENTRIES_NUM = 1000;
+ private static final int ENTRIES_NUM = 500;
/** {@inheritDoc} */
@Override protected int gridCount() {
@@ -57,21 +57,19 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
final AtomicInteger invoked = new AtomicInteger();
- for (int i = 0; i < ENTRIES_NUM; i++) {
- cache.invoke(i, new EntryProcessor<Integer, String, Object>() {
- @Override public Object process(MutableEntry<Integer, String> entry, Object... arguments)
- throws EntryProcessorException {
+ cache.invoke(100, new EntryProcessor<Integer, String, Object>() {
+ @Override public Object process(MutableEntry<Integer, String> entry, Object... arguments)
+ throws EntryProcessorException {
- invoked.incrementAndGet();
+ invoked.incrementAndGet();
- VersionedEntry<Integer, String> verEntry = entry.unwrap(VersionedEntry.class);
+ VersionedEntry<Integer, String> verEntry = entry.unwrap(VersionedEntry.class);
- checkVersionedEntry(verEntry);
+ checkVersionedEntry(verEntry);
- return entry;
- }
- });
- }
+ return entry;
+ }
+ });
assert invoked.get() > 0;
}
@@ -119,18 +117,6 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
/**
* @throws Exception If failed.
*/
- public void testIterator() throws Exception {
- IgniteCache<Integer, String> cache = grid(0).cache(null);
-
- Iterator<Cache.Entry<Integer, String>> entries = cache.iterator();
-
- while (entries.hasNext())
- checkVersionedEntry(entries.next().unwrap(VersionedEntry.class));
- }
-
- /**
- * @throws Exception If failed.
- */
public void testLocalPeek() throws Exception {
IgniteCache<Integer, String> cache = grid(0).cache(null);