ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [08/24] incubator-ignite git commit: ignite-630 Fixed keys
Date Fri, 24 Jul 2015 10:36:20 GMT
ignite-630 Fixed keys


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

Branch: refs/heads/ignite-1139
Commit: 03439e255a5aa22cd4f6d5c9fab767a9fd883514
Parents: 060177c
Author: avinogradov <avinogradov@gridgain.com>
Authored: Tue May 12 17:13:27 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Tue May 12 17:13:27 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheEvictableEntryImpl.java          |  2 +-
 .../cache/GridCacheEvictionManager.java         |  2 +-
 .../store/GridCacheStoreManagerAdapter.java     |  2 +-
 .../util/lang/GridMetadataAwareAdapter.java     | 49 ++++++++++++++------
 .../cache/eviction/GridCacheMockEntry.java      |  2 +-
 .../lang/GridMetadataAwareAdapterSelfTest.java  | 24 +++++-----
 6 files changed, 53 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
index cd056a7..c624548 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
@@ -32,7 +32,7 @@ import java.util.*;
  */
 public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> {
     /** */
-    private static final int META_KEY = GridMetadataAwareAdapter.nextUniqueKey();
+    private static final int META_KEY = GridMetadataAwareAdapter.EntryKey.CACHE_EVICTABLE_ENTRY_KEY.key();
 
     /** Cached entry. */
     @GridToStringInclude

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 4550d10..446db67 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -64,7 +64,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
     private static final sun.misc.Unsafe unsafe = GridUnsafe.unsafe();
 
     /** Attribute name used to queue node in entry metadata. */
-    private static final int META_KEY = GridMetadataAwareAdapter.nextUniqueKey();
+    private static final int META_KEY = GridMetadataAwareAdapter.EntryKey.CACHE_EVICTION_MANAGER_KEY.key();
 
     /** Eviction policy. */
     private EvictionPolicy plc;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index b558347..53b515d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -44,7 +44,7 @@ import java.util.*;
 @SuppressWarnings({"AssignmentToCatchBlockParameter", "unchecked"})
 public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapter implements
CacheStoreManager {
     /** */
-    private static final int SES_ATTR = GridMetadataAwareAdapter.nextUniqueKey();
+    private static final int SES_ATTR = GridMetadataAwareAdapter.EntryKey.CACHE_STORE_MANAGER_KEY.key();
 
     /** */
     protected CacheStore<Object, Object> store;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridMetadataAwareAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridMetadataAwareAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridMetadataAwareAdapter.java
index 134cee9..917dbcc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridMetadataAwareAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridMetadataAwareAdapter.java
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.*;
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
 
 /**
  * Convenient adapter for working with metadata. <h2 class="header">Thread Safety</h2>
This class provides necessary
@@ -34,13 +33,46 @@ import java.util.concurrent.atomic.*;
  */
 @SuppressWarnings({"SynchronizeOnNonFinalField"})
 public class GridMetadataAwareAdapter {
+    /**
+     * Enum stored predefined keys.
+     */
+    public enum EntryKey {//keys sorted by usage rate, descending.
+        /** Predefined key. */
+        CACHE_EVICTABLE_ENTRY_KEY(0),
+
+        /** Predefined key. */
+        CACHE_MOCK_ENTRY_KEY(1),
+
+        /** Predefined key. */
+        CACHE_STORE_MANAGER_KEY(2),
+
+        /** Predefined key. */
+        CACHE_EVICTION_MANAGER_KEY(3);
+
+        /** key. */
+        private int key;
+
+        /**
+         * @param key key
+         */
+        EntryKey(int key) {
+            this.key = key;
+        }
+
+        /**
+         * Returns key.
+         *
+         * @return key.
+         */
+        public int key() {
+            return key;
+        }
+    }
+
     /** Attributes. */
     @GridToStringInclude
     private Object[] data = null;
 
-    /** UID key generator. */
-    private static final AtomicInteger keyGen = new AtomicInteger();
-
     /** Serializable mutex. */
     @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
     private GridMutex mux;
@@ -53,15 +85,6 @@ public class GridMetadataAwareAdapter {
     }
 
     /**
-     * Provides next UID.
-     *
-     * @return uid.
-     */
-    public static int nextUniqueKey() {
-        return keyGen.getAndIncrement();
-    }
-
-    /**
      * Copies all metadata from another instance.
      *
      * @param from Metadata aware instance to copy metadata from.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheMockEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheMockEntry.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheMockEntry.java
index 3b354ba..7b3d92b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheMockEntry.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheMockEntry.java
@@ -32,7 +32,7 @@ import java.util.*;
  */
 public class GridCacheMockEntry<K, V> extends GridMetadataAwareAdapter implements Cache.Entry<K,
V>, EvictableEntry<K, V> {
     /** */
-    private static final int META_KEY = GridMetadataAwareAdapter.nextUniqueKey();
+    private static final int META_KEY = EntryKey.CACHE_MOCK_ENTRY_KEY.key();
 
     /** */
     @GridToStringInclude

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03439e25/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java
index 981145d..5a4534d 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java
@@ -39,17 +39,19 @@ public class GridMetadataAwareAdapterSelfTest extends GridCommonAbstractTest
{
     public void test() {
         GridMetadataAwareAdapter ma = new GridMetadataAwareAdapter();
 
-        int attr1 = GridMetadataAwareAdapter.nextUniqueKey();
-        int attr2 = GridMetadataAwareAdapter.nextUniqueKey();
-        int attr3 = GridMetadataAwareAdapter.nextUniqueKey();
-        int attr4 = GridMetadataAwareAdapter.nextUniqueKey();
-        int attr156 = GridMetadataAwareAdapter.nextUniqueKey();
-        int k1 = GridMetadataAwareAdapter.nextUniqueKey();
-        int k2 = GridMetadataAwareAdapter.nextUniqueKey();
-        int k3 = GridMetadataAwareAdapter.nextUniqueKey();
-        int a1 = GridMetadataAwareAdapter.nextUniqueKey();
-        int a2 = GridMetadataAwareAdapter.nextUniqueKey();
-        int a3 = GridMetadataAwareAdapter.nextUniqueKey();
+        int cnt = 0;
+
+        int attr1 = cnt++;
+        int attr2 = cnt++;
+        int attr3 = cnt++;
+        int attr4 = cnt++;
+        int attr156 = cnt++;
+        int k1 = cnt++;
+        int k2 = cnt++;
+        int k3 = cnt++;
+        int a1 = cnt++;
+        int a2 = cnt++;
+        int a3 = cnt++;
 
         // addMeta(name, val).
         assert ma.addMeta(attr1, "val1") == null;


Mime
View raw message