Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-23901 Add operation time performance statistics for putAllConflict, removeAllConflict #11793

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1969,8 +1969,9 @@ protected boolean put0(final K key, final V val, final CacheEntryPredicate filte
return;

final boolean statsEnabled = ctx.statisticsEnabled();
final boolean perfStatsEnabled = ctx.kernalContext().performanceStatistics().enabled();

long start = statsEnabled ? System.nanoTime() : 0L;
final long start = (statsEnabled || perfStatsEnabled) ? System.nanoTime() : 0L;

ctx.dr().onReceiveCacheEntriesReceived(drMap.size());

Expand All @@ -1986,6 +1987,9 @@ protected boolean put0(final K key, final V val, final CacheEntryPredicate filte

if (statsEnabled)
metrics0().addPutAllConflictTimeNanos(System.nanoTime() - start);

if (perfStatsEnabled)
writeStatistics(OperationType.CACHE_PUT_ALL_CONFLICT, start);
}

/** {@inheritDoc} */
Expand All @@ -1995,8 +1999,9 @@ protected boolean put0(final K key, final V val, final CacheEntryPredicate filte
return new GridFinishedFuture<Object>();

final boolean statsEnabled = ctx.statisticsEnabled();
final boolean perfStatsEnabled = ctx.kernalContext().performanceStatistics().enabled();

long start = statsEnabled ? System.nanoTime() : 0L;
final long start = (statsEnabled || perfStatsEnabled) ? System.nanoTime() : 0L;

ctx.dr().onReceiveCacheEntriesReceived(drMap.size());

Expand All @@ -2013,6 +2018,9 @@ protected boolean put0(final K key, final V val, final CacheEntryPredicate filte
if (statsEnabled)
fut.listen(new UpdatePutAllConflictTimeStatClosure<>(metrics0(), start));

if (perfStatsEnabled)
fut.listen(() -> writeStatistics(OperationType.CACHE_PUT_ALL_CONFLICT, start));

return fut;
}

Expand Down Expand Up @@ -2838,9 +2846,10 @@ protected IgniteInternalFuture<Boolean> removeAsync0(final K key, @Nullable fina
if (F.isEmpty(drMap))
return;

boolean statsEnabled = ctx.statisticsEnabled();
final boolean statsEnabled = ctx.statisticsEnabled();
final boolean perfStatsEnabled = ctx.kernalContext().performanceStatistics().enabled();

long start = statsEnabled ? System.nanoTime() : 0L;
final long start = (statsEnabled || perfStatsEnabled) ? System.nanoTime() : 0L;

ctx.dr().onReceiveCacheEntriesReceived(drMap.size());

Expand All @@ -2856,6 +2865,9 @@ protected IgniteInternalFuture<Boolean> removeAsync0(final K key, @Nullable fina

if (statsEnabled)
metrics0().addRemoveAllConflictTimeNanos(System.nanoTime() - start);

if (perfStatsEnabled)
writeStatistics(OperationType.CACHE_REMOVE_ALL_CONFLICT, start);
}

/** {@inheritDoc} */
Expand All @@ -2865,8 +2877,9 @@ protected IgniteInternalFuture<Boolean> removeAsync0(final K key, @Nullable fina
return new GridFinishedFuture<Object>();

final boolean statsEnabled = ctx.statisticsEnabled();
final boolean perfStatsEnabled = ctx.kernalContext().performanceStatistics().enabled();

final long start = statsEnabled ? System.nanoTime() : 0L;
final long start = (statsEnabled || perfStatsEnabled) ? System.nanoTime() : 0L;

ctx.dr().onReceiveCacheEntriesReceived(drMap.size());

Expand All @@ -2883,6 +2896,9 @@ protected IgniteInternalFuture<Boolean> removeAsync0(final K key, @Nullable fina
if (statsEnabled)
fut.listen(new UpdateRemoveAllConflictTimeStatClosure<>(metrics0(), start));

if (perfStatsEnabled)
fut.listen(() -> writeStatistics(OperationType.CACHE_REMOVE_ALL_CONFLICT, start));

return fut;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ public enum OperationType {
QUERY_ROWS(20),

/** Custom query property. */
QUERY_PROPERTY(21);
QUERY_PROPERTY(21),

/** Cache put all conflict. */
CACHE_PUT_ALL_CONFLICT(22),

/** Cache remove all conflict. */
CACHE_REMOVE_ALL_CONFLICT(23);

/** Cache operations. */
public static final EnumSet<OperationType> CACHE_OPS = EnumSet.of(CACHE_GET, CACHE_PUT, CACHE_REMOVE,
CACHE_GET_AND_PUT, CACHE_GET_AND_REMOVE, CACHE_INVOKE, CACHE_LOCK, CACHE_GET_ALL, CACHE_PUT_ALL,
CACHE_REMOVE_ALL, CACHE_INVOKE_ALL);
CACHE_REMOVE_ALL, CACHE_INVOKE_ALL, CACHE_PUT_ALL_CONFLICT, CACHE_REMOVE_ALL_CONFLICT);

/** Transaction operations. */
public static final EnumSet<OperationType> TX_OPS = EnumSet.of(TX_COMMIT, TX_ROLLBACK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import org.apache.ignite.Ignition;
Expand All @@ -33,9 +34,12 @@
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.ThinClientConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.client.thin.TcpClientCache;
import org.apache.ignite.internal.client.thin.TestTask;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.GridIntList;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
Expand All @@ -47,8 +51,10 @@
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_GET_AND_REMOVE;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_PUT;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_PUT_ALL;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_PUT_ALL_CONFLICT;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_REMOVE;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_REMOVE_ALL;
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_REMOVE_ALL_CONFLICT;

/**
* Tests thin client performance statistics.
Expand Down Expand Up @@ -171,6 +177,68 @@ public void testCacheOperation() throws Exception {
checkCacheOperation(CACHE_GET_AND_REMOVE, cache -> cache.getAndRemove(5));
}

/**
* Cache {@link TcpClientCache#putAllConflict} operation performed.
* @throws Exception If failed.
*/
@Test
public void testCachePutAllConflict() throws Exception {
maksaska marked this conversation as resolved.
Show resolved Hide resolved
checkCacheAllConflictOperations(CACHE_PUT_ALL_CONFLICT, false);
}

/**
* Cache {@link TcpClientCache#removeAllConflict} operation performed.
* @throws Exception If failed.
*/
@Test
public void testCacheRemoveAllConflict() throws Exception {
checkCacheAllConflictOperations(CACHE_REMOVE_ALL_CONFLICT, false);
}

/**
* Cache {@link TcpClientCache#putAllConflictAsync} operation performed.
* @throws Exception If failed.
*/
@Test
public void testCachePutAllConflictAsync() throws Exception {
checkCacheAllConflictOperations(CACHE_PUT_ALL_CONFLICT, true);
}

/**
* Cache {@link TcpClientCache#removeAllConflictAsync} operation performed.
* @throws Exception If failed.
*/
@Test
public void testCacheRemoveAllConflictAsync() throws Exception {
checkCacheAllConflictOperations(CACHE_REMOVE_ALL_CONFLICT, true);
}

/**
* @param opType {@link OperationType} cache operation type.
* @param isAsync boolean flag for asynchronous cache operation processing.
maksaska marked this conversation as resolved.
Show resolved Hide resolved
*/
private void checkCacheAllConflictOperations(OperationType opType, boolean isAsync) throws Exception {
GridCacheVersion confl = new GridCacheVersion(1, 0, 1, (byte)2);

checkCacheOperation(opType, cache -> {
TcpClientCache<Object, Object> clientCache = (TcpClientCache<Object, Object>)cache;

try {
if (opType == CACHE_PUT_ALL_CONFLICT && !isAsync)
clientCache.putAllConflict(F.asMap(6, new T3<>(1, confl, CU.EXPIRE_TIME_ETERNAL)));
else if (opType == CACHE_REMOVE_ALL_CONFLICT && !isAsync)
clientCache.removeAllConflict(F.asMap(6, confl));
else if (opType == CACHE_PUT_ALL_CONFLICT)
clientCache.putAllConflictAsync(F.asMap(7, new T3<>(2, confl, CU.EXPIRE_TIME_ETERNAL))).get();
else if (opType == CACHE_REMOVE_ALL_CONFLICT)
clientCache.removeAllConflictAsync(F.asMap(7, confl)).get();
}
catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
});
}
maksaska marked this conversation as resolved.
Show resolved Hide resolved

/** Checks cache operation. */
private void checkCacheOperation(OperationType op, Consumer<ClientCache<Object, Object>> clo) throws Exception {
long startTime = U.currentTimeMillis();
Expand Down