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.affinity.*;
import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
Expand All @@ -32,7 +31,6 @@
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.util.concurrent.*;

/**
* 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
* storage, <code>CacheStore#load(Transaction, Object)</code> method will be used.
* <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
* previous value.
* <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 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
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
* storage, <code>CacheStore#load(Transaction, Object)</code> method will be used.
* <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
* previous value.
* <p>
Expand All @@ -644,13 +642,13 @@ public boolean putx(K key, V val)
* @return Future for replace operation.
* @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.
* <p>
* 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
* should always be used whenever return value is not required.
* <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 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.
* <p>
* 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
* should always be used whenever return value is not required.
* <p>
Expand All @@ -687,7 +685,7 @@ public boolean putx(K key, V val)
* @return Future for the replace operation.
* @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
Expand All @@ -708,7 +706,7 @@ public boolean putx(K key, V val)
* @throws NullPointerException If either key or value are {@code null}.
* @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
Expand All @@ -728,7 +726,7 @@ public boolean putx(K key, V val)
* @return Future for the replace operation.
* @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
Expand Down
Expand Up @@ -2488,7 +2488,7 @@ public IgniteInternalFuture<Boolean> putxAsync0(final K key, final V val,
}

/** {@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");

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

/** {@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 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} */
@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");

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

/** {@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");

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

/** {@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");

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

/** {@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 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} */
@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
{
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} */
@Override public IgniteInternalFuture<GridCacheReturn> replacexAsync(final K key,
final V oldVal,
final V newVal)
@Override public IgniteInternalFuture<GridCacheReturn> replaceAsync(final K key, final V oldVal, final V newVal)
{
A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal");

Expand Down
Expand Up @@ -95,7 +95,7 @@ public IgniteInternalFuture<?> putAllConflictAsync(Map<KeyCacheObject, GridCache
* flag.
* @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
Expand All @@ -116,7 +116,7 @@ public IgniteInternalFuture<?> putAllConflictAsync(Map<KeyCacheObject, GridCache
* @throws NullPointerException If either key or value are {@code null}.
* @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.
Expand Down
Expand Up @@ -403,32 +403,32 @@ public boolean deserializePortables() {
}

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

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

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

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

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

/** {@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);

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

/** {@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");

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

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

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

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

/** {@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);

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

0 comments on commit c1418f8

Please sign in to comment.