anton-vinogradov commented on code in PR #13447:
URL: https://github.com/apache/ignite/pull/13447#discussion_r3758589269
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java:
##########
@@ -64,58 +68,80 @@ public class GridCacheEntryInfo implements
SelfMarshallingMessage, CacheIdAware
/** Deleted flag. */
private boolean deleted;
- /** {@inheritDoc} */
- @Override public int cacheId() {
- return cacheId;
- }
-
/**
- * @param cacheId Cache ID.
+ * Empty constructor for serialization purposes. Initializes {@link
#initTime} to properly calculate {@link #expireTime()}
+ * if {@link #expireTimeDelta} and the expiration is effective. If no
expiration is set, initialization of {@link #initTime}
+ * is not required, but it is a tradeoff for absence of the message
serealization lifecycle awareness.
*/
- public void cacheId(int cacheId) {
+ public GridCacheEntryInfo() {
+ initTime = U.currentTimeMillis();
+ }
+
+ /** */
+ public GridCacheEntryInfo(
+ int cacheId,
+ KeyCacheObject key,
+ @Nullable CacheObject val,
+ GridCacheVersion ver,
+ long initTime,
+ long expireTime,
+ long ttl
+ ) {
+ assert expireTime >= 0;
+ assert initTime > 0;
+
+ this.initTime = initTime;
+
+ expireTimeDelta = expireTime - initTime;
+
+ // Timeouted mark.
Review Comment:
Timed out/Timeout?
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java:
##########
@@ -19,40 +19,44 @@
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.Order;
-import org.apache.ignite.internal.SelfMarshallingMessage;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.CacheIdAware;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.jetbrains.annotations.Nullable;
/**
* Entry information that gets passed over wire.
*/
-public class GridCacheEntryInfo implements SelfMarshallingMessage,
CacheIdAware {
+public class GridCacheEntryInfo implements CacheIdAware, Message {
/** */
private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int
*/ + 2 * 8 /* long */ + 32 /* version */;
Review Comment:
Please check correctness.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java:
##########
@@ -64,58 +68,80 @@ public class GridCacheEntryInfo implements
SelfMarshallingMessage, CacheIdAware
/** Deleted flag. */
private boolean deleted;
- /** {@inheritDoc} */
- @Override public int cacheId() {
- return cacheId;
- }
-
/**
- * @param cacheId Cache ID.
+ * Empty constructor for serialization purposes. Initializes {@link
#initTime} to properly calculate {@link #expireTime()}
+ * if {@link #expireTimeDelta} and the expiration is effective. If no
expiration is set, initialization of {@link #initTime}
+ * is not required, but it is a tradeoff for absence of the message
serealization lifecycle awareness.
*/
- public void cacheId(int cacheId) {
+ public GridCacheEntryInfo() {
+ initTime = U.currentTimeMillis();
+ }
+
+ /** */
+ public GridCacheEntryInfo(
+ int cacheId,
+ KeyCacheObject key,
+ @Nullable CacheObject val,
+ GridCacheVersion ver,
+ long initTime,
+ long expireTime,
+ long ttl
+ ) {
+ assert expireTime >= 0;
+ assert initTime > 0;
+
+ this.initTime = initTime;
+
+ expireTimeDelta = expireTime - initTime;
+
+ // Timeouted mark.
+ if (expireTimeDelta < 0)
+ expireTimeDelta = 0;
+
this.cacheId = cacheId;
+ this.key = key;
+ this.val = val;
+ this.ver = ver;
+ this.ttl = ttl;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int cacheId() {
+ return cacheId;
}
/**
* @param key Entry key.
*/
- public void key(KeyCacheObject key) {
+ public void key(@Nullable KeyCacheObject key) {
this.key = key;
}
/**
* @return Entry key.
*/
- public KeyCacheObject key() {
+ @Nullable public KeyCacheObject key() {
return key;
}
/**
* @return Entry value.
*/
- public CacheObject value() {
+ public @Nullable CacheObject value() {
return val;
}
/**
- * @param val Entry value.
- */
- public void value(CacheObject val) {
- this.val = val;
- }
-
- /**
- * @return Expire time.
+ * @return Expire time >= 0. 0 means no expiration is set.
*/
public long expireTime() {
- return expireTime;
- }
+ if (expireTimeDelta == -1L)
Review Comment:
Seems to be an impossible case, since -1 is an initial value replaced by
real?
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java:
##########
@@ -64,58 +68,80 @@ public class GridCacheEntryInfo implements
SelfMarshallingMessage, CacheIdAware
/** Deleted flag. */
private boolean deleted;
- /** {@inheritDoc} */
- @Override public int cacheId() {
- return cacheId;
- }
-
/**
- * @param cacheId Cache ID.
+ * Empty constructor for serialization purposes. Initializes {@link
#initTime} to properly calculate {@link #expireTime()}
+ * if {@link #expireTimeDelta} and the expiration is effective. If no
expiration is set, initialization of {@link #initTime}
+ * is not required, but it is a tradeoff for absence of the message
serealization lifecycle awareness.
*/
- public void cacheId(int cacheId) {
+ public GridCacheEntryInfo() {
+ initTime = U.currentTimeMillis();
+ }
+
+ /** */
+ public GridCacheEntryInfo(
+ int cacheId,
+ KeyCacheObject key,
+ @Nullable CacheObject val,
+ GridCacheVersion ver,
+ long initTime,
+ long expireTime,
+ long ttl
+ ) {
+ assert expireTime >= 0;
+ assert initTime > 0;
+
+ this.initTime = initTime;
+
+ expireTimeDelta = expireTime - initTime;
Review Comment:
Incorrect logic for expireTime == 0 (CU.EXPIRE_TIME_ETERNAL) will cause a
timeout for such entries.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]