ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: IGNITE-36 Removed GridMetadataAware interface.
Date Fri, 19 Dec 2014 14:10:22 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-36 [created] 1bbd19c93


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/core/src/main/java/org/gridgain/grid/util/lang/GridMetadataAwareAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/util/lang/GridMetadataAwareAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/util/lang/GridMetadataAwareAdapter.java
index 6bbbf92..6328f4f 100644
--- a/modules/core/src/main/java/org/gridgain/grid/util/lang/GridMetadataAwareAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/util/lang/GridMetadataAwareAdapter.java
@@ -9,7 +9,6 @@
 
 package org.gridgain.grid.util.lang;
 
-import org.gridgain.grid.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.grid.util.typedef.internal.*;
 import org.gridgain.grid.util.*;
@@ -20,12 +19,12 @@ import java.util.*;
 import java.util.concurrent.*;
 
 /**
- * Convenient adapter for {@link GridMetadataAware}.
+ * Convenient adapter for working with metadata.
  * <h2 class="header">Thread Safety</h2>
  * This class provides necessary synchronization for thread-safe access.
  */
 @SuppressWarnings( {"SynchronizeOnNonFinalField"})
-public class GridMetadataAwareAdapter implements GridMetadataAware {
+public class GridMetadataAwareAdapter {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -72,8 +71,12 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
             return false;
     }
 
-    /** {@inheritDoc} */
-    @Override public void copyMeta(GridMetadataAware from) {
+    /**
+     * Copies all metadata from another instance.
+     *
+     * @param from Metadata aware instance to copy metadata from.
+     */
+    public void copyMeta(GridMetadataAwareAdapter from) {
         A.notNull(from, "from");
 
         synchronized (mux) {
@@ -85,8 +88,12 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public void copyMeta(Map<String, ?> data) {
+    /**
+     * Copies all metadata from given map.
+     *
+     * @param data Map to copy metadata from.
+     */
+    public void copyMeta(Map<String, ?> data) {
         A.notNull(data, "data");
 
         synchronized (mux) {
@@ -96,9 +103,17 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Adds a new metadata.
+     *
+     * @param name Metadata name.
+     * @param val Metadata value.
+     * @param <V> Type of the value.
+     * @return Metadata previously associated with given name, or
+     *      {@code null} if there was none.
+     */
     @SuppressWarnings({"unchecked"})
-    @Nullable @Override public <V> V addMeta(String name, V val) {
+    @Nullable public <V> V addMeta(String name, V val) {
         A.notNull(name, "name", val, "val");
 
         synchronized (mux) {
@@ -108,9 +123,15 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Gets metadata by name.
+     *
+     * @param name Metadata name.
+     * @param <V> Type of the value.
+     * @return Metadata value or {@code null}.
+     */
     @SuppressWarnings({"unchecked"})
-    @Nullable @Override public <V> V meta(String name) {
+    @Nullable public <V> V meta(String name) {
         A.notNull(name, "name");
 
         synchronized (mux) {
@@ -118,10 +139,15 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Removes metadata by name.
+     *
+     * @param name Name of the metadata to remove.
+     * @param <V> Type of the value.
+     * @return Value of removed metadata or {@code null}.
+     */
     @SuppressWarnings({"unchecked"})
-    @Nullable
-    @Override public <V> V removeMeta(String name) {
+    @Nullable public <V> V removeMeta(String name) {
         A.notNull(name, "name");
 
         synchronized (mux) {
@@ -137,9 +163,16 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Removes metadata only if its current value is equal to {@code val} passed in.
+     *
+     * @param name Name of metadata attribute.
+     * @param val Value to compare.
+     * @param <V> Value type.
+     * @return {@code True} if value was removed, {@code false} otherwise.
+     */
     @SuppressWarnings({"unchecked"})
-    @Override public <V> boolean removeMeta(String name, V val) {
+    public <V> boolean removeMeta(String name, V val) {
         A.notNull(name, "name", val, "val");
 
         synchronized (mux) {
@@ -158,9 +191,14 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Gets all metadata in this entry.
+     *
+     * @param <V> Type of the value.
+     * @return All metadata in this entry.
+     */
     @SuppressWarnings( {"unchecked", "RedundantCast"})
-    @Override public <V> Map<String, V> allMeta() {
+    public <V> Map<String, V> allMeta() {
         synchronized (mux) {
             if (data == null)
                 return Collections.emptyMap();
@@ -174,13 +212,23 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean hasMeta(String name) {
+    /**
+     * Tests whether or not given metadata is set.
+     *
+     * @param name Name of the metadata to test.
+     * @return Whether or not given metadata is set.
+     */
+    public boolean hasMeta(String name) {
         return meta(name) != null;
     }
 
-    /** {@inheritDoc} */
-    @Override public <V> boolean hasMeta(String name, V val) {
+    /**
+     * Tests whether or not given metadata is set.
+     *
+     * @param name Name of the metadata to test.
+     * @return Whether or not given metadata is set.
+     */
+    public <V> boolean hasMeta(String name, V val) {
         A.notNull(name, "name");
 
         Object v = meta(name);
@@ -188,9 +236,16 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         return v != null && v.equals(val);
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Adds given metadata value only if it was absent.
+     *
+     * @param name Metadata name.
+     * @param val Value to add if it's not attached already.
+     * @param <V> Type of the value.
+     * @return {@code null} if new value was put, or current value if put didn't happen.
+     */
     @SuppressWarnings({"unchecked"})
-    @Nullable @Override public <V> V putMetaIfAbsent(String name, V val) {
+    @Nullable public <V> V putMetaIfAbsent(String name, V val) {
         A.notNull(name, "name", val, "val");
 
         synchronized (mux) {
@@ -203,9 +258,19 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Adds given metadata value only if it was absent.
+     *
+     * @param name Metadata name.
+     * @param c Factory closure to produce value to add if it's not attached already.
+     *      Not that unlike {@link #addMeta(String, Object)} method the factory closure will
+     *      not be called unless the value is required and therefore value will only be created
+     *      when it is actually needed.
+     * @param <V> Type of the value.
+     * @return {@code null} if new value was put, or current value if put didn't happen.
+     */
     @SuppressWarnings({"unchecked", "ClassReferencesSubclass"})
-    @Nullable @Override public <V> V putMetaIfAbsent(String name, Callable<V>
c) {
+    @Nullable public <V> V putMetaIfAbsent(String name, Callable<V> c) {
         A.notNull(name, "name", c, "c");
 
         synchronized (mux) {
@@ -223,9 +288,18 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Adds given metadata value only if it was absent. Unlike
+     * {@link #putMetaIfAbsent(String, Callable)}, this method always returns
+     * the latest value and never previous one.
+     *
+     * @param name Metadata name.
+     * @param val Value to add if it's not attached already.
+     * @param <V> Type of the value.
+     * @return The value of the metadata after execution of this method.
+     */
     @SuppressWarnings({"unchecked"})
-    @Override public <V> V addMetaIfAbsent(String name, V val) {
+    public <V> V addMetaIfAbsent(String name, V val) {
         A.notNull(name, "name", val, "val");
 
         synchronized (mux) {
@@ -238,9 +312,20 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Adds given metadata value only if it was absent.
+     *
+     * @param name Metadata name.
+     * @param c Factory closure to produce value to add if it's not attached already.
+     *      Not that unlike {@link #addMeta(String, Object)} method the factory closure will
+     *      not be called unless the value is required and therefore value will only be created
+     *      when it is actually needed. If {@code null} and metadata value is missing - {@code
null}
+     *      will be returned from this method.
+     * @param <V> Type of the value.
+     * @return The value of the metadata after execution of this method.
+     */
     @SuppressWarnings({"unchecked"})
-    @Nullable @Override public <V> V addMetaIfAbsent(String name, @Nullable Callable<V>
c) {
+    @Nullable public <V> V addMetaIfAbsent(String name, @Nullable Callable<V>
c) {
         A.notNull(name, "name", c, "c");
 
         synchronized (mux) {
@@ -258,9 +343,17 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Replaces given metadata with new {@code newVal} value only if its current value
+     * is equal to {@code curVal}. Otherwise, it is no-op.
+     *
+     * @param name Name of the metadata.
+     * @param curVal Current value to check.
+     * @param newVal New value.
+     * @return {@code true} if replacement occurred, {@code false} otherwise.
+     */
     @SuppressWarnings({"RedundantTypeArguments"})
-    @Override public <V> boolean replaceMeta(String name, V curVal, V newVal) {
+    public <V> boolean replaceMeta(String name, V curVal, V newVal) {
         A.notNull(name, "name", newVal, "newVal", curVal, "curVal");
 
         synchronized (mux) {
@@ -317,7 +410,7 @@ public class GridMetadataAwareAdapter implements GridMetadataAware {
 
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException", "OverriddenMethodCallDuringObjectConstruction"})
-    @Override public Object clone() {
+    public Object clone() {
         try {
             GridMetadataAwareAdapter clone = (GridMetadataAwareAdapter)super.clone();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/core/src/test/java/org/gridgain/grid/GridTestJobContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/GridTestJobContext.java b/modules/core/src/test/java/org/gridgain/grid/GridTestJobContext.java
index 6fec126..0a2b528 100644
--- a/modules/core/src/test/java/org/gridgain/grid/GridTestJobContext.java
+++ b/modules/core/src/test/java/org/gridgain/grid/GridTestJobContext.java
@@ -19,7 +19,7 @@ import java.util.*;
 /**
  * Test job context.
  */
-public class GridTestJobContext extends GridMetadataAwareAdapter implements ComputeJobContext
{
+public class GridTestJobContext implements ComputeJobContext {
     /** */
     private final IgniteUuid jobId;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/core/src/test/java/org/gridgain/grid/lang/GridTupleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/lang/GridTupleSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/lang/GridTupleSelfTest.java
index 554ed38..56b0475 100644
--- a/modules/core/src/test/java/org/gridgain/grid/lang/GridTupleSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/lang/GridTupleSelfTest.java
@@ -10,13 +10,10 @@
 package org.gridgain.grid.lang;
 
 import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.util.lang.*;
-import org.gridgain.grid.util.typedef.*;
 import org.gridgain.testframework.junits.common.*;
 
 import java.util.*;
-import java.util.concurrent.*;
 
 /**
  *
@@ -157,86 +154,4 @@ public class GridTupleSelfTest extends GridCommonAbstractTest {
             info("Caught expected exception: " + e);
         }
     }
-
-    /**
-     * Helper method that checks the correctness of {@link GridMetadataAware}
-     * implementation.
-     *
-     * @param ma Metadata aware object.
-     */
-    private void checkMetadataAware(GridMetadataAware ma) {
-        // addMeta(name, val).
-        assert ma.addMeta("attr1", "val1") == null;
-        assert ma.addMeta("attr2", 1) == null;
-
-        // hasMeta(name).
-        assert ma.hasMeta("attr1");
-        assert !ma.hasMeta("attr3");
-
-        // hasMeta(name, val).
-        assert ma.hasMeta("attr1", "val1");
-        assert !ma.hasMeta("attr1", "some another val");
-
-        // meta(name).
-        assertEquals("val1", ma.meta("attr1"));
-        assertEquals(1, ma.meta("attr2"));
-
-        // allMeta().
-        Map<String, Object> allMeta = ma.allMeta();
-
-        assert allMeta != null;
-        assert allMeta.size() == 2;
-
-        assertEquals("val1", allMeta.get("attr1"));
-        assertEquals(1, allMeta.get("attr2"));
-
-        // addMetaIfAbsent(name, val).
-        assert ma.addMetaIfAbsent("attr2", 2) == 1;
-        assert ma.addMetaIfAbsent("attr3", 3) == 3;
-
-        // addMetaIfAbsent(name, c).
-        assert ma.addMetaIfAbsent("attr2", new Callable<Integer>() {
-            @Override public Integer call() throws Exception {
-                return 5;
-            }
-        }) == 1;
-
-        assert ma.addMetaIfAbsent("attr4", new Callable<Integer>() {
-            @Override public Integer call() throws Exception {
-                return 5;
-            }
-        }) == 5;
-
-        // removeMeta(name).
-        assertEquals(3, ma.removeMeta("attr3"));
-        assertEquals(5, ma.removeMeta("attr4"));
-
-        assert ma.removeMeta("attr156") == null;
-
-        // replaceMeta(name, newVal, curVal).
-        assert !ma.replaceMeta("attr2", 5, 4);
-        assert ma.replaceMeta("attr2", 1, 4);
-
-        // copyMeta(from).
-        ma.copyMeta(new GridMetadataAwareAdapter(F.<String, Object>asMap("k1", "v1",
"k2", 2)));
-
-        assertEquals("v1", ma.meta("k1"));
-        assertEquals(2, ma.meta("k2"));
-        assertEquals("val1", allMeta.get("attr1"));
-        assertEquals(4, allMeta.get("attr2"));
-
-        assert !ma.hasMeta("k3");
-
-        // copyMeta(from).
-        ma.copyMeta(F.asMap("1", 1, "2", 2));
-
-        assertEquals(1, ma.meta("1"));
-        assertEquals(2, ma.meta("2"));
-        assertEquals("v1", ma.meta("k1"));
-        assertEquals(2, ma.meta("k2"));
-        assertEquals("val1", allMeta.get("attr1"));
-        assertEquals(4, allMeta.get("attr2"));
-
-        assert !ma.hasMeta("3");
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/core/src/test/java/org/gridgain/testframework/junits/logger/GridTestLog4jLogger.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/logger/GridTestLog4jLogger.java
b/modules/core/src/test/java/org/gridgain/testframework/junits/logger/GridTestLog4jLogger.java
index c46d6a5..d6c22a9 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/logger/GridTestLog4jLogger.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/logger/GridTestLog4jLogger.java
@@ -58,7 +58,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource}
annotation about logger
  * injection.
  */
-public class GridTestLog4jLogger extends GridMetadataAwareAdapter implements IgniteLogger,
IgniteLoggerNodeIdAware {
+public class GridTestLog4jLogger implements IgniteLogger, IgniteLoggerNodeIdAware {
     /** */
     private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java
----------------------------------------------------------------------
diff --git a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java
index e82da2f..14a8064 100644
--- a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java
+++ b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java
@@ -65,7 +65,7 @@ import org.jetbrains.annotations.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource}
annotation about logger
  * injection.
  */
-public class GridJclLogger extends GridMetadataAwareAdapter implements IgniteLogger {
+public class GridJclLogger implements IgniteLogger {
     /** */
     private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/IgniteLog4jLogger.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/IgniteLog4jLogger.java
b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/IgniteLog4jLogger.java
index e7094a2..7869e47 100644
--- a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/IgniteLog4jLogger.java
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/IgniteLog4jLogger.java
@@ -58,7 +58,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource}
annotation about logger
  * injection.
  */
-public class IgniteLog4jLogger extends GridMetadataAwareAdapter implements IgniteLogger,
IgniteLoggerNodeIdAware,
+public class IgniteLog4jLogger implements IgniteLogger, IgniteLoggerNodeIdAware,
     IgniteLog4jFileAware {
     /** */
     private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/schedule/src/main/java/org/gridgain/grid/kernal/processors/schedule/ScheduleFutureImpl.java
----------------------------------------------------------------------
diff --git a/modules/schedule/src/main/java/org/gridgain/grid/kernal/processors/schedule/ScheduleFutureImpl.java
b/modules/schedule/src/main/java/org/gridgain/grid/kernal/processors/schedule/ScheduleFutureImpl.java
index 7fc8996..ac68f1c 100644
--- a/modules/schedule/src/main/java/org/gridgain/grid/kernal/processors/schedule/ScheduleFutureImpl.java
+++ b/modules/schedule/src/main/java/org/gridgain/grid/kernal/processors/schedule/ScheduleFutureImpl.java
@@ -35,7 +35,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
 /**
  * Implementation of {@link org.apache.ignite.scheduler.SchedulerFuture} interface.
  */
-class ScheduleFutureImpl<R> extends GridMetadataAwareAdapter implements SchedulerFuture<R>,
Externalizable {
+class ScheduleFutureImpl<R> implements SchedulerFuture<R>, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -772,8 +772,7 @@ class ScheduleFutureImpl<R> extends GridMetadataAwareAdapter implements
Schedule
      *
      * @param <R>
      */
-    private static class ScheduleFutureSnapshot<R> extends GridMetadataAwareAdapter
implements
-        SchedulerFuture<R> {
+    private static class ScheduleFutureSnapshot<R> implements SchedulerFuture<R>
{
         /** */
         private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/slf4j/src/main/java/org/gridgain/grid/logger/slf4j/GridSlf4jLogger.java
----------------------------------------------------------------------
diff --git a/modules/slf4j/src/main/java/org/gridgain/grid/logger/slf4j/GridSlf4jLogger.java
b/modules/slf4j/src/main/java/org/gridgain/grid/logger/slf4j/GridSlf4jLogger.java
index 68b1904..f6e1313 100644
--- a/modules/slf4j/src/main/java/org/gridgain/grid/logger/slf4j/GridSlf4jLogger.java
+++ b/modules/slf4j/src/main/java/org/gridgain/grid/logger/slf4j/GridSlf4jLogger.java
@@ -29,7 +29,7 @@ import org.slf4j.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource}
annotation about logger
  * injection.
  */
-public class GridSlf4jLogger extends GridMetadataAwareAdapter implements IgniteLogger {
+public class GridSlf4jLogger implements IgniteLogger {
     /** */
     private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1bbd19c9/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java b/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
index 49a9c72..11c9e70 100644
--- a/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
+++ b/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
@@ -66,7 +66,7 @@ import java.util.concurrent.*;
  * </pre>
  * <p>
  */
-public class GridSpringBean extends GridMetadataAwareAdapter implements Ignite, DisposableBean,
InitializingBean,
+public class GridSpringBean implements Ignite, DisposableBean, InitializingBean,
     ApplicationContextAware, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;


Mime
View raw message