Skip to content

Commit

Permalink
#ignite-683: Rename replace methods in GridCacheAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivasilinets committed Apr 13, 2015
1 parent dd5705c commit c1418f8
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 104 deletions.
Expand Up @@ -21,7 +21,6 @@
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.*; import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cache.store.*; import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*; import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.transactions.*;
Expand All @@ -32,7 +31,6 @@
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.Date; import java.util.Date;
import java.util.concurrent.*;


/** /**
* This interface provides a rich API for working with distributed caches. It includes the following * This interface provides a rich API for working with distributed caches. It includes the following
Expand Down Expand Up @@ -603,7 +601,7 @@ public boolean putx(K key, V val)
* from the underlying persistent storage. If value has to be loaded from persistent * from the underlying persistent storage. If value has to be loaded from persistent
* storage, <code>CacheStore#load(Transaction, Object)</code> method will be used. * storage, <code>CacheStore#load(Transaction, Object)</code> method will be used.
* <p> * <p>
* If the returned value is not needed, method {@link #replacex(Object, Object)} should * If the returned value is not needed, method {@link #replace(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the * always be used instead of this one to avoid the overhead associated with returning of the
* previous value. * previous value.
* <p> * <p>
Expand All @@ -619,7 +617,7 @@ public boolean putx(K key, V val)
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
* @throws IgniteCheckedException If replace operation failed. * @throws IgniteCheckedException If replace operation failed.
*/ */
@Nullable public V replace(K key, V val) throws IgniteCheckedException; @Nullable public V getAndReplace(K key, V val) throws IgniteCheckedException;


/** /**
* Asynchronously stores given key-value pair in cache only if there is a previous mapping for it. If cache * Asynchronously stores given key-value pair in cache only if there is a previous mapping for it. If cache
Expand All @@ -629,7 +627,7 @@ public boolean putx(K key, V val)
* from the underlying persistent storage. If value has to be loaded from persistent * from the underlying persistent storage. If value has to be loaded from persistent
* storage, <code>CacheStore#load(Transaction, Object)</code> method will be used. * storage, <code>CacheStore#load(Transaction, Object)</code> method will be used.
* <p> * <p>
* If the returned value is not needed, method {@link #replacex(Object, Object)} should * If the returned value is not needed, method {@link #replace(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the * always be used instead of this one to avoid the overhead associated with returning of the
* previous value. * previous value.
* <p> * <p>
Expand All @@ -644,13 +642,13 @@ public boolean putx(K key, V val)
* @return Future for replace operation. * @return Future for replace operation.
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
*/ */
public IgniteInternalFuture<V> replaceAsync(K key, V val); public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val);


/** /**
* Stores given key-value pair in cache only if only if there is a previous mapping for it. * Stores given key-value pair in cache only if only if there is a previous mapping for it.
* <p> * <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise. * This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* Unlike {@link #replace(Object, Object)} method, it does not return previous * Unlike {@link #getAndReplace(Object, Object)} method, it does not return previous
* value and, therefore, does not have any overhead associated with returning of a value. It * value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required. * should always be used whenever return value is not required.
* <p> * <p>
Expand All @@ -666,13 +664,13 @@ public boolean putx(K key, V val)
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
* @throws IgniteCheckedException If replace operation failed. * @throws IgniteCheckedException If replace operation failed.
*/ */
public boolean replacex(K key, V val) throws IgniteCheckedException; public boolean replace(K key, V val) throws IgniteCheckedException;


/** /**
* Asynchronously stores given key-value pair in cache only if only if there is a previous mapping for it. * Asynchronously stores given key-value pair in cache only if only if there is a previous mapping for it.
* <p> * <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise. * This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* Unlike {@link #replaceAsync(Object, Object)} method, it does not return previous * Unlike {@link #getAndReplaceAsync(Object, Object)} method, it does not return previous
* value and, therefore, does not have any overhead associated with returning of a value. It * value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required. * should always be used whenever return value is not required.
* <p> * <p>
Expand All @@ -687,7 +685,7 @@ public boolean putx(K key, V val)
* @return Future for the replace operation. * @return Future for the replace operation.
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
*/ */
public IgniteInternalFuture<Boolean> replacexAsync(K key, V val); public IgniteInternalFuture<Boolean> replaceAsync(K key, V val);


/** /**
* Stores given key-value pair in cache only if only if the previous value is equal to the * Stores given key-value pair in cache only if only if the previous value is equal to the
Expand All @@ -708,7 +706,7 @@ public boolean putx(K key, V val)
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
* @throws IgniteCheckedException If replace operation failed. * @throws IgniteCheckedException If replace operation failed.
*/ */
public boolean replace(K key, V oldVal, V newVal) throws IgniteCheckedException; public boolean getAndReplace(K key, V oldVal, V newVal) throws IgniteCheckedException;


