ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [02/17] incubator-ignite git commit: Ignite-176 GridCacheAffinityRoutingSelfTest fix
Date Tue, 10 Feb 2015 16:01:49 GMT
Ignite-176 GridCacheAffinityRoutingSelfTest fix


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

Branch: refs/heads/sprint-1
Commit: c12455d1d9ad995a9a656dffa708273820437aac
Parents: 46d4d26
Author: avinogradov <avinogradov@gridgain.com>
Authored: Mon Feb 9 16:33:05 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Mon Feb 9 16:33:05 2015 +0300

----------------------------------------------------------------------
 .../ignite/compute/ComputeJobContext.java       |  20 --
 .../ignite/internal/GridJobContextImpl.java     |  20 --
 .../org/apache/ignite/GridTestJobContext.java   |  10 -
 .../cache/GridCacheAffinityRoutingSelfTest.java | 345 -------------------
 4 files changed, 395 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c12455d1/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java b/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java
index 8d390fa..1254031 100644
--- a/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java
@@ -58,26 +58,6 @@ import java.util.concurrent.*;
  */
 public interface ComputeJobContext extends ComputeJobContinuation {
     /**
-     * Gets cache name for which job was co-located.
-     *
-     * @return Cache name if job was co-located or {@code null} otherwise.
-     * @see #affinityKey()
-     * @see org.apache.ignite.IgniteCompute#affinityCall(String, Object, Callable)
-     * @see org.apache.ignite.IgniteCompute#affinityRun(String, Object, Runnable)
-     */
-    @Nullable public String cacheName();
-
-    /**
-     * Gets affinity key with which job was co-located.
-     *
-     * @return Affinity key if job was co-located or {@code null} otherwise.
-     * @see #cacheName()
-     * @see org.apache.ignite.IgniteCompute#affinityCall(String, Object, Callable)
-     * @see org.apache.ignite.IgniteCompute#affinityRun(String, Object, Runnable)
-     */
-    @Nullable public <T> T affinityKey();
-
-    /**
      * Gets ID of the job this context belongs to.
      *
      * @return ID of the job this context belongs to.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c12455d1/modules/core/src/main/java/org/apache/ignite/internal/GridJobContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridJobContextImpl.java
index 433364e..ee7a700 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobContextImpl.java
@@ -230,26 +230,6 @@ public class GridJobContextImpl implements ComputeJobContext, Externalizable
{
     }
 
     /** {@inheritDoc} */
-    @Override public String cacheName() {
-        try {
-            return (String)job.getDeployment().annotatedValue(job.getJob(), CacheName.class);
-        }
-        catch (IgniteCheckedException e) {
-            throw F.wrap(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T affinityKey() {
-        try {
-            return (T)job.getDeployment().annotatedValue(job.getJob(), CacheAffinityKeyMapped.class);
-        }
-        catch (IgniteCheckedException e) {
-            throw F.wrap(e);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
         out.writeObject(ctx);
         U.writeGridUuid(out, jobId);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c12455d1/modules/core/src/test/java/org/apache/ignite/GridTestJobContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/GridTestJobContext.java b/modules/core/src/test/java/org/apache/ignite/GridTestJobContext.java
index ef789f4..cb8c187 100644
--- a/modules/core/src/test/java/org/apache/ignite/GridTestJobContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/GridTestJobContext.java
@@ -77,16 +77,6 @@ public class GridTestJobContext implements ComputeJobContext {
     }
 
     /** {@inheritDoc} */
-    @Override public String cacheName() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T affinityKey() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
     @Override public <T> T holdcc() {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c12455d1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
index 64fa603..a5dfb5a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
@@ -179,70 +179,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest
{
      *
      * @throws Exception If failed.
      */
-    public void testField() throws Exception {
-        // Jobs should be routed correctly in case of using load balancer.
-        for (int i = 0; i < KEY_CNT; i++)
-            assert grid(0).compute().call(new FieldAffinityJob(i)) :
-                "Job was routed to a wrong node [i=" + i + "]";
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testMethod() throws Exception {
-        // Jobs should be routed correctly in case of using load balancer.
-        for (int i = 0; i < KEY_CNT; i++)
-            assert grid(0).compute().call(new MethodAffinityJob(i)) :
-                "Job was routed to a wrong node [i=" + i + "]";
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testFiledCacheName() throws Exception {
-        // Jobs should be routed correctly in case of using load balancer.
-        for (int i = 0; i < KEY_CNT; i++)
-            assert grid(0).compute().call(new FieldCacheNameAffinityJob(i)) :
-                "Job was routed to a wrong node [i=" + i + "]";
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testMethodCacheName() throws Exception {
-        // Jobs should be routed correctly in case of using load balancer.
-        for (int i = 0; i < KEY_CNT; i++)
-            assert grid(0).compute().call(new MethodCacheNameAffinityJob(i)) :
-                "Job was routed to a wrong node [i=" + i + "]";
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testMultipleAnnotationsJob() throws Exception {
-        try {
-            grid(0).compute().call(new MultipleAnnotationsJob(0));
-
-            fail();
-        }
-        catch (IgniteException e) {
-            info("Caught expected exception: " + e);
-        }
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
     public void testTask() throws Exception {
         // Jobs should be routed correctly.
         for (int i = 0; i < KEY_CNT; i++)
@@ -268,283 +204,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * Test job with field annotation.
-     */
-    private static class FieldAffinityJob implements IgniteCallable<Boolean> {
-        /** Affinity key. */
-        @CacheAffinityKeyMapped
-        @GridToStringInclude
-        private Object affKey;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** */
-        @JobContextResource
-        private ComputeJobContext jobCtx;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        FieldAffinityJob(Object affKey) {
-            this.affKey = affKey;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() {
-            assert ignite != null;
-
-            assert jobCtx.affinityKey().equals(affKey);
-            assert jobCtx.cacheName() == null;
-
-            if (log.isDebugEnabled())
-                log.debug("Running job [node=" + ignite.cluster().localNode().id() + ", job="
+ this + "]");
-
-            CacheAffinity<Object> aff = ignite.cache(null).affinity();
-
-            return F.eqNodes(ignite.cluster().localNode(), aff.mapKeyToNode(affKey));
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(FieldAffinityJob.class, this);
-        }
-    }
-
-    /**
-     * Test job with method annotation.
-     */
-    private static class MethodAffinityJob implements IgniteCallable<Boolean> {
-        /** Affinity key. */
-        @GridToStringInclude
-        private Object affKey;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** */
-        @JobContextResource
-        private ComputeJobContext jobCtx;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        MethodAffinityJob(Object affKey) {
-            this.affKey = affKey;
-        }
-
-        /**
-         * @return Affinity key.
-         */
-        @CacheAffinityKeyMapped
-        public Object affinityKey() {
-            return affKey;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() {
-            assert ignite != null;
-
-            assert jobCtx.affinityKey().equals(affinityKey());
-            assert jobCtx.cacheName() == null;
-
-            if (log.isDebugEnabled())
-                log.debug("Running job [node=" + ignite.cluster().localNode().id() + ", job="
+ this + "]");
-
-            CacheAffinity<Object> aff = ignite.cache(null).affinity();
-
-            return F.eqNodes(ignite.cluster().localNode(), aff.mapKeyToNode(affKey));
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(MethodAffinityJob.class, this);
-        }
-    }
-
-    /**
-     * Test job with field cache name annotation.
-     */
-    private static class FieldCacheNameAffinityJob implements IgniteCallable<Boolean>
{
-        /** Affinity key. */
-        @GridToStringInclude
-        private Object affKey;
-
-        /** Cache name to use affinity from. */
-        @CacheName
-        private String cacheName = NON_DFLT_CACHE_NAME;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** */
-        @JobContextResource
-        private ComputeJobContext jobCtx;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        FieldCacheNameAffinityJob(Object affKey) {
-            this.affKey = affKey;
-        }
-
-        /**
-         * @return Affinity key.
-         */
-        @CacheAffinityKeyMapped
-        public Object affinityKey() {
-            return affKey;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() {
-            assert ignite != null;
-
-            assert jobCtx.affinityKey().equals(affKey);
-            assert jobCtx.cacheName().equals(cacheName);
-
-            if (log.isDebugEnabled())
-                log.debug("Running job [node=" + ignite.cluster().localNode().id() + ", job="
+ this + "]");
-
-            CacheAffinity<Object> aff = ignite.cache(cacheName).affinity();
-
-            return F.eqNodes(ignite.cluster().localNode(), aff.mapKeyToNode(affKey));
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(FieldCacheNameAffinityJob.class, this);
-        }
-    }
-
-    /**
-     * Test job with method cache name annotation.
-     */
-    private static class MethodCacheNameAffinityJob implements IgniteCallable<Boolean>
{
-        /** Affinity key. */
-        @GridToStringInclude
-        private Object affKey;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** */
-        @JobContextResource
-        private ComputeJobContext jobCtx;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        MethodCacheNameAffinityJob(Object affKey) {
-            this.affKey = affKey;
-        }
-
-        /**
-         * @return Affinity key.
-         */
-        @CacheAffinityKeyMapped
-        public Object affinityKey() {
-            return affKey;
-        }
-
-        /**
-         * @return Cache name for affinity routing.
-         */
-        @CacheName
-        public String cacheName() {
-            return NON_DFLT_CACHE_NAME;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() {
-            assert ignite != null;
-
-            assert jobCtx.affinityKey().equals(affKey);
-            assert jobCtx.cacheName().equals(cacheName());
-
-            if (log.isDebugEnabled())
-                log.debug("Running job [node=" + ignite.cluster().localNode().id() + ", job="
+ this + "]");
-
-            CacheAffinity<Object> aff = ignite.cache(cacheName()).affinity();
-
-            return F.eqNodes(ignite.cluster().localNode(), aff.mapKeyToNode(affKey));
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(MethodCacheNameAffinityJob.class, this);
-        }
-    }
-
-    /**
-     * Test job with method cache name annotation.
-     */
-    private static class MultipleAnnotationsJob implements IgniteCallable<Boolean>
{
-        /** Affinity key. */
-        @GridToStringInclude
-        @CacheAffinityKeyMapped
-        private Object affKey;
-
-        /** Duplicated affinity key. */
-        @SuppressWarnings({"UnusedDeclaration"})
-        @CacheAffinityKeyMapped
-        private Object affKeyDup;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        MultipleAnnotationsJob(Object affKey) {
-            this.affKey = affKey;
-            affKeyDup = affKey;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() {
-            assert ignite != null;
-
-            if (log.isDebugEnabled())
-                log.debug("Running job [node=" + ignite.cluster().localNode().id() + ", job="
+ this + "]");
-
-            CacheAffinity<Object> aff = ignite.cache(null).affinity();
-
-            return F.eqNodes(ignite.cluster().localNode(), aff.mapKeyToNode(affKey));
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(MultipleAnnotationsJob.class, this);
-        }
-    }
-
-    /**
      * Test task that produces a single job.
      */
     private static class OneJobTask extends ComputeTaskSplitAdapter<Integer, Boolean>
{
@@ -644,8 +303,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest
{
         @Override public void applyx() throws IgniteCheckedException {
             assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(null,
affKey).id());
             assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(null,
key).id());
-            assert jobCtx.affinityKey().equals(affKey);
-            assert jobCtx.cacheName().equals(NON_DFLT_CACHE_NAME);
         }
     }
 
@@ -680,8 +337,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest
{
         @Override public Object call() throws IgniteCheckedException {
             assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(null,
affKey).id());
             assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(null,
key).id());
-            assert jobCtx.affinityKey().equals(affKey);
-            assert jobCtx.cacheName().equals(NON_DFLT_CACHE_NAME);
 
             return null;
         }


Mime
View raw message