ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [4/5] incubator-ignite git commit: Ignite-176 Removed CacheName annotation. Deleted affinity search logic from balancer.
Date Mon, 09 Feb 2015 14:25:21 GMT
Ignite-176 Removed CacheName annotation. Deleted affinity search logic from balancer.


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

Branch: refs/heads/ignite-176
Commit: f08a824f35ebef9c11700c057c2371b652e6c138
Parents: 5f3c669
Author: avinogradov <avinogradov@gridgain.com>
Authored: Mon Feb 9 17:21:36 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Mon Feb 9 17:21:36 2015 +0300

----------------------------------------------------------------------
 .../examples/ScalarCacheAffinityExample1.scala  |  4 +-
 .../loadbalancer/GridLoadBalancerManager.java   | 57 ---------------
 .../closure/GridClosureProcessor.java           |  4 +-
 .../cache/GridCacheAffinityRoutingSelfTest.java | 75 --------------------
 .../ignite/loadtests/dsi/GridDsiPerfJob.java    |  1 -
 5 files changed, 4 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f08a824f/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
index 2a9ff14..b61c0a1 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
@@ -20,7 +20,6 @@ package org.apache.ignite.scalar.examples
 import java.util.concurrent.Callable
 
 import org.apache.ignite._
-import org.apache.ignite.cache.CacheName
 import org.apache.ignite.cache.affinity.CacheAffinityKeyMapped
 import org.apache.ignite.lang.IgniteCallable
 import org.apache.ignite.scalar.scalar
@@ -70,7 +69,8 @@ object ScalarCacheAffinityExample1 {
                         @CacheAffinityKeyMapped
                         def affinityKey(): String = key
 
-                        @CacheName
+                        // @CacheName
+                        // TODO: IGNITE-176 Use affinityCall instead
                         def cacheName(): String = NAME
 
                         @Nullable def call: String = {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f08a824f/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
index 1ee7019..ac961b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
@@ -72,16 +72,6 @@ public class GridLoadBalancerManager extends GridManagerAdapter<LoadBalancingSpi
         assert top != null;
         assert job != null;
 
-        // Check cache affinity routing first.
-        ClusterNode affNode = cacheAffinityNode(ses.deployment(), job, top);
-
-        if (affNode != null) {
-            if (log.isDebugEnabled())
-                log.debug("Found affinity node for the job [job=" + job + ", affNode=" +
affNode.id() + "]");
-
-            return affNode;
-        }
-
         return getSpi(ses.getLoadBalancingSpi()).getBalancedNode(ses, top, job);
     }
 
@@ -112,51 +102,4 @@ public class GridLoadBalancerManager extends GridManagerAdapter<LoadBalancingSpi
             }
         };
     }