/** /**
* Asynchronously stores given key-value pair in cache only if only if the previous value is equal to the * Asynchronously stores given key-value pair in cache only if only if the previous value is equal to the
Expand All @@ -728,7 +726,7 @@ public boolean putx(K key, V val)
* @return Future for the replace operation. * @return Future for the replace operation.
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
*/ */
public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal); public IgniteInternalFuture<Boolean> getAndReplaceAsync(K key, V oldVal, V newVal);


/** /**
* Stores given key-value pairs in cache. If filters are provided, then entries will * Stores given key-value pairs in cache. If filters are provided, then entries will
Expand Down
Expand Up @@ -2488,7 +2488,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Nullable @Override public V replace(final K key, final V val) throws IgniteCheckedException { @Nullable @Override public V getAndReplace(final K key, final V val) throws IgniteCheckedException {
A.notNull(key, "key", val, "val"); A.notNull(key, "key", val, "val");


if (keyCheck) if (keyCheck)
Expand All @@ -2508,7 +2508,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<V> replaceAsync(final K key, final V val) { @Override public IgniteInternalFuture<V> getAndReplaceAsync(final K key, final V val) {
final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final boolean statsEnabled = ctx.config().isStatisticsEnabled();


final long start = statsEnabled ? System.nanoTime() : 0L; final long start = statsEnabled ? System.nanoTime() : 0L;
Expand Down Expand Up @@ -2538,7 +2538,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replacex(final K key, final V val) throws IgniteCheckedException { @Override public boolean replace(final K key, final V val) throws IgniteCheckedException {
A.notNull(key, "key", val, "val"); A.notNull(key, "key", val, "val");


if (keyCheck) if (keyCheck)
Expand All @@ -2558,7 +2558,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replacexAsync(final K key, final V val) { @Override public IgniteInternalFuture<Boolean> replaceAsync(final K key, final V val) {
A.notNull(key, "key", val, "val"); A.notNull(key, "key", val, "val");


if (keyCheck) if (keyCheck)
Expand All @@ -2579,7 +2579,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replace(final K key, final V oldVal, final V newVal) throws IgniteCheckedException { @Override public boolean getAndReplace(final K key, final V oldVal, final V newVal) throws IgniteCheckedException {
A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal");


if (keyCheck) if (keyCheck)
Expand All @@ -2606,7 +2606,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replaceAsync(final K key, final V oldVal, final V newVal) { @Override public IgniteInternalFuture<Boolean> getAndReplaceAsync(final K key, final V oldVal, final V newVal) {
final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final boolean statsEnabled = ctx.config().isStatisticsEnabled();


final long start = statsEnabled ? System.nanoTime() : 0L; final long start = statsEnabled ? System.nanoTime() : 0L;
Expand Down Expand Up @@ -2944,7 +2944,7 @@ public IgniteInternalFuture<Boolean> removexAsync(final K key, @Nullable final C
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public GridCacheReturn replacex(final K key, final V oldVal, final V newVal) @Override public GridCacheReturn replace(final K key, final V oldVal, final V newVal)
throws IgniteCheckedException throws IgniteCheckedException
{ {
A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal");
Expand Down Expand Up @@ -3006,9 +3006,7 @@ public IgniteInternalFuture<Boolean> removexAsync(final K key, @Nullable final C
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<GridCacheReturn> replacexAsync(final K key, @Override public IgniteInternalFuture<GridCacheReturn> replaceAsync(final K key, final V oldVal, final V newVal)
final V oldVal,
final V newVal)
{ {
A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal");


Expand Down
Expand Up @@ -95,7 +95,7 @@ public IgniteInternalFuture<?> putAllConflictAsync(Map<KeyCacheObject, GridCache
* flag. * flag.
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
*/ */
public IgniteInternalFuture<GridCacheReturn> replacexAsync(K key, V oldVal, V newVal); public IgniteInternalFuture<GridCacheReturn> replaceAsync(K key, V oldVal, V newVal);


/** /**
* Stores given key-value pair in cache only if only if the previous value is equal to the * Stores given key-value pair in cache only if only if the previous value is equal to the
Expand All @@ -116,7 +116,7 @@ public IgniteInternalFuture<?> putAllConflictAsync(Map<KeyCacheObject, GridCache
* @throws NullPointerException If either key or value are {@code null}. * @throws NullPointerException If either key or value are {@code null}.
* @throws IgniteCheckedException If replace operation failed. * @throws IgniteCheckedException If replace operation failed.
*/ */
public GridCacheReturn replacex(K key, V oldVal, V newVal) throws IgniteCheckedException; public GridCacheReturn replace(K key, V oldVal, V newVal) throws IgniteCheckedException;


