From bd7b86628aa2520619226fcf48abec6e48f66551 Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Thu, 30 Jul 2015 13:50:40 +0300 Subject: [PATCH 1/7] ignite-946: introduced VersionedEntry, supported versioned entry for Cache.invoke/randomEntry/localEntries methods --- .../ignite/cache/version/VersionedEntry.java | 73 +++++++++++++++ .../apache/ignite/cache/version/package-info.java | 21 +++++ .../internal/processors/cache/CacheEntryImpl.java | 20 ++++ .../processors/cache/CacheInvokeEntry.java | 24 ++++- .../processors/cache/CacheVersionedEntryImpl.java | 80 ---------------- .../processors/cache/GridCacheAdapter.java | 13 ++- .../processors/cache/GridCacheMapEntry.java | 42 ++++++--- .../distributed/dht/GridDhtTxPrepareFuture.java | 2 +- .../distributed/dht/atomic/GridDhtAtomicCache.java | 3 +- .../cache/local/atomic/GridLocalAtomicCache.java | 3 +- .../cache/transactions/IgniteTxAdapter.java | 2 +- .../cache/transactions/IgniteTxEntry.java | 3 +- .../cache/transactions/IgniteTxLocalAdapter.java | 3 +- .../cache/version/CacheVersionedEntryImpl.java | 102 +++++++++++++++++++++ .../main/resources/META-INF/classnames.properties | 2 +- 15 files changed, 287 insertions(+), 106 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java create mode 100644 modules/core/src/main/java/org/apache/ignite/cache/version/package-info.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java diff --git a/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java new file mode 100644 index 0000000..6f9d8f6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java @@ -0,0 +1,73 @@ +/* + * 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.version; + +import javax.cache.*; +import java.util.*; + +/** + * Cache entry along with version information. + */ +public interface VersionedEntry extends Cache.Entry { + /** + * Versions comparator. + */ + public static final Comparator VERSIONS_COMPARATOR = new Comparator() { + @Override public int compare(VersionedEntry o1, VersionedEntry o2) { + int res = Integer.compare(o1.topologyVersion(), o2.topologyVersion()); + + if (res != 0) + return res; + + res = Long.compare(o1.order(), o2.order()); + + if (res != 0) + return res; + + return Integer.compare(o1.nodeOrder(), o2.nodeOrder()); + } + }; + + /** + * Gets entry's topology version. + * + * @return Topology version plus number of seconds from the start time of the first grid node. + */ + public int topologyVersion(); + + /** + * Gets entry's order. + * + * @return Version order. + */ + public long order(); + + /** + * Gets entry's node order. + * + * @return Node order on which this version was assigned. + */ + public int nodeOrder(); + + /** + * Gets entry's global time. + * + * @return Adjusted time. + */ + public long globalTime(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/cache/version/package-info.java b/modules/core/src/main/java/org/apache/ignite/cache/version/package-info.java new file mode 100644 index 0000000..9aeaba2 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/version/package-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ + +/** + * Contains cache version based implementations. + */ +package org.apache.ignite.cache.version; \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java index 3bd7ef4..98f3616 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.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.io.*; @@ -33,6 +36,9 @@ public class CacheEntryImpl implements Cache.Entry, Externalizable { /** */ private V val; + /** Entry version. */ + private GridCacheVersion ver; + /** * Required by {@link Externalizable}. */ @@ -49,6 +55,17 @@ public class CacheEntryImpl implements Cache.Entry, Externalizable { this.val = val; } + /** + * @param key Key. + * @param val Value. + * @param ver Entry version. + */ + public CacheEntryImpl(K key, V val, GridCacheVersion ver) { + this.key = key; + this.val = val; + this.ver = ver; + } + /** {@inheritDoc} */ @Override public K getKey() { return key; @@ -65,6 +82,9 @@ public class CacheEntryImpl implements Cache.Entry, Externalizable { if(cls.isAssignableFrom(getClass())) return cls.cast(this); + if (ver != null && cls.isAssignableFrom(VersionedEntry.class)) + return (T)new CacheVersionedEntryImpl<>(key, val, ver); + throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java index 2817748..e6f8d4e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.version.*; +import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.jetbrains.annotations.*; @@ -35,17 +37,23 @@ public class CacheInvokeEntry extends CacheLazyEntry implements Muta /** */ private V oldVal; + /** Entry version. */ + private GridCacheVersion ver; + /** * @param cctx Cache context. * @param keyObj Key cache object. * @param valObj Cache object value. + * @param ver Entry version. */ public CacheInvokeEntry(GridCacheContext cctx, KeyCacheObject keyObj, - @Nullable CacheObject valObj) { + @Nullable CacheObject valObj, + GridCacheVersion ver) { super(cctx, keyObj, valObj); this.hadVal = valObj != null; + this.ver = ver; } /** @@ -54,15 +62,18 @@ public class CacheInvokeEntry extends CacheLazyEntry implements Muta * @param key Key value. * @param valObj Value cache object. * @param val Value. + * @param ver Entry version. */ public CacheInvokeEntry(GridCacheContext ctx, KeyCacheObject keyObj, @Nullable K key, @Nullable CacheObject valObj, - @Nullable V val) { + @Nullable V val, + GridCacheVersion ver) { super(ctx, keyObj, key, valObj, val); this.hadVal = valObj != null || val != null; + this.ver = ver; } /** {@inheritDoc} */ @@ -108,6 +119,15 @@ public class CacheInvokeEntry extends CacheLazyEntry implements Muta } /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public T unwrap(Class cls) { + if (cls.isAssignableFrom(VersionedEntry.class)) + return (T)new CacheVersionedEntryImpl<>(getKey(), getValue(), ver); + + return super.unwrap(cls); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheInvokeEntry.class, this); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java deleted file mode 100644 index 59394f5..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java +++ /dev/null @@ -1,80 +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 org.jetbrains.annotations.*; - -import java.io.*; - -/** - * - */ -public class CacheVersionedEntryImpl extends CacheEntryImpl { - /** */ - private static final long serialVersionUID = 0L; - - /** Version. */ - private Object ver; - - /** - * Required by {@link Externalizable}. - */ - public CacheVersionedEntryImpl() { - // No-op. - } - - /** - * @param key Key. - * @param val Value (always null). - * @param ver Version. - */ - public CacheVersionedEntryImpl(K key, V val, Object ver) { - super(key, val); - - assert val == null; - - this.ver = ver; - } - - /** - * @return Version. - */ - @Nullable public Object version() { - return ver; - } - - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - - out.writeObject(ver); - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - - ver = in.readObject(); - } - - /** {@inheritDoc} */ - public String toString() { - return "VersionedEntry [key=" + getKey() + ", val=" + getValue() + ", ver=" + ver + ']'; - } -} 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 94bcc93..d125382 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 @@ -3691,7 +3691,16 @@ public abstract class GridCacheAdapter implements IgniteInternalCache(lazyEntry.getKey(), val); + GridCacheVersion ver = null; + + try { + ver = lazyEntry.unwrap(GridCacheVersion.class); + } + catch (IllegalArgumentException e) { + log.error("Failed to unwrap entry version information", e); + } + + return new CacheEntryImpl<>(lazyEntry.getKey(), val, ver); } catch (IgniteCheckedException e) { throw CU.convertToCacheException(e); @@ -4614,7 +4623,7 @@ public abstract class GridCacheAdapter implements IgniteInternalCache((K)key0, (V)val0); + return new CacheEntryImpl<>((K)key0, (V)val0, entry.version()); } catch (GridCacheFilterFailedException ignore) { assert false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index f85a18b..45ff619 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -609,16 +609,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme @Nullable IgniteCacheExpiryPolicy expirePlc) throws IgniteCheckedException, GridCacheEntryRemovedException { return innerGet0(tx, - readSwap, - readThrough, - evt, - unmarshal, - updateMetrics, - tmp, - subjId, - transformClo, - taskName, - expirePlc); + readSwap, + readThrough, + evt, + unmarshal, + updateMetrics, + tmp, + subjId, + transformClo, + taskName, + expirePlc); } /** {@inheritDoc} */ @@ -1385,7 +1385,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme assert entryProcessor != null; - CacheInvokeEntry entry = new CacheInvokeEntry<>(cctx, key, old); + CacheInvokeEntry entry = new CacheInvokeEntry<>(cctx, key, old, this.ver); try { Object computed = entryProcessor.process(entry, invokeArgs); @@ -1653,7 +1653,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme oldVal = rawGetOrUnmarshalUnlocked(true); - CacheInvokeEntry entry = new CacheInvokeEntry(cctx, key, oldVal); + CacheInvokeEntry entry = new CacheInvokeEntry(cctx, key, oldVal, this.ver); try { Object computed = entryProcessor.process(entry, invokeArgs); @@ -1878,7 +1878,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme EntryProcessor entryProcessor = (EntryProcessor)writeObj; - CacheInvokeEntry entry = new CacheInvokeEntry(cctx, key, oldVal); + CacheInvokeEntry entry = new CacheInvokeEntry(cctx, key, oldVal, this.ver); try { Object computed = entryProcessor.process(entry, invokeArgs); @@ -3531,7 +3531,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme val = rawGetOrUnmarshal(false); return new CacheEntryImpl<>(key.value(cctx.cacheObjectContext(), false), - CU.value(val, cctx, false)); + CU.value(val, cctx, false), ver); } catch (GridCacheFilterFailedException ignored) { throw new IgniteException("Should never happen."); @@ -3593,6 +3593,15 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme return new CacheVersionedEntryImpl<>(key.value(cctx.cacheObjectContext(), false), null, ver); } + /** + * @return Entry which holds key, value and version. + */ + private synchronized CacheVersionedEntryImpl wrapVersionedWithValue() { + V val = this.val == null ? null : this.val.value(cctx.cacheObjectContext(), false); + + return new CacheVersionedEntryImpl<>(key.value(cctx.cacheObjectContext(), false), val, ver); + } + /** {@inheritDoc} */ @Override public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException { @@ -4020,7 +4029,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme return (T)wrapEviction(); if (cls.isAssignableFrom(CacheVersionedEntryImpl.class)) - return (T)wrapVersioned(); + return cls == CacheVersionedEntryImpl.class ? (T)wrapVersioned() : (T)wrapVersionedWithValue(); + + if (cls.isAssignableFrom(GridCacheVersion.class)) + return (T)ver; if (cls.isAssignableFrom(GridCacheMapEntry.this.getClass())) return (T)GridCacheMapEntry.this; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index fbc8c84..9bd5de2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -324,7 +324,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture, Object[]> t : txEntry.entryProcessors()) { try { CacheInvokeEntry invokeEntry = - new CacheInvokeEntry<>(txEntry.context(), key, val); + new CacheInvokeEntry<>(txEntry.context(), key, val, txEntry.cached().version()); EntryProcessor processor = t.get1(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 0a21979..5dff4ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -1313,7 +1313,8 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { Object oldVal = null; Object updatedVal = null; - CacheInvokeEntry invokeEntry = new CacheInvokeEntry(ctx, entry.key(), old); + CacheInvokeEntry invokeEntry = new CacheInvokeEntry(ctx, entry.key(), old, + entry.version()); CacheObject updated; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java index bcbdec4..8dd3276 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java @@ -1057,7 +1057,8 @@ public class GridLocalAtomicCache extends GridCacheAdapter { Object oldVal = null; - CacheInvokeEntry invokeEntry = new CacheInvokeEntry<>(ctx, entry.key(), old); + CacheInvokeEntry invokeEntry = new CacheInvokeEntry<>(ctx, entry.key(), old, + entry.version()); CacheObject updated; Object updatedVal = null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java index 7190249..0d14012 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java @@ -1230,7 +1230,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter for (T2, Object[]> t : txEntry.entryProcessors()) { CacheInvokeEntry invokeEntry = new CacheInvokeEntry(txEntry.context(), - txEntry.key(), key, cacheVal, val); + txEntry.key(), key, cacheVal, val, txEntry.cached().version()); try { EntryProcessor processor = t.get1(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 247d350..7f06380 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -573,7 +573,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message { for (T2, Object[]> t : entryProcessors()) { try { - CacheInvokeEntry invokeEntry = new CacheInvokeEntry(ctx, key, keyVal, cacheVal, val); + CacheInvokeEntry invokeEntry = new CacheInvokeEntry(ctx, key, keyVal, cacheVal, val, + entry.version()); EntryProcessor processor = t.get1(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 0a61b1a..d8797fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -2522,7 +2522,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter for (T2, Object[]> t : txEntry.entryProcessors()) { CacheInvokeEntry invokeEntry = - new CacheInvokeEntry(txEntry.context(), txEntry.key(), key0, cacheVal, val0); + new CacheInvokeEntry(txEntry.context(), txEntry.key(), key0, cacheVal, val0, + txEntry.cached().version()); EntryProcessor entryProcessor = t.get1(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java new file mode 100644 index 0000000..6d1e0c9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java @@ -0,0 +1,102 @@ +/* + * 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 org.apache.ignite.cache.version.*; +import org.apache.ignite.internal.processors.cache.*; +import org.jetbrains.annotations.*; + +import java.io.*; + +/** + * + */ +public class CacheVersionedEntryImpl extends CacheEntryImpl implements VersionedEntry { + /** */ + private static final long serialVersionUID = 0L; + + /** Version. */ + private GridCacheVersion ver; + + /** + * Required by {@link Externalizable}. + */ + public CacheVersionedEntryImpl() { + // No-op. + } + + /** + * @param key Key. + * @param val Value (always null). + * @param ver Version. + */ + public CacheVersionedEntryImpl(K key, V val, GridCacheVersion ver) { + super(key, val); + + assert val == null; + + this.ver = ver; + } + + /** + * @return Version. + */ + @Nullable public GridCacheVersion version() { + return ver; + } + + /** {@inheritDoc} */ + @Override public int topologyVersion() { + return ver.topologyVersion(); + } + + /** {@inheritDoc} */ + @Override public int nodeOrder() { + return ver.nodeOrder(); + } + + /** {@inheritDoc} */ + @Override public long order() { + return ver.order(); + } + + /** {@inheritDoc} */ + @Override public long globalTime() { + return ver.globalTime(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + + out.writeObject(ver); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + + ver = (GridCacheVersion)in.readObject(); + } + + /** {@inheritDoc} */ + public String toString() { + return "VersionedEntry [key=" + getKey() + ", val=" + getValue() + ", topVer=" + ver.topologyVersion() + + ", nodeOrder=" + ver.nodeOrder() + ", order=" + ver.order() + ", globalTime=" + ver.globalTime() + ']'; + } +} diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index b3eed46..ff75b02 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -289,7 +289,7 @@ org.apache.ignite.internal.processors.cache.CacheOperationContext org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException org.apache.ignite.internal.processors.cache.CacheType -org.apache.ignite.internal.processors.cache.CacheVersionedEntryImpl +org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryImpl org.apache.ignite.internal.processors.cache.CacheWeakQueryIteratorsHolder$WeakQueryFutureIterator org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest -- 1.9.5.msysgit.0 From 84e6b5ed41b056f011b969d2a6e3bb47d503c717 Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Thu, 30 Jul 2015 16:03:18 +0300 Subject: [PATCH 2/7] ignite-946: added tests --- .../cache/version/CacheVersionedEntryImpl.java | 2 - .../version/CacheVersionedEntryAbstractTest.java | 184 +++++++++++++++++++++ .../CacheVersionedEntryLocalAtomicSelfTest.java | 40 +++++ ...heVersionedEntryLocalTransactionalSelfTest.java | 40 +++++ ...ionedEntryPartitionedAtomicOffHeapSelfTest.java | 35 ++++ ...cheVersionedEntryPartitionedAtomicSelfTest.java | 35 ++++ ...tryPartitionedTransactionalOffHeapSelfTest.java | 36 ++++ ...ionedEntryPartitionedTransactionalSelfTest.java | 35 ++++ ...sionedEntryReplicatedAtomicOffHeapSelfTest.java | 35 ++++ ...acheVersionedEntryReplicatedAtomicSelfTest.java | 35 ++++ ...ntryReplicatedTransactionalOffHeapSelfTest.java | 36 ++++ ...sionedEntryReplicatedTransactionalSelfTest.java | 35 ++++ .../ignite/testsuites/IgniteCacheTestSuite4.java | 13 ++ 13 files changed, 559 insertions(+), 2 deletions(-) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicOffHeapSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalSelfTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java index 6d1e0c9..924eff9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryImpl.java @@ -48,8 +48,6 @@ public class CacheVersionedEntryImpl extends CacheEntryImpl implemen public CacheVersionedEntryImpl(K key, V val, GridCacheVersion ver) { super(key, val); - assert val == null; - this.ver = ver; } 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 new file mode 100644 index 0000000..951d05a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java @@ -0,0 +1,184 @@ +/* + * 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 org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.version.*; +import org.apache.ignite.internal.processors.cache.*; + +import javax.cache.*; +import javax.cache.processor.*; +import java.util.*; +import java.util.concurrent.atomic.*; + +/** + * Versioned entry abstract test. + */ +public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractSelfTest { + /** Entries number to store in a cache. */ + private static final int ENTRIES_NUM = 1000; + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 2; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + Cache cache = grid(0).cache(null); + + for (int i = 0 ; i < ENTRIES_NUM; i++) + cache.put(i, "value_" + i); + } + + /** + * @throws Exception If failed. + */ + public void testInvoke() throws Exception { + Cache cache = grid(0).cache(null); + + final AtomicBoolean invoked = new AtomicBoolean(false); + + cache.invoke(100, new EntryProcessor() { + @Override public Object process(MutableEntry entry, Object... arguments) + throws EntryProcessorException { + + invoked.set(true); + + VersionedEntry verEntry = entry.unwrap(VersionedEntry.class); + + checkVersionedEntry(verEntry); + + return entry; + } + }); + + assertTrue(invoked.get()); + } + + /** + * @throws Exception If failed. + */ + public void testInvokeAll() throws Exception { + Cache cache = grid(0).cache(null); + + Set keys = new HashSet<>(); + + for (int i = 0; i < ENTRIES_NUM; i++) + keys.add(i); + + final AtomicInteger invoked = new AtomicInteger(); + + cache.invokeAll(keys, new EntryProcessor() { + @Override public Object process(MutableEntry entry, Object... arguments) + throws EntryProcessorException { + + invoked.incrementAndGet(); + + VersionedEntry verEntry = entry.unwrap(VersionedEntry.class); + + checkVersionedEntry(verEntry); + + return null; + } + }); + + assert invoked.get() > 0; + } + + /** + * @throws Exception If failed. + */ + public void testRandomEntry() throws Exception { + IgniteCache cache = grid(0).cache(null); + + for (int i = 0; i < 5; i++) + checkVersionedEntry(cache.randomEntry().unwrap(VersionedEntry.class)); + } + + /** + * @throws Exception If failed. + */ + public void testIterator() throws Exception { + IgniteCache cache = grid(0).cache(null); + + Iterator> entries = cache.iterator(); + + while (entries.hasNext()) + checkVersionedEntry(entries.next().unwrap(VersionedEntry.class)); + } + + /** + * @throws Exception If failed. + */ + public void testLocalPeek() throws Exception { + IgniteCache cache = grid(0).cache(null); + + Iterable> entries = offheapTiered(cache) ? + cache.localEntries(CachePeekMode.SWAP, CachePeekMode.OFFHEAP) : + cache.localEntries(CachePeekMode.ONHEAP); + + for (Cache.Entry entry : entries) + checkVersionedEntry(entry.unwrap(VersionedEntry.class)); + } + + /** + * @throws Exception If failed. + */ + public void testVersionComparision() throws Exception { + IgniteCache cache = grid(0).cache(null); + + VersionedEntry ver1 = cache.invoke(100, + new EntryProcessor>() { + @Override public VersionedEntry process(MutableEntry entry, + Object... arguments) throws EntryProcessorException { + return entry.unwrap(VersionedEntry.class); + } + }); + + cache.put(100, "new value 100"); + + VersionedEntry ver2 = cache.invoke(100, + new EntryProcessor>() { + @Override public VersionedEntry process(MutableEntry entry, + Object... arguments) throws EntryProcessorException { + return entry.unwrap(VersionedEntry.class); + } + }); + + assert VersionedEntry.VERSIONS_COMPARATOR.compare(ver1, ver2) < 0; + } + + /** + * @param entry Versioned entry. + */ + private void checkVersionedEntry(VersionedEntry entry) { + assertNotNull(entry); + + assert entry.topologyVersion() > 0; + assert entry.order() > 0; + assert entry.nodeOrder() > 0; + assert entry.globalTime() > 0; + + assertNotNull(entry.getKey()); + assertNotNull(entry.getValue()); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java new file mode 100644 index 0000000..a340413 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryLocalAtomicSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.LOCAL; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java new file mode 100644 index 0000000..4833c2c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryLocalTransactionalSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.LOCAL; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicOffHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicOffHeapSelfTest.java new file mode 100644 index 0000000..2f33d84 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicOffHeapSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; + +/** + * + */ +public class CacheVersionedEntryPartitionedAtomicOffHeapSelfTest extends CacheVersionedEntryPartitionedAtomicSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED); + + return cfg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicSelfTest.java new file mode 100644 index 0000000..f2197ad --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedAtomicSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryPartitionedAtomicSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.java new file mode 100644 index 0000000..7494690 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.java @@ -0,0 +1,36 @@ +/* + * 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 org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; + +/** + * + */ +public class CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest extends + CacheVersionedEntryPartitionedTransactionalSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED); + + return cfg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalSelfTest.java new file mode 100644 index 0000000..95a63c8 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryPartitionedTransactionalSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryPartitionedTransactionalSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.java new file mode 100644 index 0000000..dd3fd0c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; + +/** + * + */ +public class CacheVersionedEntryReplicatedAtomicOffHeapSelfTest extends CacheVersionedEntryReplicatedAtomicSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED); + + return cfg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicSelfTest.java new file mode 100644 index 0000000..fd9617d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedAtomicSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryReplicatedAtomicSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.REPLICATED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest.java new file mode 100644 index 0000000..d1bc5c3 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest.java @@ -0,0 +1,36 @@ +/* + * 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 org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; + +/** + * + */ +public class CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest extends + CacheVersionedEntryReplicatedTransactionalSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED); + + return cfg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalSelfTest.java new file mode 100644 index 0000000..8d37e7b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryReplicatedTransactionalSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryReplicatedTransactionalSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.REPLICATED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index 18b2409..dd9c799 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.distributed.dht.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.internal.processors.cache.integration.*; +import org.apache.ignite.internal.processors.cache.version.*; /** * Test suite. @@ -153,6 +154,18 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(CacheReadThroughLocalAtomicRestartSelfTest.class); suite.addTestSuite(CacheReadThroughAtomicRestartSelfTest.class); + // Versioned entry tests + suite.addTestSuite(CacheVersionedEntryLocalAtomicSelfTest.class); + suite.addTestSuite(CacheVersionedEntryLocalTransactionalSelfTest.class); + suite.addTestSuite(CacheVersionedEntryPartitionedAtomicSelfTest.class); + suite.addTestSuite(CacheVersionedEntryPartitionedTransactionalSelfTest.class); + suite.addTestSuite(CacheVersionedEntryPartitionedAtomicOffHeapSelfTest.class); + suite.addTestSuite(CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.class); + suite.addTestSuite(CacheVersionedEntryReplicatedAtomicSelfTest.class); + suite.addTestSuite(CacheVersionedEntryReplicatedTransactionalSelfTest.class); + suite.addTestSuite(CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.class); + suite.addTestSuite(CacheVersionedEntryPartitionedTransactionalOffHeapSelfTest.class); + return suite; } } -- 1.9.5.msysgit.0 From 66d058e30cc3ab9c4f1499b39febaa78ecfe34c1 Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Fri, 31 Jul 2015 10:19:46 +0300 Subject: [PATCH 3/7] ignite-946: improving tests --- .../cache/query/GridCacheQueryManager.java | 1 + .../version/CacheVersionedEntryAbstractTest.java | 24 ++++++------ .../CacheVersionedEntryLocalAtomicSelfTest.java | 40 ------------------- ...sionedEntryLocalAtomicSwapDisabledSelfTest.java | 45 ++++++++++++++++++++++ .../ignite/testsuites/IgniteCacheTestSuite4.java | 2 +- 5 files changed, 60 insertions(+), 52 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java index 5d3f6a3..400d997 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java @@ -845,6 +845,7 @@ public abstract class GridCacheQueryManager extends GridCacheManagerAdapte try { val = prj.localPeek(key, CachePeekModes.ONHEAP_ONLY, expiryPlc); + } catch (IgniteCheckedException e) { if (log.isDebugEnabled()) 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 951d05a..4cfacb7 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 @@ -55,23 +55,25 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS public void testInvoke() throws Exception { Cache cache = grid(0).cache(null); - final AtomicBoolean invoked = new AtomicBoolean(false); + final AtomicInteger invoked = new AtomicInteger(); - cache.invoke(100, new EntryProcessor() { - @Override public Object process(MutableEntry entry, Object... arguments) - throws EntryProcessorException { + for (int i = 0; i < ENTRIES_NUM; i++) { + cache.invoke(i, new EntryProcessor() { + @Override public Object process(MutableEntry entry, Object... arguments) + throws EntryProcessorException { - invoked.set(true); + invoked.incrementAndGet(); - VersionedEntry verEntry = entry.unwrap(VersionedEntry.class); + VersionedEntry verEntry = entry.unwrap(VersionedEntry.class); - checkVersionedEntry(verEntry); + checkVersionedEntry(verEntry); - return entry; - } - }); + return entry; + } + }); + } - assertTrue(invoked.get()); + assert invoked.get() > 0; } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java deleted file mode 100644 index a340413..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSelfTest.java +++ /dev/null @@ -1,40 +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.version; - -import org.apache.ignite.cache.*; - -/** - * - */ -public class CacheVersionedEntryLocalAtomicSelfTest extends CacheVersionedEntryAbstractTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return CacheMode.LOCAL; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return CacheAtomicityMode.ATOMIC; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.java new file mode 100644 index 0000000..b0035d1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.java @@ -0,0 +1,45 @@ +/* + * 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 org.apache.ignite.cache.*; + +/** + * + */ +public class CacheVersionedEntryLocalAtomicSwapDisabledSelfTest extends CacheVersionedEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.LOCAL; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + + /** {@inheritDoc} */ + @Override protected boolean swapEnabled() { + return false; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index dd9c799..3ac7879 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -155,7 +155,7 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(CacheReadThroughAtomicRestartSelfTest.class); // Versioned entry tests - suite.addTestSuite(CacheVersionedEntryLocalAtomicSelfTest.class); + suite.addTestSuite(CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.class); suite.addTestSuite(CacheVersionedEntryLocalTransactionalSelfTest.class); suite.addTestSuite(CacheVersionedEntryPartitionedAtomicSelfTest.class); suite.addTestSuite(CacheVersionedEntryPartitionedTransactionalSelfTest.class); -- 1.9.5.msysgit.0 From 769d727063c07cc5f043d218dac3dbad3a1e226d Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Fri, 31 Jul 2015 10:20:22 +0300 Subject: [PATCH 4/7] ignite-946: improving tests --- .../ignite/internal/processors/cache/query/GridCacheQueryManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java index 400d997..5d3f6a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java @@ -845,7 +845,6 @@ public abstract class GridCacheQueryManager extends GridCacheManagerAdapte try { val = prj.localPeek(key, CachePeekModes.ONHEAP_ONLY, expiryPlc); - } catch (IgniteCheckedException e) { if (log.isDebugEnabled()) -- 1.9.5.msysgit.0 From 4c1a399a25b4041b8a30d5af242a3a573bf0a566 Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Fri, 31 Jul 2015 11:39:47 +0300 Subject: [PATCH 5/7] ignite-946: supported VersionedEntry for IgniteCache.localEntries() when OFF_HEAP mode is used --- .../internal/processors/cache/CacheEntryImpl0.java | 5 ++++ .../processors/cache/GridCacheSwapManager.java | 8 ++++- .../cache/version/GridVersionedMapEntry.java | 33 +++++++++++++++++++++ .../version/CacheVersionedEntryAbstractTest.java | 34 +++++++--------------- 4 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 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/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 implements Cache.Entry { @Override public T unwrap(Class 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); } 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 onNext() { final Map.Entry cur0 = it.next(); - cur = new Map.Entry() { + cur = new GridVersionedMapEntry() { @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(); } 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 extends Map.Entry { + /** + * Gets entry version. + * + * @return Entry version. + */ + public GridCacheVersion version(); +} 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() { - @Override public Object process(MutableEntry entry, Object... arguments) - throws EntryProcessorException { + cache.invoke(100, new EntryProcessor() { + @Override public Object process(MutableEntry entry, Object... arguments) + throws EntryProcessorException { - invoked.incrementAndGet(); + invoked.incrementAndGet(); - VersionedEntry verEntry = entry.unwrap(VersionedEntry.class); + VersionedEntry 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 cache = grid(0).cache(null); - - Iterator> entries = cache.iterator(); - - while (entries.hasNext()) - checkVersionedEntry(entries.next().unwrap(VersionedEntry.class)); - } - - /** - * @throws Exception If failed. - */ public void testLocalPeek() throws Exception { IgniteCache cache = grid(0).cache(null); -- 1.9.5.msysgit.0 From 3f95286ef627c8a67e8ac1a1db8cd744d79dbd4a Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Fri, 31 Jul 2015 12:14:54 +0300 Subject: [PATCH 6/7] ignite-946: added documentation --- .../ignite/cache/version/VersionedEntry.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java index 6f9d8f6..e669f15 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java @@ -17,11 +17,40 @@ package org.apache.ignite.cache.version; +import org.apache.ignite.*; + import javax.cache.*; +import javax.cache.processor.*; import java.util.*; /** - * Cache entry along with version information. + * Cache entry that stores entry's version related information. + * + * To get a {@code VersionedEntry} of an {@link Cache.Entry} use {@link Cache.Entry#unwrap(Class)} by passing + * {@code VersionedEntry} class to it as the argument. + *

+ * {@code VersionedEntry} is supported only for {@link Cache.Entry} returned by one of the following methods: + *

    + *
  • {@link Cache#invoke(Object, EntryProcessor, Object...)}
  • + *
  • {@link Cache#invokeAll(Set, EntryProcessor, Object...)}
  • + *
  • invoke and invokeAll methods of {@link IgniteCache}
  • + *
  • {@link IgniteCache#randomEntry()}
  • + *
+ *

+ * {@code VersionedEntry} is not supported for {@link Cache#iterator()} because of performance reasons. + * {@link Cache#iterator()} loads entries from all the cluster nodes and to speed up the load version information + * is excluded from responses. + *

Java Example

+ *
+ * Cache cache = grid(0).cache(null);
+ *
+ *  cache.invoke(100, new EntryProcessor() {
+ *      public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException {
+ *          VersionedEntry verEntry = entry.unwrap(VersionedEntry.class);
+ *          return entry;
+ *       }
+ *   });
+ * 
*/ public interface VersionedEntry extends Cache.Entry { /** -- 1.9.5.msysgit.0 From 6beb1ba06cb391077e579c1523c1d01b7a6ddc16 Mon Sep 17 00:00:00 2001 From: Denis Magda Date: Fri, 31 Jul 2015 12:18:58 +0300 Subject: [PATCH 7/7] ignite-946: formatting fixes --- .../internal/processors/cache/GridCacheMapEntry.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index 45ff619..ebcb908 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -609,16 +609,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme @Nullable IgniteCacheExpiryPolicy expirePlc) throws IgniteCheckedException, GridCacheEntryRemovedException { return innerGet0(tx, - readSwap, - readThrough, - evt, - unmarshal, - updateMetrics, - tmp, - subjId, - transformClo, - taskName, - expirePlc); + readSwap, + readThrough, + evt, + unmarshal, + updateMetrics, + tmp, + subjId, + transformClo, + taskName, + expirePlc); } /** {@inheritDoc} */ -- 1.9.5.msysgit.0