ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [14/20] incubator-ignite git commit: ignite-630
Date Thu, 23 Jul 2015 16:04:47 GMT
ignite-630


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

Branch: refs/heads/master
Commit: fd541fc3b4bc69befdba07dc9cadc7015fb00873
Parents: 9b99371
Author: avinogradov <avinogradov@gridgain.com>
Authored: Thu May 14 19:04:47 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Thu May 14 19:04:47 2015 +0300

----------------------------------------------------------------------
 .../util/lang/GridMetadataAwareAdapter.java     | 70 +++++++-------------
 .../cache/eviction/GridCacheMockEntry.java      |  8 +--
 2 files changed, 27 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd541fc3/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 b28a4d9..a67f83d 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
@@ -17,10 +17,8 @@
 
 package org.apache.ignite.internal.util.lang;
 
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -38,16 +36,13 @@ public class GridMetadataAwareAdapter {
      */
     public enum EntryKey {//keys sorted by usage rate, descending.
         /** Predefined key. */
-        CACHE_EVICTABLE_ENTRY_KEY(0),
+        CACHE_STORE_MANAGER_KEY(0),
 
         /** Predefined key. */
-        CACHE_MOCK_ENTRY_KEY(1),
+        CACHE_EVICTABLE_ENTRY_KEY(1),
 
         /** Predefined key. */
-        CACHE_STORE_MANAGER_KEY(2),
-
-        /** Predefined key. */
-        CACHE_EVICTION_MANAGER_KEY(3);
+        CACHE_EVICTION_MANAGER_KEY(2);
 
         /** key. */
         private int key;
@@ -73,16 +68,6 @@ public class GridMetadataAwareAdapter {
     @GridToStringInclude
     private Object[] data = null;
 
-    /** Serializable mutex. */
-    private GridMutex mux;
-
-    /**
-     * Default constructor.
-     */
-    public GridMetadataAwareAdapter() {
-        mux = new GridMutex();
-    }
-
     /**
      * Copies all metadata from another instance.
      *
@@ -100,9 +85,9 @@ public class GridMetadataAwareAdapter {
      * @param data Map to copy metadata from.
      */
     public void copyMeta(Object[] data) {
-        A.notNull(data, "data");
+        assert data != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             if (this.data.length < data.length)
                 this.data = Arrays.copyOf(this.data, data.length);
 
@@ -123,9 +108,9 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     @Nullable public <V> V addMeta(int key, V val) {
-        A.notNull(key, "key", val, "val");
+        assert val != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             if (this.data == null)
                 this.data = new Object[key + 1];
             else if (this.data.length <= key)
@@ -148,9 +133,7 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     @Nullable public <V> V meta(int key) {
-        A.notNull(key, "key");
-
-        synchronized (mux) {
+        synchronized (this) {
             return data != null && data.length > key ? (V)data[key] : null;
         }
     }
@@ -164,9 +147,7 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     @Nullable public <V> V removeMeta(int key) {
-        A.notNull(key, "key");
-
-        synchronized (mux) {
+        synchronized (this) {
             if (data == null || data.length <= key)
                 return null;
 
@@ -188,9 +169,9 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     public <V> boolean removeMeta(int key, V val) {
-        A.notNull(key, "key", val, "val");
+        assert val != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             if (data == null || data.length <= key)
                 return false;
 
@@ -215,7 +196,7 @@ public class GridMetadataAwareAdapter {
     public <V> Object[] allMeta() {
         Object[] cp;
 
-        synchronized (mux) {
+        synchronized (this) {
             cp = Arrays.copyOf(data, data.length);
         }
 
@@ -226,7 +207,7 @@ public class GridMetadataAwareAdapter {
      * Removes all meta.
      */
     public void removeAllMeta() {
-        synchronized (mux) {
+        synchronized (this) {
             data = null;
         }
     }
@@ -248,8 +229,6 @@ public class GridMetadataAwareAdapter {
      * @return Whether or not given metadata is set.
      */
     public <V> boolean hasMeta(int key, V val) {
-        A.notNull(key, "key");
-
         Object v = meta(key);
 
         return v != null && v.equals(val);
@@ -265,9 +244,9 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     @Nullable public <V> V putMetaIfAbsent(int key, V val) {
-        A.notNull(key, "key", val, "val");
+        assert val != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             V v = (V)meta(key);
 
             if (v == null)
@@ -288,9 +267,9 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     public <V> V addMetaIfAbsent(int key, V val) {
-        A.notNull(key, "key", val, "val");
+        assert val != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             V v = (V)meta(key);
 
             if (v == null)
@@ -313,9 +292,9 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"unchecked"})
     @Nullable public <V> V addMetaIfAbsent(int key, @Nullable Callable<V> c)
{
-        A.notNull(key, "key", c, "c");
+        assert c != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             V v = (V)meta(key);
 
             if (v == null && c != null)
@@ -341,9 +320,10 @@ public class GridMetadataAwareAdapter {
      */
     @SuppressWarnings({"RedundantTypeArguments"})
     public <V> boolean replaceMeta(int key, V curVal, V newVal) {
-        A.notNull(key, "key", newVal, "newVal", curVal, "curVal");
+        assert newVal != null;
+        assert curVal != null;
 
-        synchronized (mux) {
+        synchronized (this) {
             if (hasMeta(key)) {
                 V val = this.<V>meta(key);
 
@@ -370,7 +350,7 @@ public class GridMetadataAwareAdapter {
         Object[] cp;
 
         // Avoid code warning (suppressing is bad here, because we need this warning for
other places).
-        synchronized (mux) {
+        synchronized (this) {
             cp = Arrays.copyOf(this.data, this.data.length);
         }
 
@@ -390,7 +370,7 @@ public class GridMetadataAwareAdapter {
     protected void readExternalMeta(ObjectInput in) throws IOException, ClassNotFoundException
{
         Object[] cp = (Object[])in.readObject();
 
-        synchronized (mux) {
+        synchronized (this) {
             this.data = cp;
         }
     }
@@ -401,8 +381,6 @@ public class GridMetadataAwareAdapter {
         try {
             GridMetadataAwareAdapter clone = (GridMetadataAwareAdapter)super.clone();
 
-            clone.mux = (GridMutex)mux.clone();
-
             clone.copyMeta(this);
 
             return clone;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd541fc3/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 2342ad0..989ad0a 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
@@ -25,13 +25,12 @@ import org.jetbrains.annotations.*;
 
 import javax.cache.*;
 
-
 /**
  * Mock cache entry.
  */
 public class GridCacheMockEntry<K, V> extends GridMetadataAwareAdapter implements Cache.Entry<K,
V>, EvictableEntry<K, V> {
     /** */
-    private static final int META_KEY = EntryKey.CACHE_MOCK_ENTRY_KEY.key();
+    private static final int META_KEY = EntryKey.values().length; //+1 to maximum value
 
     /** */
     @GridToStringInclude
@@ -82,7 +81,6 @@ public class GridCacheMockEntry<K, V> extends GridMetadataAwareAdapter
implement
     }
 
     /**
-     *
      * @return Evicted or not.
      */
     public boolean isEvicted() {
@@ -116,12 +114,12 @@ public class GridCacheMockEntry<K, V> extends GridMetadataAwareAdapter
implement
 
     /** {@inheritDoc} */
     @Override public <T> boolean replaceMeta(T curVal, T newVal) {
-        return replaceMeta(META_KEY,curVal, newVal);
+        return replaceMeta(META_KEY, curVal, newVal);
     }
 
     /** {@inheritDoc} */
     @Override public <T> T unwrap(Class<T> clazz) {
-        if(clazz.isAssignableFrom(getClass()))
+        if (clazz.isAssignableFrom(getClass()))
             return clazz.cast(this);
 
         throw new IllegalArgumentException();


Mime
View raw message