/** /**
* Removes given key mapping from cache if one exists and value is equal to the passed in value. * Removes given key mapping from cache if one exists and value is equal to the passed in value.
Expand Down
Expand Up @@ -403,32 +403,32 @@ public boolean deserializePortables() {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public V replace(K key, V val) throws IgniteCheckedException { @Override public V getAndReplace(K key, V val) throws IgniteCheckedException {
return replaceAsync(key, val).get(); return getAndReplaceAsync(key, val).get();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<V> replaceAsync(K key, V val) { @Override public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val) {
return cache.replaceAsync(key, val); return cache.getAndReplaceAsync(key, val);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replacex(K key, V val) throws IgniteCheckedException { @Override public boolean replace(K key, V val) throws IgniteCheckedException {
return replacexAsync(key, val).get(); return replaceAsync(key, val).get();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replacexAsync(K key, V val) { @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V val) {
return cache.replacexAsync(key, val); return cache.replaceAsync(key, val);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replace(K key, V oldVal, V newVal) throws IgniteCheckedException { @Override public boolean getAndReplace(K key, V oldVal, V newVal) throws IgniteCheckedException {
return replaceAsync(key, oldVal, newVal).get(); return getAndReplaceAsync(key, oldVal, newVal).get();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { @Override public IgniteInternalFuture<Boolean> getAndReplaceAsync(K key, V oldVal, V newVal) {
CacheEntryPredicate fltr = cctx.equalsValue(oldVal); CacheEntryPredicate fltr = cctx.equalsValue(oldVal);


return cache.putxAsync(key, newVal, fltr); return cache.putxAsync(key, newVal, fltr);
Expand Down Expand Up @@ -586,15 +586,15 @@ public boolean deserializePortables() {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<GridCacheReturn> replacexAsync(K key, V oldVal, V newVal) { @Override public IgniteInternalFuture<GridCacheReturn> replaceAsync(K key, V oldVal, V newVal) {
A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal");


return cache.replacexAsync(key, oldVal, newVal); return cache.replaceAsync(key, oldVal, newVal);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public GridCacheReturn replacex(K key, V oldVal, V newVal) throws IgniteCheckedException { @Override public GridCacheReturn replace(K key, V oldVal, V newVal) throws IgniteCheckedException {
return replacexAsync(key, oldVal, newVal).get(); return replaceAsync(key, oldVal, newVal).get();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down
Expand Up @@ -20,7 +20,6 @@
import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.*; import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*; import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.affinity.*; import org.apache.ignite.internal.processors.cache.affinity.*;
Expand All @@ -40,7 +39,6 @@
import javax.cache.processor.*; import javax.cache.processor.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*;


/** /**
* Cache proxy. * Cache proxy.
Expand Down Expand Up @@ -707,71 +705,71 @@ public GridCacheProjectionImpl<K, V> gateProjection() {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Nullable @Override public V replace(K key, V val) throws IgniteCheckedException { @Nullable @Override public V getAndReplace(K key, V val) throws IgniteCheckedException {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replace(key, val); return delegate.getAndReplace(key, val);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<V> replaceAsync(K key, V val) { @Override public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replaceAsync(key, val); return delegate.getAndReplaceAsync(key, val);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replacex(K key, V val) throws IgniteCheckedException { @Override public boolean replace(K key, V val) throws IgniteCheckedException {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replacex(key, val); return delegate.replace(key, val);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replacexAsync(K key, V val) { @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V val) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replacexAsync(key, val); return delegate.replaceAsync(key, val);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean replace(K key, V oldVal, V newVal) throws IgniteCheckedException { @Override public boolean getAndReplace(K key, V oldVal, V newVal) throws IgniteCheckedException {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replace(key, oldVal, newVal); return delegate.getAndReplace(key, oldVal, newVal);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { @Override public IgniteInternalFuture<Boolean> getAndReplaceAsync(K key, V oldVal, V newVal) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replaceAsync(key, oldVal, newVal); return delegate.getAndReplaceAsync(key, oldVal, newVal);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
Expand Down Expand Up @@ -1162,23 +1160,23 @@ public GridCacheProjectionImpl<K, V> gateProjection() {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public IgniteInternalFuture<GridCacheReturn> replacexAsync(K key, V oldVal, V newVal) { @Override public IgniteInternalFuture<GridCacheReturn> replaceAsync(K key, V oldVal, V newVal) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replacexAsync(key, oldVal, newVal); return delegate.replaceAsync(key, oldVal, newVal);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public GridCacheReturn replacex(K key, V oldVal, V newVal) throws IgniteCheckedException { @Override public GridCacheReturn replace(K key, V oldVal, V newVal) throws IgniteCheckedException {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return delegate.replacex(key, oldVal, newVal); return delegate.replace(key, oldVal, newVal);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
Expand Down

0 comments on commit c1418f8

Please sign in to comment.