-
-    /**
-     * @param dep Deployment.
-     * @param job Grid job.
-     * @param nodes Topology nodes.
-     * @return Cache affinity node or {@code null} if this job is not routed with cache affinity
key.
-     * @throws IgniteException If failed to determine whether to use affinity routing.
-     */
-    @Nullable private ClusterNode cacheAffinityNode(GridDeployment dep, ComputeJob job, Collection<ClusterNode>
nodes)
-        throws IgniteException {
-        assert dep != null;
-        assert job != null;
-        assert nodes != null;
-
-        try {
-            if (log.isDebugEnabled())
-                log.debug("Looking for cache affinity node [job=" + job + "]");
-
-            Object key = dep.annotatedValue(job, CacheAffinityKeyMapped.class);
-
-            if (key == null)
-                return null;
-
-            String cacheName = (String)dep.annotatedValue(job, CacheName.class);
-
-            if (log.isDebugEnabled())
-                log.debug("Affinity properties [key=" + key + ", cacheName=" + cacheName
+ "]");
-
-            ClusterNode node = ctx.affinity().mapKeyToNode(cacheName, key);
-
-            if (node == null)
-                throw new IgniteException("Failed to map key to node (is cache with given
name started?) [gridName=" +
-                    ctx.gridName() + ", key=" + key + ", cacheName=" + cacheName +
-                    ", nodes=" + U.toShortString(nodes) + ']');
-
-            if (!nodes.contains(node))
-                throw new IgniteException("Failed to map key to node (projection nodes do
not contain affinity node) " +
-                    "[gridName=" + ctx.gridName() + ", key=" + key + ", cacheName=" + cacheName
+
-                    ", nodes=" + U.toShortString(nodes) + ", node=" + U.toShortString(node)
+ ']');
-
-            return node;
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException("Failed to map affinity key to node for job [gridName="
+ ctx.gridName() +
-                ", job=" + job + ']', e);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f08a824f/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index 0ca6355..ebee8a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -416,7 +416,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
             // In case cache key is passed instead of affinity key.
             final Object affKey0 = ctx.affinity().affinityKey(cacheName, affKey);
 
-            final ClusterNode node = ctx.affinity().mapKeyToNode(affKey0);
+            final ClusterNode node = ctx.affinity().mapKeyToNode(cacheName, affKey0);
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
@@ -448,7 +448,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
             // In case cache key is passed instead of affinity key.
             final Object affKey0 = ctx.affinity().affinityKey(cacheName, affKey);
 
-            final ClusterNode node = ctx.affinity().mapKeyToNode(affKey0);
+            final ClusterNode node = ctx.affinity().mapKeyToNode(cacheName, affKey0);
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f08a824f/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 a5dfb5a..581b8ce 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
@@ -175,81 +175,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testTask() throws Exception {
-        // Jobs should be routed correctly.
-        for (int i = 0; i < KEY_CNT; i++)
-            assert grid(0).compute().execute(new OneJobTask(i), i) :
-                "Job was routed to a wrong node [i=" + i + "]";
-
-        info("Starting extra node without configured caches...");
-
-        assertEquals(GRID_CNT, G.allGrids().size());
-
-        Ignite g = startGrid(GRID_CNT);
-
-        try {
-            assertEquals(GRID_CNT + 1, g.cluster().nodes().size());
-
-            for (int i = 0; i < KEY_CNT; i++)
-                assert grid(GRID_CNT).compute().execute(new OneJobTask(i), i) :
-                    "Job was routed to a wrong node [i=" + i + "]";
-        }
-        finally {
-            stopGrid(GRID_CNT);
-        }
-    }
-
-    /**
-     * Test task that produces a single job.
-     */
-    private static class OneJobTask extends ComputeTaskSplitAdapter<Integer, Boolean>
{
-        /** Affinity key. */
-        @GridToStringInclude
-        @CacheAffinityKeyMapped
-        private Object affKey;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /**
-         * @param affKey Affinity key.
-         */
-        private OneJobTask(Integer affKey) {
-            this.affKey = affKey;
-        }
-
-        /** {@inheritDoc} */
-        @Override protected Collection<? extends ComputeJob> split(int gridSize, Integer
arg) {
-            return F.asList(new ComputeJobAdapter() {
-                @Override public Object execute() {
-                    CacheAffinity<Object> aff = ignite.cache(null).affinity();
-
-                    ClusterNode primary = aff.mapKeyToNode(affKey);
-
-                    if (log.isInfoEnabled())
-                        log.info("Primary node for the job key [affKey=" + affKey + ", primary="
+ primary.id() + "]");
-
-                    return F.eqNodes(ignite.cluster().localNode(), primary);
-                }
-            });
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean reduce(List<ComputeJobResult> results) {
-            return results.get(0).getData();
-        }
-    }
-
-    /**
      * Test key.
      */
     private static class AffinityTestKey {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f08a824f/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java
b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java
index 69e1d5f..c5f7209 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java
@@ -58,7 +58,6 @@ public class GridDsiPerfJob extends ComputeJobAdapter {
     private Ignite ignite;
 
     /** */
-    @CacheName
     private String cacheName = "PARTITIONED_CACHE";
 
     /**


Mime
View raw message