This is an automated email from the ASF dual-hosted git repository.
timoninmaxim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 42b3285bbbf IGNITE-22420 Fix expireTime setting for thin client
replication (#11376)
42b3285bbbf is described below
commit 42b3285bbbf1b7c423b380c4b30b8c77f7f64ddb
Author: Maksim Timonin <[email protected]>
AuthorDate: Thu Jun 13 09:01:19 2024 +0300
IGNITE-22420 Fix expireTime setting for thin client replication (#11376)
---
.../cache/ClientCachePutAllConflictRequest.java | 8 +---
.../client/thin/DataReplicationOperationsTest.java | 51 ++++++++++------------
2 files changed, 23 insertions(+), 36 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllConflictRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllConflictRequest.java
index ac3182b751b..ba133bbbadb 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllConflictRequest.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllConflictRequest.java
@@ -33,8 +33,6 @@ import
org.apache.ignite.internal.processors.platform.client.tx.ClientTxAwareReq
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
-import static
org.apache.ignite.internal.processors.cache.GridCacheUtils.EXPIRE_TIME_CALCULATE;
-import static
org.apache.ignite.internal.processors.cache.GridCacheUtils.TTL_NOT_CHANGED;
import static
org.apache.ignite.internal.processors.platform.utils.PlatformUtils.readCacheObject;
/**
@@ -53,8 +51,6 @@ public class ClientCachePutAllConflictRequest extends
ClientCacheDataRequest imp
public ClientCachePutAllConflictRequest(BinaryReaderExImpl reader,
ClientConnectionContext ctx) {
super(reader);
- boolean expPlc = cachex(ctx).configuration().getExpiryPolicyFactory()
!= null;
-
int cnt = reader.readInt();
map = new LinkedHashMap<>(cnt);
@@ -67,9 +63,7 @@ public class ClientCachePutAllConflictRequest extends
ClientCacheDataRequest imp
GridCacheDrInfo info = expireTime != CU.EXPIRE_TIME_ETERNAL ?
new GridCacheDrExpirationInfo(val, ver, CU.TTL_ETERNAL,
expireTime) :
- (expPlc
- ? new GridCacheDrExpirationInfo(val, ver, TTL_NOT_CHANGED,
EXPIRE_TIME_CALCULATE)
- : new GridCacheDrInfo(val, ver));
+ new GridCacheDrInfo(val, ver);
map.put(key, info);
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/DataReplicationOperationsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/DataReplicationOperationsTest.java
index c0c78101d9e..3405d3563be 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/DataReplicationOperationsTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/DataReplicationOperationsTest.java
@@ -27,7 +27,6 @@ import org.apache.ignite.client.ClientCacheConfiguration;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.client.Person;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import
org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.junit.Test;
@@ -139,33 +138,6 @@ public class DataReplicationOperationsTest extends
AbstractThinClientTest {
map.keySet().forEach(key -> assertFalse(cache.containsKey(key)));
}
- /** @throws Exception If fails. */
- @Test
- public void testWithExpiryPolicy() throws Exception {
- PlatformExpiryPolicy expPlc = new PlatformExpiryPolicy(TTL, TTL, TTL);
-
- ClientCacheConfiguration ccfgWithExpPlc = new
ClientCacheConfiguration()
- .setName("cache-with-expiry-policy")
- .setAtomicityMode(mode)
- .setExpiryPolicy(expPlc);
-
- TcpClientCache<Object, Object> cache = (TcpClientCache<Object,
Object>)client.getOrCreateCache(ccfgWithExpPlc);
-
- TcpClientCache<Object, Object> cacheWithExpPlc = binary ?
- (TcpClientCache<Object, Object>)cache.withKeepBinary() : cache;
-
- Map<Object, T3<Object, GridCacheVersion, Long>> data =
createPutAllData(CU.EXPIRE_TIME_ETERNAL);
-
- cacheWithExpPlc.putAllConflict(data);
-
- assertTrue(cacheWithExpPlc.containsKeys(data.keySet()));
-
- assertTrue(waitForCondition(
- () ->
data.keySet().stream().noneMatch(cacheWithExpPlc::containsKey),
- 2 * expPlc.getExpiryForCreation().getDurationAmount()
- ));
- }
-
/** @throws Exception If fails. */
@Test
public void testWithPerEntryExpiry() throws Exception {
@@ -184,11 +156,32 @@ public class DataReplicationOperationsTest extends
AbstractThinClientTest {
assertTrue(waitForCondition(() ->
data.keySet().stream().noneMatch(cache::containsKey), 2 * TTL));
}
+ /** */
+ @Test
+ public void testMixedExpiryTime() {
+ Map<Object, T3<Object, GridCacheVersion, Long>> put0 =
createPutAllData(System.currentTimeMillis() + TTL);
+ Map<Object, T3<Object, GridCacheVersion, Long>> put1 =
createPutAllData(KEYS_CNT, CU.EXPIRE_TIME_ETERNAL);
+
+ Map<Object, T3<Object, GridCacheVersion, Long>> drMap = new
HashMap<>();
+ drMap.putAll(put0);
+ drMap.putAll(put1);
+
+ cache.putAllConflict(drMap);
+
+ assertTrue(cache.containsKeys(put0.keySet()));
+ assertTrue(cache.containsKeys(put1.keySet()));
+ }
+
/** */
private Map<Object, T3<Object, GridCacheVersion, Long>>
createPutAllData(long expireTime) {
+ return createPutAllData(0, expireTime);
+ }
+
+ /** */
+ private Map<Object, T3<Object, GridCacheVersion, Long>>
createPutAllData(int startKey, long expireTime) {
Map<Object, T3<Object, GridCacheVersion, Long>> map = new HashMap<>();
- for (int i = 0; i < KEYS_CNT; i++) {
+ for (int i = startKey; i < startKey + KEYS_CNT; i++) {
Person key = new Person(i, "Person-" + i);
Person val = new Person(i, "Person-" + i);