http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index 705a569..893d52a 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -34,8 +34,8 @@ import java.util.concurrent.*; * Main entry point for all <b>Data Grid APIs.</b> You can get a named cache by calling {@link Ignite#cache(String)} * method. * <h1 class="header">Functionality</h1> - * This API extends {@link org.apache.ignite.cache.GridCacheProjection} API which contains vast majority of cache functionality - * and documentation. In addition to {@link org.apache.ignite.cache.GridCacheProjection} functionality this API provides: + * This API extends {@link org.apache.ignite.cache.CacheProjection} API which contains vast majority of cache functionality + * and documentation. In addition to {@link org.apache.ignite.cache.CacheProjection} functionality this API provides: * <ul> * <li> * Various {@code 'loadCache(..)'} methods to load cache either synchronously or asynchronously. @@ -43,13 +43,13 @@ import java.util.concurrent.*; * data based on the optionally passed in arguments. * </li> * <li> - * Method {@link #affinity()} provides {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction} service for information on + * Method {@link #affinity()} provides {@link org.apache.ignite.cache.affinity.CacheAffinityFunction} service for information on * data partitioning and mapping keys to grid nodes responsible for caching those keys. * </li> * <li> - * Method {@link #dataStructures()} provides {@link org.apache.ignite.cache.datastructures.GridCacheDataStructures} service for + * Method {@link #dataStructures()} provides {@link org.apache.ignite.cache.datastructures.CacheDataStructures} service for * creating and working with distributed concurrent data structures, such as - * {@link IgniteAtomicLong}, {@link IgniteAtomicReference}, {@link org.apache.ignite.cache.datastructures.GridCacheQueue}, etc. + * {@link IgniteAtomicLong}, {@link IgniteAtomicReference}, {@link org.apache.ignite.cache.datastructures.CacheQueue}, etc. * </li> * <li> * Methods like {@code 'tx{Un}Synchronize(..)'} witch allow to get notifications for transaction state changes. @@ -77,7 +77,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * which is true for near fully populated caches, this method will generally perform significantly * faster with complexity of O(S) where {@code S = 5}. * <p> - * Note that this method is not available on {@link org.apache.ignite.cache.GridCacheProjection} API since it is + * Note that this method is not available on {@link org.apache.ignite.cache.CacheProjection} API since it is * impossible (or very hard) to deterministically return a number value when pre-filtering * and post-filtering is involved (e.g. projection level predicate filters). * @@ -146,14 +146,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * if there is one. * <h2 class="header">Cache Flags</h2> * This method is not available if any of the following flags are set on projection: - * {@link org.apache.ignite.cache.GridCacheFlag#LOCAL}, {@link org.apache.ignite.cache.GridCacheFlag#READ}. + * {@link org.apache.ignite.cache.CacheFlag#LOCAL}, {@link org.apache.ignite.cache.CacheFlag#READ}. * * @param key Key to store in cache. * @param val Value to be associated with the given key. * @return Previously contained value regardless of whether put happened or not. * @throws NullPointerException If either key or value are {@code null}. * @throws CacheException If put operation failed. - * @throws org.apache.ignite.cache.GridCacheFlagException If projection flags validation failed. + * @throws org.apache.ignite.cache.CacheFlagException If projection flags validation failed. */ @Nullable public V getAndPutIfAbsent(K key, V val) throws CacheException; @@ -223,11 +223,11 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * participating in any locks or transactions). * <p> * If {@link CacheConfiguration#isSwapEnabled()} is set to {@code true} and - * {@link org.apache.ignite.cache.GridCacheFlag#SKIP_SWAP} is not enabled, the evicted entry will + * {@link org.apache.ignite.cache.CacheFlag#SKIP_SWAP} is not enabled, the evicted entry will * be swapped to offheap, and then to disk. * <h2 class="header">Cache Flags</h2> * This method is not available if any of the following flags are set on projection: - * {@link org.apache.ignite.cache.GridCacheFlag#READ}. + * {@link org.apache.ignite.cache.CacheFlag#READ}. * * @param keys Keys to evict. */ @@ -242,7 +242,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * This method does not participate in any transactions, however, it will * peek at transactional value according to the {@link org.apache.ignite.cache.GridCachePeekMode#SMART} mode * semantics. If you need to look at global cached value even from within transaction, - * you can use {@link org.apache.ignite.cache.GridCache#peek(Object, Collection)} method. + * you can use {@link org.apache.ignite.cache.Cache#peek(Object, Collection)} method. * * @param key Entry key. * @return Peeked value. @@ -257,11 +257,11 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * This method is not transactional. * <h2 class="header">Cache Flags</h2> * This method is not available if any of the following flags are set on projection: - * {@link org.apache.ignite.cache.GridCacheFlag#SKIP_SWAP}, {@link org.apache.ignite.cache.GridCacheFlag#READ}. + * {@link org.apache.ignite.cache.CacheFlag#SKIP_SWAP}, {@link org.apache.ignite.cache.CacheFlag#READ}. * * @param keys Keys to promote entries for. * @throws CacheException If promote failed. - * @throws org.apache.ignite.cache.GridCacheFlagException If flags validation failed. + * @throws org.apache.ignite.cache.CacheFlagException If flags validation failed. */ public void localPromote(Set<? extends K> keys) throws CacheException; @@ -270,7 +270,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * is not currently locked, and is not participating in a transaction. * <p> * If {@link CacheConfiguration#isSwapEnabled()} is set to {@code true} and - * {@link org.apache.ignite.cache.GridCacheFlag#SKIP_SWAP} is not enabled, the evicted entries will + * {@link org.apache.ignite.cache.CacheFlag#SKIP_SWAP} is not enabled, the evicted entries will * also be cleared from swap. * <p> * Note that this operation is local as it merely clears @@ -278,7 +278,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * remote caches or from underlying persistent storage. * <h2 class="header">Cache Flags</h2> * This method is not available if any of the following flags are set on projection: - * {@link org.apache.ignite.cache.GridCacheFlag#READ}. + * {@link org.apache.ignite.cache.CacheFlag#READ}. * * @param keys Keys to clear. * @return {@code True} if entry was successfully cleared from cache, {@code false} @@ -340,7 +340,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * (which will be stored in portable format), you should acquire following projection * to avoid deserialization: * <pre> - * GridCacheProjection<Integer, GridPortableObject> prj = cache.keepPortable(); + * CacheProjection<Integer, GridPortableObject> prj = cache.keepPortable(); * * // Value is not deserialized and returned in portable format. * GridPortableObject po = prj.get(1);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java b/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java index afe960e..5d17bca 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java @@ -108,7 +108,7 @@ public interface IgniteCluster extends ClusterGroup, IgniteAsyncSupport { * <ul> * <li>For local caches it returns only local node mapped to all keys.</li> * <li> - * For fully replicated caches, {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction} is + * For fully replicated caches, {@link org.apache.ignite.cache.affinity.CacheAffinityFunction} is * used to determine which keys are mapped to which groups of nodes. * </li> * <li>For partitioned caches, the returned map represents node-to-key affinity.</li> @@ -131,7 +131,7 @@ public interface IgniteCluster extends ClusterGroup, IgniteAsyncSupport { * <ul> * <li>For local caches it returns only local node ID.</li> * <li> - * For fully replicated caches first node ID returned by {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction} + * For fully replicated caches first node ID returned by {@link org.apache.ignite.cache.affinity.CacheAffinityFunction} * is returned. * </li> * <li>For partitioned caches, the returned node ID is the primary node for the key.</li> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/IgniteDataLoader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteDataLoader.java b/modules/core/src/main/java/org/apache/ignite/IgniteDataLoader.java index a4b41dd..c55310b 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteDataLoader.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataLoader.java @@ -34,7 +34,7 @@ import java.util.*; * the loader. * <p> * Also note that {@code GridDataLoader} is not the only way to load data into cache. - * Alternatively you can use {@link org.apache.ignite.cache.GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} + * Alternatively you can use {@link org.apache.ignite.cache.Cache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} * method to load data from underlying data store. You can also use standard * cache {@code put(...)} and {@code putAll(...)} operations as well, but they most * likely will not perform as well as this class for loading data. And finally, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java index 9f8542a..4da163e 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java +++ b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java @@ -48,9 +48,9 @@ import java.util.Date; * (assuming that class definitions are present in the classpath). * <p> * To work with the portable format directly, user should create a special cache projection - * using {@link org.apache.ignite.cache.GridCacheProjection#keepPortable()} method and then retrieve individual fields as needed: + * using {@link org.apache.ignite.cache.CacheProjection#keepPortable()} method and then retrieve individual fields as needed: * <pre name=code class=java> - * GridCacheProjection<GridPortableObject.class, GridPortableObject.class> prj = cache.keepPortable(); + * CacheProjection<GridPortableObject.class, GridPortableObject.class> prj = cache.keepPortable(); * * // Convert instance of MyKey to portable format. * // We could also use GridPortableBuilder to create @@ -66,7 +66,7 @@ import java.util.Date; * GridGain will only deserialize on the first access and will cache the deserialized object, * so it does not have to be deserialized again: * <pre name=code class=java> - * GridCacheProjection<MyKey.class, MyValue.class> prj = + * CacheProjection<MyKey.class, MyValue.class> prj = * cache.projection(MyKey.class, MyValue.class); * * MyValue val = prj.get(new MyKey()); @@ -78,7 +78,7 @@ import java.util.Date; * and still wanted to work with binary portable format for values, then we would declare cache projection * as follows: * <pre name=code class=java> - * GridCacheProjection<Integer.class, GridPortableObject.class> prj = cache.keepPortable(); + * CacheProjection<Integer.class, GridPortableObject.class> prj = cache.keepPortable(); * </pre> * <h1 class="header">Automatic Portable Types</h1> * Note that only portable classes are converted to {@link org.apache.ignite.portables.PortableObject} format. Following @@ -254,17 +254,17 @@ import java.util.Date; * or for a specific type via {@link org.apache.ignite.portables.PortableTypeConfiguration} instance. * <h1 class="header">Query Indexing</h1> * Portable objects can be indexed for querying by specifying index fields in - * {@link org.apache.ignite.cache.query.GridCacheQueryTypeMetadata} inside of specific {@link CacheConfiguration} instance, + * {@link org.apache.ignite.cache.query.CacheQueryTypeMetadata} inside of specific {@link CacheConfiguration} instance, * like so: * <pre name=code class=xml> * ... * <bean class="org.gridgain.grid.cache.GridCacheConfiguration"> * ... * <property name="queryConfiguration"> - * <bean class="GridCacheQueryConfiguration"> + * <bean class="CacheQueryConfiguration"> * <property name="typeMetadata"> * <list> - * <bean class="GridCacheQueryTypeMetadata"> + * <bean class="CacheQueryTypeMetadata"> * <property name="type" value="Employee"/> * * <!-- Fields to index in ascending order. --> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/Cache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/Cache.java b/modules/core/src/main/java/org/apache/ignite/cache/Cache.java new file mode 100644 index 0000000..2a8fbcc --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/Cache.java @@ -0,0 +1,278 @@ +/* + * 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; + +import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cache.datastructures.*; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.lang.*; +import org.apache.ignite.transactions.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Main entry point for all <b>Data Grid APIs.</b> You can get a named cache by calling {@link org.apache.ignite.Ignite#cache(String)} + * method. + * <h1 class="header">Functionality</h1> + * This API extends {@link CacheProjection} API which contains vast majority of cache functionality + * and documentation. In addition to {@link CacheProjection} functionality this API provides: + * <ul> + * <li> + * Various {@code 'loadCache(..)'} methods to load cache either synchronously or asynchronously. + * These methods don't specify any keys to load, and leave it to the underlying storage to load cache + * data based on the optionally passed in arguments. + * </li> + * <li> + * Method {@link #affinity()} provides {@link org.apache.ignite.cache.affinity.CacheAffinityFunction} service for information on + * data partitioning and mapping keys to grid nodes responsible for caching those keys. + * </li> + * <li> + * Method {@link #dataStructures()} provides {@link org.apache.ignite.cache.datastructures.CacheDataStructures} service for + * creating and working with distributed concurrent data structures, such as + * {@link org.apache.ignite.cache.datastructures.CacheAtomicLong}, {@link org.apache.ignite.cache.datastructures.CacheAtomicReference}, {@link org.apache.ignite.cache.datastructures.CacheQueue}, etc. + * </li> + * <li> + * Methods like {@code 'tx{Un}Synchronize(..)'} witch allow to get notifications for transaction state changes. + * This feature is very useful when integrating cache transactions with some other in-house transactions. + * </li> + * <li>Method {@link #metrics()} to provide metrics for the whole cache.</li> + * <li>Method {@link #configuration()} to provide cache configuration bean.</li> + * </ul> + * + * @param <K> Cache key type. + * @param <V> Cache value type. + */ +public interface Cache<K, V> extends CacheProjection<K, V> { + /** + * Gets configuration bean for this cache. + * + * @return Configuration bean for this cache. + */ + public CacheConfiguration configuration(); + + /** + * Registers transactions synchronizations for all transactions started by this cache. + * Use it whenever you need to get notifications on transaction lifecycle and possibly change + * its course. It is also particularly useful when integrating cache transactions + * with some other in-house transactions. + * + * @param syncs Transaction synchronizations to register. + */ + public void txSynchronize(@Nullable IgniteTxSynchronization syncs); + + /** + * Removes transaction synchronizations. + * + * @param syncs Transactions synchronizations to remove. + * @see #txSynchronize(IgniteTxSynchronization) + */ + public void txUnsynchronize(@Nullable IgniteTxSynchronization syncs); + + /** + * Gets registered transaction synchronizations. + * + * @return Registered transaction synchronizations. + * @see #txSynchronize(IgniteTxSynchronization) + */ + public Collection<IgniteTxSynchronization> txSynchronizations(); + + /** + * Gets affinity service to provide information about data partitioning + * and distribution. + * + * @return Cache data affinity service. + */ + public CacheAffinity<K> affinity(); + + /** + * Gets data structures service to provide a gateway for creating various + * distributed data structures similar in APIs to {@code java.util.concurrent} package. + * + * @return Cache data structures service. + */ + public CacheDataStructures dataStructures(); + + /** + * Gets metrics (statistics) for this cache. + * + * @return Cache metrics. + */ + public CacheMetrics metrics(); + + /** + * Gets size (in bytes) of all entries swapped to disk. + * + * @return Size (in bytes) of all entries swapped to disk. + * @throws IgniteCheckedException In case of error. + */ + public long overflowSize() throws IgniteCheckedException; + + /** + * Gets number of cache entries stored in off-heap memory. + * + * @return Number of cache entries stored in off-heap memory. + */ + public long offHeapEntriesCount(); + + /** + * Gets memory size allocated in off-heap. + * + * @return Allocated memory size. + */ + public long offHeapAllocatedSize(); + + /** + * Gets size in bytes for swap space. + * + * @return Size in bytes. + * @throws IgniteCheckedException If failed. + */ + public long swapSize() throws IgniteCheckedException; + + /** + * Gets number of swap entries (keys). + * + * @return Number of entries stored in swap. + * @throws IgniteCheckedException If failed. + */ + public long swapKeys() throws IgniteCheckedException; + + /** + * Gets iterator over keys and values belonging to this cache swap space on local node. This + * iterator is thread-safe, which means that cache (and therefore its swap space) + * may be modified concurrently with iteration over swap. + * <p> + * Returned iterator supports {@code remove} operation which delegates to + * {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * <h2 class="header">Cache Flags</h2> + * This method is not available if any of the following flags are set on projection: + * {@link CacheFlag#SKIP_SWAP}. + * + * @return Iterator over keys. + * @throws IgniteCheckedException If failed. + * @see #promote(Object) + */ + public Iterator<Map.Entry<K, V>> swapIterator() throws IgniteCheckedException; + + /** + * Gets iterator over keys and values belonging to this cache off-heap memory on local node. This + * iterator is thread-safe, which means that cache (and therefore its off-heap memory) + * may be modified concurrently with iteration over off-heap. To achieve better performance + * the keys and values deserialized on demand, whenever accessed. + * <p> + * Returned iterator supports {@code remove} operation which delegates to + * {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @return Iterator over keys. + * @throws IgniteCheckedException If failed. + */ + public Iterator<Map.Entry<K, V>> offHeapIterator() throws IgniteCheckedException; + + /** + * Delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method + * to load state from the underlying persistent storage. The loaded values + * will then be given to the optionally passed in predicate, and, if the predicate returns + * {@code true}, will be stored in cache. If predicate is {@code null}, then + * all loaded values will be stored in cache. + * <p> + * Note that this method does not receive keys as a parameter, so it is up to + * {@link CacheStore} implementation to provide all the data to be loaded. + * <p> + * This method is not transactional and may end up loading a stale value into + * cache if another thread has updated the value immediately after it has been + * loaded. It is mostly useful when pre-loading the cache from underlying + * data store before start, or for read-only caches. + * + * @param p Optional predicate (may be {@code null}). If provided, will be used to + * filter values to be put into cache. + * @param ttl Time to live for loaded entries ({@code 0} for infinity). + * @param args Optional user arguments to be passed into + * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method. + * @throws IgniteCheckedException If loading failed. + */ + public void loadCache(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args) throws IgniteCheckedException; + + /** + * Asynchronously delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method + * to reload state from the underlying persistent storage. The reloaded values + * will then be given to the optionally passed in predicate, and if the predicate returns + * {@code true}, will be stored in cache. If predicate is {@code null}, then + * all reloaded values will be stored in cache. + * <p> + * Note that this method does not receive keys as a parameter, so it is up to + * {@link CacheStore} implementation to provide all the data to be loaded. + * <p> + * This method is not transactional and may end up loading a stale value into + * cache if another thread has updated the value immediately after it has been + * loaded. It is mostly useful when pre-loading the cache from underlying + * data store before start, or for read-only caches. + * + * @param p Optional predicate (may be {@code null}). If provided, will be used to + * filter values to be put into cache. + * @param ttl Time to live for loaded entries ({@code 0} for infinity). + * @param args Optional user arguments to be passed into + * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method. + * @return Future to be completed whenever loading completes. + */ + public IgniteFuture<?> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args); + + /** + * Gets a random entry out of cache. In the worst cache scenario this method + * has complexity of <pre>O(S * N/64)</pre> where {@code N} is the size of internal hash + * table and {@code S} is the number of hash table buckets to sample, which is {@code 5} + * by default. However, if the table is pretty dense, with density factor of {@code N/64}, + * which is true for near fully populated caches, this method will generally perform significantly + * faster with complexity of O(S) where {@code S = 5}. + * <p> + * Note that this method is not available on {@link CacheProjection} API since it is + * impossible (or very hard) to deterministically return a number value when pre-filtering + * and post-filtering is involved (e.g. projection level predicate filters). + * + * @return Random entry, or {@code null} if cache is empty. + */ + @Nullable public CacheEntry<K, V> randomEntry(); + + /** + * Forces this cache node to re-balance its partitions. This method is usually used when + * {@link CacheConfiguration#getPreloadPartitionedDelay()} configuration parameter has non-zero value. + * When many nodes are started or stopped almost concurrently, it is more efficient to delay + * preloading until the node topology is stable to make sure that no redundant re-partitioning + * happens. + * <p> + * In case of{@link CacheMode#PARTITIONED} caches, for better efficiency user should + * usually make sure that new nodes get placed on the same place of consistent hash ring as + * the left nodes, and that nodes are restarted before + * {@link CacheConfiguration#getPreloadPartitionedDelay() preloadDelay} expires. To place nodes + * on the same place in consistent hash ring, use + * {@link org.apache.ignite.cache.affinity.consistenthash.CacheConsistentHashAffinityFunction#setHashIdResolver(org.apache.ignite.cache.affinity.CacheAffinityNodeHashResolver)} to make sure that + * a node maps to the same hash ID if re-started. + * <p> + * See {@link CacheConfiguration#getPreloadPartitionedDelay()} for more information on how to configure + * preload re-partition delay. + * <p> + * @return Future that will be completed when preloading is finished. + */ + public IgniteFuture<?> forceRepartition(); + + /** + * Resets metrics for current cache. + */ + public void resetMetrics(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicWriteOrderMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicWriteOrderMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicWriteOrderMode.java index 746060c..0771ae9 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicWriteOrderMode.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicWriteOrderMode.java @@ -24,21 +24,21 @@ import org.jetbrains.annotations.*; * atomicity mode. Write ordering mode determines which node assigns the write version, sender or the primary node. * <p> * For example, {@link #CLOCK} mode assigns write versions on a sender node which generally leads to better - * performance in {@link GridCacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case + * performance in {@link CacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case * sender can send write requests to primary and backups at the same time. Otherwise, if ordering mode is * {@link #PRIMARY}, it would only send request to primary node, which in turn will assign write version * and forward it to backups. * <p> - * {@link #CLOCK} mode will be automatically configured only with {@link GridCacheWriteSynchronizationMode#FULL_SYNC} + * {@link #CLOCK} mode will be automatically configured only with {@link CacheWriteSynchronizationMode#FULL_SYNC} * write synchronization mode, as for other synchronization modes it does not render better performance. */ public enum CacheAtomicWriteOrderMode { /** * In this mode, write versions are assigned on a sender node which generally leads to better - * performance in {@link GridCacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case + * performance in {@link CacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case * sender can send write requests to primary and backups at the same time. * <p> - * This mode will be automatically configured only with {@link GridCacheWriteSynchronizationMode#FULL_SYNC} + * This mode will be automatically configured only with {@link CacheWriteSynchronizationMode#FULL_SYNC} * write synchronization mode, as for other synchronization modes it does not render better performance. */ CLOCK, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java index 83b972e..d550531 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java @@ -74,7 +74,7 @@ public class CacheConfiguration extends MutableConfiguration { public static final CacheAtomicityMode DFLT_CACHE_ATOMICITY_MODE = CacheAtomicityMode.ATOMIC; /** Default value for cache distribution mode. */ - public static final GridCacheDistributionMode DFLT_DISTRIBUTION_MODE = GridCacheDistributionMode.PARTITIONED_ONLY; + public static final CacheDistributionMode DFLT_DISTRIBUTION_MODE = CacheDistributionMode.PARTITIONED_ONLY; /** Default query timeout. */ public static final long DFLT_QUERY_TIMEOUT = 0; @@ -98,7 +98,7 @@ public class CacheConfiguration extends MutableConfiguration { public static final boolean DFLT_STORE_VALUE_BYTES = true; /** Default preload mode for distributed cache. */ - public static final GridCachePreloadMode DFLT_PRELOAD_MODE = GridCachePreloadMode.ASYNC; + public static final CachePreloadMode DFLT_PRELOAD_MODE = CachePreloadMode.ASYNC; /** Default preload batch size in bytes. */ public static final int DFLT_PRELOAD_BATCH_SIZE = 512 * 1024; // 512K @@ -166,7 +166,7 @@ public class CacheConfiguration extends MutableConfiguration { public static final int DFLT_CONT_QUERY_QUEUE_SIZE = 1024 * 1024; /** Default memory mode. */ - public static final GridCacheMemoryMode DFLT_MEMORY_MODE = GridCacheMemoryMode.ONHEAP_TIERED; + public static final CacheMemoryMode DFLT_MEMORY_MODE = CacheMemoryMode.ONHEAP_TIERED; /** Default continuous query max buffer size. */ @SuppressWarnings("UnusedDeclaration") @@ -192,10 +192,10 @@ public class CacheConfiguration extends MutableConfiguration { private long ttl = DFLT_TIME_TO_LIVE; /** Cache expiration policy. */ - private GridCacheEvictionPolicy evictPlc; + private CacheEvictionPolicy evictPlc; /** Near cache eviction policy. */ - private GridCacheEvictionPolicy nearEvictPlc; + private CacheEvictionPolicy nearEvictPlc; /** Flag indicating whether eviction is synchronized. */ private boolean evictSync = DFLT_EVICT_SYNCHRONIZED; @@ -213,7 +213,7 @@ public class CacheConfiguration extends MutableConfiguration { private long evictSyncTimeout = DFLT_EVICT_SYNCHRONIZED_TIMEOUT; /** Eviction filter. */ - private GridCacheEvictionFilter<?, ?> evictFilter; + private CacheEvictionFilter<?, ?> evictFilter; /** Maximum eviction overflow ratio. */ private float evictMaxOverflowRatio = DFLT_MAX_EVICTION_OVERFLOW_RATIO; @@ -234,10 +234,10 @@ public class CacheConfiguration extends MutableConfiguration { private int nearStartSize = DFLT_NEAR_START_SIZE; /** Cache distribution mode. */ - private GridCacheDistributionMode distro = DFLT_DISTRIBUTION_MODE; + private CacheDistributionMode distro = DFLT_DISTRIBUTION_MODE; /** Write synchronization mode. */ - private GridCacheWriteSynchronizationMode writeSync; + private CacheWriteSynchronizationMode writeSync; /** */ private Factory storeFactory; @@ -246,7 +246,7 @@ public class CacheConfiguration extends MutableConfiguration { private boolean loadPrevVal = DFLT_LOAD_PREV_VAL; /** Node group resolver. */ - private GridCacheAffinityFunction aff; + private CacheAffinityFunction aff; /** Cache mode. */ private CacheMode cacheMode = DFLT_CACHE_MODE; @@ -270,7 +270,7 @@ public class CacheConfiguration extends MutableConfiguration { private String tmLookupClsName; /** Distributed cache preload mode. */ - private GridCachePreloadMode preloadMode = DFLT_PRELOAD_MODE; + private CachePreloadMode preloadMode = DFLT_PRELOAD_MODE; /** Cache preload order. */ private int preloadOrder; @@ -309,13 +309,13 @@ public class CacheConfiguration extends MutableConfiguration { private int maxQryIterCnt = DFLT_MAX_QUERY_ITERATOR_CNT; /** Memory mode. */ - private GridCacheMemoryMode memMode = DFLT_MEMORY_MODE; + private CacheMemoryMode memMode = DFLT_MEMORY_MODE; /** */ - private GridCacheCloner cloner; + private CacheCloner cloner; /** */ - private GridCacheAffinityKeyMapper affMapper; + private CacheAffinityKeyMapper affMapper; /** */ private String indexingSpiName; @@ -327,7 +327,7 @@ public class CacheConfiguration extends MutableConfiguration { private long preloadThrottle = DFLT_PRELOAD_THROTTLE; /** */ - private GridCacheInterceptor<?, ?> interceptor; + private CacheInterceptor<?, ?> interceptor; /** */ private boolean portableEnabled; @@ -336,7 +336,7 @@ public class CacheConfiguration extends MutableConfiguration { private boolean keepPortableInStore = true; /** Query configuration. */ - private GridCacheQueryConfiguration qryCfg; + private CacheQueryConfiguration qryCfg; /** * Flag indicating whether data can be read from backup. @@ -477,7 +477,7 @@ public class CacheConfiguration extends MutableConfiguration { * @return Cache eviction policy or {@code null} if evictions should be disabled. */ @SuppressWarnings({"unchecked"}) - @Nullable public <K, V> GridCacheEvictionPolicy<K, V> getEvictionPolicy() { + @Nullable public <K, V> CacheEvictionPolicy<K, V> getEvictionPolicy() { return evictPlc; } @@ -486,7 +486,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param evictPlc Cache expiration policy. */ - public void setEvictionPolicy(@Nullable GridCacheEvictionPolicy evictPlc) { + public void setEvictionPolicy(@Nullable CacheEvictionPolicy evictPlc) { this.evictPlc = evictPlc; } @@ -498,7 +498,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @return Cache distribution mode. */ - public GridCacheDistributionMode getDistributionMode() { + public CacheDistributionMode getDistributionMode() { return distro; } @@ -507,7 +507,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param distro Distribution mode. */ - public void setDistributionMode(GridCacheDistributionMode distro) { + public void setDistributionMode(CacheDistributionMode distro) { this.distro = distro; } @@ -517,7 +517,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @return Write synchronization mode. */ - public GridCacheWriteSynchronizationMode getWriteSynchronizationMode() { + public CacheWriteSynchronizationMode getWriteSynchronizationMode() { return writeSync; } @@ -526,7 +526,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param writeSync Write synchronization mode. */ - public void setWriteSynchronizationMode(GridCacheWriteSynchronizationMode writeSync) { + public void setWriteSynchronizationMode(CacheWriteSynchronizationMode writeSync) { this.writeSync = writeSync; } @@ -538,7 +538,7 @@ public class CacheConfiguration extends MutableConfiguration { * @return Cache eviction policy or {@code null} if evictions should be disabled. */ @SuppressWarnings({"unchecked"}) - @Nullable public <K, V> GridCacheEvictionPolicy<K, V> getNearEvictionPolicy() { + @Nullable public <K, V> CacheEvictionPolicy<K, V> getNearEvictionPolicy() { return nearEvictPlc; } @@ -548,14 +548,14 @@ public class CacheConfiguration extends MutableConfiguration { * * @param nearEvictPlc Eviction policy for near cache. */ - public void setNearEvictionPolicy(@Nullable GridCacheEvictionPolicy nearEvictPlc) { + public void setNearEvictionPolicy(@Nullable CacheEvictionPolicy nearEvictPlc) { this.nearEvictPlc = nearEvictPlc; } /** * Gets flag indicating whether eviction is synchronized between primary and * backup nodes on partitioned cache. If this parameter is {@code true} and - * swap is disabled then {@link org.apache.ignite.cache.GridCacheProjection#evict(Object)} + * swap is disabled then {@link CacheProjection#evict(Object)} * and all its variations will involve all nodes where an entry is kept - * this is a group of nodes responsible for partition to which * corresponding key belongs. If this property is set to {@code false} then @@ -715,8 +715,8 @@ public class CacheConfiguration extends MutableConfiguration { /** * Gets eviction filter to specify which entries should not be evicted - * (except explicit evict by calling {@link GridCacheEntry#evict()}). - * If {@link GridCacheEvictionFilter#evictAllowed(GridCacheEntry)} method returns + * (except explicit evict by calling {@link CacheEntry#evict()}). + * If {@link org.apache.ignite.cache.eviction.CacheEvictionFilter#evictAllowed(CacheEntry)} method returns * {@code false} then eviction policy will not be notified and entry will * never be evicted. * <p> @@ -726,8 +726,8 @@ public class CacheConfiguration extends MutableConfiguration { * @return Eviction filter or {@code null}. */ @SuppressWarnings("unchecked") - public <K, V> GridCacheEvictionFilter<K, V> getEvictionFilter() { - return (GridCacheEvictionFilter<K, V>)evictFilter; + public <K, V> CacheEvictionFilter<K, V> getEvictionFilter() { + return (CacheEvictionFilter<K, V>)evictFilter; } /** @@ -735,7 +735,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param evictFilter Eviction filter. */ - public <K, V> void setEvictionFilter(GridCacheEvictionFilter<K, V> evictFilter) { + public <K, V> void setEvictionFilter(CacheEvictionFilter<K, V> evictFilter) { this.evictFilter = evictFilter; } @@ -746,8 +746,8 @@ public class CacheConfiguration extends MutableConfiguration { * When not set, default value is {@link #DFLT_EAGER_TTL}. * <p> * <b>Note</b> that this flag only matters for entries expiring based on - * {@link GridCacheEntry#timeToLive()} value and should not be confused with entry - * evictions based on configured {@link GridCacheEvictionPolicy}. + * {@link CacheEntry#timeToLive()} value and should not be confused with entry + * evictions based on configured {@link org.apache.ignite.cache.eviction.CacheEvictionPolicy}. * * @return Flag indicating whether GridGain will eagerly remove expired entries. */ @@ -869,7 +869,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @return Key topology resolver to provide mapping from keys to nodes. */ - public GridCacheAffinityFunction getAffinity() { + public CacheAffinityFunction getAffinity() { return aff; } @@ -878,7 +878,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param aff Cache key affinity. */ - public void setAffinity(GridCacheAffinityFunction aff) { + public void setAffinity(CacheAffinityFunction aff) { this.aff = aff; } @@ -1065,7 +1065,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param preloadMode Preload mode. */ - public void setPreloadMode(GridCachePreloadMode preloadMode) { + public void setPreloadMode(CachePreloadMode preloadMode) { this.preloadMode = preloadMode; } @@ -1076,13 +1076,13 @@ public class CacheConfiguration extends MutableConfiguration { * * @return Preload mode. */ - public GridCachePreloadMode getPreloadMode() { + public CachePreloadMode getPreloadMode() { return preloadMode; } /** * Gets cache preload order. Preload order can be set to non-zero value for caches with - * {@link GridCachePreloadMode#SYNC SYNC} or {@link GridCachePreloadMode#ASYNC ASYNC} preload modes only. + * {@link CachePreloadMode#SYNC SYNC} or {@link CachePreloadMode#ASYNC ASYNC} preload modes only. * <p/> * If cache preload order is positive, preloading for this cache will be started only when preloading for * all caches with smaller preload order (except caches with preload order {@code 0}) will be completed. @@ -1135,7 +1135,7 @@ public class CacheConfiguration extends MutableConfiguration { * swap is disabled which is defined via {@link #DFLT_SWAP_ENABLED} constant. * <p> * Note that this flag may be overridden for cache projection created with flag - * {@link GridCacheFlag#SKIP_SWAP}. + * {@link CacheFlag#SKIP_SWAP}. * * @return {@code True} if swap storage is enabled. */ @@ -1320,36 +1320,36 @@ public class CacheConfiguration extends MutableConfiguration { } /** - * Cloner to be used for cloning values that are returned to user only if {@link GridCacheFlag#CLONE} - * is set on {@link org.apache.ignite.cache.GridCacheProjection}. Cloning values is useful when it is needed to get value from + * Cloner to be used for cloning values that are returned to user only if {@link CacheFlag#CLONE} + * is set on {@link CacheProjection}. Cloning values is useful when it is needed to get value from * cache, change it and put it back (if the value was not cloned, then user would be updating the * cached reference which would violate cache integrity). * <p> - * <b>NOTE:</b> by default, cache uses {@link org.apache.ignite.cache.cloner.GridCacheBasicCloner} implementation which will clone only objects + * <b>NOTE:</b> by default, cache uses {@link org.apache.ignite.cache.cloner.CacheBasicCloner} implementation which will clone only objects * implementing {@link Cloneable} interface. You can also configure cache to use - * {@link org.apache.ignite.cache.cloner.GridCacheDeepCloner} which will perform deep-cloning of all objects returned from cache, + * {@link org.apache.ignite.cache.cloner.CacheDeepCloner} which will perform deep-cloning of all objects returned from cache, * regardless of the {@link Cloneable} interface. If none of the above cloners fit your - * logic, you can also provide your own implementation of {@link GridCacheCloner} interface. + * logic, you can also provide your own implementation of {@link org.apache.ignite.cache.cloner.CacheCloner} interface. * - * @return Cloner to be used if {@link GridCacheFlag#CLONE} flag is set on cache projection. + * @return Cloner to be used if {@link CacheFlag#CLONE} flag is set on cache projection. */ @SuppressWarnings({"unchecked"}) - public GridCacheCloner getCloner() { + public CacheCloner getCloner() { return cloner; } /** - * Sets cloner to be used if {@link GridCacheFlag#CLONE} flag is set on projection. + * Sets cloner to be used if {@link CacheFlag#CLONE} flag is set on projection. * * @param cloner Cloner to use. * @see #getCloner() */ - public void setCloner(GridCacheCloner cloner) { + public void setCloner(CacheCloner cloner) { this.cloner = cloner; } /** - * Gets default number of sequence values reserved for {@link org.apache.ignite.cache.datastructures.GridCacheAtomicSequence} instances. After + * Gets default number of sequence values reserved for {@link org.apache.ignite.cache.datastructures.CacheAtomicSequence} instances. After * a certain number has been reserved, consequent increments of sequence will happen locally, * without communication with other nodes, until the next reservation has to be made. * <p> @@ -1362,7 +1362,7 @@ public class CacheConfiguration extends MutableConfiguration { } /** - * Sets default number of sequence values reserved for {@link org.apache.ignite.cache.datastructures.GridCacheAtomicSequence} instances. After a certain + * Sets default number of sequence values reserved for {@link org.apache.ignite.cache.datastructures.CacheAtomicSequence} instances. After a certain * number has been reserved, consequent increments of sequence will happen locally, without communication with other * nodes, until the next reservation has to be made. * @@ -1425,13 +1425,13 @@ public class CacheConfiguration extends MutableConfiguration { * For better efficiency user should usually make sure that new nodes get placed on * the same place of consistent hash ring as the left nodes, and that nodes are * restarted before this delay expires. To place nodes on the same place in consistent hash ring, - * use {@link org.apache.ignite.cache.affinity.consistenthash.GridCacheConsistentHashAffinityFunction#setHashIdResolver(GridCacheAffinityNodeHashResolver)} + * use {@link org.apache.ignite.cache.affinity.consistenthash.CacheConsistentHashAffinityFunction#setHashIdResolver(org.apache.ignite.cache.affinity.CacheAffinityNodeHashResolver)} * to make sure that a node maps to the same hash ID event if restarted. As an example, * node IP address and port combination may be used in this case. * <p> * Default value is {@code 0} which means that repartitioning and preloading will start * immediately upon node leaving topology. If {@code -1} is returned, then preloading - * will only be started manually by calling {@link GridCache#forceRepartition()} method or + * will only be started manually by calling {@link Cache#forceRepartition()} method or * from management console. * * @return Preloading delay, {@code 0} to start preloading immediately, {@code -1} to @@ -1490,21 +1490,21 @@ public class CacheConfiguration extends MutableConfiguration { * on the same node (they will also be backed up on the same nodes as well). * <p> * If not provided, then default implementation will be used. The default behavior - * is described in {@link GridCacheAffinityKeyMapper} documentation. + * is described in {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapper} documentation. * * @return Mapper to use for affinity key mapping. */ - public GridCacheAffinityKeyMapper getAffinityMapper() { + public CacheAffinityKeyMapper getAffinityMapper() { return affMapper; } /** * Sets custom affinity mapper. If not provided, then default implementation will be used. The default behavior is - * described in {@link GridCacheAffinityKeyMapper} documentation. + * described in {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapper} documentation. * * @param affMapper Affinity mapper. */ - public void setAffinityMapper(GridCacheAffinityKeyMapper affMapper) { + public void setAffinityMapper(CacheAffinityKeyMapper affMapper) { this.affMapper = affMapper; } @@ -1630,13 +1630,13 @@ public class CacheConfiguration extends MutableConfiguration { /** * Gets memory mode for cache. Memory mode helps control whether value is stored in on-heap memory, - * off-heap memory, or swap space. Refer to {@link GridCacheMemoryMode} for more info. + * off-heap memory, or swap space. Refer to {@link CacheMemoryMode} for more info. * <p> * Default value is {@link #DFLT_MEMORY_MODE}. * * @return Memory mode. */ - public GridCacheMemoryMode getMemoryMode() { + public CacheMemoryMode getMemoryMode() { return memMode; } @@ -1645,7 +1645,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param memMode Memory mode. */ - public void setMemoryMode(GridCacheMemoryMode memMode) { + public void setMemoryMode(CacheMemoryMode memMode) { this.memMode = memMode; } @@ -1683,8 +1683,8 @@ public class CacheConfiguration extends MutableConfiguration { * @return Cache interceptor. */ @SuppressWarnings({"unchecked"}) - @Nullable public <K, V> GridCacheInterceptor<K, V> getInterceptor() { - return (GridCacheInterceptor<K, V>)interceptor; + @Nullable public <K, V> CacheInterceptor<K, V> getInterceptor() { + return (CacheInterceptor<K, V>)interceptor; } /** @@ -1692,7 +1692,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @param interceptor Cache interceptor. */ - public <K, V> void setInterceptor(GridCacheInterceptor<K, V> interceptor) { + public <K, V> void setInterceptor(CacheInterceptor<K, V> interceptor) { this.interceptor = interceptor; } @@ -1757,7 +1757,7 @@ public class CacheConfiguration extends MutableConfiguration { * * @return Cache query configuration. */ - public GridCacheQueryConfiguration getQueryConfiguration() { + public CacheQueryConfiguration getQueryConfiguration() { return qryCfg; } @@ -1765,9 +1765,9 @@ public class CacheConfiguration extends MutableConfiguration { * Sets query configuration. * * @param qryCfg Query configuration. - * @see GridCacheQueryConfiguration + * @see org.apache.ignite.cache.query.CacheQueryConfiguration */ - public void setQueryConfiguration(GridCacheQueryConfiguration qryCfg) { + public void setQueryConfiguration(CacheQueryConfiguration qryCfg) { this.qryCfg = qryCfg; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/CacheDistributionMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheDistributionMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheDistributionMode.java new file mode 100644 index 0000000..3243845 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheDistributionMode.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.jetbrains.annotations.*; + +/** + * This enum defines mode in which partitioned cache operates. + * <p> + * Partitioned distribution mode can be configured via {@link CacheConfiguration#getDistributionMode()} + * configuration property. + */ +public enum CacheDistributionMode { + /** + * Mode in which local node does not cache any data and communicates with other cache nodes + * via remote calls. + */ + CLIENT_ONLY, + + /** + * Mode in which local node will not be either primary or backup node for any keys, but will cache + * recently accessed keys in a smaller near cache. Amount of recently accessed keys to cache is + * controlled by near eviction policy. + * + * @see CacheConfiguration#getNearEvictionPolicy() + */ + NEAR_ONLY, + + /** + * Mode in which local node may store primary and/or backup keys, and also will cache recently accessed keys. + * Amount of recently accessed keys to cache is controlled by near eviction policy. + * @see CacheConfiguration#getNearEvictionPolicy() + */ + NEAR_PARTITIONED, + + /** + * Mode in which local node may store primary or backup keys, but does not cache recently accessed keys + * in near cache. + */ + PARTITIONED_ONLY; + + /** Enumerated values. */ + private static final CacheDistributionMode[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value or {@code null} if ordinal out of range. + */ + @Nullable public static CacheDistributionMode fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java new file mode 100644 index 0000000..08789f6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java @@ -0,0 +1,621 @@ +/* + * 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; + +import org.apache.ignite.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.transactions.*; +import org.jetbrains.annotations.*; + +import java.util.*; +import java.util.Map.*; +import java.util.concurrent.*; + +/** + * This interface provides a rich API for working with individual cache entries. It + * includes the following main functionality: + * <ul> + * <li> + * Various {@code 'get(..)'} methods to synchronously or asynchronously get values from cache. + * All {@code 'get(..)'} methods are transactional and will participate in an ongoing transaction + * if there is one. + * </li> + * <li> + * Various {@code 'set(..)'}, {@code 'setIfAbsent(..)'}, and {@code 'replace(..)'} methods to + * synchronously or asynchronously put single or multiple entries into cache. + * All these methods are transactional and will participate in an ongoing transaction + * if there is one. + * </li> + * <li> + * Various {@code 'remove(..)'} methods to synchronously or asynchronously remove single or multiple keys + * from cache. All {@code 'remove(..)'} methods are transactional and will participate in an ongoing transaction + * if there is one. + * </li> + * <li> + * Various {@code 'invalidate(..)'} methods to set cached values to {@code null}. + * <li> + * <li> + * Various {@code 'isLocked(..)'} methods to check on distributed locks on a single or multiple keys + * in cache. All locking methods are not transactional and will not enlist keys into ongoing transaction, + * if any. + * </li> + * <li> + * Various {@code 'peek(..)'} methods to peek at values in global or transactional memory, swap + * storage, or persistent storage. + * </li> + * <li> + * Various {@code 'reload(..)'} methods to reload latest values from persistent storage. + * </li> + * <li> + * Method {@link #evict()} to evict elements from cache, and optionally store + * them in underlying swap storage for later access. All {@code 'evict(..)'} methods are not + * transactional and will not enlist evicted keys into ongoing transaction, if any. + * </li> + * <li> + * Methods for {@link #timeToLive(long)} to change or lookup entry's time to live. + * </ul> + * <h1 class="header">Extended Put And Remove Methods</h1> + * All methods that end with {@code 'x'} provide the same functionality as their sibling + * methods that don't end with {@code 'x'}, however instead of returning a previous value they + * return a {@code boolean} flag indicating whether operation succeeded or not. Returning + * a previous value may involve a network trip or a persistent store lookup and should be + * avoided whenever not needed. + * <h1 class="header">Predicate Filters</h1> + * All filters passed into methods on this API are checked <b>atomically</b>. In other words the value + * of cache entry is guaranteed not to change throughout the cache operation. + * <h1 class="header">Transactions</h1> + * Cache API supports distributed transactions. All {@code 'get(..)'}, {@code 'put(..)'}, {@code 'replace(..)'}, + * and {@code 'remove(..)'} operations are transactional and will participate in an ongoing transaction. + * Other methods like {@code 'peek(..)'} may be transaction-aware, i.e. check in-transaction entries first, but + * will not affect the current state of transaction. See {@link IgniteTx} documentation for more information + * about transactions. + * @param <K> Key type. + * @param <V> Value type. + */ +public interface CacheEntry<K, V> extends Map.Entry<K, V>, Cache.Entry<K, V> { + /** + * Cache projection to which this entry belongs. Note that entry and its + * parent projections have same flags and filters. + * + * @return Cache projection for the cache to which this entry belongs. + */ + public CacheProjection<K, V> projection(); + + /** + * This method has the same semantic as {@link CacheProjection#peek(Object)} method. + * + * @return See {@link CacheProjection#peek(Object)}. + */ + @Nullable public V peek(); + + /** + * This method has the same semantic as + * {@link CacheProjection#peek(Object, Collection)} method. + * + * @param modes See {@link CacheProjection#peek(Object, Collection)}. + * @return See {@link CacheProjection#peek(Object, Collection)}. + * @throws IgniteCheckedException See {@link CacheProjection#peek(Object, Collection)}. + */ + @Nullable public V peek(@Nullable Collection<GridCachePeekMode> modes) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#reload(Object)} method. + * + * @return See {@link CacheProjection#reload(Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#reload(Object)}. + */ + @Nullable public V reload() throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#reloadAsync(Object)} method. + * + * @return See {@link CacheProjection#reloadAsync(Object)}. + */ + public IgniteFuture<V> reloadAsync(); + + /** + * This method has the same semantic as + * {@link CacheProjection#isLocked(Object)} method. + * + * @return See {@link CacheProjection#isLocked(Object)}. + */ + public boolean isLocked(); + + /** + * This method has the same semantic as + * {@link CacheProjection#isLockedByThread(Object)} method. + * + * @return See {@link CacheProjection#isLockedByThread(Object)}. + */ + public boolean isLockedByThread(); + + /** + * Gets current version of this cache entry. + * + * @return Version of this cache entry. + */ + public Object version(); + + /** + * Gets expiration time for this entry. + * + * @return Absolute time when this value expires. + */ + public long expirationTime(); + + /** + * Gets time to live, i.e. maximum life time, of this entry in milliseconds. + * + * @return Time to live value for this entry. + */ + public long timeToLive(); + + /** + * Sets time to live, i.e. maximum life time, of this entry in milliseconds. + * Note that this method is transactional - if entry is enlisted into a transaction, + * then time-to-live will not be set until transaction commit. + * <p> + * When called outside the transaction, this method will have no effect until the + * next update operation. + * + * @param ttl Time to live value for this entry. + */ + public void timeToLive(long ttl); + + /** + * Gets the flag indicating current node's primary ownership for this entry. + * <p> + * Note, that this value is dynamic and may change with grid topology changes. + * + * @return {@code True} if current grid node is the primary owner for this entry. + */ + public boolean primary(); + + /** + * Gets the flag indicating if current node is backup for this entry. + * <p> + * Note, that this value is dynamic and may change with grid topology changes. + * + * @return {@code True} if current grid node is the backup for this entry. + */ + public boolean backup(); + + /** + * Gets affinity partition id for this entry. + * + * @return Partition id. + */ + public int partition(); + + /** + * This method has the same semantic as {@link #get()} method, however it + * wraps {@link IgniteCheckedException} into {@link IgniteException} if failed in order to + * comply with {@link Entry} interface. + * + * @return See {@link #get()} + */ + @Nullable @Override public V getValue(); + + /** + * This method has the same semantic as + * {@link CacheProjection#get(Object)} method. + * + * @return See {@link CacheProjection#get(Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#get(Object)}. + */ + @Nullable public V get() throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#getAsync(Object)} method. + * + * @return See {@link CacheProjection#getAsync(Object)}. + */ + public IgniteFuture<V> getAsync(); + + /** + * This method has the same semantic as {@link #set(Object, org.apache.ignite.lang.IgnitePredicate[])} method, however it + * wraps {@link IgniteCheckedException} into {@link IgniteException} if failed in order to + * comply with {@link Entry} interface. + * + * @return See {@link #set(Object, org.apache.ignite.lang.IgnitePredicate[])} + */ + @Nullable @Override public V setValue(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param val See {@link CacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} + * @param filter See {@link CacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @throws IgniteCheckedException See {@link CacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + @Nullable public V set(V val, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param val See {@link CacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} + * @param filter See {@link CacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public IgniteFuture<V> setAsync(V val, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter); + + /** + * This method has the same semantic as + * {@link CacheProjection#putIfAbsent(Object, Object)} method. + * + * @param val See {@link CacheProjection#putIfAbsent(Object, Object)} + * @return See {@link CacheProjection#putIfAbsent(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#putIfAbsent(Object, Object)}. + */ + @Nullable public V setIfAbsent(V val) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#putIfAbsentAsync(Object, Object)} method. + * + * @param val See {@link CacheProjection#putIfAbsentAsync(Object, Object)} + * @return See {@link CacheProjection#putIfAbsentAsync(Object, Object)}. + */ + public IgniteFuture<V> setIfAbsentAsync(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param val See {@link CacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} + * @param filter See {@link CacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @throws IgniteCheckedException See {@link CacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public boolean setx(V val, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) + throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param val See {@link CacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} + * @param filter See {@link CacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public IgniteFuture<Boolean> setxAsync(V val, + @Nullable IgnitePredicate<CacheEntry<K, V>>... filter); + + /** + * This method has the same semantic as + * {@link CacheProjection#putxIfAbsent(Object, Object)} method. + * + * @param val See {@link CacheProjection#putxIfAbsent(Object, Object)} + * @return See {@link CacheProjection#putxIfAbsent(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#putxIfAbsent(Object, Object)}. + */ + public boolean setxIfAbsent(@Nullable V val) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#putxIfAbsentAsync(Object, Object)} method. + * + * @param val See {@link CacheProjection#putxIfAbsentAsync(Object, Object)} + * @return See {@link CacheProjection#putxIfAbsentAsync(Object, Object)}. + */ + public IgniteFuture<Boolean> setxIfAbsentAsync(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#replace(Object, Object)} method. + * + * @param val See {@link CacheProjection#replace(Object, Object)} + * @return See {@link CacheProjection#replace(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#replace(Object, Object)}. + */ + @Nullable public V replace(V val) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#replaceAsync(Object, Object)} method. + * + * @param val See {@link CacheProjection#replaceAsync(Object, Object)} + * @return See {@link CacheProjection#replaceAsync(Object, Object)}. + */ + public IgniteFuture<V> replaceAsync(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#replacex(Object, Object)} method. + * + * @param val See {@link CacheProjection#replacex(Object, Object)} + * @return See {@link CacheProjection#replacex(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#replacex(Object, Object)}. + */ + public boolean replacex(V val) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#replacexAsync(Object, Object)} method. + * + * @param val See {@link CacheProjection#replacexAsync(Object, Object)} + * @return See {@link CacheProjection#replacexAsync(Object, Object)}. + */ + public IgniteFuture<Boolean> replacexAsync(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#replace(Object, Object, Object)} method. + * + * @param oldVal See {@link CacheProjection#replace(Object, Object, Object)} + * @param newVal See {@link CacheProjection#replace(Object, Object, Object)} + * @return See {@link CacheProjection#replace(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#replace(Object, Object)}. + */ + public boolean replace(V oldVal, V newVal) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#replaceAsync(Object, Object, Object)} method. + * + * @param oldVal See {@link CacheProjection#replaceAsync(Object, Object, Object)} + * @param newVal See {@link CacheProjection#replaceAsync(Object, Object, Object)} + * @return See {@link CacheProjection#replaceAsync(Object, Object)}. + */ + public IgniteFuture<Boolean> replaceAsync(V oldVal, V newVal); + + /** + * This method has the same semantic as + * {@link CacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param filter See {@link CacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @throws IgniteCheckedException See {@link CacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + @Nullable public V remove(@Nullable IgnitePredicate<CacheEntry<K, V>>... filter) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param filter See {@link CacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public IgniteFuture<V> removeAsync(@Nullable IgnitePredicate<CacheEntry<K, V>>... filter); + + /** + * This method has the same semantic as + * {@link CacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param filter See {@link CacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @throws IgniteCheckedException See {@link CacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public boolean removex(@Nullable IgnitePredicate<CacheEntry<K, V>>... filter) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method. + * + * @param filter See {@link CacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. + * @return See {@link CacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. + */ + public IgniteFuture<Boolean> removexAsync(@Nullable IgnitePredicate<CacheEntry<K, V>>... filter); + + /** + * This method has the same semantic as + * {@link CacheProjection#remove(Object, Object)} method. + * + * @param val See {@link CacheProjection#remove(Object, Object)}. + * @return See {@link CacheProjection#remove(Object, Object)}. + * @throws IgniteCheckedException See {@link CacheProjection#remove(Object, Object)}. + */ + public boolean remove(V val) throws IgniteCheckedException; + + /** + * This method has the same semantic as + * {@link CacheProjection#removeAsync(Object, Object)} method. + * + * @param val See {@link CacheProjection#removeAsync(Object, Object)}. + * @return See {@link CacheProjection#removeAsync(Object, Object)}. + */ + public IgniteFuture<Boolean> removeAsync(V val); + + /** + * This method has the same semantic as + * {@link CacheProjection#evict(Object)} method. + * + * @return See {@link CacheProjection#evict(Object)}. + */ + public boolean evict(); + + /** + * This method has the same semantic as + * {@link CacheProjection#clear(Object)} method. + * + * @return See {@link CacheProjection#clear(Object)}. + */ + public boolean clear(); + + /** + * Optimizes the size of this entry. If entry is expired at the time + * of the call then entry is removed locally. + * + * @throws IgniteCheckedException If failed to compact. + * @return {@code true} if entry was cleared from cache (if value was {@code null}). + */ + public boolean compact() throws IgniteCheckedException; + + /** + * Synchronously acquires lock on a cached object associated with this entry + * only if the passed in filter (if any) passes. This method together with + * filter check will be executed as one atomic operation. + * <h2 class="header">Transactions</h2> + * Locks are not transactional and should not be used from within transactions. + * If you do need explicit locking within transaction, then you should use + * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction + * which will acquire explicit locks for relevant cache operations. + * <h2 class="header">Cache Flags</h2> + * This method is not available if any of the following flags are set on projection: + * {@link CacheFlag#LOCAL}, {@link CacheFlag#READ}. + * + * @param timeout Timeout in milliseconds to wait for lock to be acquired + * ({@code '0'} for no expiration). + * @param filter Optional filter to validate prior to acquiring the lock. + * @return {@code True} if all filters passed and lock was acquired, + * {@code false} otherwise. + * @throws IgniteCheckedException If lock acquisition resulted in error. + * @throws CacheFlagException If flags validation failed. + */ + public boolean lock(long timeout, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) + throws IgniteCheckedException; + + /** + * Asynchronously acquires lock on a cached object associated with this entry + * only if the passed in filter (if any) passes. This method together with + * filter check will be executed as one atomic operation. + * <h2 class="header">Transactions</h2> + * Locks are not transactional and should not be used from within transactions. If you do + * need explicit locking within transaction, then you should use + * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction + * which will acquire explicit locks for relevant cache operations. + * <h2 class="header">Cache Flags</h2> + * This method is not available if any of the following flags are set on projection: + * {@link CacheFlag#LOCAL}, {@link CacheFlag#READ}. + * + * @param timeout Timeout in milliseconds to wait for lock to be acquired + * ({@code '0'} for no expiration). + * @param filter Optional filter to validate prior to acquiring the lock. + * @return Future for the lock operation. The future will return {@code true} + * whenever all filters pass and locks are acquired before timeout is expired, + * {@code false} otherwise. + * @throws CacheFlagException If flags validation failed. + */ + public IgniteFuture<Boolean> lockAsync(long timeout, + @Nullable IgnitePredicate<CacheEntry<K, V>>... filter); + + /** + * Unlocks this entry only if current thread owns the lock. If optional filter + * will not pass, then unlock will not happen. If this entry was never locked by + * current thread, then this method will do nothing. + * <h2 class="header">Transactions</h2> + * Locks are not transactional and should not be used from within transactions. If you do + * need explicit locking within transaction, then you should use + * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction + * which will acquire explicit locks for relevant cache operations. + * <h2 class="header">Cache Flags</h2> + * This method is not available if any of the following flags are set on projection: + * {@link CacheFlag#LOCAL}, {@link CacheFlag#READ}. + * + * @param filter Optional filter that needs to pass prior to unlock taking effect. + * @throws IgniteCheckedException If unlock execution resulted in error. + * @throws CacheFlagException If flags validation failed. + */ + public void unlock(IgnitePredicate<CacheEntry<K, V>>... filter) throws IgniteCheckedException; + + /** + * Checks whether entry is currently present in cache or not. If entry is not in + * cache (e.g. has been removed) {@code false} is returned. In this case all + * operations on this entry will cause creation of a new entry in cache. + * + * @return {@code True} if entry is in cache, {@code false} otherwise. + */ + public boolean isCached(); + + /** + * Gets size of serialized key and value in addition to any overhead added by {@code GridGain} itself. + * + * @return size in bytes. + * @throws IgniteCheckedException If failed to evaluate entry size. + */ + public int memorySize() throws IgniteCheckedException; + + /** + * Removes metadata by name. + * + * @param name Name of the metadata to remove. + * @param <V> Type of the value. + * @return Value of removed metadata or {@code null}. + */ + public <V> V removeMeta(String name); + + /** + * Removes metadata only if its current value is equal to {@code val} passed in. + * + * @param name Name of metadata attribute. + * @param val Value to compare. + * @param <V> Value type. + * @return {@code True} if value was removed, {@code false} otherwise. + */ + public <V> boolean removeMeta(String name, V val); + + /** + * Gets metadata by name. + * + * @param name Metadata name. + * @param <V> Type of the value. + * @return Metadata value or {@code null}. + */ + public <V> V meta(String name); + + /** + * Adds given metadata value only if it was absent. + * + * @param name Metadata name. + * @param c Factory closure to produce value to add if it's not attached already. + * Not that unlike {@link #addMeta(String, Object)} method the factory closure will + * not be called unless the value is required and therefore value will only be created + * when it is actually needed. + * @param <V> Type of the value. + * @return {@code null} if new value was put, or current value if put didn't happen. + */ + @Nullable public <V> V putMetaIfAbsent(String name, Callable<V> c); + + /** + * Adds given metadata value only if it was absent. + * + * @param name Metadata name. + * @param val Value to add if it's not attached already. + * @param <V> Type of the value. + * @return {@code null} if new value was put, or current value if put didn't happen. + */ + @Nullable public <V> V putMetaIfAbsent(String name, V val); + + /** + * Adds a new metadata. + * + * @param name Metadata name. + * @param val Metadata value. + * @param <V> Type of the value. + * @return Metadata previously associated with given name, or + * {@code null} if there was none. + */ + @Nullable public <V> V addMeta(String name, V val); + + /** + * Replaces given metadata with new {@code newVal} value only if its current value + * is equal to {@code curVal}. Otherwise, it is no-op. + * + * @param name Name of the metadata. + * @param curVal Current value to check. + * @param newVal New value. + * @return {@code true} if replacement occurred, {@code false} otherwise. + */ + public <V> boolean replaceMeta(String name, V curVal, V newVal); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/CacheEntryEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntryEvent.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntryEvent.java index b2ca482..1db81af 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntryEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntryEvent.java @@ -27,14 +27,14 @@ import javax.cache.event.*; */ public class CacheEntryEvent<K, V> extends javax.cache.event.CacheEntryEvent<K, V> { /** */ - private final GridCacheContinuousQueryEntry<K, V> e; + private final CacheContinuousQueryEntry<K, V> e; /** * @param src Cache. * @param type Event type. * @param e Ignite event. */ - public CacheEntryEvent(IgniteCache src, EventType type, GridCacheContinuousQueryEntry<K, V> e) { + public CacheEntryEvent(IgniteCache src, EventType type, CacheContinuousQueryEntry<K, V> e) { super(src, type); this.e = e;