You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/06/08 14:54:56 UTC
ignite git commit: ignite-3261
Repository: ignite
Updated Branches:
refs/heads/ignite-3261 e82e88bf3 -> d8b17a33b
ignite-3261
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d8b17a33
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d8b17a33
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d8b17a33
Branch: refs/heads/ignite-3261
Commit: d8b17a33b6a864cef7a640bc8b0928328ba16c41
Parents: e82e88b
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jun 8 17:54:51 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jun 8 17:54:51 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/AffinityKey.java | 69 ++++++++++++++++++++
.../binary/GridBinaryAffinityKeySelfTest.java | 15 +++++
2 files changed, 84 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d8b17a33/modules/core/src/test/java/org/apache/ignite/internal/binary/AffinityKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/AffinityKey.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/AffinityKey.java
new file mode 100644
index 0000000..1b4daee
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/AffinityKey.java
@@ -0,0 +1,69 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ *
+ */
+public class AffinityKey {
+ /** Key. */
+ private int key;
+
+ /** Affinity key. */
+ @AffinityKeyMapped
+ private int aff;
+
+ /**
+ * @param key Key.
+ * @param aff Affinity key.
+ */
+ public AffinityKey(int key, int aff) {
+ this.key = key;
+ this.aff = aff;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ AffinityKey that = (AffinityKey) o;
+
+ return key == that.key && aff == that.aff;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = key;
+
+ res = 31 * res + aff;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(AffinityKey.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d8b17a33/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java
index 06406e0..2b54f6b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java
@@ -139,6 +139,8 @@ public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest {
assertEquals(i, aff.affinityKey(ignite.binary().toBinary(new TestObject(i))));
+ assertEquals(i, aff.affinityKey(new AffinityKey(0, i)));
+
BinaryObjectBuilder bldr = ignite.binary().builder("TestObject2");
bldr.setField("affKey", i);
@@ -162,6 +164,8 @@ public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest {
assertEquals(affProc.mapKeyToNode(null, i), affProc.mapKeyToNode(null, new TestObject(i)));
assertEquals(affProc.mapKeyToNode(null, i), affProc.mapKeyToNode(null, cacheObj));
+
+ assertEquals(affProc.mapKeyToNode(null, new AffinityKey(0, i)), affProc.mapKeyToNode(null, i));
}
}
@@ -184,6 +188,17 @@ public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest {
});
assertEquals(aff.mapKeyToNode(i).id(), nodeId.get());
+
+ grid(0).compute().affinityRun(null, new AffinityKey(0, i), new IgniteRunnable() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public void run() {
+ nodeId.set(ignite.configuration().getNodeId());
+ }
+ });
+
+ assertEquals(aff.mapKeyToNode(i).id(), nodeId.get());
}
}