You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/05/18 10:58:27 UTC
[21/38] ignite git commit: Implemented task to find affinity node for
key in cache.
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/8731e46e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8731e46e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8731e46e
Branch: refs/heads/ignite-3165
Commit: 8731e46ea703a11d0b94d01467e308aa149f5d5a
Parents: 1f99a91
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue May 10 10:14:54 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue May 10 10:14:54 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/8731e46e/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/8731e46e/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);