Skip to content

Commit

Permalink
try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetmircik committed Apr 14, 2021
1 parent 60b8f32 commit d8adb32
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -21,6 +21,7 @@
import com.hazelcast.internal.eviction.ExpiredKey;
import com.hazelcast.internal.nearcache.impl.invalidation.InvalidationQueue;
import com.hazelcast.internal.serialization.Data;
import com.hazelcast.internal.util.ExceptionUtil;
import com.hazelcast.internal.util.MapUtil;
import com.hazelcast.logging.ILogger;
import com.hazelcast.map.impl.ExpirationTimeSetter;
Expand Down Expand Up @@ -258,12 +259,17 @@ public final void evictExpiredEntries(final int percentage, final long now, fina
// 2. Do scanning and evict expired keys.
int scannedCount = 0;
int expiredCount = 0;
long scanLoopStartNanos = System.nanoTime();
do {
scannedCount += findExpiredKeys(now, backup);
expiredCount += evictExpiredKeys(backup);
} while (scannedCount < maxScannableCount && getOrInitCachedIterator().hasNext()
&& (System.nanoTime() - scanLoopStartNanos) < expiredKeyScanTimeoutNanos);
try {
long scanLoopStartNanos = System.nanoTime();
do {
scannedCount += findExpiredKeys(now, backup);
expiredCount += evictExpiredKeys(backup);
} while (scannedCount < maxScannableCount && getOrInitCachedIterator().hasNext()
&& (System.nanoTime() - scanLoopStartNanos) < expiredKeyScanTimeoutNanos);
} catch (Exception e) {
BATCH_OF_EXPIRED.get().clear();
throw ExceptionUtil.rethrow(e);
}

// 3. Send expired keys to backups(only valid for max-idle-expiry)
tryToSendBackupExpiryOp();
Expand Down

0 comments on commit d8adb32

Please sign in to comment.