ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [45/54] [abbrv] incubator-ignite git commit: # ignite-63
Date Thu, 22 Jan 2015 15:17:54 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicUpdateTimeoutException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicUpdateTimeoutException.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicUpdateTimeoutException.java
new file mode 100644
index 0000000..f43954a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicUpdateTimeoutException.java
@@ -0,0 +1,47 @@
+/*
+ * 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.*;
+
+/**
+ * Exception thrown when atomic operation timeout occurs.
+ */
+public class GridCacheAtomicUpdateTimeoutException extends IgniteCheckedException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * Creates new timeout exception with given error message.
+     *
+     * @param msg Error message.
+     */
+    public GridCacheAtomicUpdateTimeoutException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Creates new timeout exception with given error message and optional nested exception.
+     *
+     * @param msg Error message.
+     * @param cause Optional nested exception (can be <tt>null</tt>).
+     */
+    public GridCacheAtomicUpdateTimeoutException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicWriteOrderMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicWriteOrderMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicWriteOrderMode.java
new file mode 100644
index 0000000..f258145
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicWriteOrderMode.java
@@ -0,0 +1,64 @@
+/*
+ * 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.*;
+
+/**
+ * Cache write ordering mode. This enumeration is taken into account only in {@link GridCacheAtomicityMode#ATOMIC}
+ * 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
+ * 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}
+ * write synchronization mode, as for other synchronization modes it does not render better performance.
+ */
+public enum GridCacheAtomicWriteOrderMode {
+    /**
+     * 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
+     * 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}
+     * write synchronization mode, as for other synchronization modes it does not render better performance.
+     */
+    CLOCK,
+
+    /**
+     * Cache version is assigned only on primary node. This means that sender will only send write request
+     * to primary node, which in turn will assign write version and forward it to backups.
+     */
+    PRIMARY;
+
+    /** Enumerated values. */
+    private static final GridCacheAtomicWriteOrderMode[] 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 GridCacheAtomicWriteOrderMode fromOrdinal(byte ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicityMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicityMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicityMode.java
new file mode 100644
index 0000000..8075b85
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheAtomicityMode.java
@@ -0,0 +1,79 @@
+/*
+ * 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.transactions.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Cache atomicity mode controls whether cache should maintain fully transactional semantics
+ * or more light-weight atomic behavior. It is recommended that {@link #ATOMIC} mode is
+ * used whenever transactions and explicit locking are not needed. Note that in {@link #ATOMIC}
+ * mode cache will still maintain full data consistency across all cache nodes.
+ * <p>
+ * Cache atomicity may be set via {@link CacheConfiguration#getAtomicityMode()}
+ * configuration property.
+ */
+public enum GridCacheAtomicityMode {
+    /**
+     * Specified fully {@code ACID}-compliant transactional cache behavior. See
+     * {@link IgniteTx} for more information about transactions.
+     * <p>
+     * This mode is currently the default cache atomicity mode. However, cache
+     * atomicity mode will be changed to {@link #ATOMIC} starting from version {@code 5.2},
+     * so it is recommended that desired atomicity mode is explicitly configured
+     * instead of relying on default value.
+     */
+    TRANSACTIONAL,
+
+    /**
+     * Specifies atomic-only cache behaviour. In this mode distributed transactions and distributed
+     * locking are not supported. Disabling transactions and locking allows to achieve much higher
+     * performance and throughput ratios.
+     * <p>
+     * In addition to transactions and locking, one of the main differences in {@code ATOMIC} mode
+     * is that bulk writes, such as {@code putAll(...)}, {@code removeAll(...)}, and {@code transformAll(...)}
+     * methods, become simple batch operations which can partially fail. In case of partial
+     * failure {@link GridCachePartialUpdateException} will be thrown which will contain a list of keys
+     * for which the update failed. It is recommended that bulk writes are used whenever multiple keys
+     * need to be inserted or updated in cache, as they reduce number of network trips and provide
+     * better performance.
+     * <p>
+     * Note that even without locking and transactions, {@code ATOMIC} mode still provides
+     * full consistency guarantees across all cache nodes.
+     * <p>
+     * Also note that all data modifications in {@code ATOMIC} mode are guaranteed to be atomic
+     * and consistent with writes to the underlying persistent store, if one is configured.
+     * <p>
+     * This mode is currently implemented for {@link GridCacheMode#PARTITIONED} caches only.
+     */
+    ATOMIC;
+
+    /** Enumerated values. */
+    private static final GridCacheAtomicityMode[] 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 GridCacheAtomicityMode fromOrdinal(int ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheDistributionMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheDistributionMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheDistributionMode.java
new file mode 100644
index 0000000..cafdea0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheDistributionMode.java
@@ -0,0 +1,70 @@
+/*
+ * 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.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 GridCacheDistributionMode {
+    /**
+     * 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 GridCacheDistributionMode[] 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 GridCacheDistributionMode fromOrdinal(int ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheEntry.java
new file mode 100644
index 0000000..120d59e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheEntry.java
@@ -0,0 +1,549 @@
+/*
+ * 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.gridgain.grid.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import java.util.*;
+import java.util.Map.*;
+
+/**
+ * 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 GridCacheEntry<K, V> extends Map.Entry<K, V>, GridMetadataAware, 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 GridCacheProjection<K, V> projection();
+
+    /**
+     * This method has the same semantic as {@link GridCacheProjection#peek(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#peek(Object)}.
+     */
+    @Nullable public V peek();
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#peek(Object, Collection)} method.
+     *
+     * @param modes See {@link GridCacheProjection#peek(Object, Collection)}.
+     * @return See {@link GridCacheProjection#peek(Object, Collection)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#peek(Object, Collection)}.
+     */
+    @Nullable public V peek(@Nullable Collection<GridCachePeekMode> modes) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#reload(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#reload(Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#reload(Object)}.
+     */
+    @Nullable public V reload() throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#reloadAsync(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#reloadAsync(Object)}.
+     */
+    public IgniteFuture<V> reloadAsync();
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#isLocked(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#isLocked(Object)}.
+     */
+    public boolean isLocked();
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#isLockedByThread(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#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 GridCacheProjection#get(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#get(Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#get(Object)}.
+     */
+    @Nullable public V get() throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#getAsync(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#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 GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param val See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}
+     * @param filter See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    @Nullable public V set(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param val See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}
+     * @param filter See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public IgniteFuture<V> setAsync(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putIfAbsent(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#putIfAbsent(Object, Object)}
+     * @return See {@link GridCacheProjection#putIfAbsent(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#putIfAbsent(Object, Object)}.
+     */
+    @Nullable public V setIfAbsent(V val) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putIfAbsentAsync(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#putIfAbsentAsync(Object, Object)}
+     * @return See {@link GridCacheProjection#putIfAbsentAsync(Object, Object)}.
+     */
+    public IgniteFuture<V> setIfAbsentAsync(V val);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param val See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}
+     * @param filter See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public boolean setx(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter)
+        throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param val See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}
+     * @param filter See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public IgniteFuture<Boolean> setxAsync(V val,
+        @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putxIfAbsent(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#putxIfAbsent(Object, Object)}
+     * @return See {@link GridCacheProjection#putxIfAbsent(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#putxIfAbsent(Object, Object)}.
+     */
+    public boolean setxIfAbsent(@Nullable V val) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)}
+     * @return See {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)}.
+     */
+    public IgniteFuture<Boolean> setxIfAbsentAsync(V val);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replace(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#replace(Object, Object)}
+     * @return See {@link GridCacheProjection#replace(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#replace(Object, Object)}.
+     */
+    @Nullable public V replace(V val) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replaceAsync(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#replaceAsync(Object, Object)}
+     * @return See {@link GridCacheProjection#replaceAsync(Object, Object)}.
+     */
+    public IgniteFuture<V> replaceAsync(V val);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replacex(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#replacex(Object, Object)}
+     * @return See {@link GridCacheProjection#replacex(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#replacex(Object, Object)}.
+     */
+    public boolean replacex(V val) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replacexAsync(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#replacexAsync(Object, Object)}
+     * @return See {@link GridCacheProjection#replacexAsync(Object, Object)}.
+     */
+    public IgniteFuture<Boolean> replacexAsync(V val);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replace(Object, Object, Object)} method.
+     *
+     * @param oldVal See {@link GridCacheProjection#replace(Object, Object, Object)}
+     * @param newVal See {@link GridCacheProjection#replace(Object, Object, Object)}
+     * @return See {@link GridCacheProjection#replace(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#replace(Object, Object)}.
+     */
+    public boolean replace(V oldVal, V newVal) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#replaceAsync(Object, Object, Object)} method.
+     *
+     * @param oldVal See {@link GridCacheProjection#replaceAsync(Object, Object, Object)}
+     * @param newVal See {@link GridCacheProjection#replaceAsync(Object, Object, Object)}
+     * @return See {@link GridCacheProjection#replaceAsync(Object, Object)}.
+     */
+    public IgniteFuture<Boolean> replaceAsync(V oldVal, V newVal);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param filter See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    @Nullable public V remove(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param filter See {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public IgniteFuture<V> removeAsync(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param filter See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public boolean removex(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method.
+     *
+     * @param filter See {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     * @return See {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}.
+     */
+    public IgniteFuture<Boolean> removexAsync(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#remove(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#remove(Object, Object)}.
+     * @return See {@link GridCacheProjection#remove(Object, Object)}.
+     * @throws IgniteCheckedException See {@link GridCacheProjection#remove(Object, Object)}.
+     */
+    public boolean remove(V val) throws IgniteCheckedException;
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#removeAsync(Object, Object)} method.
+     *
+     * @param val See {@link GridCacheProjection#removeAsync(Object, Object)}.
+     * @return See {@link GridCacheProjection#removeAsync(Object, Object)}.
+     */
+    public IgniteFuture<Boolean> removeAsync(V val);
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#evict(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#evict(Object)}.
+     */
+    public boolean evict();
+
+    /**
+     * This method has the same semantic as
+     * {@link GridCacheProjection#clear(Object)} method.
+     *
+     * @return See {@link GridCacheProjection#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 GridCacheFlag#LOCAL}, {@link GridCacheFlag#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 GridCacheFlagException If flags validation failed.
+     */
+    public boolean lock(long timeout, @Nullable IgnitePredicate<GridCacheEntry<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 GridCacheFlag#LOCAL}, {@link GridCacheFlag#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 GridCacheFlagException If flags validation failed.
+     */
+    public IgniteFuture<Boolean> lockAsync(long timeout,
+        @Nullable IgnitePredicate<GridCacheEntry<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 GridCacheFlag#LOCAL}, {@link GridCacheFlag#READ}.
+     *
+     * @param filter Optional filter that needs to pass prior to unlock taking effect.
+     * @throws IgniteCheckedException If unlock execution resulted in error.
+     * @throws GridCacheFlagException If flags validation failed.
+     */
+    public void unlock(IgnitePredicate<GridCacheEntry<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;
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlag.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlag.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlag.java
new file mode 100644
index 0000000..642c8b5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlag.java
@@ -0,0 +1,111 @@
+/*
+ * 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.CacheConfiguration;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.processor.*;
+
+/**
+ * Cache projection flags that specify projection behaviour. This flags can be explicitly passed into
+ * the following methods on {@link GridCacheProjection}:
+ * <ul>
+ * <li>{@link GridCacheProjection#flagsOn(GridCacheFlag...)}</li>
+ * <li>{@link GridCacheProjection#flagsOff(GridCacheFlag...)}</li>
+ * </ul>
+ * Also, some flags, like {@link #LOCAL}, or {@link #READ} may be implicitly set whenever
+ * creating new projections and passing entries to predicate filters.
+ */
+public enum GridCacheFlag {
+    /**
+     * Only operations that don't require any communication with
+     * other cache nodes are allowed. This flag is automatically set
+     * on underlying projection for all the entries that are given to
+     * predicate filters to make sure that no distribution happens
+     * from inside of predicate evaluation.
+     */
+    LOCAL,
+
+    /**
+     * Only operations that don't change cached data are allowed.
+     * This flag is automatically set on underlying projection for
+     * all the entries that are given to predicate filters to make
+     * sure that data cannot be updated during predicate evaluation.
+     */
+    READ,
+
+    /**
+     * Clone values prior to returning them to user.
+     * <p>
+     * Whenever values are returned from cache, they cannot be directly updated
+     * as cache holds the same references internally. If it is needed to
+     * update values that are returned from cache, this flag will provide
+     * automatic cloning of values prior to returning so they can be directly
+     * updated.
+     *
+     * @see CacheConfiguration#getCloner()
+     */
+    CLONE,
+
+    /** Skips store, i.e. no read-through and no write-through behavior. */
+    SKIP_STORE,
+
+    /** Skip swap space for reads and writes. */
+    SKIP_SWAP,
+
+    /** Synchronous commit. */
+    SYNC_COMMIT,
+
+    /**
+     * Switches a cache projection to work in {@code 'invalidation'} mode.
+     * Instead of updating remote entries with new values, small invalidation
+     * messages will be sent to set the values to {@code null}.
+     *
+     * @see IgniteTx#isInvalidate()
+     * @see CacheConfiguration#isInvalidate()
+     */
+    INVALIDATE,
+
+    /**
+     * Skips version check during {@link IgniteCache#invoke(Object, EntryProcessor, Object[])} writes in
+     * {@link GridCacheAtomicityMode#ATOMIC} mode. By default, in {@code ATOMIC} mode, whenever
+     * {@code transform(...)} is called, cache values (and not the {@code transform} closure) are sent from primary
+     * node to backup nodes to ensure proper update ordering.
+     * <p>
+     * By setting this flag, version check is skipped, and the {@code transform} closure is applied on both, primary
+     * and backup nodes. Use this flag for better performance if you are sure that there are no
+     * concurrent updates happening for the same key when {@code transform(...)} method is called.
+     */
+    FORCE_TRANSFORM_BACKUP;
+
+    /** */
+    private static final GridCacheFlag[] 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 GridCacheFlag fromOrdinal(int ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlagException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlagException.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlagException.java
new file mode 100644
index 0000000..c36723c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheFlagException.java
@@ -0,0 +1,67 @@
+/*
+ * 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.gridgain.grid.util.typedef.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * Exception thrown when projection flags check fails.
+ */
+public class GridCacheFlagException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Flags that caused this exception. */
+    private Collection<GridCacheFlag> flags;
+
+    /**
+     * @param flags Cause flags.
+     */
+    public GridCacheFlagException(@Nullable GridCacheFlag... flags) {
+        this(F.asList(flags));
+    }
+
+    /**
+     * @param flags Cause flags.
+     */
+    public GridCacheFlagException(@Nullable Collection<GridCacheFlag> flags) {
+        super(message(flags));
+
+        this.flags = flags;
+    }
+
+    /**
+     * @return Cause flags.
+     */
+    public Collection<GridCacheFlag> flags() {
+        return flags;
+    }
+
+    /**
+     * @param flags Flags.
+     * @return String information about cause flags.
+     */
+    private static String message(Collection<GridCacheFlag> flags) {
+        return "Cache projection flag violation (if flag is LOCAL, make sure to use peek(..) " +
+            "instead of get(..) methods)" + (F.isEmpty(flags) ? "." : " [flags=" + flags + ']');
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptor.java
new file mode 100644
index 0000000..af1ce45
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptor.java
@@ -0,0 +1,121 @@
+/*
+ * 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.cache.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Cache interceptor. Cache interceptor can be used for getting callbacks before
+ * and after cache {@code get(...)}, {@code put(...)}, and {@code remove(...)}
+ * operations. The {@code onBefore} callbacks can also be used to change the values
+ * stored in cache or preventing entries from being removed from cache.
+ * <p>
+ * Cache interceptor is configured via {@link CacheConfiguration#getInterceptor()}
+ * configuration property.
+ * <p>
+ * Any grid resource from {@code org.gridgain.grid.resources} package can be injected
+ * into implementation of this interface.
+ */
+public interface GridCacheInterceptor<K, V> {
+    /**
+     * This method is called within {@link GridCacheProjection#get(Object)}
+     * and similar operations to provide control over returned value.
+     * <p>
+     * If this method returns {@code null}, then {@code get()} operation
+     * results in {@code null} as well.
+     * <p>
+     * This method should not throw any exception.
+     *
+     * @param key Key.
+     * @param val Value mapped to {@code key} at the moment of {@code get()} operation.
+     * @return The new value to be returned as result of {@code get()} operation.
+     * @see GridCacheProjection#get(Object)
+     */
+    @Nullable public V onGet(K key, @Nullable V val);
+
+    /**
+     * This method is called within {@link GridCacheProjection#put(Object, Object, IgnitePredicate[])}
+     * and similar operations before new value is stored in cache.
+     * <p>
+     * Implementations should not execute any complex logic,
+     * including locking, networking or cache operations,
+     * as it may lead to deadlock, since this method is called
+     * from sensitive synchronization blocks.
+     * <p>
+     * This method should not throw any exception.
+     *
+     * @param key Key.
+     * @param oldVal Old value.
+     * @param newVal New value.
+     * @return Value to be put to cache. Returning {@code null} cancels the update.
+     * @see GridCacheProjection#put(Object, Object, IgnitePredicate[])
+     */
+    @Nullable public V onBeforePut(K key, @Nullable V oldVal, V newVal);
+
+    /**
+     * This method is called after new value has been stored.
+     * <p>
+     * Implementations should not execute any complex logic,
+     * including locking, networking or cache operations,
+     * as it may lead to deadlock, since this method is called
+     * from sensitive synchronization blocks.
+     * <p>
+     * This method should not throw any exception.
+     *
+     * @param key Key.
+     * @param val Current value.
+     */
+    public void onAfterPut(K key, V val);
+
+    /**
+     * This method is called within {@link GridCacheProjection#remove(Object, IgnitePredicate[])}
+     * and similar operations to provide control over returned value.
+     * <p>
+     * Implementations should not execute any complex logic,
+     * including locking, networking or cache operations,
+     * as it may lead to deadlock, since this method is called
+     * from sensitive synchronization blocks.
+     * <p>
+     * This method should not throw any exception.
+     *
+     * @param key Key.
+     * @param val Old value.
+     * @return Tuple. The first value is the flag whether remove should be cancelled or not.
+     *      The second is the value to be returned as result of {@code remove()} operation,
+     *      may be {@code null}.
+     * @see GridCacheProjection#remove(Object, IgnitePredicate[])
+     */
+    @Nullable public IgniteBiTuple<Boolean, V> onBeforeRemove(K key, @Nullable V val);
+
+    /**
+     * This method is called after value has been removed.
+     * <p>
+     * Implementations should not execute any complex logic,
+     * including locking, networking or cache operations,
+     * as it may lead to deadlock, since this method is called
+     * from sensitive synchronization blocks.
+     * <p>
+     * This method should not throw any exception.
+     *
+     * @param key Key.
+     * @param val Removed value.
+     */
+    public void onAfterRemove(K key, V val);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptorAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptorAdapter.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptorAdapter.java
new file mode 100644
index 0000000..9794ae1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheInterceptorAdapter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.lang.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Cache interceptor convenience adapter. It provides no-op implementations for all
+ * interceptor callbacks.
+ */
+public class GridCacheInterceptorAdapter<K, V> implements GridCacheInterceptor<K, V> {
+    /** {@inheritDoc} */
+    @Nullable @Override public V onGet(K key, V val) {
+        return val;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V onBeforePut(K key, @Nullable V oldVal, V newVal) {
+        return newVal;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onAfterPut(K key, V val) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public IgniteBiTuple<Boolean, V> onBeforeRemove(K key, @Nullable V val) {
+        return new IgniteBiTuple<>(false, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onAfterRemove(K key, V val) {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMBean.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMBean.java
new file mode 100644
index 0000000..3ee1d4b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMBean.java
@@ -0,0 +1,296 @@
+/*
+ * 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.cache.CacheConfiguration;
+import org.apache.ignite.mbean.*;
+
+/**
+ * This interface defines JMX view on {@link GridCache}.
+ */
+@IgniteMBeanDescription("MBean that provides access to cache descriptor.")
+public interface GridCacheMBean {
+    /**
+     * Gets name of this cache.
+     *
+     * @return Cache name.
+     */
+    @IgniteMBeanDescription("Cache name.")
+    public String name();
+
+    /**
+     * Gets metrics (statistics) for this cache.
+     *
+     * @return Cache metrics.
+     */
+    @IgniteMBeanDescription("Formatted cache metrics.")
+    public String metricsFormatted();
+
+    /**
+     * Gets number of entries that was swapped to disk.
+     *
+     * @return Number of entries that was swapped to disk.
+     */
+    @IgniteMBeanDescription("Number of entries that was swapped to disk.")
+    public long getOverflowSize();
+
+    /**
+     * Gets number of entries stored in off-heap memory.
+     *
+     * @return Number of entries stored in off-heap memory.
+     */
+    @IgniteMBeanDescription("Number of entries stored in off-heap memory.")
+    public long getOffHeapEntriesCount();
+
+    /**
+     * Gets memory size allocated in off-heap.
+     *
+     * @return Memory size allocated in off-heap.
+     */
+    @IgniteMBeanDescription("Memory size allocated in off-heap.")
+    public long getOffHeapAllocatedSize();
+
+    /**
+     * Returns number of non-{@code null} values in the cache.
+     *
+     * @return Number of non-{@code null} values in the cache.
+     */
+    @IgniteMBeanDescription("Number of non-null values in the cache.")
+    public int getSize();
+
+    /**
+     * Gets number of keys in the cache, possibly with {@code null} values.
+     *
+     * @return Number of keys in the cache.
+     */
+    @IgniteMBeanDescription("Number of keys in the cache (possibly with null values).")
+    public int getKeySize();
+
+    /**
+     * Returns {@code true} if this cache is empty.
+     *
+     * @return {@code true} if this cache is empty.
+     */
+    @IgniteMBeanDescription("True if cache is empty.")
+    public boolean isEmpty();
+
+    /**
+     * Gets current size of evict queue used to batch up evictions.
+     *
+     * @return Current size of evict queue.
+     */
+    @IgniteMBeanDescription("Current size of evict queue.")
+    public int getDhtEvictQueueCurrentSize();
+
+    /**
+     * Gets transaction per-thread map size.
+     *
+     * @return Thread map size.
+     */
+    @IgniteMBeanDescription("Transaction per-thread map size.")
+    public int getTxThreadMapSize();
+
+    /**
+     * Gets transaction per-Xid map size.
+     *
+     * @return Transaction per-Xid map size.
+     */
+    @IgniteMBeanDescription("Transaction per-Xid map size.")
+    public int getTxXidMapSize();
+
+    /**
+     * Gets committed transaction queue size.
+     *
+     * @return Committed transaction queue size.
+     */
+    @IgniteMBeanDescription("Transaction committed queue size.")
+    public int getTxCommitQueueSize();
+
+    /**
+     * Gets prepared transaction queue size.
+     *
+     * @return Prepared transaction queue size.
+     */
+    @IgniteMBeanDescription("Transaction prepared queue size.")
+    public int getTxPrepareQueueSize();
+
+    /**
+     * Gets start version counts map size.
+     *
+     * @return Start version counts map size.
+     */
+    @IgniteMBeanDescription("Transaction start version counts map size.")
+    public int getTxStartVersionCountsSize();
+
+    /**
+     * Gets number of cached committed transaction IDs.
+     *
+     * @return Number of cached committed transaction IDs.
+     */
+    @IgniteMBeanDescription("Transaction committed ID map size.")
+    public int getTxCommittedVersionsSize();
+
+    /**
+     * Gets number of cached rolled back transaction IDs.
+     *
+     * @return Number of cached rolled back transaction IDs.
+     */
+    @IgniteMBeanDescription("Transaction rolled back ID map size.")
+    public int getTxRolledbackVersionsSize();
+
+    /**
+     * Gets transaction DHT per-thread map size.
+     *
+     * @return DHT thread map size.
+     */
+    @IgniteMBeanDescription("Transaction DHT per-thread map size.")
+    public int getTxDhtThreadMapSize();
+
+    /**
+     * Gets transaction DHT per-Xid map size.
+     *
+     * @return Transaction DHT per-Xid map size.
+     */
+    @IgniteMBeanDescription("Transaction DHT per-Xid map size.")
+    public int getTxDhtXidMapSize();
+
+    /**
+     * Gets committed DHT transaction queue size.
+     *
+     * @return Committed DHT transaction queue size.
+     */
+    @IgniteMBeanDescription("Transaction DHT committed queue size.")
+    public int getTxDhtCommitQueueSize();
+
+    /**
+     * Gets prepared DHT transaction queue size.
+     *
+     * @return Prepared DHT transaction queue size.
+     */
+    @IgniteMBeanDescription("Transaction DHT prepared queue size.")
+    public int getTxDhtPrepareQueueSize();
+
+    /**
+     * Gets DHT start version counts map size.
+     *
+     * @return DHT start version counts map size.
+     */
+    @IgniteMBeanDescription("Transaction DHT start version counts map size.")
+    public int getTxDhtStartVersionCountsSize();
+
+    /**
+     * Gets number of cached committed DHT transaction IDs.
+     *
+     * @return Number of cached committed DHT transaction IDs.
+     */
+    @IgniteMBeanDescription("Transaction DHT committed ID map size.")
+    public int getTxDhtCommittedVersionsSize();
+
+    /**
+     * Gets number of cached rolled back DHT transaction IDs.
+     *
+     * @return Number of cached rolled back DHT transaction IDs.
+     */
+    @IgniteMBeanDescription("Transaction DHT rolled back ID map size.")
+    public int getTxDhtRolledbackVersionsSize();
+
+    /**
+     * Returns {@code True} if write-behind is enabled.
+     *
+     * @return {@code True} if write-behind is enabled.
+     */
+    @IgniteMBeanDescription("True if write-behind is enabled for this cache.")
+    public boolean isWriteBehindEnabled();
+
+    /**
+     * Gets the maximum size of the write-behind buffer. When the count of unique keys
+     * in write buffer exceeds this value, the buffer is scheduled for write to the underlying store.
+     * <p/>
+     * If this value is {@code 0}, then flush is performed only on time-elapsing basis. However,
+     * when this value is {@code 0}, the cache critical size is set to
+     * {@link CacheConfiguration#DFLT_WRITE_BEHIND_CRITICAL_SIZE}
+     *
+     * @return Buffer size that triggers flush procedure.
+     */
+    @IgniteMBeanDescription("Size of internal buffer that triggers flush procedure.")
+    public int getWriteBehindFlushSize();
+
+    /**
+     * Gets the number of flush threads that will perform store update operations.
+     *
+     * @return Count of worker threads.
+     */
+    @IgniteMBeanDescription("Count of flush threads.")
+    public int getWriteBehindFlushThreadCount();
+
+    /**
+     * Gets the cache flush frequency. All pending operations on the underlying store will be performed
+     * within time interval not less then this value.
+     * <p/>
+     * If this value is {@code 0}, then flush is performed only when buffer size exceeds flush size.
+     *
+     * @return Flush frequency in milliseconds.
+     */
+    @IgniteMBeanDescription("Flush frequency interval in milliseconds.")
+    public long getWriteBehindFlushFrequency();
+
+    /**
+     * Gets the maximum count of similar (put or remove) operations that can be grouped to a single batch.
+     *
+     * @return Maximum size of batch.
+     */
+    @IgniteMBeanDescription("Maximum size of batch for similar operations.")
+    public int getWriteBehindStoreBatchSize();
+
+    /**
+     * Gets count of write buffer overflow events since initialization. Each overflow event causes
+     * the ongoing flush operation to be performed synchronously.
+     *
+     * @return Count of cache overflow events since start.
+     */
+    @IgniteMBeanDescription("Count of cache overflow events since write-behind cache has started.")
+    public int getWriteBehindTotalCriticalOverflowCount();
+
+    /**
+     * Gets count of write buffer overflow events in progress at the moment. Each overflow event causes
+     * the ongoing flush operation to be performed synchronously.
+     *
+     * @return Count of cache overflow events since start.
+     */
+    @IgniteMBeanDescription("Count of cache overflow events since write-behind cache has started.")
+    public int getWriteBehindCriticalOverflowCount();
+
+    /**
+     * Gets count of cache entries that are in a store-retry state. An entry is assigned a store-retry state
+     * when underlying store failed due some reason and cache has enough space to retain this entry till
+     * the next try.
+     *
+     * @return Count of entries in store-retry state.
+     */
+    @IgniteMBeanDescription("Count of cache cache entries that are currently in retry state.")
+    public int getWriteBehindErrorRetryCount();
+
+    /**
+     * Gets count of entries that were processed by the write-behind store and have not been
+     * flushed to the underlying store yet.
+     *
+     * @return Total count of entries in cache store internal buffer.
+     */
+    @IgniteMBeanDescription("Count of cache entries that are waiting to be flushed.")
+    public int getWriteBehindBufferSize();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMemoryMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMemoryMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMemoryMode.java
new file mode 100644
index 0000000..b5d6371
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMemoryMode.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+/**
+ * Defines set of memory modes. Memory modes help control whether cache entries are
+ * stored on heap memory, offheap memory, or in swap space.
+ */
+public enum GridCacheMemoryMode {
+    /**
+     * Entries will be stored on-heap first. The onheap tiered storage works as follows:
+     * <nl>
+     * <li>Entries are cached on heap memory first.</li>
+     * <li>
+     *     If offheap memory is enabled and eviction policy evicts an entry from heap memory, entry will
+     *     be moved to offheap memory. If offheap memory is disabled, then entry is simply discarded.
+     * </li>
+     * <li>
+     *     If swap space is enabled and offheap memory fills up, then entry will be evicted into swap space.
+     *     If swap space is disabled, then entry will be discarded. If swap is enabled and offheap memory
+     *     is disabled, then entry will be evicted directly from heap memory into swap.
+     * </li>
+     * </nl>
+     * <p>
+     * <b>Note</b> that heap memory evictions are handled by configured {@link org.apache.ignite.cache.eviction.GridCacheEvictionPolicy}
+     * implementation. By default, no eviction policy is enabled, so entries never leave heap
+     * memory space unless explicitly removed.
+     */
+    ONHEAP_TIERED,
+
+    /**
+     * Works the same as {@link #ONHEAP_TIERED}, except that entries never end up in heap memory and get
+     * stored in offheap memory right away. Entries get cached in offheap memory first and then
+     * get evicted to swap, if one is configured.
+     */
+    OFFHEAP_TIERED,
+
+    /**
+     * Entry keys will be stored on heap memory, and values will be stored in offheap memory. Note
+     * that in this mode entries can be evicted only to swap. The evictions will happen according
+     * to configured {@link org.apache.ignite.cache.eviction.GridCacheEvictionPolicy}.
+     */
+    OFFHEAP_VALUES,
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMetrics.java
new file mode 100644
index 0000000..8a3235c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMetrics.java
@@ -0,0 +1,103 @@
+/*
+ * 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 java.io.*;
+
+/**
+ * Cache metrics used to obtain statistics on cache itself.
+ * Use {@link GridCache#metrics()} to obtain metrics for a cache.
+ */
+public interface GridCacheMetrics extends Serializable {
+    /**
+     * Gets create time of the owning entity (either cache or entry).
+     *
+     * @return Create time.
+     */
+    public long createTime();
+
+    /**
+     * Gets last write time of the owning entity (either cache or entry).
+     *
+     * @return Last write time.
+     */
+    public long writeTime();
+
+    /**
+     * Gets last read time of the owning entity (either cache or entry).
+     *
+     * @return Last read time.
+     */
+    public long readTime();
+
+    /**
+     * Gets last time transaction was committed.
+     *
+     * @return Last commit time.
+     */
+    public long commitTime();
+
+    /**
+     * Gets last time transaction was rollback.
+     *
+     * @return Last rollback time.
+     */
+    public long rollbackTime();
+
+    /**
+     * Gets total number of reads of the owning entity (either cache or entry).
+     *
+     * @return Total number of reads.
+     */
+    public int reads();
+
+    /**
+     * Gets total number of writes of the owning entity (either cache or entry).
+     *
+     * @return Total number of writes.
+     */
+    public int writes();
+
+    /**
+     * Gets total number of hits for the owning entity (either cache or entry).
+     *
+     * @return Number of hits.
+     */
+    public int hits();
+
+    /**
+     * Gets total number of misses for the owning entity (either cache or entry).
+     *
+     * @return Number of misses.
+     */
+    public int misses();
+
+    /**
+     * Gets total number of transaction commits.
+     *
+     * @return Number of transaction commits.
+     */
+    public int txCommits();
+
+    /**
+     * Gets total number of transaction rollbacks.
+     *
+     * @return Number of transaction rollbacks.
+     */
+    public int txRollbacks();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMode.java
new file mode 100644
index 0000000..128d0e8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheMode.java
@@ -0,0 +1,75 @@
+/*
+ * 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.cache.*;
+import org.gridgain.grid.cache.affinity.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Enumeration of all supported caching modes. Cache mode is specified in {@link CacheConfiguration}
+ * and cannot be changed after cache has started.
+ */
+public enum GridCacheMode {
+    /**
+     * Specifies local-only cache behaviour. In this mode caches residing on
+     * different grid nodes will not know about each other.
+     * <p>
+     * Other than distribution, {@code local} caches still have all
+     * the caching features, such as eviction, expiration, swapping,
+     * querying, etc... This mode is very useful when caching read-only data
+     * or data that automatically expires at a certain interval and
+     * then automatically reloaded from persistence store.
+     */
+    LOCAL,
+
+    /**
+     * Specifies fully replicated cache behavior. In this mode all the keys are distributed
+     * to all participating nodes. User still has affinity control
+     * over subset of nodes for any given key via {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction}
+     * configuration.
+     */
+    REPLICATED,
+
+    /**
+     * Specifies partitioned cache behaviour. In this mode the overall
+     * key set will be divided into partitions and all partitions will be split
+     * equally between participating nodes. User has affinity
+     * control over key assignment via {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction}
+     * configuration.
+     * <p>
+     * Note that partitioned cache is always fronted by local
+     * {@code 'near'} cache which stores most recent data. You
+     * can configure the size of near cache via {@link CacheConfiguration#getNearEvictionPolicy()}
+     * configuration property.
+     */
+    PARTITIONED;
+
+    /** Enumerated values. */
+    private static final GridCacheMode[] 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 GridCacheMode fromOrdinal(int ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCacheName.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCacheName.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheName.java
new file mode 100644
index 0000000..24068ee
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCacheName.java
@@ -0,0 +1,43 @@
+/*
+ * 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.gridgain.grid.cache.affinity.*;
+
+import java.lang.annotation.*;
+import java.util.concurrent.*;
+
+/**
+ * Allows to specify cache name from grid computations. It is used to provide cache name
+ * for affinity routing of grid computations, such as {@link org.apache.ignite.compute.ComputeJob}, {@link Runnable},
+ * {@link Callable}, or {@link org.apache.ignite.lang.IgniteClosure}. It should be used only in conjunction with
+ * {@link org.apache.ignite.cache.affinity.GridCacheAffinityKeyMapped @GridCacheAffinityKeyMapped} annotation, and should be attached to a method or field
+ * that provides cache name for the computation. Only one annotation per class
+ * is allowed. In the absence of this annotation, the default no-name cache
+ * will be used for providing key-to-node affinity.
+ * <p>
+ * Refer to {@link org.apache.ignite.cache.affinity.GridCacheAffinityKeyMapped @GridCacheAffinityKeyMapped} documentation for more information
+ * and examples about this annotation.
+ * @see org.apache.ignite.cache.affinity.GridCacheAffinityKeyMapped
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.METHOD})
+public @interface GridCacheName {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCachePartialUpdateException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCachePartialUpdateException.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePartialUpdateException.java
new file mode 100644
index 0000000..aa63677
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePartialUpdateException.java
@@ -0,0 +1,64 @@
+/*
+ * 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 java.util.*;
+
+/**
+ * Exception thrown from non-transactional cache in case when update succeeded only partially.
+ * One can get list of keys for which update failed with method {@link #failedKeys()}.
+ */
+public class GridCachePartialUpdateException extends IgniteCheckedException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Failed keys. */
+    private final Collection<Object> failedKeys = new ArrayList<>();
+
+    /**
+     * @param msg Error message.
+     */
+    public GridCachePartialUpdateException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Gets collection of failed keys.
+     * @return Collection of failed keys.
+     */
+    public <K> Collection<K> failedKeys() {
+        return (Collection<K>)failedKeys;
+    }
+
+    /**
+     * @param failedKeys Failed keys.
+     * @param err Error.
+     */
+    public void add(Collection<?> failedKeys, Throwable err) {
+        this.failedKeys.addAll(failedKeys);
+
+        addSuppressed(err);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getMessage() {
+        return super.getMessage() + ": " + failedKeys;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCachePeekMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCachePeekMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePeekMode.java
new file mode 100644
index 0000000..225669f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePeekMode.java
@@ -0,0 +1,85 @@
+/*
+ * 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.*;
+
+import java.util.*;
+
+/**
+ * Enumeration of all supported cache peek modes. Peek modes can be passed into various
+ * {@code 'GridCacheProjection.peek(..)'} and {@code GridCacheEntry.peek(..)} methods,
+ * such as {@link GridCacheProjection#peek(Object, Collection)},
+ * {@link GridCacheEntry#peek()}, and others.
+ * <p>
+ * The following modes are supported:
+ * <ul>
+ * <li>{@link #TX}</li>
+ * <li>{@link #GLOBAL}</li>
+ * <li>{@link #SMART}</li>
+ * <li>{@link #SWAP}</li>
+ * <li>{@link #DB}</li>
+ * </ul>
+ */
+public enum GridCachePeekMode {
+    /** Peeks value only from in-transaction memory of an ongoing transaction, if any. */
+    TX,
+
+    /** Peeks at cache global (not in-transaction) memory. */
+    GLOBAL,
+
+    /**
+     * In this mode value is peeked from in-transaction memory first using {@link #TX}
+     * mode and then, if it has not been found there, {@link #GLOBAL} mode is used to
+     * search in committed cached values.
+     */
+    SMART,
+
+    /** Peeks value only from off-heap or cache swap storage without loading swapped value into cache. */
+    SWAP,
+
+    /** Peek value from the underlying persistent storage without loading this value into cache. */
+    DB,
+
+    /**
+     * Peek value from near cache only (don't peek from partitioned cache).
+     * In case of {@link GridCacheMode#LOCAL} or {@link GridCacheMode#REPLICATED} cache,
+     * behaves as {@link #GLOBAL} mode.
+     */
+    NEAR_ONLY,
+
+    /**
+     * Peek value from partitioned cache only (skip near cache).
+     * In case of {@link GridCacheMode#LOCAL} or {@link GridCacheMode#REPLICATED} cache,
+     * behaves as {@link #GLOBAL} mode.
+     */
+    PARTITIONED_ONLY;
+
+    /** Enumerated values. */
+    private static final GridCachePeekMode[] 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 GridCachePeekMode fromOrdinal(byte ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/GridCachePreloadMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCachePreloadMode.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePreloadMode.java
new file mode 100644
index 0000000..ea596e6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCachePreloadMode.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.apache.ignite.cache.*;
+import org.gridgain.grid.cache.affinity.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Cache preload mode. When preloading is enabled (i.e. has value other than {@link #NONE}), distributed caches
+ * will attempt to preload all necessary values from other grid nodes. This enumeration is used to configure
+ * preloading via {@link CacheConfiguration#getPreloadMode()} configuration property. If not configured
+ * explicitly, then {@link CacheConfiguration#DFLT_PRELOAD_MODE} is used.
+ * <p>
+ * Replicated caches will try to load the full set of cache entries from other nodes (or as defined by
+ * pluggable {@link org.apache.ignite.cache.affinity.GridCacheAffinityFunction}), while partitioned caches will only load the entries for which
+ * current node is primary or back up.
+ * <p>
+ * Note that preload mode only makes sense for {@link GridCacheMode#REPLICATED} and {@link GridCacheMode#PARTITIONED}
+ * caches. Caches with {@link GridCacheMode#LOCAL} mode are local by definition and therefore cannot preload
+ * any values from neighboring nodes.
+ */
+public enum GridCachePreloadMode {
+    /**
+     * Synchronous preload mode. Distributed caches will not start until all necessary data
+     * is loaded from other available grid nodes.
+     */
+    SYNC,
+
+    /**
+     * Asynchronous preload mode. Distributed caches will start immediately and will load all necessary
+     * data from other available grid nodes in the background.
+     */
+    ASYNC,
+
+    /**
+     * In this mode no preloading will take place which means that caches will be either loaded on
+     * demand from persistent store whenever data is accessed, or will be populated explicitly.
+     */
+    NONE;
+
+    /** Enumerated values. */
+    private static final GridCachePreloadMode[] 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 GridCachePreloadMode fromOrdinal(int ord) {
+        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+    }
+}


Mime
View raw message