ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [17/47] incubator-ignite git commit: #ignite-629: remove forced flags.
Date Tue, 31 Mar 2015 16:40:33 GMT
#ignite-629: remove forced flags.


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

Branch: refs/heads/ignite-598
Commit: 5d5e8a3beb4a37c0228132f3242981490cd2fbf2
Parents: 2062fec
Author: ivasilinets <vasilinetc.ira@gmail.com>
Authored: Sun Mar 29 23:49:08 2015 +0300
Committer: ivasilinets <vasilinetc.ira@gmail.com>
Committed: Sun Mar 29 23:49:08 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  2 +-
 .../cache/GridCacheConcurrentMap.java           | 19 +---
 .../processors/cache/GridCacheContext.java      | 96 +-------------------
 .../cache/GridCacheProjectionImpl.java          | 13 +--
 .../cache/GridCacheOffHeapSelfTest.java         |  2 +-
 5 files changed, 8 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5d5e8a3b/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 f836788..177b9b2 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
@@ -381,7 +381,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
     /** {@inheritDoc} */
     @Override public Set<CacheFlag> flags() {
-        return F.asSet(ctx.forcedFlags());
+        return new HashSet<>();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5d5e8a3b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
index e0b756a..51df644 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
@@ -1802,9 +1802,6 @@ public class GridCacheConcurrentMap {
         private GridCacheProjectionImpl prjPerCall;
 
         /** */
-        private CacheFlag[] forcedFlags;
-
-        /** */
         private boolean clone;
 
         /**
@@ -1827,7 +1824,6 @@ public class GridCacheConcurrentMap {
             ctx = map.ctx;
 
             prjPerCall = ctx.projectionPerCall();
-            forcedFlags = ctx.forcedFlags();
         }
 
         /** {@inheritDoc} */
@@ -1839,7 +1835,7 @@ public class GridCacheConcurrentMap {
          * @return Entry iterator.
          */
         Iterator<Cache.Entry<K, V>> entryIterator() {
-            return new EntryIterator<>(map, filter, ctx, prjPerCall, forcedFlags);
+            return new EntryIterator<>(map, filter, ctx, prjPerCall);
         }
 
         /**
@@ -1980,9 +1976,6 @@ public class GridCacheConcurrentMap {
         /** */
         private GridCacheProjectionImpl<K, V> prjPerCall;
 
-        /** */
-        private CacheFlag[] forcedFlags;
-
         /**
          * Empty constructor required for {@link Externalizable}.
          */
@@ -1995,19 +1988,16 @@ public class GridCacheConcurrentMap {
          * @param filter Entry filter.
          * @param ctx Cache context.
          * @param prjPerCall Projection per call.
-         * @param forcedFlags Forced flags.
          */
         EntryIterator(
             GridCacheConcurrentMap map,
             CacheEntryPredicate[] filter,
             GridCacheContext<K, V> ctx,
-            GridCacheProjectionImpl<K, V> prjPerCall,
-            CacheFlag[] forcedFlags) {
+            GridCacheProjectionImpl<K, V> prjPerCall) {
             it = new Iterator0<>(map, false, filter, -1, -1);
 
             this.ctx = ctx;
             this.prjPerCall = prjPerCall;
-            this.forcedFlags = forcedFlags;
         }
 
         /** {@inheritDoc} */
@@ -2021,14 +2011,11 @@ public class GridCacheConcurrentMap {
 
             ctx.projectionPerCall(prjPerCall);
 
-            CacheFlag[] oldFlags = ctx.forceFlags(forcedFlags);
-
             try {
                 return it.next().wrapLazyValue();
             }
             finally {
                 ctx.projectionPerCall(oldPrj);
-                ctx.forceFlags(oldFlags);
             }
         }
 
@@ -2042,7 +2029,6 @@ public class GridCacheConcurrentMap {
             out.writeObject(it);
             out.writeObject(ctx);
             out.writeObject(prjPerCall);
-            out.writeObject(forcedFlags);
         }
 
         /** {@inheritDoc} */
@@ -2051,7 +2037,6 @@ public class GridCacheConcurrentMap {
             it = (Iterator0<K, V>)in.readObject();
             ctx = (GridCacheContext<K, V>)in.readObject();
             prjPerCall = (GridCacheProjectionImpl<K, V>)in.readObject();
-            forcedFlags = (CacheFlag[])in.readObject();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5d5e8a3b/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 3ad156d..5e07337 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
@@ -153,9 +153,6 @@ public class GridCacheContext<K, V> implements Externalizable {
      */
     private ThreadLocal<GridCacheProjectionImpl<K, V>> prjPerCall = new ThreadLocal<>();
 
-    /** Thread local forced flags that affect any projection in the same thread. */
-    private ThreadLocal<CacheFlag[]> forcedFlags = new ThreadLocal<>();
-
     /** Cache name. */
     private String cacheName;
 
@@ -1178,30 +1175,6 @@ public class GridCacheContext<K, V> implements Externalizable
{
     }
 
     /**
-     * Force projection flags for the current thread. These flags will affect all
-     * projections (even without flags) used within the current thread.
-     *
-     * @param flags Flags to force.
-     * @return Forced flags that were set prior to method call.
-     */
-    @Nullable public CacheFlag[] forceFlags(@Nullable CacheFlag[] flags) {
-        CacheFlag[] oldFlags = forcedFlags.get();
-
-        forcedFlags.set(F.isEmpty(flags) ? null : flags);
-
-        return oldFlags;
-    }
-
-    /**
-     * Gets forced flags for current thread.
-     *
-     * @return Forced flags.
-     */
-    public CacheFlag[] forcedFlags() {
-        return forcedFlags.get();
-    }
-
-    /**
      * Clone cached object.
      *
      * @param obj Object to clone
@@ -1277,58 +1250,9 @@ public class GridCacheContext<K, V> implements Externalizable
{
 
         GridCacheProjectionImpl<K, V> prj = prjPerCall.get();
 
-        CacheFlag[] forced = forcedFlags.get();
-
-        return (prj != null && prj.flags().contains(flag)) || (forced != null &&
U.containsObjectArray(forced, flag));
+        return (prj != null && prj.flags().contains(flag));
     }
 
-    /**
-     * Checks whether any of the given flags is set.
-     *
-     * @param flags Flags to check.
-     * @return {@code true} if any of the given flags is set.
-     */
-    public boolean hasAnyFlags(CacheFlag[] flags) {
-        assert !F.isEmpty(flags);
-
-        if (nearContext())
-            return dht().near().context().hasAnyFlags(flags);
-
-        GridCacheProjectionImpl<K, V> prj = prjPerCall.get();
-
-        if (prj == null && F.isEmpty(forcedFlags.get()))
-            return false;
-
-        for (CacheFlag f : flags)
-            if (hasFlag(f))
-                return true;
-
-        return false;
-    }
-
-    /**
-     * Checks whether any of the given flags is set.
-     *
-     * @param flags Flags to check.
-     * @return {@code true} if any of the given flags is set.
-     */
-    public boolean hasAnyFlags(Collection<CacheFlag> flags) {
-        assert !F.isEmpty(flags);
-
-        if (nearContext())
-            return dht().near().context().hasAnyFlags(flags);
-
-        GridCacheProjectionImpl<K, V> prj = prjPerCall.get();
-
-        if (prj == null && F.isEmpty(forcedFlags.get()))
-            return false;
-
-        for (CacheFlag f : flags)
-            if (hasFlag(f))
-                return true;
-
-        return false;
-    }
 
     /**
      * @return {@code True} if need check near cache context.
@@ -1353,10 +1277,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
         // Have to get projection per call used by calling thread to use it in a new thread.
         final GridCacheProjectionImpl<K, V> prj = projectionPerCall();
 
-        // Get flags in the same thread.
-        final CacheFlag[] flags = forcedFlags();
-
-        if (prj == null && F.isEmpty(flags))
+        if (prj == null)
             return r;
 
         return new GPR() {
@@ -1365,15 +1286,11 @@ public class GridCacheContext<K, V> implements Externalizable
{
 
                 projectionPerCall(prj);
 
-                CacheFlag[] oldFlags = forceFlags(flags);
-
                 try {
                     r.run();
                 }
                 finally {
                     projectionPerCall(oldPrj);
-
-                    forceFlags(oldFlags);
                 }
             }
         };
@@ -1395,10 +1312,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
         // Have to get projection per call used by calling thread to use it in a new thread.
         final GridCacheProjectionImpl<K, V> prj = projectionPerCall();
 
-        // Get flags in the same thread.
-        final CacheFlag[] flags = forcedFlags();
-
-        if (prj == null && F.isEmpty(flags))
+        if (prj == null)
             return r;
 
         return new GPC<T>() {
@@ -1407,15 +1321,11 @@ public class GridCacheContext<K, V> implements Externalizable
{
 
                 projectionPerCall(prj);
 
-                CacheFlag[] oldFlags = forceFlags(flags);
-
                 try {
                     return r.call();
                 }
                 finally {
                     projectionPerCall(oldPrj);
-
-                    forceFlags(oldFlags);
                 }
             }
         };

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5d5e8a3b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
index 4ab187d..051c532 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
@@ -783,18 +783,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public Set<CacheFlag> flags() {
-        CacheFlag[] forced = cctx.forcedFlags();
-
-        if (F.isEmpty(forced))
-            return flags;
-
-        // We don't expect too many flags, so default size is fine.
-        Set<CacheFlag> ret = new HashSet<>();
-
-        ret.addAll(flags);
-        ret.addAll(F.asList(forced));
-
-        return Collections.unmodifiableSet(ret);
+        return flags;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5d5e8a3b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
index 8b1c170..460a64c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
@@ -541,7 +541,7 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
             CacheValue val = CU.value(entry.rawGet(), entry.context(), false);
 
             assertNotNull("Value null for key: " + i, val);
-            assertEquals(entry.key().value(entry.context().cacheObjectContext(), false),
val.value());
+            assertEquals(entry.key().value(entry.context().cacheObjectContext(), false),
(Integer)val.value());
 
             assertEquals(entry.version(), versions.get(i));
         }


Mime
View raw message