ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [25/50] [abbrv] incubator-ignite git commit: # ignite-283: Some more simple refactoring.
Date Wed, 18 Feb 2015 19:43:15 GMT
# ignite-283: Some more simple refactoring.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3c4a85db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3c4a85db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3c4a85db

Branch: refs/heads/ignite-285
Commit: 3c4a85dbdddd245dedcbb41de4d0336eb7034048
Parents: 786690c
Author: vozerov <vozerov@gridgain.com>
Authored: Wed Feb 18 16:59:08 2015 +0300
Committer: vozerov <vozerov@gridgain.com>
Committed: Wed Feb 18 16:59:08 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  3 +-
 .../processors/cache/GridCacheContext.java      | 10 +++++
 .../GridDistributedTxRemoteAdapter.java         |  6 +--
 .../distributed/dht/GridDhtTxLocalAdapter.java  |  1 +
 .../distributed/dht/GridDhtTxPrepareFuture.java | 13 ++----
 .../near/GridNearTxPrepareFuture.java           |  5 +--
 .../cache/transactions/IgniteTxAdapter.java     |  5 +--
 .../cache/transactions/IgniteTxEntry.java       | 17 ++++----
 .../transactions/IgniteTxLocalAdapter.java      | 45 +++++---------------
 9 files changed, 42 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index cba8b1c..f269e1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3896,7 +3896,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
         GridCacheEntryEx<K, V> entry = entryEx(key, false);
 
         try {
-            entry.initialValue(val, null, ver, ttl, -1, false, topVer, replicate ? DR_LOAD
: DR_NONE);
+            entry.initialValue(val, null, ver, ttl, CU.EXPIRE_TIME_CALCULATE, false, topVer,
+                replicate ? DR_LOAD : DR_NONE);
         }
         catch (IgniteCheckedException e) {
             throw new IgniteException("Failed to put cache value: " + entry, e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index f80e3a5..060a825 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -338,6 +338,16 @@ public class GridCacheContext<K, V> implements Externalizable {
     }
 
     /**
+     * @param txEntry TX entry.
+     * @return Expiry policy for the given TX entry.
+     */
+    @Nullable public ExpiryPolicy expiryForTxEntry(IgniteTxEntry txEntry) {
+        ExpiryPolicy plc = txEntry.expiry();
+
+        return plc != null ? plc : expiryPlc;
+    }
+
+    /**
      * @param mgr Manager to add.
      * @return Added manager.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index a2cded9..1ae5778 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -345,7 +345,7 @@ public class GridDistributedTxRemoteAdapter<K, V> extends IgniteTxAdapter<K,
V>
             entry.explicitVersion(e.explicitVersion());
             entry.groupLockEntry(e.groupLockEntry());
 
-            // DR stuff.
+            // Conflict resolution stuff.
             entry.conflictVersion(e.conflictVersion());
             entry.conflictExpireTime(e.conflictExpireTime());
         }
@@ -529,7 +529,7 @@ public class GridDistributedTxRemoteAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                             if (drCtx.newEntry().dataCenterId() != cacheCtx.dataCenterId())
                                                 txEntry.conflictExpireTime(drCtx.expireTime());
                                             else
-                                                txEntry.conflictExpireTime(-1L);
+                                                txEntry.conflictExpireTime(CU.EXPIRE_TIME_CALCULATE);
                                         }
                                         else if (drCtx.isMerge()) {
                                             op = drRes.get1();
@@ -538,7 +538,7 @@ public class GridDistributedTxRemoteAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                             explicitVer = writeVersion();
 
                                             txEntry.ttl(drCtx.ttl());
-                                            txEntry.conflictExpireTime(-1L);
+                                            txEntry.conflictExpireTime(CU.EXPIRE_TIME_CALCULATE);
                                         }
                                     }
                                     else

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 6d04f4f..1c71f12 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -452,6 +452,7 @@ public abstract class GridDhtTxLocalAdapter<K, V> extends IgniteTxLocalAdapter<K
                 entry.ttl(e.ttl());
                 entry.filters(e.filters());
                 entry.expiry(e.expiry());
+
                 entry.conflictExpireTime(e.conflictExpireTime());
                 entry.conflictVersion(e.conflictVersion());
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 61a8e37..e3cdc6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -279,13 +279,11 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu
 
             GridCacheEntryEx<K, V> cached = txEntry.cached();
 
-            ExpiryPolicy expiry = txEntry.expiry();
-
-            if (expiry == null)
-                expiry = cacheCtx.expiry();
+            ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
 
             try {
-                if (txEntry.op() == CREATE || txEntry.op() == UPDATE && txEntry.conflictExpireTime()
== -1L) {
+                if ((txEntry.op() == CREATE || txEntry.op() == UPDATE) &&
+                    txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) {
                     if (expiry != null) {
                         Duration duration = cached.hasValue() ?
                             expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
@@ -994,10 +992,7 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu
 
         GridDhtCacheAdapter<K, V> dht = cacheCtx.isNear() ? cacheCtx.near().dht() :
cacheCtx.dht();
 
-        ExpiryPolicy expiry = entry.expiry();
-
-        if (expiry == null)
-            expiry = cacheCtx.expiry();
+        ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(entry);
 
         if (expiry != null && entry.op() == READ) {
             entry.op(NOOP);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
index a94ffba..18fda47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
@@ -983,10 +983,9 @@ public final class GridNearTxPrepareFuture<K, V> extends GridCompoundIdentityFut
 
                         txEntry.op(NOOP);
 
-                        ExpiryPolicy expiry = txEntry.expiry();
+                        assert txEntry.context() != null;
 
-                        if (expiry == null)
-                            expiry = txEntry.context().expiry();
+                        ExpiryPolicy expiry = txEntry.context().expiryForTxEntry(txEntry);
 
                         if (expiry != null)
                             txEntry.ttl(CU.toTtl(expiry.getExpiryForAccess()));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 62d4e3b..ab0b2a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1244,10 +1244,7 @@ public abstract class IgniteTxAdapter<K, V> extends GridMetadataAwareAdapter
                 GridCacheOperation op = modified ? (val == null ? DELETE : UPDATE) : NOOP;
 
                 if (op == NOOP) {
-                    ExpiryPolicy expiry = txEntry.expiry();
-
-                    if (expiry == null)
-                        expiry = cacheCtx.expiry();
+                    ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
 
                     if (expiry != null) {
                         long ttl = CU.toTtl(expiry.getExpiryForAccess());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 9470c49..cebaa16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -91,7 +91,10 @@ public class IgniteTxEntry<K, V> implements GridPeerDeployAware,
Externalizable,
     private long ttl;
 
     /** DR expire time (explicit) */
-    private long conflictExpireTime = -1L;
+    private long conflictExpireTime = CU.EXPIRE_TIME_CALCULATE;
+
+    /** Conflict version. */
+    private GridCacheVersion conflictVer;
 
     /** Explicit lock version if there is one. */
     @GridToStringInclude
@@ -135,9 +138,6 @@ public class IgniteTxEntry<K, V> implements GridPeerDeployAware,
Externalizable,
     /** Deployment enabled flag. */
     private boolean depEnabled;
 
-    /** Conflict version. */
-    private GridCacheVersion conflictVer;
-
     /** Expiry policy. */
     private ExpiryPolicy expiryPlc;
 
@@ -692,17 +692,17 @@ public class IgniteTxEntry<K, V> implements GridPeerDeployAware,
Externalizable,
     }
 
     /**
-     * @return DR version.
+     * @return Conflict version.
      */
     @Nullable public GridCacheVersion conflictVersion() {
         return conflictVer;
     }
 
     /**
-     * @param drVer DR version.
+     * @param conflictVer Conflict version.
      */
-    public void conflictVersion(@Nullable GridCacheVersion drVer) {
-        this.conflictVer = drVer;
+    public void conflictVersion(@Nullable GridCacheVersion conflictVer) {
+        this.conflictVer = conflictVer;
     }
 
     /**
@@ -1103,6 +1103,7 @@ public class IgniteTxEntry<K, V> implements GridPeerDeployAware,
Externalizable,
          * @throws IOException If failed.
          * @throws ClassNotFoundException If failed.
          */
+        @SuppressWarnings("unchecked")
         public void readFrom(ObjectInput in) throws IOException, ClassNotFoundException {
             hasWriteVal = in.readBoolean();
             valBytesSent = in.readBoolean();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c4a85db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index b2129cc..c8c00f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -724,11 +724,9 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                     if (cacheCtx.isNear()) {
                                         ((GridNearCacheEntry<K, V>)cached).recordDhtVersion(txEntry.dhtVersion());
 
-                                        if (txEntry.op() == CREATE || txEntry.op() == UPDATE
&& txEntry.conflictExpireTime() == -1L) {
-                                            ExpiryPolicy expiry = txEntry.expiry();
-
-                                            if (expiry == null)
-                                                expiry = cacheCtx.expiry();
+                                        if ((txEntry.op() == CREATE || txEntry.op() == UPDATE)
&&
+                                            txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE)
{
+                                            ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
 
                                             if (expiry != null) {
                                                 Duration duration = cached.hasValue() ?
@@ -747,11 +745,9 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                     GridCacheVersion explicitVer = txEntry.conflictVersion()
!= null ?
                                         txEntry.conflictVersion() : writeVersion();
 
-                                    if (op == CREATE || op == UPDATE && txEntry.conflictExpireTime()
== -1L) {
-                                        ExpiryPolicy expiry = txEntry.expiry();
-
-                                        if (expiry == null)
-                                            expiry = cacheCtx.expiry();
+                                    if ((op == CREATE || op == UPDATE) &&
+                                        txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE)
{
+                                        ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
 
                                         if (expiry != null) {
                                             Duration duration = cached.hasValue() ?
@@ -785,7 +781,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                             if (conflictCtx.newEntry().dataCenterId() !=
cctx.dataCenterId())
                                                 txEntry.conflictExpireTime(conflictCtx.expireTime());
                                             else
-                                                txEntry.conflictExpireTime(-1L);
+                                                txEntry.conflictExpireTime(CU.EXPIRE_TIME_CALCULATE);
                                         }
                                         else {
                                             assert conflictCtx.isMerge();
@@ -796,7 +792,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                             explicitVer = writeVersion();
 
                                             txEntry.ttl(conflictCtx.ttl());
-                                            txEntry.conflictExpireTime(-1L);
+                                            txEntry.conflictExpireTime(CU.EXPIRE_TIME_CALCULATE);
                                         }
                                     }
                                     else
@@ -892,10 +888,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                                             nearCached.innerReload();
                                     }
                                     else if (op == READ) {
-                                        ExpiryPolicy expiry = txEntry.expiry();
-
-                                        if (expiry == null)
-                                            expiry = cacheCtx.expiry();
+                                        ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry);
 
                                         if (expiry != null) {
                                             Duration duration = expiry.getExpiryForAccess();
@@ -2380,7 +2373,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
 
                     if (updateTtl) {
                         if (!read) {
-                            ExpiryPolicy expiryPlc = txEntry.expiry() != null ? txEntry.expiry()
: cacheCtx.expiry();
+                            ExpiryPolicy expiryPlc = cacheCtx.expiryForTxEntry(txEntry);
 
                             if (expiryPlc != null)
                                 txEntry.ttl(CU.toTtl(expiryPlc.getExpiryForAccess()));
@@ -3257,24 +3250,6 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
 
     /**
      * @param key Key.
-     * @param ttl Time to live.
-     * @return {@code true} if tx entry exists for this key, {@code false} otherwise.
-     */
-    public boolean entryTtl(IgniteTxKey<K> key, long ttl) {
-        assert key != null;
-
-        IgniteTxEntry<K, V> e = entry(key);
-
-        if (e != null) {
-            e.ttl(ttl);
-            e.conflictExpireTime(-1L);
-        }
-
-        return e != null;
-    }
-
-    /**
-     * @param key Key.
      * @param expiryPlc Expiry policy.
      */
     void entryExpiry(IgniteTxKey<K> key, @Nullable ExpiryPolicy expiryPlc) {


Mime
View raw message