ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/2] ignite git commit: Implemented task to find affinity node for key in cache.
Date Tue, 10 May 2016 03:39:04 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 388ffefd8 -> 41e37a52b


Implemented task to find affinity node for key in cache.


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

Branch: refs/heads/master
Commit: b27ebe6914ae5efb04e62b3de506ce477c16dfe7
Parents: e5aed69
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Tue May 10 10:20:55 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue May 10 10:20:55 2016 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheAffinityNodeTask.java | 70 ++++++++++++++++++++
 .../visor/cache/VisorCacheConfiguration.java    |  5 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b27ebe69/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java
new file mode 100644
index 0000000..83d421a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.visor.cache;
+
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Task that will find affinity node for key.
+ */
+@GridInternal
+public class VisorCacheAffinityNodeTask extends VisorOneNodeTask<IgniteBiTuple<String,
Object>, UUID> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorCacheAffinityNodeJob job(IgniteBiTuple<String, Object>
arg) {
+        return new VisorCacheAffinityNodeJob(arg, debug);
+    }
+
+    /** Job that will find affinity node for key. */
+    private static class VisorCacheAffinityNodeJob extends VisorJob<IgniteBiTuple<String,
Object>, UUID> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param arg Cache name and key to find affinity node.
+         * @param debug Debug flag.
+         */
+        private VisorCacheAffinityNodeJob(IgniteBiTuple<String, Object> arg, boolean
debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected UUID run(@Nullable IgniteBiTuple<String, Object> arg) throws
IgniteException {
+            assert arg != null;
+
+            ClusterNode node = ignite.affinity(arg.getKey()).mapKeyToNode(arg.getValue());
+
+            return node != null ? node.id() : null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(VisorCacheAffinityNodeJob.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b27ebe69/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index efa6740..5d27a8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMemoryMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -158,7 +159,7 @@ public class VisorCacheConfiguration implements Serializable {
 
         boolean compatibility = false;
 
-        for (org.apache.ignite.cluster.ClusterNode node : ignite.cluster().nodes()) {
+        for (ClusterNode node : ignite.cluster().nodes()) {
             if (node.version().compareToIgnoreTimestamp(VER_1_4_1) <= 0) {
                 compatibility = true;
 
@@ -167,7 +168,7 @@ public class VisorCacheConfiguration implements Serializable {
         }
 
         storeCfg = (compatibility ? new VisorCacheStoreConfiguration() : new VisorCacheStoreConfigurationV2())
-                .from(ignite, ccfg);
+            .from(ignite, ccfg);
 
         qryCfg = (compatibility ? new VisorCacheQueryConfiguration() : new VisorCacheQueryConfigurationV2()).from(ccfg);
 


Mime
View raw message