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/08/24 14:04:24 UTC
[01/50] [abbrv] ignite git commit:
CacheKeepBinaryIterationSwapEnabledTest fix.
Repository: ignite
Updated Branches:
refs/heads/ignite-2649 [created] acb420318
CacheKeepBinaryIterationSwapEnabledTest fix.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7aa609aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7aa609aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7aa609aa
Branch: refs/heads/ignite-2649
Commit: 7aa609aa54f0015649776105bf32b2a213fa031d
Parents: 005ce0f
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Jul 11 15:30:53 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Jul 11 15:30:53 2016 +0300
----------------------------------------------------------------------
.../cache/CacheEvictableEntryImpl.java | 11 ++++--
.../CacheKeepBinaryIterationTest.java | 36 ++++++++++----------
2 files changed, 27 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7aa609aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
index 9f4d9d7..aef71ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
@@ -64,9 +64,16 @@ public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> {
try {
assert ctx != null;
- assert ctx.evicts() != null;
- return ctx.evicts().evict(cached, null, false, null);
+ GridCacheEvictionManager mgr = ctx.evicts();
+
+ if (mgr == null) {
+ assert ctx.kernalContext().isStopping();
+
+ return false;
+ }
+
+ return mgr.evict(cached, null, false, null);
}
catch (IgniteCheckedException e) {
U.error(ctx.grid().log(), "Failed to evict entry from cache: " + cached, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7aa609aa/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
index a775d21..605181f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
@@ -29,11 +29,9 @@ import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -221,11 +219,11 @@ public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
/**
* @param ccfg Cache configuration.
*/
- private void doTestScanQuery(CacheConfiguration<Object, Object> ccfg, boolean keepBinary,
- boolean primitives) throws IgniteInterruptedCheckedException {
+ private void doTestScanQuery(final CacheConfiguration<Object, Object> ccfg, boolean keepBinary,
+ boolean primitives) throws Exception {
IgniteCache<Object, Object> cache = grid(0).createCache(ccfg);
- assertTrue(cache.size() == 0);
+ assertEquals(0, cache.size());
try {
for (int i = 0; i < KEYS; i++)
@@ -272,24 +270,25 @@ public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
}
}
finally {
- cache.removeAll();
+ if (ccfg.getEvictionPolicy() != null) { // TODO: IGNITE-3462. Fixes evictionPolicy issues at cache destroy.
+ stopAllGrids();
- if (ccfg.getEvictionPolicy() != null)
- U.sleep(1000); // Fixes evictionPolicy issues at cache destroy.
-
- grid(0).destroyCache(ccfg.getName());
+ startGridsMultiThreaded(getServerNodeCount());
+ }
+ else
+ grid(0).destroyCache(ccfg.getName());
}
}
/**
* @param ccfg Cache configuration.
*/
- private void doTestLocalEntries(CacheConfiguration<Object, Object> ccfg,
+ private void doTestLocalEntries(final CacheConfiguration<Object, Object> ccfg,
boolean keepBinary,
- boolean primitives) throws IgniteInterruptedCheckedException {
+ boolean primitives) throws Exception {
IgniteCache<Object, Object> cache = grid(0).createCache(ccfg);
- assertTrue(cache.size() == 0);
+ assertEquals(0, cache.size());
try {
for (int i = 0; i < KEYS; i++)
@@ -341,12 +340,13 @@ public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
}
}
finally {
- cache.removeAll();
+ if (ccfg.getEvictionPolicy() != null) { // TODO: IGNITE-3462. Fixes evictionPolicy issues at cache destroy.
+ stopAllGrids();
- if (ccfg.getEvictionPolicy() != null)
- U.sleep(1000); // Fixes evictionPolicy issues at cache destroy.
-
- grid(0).destroyCache(ccfg.getName());
+ startGridsMultiThreaded(getServerNodeCount());
+ }
+ else
+ grid(0).destroyCache(ccfg.getName());
}
}
[49/50] [abbrv] ignite git commit: Cleanup (4).
Posted by vo...@apache.org.
Cleanup (4).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/739c69d1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/739c69d1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/739c69d1
Branch: refs/heads/ignite-2649
Commit: 739c69d1373b8d08e9d67124c4701be5e7aef226
Parents: 4f45986
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:59:44 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:59:44 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgnitionEx.java | 54 ++---------------
.../apache/ignite/internal/LocalGridName.java | 46 ---------------
.../internal/binary/BinaryReaderExImpl.java | 12 +---
.../internal/binary/BinaryWriterExImpl.java | 12 +---
.../ignite/internal/util/IgniteUtils.java | 55 ++++++++++++++++-
.../ignite/marshaller/MarshallerUtils.java | 62 ++++----------------
6 files changed, 76 insertions(+), 165 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 63d0aec..05cbd45 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -166,13 +166,6 @@ public class IgnitionEx {
private static final Collection<IgnitionListener> lsnrs = new GridConcurrentHashSet<>(4);
/** */
- private static final ThreadLocal<LocalGridName> GRID_NAME_THREAD_LOC = new ThreadLocal<LocalGridName>() {
- @Override protected LocalGridName initialValue() {
- return new LocalGridNameImpl();
- }
- };
-
- /** */
private static ThreadLocal<Boolean> daemon = new ThreadLocal<Boolean>() {
@Override protected Boolean initialValue() {
return false;
@@ -1286,22 +1279,21 @@ public class IgnitionEx {
}
/**
- * Gets a name of the grid from thread local config, which is owner of current thread. An Exception is thrown if
- * current thread is not an {@link IgniteThread}.
+ * Gets a name of the grid from thread local config, which is owner of current thread.
*
* @return Grid instance related to current thread
* @throws IllegalArgumentException Thrown to indicate, that current thread is not an {@link IgniteThread}.
*/
public static IgniteKernal localIgnite() throws IllegalArgumentException {
- final LocalGridName gridName = GRID_NAME_THREAD_LOC.get();
+ String gridName = U.getCurrentIgniteName();
- if (gridName.isSet())
- return gridx(gridName.getGridName());
+ if (U.isCurrentIgniteNameSet(gridName))
+ return gridx(gridName);
else if (Thread.currentThread() instanceof IgniteThread)
return gridx(((IgniteThread)Thread.currentThread()).getGridName());
else
throw new IllegalArgumentException("Ignite grid name thread local must be set or" +
- " this method should be accessed under " + IgniteThread.class.getName());
+ " this method should be accessed under " + IgniteThread.class.getName());
}
/**
@@ -1367,15 +1359,6 @@ public class IgnitionEx {
}
/**
- * Get ignite config from thread local.
- *
- * @return Local grid name.
- */
- public static LocalGridName gridNameThreadLocal() {
- return GRID_NAME_THREAD_LOC.get();
- }
-
- /**
* Start context encapsulates all starting parameters.
*/
private static final class GridStartContext {
@@ -2542,31 +2525,4 @@ public class IgnitionEx {
}
}
}
-
- /**
- *
- */
- private static class LocalGridNameImpl implements LocalGridName {
- /** Indicates whether value is initial or not. */
- private boolean valSet;
-
- /** Grid name. */
- private String gridName;
-
- /** {@inheritDoc} */
- @Override public boolean isSet() {
- return valSet;
- }
-
- /** {@inheritDoc} */
- @Override public String getGridName() {
- return gridName;
- }
-
- /** {@inheritDoc} */
- @Override public void setGridName(final boolean set, final String gridName) {
- this.valSet = set;
- this.gridName = gridName;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java b/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
deleted file mode 100644
index 276091b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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;
-
-/**
- * Container holds local grid name and has indicator
- * that shows if value was initialized.
- */
-public interface LocalGridName {
- /**
- * Indicates whether value was set.
- *
- * @return {@code True} if value was set.
- */
- public boolean isSet();
-
- /**
- * Get grid name.
- *
- * @return Grid name.
- */
- public String getGridName();
-
- /**
- * Set grid name and set flag.
- *
- * @param set {@code True} if value is not initial.
- * @param gridName Grid name.
- */
- public void setGridName(boolean set, String gridName);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 47df697..3481ca3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -33,9 +33,8 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.internal.LocalGridName;
-import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1422,18 +1421,13 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
* @throws BinaryObjectException If failed.
*/
@Nullable Object deserialize() throws BinaryObjectException {
- final LocalGridName gridName = IgnitionEx.gridNameThreadLocal();
-
- final String gridNameStr = gridName.getGridName();
- final boolean init = gridName.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(ctx.configuration().getGridName());
try {
- gridName.setGridName(true, ctx.configuration().getGridName());
-
return deserialize0();
}
finally {
- gridName.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 675b2d9..b3963d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -33,10 +33,9 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.internal.LocalGridName;
-import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
@@ -141,18 +140,13 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
void marshal(Object obj, boolean enableReplace) throws BinaryObjectException {
- final LocalGridName gridName = IgnitionEx.gridNameThreadLocal();
-
- final String gridNameStr = gridName.getGridName();
- final boolean init = gridName.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(ctx.configuration().getGridName());
try {
- gridName.setGridName(true, ctx.configuration().getGridName());
-
marshal0(obj, enableReplace);
}
finally {
- gridName.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 08c9219..3ddc0f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -250,7 +250,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
/**
* Collection of utility methods used throughout the system.
*/
-@SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName"})
+@SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName", "RedundantStringConstructorCall"})
public abstract class IgniteUtils {
/** Unsafe. */
private static final Unsafe UNSAFE = GridUnsafe.unsafe();
@@ -489,6 +489,16 @@ public abstract class IgniteUtils {
/** Object.toString() */
private static Method toStringMtd;
+ /** Empty local Ignite name. */
+ private static final String CUR_IGNITE_NAME_EMPTY = new String();
+
+ /** Local Ignite name thread local. */
+ private static ThreadLocal<String> LOC_IGNITE_NAME = new ThreadLocal<String>() {
+ @Override protected String initialValue() {
+ return CUR_IGNITE_NAME_EMPTY;
+ }
+ };
+
/**
* Initializes enterprise check.
*/
@@ -9555,4 +9565,47 @@ public abstract class IgniteUtils {
public static boolean isToStringMethod(Method mtd) {
return toStringMtd.equals(mtd);
}
+
+ /**
+ * Get current Ignite name.
+ *
+ * @return Current Ignite name.
+ */
+ @Nullable public static String getCurrentIgniteName() {
+ return LOC_IGNITE_NAME.get();
+ }
+
+ /**
+ * Check if current Ignite name is set.
+ *
+ * @param name Name to check.
+ * @return {@code True} if set.
+ */
+ @SuppressWarnings("StringEquality")
+ public static boolean isCurrentIgniteNameSet(@Nullable String name) {
+ return name != CUR_IGNITE_NAME_EMPTY;
+ }
+
+ /**
+ * Set current Ignite name.
+ *
+ * @param newName New name.
+ * @return Old name.
+ */
+ @Nullable public static String setCurrentIgniteName(@Nullable String newName) {
+ String oldName = LOC_IGNITE_NAME.get();
+
+ LOC_IGNITE_NAME.set(newName);
+
+ return oldName;
+ }
+
+ /**
+ * Restore current Ignite name.
+ *
+ * @param oldName Old name.
+ */
+ public static void restoreCurrentIgniteName(@Nullable String oldName) {
+ LOC_IGNITE_NAME.set(oldName);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/739c69d1/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 6e2dab3..0775622 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -19,8 +19,7 @@ package org.apache.ignite.marshaller;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgnitionEx;
-import org.apache.ignite.internal.LocalGridName;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.jetbrains.annotations.Nullable;
import java.io.InputStream;
@@ -40,18 +39,13 @@ public class MarshallerUtils {
* @throws IgniteCheckedException If failed.
*/
public static byte[] marshal(String name, Marshaller marsh, @Nullable Object obj) throws IgniteCheckedException {
- LocalGridName gridNameTl = gridName();
-
- String gridNameStr = gridNameTl.getGridName();
- boolean init = gridNameTl.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(name);
try {
- gridNameTl.setGridName(true, name);
-
return marsh.marshal(obj);
}
finally {
- gridNameTl.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
@@ -66,18 +60,13 @@ public class MarshallerUtils {
*/
public static void marshal(String name, Marshaller marshaller, @Nullable Object obj, OutputStream out)
throws IgniteCheckedException {
- LocalGridName gridNameTl = gridName();
-
- String gridNameStr = gridNameTl.getGridName();
- boolean init = gridNameTl.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(name);
try {
- gridNameTl.setGridName(true, name);
-
marshaller.marshal(obj, out);
}
finally {
- gridNameTl.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
@@ -93,13 +82,6 @@ public class MarshallerUtils {
return marshal(ctx.gridName(), ctx.config().getMarshaller(), obj);
}
-
-
-
-
-
-
-
/**
* Unmarshal object and set grid name thread local.
*
@@ -112,18 +94,13 @@ public class MarshallerUtils {
*/
public static <T> T unmarshal(String name, Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr)
throws IgniteCheckedException {
- LocalGridName gridNameTl = gridName();
-
- String gridNameStr = gridNameTl.getGridName();
- boolean init = gridNameTl.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(name);
try {
- gridNameTl.setGridName(true, name);
-
return marsh.unmarshal(arr, ldr);
}
finally {
- gridNameTl.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
@@ -139,18 +116,13 @@ public class MarshallerUtils {
*/
public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable ClassLoader ldr)
throws IgniteCheckedException {
- LocalGridName gridNameTl = gridName();
-
- String gridNameStr = gridNameTl.getGridName();
- boolean init = gridNameTl.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(name);
try {
- gridNameTl.setGridName(true, name);
-
return marsh.unmarshal(in, ldr);
}
finally {
- gridNameTl.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
@@ -166,29 +138,17 @@ public class MarshallerUtils {
*/
public static <T> T marshalUnmarshal(String name, Marshaller marsh, T obj, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
- LocalGridName gridNameTl = gridName();
-
- String gridNameStr = gridNameTl.getGridName();
- boolean init = gridNameTl.isSet();
+ String oldName = IgniteUtils.setCurrentIgniteName(name);
try {
- gridNameTl.setGridName(true, name);
-
return marsh.unmarshal(marsh.marshal(obj), clsLdr);
}
finally {
- gridNameTl.setGridName(init, gridNameStr);
+ IgniteUtils.restoreCurrentIgniteName(oldName);
}
}
/**
- * @return Grid name thread local.
- */
- private static LocalGridName gridName() {
- return IgnitionEx.gridNameThreadLocal();
- }
-
- /**
* Private constructor.
*/
private MarshallerUtils() {
[06/50] [abbrv] ignite git commit: IGNITE-3440: Ignite Services:
ServiceTopologyCallable is executed before system cache is started
Posted by vo...@apache.org.
IGNITE-3440: Ignite Services: ServiceTopologyCallable is executed before system cache is started
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/06b24a9b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/06b24a9b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/06b24a9b
Branch: refs/heads/ignite-2649
Commit: 06b24a9b3952598604e02d80d1ed76a52d85e743
Parents: 89d64e7
Author: Denis Magda <dm...@gridgain.com>
Authored: Wed Jul 13 14:19:51 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Jul 13 14:19:51 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 2 +
.../service/GridServiceProcessor.java | 70 +++++++++++++++++++-
2 files changed, 71 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/06b24a9b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 414a915..6484d4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -797,6 +797,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (!ctx.config().isDaemon())
ctx.cacheObjects().onUtilityCacheStarted();
+ ctx.service().onUtilityCacheStarted();
+
// Wait for caches in SYNC preload mode.
for (CacheConfiguration cfg : ctx.config().getCacheConfiguration()) {
GridCacheAdapter cache = caches.get(maskNull(cfg.getName()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/06b24a9b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 53eaeb5..b418ba2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -38,8 +38,10 @@ import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJobContext;
import org.apache.ignite.configuration.DeploymentMode;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
@@ -81,6 +83,8 @@ import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.JobContextResource;
+import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceConfiguration;
import org.apache.ignite.services.ServiceDescriptor;
@@ -125,6 +129,9 @@ public class GridServiceProcessor extends GridProcessorAdapter {
/** Deployment futures. */
private final ConcurrentMap<String, GridFutureAdapter<?>> undepFuts = new ConcurrentHashMap8<>();
+ /** Pending compute job contexts that waiting for utility cache initialization. */
+ private final List<ComputeJobContext> pendingJobCtxs = new ArrayList<>(0);
+
/** Deployment executor service. */
private final ExecutorService depExe;
@@ -1304,6 +1311,23 @@ public class GridServiceProcessor extends GridProcessorAdapter {
}
/**
+ * Called right after utility cache is started and ready for the usage.
+ */
+ public void onUtilityCacheStarted() {
+ synchronized (pendingJobCtxs) {
+ if (pendingJobCtxs.size() == 0)
+ return;
+
+ Iterator<ComputeJobContext> iter = pendingJobCtxs.iterator();
+
+ while (iter.hasNext()) {
+ iter.next().callcc();
+ iter.remove();
+ }
+ }
+ }
+
+ /**
* Service deployment listener.
*/
@SuppressWarnings("unchecked")
@@ -1783,9 +1807,20 @@ public class GridServiceProcessor extends GridProcessorAdapter {
private final String svcName;
/** */
+ private boolean waitedCacheInit;
+
+ /** */
@IgniteInstanceResource
private IgniteEx ignite;
+ /** */
+ @JobContextResource
+ private ComputeJobContext jCtx;
+
+ /** */
+ @LoggerResource
+ private IgniteLogger log;
+
/**
* @param svcName Service name.
*/
@@ -1795,7 +1830,40 @@ public class GridServiceProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public Map<UUID, Integer> call() throws Exception {
- return serviceTopology(ignite.context().cache().utilityCache(), svcName);
+ IgniteInternalCache<Object, Object> cache = ignite.context().cache().utilityCache();
+
+ if (cache == null) {
+ List<ComputeJobContext> pendingCtxs = ignite.context().service().pendingJobCtxs;
+
+ synchronized (pendingCtxs) {
+ // Double check cache reference after lock acqusition.
+ cache = ignite.context().cache().utilityCache();
+
+ if (cache == null) {
+ if (!waitedCacheInit) {
+ log.debug("Utility cache hasn't been initialized yet. Waiting.");
+
+ // waiting for a minute for cache initialization.
+ jCtx.holdcc(60 * 1000);
+
+ pendingCtxs.add(jCtx);
+
+ waitedCacheInit = true;
+
+ return null;
+ }
+ else {
+ log.error("Failed to gather service topology. Utility " +
+ "cache initialization is stuck.");
+
+ throw new IgniteCheckedException("Failed to gather service topology. Utility " +
+ "cache initialization is stuck.");
+ }
+ }
+ }
+ }
+
+ return serviceTopology(cache, svcName);
}
}
[38/50] [abbrv] ignite git commit: Review (WIP).
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index 74e2be0..d635825 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -358,7 +358,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private byte[] marshal(final Object obj) throws IOException {
if (marshaller != null) {
try {
- return MarshallerUtils.marshal(marshaller, obj, gridName);
+ return MarshallerUtils.marshal(gridName, marshaller, obj);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
[20/50] [abbrv] ignite git commit: IGNITE-3414: Hadoop: implemented
new weight-based map-reduce planner.
Posted by vo...@apache.org.
IGNITE-3414: Hadoop: implemented new weight-based map-reduce planner.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/73649386
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/73649386
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/73649386
Branch: refs/heads/ignite-2649
Commit: 736493865c1e3a56f864a01583d38e50d02b2c56
Parents: 5f57cc8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 19 15:16:21 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 19 15:16:21 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsIgniteMock.java | 492 +++++++++++
.../internal/processors/igfs/IgfsMock.java | 397 +++++++++
.../mapreduce/IgniteHadoopMapReducePlanner.java | 48 +-
.../IgniteHadoopWeightedMapReducePlanner.java | 846 +++++++++++++++++++
.../internal/processors/hadoop/HadoopUtils.java | 81 ++
.../planner/HadoopAbstractMapReducePlanner.java | 116 +++
.../planner/HadoopMapReducePlanGroup.java | 150 ++++
.../planner/HadoopMapReducePlanTopology.java | 89 ++
.../HadoopDefaultMapReducePlannerSelfTest.java | 451 +---------
.../processors/hadoop/HadoopMapReduceTest.java | 16 +-
.../processors/hadoop/HadoopPlannerMockJob.java | 168 ++++
.../HadoopWeightedMapReducePlannerTest.java | 599 +++++++++++++
.../HadoopWeightedPlannerMapReduceTest.java | 38 +
.../testsuites/IgniteHadoopTestSuite.java | 8 +-
14 files changed, 3022 insertions(+), 477 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsIgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsIgniteMock.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsIgniteMock.java
new file mode 100644
index 0000000..0c55595
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsIgniteMock.java
@@ -0,0 +1,492 @@
+/*
+ * 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.processors.igfs;
+
+import org.apache.ignite.IgniteAtomicLong;
+import org.apache.ignite.IgniteAtomicReference;
+import org.apache.ignite.IgniteAtomicSequence;
+import org.apache.ignite.IgniteAtomicStamped;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteCountDownLatch;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteMessaging;
+import org.apache.ignite.IgniteQueue;
+import org.apache.ignite.IgniteScheduler;
+import org.apache.ignite.IgniteSemaphore;
+import org.apache.ignite.IgniteServices;
+import org.apache.ignite.IgniteSet;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.CollectionConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.hadoop.Hadoop;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.plugin.IgnitePlugin;
+import org.apache.ignite.plugin.PluginNotFoundException;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Mocked Ignite implementation for IGFS tests.
+ */
+public class IgfsIgniteMock implements IgniteEx {
+ /** Name. */
+ private final String name;
+
+ /** IGFS. */
+ private final IgniteFileSystem igfs;
+
+ /**
+ * Constructor.
+ *
+ * @param igfs IGFS instance.
+ */
+ public IgfsIgniteMock(@Nullable String name, IgniteFileSystem igfs) {
+ this.name = name;
+ this.igfs = igfs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex(@Nullable String name) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public Collection<IgniteInternalCache<?, ?>> cachesx(
+ @Nullable IgnitePredicate<? super IgniteInternalCache<?, ?>>... p) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean eventUserRecordable(int type) {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean allEventsUserRecordable(int[] types) {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isJmxRemoteEnabled() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isRestartEnabled() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteFileSystem igfsx(@Nullable String name) {
+ return F.eq(name, igfs.name()) ? igfs : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Hadoop hadoop() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteClusterEx cluster() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String latestVersion() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode localNode() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridKernalContext context() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteLogger log() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteConfiguration configuration() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteCompute compute() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteCompute compute(ClusterGroup grp) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteMessaging message() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteMessaging message(ClusterGroup grp) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteEvents events() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteEvents events(ClusterGroup grp) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteServices services() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteServices services(ClusterGroup grp) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ExecutorService executorService() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ExecutorService executorService(ClusterGroup grp) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteProductVersion version() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteScheduler scheduler() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String cacheName) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> void addCacheConfiguration(CacheConfiguration<K, V> cacheCfg) {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg,
+ NearCacheConfiguration<K, V> nearCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg,
+ NearCacheConfiguration<K, V> nearCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName,
+ NearCacheConfiguration<K, V> nearCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable String cacheName,
+ NearCacheConfiguration<K, V> nearCfg) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroyCache(String cacheName) {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> cache(@Nullable String name) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTransactions transactions() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> IgniteDataStreamer<K, V> dataStreamer(@Nullable String cacheName) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFileSystem fileSystem(String name) {
+ IgniteFileSystem res = igfsx(name);
+
+ if (res == null)
+ throw new IllegalArgumentException("IGFS is not configured: " + name);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgniteFileSystem> fileSystems() {
+ return Collections.singleton(igfs);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteAtomicLong atomicLong(String name, long initVal, boolean create) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal,
+ @Nullable S initStamp, boolean create) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> IgniteQueue<T> queue(String name, int cap, @Nullable CollectionConfiguration cfg)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> IgniteSet<T> set(String name, @Nullable CollectionConfiguration cfg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteBinary binary() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K> Affinity<K> affinity(String cacheName) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /**
+ * Throw {@link UnsupportedOperationException}.
+ */
+ private static void throwUnsupported() {
+ throw new UnsupportedOperationException("Should not be called!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
new file mode 100644
index 0000000..dccab4a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
@@ -0,0 +1,397 @@
+/*
+ * 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.processors.igfs;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.igfs.IgfsBlockLocation;
+import org.apache.ignite.igfs.IgfsFile;
+import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.igfs.IgfsOutputStream;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.igfs.IgfsPathSummary;
+import org.apache.ignite.igfs.mapreduce.IgfsRecordResolver;
+import org.apache.ignite.igfs.mapreduce.IgfsTask;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Mocked IGFS implementation for IGFS tests.
+ */
+public class IgfsMock implements IgfsEx {
+ /** Name. */
+ private final String name;
+
+ /**
+ * Constructor.
+ *
+ * @param name Name.
+ */
+ public IgfsMock(@Nullable String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop(boolean cancel) {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsContext context() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsPaths proxyPaths() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsInputStreamAdapter open(IgfsPath path, int bufSize, int seqReadsBeforePrefetch) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsInputStreamAdapter open(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsInputStreamAdapter open(IgfsPath path, int bufSize) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsStatus globalSpace() throws IgniteCheckedException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void globalSampling(@Nullable Boolean val) throws IgniteCheckedException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Boolean globalSampling() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsLocalMetrics localMetrics() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long groupBlockSize() {
+ throwUnsupported();
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String clientLogDirectory() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clientLogDirectory(String logDir) {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean evictExclude(IgfsPath path, boolean primary) {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid nextAffinityKey() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isProxy(URI path) {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsSecondaryFileSystem asSecondary() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public FileSystemConfiguration configuration() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsPathSummary summary(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsOutputStream create(IgfsPath path, boolean overwrite) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
+ long blockSize, @Nullable Map<String, String> props) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite, @Nullable IgniteUuid affKey,
+ int replication, long blockSize, @Nullable Map<String, String> props) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsOutputStream append(IgfsPath path, boolean create) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create,
+ @Nullable Map<String, String> props) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len, long maxLen)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsMetrics metrics() throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void resetMetrics() throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long size(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void format() throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg)
+ throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(IgfsPath path) {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsFile update(IgfsPath path, Map<String, String> props) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rename(IgfsPath src, IgfsPath dest) throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(IgfsPath path, boolean recursive) throws IgniteException {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) throws IgniteException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsPath> listPaths(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsFile> listFiles(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgfsFile info(IgfsPath path) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long usedSpaceSize() throws IgniteException {
+ throwUnsupported();
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFileSystem withAsync() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isAsync() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> future() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /**
+ * Throw {@link UnsupportedOperationException}.
+ */
+ private static void throwUnsupported() {
+ throw new UnsupportedOperationException("Should not be called!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopMapReducePlanner.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopMapReducePlanner.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopMapReducePlanner.java
index 287b5ec..d4a44fa 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopMapReducePlanner.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopMapReducePlanner.java
@@ -26,10 +26,9 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.UUID;
-import org.apache.ignite.Ignite;
+
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsPath;
@@ -38,14 +37,11 @@ import org.apache.ignite.internal.processors.hadoop.HadoopFileBlock;
import org.apache.ignite.internal.processors.hadoop.HadoopInputSplit;
import org.apache.ignite.internal.processors.hadoop.HadoopJob;
import org.apache.ignite.internal.processors.hadoop.HadoopMapReducePlan;
-import org.apache.ignite.internal.processors.hadoop.HadoopMapReducePlanner;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint;
import org.apache.ignite.internal.processors.hadoop.planner.HadoopDefaultMapReducePlan;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopAbstractMapReducePlanner;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -54,16 +50,7 @@ import static org.apache.ignite.IgniteFileSystem.IGFS_SCHEME;
/**
* Default map-reduce planner implementation.
*/
-public class IgniteHadoopMapReducePlanner implements HadoopMapReducePlanner {
- /** Injected grid. */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** Logger. */
- @SuppressWarnings("UnusedDeclaration")
- @LoggerResource
- private IgniteLogger log;
-
+public class IgniteHadoopMapReducePlanner extends HadoopAbstractMapReducePlanner {
/** {@inheritDoc} */
@Override public HadoopMapReducePlan preparePlan(HadoopJob job, Collection<ClusterNode> top,
@Nullable HadoopMapReducePlan oldPlan) throws IgniteCheckedException {
@@ -98,7 +85,7 @@ public class IgniteHadoopMapReducePlanner implements HadoopMapReducePlanner {
Iterable<HadoopInputSplit> splits) throws IgniteCheckedException {
Map<UUID, Collection<HadoopInputSplit>> mappers = new HashMap<>();
- Map<String, Collection<UUID>> nodes = hosts(top);
+ Map<String, Collection<UUID>> nodes = groupByHost(top);
Map<UUID, Integer> nodeLoads = new HashMap<>(top.size(), 1.0f); // Track node load.
@@ -129,33 +116,6 @@ public class IgniteHadoopMapReducePlanner implements HadoopMapReducePlanner {
}
/**
- * Groups nodes by host names.
- *
- * @param top Topology to group.
- * @return Map.
- */
- private static Map<String, Collection<UUID>> hosts(Collection<ClusterNode> top) {
- Map<String, Collection<UUID>> grouped = U.newHashMap(top.size());
-
- for (ClusterNode node : top) {
- for (String host : node.hostNames()) {
- Collection<UUID> nodeIds = grouped.get(host);
-
- if (nodeIds == null) {
- // Expecting 1-2 nodes per host.
- nodeIds = new ArrayList<>(2);
-
- grouped.put(host, nodeIds);
- }
-
- nodeIds.add(node.id());
- }
- }
-
- return grouped;
- }
-
- /**
* Determine the best node for this split.
*
* @param split Split.
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopWeightedMapReducePlanner.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopWeightedMapReducePlanner.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopWeightedMapReducePlanner.java
new file mode 100644
index 0000000..27ffc19
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopWeightedMapReducePlanner.java
@@ -0,0 +1,846 @@
+/*
+ * 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.hadoop.mapreduce;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.igfs.IgfsBlockLocation;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.hadoop.HadoopFileBlock;
+import org.apache.ignite.internal.processors.hadoop.HadoopInputSplit;
+import org.apache.ignite.internal.processors.hadoop.HadoopJob;
+import org.apache.ignite.internal.processors.hadoop.HadoopMapReducePlan;
+import org.apache.ignite.internal.processors.hadoop.HadoopUtils;
+import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopAbstractMapReducePlanner;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopDefaultMapReducePlan;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopMapReducePlanGroup;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopMapReducePlanTopology;
+import org.apache.ignite.internal.processors.igfs.IgfsEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Map-reduce planner which assigns mappers and reducers based on their "weights". Weight describes how much resources
+ * are required to execute particular map or reduce task.
+ * <p>
+ * Plan creation consists of two steps: assigning mappers and assigning reducers.
+ * <p>
+ * Mappers are assigned based on input split data location. For each input split we search for nodes where
+ * its data is stored. Planner tries to assign mappers to their affinity nodes first. This process is governed by two
+ * properties:
+ * <ul>
+ * <li><b>{@code localMapperWeight}</b> - weight of a map task when it is executed on an affinity node;</li>
+ * <li><b>{@code remoteMapperWeight}</b> - weight of a map task when it is executed on a non-affinity node.</li>
+ * </ul>
+ * Planning algorithm assign mappers so that total resulting weight on all nodes is minimum possible.
+ * <p>
+ * Reducers are assigned differently. First we try to distribute reducers across nodes with mappers. This approach
+ * could minimize expensive data transfer over network. Reducer assigned to a node with mapper is considered
+ * <b>{@code local}</b>. Otherwise it is considered <b>{@code remote}</b>. This process continue until certain weight
+ * threshold is reached what means that current node is already too busy and it should not have higher priority over
+ * other nodes any more. Threshold can be configured using <b>{@code preferLocalReducerThresholdWeight}</b> property.
+ * <p>
+ * When local reducer threshold is reached on all nodes, we distribute remaining reducers based on their local and
+ * remote weights in the same way as it is done for mappers. This process is governed by two
+ * properties:
+ * <ul>
+ * <li><b>{@code localReducerWeight}</b> - weight of a reduce task when it is executed on a node with mappers;</li>
+ * <li><b>{@code remoteReducerWeight}</b> - weight of a map task when it is executed on a node without mappers.</li>
+ * </ul>
+ */
+public class IgniteHadoopWeightedMapReducePlanner extends HadoopAbstractMapReducePlanner {
+ /** Default local mapper weight. */
+ public static final int DFLT_LOC_MAPPER_WEIGHT = 100;
+
+ /** Default remote mapper weight. */
+ public static final int DFLT_RMT_MAPPER_WEIGHT = 100;
+
+ /** Default local reducer weight. */
+ public static final int DFLT_LOC_REDUCER_WEIGHT = 100;
+
+ /** Default remote reducer weight. */
+ public static final int DFLT_RMT_REDUCER_WEIGHT = 100;
+
+ /** Default reducer migration threshold weight. */
+ public static final int DFLT_PREFER_LOCAL_REDUCER_THRESHOLD_WEIGHT = 200;
+
+ /** Local mapper weight. */
+ private int locMapperWeight = DFLT_LOC_MAPPER_WEIGHT;
+
+ /** Remote mapper weight. */
+ private int rmtMapperWeight = DFLT_RMT_MAPPER_WEIGHT;
+
+ /** Local reducer weight. */
+ private int locReducerWeight = DFLT_LOC_REDUCER_WEIGHT;
+
+ /** Remote reducer weight. */
+ private int rmtReducerWeight = DFLT_RMT_REDUCER_WEIGHT;
+
+ /** Reducer migration threshold weight. */
+ private int preferLocReducerThresholdWeight = DFLT_PREFER_LOCAL_REDUCER_THRESHOLD_WEIGHT;
+
+ /** {@inheritDoc} */
+ @Override public HadoopMapReducePlan preparePlan(HadoopJob job, Collection<ClusterNode> nodes,
+ @Nullable HadoopMapReducePlan oldPlan) throws IgniteCheckedException {
+ List<HadoopInputSplit> splits = HadoopUtils.sortInputSplits(job.input());
+ int reducerCnt = job.info().reducers();
+
+ if (reducerCnt < 0)
+ throw new IgniteCheckedException("Number of reducers must be non-negative, actual: " + reducerCnt);
+
+ HadoopMapReducePlanTopology top = topology(nodes);
+
+ Mappers mappers = assignMappers(splits, top);
+
+ Map<UUID, int[]> reducers = assignReducers(splits, top, mappers, reducerCnt);
+
+ return new HadoopDefaultMapReducePlan(mappers.nodeToSplits, reducers);
+ }
+
+ /**
+ * Assign mappers to nodes.
+ *
+ * @param splits Input splits.
+ * @param top Topology.
+ * @return Mappers.
+ * @throws IgniteCheckedException If failed.
+ */
+ private Mappers assignMappers(Collection<HadoopInputSplit> splits,
+ HadoopMapReducePlanTopology top) throws IgniteCheckedException {
+ Mappers res = new Mappers();
+
+ for (HadoopInputSplit split : splits) {
+ // Try getting IGFS affinity.
+ Collection<UUID> nodeIds = affinityNodesForSplit(split, top);
+
+ // Get best node.
+ UUID node = bestMapperNode(nodeIds, top);
+
+ assert node != null;
+
+ res.add(split, node);
+ }
+
+ return res;
+ }
+
+ /**
+ * Get affinity nodes for the given input split.
+ * <p>
+ * Order in the returned collection *is* significant, meaning that nodes containing more data
+ * go first. This way, the 1st nodes in the collection considered to be preferable for scheduling.
+ *
+ * @param split Split.
+ * @param top Topology.
+ * @return Affintiy nodes.
+ * @throws IgniteCheckedException If failed.
+ */
+ private Collection<UUID> affinityNodesForSplit(HadoopInputSplit split, HadoopMapReducePlanTopology top)
+ throws IgniteCheckedException {
+ Collection<UUID> igfsNodeIds = igfsAffinityNodesForSplit(split);
+
+ if (igfsNodeIds != null)
+ return igfsNodeIds;
+
+ Map<NodeIdAndLength, UUID> res = new TreeMap<>();
+
+ for (String host : split.hosts()) {
+ long len = split instanceof HadoopFileBlock ? ((HadoopFileBlock)split).length() : 0L;
+
+ HadoopMapReducePlanGroup grp = top.groupForHost(host);
+
+ if (grp != null) {
+ for (int i = 0; i < grp.nodeCount(); i++) {
+ UUID nodeId = grp.nodeId(i);
+
+ res.put(new NodeIdAndLength(nodeId, len), nodeId);
+ }
+ }
+ }
+
+ return new LinkedHashSet<>(res.values());
+ }
+
+ /**
+ * Get IGFS affinity nodes for split if possible.
+ * <p>
+ * Order in the returned collection *is* significant, meaning that nodes containing more data
+ * go first. This way, the 1st nodes in the collection considered to be preferable for scheduling.
+ *
+ * @param split Input split.
+ * @return IGFS affinity or {@code null} if IGFS is not available.
+ * @throws IgniteCheckedException If failed.
+ */
+ @Nullable private Collection<UUID> igfsAffinityNodesForSplit(HadoopInputSplit split) throws IgniteCheckedException {
+ if (split instanceof HadoopFileBlock) {
+ HadoopFileBlock split0 = (HadoopFileBlock)split;
+
+ if (IgniteFileSystem.IGFS_SCHEME.equalsIgnoreCase(split0.file().getScheme())) {
+ HadoopIgfsEndpoint endpoint = new HadoopIgfsEndpoint(split0.file().getAuthority());
+
+ IgfsEx igfs = null;
+
+ if (F.eq(ignite.name(), endpoint.grid()))
+ igfs = (IgfsEx)((IgniteEx)ignite).igfsx(endpoint.igfs());
+
+ if (igfs != null && !igfs.isProxy(split0.file())) {
+ IgfsPath path = new IgfsPath(split0.file());
+
+ if (igfs.exists(path)) {
+ Collection<IgfsBlockLocation> blocks;
+
+ try {
+ blocks = igfs.affinity(path, split0.start(), split0.length());
+ }
+ catch (IgniteException e) {
+ throw new IgniteCheckedException("Failed to get IGFS file block affinity [path=" + path +
+ ", start=" + split0.start() + ", len=" + split0.length() + ']', e);
+ }
+
+ assert blocks != null;
+
+ if (blocks.size() == 1)
+ return blocks.iterator().next().nodeIds();
+ else {
+ // The most "local" nodes go first.
+ Map<UUID, Long> idToLen = new HashMap<>();
+
+ for (IgfsBlockLocation block : blocks) {
+ for (UUID id : block.nodeIds()) {
+ Long len = idToLen.get(id);
+
+ idToLen.put(id, len == null ? block.length() : block.length() + len);
+ }
+ }
+
+ // Sort the nodes in non-ascending order by contained data lengths.
+ Map<NodeIdAndLength, UUID> res = new TreeMap<>();
+
+ for (Map.Entry<UUID, Long> idToLenEntry : idToLen.entrySet()) {
+ UUID id = idToLenEntry.getKey();
+
+ res.put(new NodeIdAndLength(id, idToLenEntry.getValue()), id);
+ }
+
+ return new LinkedHashSet<>(res.values());
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Find best mapper node.
+ *
+ * @param affIds Affinity node IDs.
+ * @param top Topology.
+ * @return Result.
+ */
+ private UUID bestMapperNode(@Nullable Collection<UUID> affIds, HadoopMapReducePlanTopology top) {
+ // Priority node.
+ UUID prioAffId = F.first(affIds);
+
+ // Find group with the least weight.
+ HadoopMapReducePlanGroup resGrp = null;
+ MapperPriority resPrio = MapperPriority.NORMAL;
+ int resWeight = Integer.MAX_VALUE;
+
+ for (HadoopMapReducePlanGroup grp : top.groups()) {
+ MapperPriority prio = groupPriority(grp, affIds, prioAffId);
+
+ int weight = grp.weight() + (prio == MapperPriority.NORMAL ? rmtMapperWeight : locMapperWeight);
+
+ if (resGrp == null || weight < resWeight || weight == resWeight && prio.value() > resPrio.value()) {
+ resGrp = grp;
+ resPrio = prio;
+ resWeight = weight;
+ }
+ }
+
+ assert resGrp != null;
+
+ // Update group weight for further runs.
+ resGrp.weight(resWeight);
+
+ // Return the best node from the group.
+ return bestMapperNodeForGroup(resGrp, resPrio, affIds, prioAffId);
+ }
+
+ /**
+ * Get best node in the group.
+ *
+ * @param grp Group.
+ * @param priority Priority.
+ * @param affIds Affinity IDs.
+ * @param prioAffId Priority affinity IDs.
+ * @return Best node ID in the group.
+ */
+ private static UUID bestMapperNodeForGroup(HadoopMapReducePlanGroup grp, MapperPriority priority,
+ @Nullable Collection<UUID> affIds, @Nullable UUID prioAffId) {
+ // Return the best node from the group.
+ int idx = 0;
+
+ // This is rare situation when several nodes are started on the same host.
+ if (!grp.single()) {
+ switch (priority) {
+ case NORMAL: {
+ // Pick any node.
+ idx = ThreadLocalRandom.current().nextInt(grp.nodeCount());
+
+ break;
+ }
+ case HIGH: {
+ // Pick any affinity node.
+ assert affIds != null;
+
+ List<Integer> cands = new ArrayList<>();
+
+ for (int i = 0; i < grp.nodeCount(); i++) {
+ UUID id = grp.nodeId(i);
+
+ if (affIds.contains(id))
+ cands.add(i);
+ }
+
+ idx = cands.get(ThreadLocalRandom.current().nextInt(cands.size()));
+
+ break;
+ }
+ default: {
+ // Find primary node.
+ assert prioAffId != null;
+
+ for (int i = 0; i < grp.nodeCount(); i++) {
+ UUID id = grp.nodeId(i);
+
+ if (F.eq(id, prioAffId)) {
+ idx = i;
+
+ break;
+ }
+ }
+
+ assert priority == MapperPriority.HIGHEST;
+ }
+ }
+ }
+
+ return grp.nodeId(idx);
+ }
+
+ /**
+ * Generate reducers.
+ *
+ * @param splits Input splits.
+ * @param top Topology.
+ * @param mappers Mappers.
+ * @param reducerCnt Reducer count.
+ * @return Reducers.
+ */
+ private Map<UUID, int[]> assignReducers(Collection<HadoopInputSplit> splits, HadoopMapReducePlanTopology top,
+ Mappers mappers, int reducerCnt) {
+ Map<UUID, Integer> reducers = assignReducers0(top, splits, mappers, reducerCnt);
+
+ int cnt = 0;
+
+ Map<UUID, int[]> res = new HashMap<>(reducers.size());
+
+ for (Map.Entry<UUID, Integer> reducerEntry : reducers.entrySet()) {
+ int[] arr = new int[reducerEntry.getValue()];
+
+ for (int i = 0; i < arr.length; i++)
+ arr[i] = cnt++;
+
+ res.put(reducerEntry.getKey(), arr);
+ }
+
+ assert reducerCnt == cnt : reducerCnt + " != " + cnt;
+
+ return res;
+ }
+
+ /**
+ * Generate reducers.
+ *
+ * @param top Topology.
+ * @param splits Input splits.
+ * @param mappers Mappers.
+ * @param reducerCnt Reducer count.
+ * @return Reducers.
+ */
+ private Map<UUID, Integer> assignReducers0(HadoopMapReducePlanTopology top, Collection<HadoopInputSplit> splits,
+ Mappers mappers, int reducerCnt) {
+ Map<UUID, Integer> res = new HashMap<>();
+
+ // Assign reducers to splits.
+ Map<HadoopInputSplit, Integer> splitToReducerCnt = assignReducersToSplits(splits, reducerCnt);
+
+ // Assign as much local reducers as possible.
+ int remaining = 0;
+
+ for (Map.Entry<HadoopInputSplit, Integer> entry : splitToReducerCnt.entrySet()) {
+ HadoopInputSplit split = entry.getKey();
+ int cnt = entry.getValue();
+
+ if (cnt > 0) {
+ int assigned = assignLocalReducers(split, cnt, top, mappers, res);
+
+ assert assigned <= cnt;
+
+ remaining += cnt - assigned;
+ }
+ }
+
+ // Assign the rest reducers.
+ if (remaining > 0)
+ assignRemoteReducers(remaining, top, mappers, res);
+
+ return res;
+ }
+
+ /**
+ * Assign local split reducers.
+ *
+ * @param split Split.
+ * @param cnt Reducer count.
+ * @param top Topology.
+ * @param mappers Mappers.
+ * @param resMap Reducers result map.
+ * @return Number of locally assigned reducers.
+ */
+ private int assignLocalReducers(HadoopInputSplit split, int cnt, HadoopMapReducePlanTopology top, Mappers mappers,
+ Map<UUID, Integer> resMap) {
+ // Dereference node.
+ UUID nodeId = mappers.splitToNode.get(split);
+
+ assert nodeId != null;
+
+ // Dereference group.
+ HadoopMapReducePlanGroup grp = top.groupForId(nodeId);
+
+ assert grp != null;
+
+ // Assign more reducers to the node until threshold is reached.
+ int res = 0;
+
+ while (res < cnt && grp.weight() < preferLocReducerThresholdWeight) {
+ res++;
+
+ grp.weight(grp.weight() + locReducerWeight);
+ }
+
+ // Update result map.
+ if (res > 0) {
+ Integer reducerCnt = resMap.get(nodeId);
+
+ resMap.put(nodeId, reducerCnt == null ? res : reducerCnt + res);
+ }
+
+ return res;
+ }
+
+ /**
+ * Assign remote reducers. Assign to the least loaded first.
+ *
+ * @param cnt Count.
+ * @param top Topology.
+ * @param mappers Mappers.
+ * @param resMap Reducers result map.
+ */
+ private void assignRemoteReducers(int cnt, HadoopMapReducePlanTopology top, Mappers mappers,
+ Map<UUID, Integer> resMap) {
+
+ TreeSet<HadoopMapReducePlanGroup> set = new TreeSet<>(new GroupWeightComparator());
+
+ set.addAll(top.groups());
+
+ while (cnt-- > 0) {
+ // The least loaded machine.
+ HadoopMapReducePlanGroup grp = set.first();
+
+ // Look for nodes with assigned splits.
+ List<UUID> splitNodeIds = null;
+
+ for (int i = 0; i < grp.nodeCount(); i++) {
+ UUID nodeId = grp.nodeId(i);
+
+ if (mappers.nodeToSplits.containsKey(nodeId)) {
+ if (splitNodeIds == null)
+ splitNodeIds = new ArrayList<>(2);
+
+ splitNodeIds.add(nodeId);
+ }
+ }
+
+ // Select best node.
+ UUID id;
+ int newWeight;
+
+ if (splitNodeIds != null) {
+ id = splitNodeIds.get(ThreadLocalRandom.current().nextInt(splitNodeIds.size()));
+
+ newWeight = grp.weight() + locReducerWeight;
+ }
+ else {
+ id = grp.nodeId(ThreadLocalRandom.current().nextInt(grp.nodeCount()));
+
+ newWeight = grp.weight() + rmtReducerWeight;
+ }
+
+ // Re-add entry with new weight.
+ boolean rmv = set.remove(grp);
+
+ assert rmv;
+
+ grp.weight(newWeight);
+
+ boolean add = set.add(grp);
+
+ assert add;
+
+ // Update result map.
+ Integer res = resMap.get(id);
+
+ resMap.put(id, res == null ? 1 : res + 1);
+ }
+ }
+
+ /**
+ * Comparator based on group's weight.
+ */
+ private static class GroupWeightComparator implements Comparator<HadoopMapReducePlanGroup> {
+ /** {@inheritDoc} */
+ @Override public int compare(HadoopMapReducePlanGroup first, HadoopMapReducePlanGroup second) {
+ int res = first.weight() - second.weight();
+
+ if (res < 0)
+ return -1;
+ else if (res > 0)
+ return 1;
+ else
+ return first.macs().compareTo(second.macs());
+ }
+ }
+
+ /**
+ * Distribute reducers between splits.
+ *
+ * @param splits Splits.
+ * @param reducerCnt Reducer count.
+ * @return Map from input split to reducer count.
+ */
+ private Map<HadoopInputSplit, Integer> assignReducersToSplits(Collection<HadoopInputSplit> splits,
+ int reducerCnt) {
+ Map<HadoopInputSplit, Integer> res = new IdentityHashMap<>(splits.size());
+
+ int base = reducerCnt / splits.size();
+ int remainder = reducerCnt % splits.size();
+
+ for (HadoopInputSplit split : splits) {
+ int val = base;
+
+ if (remainder > 0) {
+ val++;
+
+ remainder--;
+ }
+
+ res.put(split, val);
+ }
+
+ assert remainder == 0;
+
+ return res;
+ }
+
+ /**
+ * Calculate group priority.
+ *
+ * @param grp Group.
+ * @param affIds Affinity IDs.
+ * @param prioAffId Priority affinity ID.
+ * @return Group priority.
+ */
+ private static MapperPriority groupPriority(HadoopMapReducePlanGroup grp, @Nullable Collection<UUID> affIds,
+ @Nullable UUID prioAffId) {
+ assert F.isEmpty(affIds) ? prioAffId == null : prioAffId == F.first(affIds);
+ assert grp != null;
+
+ MapperPriority prio = MapperPriority.NORMAL;
+
+ if (!F.isEmpty(affIds)) {
+ for (int i = 0; i < grp.nodeCount(); i++) {
+ UUID id = grp.nodeId(i);
+
+ if (affIds.contains(id)) {
+ prio = MapperPriority.HIGH;
+
+ if (F.eq(prioAffId, id)) {
+ prio = MapperPriority.HIGHEST;
+
+ break;
+ }
+ }
+ }
+ }
+
+ return prio;
+ }
+
+ /**
+ * Get local mapper weight. This weight is added to a node when a mapper is assigned and it's input split data is
+ * located on this node (at least partially).
+ * <p>
+ * Defaults to {@link #DFLT_LOC_MAPPER_WEIGHT}.
+ *
+ * @return Remote mapper weight.
+ */
+ public int getLocalMapperWeight() {
+ return locMapperWeight;
+ }
+
+ /**
+ * Set local mapper weight. See {@link #getLocalMapperWeight()} for more information.
+ *
+ * @param locMapperWeight Local mapper weight.
+ */
+ public void setLocalMapperWeight(int locMapperWeight) {
+ this.locMapperWeight = locMapperWeight;
+ }
+
+ /**
+ * Get remote mapper weight. This weight is added to a node when a mapper is assigned, but it's input
+ * split data is not located on this node.
+ * <p>
+ * Defaults to {@link #DFLT_RMT_MAPPER_WEIGHT}.
+ *
+ * @return Remote mapper weight.
+ */
+ public int getRemoteMapperWeight() {
+ return rmtMapperWeight;
+ }
+
+ /**
+ * Set remote mapper weight. See {@link #getRemoteMapperWeight()} for more information.
+ *
+ * @param rmtMapperWeight Remote mapper weight.
+ */
+ public void setRemoteMapperWeight(int rmtMapperWeight) {
+ this.rmtMapperWeight = rmtMapperWeight;
+ }
+
+ /**
+ * Get local reducer weight. This weight is added to a node when a reducer is assigned and the node have at least
+ * one assigned mapper.
+ * <p>
+ * Defaults to {@link #DFLT_LOC_REDUCER_WEIGHT}.
+ *
+ * @return Local reducer weight.
+ */
+ public int getLocalReducerWeight() {
+ return locReducerWeight;
+ }
+
+ /**
+ * Set local reducer weight. See {@link #getLocalReducerWeight()} for more information.
+ *
+ * @param locReducerWeight Local reducer weight.
+ */
+ public void setLocalReducerWeight(int locReducerWeight) {
+ this.locReducerWeight = locReducerWeight;
+ }
+
+ /**
+ * Get remote reducer weight. This weight is added to a node when a reducer is assigned, but the node doesn't have
+ * any assigned mappers.
+ * <p>
+ * Defaults to {@link #DFLT_RMT_REDUCER_WEIGHT}.
+ *
+ * @return Remote reducer weight.
+ */
+ public int getRemoteReducerWeight() {
+ return rmtReducerWeight;
+ }
+
+ /**
+ * Set remote reducer weight. See {@link #getRemoteReducerWeight()} for more information.
+ *
+ * @param rmtReducerWeight Remote reducer weight.
+ */
+ public void setRemoteReducerWeight(int rmtReducerWeight) {
+ this.rmtReducerWeight = rmtReducerWeight;
+ }
+
+ /**
+ * Get reducer migration threshold weight. When threshold is reached, a node with mappers is no longer considered
+ * as preferred for further reducer assignments.
+ * <p>
+ * Defaults to {@link #DFLT_PREFER_LOCAL_REDUCER_THRESHOLD_WEIGHT}.
+ *
+ * @return Reducer migration threshold weight.
+ */
+ public int getPreferLocalReducerThresholdWeight() {
+ return preferLocReducerThresholdWeight;
+ }
+
+ /**
+ * Set reducer migration threshold weight. See {@link #getPreferLocalReducerThresholdWeight()} for more
+ * information.
+ *
+ * @param reducerMigrationThresholdWeight Reducer migration threshold weight.
+ */
+ public void setPreferLocalReducerThresholdWeight(int reducerMigrationThresholdWeight) {
+ this.preferLocReducerThresholdWeight = reducerMigrationThresholdWeight;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgniteHadoopWeightedMapReducePlanner.class, this);
+ }
+
+ /**
+ * Node ID and length.
+ */
+ private static class NodeIdAndLength implements Comparable<NodeIdAndLength> {
+ /** Node ID. */
+ private final UUID id;
+
+ /** Length. */
+ private final long len;
+
+ /**
+ * Constructor.
+ *
+ * @param id Node ID.
+ * @param len Length.
+ */
+ public NodeIdAndLength(UUID id, long len) {
+ this.id = id;
+ this.len = len;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("NullableProblems")
+ @Override public int compareTo(NodeIdAndLength obj) {
+ long res = len - obj.len;
+
+ if (res > 0)
+ return -1;
+ else if (res < 0)
+ return 1;
+ else
+ return id.compareTo(obj.id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ return obj instanceof NodeIdAndLength && F.eq(id, ((NodeIdAndLength)obj).id);
+ }
+ }
+
+ /**
+ * Mappers.
+ */
+ private static class Mappers {
+ /** Node-to-splits map. */
+ private final Map<UUID, Collection<HadoopInputSplit>> nodeToSplits = new HashMap<>();
+
+ /** Split-to-node map. */
+ private final Map<HadoopInputSplit, UUID> splitToNode = new IdentityHashMap<>();
+
+ /**
+ * Add mapping.
+ *
+ * @param split Split.
+ * @param node Node.
+ */
+ public void add(HadoopInputSplit split, UUID node) {
+ Collection<HadoopInputSplit> nodeSplits = nodeToSplits.get(node);
+
+ if (nodeSplits == null) {
+ nodeSplits = new HashSet<>();
+
+ nodeToSplits.put(node, nodeSplits);
+ }
+
+ nodeSplits.add(split);
+
+ splitToNode.put(split, node);
+ }
+ }
+
+ /**
+ * Mapper priority enumeration.
+ */
+ private enum MapperPriority {
+ /** Normal node. */
+ NORMAL(0),
+
+ /** (likely) Affinity node. */
+ HIGH(1),
+
+ /** (likely) Affinity node with the highest priority (e.g. because it hosts more data than other nodes). */
+ HIGHEST(2);
+
+ /** Value. */
+ private final int val;
+
+ /**
+ * Constructor.
+ *
+ * @param val Value.
+ */
+ MapperPriority(int val) {
+ this.val = val;
+ }
+
+ /**
+ * @return Value.
+ */
+ public int value() {
+ return val;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopUtils.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopUtils.java
index 3fa963f..44d871a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopUtils.java
@@ -25,8 +25,12 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.TreeSet;
import java.util.UUID;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -352,4 +356,81 @@ public class HadoopUtils {
}
}
+ /**
+ * Sort input splits by length.
+ *
+ * @param splits Splits.
+ * @return Sorted splits.
+ */
+ public static List<HadoopInputSplit> sortInputSplits(Collection<HadoopInputSplit> splits) {
+ int id = 0;
+
+ TreeSet<SplitSortWrapper> sortedSplits = new TreeSet<>();
+
+ for (HadoopInputSplit split : splits) {
+ long len = split instanceof HadoopFileBlock ? ((HadoopFileBlock)split).length() : 0;
+
+ sortedSplits.add(new SplitSortWrapper(id++, split, len));
+ }
+
+ ArrayList<HadoopInputSplit> res = new ArrayList<>(sortedSplits.size());
+
+ for (SplitSortWrapper sortedSplit : sortedSplits)
+ res.add(sortedSplit.split);
+
+ return res;
+ }
+
+ /**
+ * Split wrapper for sorting.
+ */
+ private static class SplitSortWrapper implements Comparable<SplitSortWrapper> {
+ /** Unique ID. */
+ private final int id;
+
+ /** Split. */
+ private final HadoopInputSplit split;
+
+ /** Split length. */
+ private final long len;
+
+ /**
+ * Constructor.
+ *
+ * @param id Unique ID.
+ * @param split Split.
+ * @param len Split length.
+ */
+ public SplitSortWrapper(int id, HadoopInputSplit split, long len) {
+ this.id = id;
+ this.split = split;
+ this.len = len;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("NullableProblems")
+ @Override public int compareTo(SplitSortWrapper other) {
+ assert other != null;
+
+ long res = len - other.len;
+
+ if (res > 0)
+ return -1;
+ else if (res < 0)
+ return 1;
+ else
+ return id - other.id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ return obj instanceof SplitSortWrapper && id == ((SplitSortWrapper)obj).id;
+ }
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopAbstractMapReducePlanner.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopAbstractMapReducePlanner.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopAbstractMapReducePlanner.java
new file mode 100644
index 0000000..f01f72b
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopAbstractMapReducePlanner.java
@@ -0,0 +1,116 @@
+/*
+ * 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.processors.hadoop.planner;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.processors.hadoop.HadoopMapReducePlanner;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+
+/**
+ * Base class for map-reduce planners.
+ */
+public abstract class HadoopAbstractMapReducePlanner implements HadoopMapReducePlanner {
+ /** Injected grid. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Logger. */
+ @SuppressWarnings("UnusedDeclaration")
+ @LoggerResource
+ protected IgniteLogger log;
+
+ /**
+ * Create plan topology.
+ *
+ * @param nodes Topology nodes.
+ * @return Plan topology.
+ */
+ protected static HadoopMapReducePlanTopology topology(Collection<ClusterNode> nodes) {
+ Map<String, HadoopMapReducePlanGroup> macsMap = new HashMap<>(nodes.size());
+
+ Map<UUID, HadoopMapReducePlanGroup> idToGrp = new HashMap<>(nodes.size());
+ Map<String, HadoopMapReducePlanGroup> hostToGrp = new HashMap<>(nodes.size());
+
+ for (ClusterNode node : nodes) {
+ String macs = node.attribute(ATTR_MACS);
+
+ HadoopMapReducePlanGroup grp = macsMap.get(macs);
+
+ if (grp == null) {
+ grp = new HadoopMapReducePlanGroup(node, macs);
+
+ macsMap.put(macs, grp);
+ }
+ else
+ grp.add(node);
+
+ idToGrp.put(node.id(), grp);
+
+ for (String host : node.addresses()) {
+ HadoopMapReducePlanGroup hostGrp = hostToGrp.get(host);
+
+ if (hostGrp == null)
+ hostToGrp.put(host, grp);
+ else
+ assert hostGrp == grp;
+ }
+ }
+
+ return new HadoopMapReducePlanTopology(new ArrayList<>(macsMap.values()), idToGrp, hostToGrp);
+ }
+
+
+ /**
+ * Groups nodes by host names.
+ *
+ * @param top Topology to group.
+ * @return Map.
+ */
+ protected static Map<String, Collection<UUID>> groupByHost(Collection<ClusterNode> top) {
+ Map<String, Collection<UUID>> grouped = U.newHashMap(top.size());
+
+ for (ClusterNode node : top) {
+ for (String host : node.hostNames()) {
+ Collection<UUID> nodeIds = grouped.get(host);
+
+ if (nodeIds == null) {
+ // Expecting 1-2 nodes per host.
+ nodeIds = new ArrayList<>(2);
+
+ grouped.put(host, nodeIds);
+ }
+
+ nodeIds.add(node.id());
+ }
+ }
+
+ return grouped;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanGroup.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanGroup.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanGroup.java
new file mode 100644
index 0000000..2fe8682
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanGroup.java
@@ -0,0 +1,150 @@
+/*
+ * 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.processors.hadoop.planner;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.util.ArrayList;
+import java.util.UUID;
+
+/**
+ * Map-reduce plan group of nodes on a single physical machine.
+ */
+public class HadoopMapReducePlanGroup {
+ /** Node. */
+ private ClusterNode node;
+
+ /** Nodes. */
+ private ArrayList<ClusterNode> nodes;
+
+ /** MAC addresses. */
+ private final String macs;
+
+ /** Weight. */
+ private int weight;
+
+ /**
+ * Constructor.
+ *
+ * @param node First node in the group.
+ * @param macs MAC addresses.
+ */
+ public HadoopMapReducePlanGroup(ClusterNode node, String macs) {
+ assert node != null;
+ assert macs != null;
+
+ this.node = node;
+ this.macs = macs;
+ }
+
+ /**
+ * Add node to the group.
+ *
+ * @param newNode New node.
+ */
+ public void add(ClusterNode newNode) {
+ if (node != null) {
+ nodes = new ArrayList<>(2);
+
+ nodes.add(node);
+
+ node = null;
+ }
+
+ nodes.add(newNode);
+ }
+
+ /**
+ * @return MAC addresses.
+ */
+ public String macs() {
+ return macs;
+ }
+
+ /**
+ * @return {@code True} if only sinle node present.
+ */
+ public boolean single() {
+ return nodeCount() == 1;
+ }
+
+ /**
+ * Get node ID by index.
+ *
+ * @param idx Index.
+ * @return Node.
+ */
+ public UUID nodeId(int idx) {
+ ClusterNode res;
+
+ if (node != null) {
+ assert idx == 0;
+
+ res = node;
+ }
+ else {
+ assert nodes != null;
+ assert idx < nodes.size();
+
+ res = nodes.get(idx);
+ }
+
+ assert res != null;
+
+ return res.id();
+ }
+
+ /**
+ * @return Node count.
+ */
+ public int nodeCount() {
+ return node != null ? 1 : nodes.size();
+ }
+
+ /**
+ * @return weight.
+ */
+ public int weight() {
+ return weight;
+ }
+
+ /**
+ * @param weight weight.
+ */
+ public void weight(int weight) {
+ this.weight = weight;
+ }
+
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return macs.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ return obj instanceof HadoopMapReducePlanGroup && F.eq(macs, ((HadoopMapReducePlanGroup)obj).macs);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HadoopMapReducePlanGroup.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanTopology.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanTopology.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanTopology.java
new file mode 100644
index 0000000..fa5c469
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/planner/HadoopMapReducePlanTopology.java
@@ -0,0 +1,89 @@
+/*
+ * 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.processors.hadoop.planner;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Map-reduce plan topology.
+ */
+public class HadoopMapReducePlanTopology {
+ /** All groups. */
+ private final List<HadoopMapReducePlanGroup> grps;
+
+ /** Node ID to group map. */
+ private final Map<UUID, HadoopMapReducePlanGroup> idToGrp;
+
+ /** Host to group map. */
+ private final Map<String, HadoopMapReducePlanGroup> hostToGrp;
+
+ /**
+ * Constructor.
+ *
+ * @param grps All groups.
+ * @param idToGrp ID to group map.
+ * @param hostToGrp Host to group map.
+ */
+ public HadoopMapReducePlanTopology(List<HadoopMapReducePlanGroup> grps,
+ Map<UUID, HadoopMapReducePlanGroup> idToGrp, Map<String, HadoopMapReducePlanGroup> hostToGrp) {
+ assert grps != null;
+ assert idToGrp != null;
+ assert hostToGrp != null;
+
+ this.grps = grps;
+ this.idToGrp = idToGrp;
+ this.hostToGrp = hostToGrp;
+ }
+
+ /**
+ * @return All groups.
+ */
+ public List<HadoopMapReducePlanGroup> groups() {
+ return grps;
+ }
+
+ /**
+ * Get group for node ID.
+ *
+ * @param id Node ID.
+ * @return Group.
+ */
+ public HadoopMapReducePlanGroup groupForId(UUID id) {
+ return idToGrp.get(id);
+ }
+
+ /**
+ * Get group for host.
+ *
+ * @param host Host.
+ * @return Group.
+ */
+ @Nullable public HadoopMapReducePlanGroup groupForHost(String host) {
+ return hostToGrp.get(host);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HadoopMapReducePlanTopology.class, this);
+ }
+}
[31/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
IGNITE-2649 - Ignition.localIgnite() unreliable under Gateways and cause wrong components deserialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/63210e6d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/63210e6d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/63210e6d
Branch: refs/heads/ignite-2649
Commit: 63210e6d540604915371c35ca66d69339bb37370
Parents: 97ce8fb
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Aug 3 17:51:10 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Aug 3 17:51:10 2016 +0300
----------------------------------------------------------------------
.../socket/WordsSocketStreamerServer.java | 2 +-
.../rest/protocols/tcp/MockNioSession.java | 2 +-
.../rendezvous/RendezvousAffinityFunction.java | 2 +-
.../cache/store/jdbc/CacheJdbcBlobStore.java | 4 +-
.../org/apache/ignite/internal/IgnitionEx.java | 10 +-
.../internal/binary/BinaryEnumObjectImpl.java | 2 +-
.../internal/binary/BinaryObjectImpl.java | 17 +-
.../internal/binary/BinaryReaderExImpl.java | 25 ++
.../internal/binary/BinaryWriterExImpl.java | 21 +-
.../connection/GridClientNioTcpConnection.java | 2 +-
.../router/impl/GridTcpRouterNioParser.java | 2 +-
.../jdbc/GridCacheQueryJdbcMetadataTask.java | 4 +-
.../query/jdbc/GridCacheQueryJdbcTask.java | 6 +-
.../rest/protocols/tcp/GridTcpRestParser.java | 30 +-
.../internal/util/ipc/IpcToNioAdapter.java | 6 +-
.../ignite/internal/util/nio/GridNioServer.java | 6 +-
.../internal/util/nio/GridNioSession.java | 4 +-
.../internal/util/nio/GridNioSessionImpl.java | 14 +-
.../util/nio/GridSelectorNioSessionImpl.java | 6 +-
.../ignite/marshaller/MarshallerUtils.java | 37 ---
.../communication/tcp/TcpCommunicationSpi.java | 2 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 26 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 4 +-
.../TcpDiscoveryMulticastIpFinder.java | 31 +-
.../TcpDiscoveryCustomEventMessage.java | 12 +-
.../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +-
.../stream/socket/SocketMessageConverter.java | 6 +-
.../ignite/stream/socket/SocketStreamer.java | 6 +-
.../GridBinaryCacheSerializationTest.java | 299 +++++++++++++++++--
.../nio/impl/GridNioFilterChainSelfTest.java | 2 +-
.../stream/socket/SocketStreamerSelfTest.java | 4 +-
.../HadoopExternalCommunication.java | 5 +-
.../communication/HadoopIpcToNioAdapter.java | 6 +-
.../communication/HadoopMarshallerFilter.java | 4 +-
.../cache/websession/WebSessionFilter.java | 8 +-
.../ignite/cache/websession/WebSessionV2.java | 13 +-
37 files changed, 439 insertions(+), 199 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
index c1727a55..a9eef7f 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
@@ -100,7 +100,7 @@ public class WordsSocketStreamerServer {
// Converter from zero-terminated string to Java strings.
sockStmr.setConverter(new SocketMessageConverter<String>() {
- @Override public String convert(byte[] msg, IgniteConfiguration cfg) {
+ @Override public String convert(byte[] msg, String gridName) {
try {
return new String(msg, "ASCII");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
index e4efc78..737f5a9 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
@@ -143,7 +143,7 @@ public class MockNioSession extends GridMetadataAwareAdapter implements GridNioS
}
/** {@inheritDoc} */
- @Override public IgniteConfiguration igniteConfiguration() {
+ @Override public String gridName() {
return null;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 8a84e9f..b60d806 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -338,7 +338,7 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] nodeHashBytes = MarshallerUtils.marshal(
- ignite.configuration().getMarshaller(), nodeHash, ignite.configuration());
+ ignite.configuration().getMarshaller(), nodeHash, ignite.name());
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
out.write(nodeHashBytes, 0, nodeHashBytes.length); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
index d34adda..e641736 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -561,7 +561,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
* @throws IgniteCheckedException If failed to convert.
*/
protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return MarshallerUtils.marshal(marsh, obj, ignite.configuration());
+ return MarshallerUtils.marshal(marsh, obj, ignite.name());
}
/**
@@ -576,7 +576,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
if (bytes == null || bytes.length == 0)
return null;
- return MarshallerUtils.unmarshal(marsh, bytes, getClass().getClassLoader(), ignite.configuration());
+ return MarshallerUtils.unmarshal(marsh, bytes, getClass().getClassLoader(), ignite.name());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 8f882ef..fe9dab0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1289,12 +1289,16 @@ public class IgnitionEx {
* @throws IllegalArgumentException Thrown to indicate, that current thread is not an {@link IgniteThread}.
*/
public static IgniteKernal localIgnite() throws IllegalArgumentException {
- if (GRID_NAME_THREAD_LOC.get() != null)
- return gridx(GRID_NAME_THREAD_LOC.get());
+ final String gridName = GRID_NAME_THREAD_LOC.get();
+
+ // TODO support null!!
+
+ if (gridName != null)
+ return gridx(gridName);
else if (Thread.currentThread() instanceof IgniteThread)
return gridx(((IgniteThread)Thread.currentThread()).getGridName());
else
- throw new IllegalArgumentException("Ignite conf thread local must be set or" +
+ throw new IllegalArgumentException("Ignite grid name thread local must be set or" +
" this method should be accessed under " + IgniteThread.class.getName());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index 489220e..aa415eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -244,7 +244,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectContext cacheCtx) throws IgniteCheckedException {
- return MarshallerUtils.marshal(ctx.marshaller(), this, ctx.configuration());
+ return MarshallerUtils.marshal(ctx.marshaller(), this, ctx.configuration().getGridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index 2296a3d..047bcac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -21,7 +21,6 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
import org.apache.ignite.internal.IgnitionEx;
@@ -540,18 +539,8 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
* @return Object.
*/
private Object deserializeValue(@Nullable CacheObjectContext coCtx) {
- final String gridName = IgnitionEx.getGridNameThreadLocal();
-
- final ClassLoader cl;
-
- if (coCtx != null) {
- IgnitionEx.setGridNameThreadLocal(coCtx.kernalContext().config().getGridName());
-
- cl = coCtx.kernalContext().config().getClassLoader();
- } else
- cl = ctx.configuration().getClassLoader();
-
- final BinaryReaderExImpl reader = reader(null, cl);
+ BinaryReaderExImpl reader = reader(null,
+ coCtx != null ? coCtx.kernalContext().config().getClassLoader() : ctx.configuration().getClassLoader());
Object obj0 = reader.deserialize();
@@ -562,8 +551,6 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
if (coCtx != null && coCtx.storeValue())
obj = obj0;
- IgnitionEx.setGridNameThreadLocal(gridName);
-
return obj0;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 9e7a1b3..44cf85e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -33,6 +33,7 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.jetbrains.annotations.NotNull;
@@ -1420,6 +1421,23 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
* @throws BinaryObjectException If failed.
*/
@Nullable Object deserialize() throws BinaryObjectException {
+ final String gridName = IgnitionEx.getGridNameThreadLocal();
+
+ try {
+ IgnitionEx.setGridNameThreadLocal(ctx.configuration().getGridName());
+
+ return deserialize0();
+ }
+ finally {
+ IgnitionEx.setGridNameThreadLocal(gridName);
+ }
+ }
+
+ /**
+ * @return Deserialized object.
+ * @throws BinaryObjectException If failed.
+ */
+ @Nullable private Object deserialize0() throws BinaryObjectException {
Object obj;
byte flag = in.readByte();
@@ -2028,6 +2046,13 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
}
/**
+ * @return Binary context.
+ */
+ public BinaryContext context() {
+ return ctx;
+ }
+
+ /**
* Flag.
*/
private enum Flag {
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index fab379a..9bf7ecb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -33,6 +33,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -139,6 +140,24 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
void marshal(Object obj, boolean enableReplace) throws BinaryObjectException {
+ final String gridName = IgnitionEx.getGridNameThreadLocal();
+
+ try {
+ IgnitionEx.setGridNameThreadLocal(ctx.configuration().getGridName());
+
+ marshal0(obj, enableReplace);
+ }
+ finally {
+ IgnitionEx.setGridNameThreadLocal(gridName);
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param enableReplace Object replacing enabled flag.
+ * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ */
+ private void marshal0(Object obj, boolean enableReplace) throws BinaryObjectException {
assert obj != null;
Class<?> cls = obj.getClass();
@@ -158,7 +177,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
out.writeByte(GridBinaryMarshaller.OPTM_MARSH);
try {
- byte[] arr = MarshallerUtils.marshal(ctx.optimizedMarsh(), obj, ctx.configuration());
+ byte[] arr = MarshallerUtils.marshal(ctx.optimizedMarsh(), obj, ctx.configuration().getGridName());
writeInt(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
index c91f085..579d185 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
@@ -541,7 +541,7 @@ public class GridClientNioTcpConnection extends GridClientConnection {
if (res instanceof GridRouterResponse) {
res0 = MarshallerUtils.unmarshal(marsh, ((GridRouterResponse)res).body(),
- ses.igniteConfiguration().getGridName());
+ ses.gridName());
res0.requestId(res.requestId());
res0.clientId(res.clientId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
index 77b9f82..0b3a042 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
@@ -86,7 +86,7 @@ class GridTcpRouterNioParser extends GridTcpRestParser {
GridClientMessage clientMsg = (GridClientMessage)msg;
- ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.igniteConfiguration().getGridName());
+ ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.gridName());
ByteBuffer slice = res.slice();
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
index ec242f1..9d4fb7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
@@ -154,7 +154,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 0;
- data = MarshallerUtils.marshal(MARSHALLER, F.asList(schemasMap, indexesInfo), ignite.configuration());
+ data = MarshallerUtils.marshal(MARSHALLER, F.asList(schemasMap, indexesInfo), ignite.name());
}
catch (Throwable t) {
U.error(log, "Failed to get metadata for JDBC.", t);
@@ -164,7 +164,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 1;
try {
- data = MarshallerUtils.marshal(MARSHALLER, err, ignite.configuration());
+ data = MarshallerUtils.marshal(MARSHALLER, err, ignite.name());
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index 3faca1b..d078f38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -83,7 +83,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
try {
assert arg != null;
- Map<String, Object> args = MarshallerUtils.unmarshal(MARSHALLER, arg, null, ignite.configuration());
+ Map<String, Object> args = MarshallerUtils.unmarshal(MARSHALLER, arg, null, ignite.name());
boolean first = true;
@@ -131,13 +131,13 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
if (res.getException() == null) {
status = 0;
- bytes = MarshallerUtils.marshal(MARSHALLER, res.getData(), ignite.configuration());
+ bytes = MarshallerUtils.marshal(MARSHALLER, res.getData(), ignite.name());
}
else {
status = 1;
bytes = MarshallerUtils.marshal(MARSHALLER, new SQLException(res.getException().getMessage()),
- ignite.configuration());
+ ignite.name());
}
byte[] packet = new byte[bytes.length + 1];
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 21f105d..4e44abe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -171,7 +171,7 @@ public class GridTcpRestParser implements GridNioParser {
GridClientMessage msg = (GridClientMessage)msg0;
if (msg instanceof GridMemcachedMessage)
- return encodeMemcache((GridMemcachedMessage)msg, ses.igniteConfiguration());
+ return encodeMemcache((GridMemcachedMessage)msg, ses.gridName());
else if (msg instanceof GridClientPingPacket)
return ByteBuffer.wrap(GridClientPingPacket.PING_PACKET);
else if (msg instanceof GridClientHandshakeRequest) {
@@ -210,7 +210,7 @@ public class GridTcpRestParser implements GridNioParser {
else {
GridClientMarshaller marsh = marshaller(ses);
- ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.igniteConfiguration().getGridName());
+ ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.gridName());
ByteBuffer slice = res.slice();
@@ -522,7 +522,7 @@ public class GridTcpRestParser implements GridNioParser {
GridClientMarshaller marsh = marshaller(ses);
msg = MarshallerUtils.unmarshal(marsh, state.buffer().toByteArray(),
- ses.igniteConfiguration().getGridName());
+ ses.gridName());
msg.requestId(state.header().reqId());
msg.clientId(state.header().clientId());
@@ -536,12 +536,12 @@ public class GridTcpRestParser implements GridNioParser {
* Encodes memcache message to a raw byte array.
*
* @param msg Message being serialized.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @return Serialized message.
* @throws IgniteCheckedException If serialization failed.
*/
private ByteBuffer encodeMemcache(GridMemcachedMessage msg,
- final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ final String gridName) throws IgniteCheckedException {
GridByteArrayList res = new GridByteArrayList(HDR_LEN);
int keyLen = 0;
@@ -551,7 +551,7 @@ public class GridTcpRestParser implements GridNioParser {
if (msg.key() != null) {
ByteArrayOutputStream rawKey = new ByteArrayOutputStream();
- keyFlags = encodeObj(msg.key(), rawKey, igniteCfg);
+ keyFlags = encodeObj(msg.key(), rawKey, gridName);
msg.key(rawKey.toByteArray());
@@ -565,7 +565,7 @@ public class GridTcpRestParser implements GridNioParser {
if (msg.value() != null) {
ByteArrayOutputStream rawVal = new ByteArrayOutputStream();
- valFlags = encodeObj(msg.value(), rawVal, igniteCfg);
+ valFlags = encodeObj(msg.value(), rawVal, gridName);
msg.value(rawVal.toByteArray());
@@ -650,7 +650,7 @@ public class GridTcpRestParser implements GridNioParser {
byte[] rawKey = (byte[])req.key();
// Only values can be hessian-encoded.
- req.key(decodeObj(keyFlags, rawKey, ses.igniteConfiguration()));
+ req.key(decodeObj(keyFlags, rawKey, ses.gridName()));
}
if (req.value() != null) {
@@ -658,7 +658,7 @@ public class GridTcpRestParser implements GridNioParser {
byte[] rawVal = (byte[])req.value();
- req.value(decodeObj(valFlags, rawVal, ses.igniteConfiguration()));
+ req.value(decodeObj(valFlags, rawVal, ses.gridName()));
}
}
@@ -716,16 +716,16 @@ public class GridTcpRestParser implements GridNioParser {
*
* @param flags Flags.
* @param bytes Byte array to decode.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @return Decoded value.
* @throws IgniteCheckedException If deserialization failed.
*/
private Object decodeObj(short flags, byte[] bytes,
- final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ final String gridName) throws IgniteCheckedException {
assert bytes != null;
if ((flags & SERIALIZED_FLAG) != 0)
- return MarshallerUtils.unmarshal(jdkMarshaller, bytes, null, igniteCfg);
+ return MarshallerUtils.unmarshal(jdkMarshaller, bytes, null, gridName);
int masked = flags & 0xff00;
@@ -756,12 +756,12 @@ public class GridTcpRestParser implements GridNioParser {
*
* @param obj Object to serialize.
* @param out Output stream to which object should be written.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @return Serialization flags.
* @throws IgniteCheckedException If JDK serialization failed.
*/
private int encodeObj(Object obj, ByteArrayOutputStream out,
- final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ final String gridName) throws IgniteCheckedException {
int flags = 0;
byte[] data = null;
@@ -809,7 +809,7 @@ public class GridTcpRestParser implements GridNioParser {
flags |= BYTE_ARR_FLAG;
}
else {
- MarshallerUtils.marshal(jdkMarshaller, obj, out, igniteCfg.getGridName());
+ MarshallerUtils.marshal(jdkMarshaller, obj, out, gridName);
flags |= SERIALIZED_FLAG;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
index 56d0c30..0063cff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
@@ -74,12 +74,12 @@ public class IpcToNioAdapter<T> {
* @param endp Endpoint.
* @param lsnr Listener.
* @param writerFactory Writer factory.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @param filters Filters.
*/
public IpcToNioAdapter(GridNioMetricsListener metricsLsnr, IgniteLogger log, IpcEndpoint endp,
GridNioServerListener<T> lsnr, GridNioMessageWriterFactory writerFactory,
- IgniteConfiguration igniteCfg, GridNioFilter... filters) {
+ String gridName, GridNioFilter... filters) {
assert metricsLsnr != null;
this.metricsLsnr = metricsLsnr;
@@ -87,7 +87,7 @@ public class IpcToNioAdapter<T> {
this.writerFactory = writerFactory;
chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
- ses = new GridNioSessionImpl(chain, null, null, true, igniteCfg);
+ ses = new GridNioSessionImpl(chain, null, null, true, gridName);
writeBuf = ByteBuffer.allocate(8 << 10);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 3a2a98f..7470759 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -1635,10 +1635,6 @@ public class GridNioServer<T> {
readBuf.order(order);
}
- final IgniteConfiguration cfg = new IgniteConfiguration(); // TODO provide real config
-
- cfg.setGridName(gridName);
-
final GridSelectorNioSessionImpl ses = new GridSelectorNioSessionImpl(
log,
idx,
@@ -1649,7 +1645,7 @@ public class GridNioServer<T> {
sndQueueLimit,
writeBuf,
readBuf,
- cfg);
+ gridName);
Map<Integer, ?> meta = req.meta();
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
index edc9aa6..766670a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
@@ -168,7 +168,7 @@ public interface GridNioSession {
@Nullable public GridNioRecoveryDescriptor recoveryDescriptor();
/**
- * @return Ignite configuration.
+ * @return Grid name.
*/
- public IgniteConfiguration igniteConfiguration();
+ public String gridName();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
index b1465c6..638732e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
@@ -70,14 +70,14 @@ public class GridNioSessionImpl implements GridNioSession {
/** Accepted flag. */
private final boolean accepted;
- /** Ignite configuration. */
- private IgniteConfiguration igniteCfg;
+ /** Grid name. */
+ private String gridName;
/**
* @param filterChain Chain.
* @param locAddr Local address.
* @param rmtAddr Remote address.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @param accepted {@code True} if this session was initiated from remote host.
*/
public GridNioSessionImpl(
@@ -85,13 +85,13 @@ public class GridNioSessionImpl implements GridNioSession {
@Nullable InetSocketAddress locAddr,
@Nullable InetSocketAddress rmtAddr,
boolean accepted,
- IgniteConfiguration igniteCfg
+ String gridName
) {
this.filterChain = filterChain;
this.locAddr = locAddr;
this.rmtAddr = rmtAddr;
this.accepted = accepted;
- this.igniteCfg = igniteCfg;
+ this.gridName = gridName;
long now = U.currentTimeMillis();
@@ -318,7 +318,7 @@ public class GridNioSessionImpl implements GridNioSession {
}
/** {@inheritDoc} */
- @Override public IgniteConfiguration igniteConfiguration() {
- return igniteCfg;
+ @Override public String gridName() {
+ return gridName;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
index 042eaee..db5fc18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
@@ -78,7 +78,7 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl {
* @param sndQueueLimit Send queue limit.
* @param writeBuf Write buffer.
* @param readBuf Read buffer.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
*/
GridSelectorNioSessionImpl(
IgniteLogger log,
@@ -90,9 +90,9 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl {
int sndQueueLimit,
@Nullable ByteBuffer writeBuf,
@Nullable ByteBuffer readBuf,
- IgniteConfiguration igniteCfg
+ String gridName
) {
- super(filterChain, locAddr, rmtAddr, accepted, igniteCfg);
+ super(filterChain, locAddr, rmtAddr, accepted, gridName);
assert selectorIdx >= 0;
assert sndQueueLimit >= 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index b6808e9..b678bd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -64,19 +64,6 @@ public final class MarshallerUtils {
*
* @param marshaller marshaller.
* @param obj object.
- * @param igniteCfg ignite config.
- * @return serialized.
- * @throws IgniteCheckedException
- */
- public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
- final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
- return marshal(marshaller, obj, igniteCfg.getGridName());
- }
-
- /**
- *
- * @param marshaller marshaller.
- * @param obj object.
* @param gridName Grid name.
* @return serialized.
* @throws IgniteCheckedException
@@ -137,21 +124,6 @@ public final class MarshallerUtils {
/**
*
* @param marshaller marshaller.
- * @param arr byte array.
- * @param clsLdr class loader.
- * @param igniteCfg ignite config.
- * @param <T> target type
- * @return deserialized object.
- * @throws IgniteCheckedException
- */
- public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
- final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
- return unmarshal(marshaller, arr, clsLdr, igniteCfg.getGridName());
- }
-
- /**
- *
- * @param marshaller marshaller.
* @param obj object
* @param clsLdr class loader.
* @param gridName Grid name.
@@ -229,13 +201,4 @@ public final class MarshallerUtils {
private static void restoreGridName(final String name) {
IgnitionEx.setGridNameThreadLocal(name);
}
-
- /**
- *
- * @param kernalCtx kernal context.
- * @return ignite config or null.
- */
- private static IgniteConfiguration getConfig(final @Nullable GridKernalContext kernalCtx) {
- return kernalCtx == null ? null : kernalCtx.config();
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 8e78352..5938db6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -3013,7 +3013,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
endpoint,
srvLsnr,
writerFactory,
- ignite.configuration(),
+ gridName,
new GridNioCodecFilter(new GridDirectParser(msgFactory, readerFactory), log, true),
new GridConnectionBytesVerifyFilter(log)
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index f383fe7..0a0b42d 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -431,7 +431,7 @@ class ClientImpl extends TcpDiscoveryImpl {
try {
sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().configuration())));
+ MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().name())));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -686,7 +686,7 @@ class ClientImpl extends TcpDiscoveryImpl {
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
MarshallerUtils.marshal(spi.marsh, attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS),
- spi.ignite().configuration()));
+ spi.ignite().name()));
node.setAttributes(attrs);
}
@@ -1968,7 +1968,7 @@ class ClientImpl extends TcpDiscoveryImpl {
if (node != null && node.visible()) {
try {
DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration());
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().name());
notifyDiscovery(EVT_DISCOVERY_CUSTOM_EVT, topVer, node, allVisibleNodes(), msgObj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 3244182..d8dcca4 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -743,7 +743,7 @@ class ServerImpl extends TcpDiscoveryImpl {
@Override public void sendCustomEvent(DiscoverySpiCustomMessage evt) {
try {
msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().configuration())));
+ MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().name())));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -827,7 +827,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(locNode.attributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().configuration()));
+ MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().name()));
attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
locNode.setAttributes(attrs);
@@ -1244,7 +1244,7 @@ class ServerImpl extends TcpDiscoveryImpl {
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
MarshallerUtils.marshal(spi.marsh,
- attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS), spi.ignite().configuration()));
+ attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS), spi.ignite().name()));
node.setAttributes(attrs);
}
@@ -1267,7 +1267,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (credBytes == null)
return null;
- return MarshallerUtils.unmarshal(spi.marsh, credBytes, null, spi.ignite().configuration());
+ return MarshallerUtils.unmarshal(spi.marsh, credBytes, null, spi.ignite().name());
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to unmarshal node security credentials: " + node.id(), e);
@@ -2361,7 +2361,7 @@ class ServerImpl extends TcpDiscoveryImpl {
for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
if (msgBytes == null) {
try {
- msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().configuration());
+ msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().name());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal message: " + msg, e);
@@ -2381,7 +2381,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (clientMsgWorker.clientNodeId.equals(node.id())) {
try {
msg0 = MarshallerUtils.unmarshal(spi.marsh, msgBytes,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration());
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().name());
prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId, null, null, null);
@@ -3140,7 +3140,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().configuration()));
+ MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().name()));
node.setAttributes(attrs);
}
@@ -3795,7 +3795,7 @@ class ServerImpl extends TcpDiscoveryImpl {
SecurityContext coordSubj = MarshallerUtils.unmarshal(spi.marsh,
node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
- U.resolveClassLoader(cfg), cfg);
+ U.resolveClassLoader(cfg), cfg.getGridName());
if (!permissionsEqual(coordSubj.subject().permissions(), subj.subject().permissions())) {
// Node has not pass authentication.
@@ -4847,7 +4847,7 @@ class ServerImpl extends TcpDiscoveryImpl {
try {
msgObj = msg.message(spi.marsh, U.resolveClassLoader(spi.ignite().configuration()),
- spi.ignite().configuration());
+ spi.ignite().name());
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -4860,7 +4860,7 @@ class ServerImpl extends TcpDiscoveryImpl {
try {
TcpDiscoveryCustomEventMessage ackMsg = new TcpDiscoveryCustomEventMessage(
getLocalNodeId(), nextMsg,
- MarshallerUtils.marshal(spi.marsh, nextMsg, spi.ignite().configuration()));
+ MarshallerUtils.marshal(spi.marsh, nextMsg, spi.ignite().name()));
ackMsg.topologyVersion(msg.topologyVersion());
@@ -4994,7 +4994,7 @@ class ServerImpl extends TcpDiscoveryImpl {
final IgniteConfiguration cfg = spi.ignite().configuration();
DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
- U.resolveClassLoader(cfg), cfg);
+ U.resolveClassLoader(cfg), cfg.getGridName());
lsnr.onDiscovery(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT,
msg.topologyVersion(),
@@ -5005,7 +5005,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (msgObj.isMutable())
msg.message(msgObj,
- MarshallerUtils.marshal(spi.marsh, msgObj, spi.ignite().configuration()));
+ MarshallerUtils.marshal(spi.marsh, msgObj, spi.ignite().name()));
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -5932,7 +5932,7 @@ class ServerImpl extends TcpDiscoveryImpl {
byte[] msgBytes = msgT.get2();
if (msgBytes == null)
- msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().configuration());
+ msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().name());
if (msg instanceof TcpDiscoveryClientAckResponse) {
if (clientVer == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index bb01f74..61186d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1678,7 +1678,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, Serializable> entry : data.entrySet()) {
try {
- byte[] bytes = MarshallerUtils.marshal(marsh, entry.getValue(), ignite.configuration());
+ byte[] bytes = MarshallerUtils.marshal(marsh, entry.getValue(), ignite.name());
data0.put(entry.getKey(), bytes);
}
@@ -1709,7 +1709,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, byte[]> entry : data.entrySet()) {
try {
Serializable compData = MarshallerUtils.unmarshal(marsh, entry.getValue(), clsLdr,
- ignite.configuration());
+ ignite.name());
data0.put(entry.getKey(), compData);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index d213eaa..24f4803 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -361,7 +361,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (!addr.isLoopbackAddress()) {
try {
if (!clientMode)
- addrSnds.add(new AddressSender(mcastAddr, addr, addrs, getIgniteConfiguration()));
+ addrSnds.add(new AddressSender(mcastAddr, addr, addrs));
reqItfs.add(addr);
}
@@ -381,7 +381,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
try {
// Create non-bound socket if local host is loopback or failed to create sockets explicitly
// bound to interfaces.
- addrSnds.add(new AddressSender(mcastAddr, null, addrs, getIgniteConfiguration()));
+ addrSnds.add(new AddressSender(mcastAddr, null, addrs));
}
catch (IOException e) {
if (log.isDebugEnabled())
@@ -391,7 +391,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (addrSnds.isEmpty()) {
try {
- addrSnds.add(new AddressSender(mcastAddr, mcastAddr, addrs, getIgniteConfiguration()));
+ addrSnds.add(new AddressSender(mcastAddr, mcastAddr, addrs));
reqItfs.add(mcastAddr);
}
@@ -595,7 +595,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
AddressResponse addrRes;
try {
- addrRes = new AddressResponse(data, getIgniteConfiguration());
+ addrRes = new AddressResponse(data, getGridName());
}
catch (IgniteCheckedException e) {
LT.warn(log, e, "Failed to deserialize multicast response.");
@@ -647,8 +647,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
*
* @return Ignite config or {@code null}.
*/
- @Nullable private IgniteConfiguration getIgniteConfiguration() {
- return ignite == null ? null : ignite.configuration();
+ @Nullable private String getGridName() {
+ return ignite == null ? null : ignite.name();
}
/** {@inheritDoc} */
@@ -699,10 +699,10 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
* @param addrs Addresses discovery SPI binds to.
* @throws IgniteCheckedException If marshalling failed.
*/
- private AddressResponse(Collection<InetSocketAddress> addrs, final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ private AddressResponse(Collection<InetSocketAddress> addrs, final String gridName) throws IgniteCheckedException {
this.addrs = addrs;
- byte[] addrsData = MarshallerUtils.marshal(marsh, addrs, igniteCfg);
+ byte[] addrsData = MarshallerUtils.marshal(marsh, addrs, gridName);
data = new byte[U.IGNITE_HEADER.length + addrsData.length];
if (data.length > MAX_DATA_LENGTH)
@@ -714,15 +714,16 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
/**
* @param data Message data.
+ * @param gridName Grid name.
* @throws IgniteCheckedException If unmarshalling failed.
*/
- private AddressResponse(byte[] data, final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ private AddressResponse(byte[] data, final String gridName) throws IgniteCheckedException {
assert U.bytesEqual(U.IGNITE_HEADER, 0, data, 0, U.IGNITE_HEADER.length);
this.data = data;
addrs = MarshallerUtils.unmarshal(marsh,
- Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null, igniteCfg);
+ Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null, gridName);
}
/**
@@ -794,24 +795,18 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
/** */
private final InetAddress sockItf;
- /** */
- private final IgniteConfiguration igniteCfg;
-
/**
* @param mcastGrp Multicast address.
* @param sockItf Optional interface multicast socket should be bound to.
* @param addrs Local node addresses.
- * @param igniteCfg Ignite configuration.
* @throws IOException If fails to create multicast socket.
*/
- private AddressSender(InetAddress mcastGrp, @Nullable InetAddress sockItf, Collection<InetSocketAddress> addrs,
- final IgniteConfiguration igniteCfg)
+ private AddressSender(InetAddress mcastGrp, @Nullable InetAddress sockItf, Collection<InetSocketAddress> addrs)
throws IOException {
super(ignite == null ? null : ignite.name(), "tcp-disco-multicast-addr-sender", log);
this.mcastGrp = mcastGrp;
this.addrs = addrs;
this.sockItf = sockItf;
- this.igniteCfg = igniteCfg;
sock = createSocket();
}
@@ -847,7 +842,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
AddressResponse res;
try {
- res = new AddressResponse(addrs, igniteCfg);
+ res = new AddressResponse(addrs, gridName);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to prepare multicast message.", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index 1555718..e75e8ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -74,25 +74,25 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
/**
* @param marsh Marshaller.
- * @param igniteCfg Ignite configuration.
+ * @param gridName Grid name.
* @return Deserialized message.
* @throws java.lang.Throwable if unmarshal failed.
*/
- @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, IgniteConfiguration igniteCfg) throws Throwable {
- return message(marsh, null, igniteCfg);
+ @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, String gridName) throws Throwable {
+ return message(marsh, null, gridName);
}
/**
* @param marsh Marshaller.
* @param ldr Class loader.
- * @param igniteCfg Ignite configuration.
+ * @param gridName Grid name.
* @return Deserialized message.
* @throws java.lang.Throwable if unmarshal failed.
*/
@Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr,
- final IgniteConfiguration igniteCfg) throws Throwable {
+ final String gridName) throws Throwable {
if (msg == null) {
- msg = MarshallerUtils.unmarshal(marsh, msgBytes, ldr, igniteCfg);
+ msg = MarshallerUtils.unmarshal(marsh, msgBytes, ldr, gridName);
assert msg != null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index a9e19b5..b8365c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -595,7 +595,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
if (keyBytes == null) {
try {
- keyBytes = MarshallerUtils.marshal(ignite.configuration().getMarshaller(), key.key(), ignite.configuration());
+ keyBytes = MarshallerUtils.marshal(ignite.configuration().getMarshaller(), key.key(), ignite.name());
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal key: " + key.key(), e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
index d1372ee..9e2ca67 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
@@ -17,8 +17,6 @@
package org.apache.ignite.stream.socket;
-import org.apache.ignite.configuration.IgniteConfiguration;
-
/**
* Socket message converter.
*/
@@ -27,8 +25,8 @@ public interface SocketMessageConverter<T> {
* Converter message represented by array of bytes to object.
*
* @param msg Message.
- * @param igniteCfg Ignite config.
+ * @param gridName Grid name.
* @return Converted object.
*/
- public T convert(byte[] msg, IgniteConfiguration igniteCfg);
+ public T convert(byte[] msg, String gridName);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
index 24580e7..7378bd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
@@ -165,7 +165,7 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
}
@Override public void onMessage(GridNioSession ses, byte[] msg) {
- addMessage(converter.convert(msg, ses.igniteConfiguration()));
+ addMessage(converter.convert(msg, ses.gridName()));
}
};
@@ -220,9 +220,9 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
private static final JdkMarshaller MARSH = new JdkMarshaller();
/** {@inheritDoc} */
- @Override public T convert(byte[] msg, final IgniteConfiguration igniteCfg) {
+ @Override public T convert(byte[] msg, final String gridName) {
try {
- return MarshallerUtils.unmarshal(MARSH, msg, null, igniteCfg);
+ return MarshallerUtils.unmarshal(MARSH, msg, null, gridName);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
index 0308ab6..d5de056 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
@@ -17,11 +17,26 @@
package org.apache.ignite.internal.processors.cache.binary;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.junits.GridAbstractTest;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.lang.reflect.Method;
/**
@@ -49,48 +64,110 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
runTest.invoke(this);
}
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName != null && gridName.startsWith("binary"))
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ return cfg;
+ }
+
/**
* Test that calling {@link Ignition#localIgnite()}
* is safe for binary marshaller.
*
* @throws Exception
*/
- public void testPutGet() throws Exception {
- final IgniteCache<Integer, MyObj> cache = startGrid().getOrCreateCache(CACHE_NAME);
+ public void testPutGetSimple() throws Exception {
+ testPutGet(new SimpleTestObject("one"), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSerializable() throws Exception {
+ testPutGet(new SerializableTestObject("test"), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutGetExternalizable() throws Exception {
+ testPutGet(new ExternalizableTestObject("test"), null);
+ }
- final MyObj one = new MyObj("one");
- final MyObj two = new MyObj("two");
- final MyObj three = new MyObj("three");
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutGetBinarylizable() throws Exception {
+ testPutGet(new BinarylizableTestObject("test"), "binaryIgnite");
+ }
- cache.put(1, one);
- cache.put(2, two);
- cache.put(3, three);
+ /**
+ * @throws Exception If failed.
+ */
+ private void testPutGet(final TestObject obj, final String gridName) throws Exception {
+ try (final Ignite ignite = startGrid(gridName)) {
+ final IgniteCache<Integer, TestObject> cache = ignite.getOrCreateCache(CACHE_NAME);
- final MyObj loadedOne = cache.get(1);
- final MyObj loadedTwo = cache.get(2);
- final MyObj loadedThree = cache.get(3);
+ assertNull(obj.ignite());
- assert one.equals(loadedOne);
- assert two.equals(loadedTwo);
- assert three.equals(loadedThree);
+ cache.put(1, obj);
+ assertNotNull(obj.ignite());
+
+ final TestObject loadedObj = cache.get(1);
+
+ assertNotNull(loadedObj.ignite());
+
+ assertEquals(obj, loadedObj);
+ }
}
/**
- * Test obj.
+ *
*/
- private static class MyObj {
+ private interface TestObject {
+ /**
+ * @return Ignite instance.
+ */
+ Ignite ignite();
+ }
+ /**
+ * Test object.
+ */
+ private static class SimpleTestObject implements TestObject {
/** */
- final String val;
+ private final String val;
/** */
- private MyObj(final String val) {
+ private transient Ignite ignite;
+
+ /** */
+ private SimpleTestObject(final String val) {
this.val = val;
}
+ /**
+ * @return Object.
+ */
+ @SuppressWarnings("unused")
private Object readResolve() {
- Ignition.localIgnite();
+ ignite = Ignition.localIgnite();
+
+ return this;
+ }
+
+ /**
+ * @return Object.
+ */
+ @SuppressWarnings("unused")
+ private Object writeReplace() {
+ ignite = Ignition.localIgnite();
+
return this;
}
@@ -99,15 +176,195 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- final MyObj myObj = (MyObj) o;
+ final SimpleTestObject simpleTestObj = (SimpleTestObject) o;
+
+ return val != null ? val.equals(simpleTestObj.val) : simpleTestObj.val == null;
+
+ }
+
+ /** */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SerializableTestObject implements Serializable, TestObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ public SerializableTestObject() {
+ }
+
+ public SerializableTestObject(final String val) {
+ this.val = val;
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ U.writeString(out, val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException {
+ val = U.readString(in);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final SerializableTestObject that = (SerializableTestObject) o;
+
+ return val != null ? val.equals(that.val) : that.val == null;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExternalizableTestObject implements Externalizable, TestObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ /**
+ *
+ */
+ public ExternalizableTestObject() {
+ }
+
+ /**
+ * @param val Value.
+ */
+ public ExternalizableTestObject(final String val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(final ObjectOutput out) throws IOException {
+ U.writeString(out, val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+ val = U.readString(in);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final ExternalizableTestObject that = (ExternalizableTestObject) o;
- return val != null ? val.equals(myObj.val) : myObj.val == null;
+ return val != null ? val.equals(that.val) : that.val == null;
}
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class BinarylizableTestObject implements Binarylizable, TestObject {
+ /** */
+ private String val;
+
/** */
+ private transient Ignite ignite;
+
+ /**
+ *
+ */
+ public BinarylizableTestObject() {
+ }
+
+ /**
+ * @param val Value.
+ */
+ public BinarylizableTestObject(final String val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
+ writer.rawWriter().writeString(val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
+ val = reader.rawReader().readString();
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final BinarylizableTestObject that = (BinarylizableTestObject) o;
+
+ return val != null ? val.equals(that.val) : that.val == null;
+
+ }
+
+ /** {@inheritDoc} */
@Override public int hashCode() {
return val != null ? val.hashCode() : 0;
}
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
index 043ec02..e47fc0f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
@@ -380,7 +380,7 @@ public class GridNioFilterChainSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public IgniteConfiguration igniteConfiguration() {
+ @Override public String gridName() {
return null;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
index a76a1fa..a59ebea 100644
--- a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
@@ -169,7 +169,7 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest {
*/
public void testSizeBasedCustomConverter() throws Exception {
SocketMessageConverter<Message> converter = new SocketMessageConverter<Message>() {
- @Override public Message convert(byte[] msg, IgniteConfiguration cfg) {
+ @Override public Message convert(byte[] msg, String gridName) {
int i = (msg[0] & 0xFF) << 24;
i |= (msg[1] & 0xFF) << 16;
i |= (msg[2] & 0xFF) << 8;
@@ -233,7 +233,7 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest {
*/
public void testDelimiterBasedCustomConverter() throws Exception {
SocketMessageConverter<Message> converter = new SocketMessageConverter<Message>() {
- @Override public Message convert(byte[] msg, IgniteConfiguration cfg) {
+ @Override public Message convert(byte[] msg, String gridName) {
int i = (msg[0] & 0xFF) << 24;
i |= (msg[1] & 0xFF) << 16;
i |= (msg[2] & 0xFF) << 8;
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
index 736c69f..2c87540 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
@@ -1175,15 +1175,12 @@ public class HadoopExternalCommunication {
this.endpoint = endpoint;
- final IgniteConfiguration cfg = new IgniteConfiguration(); // TODO provide real config
- cfg.setGridName(gridName);
-
adapter = new HadoopIpcToNioAdapter<>(
HadoopExternalCommunication.this.log,
endpoint,
accepted,
srvLsnr,
- cfg,
+ gridName,
filters());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
index 1000b8a..23c6510 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
@@ -63,15 +63,15 @@ public class HadoopIpcToNioAdapter<T> {
* @param log Log.
* @param endp Endpoint.
* @param lsnr Listener.
- * @param igniteCfg Ignite config.
+ * @param gridname Ignite config.
* @param filters Filters.
*/
public HadoopIpcToNioAdapter(IgniteLogger log, IpcEndpoint endp, boolean accepted,
- GridNioServerListener<T> lsnr, IgniteConfiguration igniteCfg, GridNioFilter... filters) {
+ GridNioServerListener<T> lsnr, String gridname, GridNioFilter... filters) {
this.endp = endp;
chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
- ses = new GridNioSessionImpl(chain, null, null, accepted, igniteCfg);
+ ses = new GridNioSessionImpl(chain, null, null, accepted, gridname);
writeBuf = ByteBuffer.allocate(8 << 10);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
index d0cbecc..a2e3902 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
@@ -60,7 +60,7 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
@Override public GridNioFuture<?> onSessionWrite(GridNioSession ses, Object msg) throws IgniteCheckedException {
assert msg instanceof HadoopMessage : "Invalid message type: " + msg;
- return proceedSessionWrite(ses, MarshallerUtils.marshal(marshaller, msg, ses.igniteConfiguration()));
+ return proceedSessionWrite(ses, MarshallerUtils.marshal(marshaller, msg, ses.gridName()));
}
/** {@inheritDoc} */
@@ -68,7 +68,7 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
assert msg instanceof byte[];
// Always unmarshal with system classloader.
- proceedMessageReceived(ses, MarshallerUtils.unmarshal(marshaller, (byte[])msg, null, ses.igniteConfiguration()));
+ proceedMessageReceived(ses, MarshallerUtils.unmarshal(marshaller, (byte[])msg, null, ses.gridName()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
index 414fef1..17c0a29 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
@@ -516,7 +516,7 @@ public class WebSessionFilter implements Filter {
if (entity != null) {
cached = new WebSessionV2(sesId, httpReq.getSession(false), false, ctx, entity, marshaller,
- webSesIgnite.configuration());
+ webSesIgnite.name());
}
break;
@@ -700,7 +700,7 @@ public class WebSessionFilter implements Filter {
if (log.isDebugEnabled())
log.debug("Session created: " + sesId);
- WebSessionV2 cached = new WebSessionV2(sesId, ses, true, ctx, null, marshaller, webSesIgnite.configuration());
+ WebSessionV2 cached = new WebSessionV2(sesId, ses, true, ctx, null, marshaller, webSesIgnite.name());
final WebSessionEntity marshaledEntity = cached.marshalAttributes();
@@ -712,9 +712,9 @@ public class WebSessionFilter implements Filter {
final WebSessionEntity old = cache0.getAndPutIfAbsent(sesId, marshaledEntity);
if (old != null)
- cached = new WebSessionV2(sesId, ses, false, ctx, old, marshaller, webSesIgnite.configuration());
+ cached = new WebSessionV2(sesId, ses, false, ctx, old, marshaller, webSesIgnite.name());
else
- cached = new WebSessionV2(sesId, ses, false, ctx, marshaledEntity, marshaller, webSesIgnite.configuration());
+ cached = new WebSessionV2(sesId, ses, false, ctx, marshaledEntity, marshaller, webSesIgnite.name());
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63210e6d/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index 28d16b1..fd420d9 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -19,7 +19,6 @@ package org.apache.ignite.cache.websession;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.websession.WebSessionEntity;
@@ -90,7 +89,7 @@ class WebSessionV2 implements HttpSession {
private final HttpSession genuineSes;
/** Ignite config. */
- private final IgniteConfiguration cfg;
+ private final String gridName;
/**
* @param id Session ID.
@@ -98,18 +97,18 @@ class WebSessionV2 implements HttpSession {
* @param isNew Is new flag.
*/
WebSessionV2(final String id, final @Nullable HttpSession ses, final boolean isNew, final ServletContext ctx,
- @Nullable WebSessionEntity entity, final Marshaller marshaller, final IgniteConfiguration cfg) {
+ @Nullable WebSessionEntity entity, final Marshaller marshaller, final String gridName) {
assert id != null;
assert marshaller != null;
assert ctx != null;
assert ses != null || entity != null;
- assert cfg != null;
+ assert gridName != null;
this.marshaller = marshaller;
this.ctx = ctx;
this.isNew = isNew;
this.genuineSes = ses;
- this.cfg = cfg;
+ this.gridName = gridName;
accessTime = System.currentTimeMillis();
@@ -340,7 +339,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private <T> T unmarshal(final byte[] bytes) throws IOException {
if (marshaller != null) {
try {
- return MarshallerUtils.unmarshal(marshaller, bytes, getClass().getClassLoader(), cfg);
+ return MarshallerUtils.unmarshal(marshaller, bytes, getClass().getClassLoader(), gridName);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
@@ -360,7 +359,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private byte[] marshal(final Object obj) throws IOException {
if (marshaller != null) {
try {
- return MarshallerUtils.marshal(marshaller, obj, cfg);
+ return MarshallerUtils.marshal(marshaller, obj, gridName);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
[18/50] [abbrv] ignite git commit: GG-11293: .NET: Backported
affinity functions feature to 7.5.30.
Posted by vo...@apache.org.
GG-11293: .NET: Backported affinity functions feature to 7.5.30.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5f57cc8d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5f57cc8d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5f57cc8d
Branch: refs/heads/ignite-2649
Commit: 5f57cc8d703f9e8f749c9e3c403781365642dc3a
Parents: 78d7c13
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 19 14:34:35 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 19 14:34:35 2016 +0300
----------------------------------------------------------------------
.../internal/binary/GridBinaryMarshaller.java | 11 +-
.../GridAffinityFunctionContextImpl.java | 9 +
.../processors/cache/GridCacheProcessor.java | 65 +++--
.../affinity/PlatformAffinityFunction.java | 277 +++++++++++++++++++
.../PlatformAffinityFunctionTarget.java | 113 ++++++++
.../cache/affinity/PlatformAffinityUtils.java | 116 ++++++++
.../callback/PlatformCallbackGateway.java | 89 ++++++
.../callback/PlatformCallbackUtils.java | 49 ++++
.../PlatformDotNetConfigurationClosure.java | 115 +++++++-
.../dotnet/PlatformDotNetAffinityFunction.java | 171 ++++++++++++
.../cpp/common/include/ignite/common/java.h | 18 ++
modules/platforms/cpp/common/src/java.cpp | 36 ++-
.../Apache.Ignite.Core.Tests.csproj | 9 +-
.../Affinity/AffinityFunctionSpringTest.cs | 184 ++++++++++++
.../Config/Cache/Affinity/affinity-function.xml | 129 +++++++++
.../Cache/Affinity/affinity-function2.xml | 49 ++++
.../Apache.Ignite.Core.Tests/TestRunner.cs | 3 +-
.../Apache.Ignite.Core.csproj | 11 +-
.../Cache/Affinity/AffinityFunctionBase.cs | 139 ++++++++++
.../Cache/Affinity/AffinityFunctionContext.cs | 120 ++++++++
.../Cache/Affinity/AffinityTopologyVersion.cs | 138 +++++++++
.../Cache/Affinity/Fair/FairAffinityFunction.cs | 32 +++
.../Cache/Affinity/IAffinityFunction.cs | 82 ++++++
.../Rendezvous/RendezvousAffinityFunction.cs | 31 +++
.../Apache.Ignite.Core/Events/EventReader.cs | 8 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 38 ++-
.../Impl/Binary/BinaryReaderExtensions.cs | 14 +
.../Impl/Binary/Marshaller.cs | 6 +-
.../Affinity/AffinityFunctionSerializer.cs | 277 +++++++++++++++++++
.../Cache/Affinity/PlatformAffinityFunction.cs | 74 +++++
.../Impl/Common/ObjectInfoHolder.cs | 86 ++++++
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 10 +-
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 6 +
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 133 ++++++++-
34 files changed, 2596 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index 535207c..3a3dfd1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -305,6 +305,15 @@ public class GridBinaryMarshaller {
/**
* Push binary context and return the old one.
*
+ * @return Old binary context.
+ */
+ public BinaryContext pushContext() {
+ return pushContext(ctx);
+ }
+
+ /**
+ * Push binary context and return the old one.
+ *
* @param ctx Binary context.
* @return Old binary context.
*/
@@ -321,7 +330,7 @@ public class GridBinaryMarshaller {
*
* @param oldCtx Old binary context.
*/
- private static void popContext(@Nullable BinaryContext oldCtx) {
+ public static void popContext(@Nullable BinaryContext oldCtx) {
if (oldCtx == null)
BINARY_CTX.remove();
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityFunctionContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityFunctionContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityFunctionContextImpl.java
index 6c97efd..4ddee00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityFunctionContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityFunctionContextImpl.java
@@ -80,4 +80,13 @@ public class GridAffinityFunctionContextImpl implements AffinityFunctionContext
@Override public int backups() {
return backups;
}
+
+ /**
+ * Gets the previous assignment.
+ *
+ * @return Previous assignment.
+ */
+ public List<List<ClusterNode>> prevAssignment() {
+ return prevAssignment;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 6484d4d..6761fac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -69,10 +69,13 @@ import org.apache.ignite.internal.IgniteComponentType;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.IgniteTransactionsEx;
+import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -94,12 +97,14 @@ import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
@@ -3379,32 +3384,60 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException If validation failed.
* @return Configuration copy.
*/
- private CacheConfiguration cloneCheckSerializable(CacheConfiguration val) throws IgniteCheckedException {
+ private CacheConfiguration cloneCheckSerializable(final CacheConfiguration val) throws IgniteCheckedException {
if (val == null)
return null;
- if (val.getCacheStoreFactory() != null) {
- try {
- ClassLoader ldr = ctx.config().getClassLoader();
+ return withBinaryContext(new IgniteOutClosureX<CacheConfiguration>() {
+ @Override public CacheConfiguration applyx() throws IgniteCheckedException {
+ if (val.getCacheStoreFactory() != null) {
+ try {
+ ClassLoader ldr = ctx.config().getClassLoader();
- if (ldr == null)
- ldr = val.getCacheStoreFactory().getClass().getClassLoader();
+ if (ldr == null)
+ ldr = val.getCacheStoreFactory().getClass().getClassLoader();
- marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
- U.resolveClassLoader(ldr, ctx.config()));
- }
- catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration. " +
- "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
+ U.resolveClassLoader(ldr, ctx.config()));
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteCheckedException("Failed to validate cache configuration. " +
+ "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ }
+ }
+
+ try {
+ return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config()));
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteCheckedException("Failed to validate cache configuration " +
+ "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
+ }
}
+ });
+ }
+
+ /**
+ * @param c Closure.
+ * @return Closure result.
+ * @throws IgniteCheckedException If failed.
+ */
+ private <T> T withBinaryContext(IgniteOutClosureX<T> c) throws IgniteCheckedException {
+ IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
+ BinaryContext oldCtx = null;
+
+ if (objProc instanceof CacheObjectBinaryProcessorImpl) {
+ GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller();
+
+ oldCtx = binMarsh == null ? null : binMarsh.pushContext();
}
try {
- return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config()));
+ return c.applyx();
}
- catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration " +
- "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
+ finally {
+ if (objProc instanceof CacheObjectBinaryProcessorImpl)
+ GridBinaryMarshaller.popContext(oldCtx);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
new file mode 100644
index 0000000..6681e7a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
@@ -0,0 +1,277 @@
+/*
+ * 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.processors.platform.cache.affinity;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
+import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Platform AffinityFunction.
+ */
+public class PlatformAffinityFunction implements AffinityFunction, Externalizable, LifecycleAware {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private static final byte FLAG_PARTITION = 1;
+
+ /** */
+ private static final byte FLAG_REMOVE_NODE = 1 << 1;
+
+ /** */
+ private static final byte FLAG_ASSIGN_PARTITIONS = 1 << 2;
+
+ /** */
+ private Object userFunc;
+
+ /**
+ * Partition count.
+ *
+ * 1) Java calls partitions() method very early (before LifecycleAware.start) during CacheConfiguration validation.
+ * 2) Partition count never changes.
+ * Therefore, we get the value on .NET side once, and pass it along with PlatformAffinity.
+ */
+ private int partitions;
+
+ /** */
+ private AffinityFunction baseFunc;
+
+ /** */
+ private byte overrideFlags;
+
+ /** */
+ private transient Ignite ignite;
+
+ /** */
+ private transient PlatformContext ctx;
+
+ /** */
+ private transient long ptr;
+
+ /** */
+ private transient PlatformAffinityFunctionTarget baseTarget;
+
+
+ /**
+ * Ctor for serialization.
+ *
+ */
+ public PlatformAffinityFunction() {
+ partitions = -1;
+ }
+
+ /**
+ * Ctor.
+ *
+ * @param func User fun object.
+ * @param partitions Number of partitions.
+ */
+ public PlatformAffinityFunction(Object func, int partitions, byte overrideFlags, AffinityFunction baseFunc) {
+ userFunc = func;
+ this.partitions = partitions;
+ this.overrideFlags = overrideFlags;
+ this.baseFunc = baseFunc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reset() {
+ // userFunc is always in initial state (it is serialized only once on start).
+ if (baseFunc != null)
+ baseFunc.reset();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partitions() {
+ // Affinity function can not return different number of partitions,
+ // so we pass this value once from the platform.
+ assert partitions > 0;
+
+ return partitions;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partition(Object key) {
+ if ((overrideFlags & FLAG_PARTITION) == 0) {
+ assert baseFunc != null;
+
+ return baseFunc.partition(key);
+ }
+
+ assert ctx != null;
+ assert ptr != 0;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+ BinaryRawWriterEx writer = ctx.writer(out);
+
+ writer.writeObject(key);
+
+ out.synchronize();
+
+ return ctx.gateway().affinityFunctionPartition(ptr, mem.pointer());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<List<ClusterNode>> assignPartitions(AffinityFunctionContext affCtx) {
+ if ((overrideFlags & FLAG_ASSIGN_PARTITIONS) == 0) {
+ assert baseFunc != null;
+
+ return baseFunc.assignPartitions(affCtx);
+ }
+
+ assert ctx != null;
+ assert ptr != 0;
+ assert affCtx != null;
+
+ try (PlatformMemory outMem = ctx.memory().allocate()) {
+ try (PlatformMemory inMem = ctx.memory().allocate()) {
+ PlatformOutputStream out = outMem.output();
+ BinaryRawWriterEx writer = ctx.writer(out);
+
+ // Write previous assignment
+ PlatformAffinityUtils.writeAffinityFunctionContext(affCtx, writer, ctx);
+
+ out.synchronize();
+
+ // Call platform
+ // We can not restore original AffinityFunctionContext after the call to platform,
+ // due to DiscoveryEvent (when node leaves, we can't get it by id anymore).
+ // Secondly, AffinityFunctionContext can't be changed by the user.
+ if (baseTarget != null)
+ baseTarget.setCurrentAffinityFunctionContext(affCtx);
+
+ try {
+ ctx.gateway().affinityFunctionAssignPartitions(ptr, outMem.pointer(), inMem.pointer());
+ }
+ finally {
+ if (baseTarget != null)
+ baseTarget.setCurrentAffinityFunctionContext(null);
+ }
+
+ // Read result
+ return PlatformAffinityUtils.readPartitionAssignment(ctx.reader(inMem), ctx);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeNode(UUID nodeId) {
+ if ((overrideFlags & FLAG_REMOVE_NODE) == 0) {
+ assert baseFunc != null;
+
+ baseFunc.removeNode(nodeId);
+
+ return;
+ }
+
+ assert ctx != null;
+ assert ptr != 0;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+ BinaryRawWriterEx writer = ctx.writer(out);
+
+ writer.writeUuid(nodeId);
+
+ out.synchronize();
+
+ ctx.gateway().affinityFunctionRemoveNode(ptr, mem.pointer());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(userFunc);
+ out.writeInt(partitions);
+ out.writeByte(overrideFlags);
+ out.writeObject(baseFunc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ userFunc = in.readObject();
+ partitions = in.readInt();
+ overrideFlags = in.readByte();
+ baseFunc = (AffinityFunction)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ // userFunc is null when there is nothing overridden
+ if (userFunc == null)
+ return;
+
+ assert ignite != null;
+ ctx = PlatformUtils.platformContext(ignite);
+ assert ctx != null;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+ BinaryRawWriterEx writer = ctx.writer(out);
+
+ writer.writeObject(userFunc);
+
+ out.synchronize();
+
+ baseTarget = baseFunc != null
+ ? new PlatformAffinityFunctionTarget(ctx, baseFunc)
+ : null;
+
+ ptr = ctx.gateway().affinityFunctionInit(mem.pointer(), baseTarget);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+ if (ptr == 0)
+ return;
+
+ assert ctx != null;
+
+ ctx.gateway().affinityFunctionDestroy(ptr);
+ }
+
+ /**
+ * Injects the Ignite.
+ *
+ * @param ignite Ignite.
+ */
+ @SuppressWarnings("unused")
+ @IgniteInstanceResource
+ public void setIgnite(Ignite ignite) {
+ this.ignite = ignite;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunctionTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunctionTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunctionTarget.java
new file mode 100644
index 0000000..8a07b33
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunctionTarget.java
@@ -0,0 +1,113 @@
+/*
+ * 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.processors.platform.cache.affinity;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import java.util.List;
+
+/**
+ * Platform affinity function target:
+ * to be invoked when Platform function calls base implementation of one of the AffinityFunction methods.
+ */
+public class PlatformAffinityFunctionTarget extends PlatformAbstractTarget {
+ /** */
+ private static final int OP_PARTITION = 1;
+
+ /** */
+ private static final int OP_REMOVE_NODE = 2;
+
+ /** */
+ private static final int OP_ASSIGN_PARTITIONS = 3;
+
+ /** Inner function to delegate calls to. */
+ private final AffinityFunction baseFunc;
+
+ /** Thread local to hold the current affinity function context. */
+ private static final ThreadLocal<AffinityFunctionContext> currentAffCtx = new ThreadLocal<>();
+
+ /**
+ * Constructor.
+ *
+ * @param platformCtx Context.
+ * @param baseFunc Function to wrap.
+ */
+ protected PlatformAffinityFunctionTarget(PlatformContext platformCtx, AffinityFunction baseFunc) {
+ super(platformCtx);
+
+ assert baseFunc != null;
+ this.baseFunc = baseFunc;
+
+ try {
+ platformCtx.kernalContext().resource().injectGeneric(baseFunc);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
+ if (type == OP_PARTITION)
+ return baseFunc.partition(reader.readObjectDetached());
+ else if (type == OP_REMOVE_NODE) {
+ baseFunc.removeNode(reader.readUuid());
+
+ return 0;
+ }
+
+ return super.processInStreamOutLong(type, reader);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
+ if (type == OP_ASSIGN_PARTITIONS) {
+ AffinityFunctionContext affCtx = currentAffCtx.get();
+
+ if (affCtx == null)
+ throw new IgniteException("Thread-local AffinityFunctionContext is null. " +
+ "This may indicate an unsupported call to the base AffinityFunction.");
+
+ final List<List<ClusterNode>> partitions = baseFunc.assignPartitions(affCtx);
+
+ PlatformAffinityUtils.writePartitionAssignment(partitions, writer, platformContext());
+
+ return;
+ }
+
+ super.processOutStream(type, writer);
+ }
+
+ /**
+ * Sets the context for current operation.
+ *
+ * @param ctx Context.
+ */
+ void setCurrentAffinityFunctionContext(AffinityFunctionContext ctx) {
+ currentAffCtx.set(ctx);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityUtils.java
new file mode 100644
index 0000000..b1e1b23
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityUtils.java
@@ -0,0 +1,116 @@
+/*
+ * 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.processors.platform.cache.affinity;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Affinity serialization functions.
+ */
+public class PlatformAffinityUtils {
+ /**
+ * Writes the affinity function context.
+ * @param affCtx Affinity context.
+ * @param writer Writer.
+ * @param ctx Platform context.
+ */
+ public static void writeAffinityFunctionContext(AffinityFunctionContext affCtx, BinaryRawWriterEx writer,
+ PlatformContext ctx) {
+ assert affCtx != null;
+ assert writer != null;
+ assert ctx != null;
+
+ ctx.writeNodes(writer, affCtx.currentTopologySnapshot());
+
+ writer.writeInt(affCtx.backups());
+ writer.writeLong(affCtx.currentTopologyVersion().topologyVersion());
+ writer.writeInt(affCtx.currentTopologyVersion().minorTopologyVersion());
+
+ ctx.writeEvent(writer, affCtx.discoveryEvent());
+
+ // Write previous assignment
+ List<List<ClusterNode>> prevAssignment = ((GridAffinityFunctionContextImpl)affCtx).prevAssignment();
+
+ if (prevAssignment == null)
+ writer.writeInt(-1);
+ else {
+ writer.writeInt(prevAssignment.size());
+
+ for (List<ClusterNode> part : prevAssignment)
+ ctx.writeNodes(writer, part);
+ }
+ }
+
+ /**
+ * Writes the partition assignment to a stream.
+ *
+ * @param partitions Partitions.
+ * @param writer Writer.
+ */
+ public static void writePartitionAssignment(Collection<List<ClusterNode>> partitions, BinaryRawWriterEx writer,
+ PlatformContext ctx) {
+ assert partitions != null;
+ assert writer != null;
+
+ writer.writeInt(partitions.size());
+
+ for (List<ClusterNode> part : partitions)
+ ctx.writeNodes(writer, part);
+ }
+
+ /**
+ * Reads the partition assignment.
+ *
+ * @param reader Reader.
+ * @param ctx Platform context.
+ * @return Partitions.
+ */
+ public static List<List<ClusterNode>> readPartitionAssignment(BinaryRawReader reader, PlatformContext ctx) {
+ assert reader != null;
+ assert ctx != null;
+
+ int partCnt = reader.readInt();
+
+ List<List<ClusterNode>> res = new ArrayList<>(partCnt);
+
+ IgniteClusterEx cluster = ctx.kernalContext().grid().cluster();
+
+ for (int i = 0; i < partCnt; i++) {
+ int partSize = reader.readInt();
+
+ List<ClusterNode> part = new ArrayList<>(partSize);
+
+ for (int j = 0; j < partSize; j++)
+ part.add(cluster.node(reader.readUuid()));
+
+ res.add(part);
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
index 47862a2..1759a5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.platform.callback;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunctionTarget;
import org.apache.ignite.internal.util.GridStripedSpinBusyLock;
/**
@@ -920,6 +921,94 @@ public class PlatformCallbackGateway {
}
/**
+ * Initializes affinity function.
+ *
+ * @param memPtr Pointer to a stream with serialized affinity function.
+ * @param baseFunc Optional func for base calls.
+ * @return Affinity function pointer.
+ */
+ public long affinityFunctionInit(long memPtr, PlatformAffinityFunctionTarget baseFunc) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.affinityFunctionInit(envPtr, memPtr, baseFunc);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Gets the partition from affinity function.
+ *
+ * @param ptr Affinity function pointer.
+ * @param memPtr Pointer to a stream with key object.
+ * @return Partition number for a given key.
+ */
+ public int affinityFunctionPartition(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.affinityFunctionPartition(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Assigns the affinity partitions.
+ *
+ * @param ptr Affinity function pointer.
+ * @param outMemPtr Pointer to a stream with affinity context.
+ * @param inMemPtr Pointer to a stream with result.
+ */
+ public void affinityFunctionAssignPartitions(long ptr, long outMemPtr, long inMemPtr){
+ enter();
+
+ try {
+ PlatformCallbackUtils.affinityFunctionAssignPartitions(envPtr, ptr, outMemPtr, inMemPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Removes the node from affinity function.
+ *
+ * @param ptr Affinity function pointer.
+ * @param memPtr Pointer to a stream with node id.
+ */
+ public void affinityFunctionRemoveNode(long ptr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.affinityFunctionRemoveNode(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Destroys the affinity function.
+ *
+ * @param ptr Affinity function pointer.
+ */
+ public void affinityFunctionDestroy(long ptr) {
+ if (!lock.enterBusy())
+ return; // skip: destroy is not necessary during shutdown.
+
+ try {
+ PlatformCallbackUtils.affinityFunctionDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
* Enter gateway.
*/
protected void enter() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
index 7f3ba6f..1cbbd7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.platform.callback;
+import org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunctionTarget;
+
/**
* Platform callback utility methods. Implemented in target platform. All methods in this class must be
* package-visible and invoked only through {@link PlatformCallbackGateway}.
@@ -482,6 +484,53 @@ public class PlatformCallbackUtils {
static native long extensionCallbackInLongLongOutLong(long envPtr, int typ, long arg1, long arg2);
/**
+ * Initializes affinity function.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Pointer to a stream with serialized affinity function.
+ * @param baseFunc Optional func for base calls.
+ * @return Affinity function pointer.
+ */
+ static native long affinityFunctionInit(long envPtr, long memPtr, PlatformAffinityFunctionTarget baseFunc);
+
+ /**
+ * Gets the partition from affinity function.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Affinity function pointer.
+ * @param memPtr Pointer to a stream with key object.
+ * @return Partition number for a given key.
+ */
+ static native int affinityFunctionPartition(long envPtr, long ptr, long memPtr);
+
+ /**
+ * Assigns the affinity partitions.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Affinity function pointer.
+ * @param outMemPtr Pointer to a stream with affinity context.
+ * @param inMemPtr Pointer to a stream with result.
+ */
+ static native void affinityFunctionAssignPartitions(long envPtr, long ptr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Removes the node from affinity function.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Affinity function pointer.
+ * @param memPtr Pointer to a stream with node id.
+ */
+ static native void affinityFunctionRemoveNode(long envPtr, long ptr, long memPtr);
+
+ /**
+ * Destroys the affinity function.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Affinity function pointer.
+ */
+ static native void affinityFunctionDestroy(long envPtr, long ptr);
+
+ /**
* Private constructor.
*/
private PlatformCallbackUtils() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6b9b441..f441f4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,21 +19,28 @@ package org.apache.ignite.internal.processors.platform.dotnet;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryBasicIdMapper;
-import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.fair.FairAffinityFunction;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
+import org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction;
import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
-import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
@@ -42,8 +49,8 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction;
import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
import java.util.ArrayList;
@@ -183,7 +190,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
try (PlatformMemory inMem = memMgr.allocate()) {
PlatformOutputStream out = outMem.output();
- BinaryRawWriterEx writer = marshaller().writer(out);
+ final GridBinaryMarshaller marshaller = marshaller();
+
+ BinaryRawWriterEx writer = marshaller.writer(out);
PlatformUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
@@ -196,12 +205,24 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
writer.writeMap(bean.getProperties());
}
+ // Write .NET affinity funcs
+ List<PlatformDotNetAffinityFunction> affFuncs = affinityFunctions(igniteCfg);
+
+ writer.writeInt(affFuncs.size());
+
+ for (PlatformDotNetAffinityFunction func : affFuncs) {
+ writer.writeString(func.getTypeName());
+ writer.writeMap(func.getProperties());
+ }
+
out.synchronize();
gate.extensionCallbackInLongLongOutLong(
PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
- processPrepareResult(inMem.input());
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(marshaller.context(), inMem.input(), null);
+
+ processPrepareResult(reader);
}
}
}
@@ -211,7 +232,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
*
* @param in Input stream.
*/
- private void processPrepareResult(PlatformInputStream in) {
+ private void processPrepareResult(BinaryReaderExImpl in) {
assert cfg != null;
List<PlatformDotNetLifecycleBean> beans = beans(cfg);
@@ -245,6 +266,63 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
cfg.setLifecycleBeans(mergedBeans);
}
}
+
+ // Process affinity functions
+ List<PlatformDotNetAffinityFunction> affFuncs = affinityFunctions(cfg);
+
+ if (!affFuncs.isEmpty()) {
+ for (PlatformDotNetAffinityFunction aff : affFuncs)
+ aff.init(readAffinityFunction(in));
+ }
+ }
+
+ /**
+ * Reads the affinity function.
+ *
+ * @param in Stream.
+ * @return Affinity function.
+ */
+ private static PlatformAffinityFunction readAffinityFunction(BinaryRawReaderEx in) {
+ byte plcTyp = in.readByte();
+
+ if (plcTyp == 0)
+ return null;
+
+ int partitions = in.readInt();
+ boolean exclNeighbours = in.readBoolean();
+ byte overrideFlags = in.readByte();
+ Object userFunc = in.readObjectDetached();
+
+ AffinityFunction baseFunc = null;
+
+ switch (plcTyp) {
+ case 1: {
+ FairAffinityFunction f = new FairAffinityFunction();
+
+ f.setPartitions(partitions);
+ f.setExcludeNeighbors(exclNeighbours);
+
+ baseFunc = f;
+
+ break;
+ }
+
+ case 2: {
+ RendezvousAffinityFunction f = new RendezvousAffinityFunction();
+
+ f.setPartitions(partitions);
+ f.setExcludeNeighbors(exclNeighbours);
+
+ baseFunc = f;
+
+ break;
+ }
+
+ default:
+ assert plcTyp == 3 : "Unknown affinity function policy type: " + plcTyp;
+ }
+
+ return new PlatformAffinityFunction(userFunc, partitions, overrideFlags, baseFunc);
}
/**
@@ -289,4 +367,25 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
throw U.convertException(e);
}
}
+
+ /**
+ * Find .NET affinity functions in configuration.
+ *
+ * @param cfg Configuration.
+ * @return affinity functions.
+ */
+ private static List<PlatformDotNetAffinityFunction> affinityFunctions(IgniteConfiguration cfg) {
+ List<PlatformDotNetAffinityFunction> res = new ArrayList<>();
+
+ CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
+
+ if (cacheCfg != null) {
+ for (CacheConfiguration ccfg : cacheCfg) {
+ if (ccfg.getAffinity() instanceof PlatformDotNetAffinityFunction)
+ res.add((PlatformDotNetAffinityFunction)ccfg.getAffinity());
+ }
+ }
+
+ return res;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
new file mode 100644
index 0000000..254c379
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
@@ -0,0 +1,171 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * AffinityFunction implementation which can be used to configure .NET affinity function in Java Spring configuration.
+ */
+public class PlatformDotNetAffinityFunction implements AffinityFunction, Externalizable, LifecycleAware {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** .NET type name. */
+ private transient String typName;
+
+ /** Properties. */
+ private transient Map<String, ?> props;
+
+ /** Inner function. */
+ private PlatformAffinityFunction func;
+
+ /**
+ * Gets .NET type name.
+ *
+ * @return .NET type name.
+ */
+ public String getTypeName() {
+ return typName;
+ }
+
+ /**
+ * Sets .NET type name.
+ *
+ * @param typName .NET type name.
+ */
+ public void setTypeName(String typName) {
+ this.typName = typName;
+ }
+
+ /**
+ * Get properties.
+ *
+ * @return Properties.
+ */
+ public Map<String, ?> getProperties() {
+ return props;
+ }
+
+ /**
+ * Set properties.
+ *
+ * @param props Properties.
+ */
+ public void setProperties(Map<String, ?> props) {
+ this.props = props;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reset() {
+ assert func != null;
+
+ func.reset();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partitions() {
+ assert func != null;
+
+ return func.partitions();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partition(Object key) {
+ assert func != null;
+
+ return func.partition(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<List<ClusterNode>> assignPartitions(AffinityFunctionContext affCtx) {
+ assert func != null;
+
+ return func.assignPartitions(affCtx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeNode(UUID nodeId) {
+ assert func != null;
+
+ func.removeNode(nodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(func);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ func = (PlatformAffinityFunction) in.readObject();
+ }
+
+ /**
+ * Initializes this instance.
+ *
+ * @param func Underlying func.
+ */
+ public void init(PlatformAffinityFunction func) {
+ assert func != null;
+
+ this.func = func;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ assert func != null;
+
+ func.start();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+ assert func != null;
+
+ func.stop();
+ }
+
+ /**
+ * Injects the Ignite.
+ *
+ * @param ignite Ignite.
+ */
+ @SuppressWarnings("unused")
+ @IgniteInstanceResource
+ private void setIgnite(Ignite ignite) {
+ assert func != null;
+
+ func.setIgnite(ignite);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index e629c77..91caddd 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -103,6 +103,12 @@ namespace ignite
typedef long long(JNICALL *ExtensionCallbackInLongOutLongHandler)(void* target, int typ, long long arg1);
typedef long long(JNICALL *ExtensionCallbackInLongLongOutLongHandler)(void* target, int typ, long long arg1, long long arg2);
+ typedef long long(JNICALL *AffinityFunctionInitHandler)(void* target, long long memPtr, void* baseFunc);
+ typedef int(JNICALL *AffinityFunctionPartitionHandler)(void* target, long long ptr, long long memPtr);
+ typedef void(JNICALL *AffinityFunctionAssignPartitionsHandler)(void* target, long long ptr, long long inMemPtr, long long outMemPtr);
+ typedef void(JNICALL *AffinityFunctionRemoveNodeHandler)(void* target, long long ptr, long long memPtr);
+ typedef void(JNICALL *AffinityFunctionDestroyHandler)(void* target, long long ptr);
+
/**
* JNI handlers holder.
*/
@@ -177,6 +183,12 @@ namespace ignite
ExtensionCallbackInLongOutLongHandler extensionCallbackInLongOutLong;
ExtensionCallbackInLongLongOutLongHandler extensionCallbackInLongLongOutLong;
+
+ AffinityFunctionInitHandler affinityFunctionInit;
+ AffinityFunctionPartitionHandler affinityFunctionPartition;
+ AffinityFunctionAssignPartitionsHandler affinityFunctionAssignPartitions;
+ AffinityFunctionRemoveNodeHandler affinityFunctionRemoveNode;
+ AffinityFunctionDestroyHandler affinityFunctionDestroy;
};
/**
@@ -683,6 +695,12 @@ namespace ignite
JNIEXPORT jlong JNICALL JniExtensionCallbackInLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1);
JNIEXPORT jlong JNICALL JniExtensionCallbackInLongLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1, jlong arg2);
+
+ JNIEXPORT jlong JNICALL JniAffinityFunctionInit(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr, jobject baseFunc);
+ JNIEXPORT jint JNICALL JniAffinityFunctionPartition(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
+ JNIEXPORT void JNICALL JniAffinityFunctionAssignPartitions(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong inMemPtr, jlong outMemPtr);
+ JNIEXPORT void JNICALL JniAffinityFunctionRemoveNode(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
+ JNIEXPORT void JNICALL JniAffinityFunctionDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 63deba5..789b6a3 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -346,6 +346,12 @@ namespace ignite
JniMethod M_PLATFORM_CALLBACK_UTILS_EXTENSION_CALLBACK_IN_LONG_OUT_LONG = JniMethod("extensionCallbackInLongOutLong", "(JIJ)J", true);
JniMethod M_PLATFORM_CALLBACK_UTILS_EXTENSION_CALLBACK_IN_LONG_LONG_OUT_LONG = JniMethod("extensionCallbackInLongLongOutLong", "(JIJJ)J", true);
+ JniMethod M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_INIT = JniMethod("affinityFunctionInit", "(JJLorg/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunctionTarget;)J", true);
+ JniMethod M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_PARTITION = JniMethod("affinityFunctionPartition", "(JJJ)I", true);
+ JniMethod M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_ASSIGN_PARTITIONS = JniMethod("affinityFunctionAssignPartitions", "(JJJJ)V", true);
+ JniMethod M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_REMOVE_NODE = JniMethod("affinityFunctionRemoveNode", "(JJJ)V", true);
+ JniMethod M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_DESTROY = JniMethod("affinityFunctionDestroy", "(JJ)V", true);
+
const char* C_PLATFORM_UTILS = "org/apache/ignite/internal/processors/platform/utils/PlatformUtils";
JniMethod M_PLATFORM_UTILS_REALLOC = JniMethod("reallocate", "(JI)V", true);
JniMethod M_PLATFORM_UTILS_ERR_DATA = JniMethod("errorData", "(Ljava/lang/Throwable;)[B", true);
@@ -766,7 +772,7 @@ namespace ignite
void RegisterNatives(JNIEnv* env) {
{
- JNINativeMethod methods[52];
+ JNINativeMethod methods[57];
int idx = 0;
@@ -840,6 +846,12 @@ namespace ignite
AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_EXTENSION_CALLBACK_IN_LONG_OUT_LONG, reinterpret_cast<void*>(JniExtensionCallbackInLongOutLong));
AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_EXTENSION_CALLBACK_IN_LONG_LONG_OUT_LONG, reinterpret_cast<void*>(JniExtensionCallbackInLongLongOutLong));
+ AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_INIT, reinterpret_cast<void*>(JniAffinityFunctionInit));
+ AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_PARTITION, reinterpret_cast<void*>(JniAffinityFunctionPartition));
+ AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_ASSIGN_PARTITIONS, reinterpret_cast<void*>(JniAffinityFunctionAssignPartitions));
+ AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_REMOVE_NODE, reinterpret_cast<void*>(JniAffinityFunctionRemoveNode));
+ AddNativeMethod(methods + idx++, M_PLATFORM_CALLBACK_UTILS_AFFINITY_FUNCTION_DESTROY, reinterpret_cast<void*>(JniAffinityFunctionDestroy));
+
jint res = env->RegisterNatives(FindClass(env, C_PLATFORM_CALLBACK_UTILS), methods, idx);
if (res != JNI_OK)
@@ -2471,6 +2483,26 @@ namespace ignite
JNIEXPORT jlong JNICALL JniExtensionCallbackInLongLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1, jlong arg2) {
IGNITE_SAFE_FUNC(env, envPtr, ExtensionCallbackInLongLongOutLongHandler, extensionCallbackInLongLongOutLong, typ, arg1, arg2);
}
- }
+
+ JNIEXPORT jlong JNICALL JniAffinityFunctionInit(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr, jobject baseFunc) {
+ void* baseFuncRef = baseFunc ? env->NewGlobalRef(baseFunc) : nullptr;
+ IGNITE_SAFE_FUNC(env, envPtr, AffinityFunctionInitHandler, affinityFunctionInit, memPtr, baseFuncRef);
+ }
+
+ JNIEXPORT jint JNICALL JniAffinityFunctionPartition(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr) {
+ IGNITE_SAFE_FUNC(env, envPtr, AffinityFunctionPartitionHandler, affinityFunctionPartition, ptr, memPtr);
+ }
+
+ JNIEXPORT void JNICALL JniAffinityFunctionAssignPartitions(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong inMemPtr, jlong outMemPtr) {
+ IGNITE_SAFE_PROC(env, envPtr, AffinityFunctionAssignPartitionsHandler, affinityFunctionAssignPartitions, ptr, inMemPtr, outMemPtr);
+ }
+
+ JNIEXPORT void JNICALL JniAffinityFunctionRemoveNode(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr) {
+ IGNITE_SAFE_PROC(env, envPtr, AffinityFunctionRemoveNodeHandler, affinityFunctionRemoveNode, ptr, memPtr);
+ }
+
+ JNIEXPORT void JNICALL JniAffinityFunctionDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr) {
+ IGNITE_SAFE_PROC(env, envPtr, AffinityFunctionDestroyHandler, affinityFunctionDestroy, ptr);
+ } }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 0194450..89cd2a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -60,6 +60,7 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Cache\Affinity\AffinityFunctionSpringTest.cs" />
<Compile Include="Cache\CacheDynamicStartTest.cs" />
<Compile Include="Cache\CacheTestAsyncWrapper.cs" />
<Compile Include="Cache\CacheAbstractTest.cs" />
@@ -175,6 +176,12 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
+ <Content Include="Config\Cache\Affinity\affinity-function2.xml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Cache\Affinity\affinity-function.xml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="Config\Cache\Store\cache-store-session.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@@ -262,4 +269,4 @@ copy /Y $(SolutionDir)Apache.Ignite\bin\$(PlatformName)\$(ConfigurationName)\Apa
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionSpringTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionSpringTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionSpringTest.cs
new file mode 100644
index 0000000..7b317ac
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionSpringTest.cs
@@ -0,0 +1,184 @@
+\ufeff/*
+ * 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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+// ReSharper disable UnusedMember.Local
+namespace Apache.Ignite.Core.Tests.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Cache.Affinity.Fair;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests AffinityFunction defined in Spring XML.
+ /// </summary>
+ public class AffinityFunctionSpringTest : IgniteTestBase
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AffinityFunctionSpringTest"/> class.
+ /// </summary>
+ public AffinityFunctionSpringTest() : base(6,
+ "config\\cache\\affinity\\affinity-function.xml",
+ "config\\cache\\affinity\\affinity-function2.xml")
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Tests the static cache.
+ /// </summary>
+ [Test]
+ public void TestStaticCache()
+ {
+ ValidateAffinityFunction(Grid.GetCache<long, int>("cache1"));
+ ValidateAffinityFunction(Grid2.GetCache<long, int>("cache1"));
+ ValidateAffinityFunction(Grid.GetCache<long, int>("cache2"));
+ ValidateAffinityFunction(Grid2.GetCache<long, int>("cache2"));
+ }
+
+ /// <summary>
+ /// Tests the dynamic cache.
+ /// </summary>
+ [Test]
+ public void TestDynamicCache()
+ {
+ ValidateAffinityFunction(Grid.CreateCache<long, int>("dyn-cache-1"));
+ ValidateAffinityFunction(Grid2.GetCache<long, int>("dyn-cache-1"));
+
+ ValidateAffinityFunction(Grid2.CreateCache<long, int>("dyn-cache-2"));
+ ValidateAffinityFunction(Grid.GetCache<long, int>("dyn-cache-2"));
+
+ ValidateAffinityFunction(Grid.CreateCache<long, int>("dyn-cache2-1"));
+ ValidateAffinityFunction(Grid2.GetCache<long, int>("dyn-cache2-1"));
+
+ ValidateAffinityFunction(Grid2.CreateCache<long, int>("dyn-cache2-2"));
+ ValidateAffinityFunction(Grid.GetCache<long, int>("dyn-cache2-2"));
+ }
+
+ /// <summary>
+ /// Validates the affinity function.
+ /// </summary>
+ /// <param name="cache">The cache.</param>
+ private static void ValidateAffinityFunction(ICache<long, int> cache)
+ {
+ var aff = cache.Ignite.GetAffinity(cache.Name);
+
+ Assert.AreEqual(5, aff.Partitions);
+
+ // Predefined map
+ Assert.AreEqual(2, aff.GetPartition(1L));
+ Assert.AreEqual(1, aff.GetPartition(2L));
+
+ // Other keys
+ Assert.AreEqual(1, aff.GetPartition(13L));
+ Assert.AreEqual(3, aff.GetPartition(4L));
+ }
+
+ private class TestFunc : IAffinityFunction // [Serializable] is not necessary
+ {
+ [InstanceResource]
+ private readonly IIgnite _ignite = null;
+
+ private int Property1 { get; set; }
+
+ private string Property2 { get; set; }
+
+ public int Partitions
+ {
+ get { return 5; }
+ }
+
+ public int GetPartition(object key)
+ {
+ Assert.IsNotNull(_ignite);
+ Assert.AreEqual(1, Property1);
+ Assert.AreEqual("1", Property2);
+
+ var longKey = (long)key;
+ int res;
+
+ if (TestFairFunc.PredefinedParts.TryGetValue(longKey, out res))
+ return res;
+
+ return (int)(longKey * 2 % 5);
+ }
+
+ // ReSharper disable once UnusedParameter.Local
+ public void RemoveNode(Guid nodeId)
+ {
+ // No-op.
+ }
+
+ public IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
+ {
+ return Enumerable.Range(0, Partitions).Select(x => context.CurrentTopologySnapshot);
+ }
+ }
+
+ private class TestFairFunc : FairAffinityFunction // [Serializable] is not necessary
+ {
+ public static readonly Dictionary<long, int> PredefinedParts = new Dictionary<long, int>
+ {
+ {1, 2},
+ {2, 1}
+ };
+
+ [InstanceResource]
+ private readonly IIgnite _ignite = null;
+
+ private int Property1 { get; set; }
+
+ private string Property2 { get; set; }
+
+ public override int GetPartition(object key)
+ {
+ Assert.IsNotNull(_ignite);
+ Assert.AreEqual(1, Property1);
+ Assert.AreEqual("1", Property2);
+
+ Assert.IsInstanceOf<long>(key);
+
+ var basePart = base.GetPartition(key);
+ Assert.Greater(basePart, -1);
+ Assert.Less(basePart, Partitions);
+
+ var longKey = (long) key;
+ int res;
+
+ if (PredefinedParts.TryGetValue(longKey, out res))
+ return res;
+
+ return (int) (longKey * 2 % 5);
+ }
+
+ public override IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
+ {
+ var baseRes = base.AssignPartitions(context).ToList(); // test base call
+
+ Assert.AreEqual(Partitions, baseRes.Count);
+
+ return baseRes;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function.xml
new file mode 100644
index 0000000..67ff128
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function.xml
@@ -0,0 +1,129 @@
+\ufeff<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration">
+ <null/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction">
+ <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Affinity.AffinityFunctionSpringTest+TestFunc, Apache.Ignite.Core.Tests"/>
+ <property name="properties">
+ <map>
+ <entry key="Property1">
+ <value type="java.lang.Integer">1</value>
+ </entry>
+ <entry key="Property2" value="1"/>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="dyn-cache-*"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction">
+ <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Affinity.AffinityFunctionSpringTest+TestFunc, Apache.Ignite.Core.Tests"/>
+ <property name="properties">
+ <map>
+ <entry key="Property1">
+ <value type="java.lang.Integer">1</value>
+ </entry>
+ <entry key="Property2" value="1"/>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache2"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction">
+ <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Affinity.AffinityFunctionSpringTest+TestFairFunc, Apache.Ignite.Core.Tests"/>
+ <property name="properties">
+ <map>
+ <entry key="Property1">
+ <value type="java.lang.Integer">1</value>
+ </entry>
+ <entry key="Property2" value="1"/>
+ <entry key="Partitions">
+ <value type="java.lang.Integer">5</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="dyn-cache2-*"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction">
+ <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Affinity.AffinityFunctionSpringTest+TestFairFunc, Apache.Ignite.Core.Tests"/>
+ <property name="properties">
+ <map>
+ <entry key="Property1">
+ <value type="java.lang.Integer">1</value>
+ </entry>
+ <entry key="Property2" value="1"/>
+ <entry key="Partitions">
+ <value type="java.lang.Integer">5</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ <property name="socketTimeout" value="300" />
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function2.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function2.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function2.xml
new file mode 100644
index 0000000..cab34b5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Affinity/affinity-function2.xml
@@ -0,0 +1,49 @@
+\ufeff<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+ <property name="gridName" value="grid2" />
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ <property name="socketTimeout" value="300" />
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
index 2b0ab8e..95be6dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests
using System;
using System.Diagnostics;
using System.Reflection;
+ using Apache.Ignite.Core.Tests.Cache.Affinity;
using Apache.Ignite.Core.Tests.Memory;
using NUnit.ConsoleRunner;
@@ -33,7 +34,7 @@ namespace Apache.Ignite.Core.Tests
//TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
- TestAll(typeof (ExecutableTest));
+ TestAll(typeof (AffinityFunctionSpringTest));
//TestAllInAssembly();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 05a7fa7..6793873 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -55,6 +55,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Binary\Package-Info.cs" />
+ <Compile Include="Cache\Affinity\AffinityFunctionBase.cs" />
+ <Compile Include="Cache\Affinity\AffinityFunctionContext.cs" />
+ <Compile Include="Cache\Affinity\AffinityTopologyVersion.cs" />
+ <Compile Include="Cache\Affinity\Fair\FairAffinityFunction.cs" />
+ <Compile Include="Cache\Affinity\IAffinityFunction.cs" />
+ <Compile Include="Cache\Affinity\Rendezvous\RendezvousAffinityFunction.cs" />
<Compile Include="Cache\CacheAtomicUpdateTimeoutException.cs" />
<Compile Include="Cache\CacheEntryProcessorException.cs" />
<Compile Include="Cache\CacheException.cs" />
@@ -108,7 +114,10 @@
<Compile Include="Common\IgniteFutureCancelledException.cs" />
<Compile Include="Common\IgniteGuid.cs" />
<Compile Include="Common\Package-Info.cs" />
+ <Compile Include="Impl\Cache\Affinity\AffinityFunctionSerializer.cs" />
+ <Compile Include="Impl\Cache\Affinity\PlatformAffinityFunction.cs" />
<Compile Include="Impl\Cache\Event\JavaCacheEntryEventFilter.cs" />
+ <Compile Include="Impl\Common\ObjectInfoHolder.cs" />
<Compile Include="Impl\Common\PlatformJavaObjectFactoryProxy.cs" />
<Compile Include="Compute\ComputeExecutionRejectedException.cs" />
<Compile Include="Compute\ComputeJobAdapter.cs" />
@@ -414,4 +423,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
new file mode 100644
index 0000000..ce2e5e1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
@@ -0,0 +1,139 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Base class for predefined affinity functions.
+ /// </summary>
+ [Serializable]
+ public abstract class AffinityFunctionBase : IAffinityFunction
+ {
+ /// <summary> The default value for <see cref="Partitions"/> property. </summary>
+ public const int DefaultPartitions = 1024;
+
+ /** */
+ private int _partitions = DefaultPartitions;
+
+ /** */
+ private IAffinityFunction _baseFunction;
+
+
+ /// <summary>
+ /// Gets or sets the total number of partitions.
+ /// </summary>
+ [DefaultValue(DefaultPartitions)]
+ public virtual int Partitions
+ {
+ get { return _partitions; }
+ set { _partitions = value; }
+ }
+
+ /// <summary>
+ /// Gets partition number for a given key starting from 0. Partitioned caches
+ /// should make sure that keys are about evenly distributed across all partitions
+ /// from 0 to <see cref="Partitions" /> for best performance.
+ /// <para />
+ /// Note that for fully replicated caches it is possible to segment key sets among different
+ /// grid node groups. In that case each node group should return a unique partition
+ /// number. However, unlike partitioned cache, mappings of keys to nodes in
+ /// replicated caches are constant and a node cannot migrate from one partition
+ /// to another.
+ /// </summary>
+ /// <param name="key">Key to get partition for.</param>
+ /// <returns>
+ /// Partition number for a given key.
+ /// </returns>
+ public virtual int GetPartition(object key)
+ {
+ ThrowIfUninitialized();
+
+ return _baseFunction.GetPartition(key);
+ }
+
+ /// <summary>
+ /// Removes node from affinity. This method is called when it is safe to remove
+ /// disconnected node from affinity mapping.
+ /// </summary>
+ /// <param name="nodeId">The node identifier.</param>
+ public virtual void RemoveNode(Guid nodeId)
+ {
+ ThrowIfUninitialized();
+
+ _baseFunction.RemoveNode(nodeId);
+ }
+
+ /// <summary>
+ /// Gets affinity nodes for a partition. In case of replicated cache, all returned
+ /// nodes are updated in the same manner. In case of partitioned cache, the returned
+ /// list should contain only the primary and back up nodes with primary node being
+ /// always first.
+ /// <pare />
+ /// Note that partitioned affinity must obey the following contract: given that node
+ /// <code>N</code> is primary for some key <code>K</code>, if any other node(s) leave
+ /// grid and no node joins grid, node <code>N</code> will remain primary for key <code>K</code>.
+ /// </summary>
+ /// <param name="context">The affinity function context.</param>
+ /// <returns>
+ /// A collection of partitions, where each partition is a collection of nodes,
+ /// where first node is a primary node, and other nodes are backup nodes.
+ /// </returns>
+ public virtual IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
+ {
+ ThrowIfUninitialized();
+
+ return _baseFunction.AssignPartitions(context);
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to exclude same-host-neighbors from being backups of each other.
+ /// </summary>
+ public virtual bool ExcludeNeighbors { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AffinityFunctionBase"/> class.
+ /// </summary>
+ internal AffinityFunctionBase()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Sets the base function.
+ /// </summary>
+ /// <param name="baseFunc">The base function.</param>
+ internal void SetBaseFunction(IAffinityFunction baseFunc)
+ {
+ _baseFunction = baseFunc;
+ }
+
+ /// <summary>
+ /// Gets the direct usage error.
+ /// </summary>
+ private void ThrowIfUninitialized()
+ {
+ if (_baseFunction == null)
+ throw new IgniteException(GetType() + " has not yet been initialized.");
+ }
+ }
+}
[25/50] [abbrv] ignite git commit: IGNITE-3476 Node started within
SpringCacheManager does not inject Spring resources
Posted by vo...@apache.org.
IGNITE-3476 Node started within SpringCacheManager does not inject Spring resources
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a39770aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a39770aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a39770aa
Branch: refs/heads/ignite-2649
Commit: a39770aa48412fad57712a4cb580b028cb111eb9
Parents: 71ef652
Author: EdShangGG <es...@gridgain.com>
Authored: Tue Jul 26 12:46:05 2016 +0300
Committer: EdShangGG <es...@gridgain.com>
Committed: Tue Jul 26 12:46:05 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/spring/SpringCacheManager.java | 17 ++-
.../spring/SpringTransactionManager.java | 59 +++++----
.../test/java/config/spring-transactions.xml | 4 +-
.../ignite/TestInjectionLifecycleBean.java | 42 +++++++
.../org/apache/ignite/spring-injection-test.xml | 43 +++++++
.../SpringCacheManagerContextInjectionTest.java | 126 +++++++++++++++++++
.../testsuites/IgniteSpringTestSuite.java | 5 +
...gTransactionManagerContextInjectionTest.java | 125 ++++++++++++++++++
8 files changed, 393 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
index 71b723f..6d1a9b6 100644
--- a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
+++ b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSpring;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -28,6 +29,8 @@ import org.apache.ignite.configuration.NearCacheConfiguration;
import org.jsr166.ConcurrentHashMap8;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.cache.CacheManager;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
/**
* Implementation of Spring cache abstraction based on Ignite cache.
@@ -133,7 +136,7 @@ import org.springframework.cache.CacheManager;
* Ignite distribution, and all these nodes will participate
* in caching the data.
*/
-public class SpringCacheManager implements CacheManager, InitializingBean {
+public class SpringCacheManager implements CacheManager, InitializingBean, ApplicationContextAware {
/** Caches map. */
private final ConcurrentMap<String, SpringCache> caches = new ConcurrentHashMap8<>();
@@ -155,6 +158,14 @@ public class SpringCacheManager implements CacheManager, InitializingBean {
/** Ignite instance. */
private Ignite ignite;
+ /** Spring context */
+ private ApplicationContext springCtx;
+
+ /** {@inheritDoc} */
+ @Override public void setApplicationContext(ApplicationContext ctx) {
+ this.springCtx = ctx;
+ }
+
/**
* Gets configuration file path.
*
@@ -257,9 +268,9 @@ public class SpringCacheManager implements CacheManager, InitializingBean {
}
if (cfgPath != null)
- ignite = Ignition.start(cfgPath);
+ ignite = IgniteSpring.start(cfgPath, springCtx);
else if (cfg != null)
- ignite = Ignition.start(cfg);
+ ignite = IgniteSpring.start(cfg, springCtx);
else
ignite = Ignition.ignite(gridName);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java b/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
index d8bbbbd..32a7b43 100644
--- a/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
+++ b/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
@@ -21,12 +21,15 @@ import java.util.concurrent.TimeUnit;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSpring;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.InvalidIsolationLevelException;
import org.springframework.transaction.PlatformTransactionManager;
@@ -194,7 +197,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* </pre>
*/
public class SpringTransactionManager extends AbstractPlatformTransactionManager
- implements ResourceTransactionManager, PlatformTransactionManager, InitializingBean {
+ implements ResourceTransactionManager, PlatformTransactionManager, InitializingBean, ApplicationContextAware {
/**
* Logger.
*/
@@ -225,6 +228,14 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
*/
private Ignite ignite;
+ /** Spring context */
+ private ApplicationContext springCtx;
+
+ /** {@inheritDoc} */
+ @Override public void setApplicationContext(ApplicationContext ctx) {
+ this.springCtx = ctx;
+ }
+
/**
* Constructs the transaction manager with no target Ignite instance. An
* instance must be set before use.
@@ -319,9 +330,9 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
}
if (cfgPath != null)
- ignite = Ignition.start(cfgPath);
+ ignite = IgniteSpring.start(cfgPath, springCtx);
else if (cfg != null)
- ignite = Ignition.start(cfg);
+ ignite = IgniteSpring.start(cfg, springCtx);
else
ignite = Ignition.ignite(gridName);
@@ -335,12 +346,12 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
* {@inheritDoc}
*/
@Override protected Object doGetTransaction() throws TransactionException {
- IgniteTransactionObject txObject = new IgniteTransactionObject();
+ IgniteTransactionObject txObj = new IgniteTransactionObject();
- txObject.setTransactionHolder(
+ txObj.setTransactionHolder(
(IgniteTransactionHolder)TransactionSynchronizationManager.getResource(this.ignite), false);
- return txObject;
+ return txObj;
}
/**
@@ -350,11 +361,11 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
if (definition.getIsolationLevel() == TransactionDefinition.ISOLATION_READ_UNCOMMITTED)
throw new InvalidIsolationLevelException("Ignite does not support READ_UNCOMMITTED isolation level.");
- IgniteTransactionObject txObject = (IgniteTransactionObject)transaction;
+ IgniteTransactionObject txObj = (IgniteTransactionObject)transaction;
Transaction tx = null;
try {
- if (txObject.getTransactionHolder() == null || txObject.getTransactionHolder().isSynchronizedWithTransaction()) {
+ if (txObj.getTransactionHolder() == null || txObj.getTransactionHolder().isSynchronizedWithTransaction()) {
long timeout = ignite.configuration().getTransactionConfiguration().getDefaultTxTimeout();
if (definition.getTimeout() > 0)
@@ -366,17 +377,17 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
if (log.isDebugEnabled())
log.debug("Started Ignite transaction: " + newTx);
- txObject.setTransactionHolder(new IgniteTransactionHolder(newTx), true);
+ txObj.setTransactionHolder(new IgniteTransactionHolder(newTx), true);
}
- txObject.getTransactionHolder().setSynchronizedWithTransaction(true);
- txObject.getTransactionHolder().setTransactionActive(true);
+ txObj.getTransactionHolder().setSynchronizedWithTransaction(true);
+ txObj.getTransactionHolder().setTransactionActive(true);
- tx = txObject.getTransactionHolder().getTransaction();
+ tx = txObj.getTransactionHolder().getTransaction();
// Bind the session holder to the thread.
- if (txObject.isNewTransactionHolder())
- TransactionSynchronizationManager.bindResource(this.ignite, txObject.getTransactionHolder());
+ if (txObj.isNewTransactionHolder())
+ TransactionSynchronizationManager.bindResource(this.ignite, txObj.getTransactionHolder());
}
catch (Exception ex) {
if (tx != null)
@@ -390,8 +401,8 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
* {@inheritDoc}
*/
@Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
- IgniteTransactionObject txObject = (IgniteTransactionObject)status.getTransaction();
- Transaction tx = txObject.getTransactionHolder().getTransaction();
+ IgniteTransactionObject txObj = (IgniteTransactionObject)status.getTransaction();
+ Transaction tx = txObj.getTransactionHolder().getTransaction();
if (status.isDebug() && log.isDebugEnabled())
log.debug("Committing Ignite transaction: " + tx);
@@ -408,8 +419,8 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
* {@inheritDoc}
*/
@Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
- IgniteTransactionObject txObject = (IgniteTransactionObject)status.getTransaction();
- Transaction tx = txObject.getTransactionHolder().getTransaction();
+ IgniteTransactionObject txObj = (IgniteTransactionObject)status.getTransaction();
+ Transaction tx = txObj.getTransactionHolder().getTransaction();
if (status.isDebug() && log.isDebugEnabled())
log.debug("Rolling back Ignite transaction: " + tx);
@@ -426,27 +437,27 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
* {@inheritDoc}
*/
@Override protected void doCleanupAfterCompletion(Object transaction) {
- IgniteTransactionObject txObject = (IgniteTransactionObject)transaction;
+ IgniteTransactionObject txObj = (IgniteTransactionObject)transaction;
// Remove the transaction holder from the thread, if exposed.
- if (txObject.isNewTransactionHolder()) {
- Transaction tx = txObject.getTransactionHolder().getTransaction();
+ if (txObj.isNewTransactionHolder()) {
+ Transaction tx = txObj.getTransactionHolder().getTransaction();
TransactionSynchronizationManager.unbindResource(this.ignite);
if (log.isDebugEnabled())
log.debug("Releasing Ignite transaction: " + tx);
}
- txObject.getTransactionHolder().clear();
+ txObj.getTransactionHolder().clear();
}
/**
* {@inheritDoc}
*/
@Override protected boolean isExistingTransaction(Object transaction) throws TransactionException {
- IgniteTransactionObject txObject = (IgniteTransactionObject)transaction;
+ IgniteTransactionObject txObj = (IgniteTransactionObject)transaction;
- return (txObject.getTransactionHolder() != null && txObject.getTransactionHolder().isTransactionActive());
+ return (txObj.getTransactionHolder() != null && txObj.getTransactionHolder().isTransactionActive());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/config/spring-transactions.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/config/spring-transactions.xml b/modules/spring/src/test/java/config/spring-transactions.xml
index ba90cb0..392bd84 100644
--- a/modules/spring/src/test/java/config/spring-transactions.xml
+++ b/modules/spring/src/test/java/config/spring-transactions.xml
@@ -27,7 +27,9 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<tx:annotation-driven/>
- <context:component-scan base-package="org.apache.ignite.transactions.spring"/>
+ <context:component-scan base-package="org.apache.ignite.transactions.spring">
+ <context:exclude-filter type="annotation" expression="org.springframework.context.annotation.Configuration"/>
+ </context:component-scan>
<bean id="transactionManager" class="org.apache.ignite.transactions.spring.SpringTransactionManager">
<property name="transactionConcurrency" value="OPTIMISTIC"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/org/apache/ignite/TestInjectionLifecycleBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/TestInjectionLifecycleBean.java b/modules/spring/src/test/java/org/apache/ignite/TestInjectionLifecycleBean.java
new file mode 100644
index 0000000..2b8c932
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/TestInjectionLifecycleBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.springframework.context.ApplicationContext;
+
+import static org.junit.Assert.assertNotNull;
+
+/** Lifecycle bean for testing. */
+public class TestInjectionLifecycleBean implements LifecycleBean {
+ /** */
+ @SpringApplicationContextResource
+ private ApplicationContext appCtx;
+
+ /** Checks that context was injected. */
+ public void checkState() {
+ assertNotNull(appCtx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onLifecycleEvent(LifecycleEventType evt) {
+ checkState();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/org/apache/ignite/spring-injection-test.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring-injection-test.xml b/modules/spring/src/test/java/org/apache/ignite/spring-injection-test.xml
new file mode 100644
index 0000000..b8368a3
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/spring-injection-test.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ GridGain Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="lifecycleBeans">
+ <array>
+ <bean id="bean1" class="org.apache.ignite.TestInjectionLifecycleBean"/>
+ <bean id="bean2" class="org.apache.ignite.TestInjectionLifecycleBean"/>
+ </array>
+ </property>
+
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="gridName" value="springInjectionTest"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/org/apache/ignite/spring/SpringCacheManagerContextInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/SpringCacheManagerContextInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/SpringCacheManagerContextInjectionTest.java
new file mode 100644
index 0000000..1554198
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/SpringCacheManagerContextInjectionTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.spring;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.TestInjectionLifecycleBean;
+import org.apache.ignite.cache.spring.SpringCacheManager;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ *
+ */
+public class SpringCacheManagerContextInjectionTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBeanInjectionUsingConfigPath() throws Exception {
+ new AnnotationConfigApplicationContext(TestPathConfiguration.class);
+
+ Ignite grid = IgnitionEx.grid("springInjectionTest");
+
+ IgniteConfiguration cfg = grid.configuration();
+
+ LifecycleBean[] beans = cfg.getLifecycleBeans();
+
+ assertEquals(2, beans.length);
+
+ TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)beans[0];
+ TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)beans[1];
+
+ bean1.checkState();
+ bean2.checkState();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBeanInjectionUsingConfiguration() throws Exception {
+ BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class);
+
+ TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)factory.getBean("bean1");
+ TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)factory.getBean("bean2");
+
+ bean1.checkState();
+ bean2.checkState();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /** */
+ @SuppressWarnings("WeakerAccess")
+ @Configuration
+ static class TestPathConfiguration {
+ /** */
+ @Bean(name = "mgr")
+ public SpringCacheManager springCacheManager() {
+ SpringCacheManager mgr = new SpringCacheManager();
+
+ mgr.setConfigurationPath("org/apache/ignite/spring-injection-test.xml");
+
+ return mgr;
+ }
+ }
+
+ /** */
+ @SuppressWarnings("WeakerAccess")
+ @Configuration
+ static class TestCfgConfiguration {
+ /** */
+ @Bean(name = "mgr")
+ public SpringCacheManager springCacheManager() {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setLocalHost("127.0.0.1");
+
+ cfg.setGridName("scmt");
+
+ cfg.setLifecycleBeans(bean1(), bean2());
+
+ SpringCacheManager mgr = new SpringCacheManager();
+
+ mgr.setConfiguration(cfg);
+
+ return mgr;
+ }
+
+ /** */
+ @Bean(name = "bean1")
+ LifecycleBean bean1() {
+ return new TestInjectionLifecycleBean();
+ }
+
+ /** */
+ @Bean(name = "bean2")
+ LifecycleBean bean2() {
+ return new TestInjectionLifecycleBean();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
index 4fc159e..9ae3423 100644
--- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
+++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
@@ -28,8 +28,10 @@ import org.apache.ignite.p2p.GridP2PUserVersionChangeSelfTest;
import org.apache.ignite.spring.GridSpringCacheManagerSelfTest;
import org.apache.ignite.spring.IgniteExcludeInConfigurationTest;
import org.apache.ignite.spring.IgniteStartFromStreamConfigurationTest;
+import org.apache.ignite.spring.SpringCacheManagerContextInjectionTest;
import org.apache.ignite.spring.injection.GridServiceInjectionSpringResourceTest;
import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest;
+import org.apache.ignite.transactions.spring.SpringTransactionManagerContextInjectionTest;
/**
* Spring tests.
@@ -68,6 +70,9 @@ public class IgniteSpringTestSuite extends TestSuite {
suite.addTestSuite(GridServiceInjectionSpringResourceTest.class);
+ suite.addTestSuite(SpringCacheManagerContextInjectionTest.class);
+ suite.addTestSuite(SpringTransactionManagerContextInjectionTest.class);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a39770aa/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java
new file mode 100644
index 0000000..467be20
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.transactions.spring;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.TestInjectionLifecycleBean;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ *
+ */
+public class SpringTransactionManagerContextInjectionTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBeanInjectionUsingConfigPath() throws Exception {
+ BeanFactory factory = new AnnotationConfigApplicationContext(TestPathConfiguration.class);
+
+ Ignite grid = IgnitionEx.grid("springInjectionTest");
+
+ IgniteConfiguration cfg = grid.configuration();
+
+ LifecycleBean[] beans = cfg.getLifecycleBeans();
+
+ assertEquals(2, beans.length);
+
+ TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)beans[0];
+ TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)beans[1];
+
+ bean1.checkState();
+ bean2.checkState();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBeanInjectionUsingConfig() throws Exception {
+ BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class);
+
+ TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)factory.getBean("bean1");
+ TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)factory.getBean("bean2");
+
+ bean1.checkState();
+ bean2.checkState();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /** */
+ @SuppressWarnings("WeakerAccess")
+ @Configuration
+ static class TestPathConfiguration {
+ /** */
+ @Bean(name = "mgr")
+ public SpringTransactionManager springTransactionManager() {
+ SpringTransactionManager mgr = new SpringTransactionManager();
+
+ mgr.setConfigurationPath("org/apache/ignite/spring-injection-test.xml");
+
+ return mgr;
+ }
+ }
+
+ /** */
+ @SuppressWarnings("WeakerAccess")
+ @Configuration
+ static class TestCfgConfiguration {
+ /** */
+ @Bean(name = "mgr")
+ public SpringTransactionManager springTransactionManager() {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setLocalHost("127.0.0.1");
+
+ cfg.setGridName("stmcit");
+
+ cfg.setLifecycleBeans(bean1(), bean2());
+
+ SpringTransactionManager mgr = new SpringTransactionManager();
+
+ mgr.setConfiguration(cfg);
+
+ return mgr;
+ }
+
+ /** */
+ @Bean(name = "bean1")
+ LifecycleBean bean1() {
+ return new TestInjectionLifecycleBean();
+ }
+
+ /** */
+ @Bean(name = "bean2")
+ LifecycleBean bean2() {
+ return new TestInjectionLifecycleBean();
+ }
+ }
+}
\ No newline at end of file
[16/50] [abbrv] ignite git commit: ignite-3465 Do not call
super.toString for not-initialized BinaryObjectImpl.
Posted by vo...@apache.org.
ignite-3465 Do not call super.toString for not-initialized BinaryObjectImpl.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/78d7c136
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/78d7c136
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/78d7c136
Branch: refs/heads/ignite-2649
Commit: 78d7c136a3860f1cb4346b37bf8853bc8b576636
Parents: 84e83c9
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jul 19 13:35:59 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 19 13:35:59 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/binary/BinaryObjectImpl.java | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/78d7c136/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index 468cc25..3563fba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -586,4 +586,12 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx) {
return reader(rCtx, null);
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ if (arr == null || ctx == null)
+ return "BinaryObjectImpl [arr= " + (arr != null) + ", ctx=" + (ctx != null) + ", start=" + start + "]";
+
+ return super.toString();
+ }
}
[19/50] [abbrv] ignite git commit: IGNITE-3414: Hadoop: implemented
new weight-based map-reduce planner.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
index ffa6f7d..a69b72a 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
@@ -17,47 +17,27 @@
package org.apache.ignite.internal.processors.hadoop;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteFileSystem;
-import org.apache.ignite.IgniteSpringBean;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.hadoop.mapreduce.IgniteHadoopMapReducePlanner;
import org.apache.ignite.igfs.IgfsBlockLocation;
-import org.apache.ignite.igfs.IgfsFile;
-import org.apache.ignite.igfs.IgfsMetrics;
-import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.igfs.IgfsPathSummary;
-import org.apache.ignite.igfs.mapreduce.IgfsRecordResolver;
-import org.apache.ignite.igfs.mapreduce.IgfsTask;
-import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.cluster.IgniteClusterEx;
-import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopAbstractMapReducePlanner;
import org.apache.ignite.internal.processors.igfs.IgfsBlockLocationImpl;
-import org.apache.ignite.internal.processors.igfs.IgfsContext;
-import org.apache.ignite.internal.processors.igfs.IgfsEx;
-import org.apache.ignite.internal.processors.igfs.IgfsInputStreamAdapter;
-import org.apache.ignite.internal.processors.igfs.IgfsLocalMetrics;
-import org.apache.ignite.internal.processors.igfs.IgfsPaths;
-import org.apache.ignite.internal.processors.igfs.IgfsStatus;
+import org.apache.ignite.internal.processors.igfs.IgfsIgniteMock;
+import org.apache.ignite.internal.processors.igfs.IgfsMock;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.testframework.GridTestNode;
import org.apache.ignite.testframework.GridTestUtils;
-import org.jetbrains.annotations.Nullable;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
/**
*
@@ -90,12 +70,12 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
/** */
private static final String INVALID_HOST_3 = "invalid_host3";
- /** Mocked Grid. */
- private static final MockIgnite GRID = new MockIgnite();
-
/** Mocked IGFS. */
private static final IgniteFileSystem IGFS = new MockIgfs();
+ /** Mocked Grid. */
+ private static final IgfsIgniteMock GRID = new IgfsIgniteMock(null, IGFS);
+
/** Planner. */
private static final HadoopMapReducePlanner PLANNER = new IgniteHadoopMapReducePlanner();
@@ -109,15 +89,15 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
private static final ThreadLocal<HadoopMapReducePlan> PLAN = new ThreadLocal<>();
/**
- *
+ * Static initializer.
*/
static {
- GridTestUtils.setFieldValue(PLANNER, "ignite", GRID);
+ GridTestUtils.setFieldValue(PLANNER, HadoopAbstractMapReducePlanner.class, "ignite", GRID);
}
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- GridTestUtils.setFieldValue(PLANNER, "log", log());
+ GridTestUtils.setFieldValue(PLANNER, HadoopAbstractMapReducePlanner.class, "log", log());
BLOCK_MAP.clear();
PROXY_MAP.clear();
@@ -445,7 +425,7 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
top.add(node2);
top.add(node3);
- HadoopMapReducePlan plan = PLANNER.preparePlan(new MockJob(reducers, splitList), top, null);
+ HadoopMapReducePlan plan = PLANNER.preparePlan(new HadoopPlannerMockJob(splitList, reducers), top, null);
PLAN.set(plan);
@@ -607,81 +587,17 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
}
/**
- * Mocked job.
+ * Mocked IGFS.
*/
- private static class MockJob implements HadoopJob {
- /** Reducers count. */
- private final int reducers;
-
- /** */
- private Collection<HadoopInputSplit> splitList;
-
+ private static class MockIgfs extends IgfsMock {
/**
* Constructor.
- *
- * @param reducers Reducers count.
- * @param splitList Splits.
*/
- private MockJob(int reducers, Collection<HadoopInputSplit> splitList) {
- this.reducers = reducers;
- this.splitList = splitList;
- }
-
- /** {@inheritDoc} */
- @Override public HadoopJobId id() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public HadoopJobInfo info() {
- return new HadoopDefaultJobInfo() {
- @Override public int reducers() {
- return reducers;
- }
- };
+ public MockIgfs() {
+ super("igfs");
}
/** {@inheritDoc} */
- @Override public Collection<HadoopInputSplit> input() throws IgniteCheckedException {
- return splitList;
- }
-
- /** {@inheritDoc} */
- @Override public HadoopTaskContext getTaskContext(HadoopTaskInfo info) throws IgniteCheckedException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void initialize(boolean external, UUID nodeId) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void dispose(boolean external) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void prepareTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void cleanupTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void cleanupStagingDirectory() {
- // No-op.
- }
- }
-
- /**
- * Mocked IGFS.
- */
- private static class MockIgfs implements IgfsEx {
- /** {@inheritDoc} */
@Override public boolean isProxy(URI path) {
return PROXY_MAP.containsKey(path) && PROXY_MAP.get(path);
}
@@ -692,331 +608,8 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
}
/** {@inheritDoc} */
- @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len,
- long maxLen) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void stop(boolean cancel) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public IgfsContext context() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsPaths proxyPaths() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsInputStreamAdapter open(IgfsPath path, int bufSize, int seqReadsBeforePrefetch) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsInputStreamAdapter open(IgfsPath path) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsInputStreamAdapter open(IgfsPath path, int bufSize) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsStatus globalSpace() throws IgniteCheckedException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void globalSampling(@Nullable Boolean val) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Boolean globalSampling() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsLocalMetrics localMetrics() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public long groupBlockSize() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String clientLogDirectory() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void clientLogDirectory(String logDir) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean evictExclude(IgfsPath path, boolean primary) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String name() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public FileSystemConfiguration configuration() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override public boolean exists(IgfsPath path) {
return true;
}
-
- /** {@inheritDoc} */
- @Nullable @Override public IgfsFile info(IgfsPath path) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsPathSummary summary(IgfsPath path) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void rename(IgfsPath src, IgfsPath dest) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean delete(IgfsPath path, boolean recursive) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public void mkdirs(IgfsPath path) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public Collection<IgfsPath> listPaths(IgfsPath path) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Collection<IgfsFile> listFiles(IgfsPath path) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public long usedSpaceSize() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsOutputStream create(IgfsPath path, boolean overwrite) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
- long blockSize, @Nullable Map<String, String> props) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite,
- @Nullable IgniteUuid affKey, int replication, long blockSize, @Nullable Map<String, String> props) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsOutputStream append(IgfsPath path, boolean create) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create,
- @Nullable Map<String, String> props) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void setTimes(IgfsPath path, long accessTime, long modificationTime) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public IgfsMetrics metrics() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void resetMetrics() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public long size(IgfsPath path) {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public void format() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
- Collection<IgfsPath> paths, @Nullable T arg) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
- Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
- @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
- @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
- long maxRangeLen, @Nullable T arg) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteUuid nextAffinityKey() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteFileSystem withAsync() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isAsync() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public <R> IgniteFuture<R> future() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsSecondaryFileSystem asSecondary() {
- return null;
- }
- }
-
- /**
- * Mocked Grid.
- */
- @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
- private static class MockIgnite extends IgniteSpringBean implements IgniteEx {
- /** {@inheritDoc} */
- @Override public IgniteClusterEx cluster() {
- return (IgniteClusterEx)super.cluster();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteFileSystem igfsx(String name) {
- assert F.eq("igfs", name);
-
- return IGFS;
- }
-
- /** {@inheritDoc} */
- @Override public Hadoop hadoop() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex(@Nullable String name) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex() {
- return null;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public Collection<IgniteInternalCache<?, ?>> cachesx(@Nullable IgnitePredicate<? super IgniteInternalCache<?, ?>>... p) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean eventUserRecordable(int type) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public boolean allEventsUserRecordable(int[] types) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isJmxRemoteEnabled() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isRestartEnabled() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public ClusterNode localNode() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public String latestVersion() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public GridKernalContext context() {
- return null;
- }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
index 1cb4f74..5d1de38 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
@@ -20,9 +20,7 @@ package org.apache.ignite.internal.processors.hadoop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -395,10 +393,24 @@ public class HadoopMapReduceTest extends HadoopAbstractWordCountTest {
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
+ HadoopConfiguration hadoopCfg = createHadoopConfiguration();
+
+ if (hadoopCfg != null)
+ cfg.setHadoopConfiguration(hadoopCfg);
+
return G.start(cfg);
}
/**
+ * Creates custom Hadoop configuration.
+ *
+ * @return The Hadoop configuration.
+ */
+ protected HadoopConfiguration createHadoopConfiguration() {
+ return null;
+ }
+
+ /**
* @return IGFS configuration.
*/
@Override public FileSystemConfiguration igfsConfiguration() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopPlannerMockJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopPlannerMockJob.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopPlannerMockJob.java
new file mode 100644
index 0000000..88d0f80
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopPlannerMockJob.java
@@ -0,0 +1,168 @@
+/*
+ * 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.processors.hadoop;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.UUID;
+
+/**
+ * Mock job for planner tests.
+ */
+public class HadoopPlannerMockJob implements HadoopJob {
+ /** Input splits. */
+ private final Collection<HadoopInputSplit> splits;
+
+ /** Reducers count. */
+ private final int reducers;
+
+ /**
+ * Constructor.
+ *
+ * @param splits Input splits.
+ * @param reducers Reducers.
+ */
+ public HadoopPlannerMockJob(Collection<HadoopInputSplit> splits, int reducers) {
+ this.splits = splits;
+ this.reducers = reducers;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<HadoopInputSplit> input() throws IgniteCheckedException {
+ return splits;
+ }
+
+ /** {@inheritDoc} */
+ @Override public HadoopJobInfo info() {
+ return new JobInfo(reducers);
+ }
+
+ /** {@inheritDoc} */
+ @Override public HadoopJobId id() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public HadoopTaskContext getTaskContext(HadoopTaskInfo info) throws IgniteCheckedException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void initialize(boolean external, UUID nodeId) throws IgniteCheckedException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void dispose(boolean external) throws IgniteCheckedException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cleanupTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cleanupStagingDirectory() {
+ throwUnsupported();
+ }
+
+ /**
+ * Throw {@link UnsupportedOperationException}.
+ */
+ private static void throwUnsupported() {
+ throw new UnsupportedOperationException("Should not be called!");
+ }
+
+ /**
+ * Mocked job info.
+ */
+ private static class JobInfo implements HadoopJobInfo {
+ /** Reducers. */
+ private final int reducers;
+
+ /**
+ * Constructor.
+ *
+ * @param reducers Reducers.
+ */
+ public JobInfo(int reducers) {
+ this.reducers = reducers;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int reducers() {
+ return reducers;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String property(String name) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasCombiner() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasReducer() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public HadoopJob createJob(Class<? extends HadoopJob> jobCls, HadoopJobId jobId, IgniteLogger log,
+ @Nullable String[] libNames) throws IgniteCheckedException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String jobName() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String user() {
+ throwUnsupported();
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedMapReducePlannerTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedMapReducePlannerTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedMapReducePlannerTest.java
new file mode 100644
index 0000000..4e7cc50
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedMapReducePlannerTest.java
@@ -0,0 +1,599 @@
+/*
+ * 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.processors.hadoop;
+
+import org.apache.ignite.cluster.ClusterMetrics;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.hadoop.mapreduce.IgniteHadoopWeightedMapReducePlanner;
+import org.apache.ignite.igfs.IgfsBlockLocation;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.IgniteNodeAttributes;
+import org.apache.ignite.internal.processors.hadoop.planner.HadoopAbstractMapReducePlanner;
+import org.apache.ignite.internal.processors.igfs.IgfsIgniteMock;
+import org.apache.ignite.internal.processors.igfs.IgfsMock;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.UUID;
+
+/**
+ * Tests for weighted map-reduce planned.
+ */
+public class HadoopWeightedMapReducePlannerTest extends GridCommonAbstractTest {
+ /** ID 1. */
+ private static final UUID ID_1 = new UUID(0, 1);
+
+ /** ID 2. */
+ private static final UUID ID_2 = new UUID(0, 2);
+
+ /** ID 3. */
+ private static final UUID ID_3 = new UUID(0, 3);
+
+ /** MAC 1. */
+ private static final String MAC_1 = "mac1";
+
+ /** MAC 2. */
+ private static final String MAC_2 = "mac2";
+
+ /** MAC 3. */
+ private static final String MAC_3 = "mac3";
+
+ /** Host 1. */
+ private static final String HOST_1 = "host1";
+
+ /** Host 2. */
+ private static final String HOST_2 = "host2";
+
+ /** Host 3. */
+ private static final String HOST_3 = "host3";
+
+ /** Host 4. */
+ private static final String HOST_4 = "host4";
+
+ /** Host 5. */
+ private static final String HOST_5 = "host5";
+
+ /** Standard node 1. */
+ private static final MockNode NODE_1 = new MockNode(ID_1, MAC_1, HOST_1);
+
+ /** Standard node 2. */
+ private static final MockNode NODE_2 = new MockNode(ID_2, MAC_2, HOST_2);
+
+ /** Standard node 3. */
+ private static final MockNode NODE_3 = new MockNode(ID_3, MAC_3, HOST_3);
+
+ /** Standard nodes. */
+ private static final Collection<ClusterNode> NODES;
+
+ /**
+ * Static initializer.
+ */
+ static {
+ NODES = new ArrayList<>();
+
+ NODES.add(NODE_1);
+ NODES.add(NODE_2);
+ NODES.add(NODE_3);
+ }
+
+ /**
+ * Test one IGFS split being assigned to affinity node.
+ *
+ * @throws Exception If failed.
+ */
+ public void testOneIgfsSplitAffinity() throws Exception {
+ IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs();
+
+ List<HadoopInputSplit> splits = new ArrayList<>();
+
+ splits.add(new HadoopFileBlock(new String[] { HOST_1 }, URI.create("igfs://igfs@/file"), 0, 50));
+
+ final int expReducers = 4;
+
+ HadoopPlannerMockJob job = new HadoopPlannerMockJob(splits, expReducers);
+
+ IgniteHadoopWeightedMapReducePlanner planner = createPlanner(igfs);
+
+ HadoopMapReducePlan plan = planner.preparePlan(job, NODES, null);
+
+ assert plan.mappers() == 1;
+ assert plan.mapperNodeIds().size() == 1;
+ assert plan.mapperNodeIds().contains(ID_1);
+
+ checkPlanMappers(plan, splits, NODES, false/*only 1 split*/);
+ checkPlanReducers(plan, NODES, expReducers, false/* because of threshold behavior.*/);
+ }
+
+ /**
+ * Test one HDFS splits.
+ *
+ * @throws Exception If failed.
+ */
+ public void testHdfsSplitsAffinity() throws Exception {
+ IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs();
+
+ final List<HadoopInputSplit> splits = new ArrayList<>();
+
+ splits.add(new HadoopFileBlock(new String[] { HOST_1 }, URI.create("hfds://" + HOST_1 + "/x"), 0, 50));
+ splits.add(new HadoopFileBlock(new String[] { HOST_2 }, URI.create("hfds://" + HOST_2 + "/x"), 50, 100));
+ splits.add(new HadoopFileBlock(new String[] { HOST_3 }, URI.create("hfds://" + HOST_3 + "/x"), 100, 37));
+
+ // The following splits belong to hosts that are out of Ignite topology at all.
+ // This means that these splits should be assigned to any least loaded modes:
+ splits.add(new HadoopFileBlock(new String[] { HOST_4 }, URI.create("hfds://" + HOST_4 + "/x"), 138, 2));
+ splits.add(new HadoopFileBlock(new String[] { HOST_5 }, URI.create("hfds://" + HOST_5 + "/x"), 140, 3));
+
+ final int expReducers = 7;
+
+ HadoopPlannerMockJob job = new HadoopPlannerMockJob(splits, expReducers);
+
+ IgniteHadoopWeightedMapReducePlanner planner = createPlanner(igfs);
+
+ final HadoopMapReducePlan plan = planner.preparePlan(job, NODES, null);
+
+ checkPlanMappers(plan, splits, NODES, true);
+
+ checkPlanReducers(plan, NODES, expReducers, true);
+ }
+
+ /**
+ * Test HDFS splits with Replication == 3.
+ *
+ * @throws Exception If failed.
+ */
+ public void testHdfsSplitsReplication() throws Exception {
+ IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs();
+
+ final List<HadoopInputSplit> splits = new ArrayList<>();
+
+ splits.add(new HadoopFileBlock(new String[] { HOST_1, HOST_2, HOST_3 }, URI.create("hfds://" + HOST_1 + "/x"), 0, 50));
+ splits.add(new HadoopFileBlock(new String[] { HOST_2, HOST_3, HOST_4 }, URI.create("hfds://" + HOST_2 + "/x"), 50, 100));
+ splits.add(new HadoopFileBlock(new String[] { HOST_3, HOST_4, HOST_5 }, URI.create("hfds://" + HOST_3 + "/x"), 100, 37));
+ // The following splits belong to hosts that are out of Ignite topology at all.
+ // This means that these splits should be assigned to any least loaded modes:
+ splits.add(new HadoopFileBlock(new String[] { HOST_4, HOST_5, HOST_1 }, URI.create("hfds://" + HOST_4 + "/x"), 138, 2));
+ splits.add(new HadoopFileBlock(new String[] { HOST_5, HOST_1, HOST_2 }, URI.create("hfds://" + HOST_5 + "/x"), 140, 3));
+
+ final int expReducers = 8;
+
+ HadoopPlannerMockJob job = new HadoopPlannerMockJob(splits, expReducers);
+
+ IgniteHadoopWeightedMapReducePlanner planner = createPlanner(igfs);
+
+ final HadoopMapReducePlan plan = planner.preparePlan(job, NODES, null);
+
+ checkPlanMappers(plan, splits, NODES, true);
+
+ checkPlanReducers(plan, NODES, expReducers, true);
+ }
+
+ /**
+ * Get all IDs.
+ *
+ * @param nodes Nodes.
+ * @return IDs.
+ */
+ private static Set<UUID> allIds(Collection<ClusterNode> nodes) {
+ Set<UUID> allIds = new HashSet<>();
+
+ for (ClusterNode n : nodes)
+ allIds.add(n.id());
+
+ return allIds;
+ }
+
+ /**
+ * Check mappers for the plan.
+ *
+ * @param plan Plan.
+ * @param splits Splits.
+ * @param nodes Nodes.
+ * @param expectUniformity WHether uniformity is expected.
+ */
+ private static void checkPlanMappers(HadoopMapReducePlan plan, List<HadoopInputSplit> splits,
+ Collection<ClusterNode> nodes, boolean expectUniformity) {
+ // Number of mappers should correspomd to the number of input splits:
+ assertEquals(splits.size(), plan.mappers());
+
+ if (expectUniformity) {
+ // mappers are assigned to all available nodes:
+ assertEquals(nodes.size(), plan.mapperNodeIds().size());
+
+
+ assertEquals(allIds(nodes), plan.mapperNodeIds());
+ }
+
+ // Check all splits are covered by mappers:
+ Set<HadoopInputSplit> set = new HashSet<>();
+
+ for (UUID id: plan.mapperNodeIds()) {
+ Collection<HadoopInputSplit> sp = plan.mappers(id);
+
+ assert sp != null;
+
+ for (HadoopInputSplit s: sp)
+ assertTrue(set.add(s));
+ }
+
+ // must be of the same size & contain same elements:
+ assertEquals(set, new HashSet<>(splits));
+ }
+
+ /**
+ * Check plan reducers.
+ *
+ * @param plan Plan.
+ * @param nodes Nodes.
+ * @param expReducers Expected reducers.
+ * @param expectUniformity Expected uniformity.
+ */
+ private static void checkPlanReducers(HadoopMapReducePlan plan,
+ Collection<ClusterNode> nodes, int expReducers, boolean expectUniformity) {
+
+ assertEquals(expReducers, plan.reducers());
+
+ if (expectUniformity)
+ assertEquals(allIds(nodes), plan.reducerNodeIds());
+
+ int sum = 0;
+ int lenSum = 0;
+
+ for (UUID uuid: plan.reducerNodeIds()) {
+ int[] rr = plan.reducers(uuid);
+
+ assert rr != null;
+
+ lenSum += rr.length;
+
+ for (int i: rr)
+ sum += i;
+ }
+
+ assertEquals(expReducers, lenSum);
+
+ // Numbers in the arrays must be consequtive integers stating from 0,
+ // check that simply calculating their total sum:
+ assertEquals((lenSum * (lenSum - 1) / 2), sum);
+ }
+
+ /**
+ * Create planner for IGFS.
+ *
+ * @param igfs IGFS.
+ * @return Planner.
+ */
+ private static IgniteHadoopWeightedMapReducePlanner createPlanner(IgfsMock igfs) {
+ IgniteHadoopWeightedMapReducePlanner planner = new IgniteHadoopWeightedMapReducePlanner();
+
+ IgfsIgniteMock ignite = new IgfsIgniteMock(null, igfs);
+
+ GridTestUtils.setFieldValue(planner, HadoopAbstractMapReducePlanner.class, "ignite", ignite);
+
+ return planner;
+ }
+
+ /**
+ * Throw {@link UnsupportedOperationException}.
+ */
+ private static void throwUnsupported() {
+ throw new UnsupportedOperationException("Should not be called!");
+ }
+
+ /**
+ * Mocked node.
+ */
+ private static class MockNode implements ClusterNode {
+ /** ID. */
+ private final UUID id;
+
+ /** MAC addresses. */
+ private final String macs;
+
+ /** Addresses. */
+ private final List<String> addrs;
+
+ /**
+ * Constructor.
+ *
+ * @param id Node ID.
+ * @param macs MAC addresses.
+ * @param addrs Addresses.
+ */
+ public MockNode(UUID id, String macs, String... addrs) {
+ assert addrs != null;
+
+ this.id = id;
+ this.macs = macs;
+
+ this.addrs = Arrays.asList(addrs);
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Nullable @Override public <T> T attribute(String name) {
+ if (F.eq(name, IgniteNodeAttributes.ATTR_MACS))
+ return (T)macs;
+
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> addresses() {
+ return addrs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object consistentId() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterMetrics metrics() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, Object> attributes() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> hostNames() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long order() {
+ throwUnsupported();
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteProductVersion version() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isLocal() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isDaemon() {
+ throwUnsupported();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClient() {
+ throwUnsupported();
+
+ return false;
+ }
+ }
+
+ /**
+ * Locations builder.
+ */
+ private static class LocationsBuilder {
+ /** Locations. */
+ private final TreeMap<Long, Collection<MockNode>> locs = new TreeMap<>();
+
+ /**
+ * Create new locations builder.
+ *
+ * @return Locations builder.
+ */
+ public static LocationsBuilder create() {
+ return new LocationsBuilder();
+ }
+
+ /**
+ * Add locations.
+ *
+ * @param start Start.
+ * @param nodes Nodes.
+ * @return This builder for chaining.
+ */
+ public LocationsBuilder add(long start, MockNode... nodes) {
+ locs.put(start, Arrays.asList(nodes));
+
+ return this;
+ }
+
+ /**
+ * Build locations.
+ *
+ * @return Locations.
+ */
+ public TreeMap<Long, Collection<MockNode>> build() {
+ return locs;
+ }
+
+ /**
+ * Build IGFS.
+ *
+ * @return IGFS.
+ */
+ public MockIgfs buildIgfs() {
+ return new MockIgfs(build());
+ }
+ }
+
+ /**
+ * Mocked IGFS.
+ */
+ private static class MockIgfs extends IgfsMock {
+ /** Block locations. */
+ private final TreeMap<Long, Collection<MockNode>> locs;
+
+ /**
+ * Constructor.
+ *
+ * @param locs Block locations.
+ */
+ public MockIgfs(TreeMap<Long, Collection<MockNode>> locs) {
+ super("igfs");
+
+ this.locs = locs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len) {
+ Collection<IgfsBlockLocation> res = new ArrayList<>();
+
+ long cur = start;
+ long remaining = len;
+
+ long prevLocStart = -1;
+ Collection<MockNode> prevLocNodes = null;
+
+ for (Map.Entry<Long, Collection<MockNode>> locEntry : locs.entrySet()) {
+ long locStart = locEntry.getKey();
+ Collection<MockNode> locNodes = locEntry.getValue();
+
+ if (prevLocNodes != null) {
+ if (cur < locStart) {
+ // Add part from previous block.
+ long prevLen = locStart - prevLocStart;
+
+ res.add(new IgfsBlockLocationMock(cur, prevLen, prevLocNodes));
+
+ cur = locStart;
+ remaining -= prevLen;
+ }
+ }
+
+ prevLocStart = locStart;
+ prevLocNodes = locNodes;
+
+ if (remaining == 0)
+ break;
+ }
+
+ // Add remainder.
+ if (remaining != 0)
+ res.add(new IgfsBlockLocationMock(cur, remaining, prevLocNodes));
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(IgfsPath path) {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isProxy(URI path) {
+ return false;
+ }
+ }
+
+ /**
+ * Mocked block location.
+ */
+ private static class IgfsBlockLocationMock implements IgfsBlockLocation {
+ /** Start. */
+ private final long start;
+
+ /** Length. */
+ private final long len;
+
+ /** Node IDs. */
+ private final List<UUID> nodeIds;
+
+ /**
+ * Constructor.
+ *
+ * @param start Start.
+ * @param len Length.
+ * @param nodes Nodes.
+ */
+ public IgfsBlockLocationMock(long start, long len, Collection<MockNode> nodes) {
+ this.start = start;
+ this.len = len;
+
+ this.nodeIds = new ArrayList<>(nodes.size());
+
+ for (MockNode node : nodes)
+ nodeIds.add(node.id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long start() {
+ return start;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long length() {
+ return len;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<UUID> nodeIds() {
+ return nodeIds;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> names() {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> hosts() {
+ throwUnsupported();
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedPlannerMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedPlannerMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedPlannerMapReduceTest.java
new file mode 100644
index 0000000..e0403c2
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopWeightedPlannerMapReduceTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.processors.hadoop;
+
+import org.apache.ignite.configuration.HadoopConfiguration;
+import org.apache.ignite.hadoop.mapreduce.IgniteHadoopWeightedMapReducePlanner;
+
+/**
+ * Tests whole map-red execution Weighted planner.
+ */
+public class HadoopWeightedPlannerMapReduceTest extends HadoopMapReduceTest {
+ /** {@inheritDoc} */
+ @Override protected HadoopConfiguration createHadoopConfiguration() {
+ HadoopConfiguration hadoopCfg = new HadoopConfiguration();
+
+ // Use weighted planner with default settings:
+ IgniteHadoopWeightedMapReducePlanner planner = new IgniteHadoopWeightedMapReducePlanner();
+
+ hadoopCfg.setMapReducePlanner(planner);
+
+ return hadoopCfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73649386/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index e0d1142..52104a8 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -28,7 +28,6 @@ import org.apache.ignite.hadoop.cache.HadoopTxConfigCacheTest;
import org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactorySelfTest;
import org.apache.ignite.hadoop.util.BasicUserNameMapperSelfTest;
import org.apache.ignite.hadoop.util.ChainedUserNameMapperSelfTest;
-import org.apache.ignite.hadoop.util.KerberosUserNameMapper;
import org.apache.ignite.hadoop.util.KerberosUserNameMapperSelfTest;
import org.apache.ignite.igfs.Hadoop1OverIgfsDualAsyncTest;
import org.apache.ignite.igfs.Hadoop1OverIgfsDualSyncTest;
@@ -70,6 +69,8 @@ import org.apache.ignite.internal.processors.hadoop.HadoopTasksV1Test;
import org.apache.ignite.internal.processors.hadoop.HadoopTasksV2Test;
import org.apache.ignite.internal.processors.hadoop.HadoopV2JobSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopValidationSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopWeightedMapReducePlannerTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopWeightedPlannerMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimapSelftest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMapSelfTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipListSelfTest;
@@ -108,6 +109,9 @@ public class IgniteHadoopTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite");
+ suite.addTest(new TestSuite(ldr.loadClass(HadoopDefaultMapReducePlannerSelfTest.class.getName())));
+ suite.addTest(new TestSuite(ldr.loadClass(HadoopWeightedMapReducePlannerTest.class.getName())));
+
suite.addTest(new TestSuite(ldr.loadClass(BasicUserNameMapperSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(KerberosUserNameMapperSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(ChainedUserNameMapperSelfTest.class.getName())));
@@ -154,7 +158,6 @@ public class IgniteHadoopTestSuite extends TestSuite {
suite.addTest(new TestSuite(ldr.loadClass(HadoopValidationSelfTest.class.getName())));
- suite.addTest(new TestSuite(ldr.loadClass(HadoopDefaultMapReducePlannerSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopJobTrackerSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopHashMapSelfTest.class.getName())));
@@ -174,6 +177,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
suite.addTest(new TestSuite(ldr.loadClass(HadoopTasksV2Test.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceTest.class.getName())));
+ suite.addTest(new TestSuite(ldr.loadClass(HadoopWeightedPlannerMapReduceTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceEmbeddedSelfTest.class.getName())));
[23/50] [abbrv] ignite git commit: IGNITE-3470 - Support EXPIRED
events in continuous queries
Posted by vo...@apache.org.
IGNITE-3470 - Support EXPIRED events in continuous queries
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aedfde69
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aedfde69
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aedfde69
Branch: refs/heads/ignite-2649
Commit: aedfde69af6e91277616052ab60fa0037693c2c6
Parents: b81dbbf
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Jul 19 16:01:32 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Jul 19 16:01:32 2016 -0700
----------------------------------------------------------------------
.../ignite/cache/query/ContinuousQuery.java | 47 +++++++++++++++----
.../processors/cache/IgniteCacheProxy.java | 3 +-
.../continuous/CacheContinuousQueryManager.java | 9 ++--
...ridCacheContinuousQueryAbstractSelfTest.java | 48 +++++++++++++++++++-
4 files changed, 91 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aedfde69/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
index bbfe8cc..49d471e 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
@@ -21,6 +21,7 @@ import javax.cache.Cache;
import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.event.EventType;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -142,6 +143,9 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
/** Automatic unsubscription flag. */
private boolean autoUnsubscribe = DFLT_AUTO_UNSUBSCRIBE;
+ /** Whether to notify about {@link EventType#EXPIRED} events. */
+ private boolean includeExpired;
+
/**
* Creates new continuous query.
*/
@@ -324,6 +328,38 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
return this;
}
+ /**
+ * Gets automatic unsubscription flag value.
+ *
+ * @return Automatic unsubscription flag.
+ */
+ public boolean isAutoUnsubscribe() {
+ return autoUnsubscribe;
+ }
+
+ /**
+ * Sets the flag value defining whether to notify about {@link EventType#EXPIRED} events.
+ * If {@code true}, then the remote listener will get notifications about entries
+ * expired in cache. Otherwise, only {@link EventType#CREATED}, {@link EventType#UPDATED}
+ * and {@link EventType#REMOVED} events will be fired in the remote listener.
+ * <p>
+ * This flag is {@code false} by default, so {@link EventType#EXPIRED} events are disabled.
+ *
+ * @param includeExpired Whether to notify about {@link EventType#EXPIRED} events.
+ */
+ public void setIncludeExpired(boolean includeExpired) {
+ this.includeExpired = includeExpired;
+ }
+
+ /**
+ * Gets the flag value defining whether to notify about {@link EventType#EXPIRED} events.
+ *
+ * @return Whether to notify about {@link EventType#EXPIRED} events.
+ */
+ public boolean isIncludeExpired() {
+ return includeExpired;
+ }
+
/** {@inheritDoc} */
@Override public ContinuousQuery<K, V> setPageSize(int pageSize) {
return (ContinuousQuery<K, V>)super.setPageSize(pageSize);
@@ -333,13 +369,4 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
@Override public ContinuousQuery<K, V> setLocal(boolean loc) {
return (ContinuousQuery<K, V>)super.setLocal(loc);
}
-
- /**
- * Gets automatic unsubscription flag value.
- *
- * @return Automatic unsubscription flag.
- */
- public boolean isAutoUnsubscribe() {
- return autoUnsubscribe;
- }
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aedfde69/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 92e59db..249cfae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -598,7 +598,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
qry.getTimeInterval(),
qry.isAutoUnsubscribe(),
loc,
- keepBinary);
+ keepBinary,
+ qry.isIncludeExpired());
final QueryCursor<Cache.Entry<K, V>> cur =
qry.getInitialQuery() != null ? query(qry.getInitialQuery()) : null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/aedfde69/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 195f3ae..a8e5a6b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -421,7 +421,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
long timeInterval,
boolean autoUnsubscribe,
boolean loc,
- final boolean keepBinary) throws IgniteCheckedException
+ final boolean keepBinary,
+ final boolean includeExpired) throws IgniteCheckedException
{
IgniteClosure<Boolean, CacheContinuousQueryHandler> clsr;
@@ -438,7 +439,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
rmtFilterFactory,
true,
false,
- true,
+ !includeExpired,
false,
null);
else {
@@ -456,7 +457,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
(CacheEntryEventSerializableFilter)fltr,
true,
false,
- true,
+ !includeExpired,
false);
}
@@ -473,7 +474,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
rmtFilter,
true,
false,
- true,
+ !includeExpired,
false);
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/aedfde69/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
index 3d238af..08acc42 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
@@ -34,6 +34,9 @@ import javax.cache.Cache;
import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.event.EventType;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
import javax.cache.integration.CacheWriterException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -71,7 +74,6 @@ import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import org.jsr166.ConcurrentLinkedDeque8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -1094,6 +1096,50 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
}
/**
+ * @throws Exception If failed.
+ */
+ public void testExpired() throws Exception {
+ IgniteCache<Object, Object> cache = grid(0).cache(null).
+ withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, 1000)));
+
+ final Map<Object, Object> map = new ConcurrentHashMap8<>();
+ final CountDownLatch latch = new CountDownLatch(2);
+
+ ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
+
+ qry.setIncludeExpired(true);
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> e : evts) {
+ if (e.getEventType() == EventType.EXPIRED) {
+ assertNull(e.getValue());
+
+ map.put(e.getKey(), e.getOldValue());
+
+ latch.countDown();
+ }
+ }
+ }
+ });
+
+ try (QueryCursor<Cache.Entry<Object, Object>> ignored = cache.query(qry)) {
+ cache.put(1, 1);
+ cache.put(2, 2);
+
+ // Wait for expiration.
+ Thread.sleep(2000);
+
+ assert latch.await(LATCH_TIMEOUT, MILLISECONDS);
+
+ assertEquals(2, map.size());
+
+ assertEquals(1, (int)map.get(1));
+ assertEquals(2, (int)map.get(2));
+ }
+ }
+
+ /**
*
*/
private static class StoreFactory implements Factory<CacheStore> {
[36/50] [abbrv] ignite git commit: Merge branch 'ignite-1.5.31' into
ignite-2649
Posted by vo...@apache.org.
Merge branch 'ignite-1.5.31' into ignite-2649
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1e47d961
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1e47d961
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1e47d961
Branch: refs/heads/ignite-2649
Commit: 1e47d9613334ee150a7723445664773c1708c1c3
Parents: d25e321 2b1c82c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 15:00:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 15:00:43 2016 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtLocalPartition.java | 2 +-
.../dht/GridDhtPartitionTopologyImpl.java | 36 +++++-
.../internal/visor/cache/VisorCacheV4.java | 2 +-
.../visor/node/VisorNodeDataCollectorJob.java | 29 ++++-
.../ignite/cache/spring/SpringCacheManager.java | 17 ++-
.../spring/SpringTransactionManager.java | 59 +++++----
.../test/java/config/spring-transactions.xml | 4 +-
.../ignite/TestInjectionLifecycleBean.java | 42 +++++++
.../org/apache/ignite/spring-injection-test.xml | 43 +++++++
.../SpringCacheManagerContextInjectionTest.java | 126 +++++++++++++++++++
.../testsuites/IgniteSpringTestSuite.java | 5 +
...gTransactionManagerContextInjectionTest.java | 125 ++++++++++++++++++
12 files changed, 454 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
[37/50] [abbrv] ignite git commit: Minors.
Posted by vo...@apache.org.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6b8231fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6b8231fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6b8231fe
Branch: refs/heads/ignite-2649
Commit: 6b8231fe02c5ce7ab1697ba1ba35a94f3824eb04
Parents: 1e47d96
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 15:30:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 15:30:16 2016 +0300
----------------------------------------------------------------------
.../rest/protocols/tcp/MockNioSession.java | 5 ++-
.../rendezvous/RendezvousAffinityFunction.java | 32 ++++++++++----------
.../ignite/marshaller/MarshallerUtils.java | 3 +-
3 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6b8231fe/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
index 737f5a9..49fa88d 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
@@ -17,9 +17,6 @@
package org.apache.ignite.internal.processors.rest.protocols.tcp;
-import java.net.InetSocketAddress;
-
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
import org.apache.ignite.internal.util.nio.GridNioFinishedFuture;
import org.apache.ignite.internal.util.nio.GridNioFuture;
@@ -27,6 +24,8 @@ import org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor;
import org.apache.ignite.internal.util.nio.GridNioSession;
import org.jetbrains.annotations.Nullable;
+import java.net.InetSocketAddress;
+
/**
* Mock nio session with disabled functionality for testing parser.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/6b8231fe/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index b60d806..2dd646f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -17,21 +17,6 @@
package org.apache.ignite.cache.affinity.rendezvous;
-import java.io.ByteArrayOutputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -42,7 +27,6 @@ import org.apache.ignite.cache.affinity.AffinityNodeHashResolver;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.GridKernalContextImpl;
import org.apache.ignite.internal.processors.cache.GridCacheUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -55,6 +39,22 @@ import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
import org.jetbrains.annotations.Nullable;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
/**
* Affinity function for partitioned cache based on Highest Random Weight algorithm.
* This function supports the following configuration:
http://git-wip-us.apache.org/repos/asf/ignite/blob/6b8231fe/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 629ce6a..94ca30b 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -84,7 +84,8 @@ public final class MarshallerUtils {
gridNameTl.setGridName(true, gridName);
return marshaller.marshal(obj);
- } finally {
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
[33/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
IGNITE-2649 - Ignition.localIgnite() unreliable under Gateways and cause wrong components deserialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/087f84f0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/087f84f0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/087f84f0
Branch: refs/heads/ignite-2649
Commit: 087f84f09f820948fa590e73509bf5568185ded4
Parents: 09a30f3
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Aug 3 18:36:49 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Aug 3 18:36:49 2016 +0300
----------------------------------------------------------------------
.../cache/GridLocalIgniteSerializationTest.java | 373 +++++++++++++++++++
.../testsuites/IgniteCacheTestSuite4.java | 3 +
2 files changed, 376 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/087f84f0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java
new file mode 100644
index 0000000..4a8c60c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java
@@ -0,0 +1,373 @@
+/*
+ * 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.processors.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.concurrent.Callable;
+
+/**
+ *
+ */
+public class GridLocalIgniteSerializationTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "cache_name";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName != null && gridName.startsWith("binary"))
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ return cfg;
+ }
+
+ /**
+ * Test that calling {@link Ignition#localIgnite()}
+ * is safe for binary marshaller.
+ *
+ * @throws Exception
+ */
+ public void testPutGetSimple() throws Exception {
+ testPutGet(new SimpleTestObject("one"), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutGetSerializable() throws Exception {
+ testPutGet(new SerializableTestObject("test"), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutGetExternalizable() throws Exception {
+ testPutGet(new ExternalizableTestObject("test"), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutGetBinarylizable() throws Exception {
+ testPutGet(new BinarylizableTestObject("test"), "binaryIgnite");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testPutGet(final TestObject obj, final String gridName) throws Exception {
+ // Run async to emulate user thread.
+ GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (final Ignite ignite = startGrid(gridName)) {
+ final IgniteCache<Integer, TestObject> cache = ignite.getOrCreateCache(CACHE_NAME);
+
+ assertNull(obj.ignite());
+
+ cache.put(1, obj);
+
+ assertNotNull(obj.ignite());
+
+ final TestObject loadedObj = cache.get(1);
+
+ assertNotNull(loadedObj.ignite());
+
+ assertEquals(obj, loadedObj);
+ }
+
+ return null;
+ }
+ }).get();
+ }
+
+ /**
+ *
+ */
+ private interface TestObject {
+ /**
+ * @return Ignite instance.
+ */
+ Ignite ignite();
+ }
+
+ /**
+ * Test object.
+ */
+ private static class SimpleTestObject implements TestObject {
+ /** */
+ private final String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ /** */
+ private SimpleTestObject(final String val) {
+ this.val = val;
+ }
+
+ /**
+ * @return Object.
+ */
+ @SuppressWarnings("unused")
+ private Object readResolve() {
+ ignite = Ignition.localIgnite();
+
+ return this;
+ }
+
+ /**
+ * @return Object.
+ */
+ @SuppressWarnings("unused")
+ private Object writeReplace() {
+ ignite = Ignition.localIgnite();
+
+ return this;
+ }
+
+ /** */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final SimpleTestObject simpleTestObj = (SimpleTestObject) o;
+
+ return val != null ? val.equals(simpleTestObj.val) : simpleTestObj.val == null;
+
+ }
+
+ /** */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SerializableTestObject implements Serializable, TestObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ /**
+ *
+ */
+ public SerializableTestObject() {
+ }
+
+ /**
+ * @param val Value
+ */
+ public SerializableTestObject(final String val) {
+ this.val = val;
+ }
+
+ /**
+ * @param out Object output.
+ * @throws IOException If fail.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ U.writeString(out, val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /**
+ * @param in Object input.
+ * @throws IOException If fail.
+ */
+ private void readObject(ObjectInputStream in) throws IOException {
+ val = U.readString(in);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final SerializableTestObject that = (SerializableTestObject) o;
+
+ return val != null ? val.equals(that.val) : that.val == null;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExternalizableTestObject implements Externalizable, TestObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ /**
+ *
+ */
+ public ExternalizableTestObject() {
+ }
+
+ /**
+ * @param val Value.
+ */
+ public ExternalizableTestObject(final String val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(final ObjectOutput out) throws IOException {
+ U.writeString(out, val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+ val = U.readString(in);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final ExternalizableTestObject that = (ExternalizableTestObject) o;
+
+ return val != null ? val.equals(that.val) : that.val == null;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class BinarylizableTestObject implements Binarylizable, TestObject {
+ /** */
+ private String val;
+
+ /** */
+ private transient Ignite ignite;
+
+ /**
+ *
+ */
+ public BinarylizableTestObject() {
+ }
+
+ /**
+ * @param val Value.
+ */
+ public BinarylizableTestObject(final String val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
+ writer.rawWriter().writeString(val);
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
+ val = reader.rawReader().readString();
+
+ ignite = Ignition.localIgnite();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final BinarylizableTestObject that = (BinarylizableTestObject) o;
+
+ return val != null ? val.equals(that.val) : that.val == null;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ignite ignite() {
+ return ignite;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/087f84f0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 883f426..4d03b8a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -51,6 +51,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateSelfT
import org.apache.ignite.internal.processors.cache.GridCacheStoreManagerDeserializationTest;
import org.apache.ignite.internal.processors.cache.GridCacheVersionMultinodeTest;
import org.apache.ignite.internal.processors.cache.GridLocalCacheStoreManagerDeserializationTest;
+import org.apache.ignite.internal.processors.cache.GridLocalIgniteSerializationTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicCopyOnReadDisabledTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalPeekModesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalStoreValueTest;
@@ -319,6 +320,8 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(MarshallerCacheJobRunNodeRestartTest.class);
+ suite.addTestSuite(GridLocalIgniteSerializationTest.class);
+
return suite;
}
}
\ No newline at end of file
[26/50] [abbrv] ignite git commit: Print debug information on
'waitForRent' timeout.
Posted by vo...@apache.org.
Print debug information on 'waitForRent' timeout.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7cf26d96
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7cf26d96
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7cf26d96
Branch: refs/heads/ignite-2649
Commit: 7cf26d9601f25b96198172f1c8140a0a34687814
Parents: a39770a
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jul 26 15:48:36 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 26 15:48:36 2016 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtLocalPartition.java | 2 +-
.../dht/GridDhtPartitionTopologyImpl.java | 36 +++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7cf26d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 2c33fa2..6ea6159 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -507,7 +507,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
/**
* @return {@code true} If there is a group reservation.
*/
- private boolean groupReserved() {
+ public boolean groupReserved() {
for (GridDhtPartitionsReservation reservation : reservations) {
if (!reservation.invalidate())
return true; // Failed to invalidate reservation -> we are reserved.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7cf26d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 501388c..f9344bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -32,8 +32,10 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -51,6 +53,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT;
import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
@@ -171,6 +174,11 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
private boolean waitForRent() throws IgniteCheckedException {
boolean changed = false;
+ final long longOpDumpTimeout =
+ IgniteSystemProperties.getLong(IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, 60_000);
+
+ int dumpCnt = 0;
+
// Synchronously wait for all renting partitions to complete.
for (Iterator<GridDhtLocalPartition> it = locParts.values().iterator(); it.hasNext();) {
GridDhtLocalPartition p = it.next();
@@ -182,7 +190,33 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
log.debug("Waiting for renting partition: " + p);
// Wait for partition to empty out.
- p.rent(true).get();
+ if (longOpDumpTimeout > 0) {
+ while (true) {
+ try {
+ p.rent(true).get(longOpDumpTimeout);
+
+ break;
+ }
+ catch (IgniteFutureTimeoutCheckedException e) {
+ if (dumpCnt++ < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
+ U.warn(log, "Failed to wait for partition eviction [" +
+ "topVer=" + topVer +
+ ", cache=" + cctx.name() +
+ ", part=" + p.id() +
+ ", partState=" + p.state() +
+ ", size=" + p.size() +
+ ", reservations=" + p.reservations() +
+ ", grpReservations=" + p.groupReserved() +
+ ", node=" + cctx.localNodeId() + "]");
+
+ if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT, false))
+ U.dumpThreads(log);
+ }
+ }
+ }
+ }
+ else
+ p.rent(true).get();
if (log.isDebugEnabled())
log.debug("Finished waiting for renting partition: " + p);
[32/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
IGNITE-2649 - Ignition.localIgnite() unreliable under Gateways and cause wrong components deserialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/09a30f30
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/09a30f30
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/09a30f30
Branch: refs/heads/ignite-2649
Commit: 09a30f3077e6fa6034fa2d95803df2a19a70a278
Parents: 63210e6
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Aug 3 18:34:00 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Aug 3 18:34:00 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgnitionEx.java | 54 ++++++++----
.../apache/ignite/internal/LocalGridName.java | 46 +++++++++++
.../internal/binary/BinaryReaderExImpl.java | 10 ++-
.../internal/binary/BinaryWriterExImpl.java | 10 ++-
.../ignite/marshaller/MarshallerUtils.java | 86 ++++++++++++--------
.../GridBinaryCacheSerializationTest.java | 63 +++++++-------
6 files changed, 183 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index fe9dab0..63d0aec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -166,7 +166,11 @@ public class IgnitionEx {
private static final Collection<IgnitionListener> lsnrs = new GridConcurrentHashSet<>(4);
/** */
- private static final ThreadLocal<String> GRID_NAME_THREAD_LOC = new ThreadLocal<>();
+ private static final ThreadLocal<LocalGridName> GRID_NAME_THREAD_LOC = new ThreadLocal<LocalGridName>() {
+ @Override protected LocalGridName initialValue() {
+ return new LocalGridNameImpl();
+ }
+ };
/** */
private static ThreadLocal<Boolean> daemon = new ThreadLocal<Boolean>() {
@@ -1289,12 +1293,10 @@ public class IgnitionEx {
* @throws IllegalArgumentException Thrown to indicate, that current thread is not an {@link IgniteThread}.
*/
public static IgniteKernal localIgnite() throws IllegalArgumentException {
- final String gridName = GRID_NAME_THREAD_LOC.get();
-
- // TODO support null!!
+ final LocalGridName gridName = GRID_NAME_THREAD_LOC.get();
- if (gridName != null)
- return gridx(gridName);
+ if (gridName.isSet())
+ return gridx(gridName.getGridName());
else if (Thread.currentThread() instanceof IgniteThread)
return gridx(((IgniteThread)Thread.currentThread()).getGridName());
else
@@ -1365,20 +1367,11 @@ public class IgnitionEx {
}
/**
- * Set ignite config to thread local.
- *
- * @param name Grid name.
- */
- public static void setGridNameThreadLocal(final String name) {
- GRID_NAME_THREAD_LOC.set(name);
- }
-
- /**
* Get ignite config from thread local.
*
- * @return Grid name.
+ * @return Local grid name.
*/
- public static String getGridNameThreadLocal() {
+ public static LocalGridName gridNameThreadLocal() {
return GRID_NAME_THREAD_LOC.get();
}
@@ -2549,4 +2542,31 @@ public class IgnitionEx {
}
}
}
+
+ /**
+ *
+ */
+ private static class LocalGridNameImpl implements LocalGridName {
+ /** Indicates whether value is initial or not. */
+ private boolean valSet;
+
+ /** Grid name. */
+ private String gridName;
+
+ /** {@inheritDoc} */
+ @Override public boolean isSet() {
+ return valSet;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getGridName() {
+ return gridName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setGridName(final boolean set, final String gridName) {
+ this.valSet = set;
+ this.gridName = gridName;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java b/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
new file mode 100644
index 0000000..276091b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/LocalGridName.java
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+/**
+ * Container holds local grid name and has indicator
+ * that shows if value was initialized.
+ */
+public interface LocalGridName {
+ /**
+ * Indicates whether value was set.
+ *
+ * @return {@code True} if value was set.
+ */
+ public boolean isSet();
+
+ /**
+ * Get grid name.
+ *
+ * @return Grid name.
+ */
+ public String getGridName();
+
+ /**
+ * Set grid name and set flag.
+ *
+ * @param set {@code True} if value is not initial.
+ * @param gridName Grid name.
+ */
+ public void setGridName(boolean set, String gridName);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 44cf85e..47df697 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -33,6 +33,7 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.internal.LocalGridName;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.util.typedef.internal.SB;
@@ -1421,15 +1422,18 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
* @throws BinaryObjectException If failed.
*/
@Nullable Object deserialize() throws BinaryObjectException {
- final String gridName = IgnitionEx.getGridNameThreadLocal();
+ final LocalGridName gridName = IgnitionEx.gridNameThreadLocal();
+
+ final String gridNameStr = gridName.getGridName();
+ final boolean init = gridName.isSet();
try {
- IgnitionEx.setGridNameThreadLocal(ctx.configuration().getGridName());
+ gridName.setGridName(true, ctx.configuration().getGridName());
return deserialize0();
}
finally {
- IgnitionEx.setGridNameThreadLocal(gridName);
+ gridName.setGridName(init, gridNameStr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 9bf7ecb..de89f76 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -33,6 +33,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.LocalGridName;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
@@ -140,15 +141,18 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
void marshal(Object obj, boolean enableReplace) throws BinaryObjectException {
- final String gridName = IgnitionEx.getGridNameThreadLocal();
+ final LocalGridName gridName = IgnitionEx.gridNameThreadLocal();
+
+ final String gridNameStr = gridName.getGridName();
+ final boolean init = gridName.isSet();
try {
- IgnitionEx.setGridNameThreadLocal(ctx.configuration().getGridName());
+ gridName.setGridName(true, ctx.configuration().getGridName());
marshal0(obj, enableReplace);
}
finally {
- IgnitionEx.setGridNameThreadLocal(gridName);
+ gridName.setGridName(init, gridNameStr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index b678bd2..cfb45ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -18,11 +18,9 @@
package org.apache.ignite.marshaller;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.LocalGridName;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
-import org.apache.ignite.internal.util.typedef.F;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -51,12 +49,17 @@ public final class MarshallerUtils {
*/
public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
final OutputStream out, final String gridName) throws IgniteCheckedException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
marshaller.marshal(obj, out);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -70,12 +73,17 @@ public final class MarshallerUtils {
*/
public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
final String gridName) throws IgniteCheckedException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return marshaller.marshal(obj);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -91,12 +99,17 @@ public final class MarshallerUtils {
*/
public static <T> T unmarshal(final Marshaller marshaller, InputStream in, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return marshaller.unmarshal(in, clsLdr);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -112,12 +125,17 @@ public final class MarshallerUtils {
*/
public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return marshaller.unmarshal(arr, clsLdr);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -133,12 +151,17 @@ public final class MarshallerUtils {
*/
public static <T> T clone(final Marshaller marshaller, T obj, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return marshaller.unmarshal(marshaller.marshal(obj), clsLdr);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -153,12 +176,17 @@ public final class MarshallerUtils {
*/
public static ByteBuffer marshal(GridClientMarshaller gridMarshaller, Object obj, int off,
String gridName) throws IOException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return gridMarshaller.marshal(obj, off);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -173,32 +201,24 @@ public final class MarshallerUtils {
*/
public static <T> T unmarshal(GridClientMarshaller gridMarshaller, byte[] bytes,
String gridName) throws IOException {
- final String name = setGridName(gridName);
+ final LocalGridName gridNameTl = gridName();
+
+ final String gridNameStr = gridNameTl.getGridName();
+ final boolean init = gridNameTl.isSet();
try {
+ gridNameTl.setGridName(true, gridName);
+
return gridMarshaller.unmarshal(bytes);
} finally {
- restoreGridName(name);
+ gridNameTl.setGridName(init, gridNameStr);
}
}
/**
- * @param name Grid name.
- * @return Old grid name.
- */
- private static String setGridName(final String name) {
- final String gridName = IgnitionEx.getGridNameThreadLocal();
-
- if (!F.eq(name, gridName))
- IgnitionEx.setGridNameThreadLocal(name);
-
- return gridName;
- }
-
- /**
- * @param name Grid name.
+ * @return Grid name thread local.
*/
- private static void restoreGridName(final String name) {
- IgnitionEx.setGridNameThreadLocal(name);
+ private static LocalGridName gridName() {
+ return IgnitionEx.gridNameThreadLocal();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a30f30/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
index d5de056..31a7258 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
@@ -27,7 +27,7 @@ import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.junits.GridAbstractTest;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.io.Externalizable;
@@ -37,7 +37,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
/**
*
@@ -46,24 +46,6 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
/** */
private static final String CACHE_NAME = "cache_name";
- /**
- * Emulate user thread.
- *
- * @throws Throwable
- */
- @Override protected void runTest() throws Throwable {
- Class<?> cls = getClass();
-
- while (!cls.equals(GridAbstractTest.class))
- cls = cls.getSuperclass();
-
- final Method runTest = cls.getDeclaredMethod("runTestInternal");
-
- runTest.setAccessible(true);
-
- runTest.invoke(this);
- }
-
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
final IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -87,7 +69,7 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testSerializable() throws Exception {
+ public void testPutGetSerializable() throws Exception {
testPutGet(new SerializableTestObject("test"), null);
}
@@ -109,21 +91,28 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
private void testPutGet(final TestObject obj, final String gridName) throws Exception {
- try (final Ignite ignite = startGrid(gridName)) {
- final IgniteCache<Integer, TestObject> cache = ignite.getOrCreateCache(CACHE_NAME);
+ // Run async to emulate user thread.
+ GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (final Ignite ignite = startGrid(gridName)) {
+ final IgniteCache<Integer, TestObject> cache = ignite.getOrCreateCache(CACHE_NAME);
- assertNull(obj.ignite());
+ assertNull(obj.ignite());
- cache.put(1, obj);
+ cache.put(1, obj);
- assertNotNull(obj.ignite());
+ assertNotNull(obj.ignite());
- final TestObject loadedObj = cache.get(1);
+ final TestObject loadedObj = cache.get(1);
- assertNotNull(loadedObj.ignite());
+ assertNotNull(loadedObj.ignite());
- assertEquals(obj, loadedObj);
- }
+ assertEquals(obj, loadedObj);
+ }
+
+ return null;
+ }
+ }).get();
}
/**
@@ -206,19 +195,33 @@ public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
/** */
private transient Ignite ignite;
+ /**
+ *
+ */
public SerializableTestObject() {
}
+ /**
+ * @param val Value
+ */
public SerializableTestObject(final String val) {
this.val = val;
}
+ /**
+ * @param out Object output.
+ * @throws IOException If fail.
+ */
private void writeObject(ObjectOutputStream out) throws IOException {
U.writeString(out, val);
ignite = Ignition.localIgnite();
}
+ /**
+ * @param in Object input.
+ * @throws IOException If fail.
+ */
private void readObject(ObjectInputStream in) throws IOException {
val = U.readString(in);
[45/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
Cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c451d875
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c451d875
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c451d875
Branch: refs/heads/ignite-2649
Commit: c451d875cdb520d4477f1d7b7b9fb406c119c7fc
Parents: 2cc423b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:27:31 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:27:31 2016 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/marshaller/MarshallerUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c451d875/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index fd13937..a73e8a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -142,7 +142,7 @@ public class MarshallerUtils {
* @return Deserialized object.
* @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal( Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr,
+ public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr,
String name) throws IgniteCheckedException {
LocalGridName gridNameTl = gridName();
[08/50] [abbrv] ignite git commit: ignite-3254 - fixed
Posted by vo...@apache.org.
ignite-3254 - fixed
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4d2be722
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4d2be722
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4d2be722
Branch: refs/heads/ignite-2649
Commit: 4d2be722935da42c82310ce70db996c5752f72f6
Parents: 10224df
Author: Sergi Vladykin <se...@gmail.com>
Authored: Wed Jul 13 20:19:25 2016 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Wed Jul 13 20:19:25 2016 +0300
----------------------------------------------------------------------
.../examples/IndexingBridgeMethodTest.java | 93 ++++++++++++++++++++
.../IgniteExamplesJ8SelfTestSuite.java | 2 +
.../configuration/CacheConfiguration.java | 3 +
3 files changed, 98 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
new file mode 100644
index 0000000..2837ed6
--- /dev/null
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.java8.examples;
+
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test covering bridge methods changes in Java 8.
+ */
+public class IndexingBridgeMethodTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBridgeMethod() throws Exception {
+ Ignite ignite = startGrid();
+
+ CacheConfiguration<Integer, MyType> ccfg = new CacheConfiguration<>();
+
+ ccfg.setName("mytype");
+ ccfg.setIndexedTypes(Integer.class, MyType.class);
+
+ IgniteCache<Integer,MyType> c = ignite.getOrCreateCache(ccfg);
+
+ for (int i = 0; i < 100; i++)
+ c.put(i, new MyType(i));
+
+ assertEquals(100L, c.query(new SqlFieldsQuery(
+ "select count(*) from MyType")).getAll().get(0).get(0));
+ assertEquals(15, c.query(new SqlFieldsQuery(
+ "select id from MyType where _key = 15")).getAll().get(0).get(0));
+ assertEquals(25, c.query(new SqlFieldsQuery(
+ "select _key from MyType where id = 25")).getAll().get(0).get(0));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Classes implementing this method, will have bridge method.
+ */
+ private static interface HasId<T extends Number> {
+ /**
+ * @return ID.
+ */
+ public T getId();
+ }
+
+ /**
+ *
+ */
+ private static class MyType implements HasId<Integer> {
+ /** */
+ private int id;
+
+ /**
+ * @param id Id.
+ */
+ private MyType(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ @QuerySqlField(index = true)
+ @Override public Integer getId() {
+ return id;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
index 57e48f9..949324c 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
+import org.apache.ignite.java8.examples.IndexingBridgeMethodTest;
import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
import org.apache.ignite.testframework.GridTestUtils;
@@ -45,6 +46,7 @@ public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+ suite.addTest(new TestSuite(IndexingBridgeMethodTest.class));
suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
// suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 07542de..3276627 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2292,6 +2292,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
for (Method mtd : c.getDeclaredMethods()) {
+ if (mtd.isBridge())
+ continue;
+
QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
[48/50] [abbrv] ignite git commit: Cleanup (3).
Posted by vo...@apache.org.
Cleanup (3).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4f459866
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4f459866
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4f459866
Branch: refs/heads/ignite-2649
Commit: 4f4598660e88b345110a42458a575562a1788c99
Parents: 61f8b70
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:36:20 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:36:20 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/store/jdbc/CacheJdbcBlobStore.java | 2 +-
.../ignite/internal/GridEventConsumeHandler.java | 6 +++---
.../ignite/internal/GridJobSiblingsResponse.java | 2 +-
.../ignite/internal/GridMessageListenHandler.java | 8 ++++----
.../managers/checkpoint/GridCheckpointManager.java | 4 ++--
.../managers/communication/GridIoManager.java | 10 +++++-----
.../deployment/GridDeploymentCommunication.java | 4 ++--
.../eventstorage/GridEventStorageManager.java | 16 ++++++++--------
.../managers/swapspace/GridSwapSpaceManager.java | 2 +-
.../processors/affinity/GridAffinityUtils.java | 4 ++--
.../cache/CacheEntrySerializablePredicate.java | 4 ++--
.../processors/cache/CacheInvokeDirectResult.java | 4 ++--
.../internal/processors/cache/GridCacheMessage.java | 8 ++++----
.../distributed/GridDistributedLockResponse.java | 4 ++--
.../GridDistributedTxPrepareRequest.java | 4 ++--
.../GridDistributedTxPrepareResponse.java | 4 ++--
.../dht/GridDhtAffinityAssignmentResponse.java | 4 ++--
.../distributed/dht/GridDhtTxFinishResponse.java | 4 ++--
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 4 ++--
.../dht/atomic/GridNearAtomicUpdateRequest.java | 4 ++--
.../dht/atomic/GridNearAtomicUpdateResponse.java | 4 ++--
.../dht/preloader/GridDhtForceKeysResponse.java | 4 ++--
.../preloader/GridDhtPartitionDemandMessage.java | 4 ++--
.../dht/preloader/GridDhtPartitionsFullMessage.java | 8 ++++----
.../preloader/GridDhtPartitionsSingleMessage.java | 8 ++++----
.../cache/distributed/near/GridNearGetResponse.java | 4 ++--
.../distributed/near/GridNearSingleGetResponse.java | 4 ++--
.../distributed/near/GridNearTxFinishResponse.java | 4 ++--
.../cache/query/GridCacheQueryRequest.java | 14 +++++++-------
.../cache/query/GridCacheQueryResponse.java | 4 ++--
.../processors/cache/query/GridCacheSqlQuery.java | 2 +-
.../continuous/CacheContinuousQueryHandler.java | 4 ++--
.../cache/query/jdbc/GridCacheQueryJdbcTask.java | 2 +-
.../cache/transactions/IgniteTxEntry.java | 8 ++++----
.../cache/version/GridCacheRawVersionedEntry.java | 8 ++++----
.../cacheobject/IgniteCacheObjectProcessorImpl.java | 4 ++--
.../processors/closure/GridClosureProcessor.java | 2 +-
.../continuous/GridContinuousProcessor.java | 8 ++++----
.../processors/continuous/StartRequestData.java | 2 +-
.../datastreamer/DataStreamProcessor.java | 8 ++++----
.../processors/datastreamer/DataStreamerImpl.java | 4 ++--
.../internal/processors/igfs/IgfsAckMessage.java | 2 +-
.../internal/processors/igfs/IgfsDeleteMessage.java | 2 +-
.../internal/processors/job/GridJobProcessor.java | 16 ++++++++--------
.../internal/processors/job/GridJobWorker.java | 4 ++--
.../processors/offheap/GridOffHeapProcessor.java | 2 +-
.../rest/handlers/task/GridTaskCommandHandler.java | 8 ++++----
.../rest/protocols/tcp/GridTcpRestParser.java | 2 +-
.../processors/service/GridServiceProcessor.java | 6 +++---
.../internal/processors/task/GridTaskProcessor.java | 8 ++++----
.../internal/processors/task/GridTaskWorker.java | 12 ++++++------
.../apache/ignite/marshaller/MarshallerUtils.java | 4 ++--
.../apache/ignite/spi/discovery/tcp/ServerImpl.java | 10 +++++-----
.../ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 4 ++--
.../multicast/TcpDiscoveryMulticastIpFinder.java | 4 ++--
.../messages/TcpDiscoveryCustomEventMessage.java | 3 +--
.../apache/ignite/stream/socket/SocketStreamer.java | 3 +--
.../communication/HadoopMarshallerFilter.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 4 ++--
.../ignite/cache/websession/WebSessionV2.java | 2 +-
60 files changed, 154 insertions(+), 156 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
index 8d5227c..15aa111 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -576,7 +576,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
if (bytes == null || bytes.length == 0)
return null;
- return MarshallerUtils.unmarshal(marsh, bytes, getClass().getClassLoader(), ignite.name());
+ return MarshallerUtils.unmarshal(ignite.name(), marsh, bytes, getClass().getClassLoader());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index 5cb3f6a..243d5f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -387,8 +387,8 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
- filter = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), filterBytes,
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ filter = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), filterBytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
}
}
@@ -505,7 +505,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
assert evt == null;
assert bytes != null;
- evt = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), bytes, ldr, ctx.gridName());
+ evt = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), bytes, ldr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
index 714fb13..55f332b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
@@ -76,7 +76,7 @@ public class GridJobSiblingsResponse implements Message {
assert marsh != null;
if (siblingsBytes != null)
- siblings = MarshallerUtils.unmarshal(marsh, siblingsBytes, null, ctx.gridName());
+ siblings = MarshallerUtils.unmarshal(ctx.gridName(), marsh, siblingsBytes, null);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 1d2dda9..3d1f399 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -194,12 +194,12 @@ public class GridMessageListenHandler implements GridContinuousHandler {
ClassLoader ldr = dep.classLoader();
if (topicBytes != null) {
- topic = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), topicBytes,
- U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
+ topic = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), topicBytes,
+ U.resolveClassLoader(ldr, ctx.config()));
}
- pred = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), predBytes,
- U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
+ pred = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), predBytes,
+ U.resolveClassLoader(ldr, ctx.config()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
index 483922f..f2fd64f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
@@ -339,8 +339,8 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
// Always deserialize with task/session class loader.
if (data != null) {
- state = MarshallerUtils.unmarshal(marsh, data,
- U.resolveClassLoader(ses.getClassLoader(), ctx.config()), ctx.gridName());
+ state = MarshallerUtils.unmarshal(ctx.gridName(), marsh, data,
+ U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
}
record(EVT_CHECKPOINT_LOADED, key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 855fd8a..faedcea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -595,7 +595,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
int topicOrd = msg.topicOrdinal();
msg.topic(topicOrd >= 0 ? GridTopic.fromOrdinal(topicOrd) :
- MarshallerUtils.unmarshal(marsh, msg.topicBytes(), U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ MarshallerUtils.unmarshal(ctx.gridName(), marsh, msg.topicBytes(), U.resolveClassLoader(ctx.config())));
}
if (!started) {
@@ -2038,8 +2038,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
// Unmarshall message topic if needed.
if (msgTopic == null && msgTopicBytes != null) {
- msgTopic = MarshallerUtils.unmarshal(marsh, msgTopicBytes,
- U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()), ctx.gridName());
+ msgTopic = MarshallerUtils.unmarshal(ctx.gridName(), marsh, msgTopicBytes,
+ U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
ioMsg.topic(msgTopic); // Save topic to avoid future unmarshallings.
}
@@ -2048,8 +2048,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
return;
if (msgBody == null) {
- msgBody = MarshallerUtils.unmarshal(marsh, ioMsg.bodyBytes(),
- U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()), ctx.gridName());
+ msgBody = MarshallerUtils.unmarshal(ctx.gridName(), marsh, ioMsg.bodyBytes(),
+ U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
ioMsg.body(msgBody); // Save body to avoid future unmarshallings.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index 86ab22e..880cfca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -184,8 +184,8 @@ class GridDeploymentCommunication {
if (req.responseTopic() == null) {
try {
- req.responseTopic(MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ req.responseTopic(MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(ctx.config())));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process deployment request (will ignore): " + req, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 7dabd81..ac76cdc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -892,12 +892,12 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
try {
if (res.eventsBytes() != null)
- res.events(MarshallerUtils.<Collection<Event>>unmarshal(marsh, res.eventsBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ res.events(MarshallerUtils.<Collection<Event>>unmarshal(ctx.gridName(), marsh, res.eventsBytes(),
+ U.resolveClassLoader(ctx.config())));
if (res.exceptionBytes() != null)
- res.exception(MarshallerUtils.<Throwable>unmarshal(marsh, res.exceptionBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ res.exception(MarshallerUtils.<Throwable>unmarshal(ctx.gridName(), marsh, res.exceptionBytes(),
+ U.resolveClassLoader(ctx.config())));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal events query response: " + msg, e);
@@ -1090,8 +1090,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
try {
if (req.responseTopicBytes() != null) {
- req.responseTopic(MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ req.responseTopic(MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(ctx.config())));
}
GridDeployment dep = ctx.deploy().getGlobalDeployment(
@@ -1108,8 +1108,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for event filter " +
"(is peer class loading turned on?): " + req);
- filter = MarshallerUtils.unmarshal(marsh, req.filter(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ filter = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.filter(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
// Resource injection.
ctx.resource().inject(dep, dep.deployedClass(req.filterClassName()), filter);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index 1d205ca..767e459 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -401,7 +401,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
if (swapBytes == null)
return null;
- return MarshallerUtils.unmarshal(marsh, swapBytes, ldr != null ? ldr : U.gridClassLoader(), ctx.gridName());
+ return MarshallerUtils.unmarshal(ctx.gridName(), marsh, swapBytes, ldr != null ? ldr : U.gridClassLoader());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index 599a6bc..6f42e4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -111,8 +111,8 @@ class GridAffinityUtils {
throw new IgniteDeploymentCheckedException("Failed to obtain affinity object (is peer class loading turned on?): " +
msg);
- Object src = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), msg.source(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ Object src = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), msg.source(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
// Resource injection.
ctx.resource().inject(dep, dep.deployedClass(msg.sourceClassName()), src);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index 8d0d99b..f3cf1e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -82,8 +82,8 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
assert p != null || bytes != null;
if (p == null) {
- p = MarshallerUtils.unmarshal(ctx.marshaller(), bytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ p = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), bytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
p.finishUnmarshal(ctx, ldr);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index 096c2a8..fb4b830 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -123,8 +123,8 @@ public class CacheInvokeDirectResult implements Message {
key.finishUnmarshal(ctx.cacheObjectContext(), ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (res != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index a0f4b06..53a0c16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -459,8 +459,8 @@ public abstract class GridCacheMessage implements Message {
Marshaller marsh = ctx.marshaller();
for (int i = 0; i < byteCol.length; i++) {
- args[i] = byteCol[i] == null ? null : MarshallerUtils.unmarshal(marsh, byteCol[i],
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ args[i] = byteCol[i] == null ? null : MarshallerUtils.unmarshal(ctx.gridName(), marsh, byteCol[i],
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
return args;
@@ -612,8 +612,8 @@ public abstract class GridCacheMessage implements Message {
Marshaller marsh = ctx.marshaller();
for (byte[] bytes : byteCol) {
- col.add(bytes == null ? null : MarshallerUtils.<T>unmarshal(marsh, bytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName()));
+ col.add(bytes == null ? null : MarshallerUtils.<T>unmarshal(ctx.gridName(), marsh, bytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig())));
}
return col;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index 260672a..d0d9aa3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -214,8 +214,8 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
finishUnmarshalCacheObjects(vals, ctx.cacheContext(cacheId), ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index 8b71d23..2506d9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -374,8 +374,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
txNodes = F.viewReadOnly(txNodesMsg, MSG_TO_COL);
if (txNodesBytes != null && txNodes == null)
- txNodes = MarshallerUtils.unmarshal(ctx.marshaller(), txNodesBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ txNodes = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), txNodesBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index 84a5bc9..8f5920d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -110,8 +110,8 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
super.finishUnmarshal(ctx, ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index fb8ca7a..11d0f9c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -117,8 +117,8 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
super.finishUnmarshal(ctx, ldr);
if (affAssignmentBytes != null) {
- affAssignment = MarshallerUtils.unmarshal(ctx.marshaller(), affAssignmentBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ affAssignment = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), affAssignmentBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
// TODO IGNITE-2110: setting 'local' for nodes not needed when IGNITE-2110 is implemented.
int assignments = affAssignment.size();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index 0c871e8..df93f8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -122,8 +122,8 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
super.finishUnmarshal(ctx, ldr);
if (checkCommittedErrBytes != null) {
- checkCommittedErr = MarshallerUtils.unmarshal(ctx.marshaller(), checkCommittedErrBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ checkCommittedErr = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), checkCommittedErrBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index 097b316..7a5852d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -182,8 +182,8 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
finishUnmarshalCacheObjects(nearEvicted, cctx, ldr);
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index 8edf383..446e950 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -637,8 +637,8 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
if (expiryPlcBytes != null) {
- expiryPlc = MarshallerUtils.unmarshal(ctx.marshaller(), expiryPlcBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ expiryPlc = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), expiryPlcBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index 0ec7ba3..f3bf5c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -418,8 +418,8 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
super.finishUnmarshal(ctx, ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
GridCacheContext cctx = ctx.cacheContext(cacheId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index 2f9b4de..a516831 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -191,8 +191,8 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
}
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 3aadf93..f435dc3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -193,8 +193,8 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
super.finishUnmarshal(ctx, ldr);
if (topicBytes != null) {
- topic = MarshallerUtils.unmarshal(ctx.marshaller(), topicBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ topic = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), topicBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index ad8de3d..0498c20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -160,16 +160,16 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
super.finishUnmarshal(ctx, ldr);
if (partsBytes != null && parts == null) {
- parts = MarshallerUtils.unmarshal(ctx.marshaller(), partsBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ parts = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), partsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (parts == null)
parts = new HashMap<>();
if (partCntrsBytes != null && partCntrs == null) {
- partCntrs = MarshallerUtils.unmarshal(ctx.marshaller(), partCntrsBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ partCntrs = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), partCntrsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (partCntrs == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 2daeb21..38307e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -150,13 +150,13 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
super.finishUnmarshal(ctx, ldr);
if (partsBytes != null && parts == null) {
- parts = MarshallerUtils.unmarshal(ctx.marshaller(), partsBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ parts = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), partsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (partCntrsBytes != null) {
- partCntrs = MarshallerUtils.unmarshal(ctx.marshaller(), partCntrsBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ partCntrs = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), partCntrsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index 7060463..03ddf43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -207,8 +207,8 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
}
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
index fc1f442..19b2163 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
@@ -190,8 +190,8 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
}
if (errBytes != null && err == null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index b06aca5..e01eb9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -111,8 +111,8 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
super.finishUnmarshal(ctx, ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index d4de268..08cbb29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -320,21 +320,21 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
Marshaller marsh = ctx.marshaller();
if (keyValFilterBytes != null) {
- keyValFilter = MarshallerUtils.unmarshal(marsh, keyValFilterBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ keyValFilter = MarshallerUtils.unmarshal(ctx.gridName(), marsh, keyValFilterBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (rdcBytes != null)
- rdc = MarshallerUtils.unmarshal(marsh, rdcBytes, ldr, ctx.gridName());
+ rdc = MarshallerUtils.unmarshal(ctx.gridName(), marsh, rdcBytes, ldr);
if (transBytes != null) {
- trans = MarshallerUtils.unmarshal(marsh, transBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ trans = MarshallerUtils.unmarshal(ctx.gridName(), marsh, transBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (argsBytes != null) {
- args = MarshallerUtils.unmarshal(marsh, argsBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ args = MarshallerUtils.unmarshal(ctx.gridName(), marsh, argsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 28d8aef..a015ac5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -148,8 +148,8 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
super.finishUnmarshal(ctx, ldr);
if (errBytes != null) {
- err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
- U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()));
}
metadata = unmarshalCollection(metaDataBytes, ctx, ldr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index aae96a5..7a77ea5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -156,7 +156,7 @@ public class GridCacheSqlQuery implements Message {
assert paramsBytes != null;
- params = MarshallerUtils.unmarshal(m, paramsBytes, U.resolveClassLoader(ctx.config()), ctx.gridName());
+ params = MarshallerUtils.unmarshal(ctx.gridName(), m, paramsBytes, U.resolveClassLoader(ctx.config()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 461d31b..627a04b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -1560,8 +1560,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
- return MarshallerUtils.unmarshal(ctx.config().getMarshaller(), bytes,
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ return MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), bytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index b98dcbd..a6c5f14 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -83,7 +83,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
try {
assert arg != null;
- Map<String, Object> args = MarshallerUtils.unmarshal(MARSHALLER, arg, null, ignite.name());
+ Map<String, Object> args = MarshallerUtils.unmarshal(ignite.name(), MARSHALLER, arg, null);
boolean first = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 8bbe151..e7fc5de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -879,8 +879,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
// Unmarshal transform closure anyway if it exists.
if (transformClosBytes != null && entryProcessorsCol == null)
- entryProcessorsCol = MarshallerUtils.unmarshal(ctx.marshaller(),
- transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()), ctx.gridName());
+ entryProcessorsCol = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(),
+ transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()));
if (filters == null)
filters = CU.empty0();
@@ -896,8 +896,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
val.unmarshal(this.ctx, clsLdr);
if (expiryPlcBytes != null) {
- expiryPlc = MarshallerUtils.unmarshal(ctx.marshaller(), expiryPlcBytes,
- U.resolveClassLoader(clsLdr, ctx.gridConfig()), ctx.gridName());
+ expiryPlc = MarshallerUtils.unmarshal(ctx.gridName(), ctx.marshaller(), expiryPlcBytes,
+ U.resolveClassLoader(clsLdr, ctx.gridConfig()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
index 0b87652..98c651b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
@@ -192,8 +192,8 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
unmarshalKey(ctx, marsh);
if (val == null && valBytes != null) {
- val = MarshallerUtils.unmarshal(marsh, valBytes,
- U.resolveClassLoader(ctx.kernalContext().config()), ctx.kernalContext().gridName());
+ val = MarshallerUtils.unmarshal(ctx.kernalContext().gridName(), marsh, valBytes,
+ U.resolveClassLoader(ctx.kernalContext().config()));
val.finishUnmarshal(ctx, null);
}
@@ -224,8 +224,8 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
if (key == null) {
assert keyBytes != null;
- key = MarshallerUtils.unmarshal(marsh, keyBytes,
- U.resolveClassLoader(ctx.kernalContext().config()), ctx.kernalContext().gridName());
+ key = MarshallerUtils.unmarshal(ctx.kernalContext().gridName(), marsh, keyBytes,
+ U.resolveClassLoader(ctx.kernalContext().config()));
key.finishUnmarshal(ctx, null);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index d46fdbd..a3070e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -108,8 +108,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
@Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
throws IgniteCheckedException
{
- return MarshallerUtils.unmarshal(ctx.kernalContext().cache().context().marshaller(),
- bytes, U.resolveClassLoader(clsLdr, ctx.kernalContext().config()), ctx.kernalContext().gridName());
+ return MarshallerUtils.unmarshal(ctx.kernalContext().gridName(), ctx.kernalContext().cache().context().marshaller(),
+ bytes, U.resolveClassLoader(clsLdr, ctx.kernalContext().config()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/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 a330986..fb5c2c8 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
@@ -1149,7 +1149,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
}
if (c.job == closure)
- c.job = MarshallerUtils.unmarshal(marsh, closureBytes, U.resolveClassLoader(ctx.config()), ctx.gridName());
+ c.job = MarshallerUtils.unmarshal(ctx.gridName(), marsh, closureBytes, U.resolveClassLoader(ctx.config()));
else
c.job = MarshallerUtils.marshalUnmarshal(ctx.gridName(), marsh, c.job,
U.resolveClassLoader(ctx.config()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index a205c2c..28df19f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -289,8 +289,8 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (msg.data() == null && msg.dataBytes() != null) {
try {
- msg.data(MarshallerUtils.unmarshal(marsh, msg.dataBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ msg.data(MarshallerUtils.unmarshal(ctx.gridName(), marsh, msg.dataBytes(),
+ U.resolveClassLoader(ctx.config())));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
@@ -735,8 +735,8 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (msg.data() == null && msg.dataBytes() != null) {
try {
- msg.data(MarshallerUtils.unmarshal(marsh, msg.dataBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ msg.data(MarshallerUtils.unmarshal(ctx.gridName(), marsh, msg.dataBytes(),
+ U.resolveClassLoader(ctx.config())));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
index 4167c62..619bd86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
@@ -114,7 +114,7 @@ class StartRequestData implements Externalizable {
assert prjPred == null;
assert prjPredBytes != null;
- prjPred = MarshallerUtils.unmarshal(marsh, prjPredBytes, ldr, kernalCtx.gridName());
+ prjPred = MarshallerUtils.unmarshal(kernalCtx.gridName(), marsh, prjPredBytes, ldr);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index 065f5ad..853d1a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -236,8 +236,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
Object topic;
try {
- topic = MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
- U.resolveClassLoader(null, ctx.config()), ctx.gridName());
+ topic = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(null, ctx.config()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal topic from request: " + req, e);
@@ -277,8 +277,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
StreamReceiver<K, V> updater;
try {
- updater = MarshallerUtils.unmarshal(marsh, req.updaterBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
+ updater = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.updaterBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()));
if (updater != null)
ctx.resource().injectGeneric(updater);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 01d17d3..9d04a5f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -1495,8 +1495,8 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
try {
GridPeerDeployAware jobPda0 = jobPda;
- err = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), errBytes,
- U.resolveClassLoader(jobPda0 != null ? jobPda0.classLoader() : null, ctx.config()), ctx.gridName());
+ err = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), errBytes,
+ U.resolveClassLoader(jobPda0 != null ? jobPda0.classLoader() : null, ctx.config()));
}
catch (IgniteCheckedException e) {
f.onDone(null, new IgniteCheckedException("Failed to unmarshal response.", e));
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index 87d145b..20c80bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -107,7 +107,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
super.finishUnmarshal(marsh, ldr, kernalCtx);
if (errBytes != null)
- err = MarshallerUtils.unmarshal(marsh, errBytes, ldr, kernalCtx.gridName());
+ err = MarshallerUtils.unmarshal(kernalCtx.gridName(), marsh, errBytes, ldr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index a3e84e5..d0776bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -106,7 +106,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
super.finishUnmarshal(marsh, ldr, kernalCtx);
if (errBytes != null)
- err = MarshallerUtils.unmarshal(marsh, errBytes, ldr, kernalCtx.gridName());
+ err = MarshallerUtils.unmarshal(kernalCtx.gridName(), marsh, errBytes, ldr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index f3907c0..5938eb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -1019,8 +1019,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (siblings0 == null) {
assert req.getSiblingsBytes() != null;
- siblings0 = MarshallerUtils.unmarshal(marsh, req.getSiblingsBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName());
+ siblings0 = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.getSiblingsBytes(),
+ U.resolveClassLoader(ctx.config()));
}
siblings = new ArrayList<>(siblings0);
@@ -1032,8 +1032,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
sesAttrs = req.getSessionAttributes();
if (sesAttrs == null) {
- sesAttrs = MarshallerUtils.unmarshal(marsh, req.getSessionAttributesBytes(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ sesAttrs = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.getSessionAttributesBytes(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
}
}
@@ -1060,8 +1060,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
Map<? extends Serializable, ? extends Serializable> jobAttrs = req.getJobAttributes();
if (jobAttrs == null) {
- jobAttrs = MarshallerUtils.unmarshal(marsh, req.getJobAttributesBytes(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ jobAttrs = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.getJobAttributesBytes(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
}
jobCtx = new GridJobContextImpl(ctx, req.getJobId(), jobAttrs);
@@ -1429,8 +1429,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
Map<?, ?> attrs = loc ? req.getAttributes() :
- (Map<?, ?>)MarshallerUtils.unmarshal(marsh, req.getAttributesBytes(),
- U.resolveClassLoader(ses.getClassLoader(), ctx.config()), ctx.gridName());
+ (Map<?, ?>)MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.getAttributesBytes(),
+ U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
if (ctx.event().isRecordable(EVT_TASK_SESSION_ATTR_SET)) {
Event evt = new TaskEvent(
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index 7af32ce..39457e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -407,8 +407,8 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
try {
if (job == null) {
- job = MarshallerUtils.unmarshal(marsh, jobBytes,
- U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ job = MarshallerUtils.unmarshal(ctx.gridName(), marsh, jobBytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()));
// No need to hold reference any more.
jobBytes = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
index 2e9e957..1de7049 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
@@ -213,7 +213,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
if (valBytes == null)
return null;
- return MarshallerUtils.unmarshal(marsh, valBytes, U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
+ return MarshallerUtils.unmarshal(ctx.gridName(), marsh, valBytes, U.resolveClassLoader(ldr, ctx.config()));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index 1badaf9..c052570 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -142,8 +142,8 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
else
res.found(false);
- Object topic = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), req.topicBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName());
+ Object topic = MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), req.topicBytes(),
+ U.resolveClassLoader(ctx.config()));
ctx.io().send(nodeId, topic, res, SYSTEM_POOL);
}
@@ -441,8 +441,8 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
res = (GridTaskResultResponse)msg;
try {
- res.result(MarshallerUtils.unmarshal(ctx.config().getMarshaller(), res.resultBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ res.result(MarshallerUtils.unmarshal(ctx.gridName(), ctx.config().getMarshaller(), res.resultBytes(),
+ U.resolveClassLoader(ctx.config())));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal task result: " + res, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 8c14305..133d754 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -723,7 +723,7 @@ public class GridTcpRestParser implements GridNioParser {
assert bytes != null;
if ((flags & SERIALIZED_FLAG) != 0)
- return MarshallerUtils.unmarshal(jdkMarshaller, bytes, null, gridName);
+ return MarshallerUtils.unmarshal(gridName, jdkMarshaller, bytes, null);
int masked = flags & 0xff00;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 3c2317e..654114d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -1122,7 +1122,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
if (cfg instanceof LazyServiceConfiguration) {
byte[] bytes = ((LazyServiceConfiguration)cfg).serviceBytes();
- Service srvc = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(null, ctx.config()), ctx.gridName());
+ Service srvc = MarshallerUtils.unmarshal(ctx.gridName(), m, bytes, U.resolveClassLoader(null, ctx.config()));
ctx.resource().inject(srvc);
@@ -1134,8 +1134,8 @@ public class GridServiceProcessor extends GridProcessorAdapter {
try {
byte[] bytes = MarshallerUtils.marshal(ctx, svc);
- Service cp = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(),
- ctx.config()), ctx.gridName());
+ Service cp = MarshallerUtils.unmarshal(ctx.gridName(), m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(),
+ ctx.config()));
ctx.resource().inject(cp);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 7cb097f..9633a65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -1030,8 +1030,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
Map<?, ?> attrs = loc ? msg.getAttributes() :
- MarshallerUtils.<Map<?, ?>>unmarshal(marsh, msg.getAttributesBytes(),
- U.resolveClassLoader(task.getTask().getClass().getClassLoader(), ctx.config()), ctx.gridName());
+ MarshallerUtils.<Map<?, ?>>unmarshal(ctx.gridName(), marsh, msg.getAttributesBytes(),
+ U.resolveClassLoader(task.getTask().getClass().getClassLoader(), ctx.config()));
GridTaskSessionImpl ses = task.getSession();
@@ -1306,8 +1306,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
if (topic == null) {
assert req.topicBytes() != null;
- topic = MarshallerUtils.unmarshal(marsh, req.topicBytes(),
- U.resolveClassLoader(ctx.config()), ctx.gridName());
+ topic = MarshallerUtils.unmarshal(ctx.gridName(), marsh, req.topicBytes(),
+ U.resolveClassLoader(ctx.config()));
}
boolean loc = ctx.localNodeId().equals(nodeId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 3089cc7..10942da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -775,16 +775,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
try {
boolean loc = ctx.localNodeId().equals(res.getNodeId()) && !ctx.config().isMarshalLocalJobs();
- Object res0 = loc ? res.getJobResult() : MarshallerUtils.unmarshal(marsh,
- res.getJobResultBytes(), U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
+ Object res0 = loc ? res.getJobResult() : MarshallerUtils.unmarshal(ctx.gridName(), marsh,
+ res.getJobResultBytes(), U.resolveClassLoader(clsLdr, ctx.config()));
IgniteException ex = loc ? res.getException() :
- MarshallerUtils.<IgniteException>unmarshal(marsh, res.getExceptionBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
+ MarshallerUtils.<IgniteException>unmarshal(ctx.gridName(), marsh, res.getExceptionBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()));
Map<Object, Object> attrs = loc ? res.getJobAttributes() :
- MarshallerUtils.<Map<Object, Object>>unmarshal(marsh, res.getJobAttributesBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
+ MarshallerUtils.<Map<Object, Object>>unmarshal(ctx.gridName(), marsh, res.getJobAttributesBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()));
jobRes.onResponse(res0, ex, attrs, res.isCancelled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index c302351..6e2dab3 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -103,14 +103,14 @@ public class MarshallerUtils {
/**
* Unmarshal object and set grid name thread local.
*
+ * @param name Grid name.
* @param marsh Marshaller.
* @param arr Binary data.
* @param ldr Class loader.
- * @param name Grid name.
* @return Deserialized object.
* @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr, String name)
+ public static <T> T unmarshal(String name, Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr)
throws IgniteCheckedException {
LocalGridName gridNameTl = gridName();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 61bdc2f..9211722 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -1266,7 +1266,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (credBytes == null)
return null;
- return MarshallerUtils.unmarshal(spi.marsh, credBytes, null, spi.ignite().name());
+ return MarshallerUtils.unmarshal(spi.ignite().name(), spi.marsh, credBytes, null);
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to unmarshal node security credentials: " + node.id(), e);
@@ -2379,8 +2379,8 @@ class ServerImpl extends TcpDiscoveryImpl {
if (clientMsgWorker.clientNodeId.equals(node.id())) {
try {
- msg0 = MarshallerUtils.unmarshal(spi.marsh, msgBytes,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().name());
+ msg0 = MarshallerUtils.unmarshal(spi.ignite().name(), spi.marsh, msgBytes,
+ U.resolveClassLoader(spi.ignite().configuration()));
prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId, null, null, null);
@@ -3791,9 +3791,9 @@ class ServerImpl extends TcpDiscoveryImpl {
final IgniteConfiguration cfg = spi.ignite().configuration();
- SecurityContext coordSubj = MarshallerUtils.unmarshal(spi.marsh,
+ SecurityContext coordSubj = MarshallerUtils.unmarshal(cfg.getGridName(), spi.marsh,
node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
- U.resolveClassLoader(cfg), cfg.getGridName());
+ U.resolveClassLoader(cfg));
if (!permissionsEqual(coordSubj.subject().permissions(), subj.subject().permissions())) {
// Node has not pass authentication.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 39dc9dc..1fb5482 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1708,8 +1708,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, byte[]> entry : data.entrySet()) {
try {
- Serializable compData = MarshallerUtils.unmarshal(marsh, entry.getValue(), clsLdr,
- ignite.name());
+ Serializable compData = MarshallerUtils.unmarshal(ignite.name(), marsh, entry.getValue(), clsLdr
+ );
data0.put(entry.getKey(), compData);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index aa28118..ba19ade 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -723,8 +723,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
this.data = data;
- addrs = MarshallerUtils.unmarshal(marsh,
- Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null, gridName);
+ addrs = MarshallerUtils.unmarshal(gridName, marsh,
+ Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null);
}
/**
[17/50] [abbrv] ignite git commit: GG-11293: .NET: Backported
affinity functions feature to 7.5.30.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
new file mode 100644
index 0000000..6067af4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity
+{
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Impl;
+
+ /// <summary>
+ /// Affinity function context.
+ /// </summary>
+ public class AffinityFunctionContext
+ {
+ /** */
+ private readonly List<List<IClusterNode>> _previousAssignment;
+
+ /** */
+ private readonly int _backups;
+
+ /** */
+ private readonly ICollection<IClusterNode> _currentTopologySnapshot;
+
+ /** */
+ private readonly AffinityTopologyVersion _currentTopologyVersion;
+
+ /** */
+ private readonly DiscoveryEvent _discoveryEvent;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AffinityFunctionContext"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal AffinityFunctionContext(IBinaryRawReader reader)
+ {
+ Debug.Assert(reader != null);
+
+ _currentTopologySnapshot = IgniteUtils.ReadNodes(reader);
+ _backups = reader.ReadInt();
+ _currentTopologyVersion = new AffinityTopologyVersion(reader.ReadLong(), reader.ReadInt());
+ _discoveryEvent = EventReader.Read<DiscoveryEvent>(reader);
+
+ // Prev assignment
+ var cnt = reader.ReadInt();
+
+ if (cnt > 0)
+ {
+ _previousAssignment = new List<List<IClusterNode>>(cnt);
+
+ for (var i = 0; i < cnt; i++)
+ _previousAssignment.Add(IgniteUtils.ReadNodes(reader));
+ }
+ }
+
+ /// <summary>
+ /// Gets the affinity assignment for given partition on previous topology version.
+ /// First node in returned list is a primary node, other nodes are backups.
+ /// </summary>
+ /// <param name="partition">The partition to get previous assignment for.</param>
+ /// <returns>
+ /// List of nodes assigned to a given partition on previous topology version or <code>null</code>
+ /// if this information is not available.
+ /// </returns>
+ public ICollection<IClusterNode> GetPreviousAssignment(int partition)
+ {
+ return _previousAssignment == null ? null : _previousAssignment[partition];
+ }
+
+ /// <summary>
+ /// Gets number of backups for new assignment.
+ /// </summary>
+ public int Backups
+ {
+ get { return _backups; }
+ }
+
+ /// <summary>
+ /// Gets the current topology snapshot. Snapshot will contain only nodes on which the particular
+ /// cache is configured. List of passed nodes is guaranteed to be sorted in a same order
+ /// on all nodes on which partition assignment is performed.
+ /// </summary>
+ public ICollection<IClusterNode> CurrentTopologySnapshot
+ {
+ get { return _currentTopologySnapshot; }
+ }
+
+ /// <summary>
+ /// Gets the current topology version.
+ /// </summary>
+ public AffinityTopologyVersion CurrentTopologyVersion
+ {
+ get { return _currentTopologyVersion; }
+ }
+
+ /// <summary>
+ /// Gets the discovery event that caused the topology change.
+ /// </summary>
+ public DiscoveryEvent DiscoveryEvent
+ {
+ get { return _discoveryEvent; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityTopologyVersion.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityTopologyVersion.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityTopologyVersion.cs
new file mode 100644
index 0000000..9bfdfb4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityTopologyVersion.cs
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity
+{
+ using System;
+ using Apache.Ignite.Core.Cluster;
+
+ /// <summary>
+ /// Affinity topology version.
+ /// </summary>
+ public struct AffinityTopologyVersion : IEquatable<AffinityTopologyVersion>
+ {
+ /** */
+ private readonly long _version;
+
+ /** */
+ private readonly int _minorVersion;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AffinityTopologyVersion"/> struct.
+ /// </summary>
+ /// <param name="version">The version.</param>
+ /// <param name="minorVersion">The minor version.</param>
+ public AffinityTopologyVersion(long version, int minorVersion)
+ {
+ _version = version;
+ _minorVersion = minorVersion;
+ }
+
+ /// <summary>
+ /// Gets the major version, same as <see cref="ICluster.TopologyVersion"/>.
+ /// </summary>
+ public long Version
+ {
+ get { return _version; }
+ }
+
+ /// <summary>
+ /// Gets the minor version, which is increased when new caches start.
+ /// </summary>
+ public int MinorVersion
+ {
+ get { return _minorVersion; }
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this object.</param>
+ /// <returns>
+ /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
+ /// </returns>
+ public bool Equals(AffinityTopologyVersion other)
+ {
+ return _version == other._version && _minorVersion == other._minorVersion;
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise,
+ /// <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ return obj is AffinityTopologyVersion && Equals((AffinityTopologyVersion) obj);
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (_version.GetHashCode()*397) ^ _minorVersion;
+ }
+ }
+
+ /// <summary>
+ /// Implements the operator ==.
+ /// </summary>
+ /// <param name="left">The left.</param>
+ /// <param name="right">The right.</param>
+ /// <returns>
+ /// The result of the operator.
+ /// </returns>
+ public static bool operator ==(AffinityTopologyVersion left, AffinityTopologyVersion right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements the operator !=.
+ /// </summary>
+ /// <param name="left">The left.</param>
+ /// <param name="right">The right.</param>
+ /// <returns>
+ /// The result of the operator.
+ /// </returns>
+ public static bool operator !=(AffinityTopologyVersion left, AffinityTopologyVersion right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="string" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="string" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format("AffinityTopologyVersion [Version={0}, MinorVersion={1}]", _version, _minorVersion);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
new file mode 100644
index 0000000..4a3885f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity.Fair
+{
+ using System;
+
+ /// <summary>
+ /// Fair affinity function which tries to ensure that all nodes get equal number of partitions with
+ /// minimum amount of reassignments between existing nodes.
+ /// </summary>
+ [Serializable]
+ public class FairAffinityFunction : AffinityFunctionBase
+ {
+ // No-op.
+ // Actual implementation is in Java, see AffinityFunctionSerializer.Write method.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/IAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/IAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/IAffinityFunction.cs
new file mode 100644
index 0000000..b6c190c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/IAffinityFunction.cs
@@ -0,0 +1,82 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cache.Affinity.Fair;
+ using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
+ using Apache.Ignite.Core.Cluster;
+
+ /// <summary>
+ /// Represents a function that maps cache keys to cluster nodes.
+ /// <para />
+ /// Predefined implementations:
+ /// <see cref="RendezvousAffinityFunction"/>, <see cref="FairAffinityFunction"/>.
+ /// </summary>
+ public interface IAffinityFunction
+ {
+ /// <summary>
+ /// Gets the total number of partitions.
+ /// <para />
+ /// All caches should always provide correct partition count which should be the same on all
+ /// participating nodes. Note that partitions should always be numbered from 0 inclusively
+ /// to N exclusively without any gaps.
+ /// </summary>
+ int Partitions { get; }
+
+ /// <summary>
+ /// Gets partition number for a given key starting from 0. Partitioned caches
+ /// should make sure that keys are about evenly distributed across all partitions
+ /// from 0 to <see cref="Partitions"/> for best performance.
+ /// <para />
+ /// Note that for fully replicated caches it is possible to segment key sets among different
+ /// grid node groups. In that case each node group should return a unique partition
+ /// number. However, unlike partitioned cache, mappings of keys to nodes in
+ /// replicated caches are constant and a node cannot migrate from one partition
+ /// to another.
+ /// </summary>
+ /// <param name="key">Key to get partition for.</param>
+ /// <returns>Partition number for a given key.</returns>
+ int GetPartition(object key);
+
+ /// <summary>
+ /// Removes node from affinity. This method is called when it is safe to remove
+ /// disconnected node from affinity mapping.
+ /// </summary>
+ /// <param name="nodeId">The node identifier.</param>
+ void RemoveNode(Guid nodeId);
+
+ /// <summary>
+ /// Gets affinity nodes for a partition. In case of replicated cache, all returned
+ /// nodes are updated in the same manner. In case of partitioned cache, the returned
+ /// list should contain only the primary and back up nodes with primary node being
+ /// always first.
+ /// <pare />
+ /// Note that partitioned affinity must obey the following contract: given that node
+ /// <code>N</code> is primary for some key <code>K</code>, if any other node(s) leave
+ /// grid and no node joins grid, node <code>N</code> will remain primary for key <code>K</code>.
+ /// </summary>
+ /// <param name="context">The affinity function context.</param>
+ /// <returns>
+ /// A collection of partitions, where each partition is a collection of nodes,
+ /// where first node is a primary node, and other nodes are backup nodes.
+ /// </returns>
+ IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
new file mode 100644
index 0000000..98ec364
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Affinity.Rendezvous
+{
+ using System;
+
+ /// <summary>
+ /// Affinity function for partitioned cache based on Highest Random Weight algorithm.
+ /// </summary>
+ [Serializable]
+ public class RendezvousAffinityFunction : AffinityFunctionBase
+ {
+ // No-op.
+ // Actual implementation is in Java, see AffinityFunctionSerializer.Write method.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
index cb1c715..ee1c837 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
@@ -32,16 +32,14 @@ namespace Apache.Ignite.Core.Events
/// <param name="reader">Reader.</param>
/// <returns>Deserialized event.</returns>
/// <exception cref="System.InvalidCastException">Incompatible event type.</exception>
- public static T Read<T>(IBinaryReader reader) where T : IEvent
+ public static T Read<T>(IBinaryRawReader reader) where T : IEvent
{
- var r = reader.GetRawReader();
-
- var clsId = r.ReadInt();
+ var clsId = reader.ReadInt();
if (clsId == -1)
return default(T);
- return (T) CreateInstance(clsId, r);
+ return (T) CreateInstance(clsId, reader);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 7a3fafc..f6fab5d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -26,10 +26,12 @@ namespace Apache.Ignite.Core
using System.Runtime;
using System.Threading;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Affinity;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
+ using Apache.Ignite.Core.Impl.Cache.Affinity;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Handle;
using Apache.Ignite.Core.Impl.Memory;
@@ -233,6 +235,8 @@ namespace Apache.Ignite.Core
PrepareConfiguration(reader);
PrepareLifecycleBeans(reader, outStream, handleRegistry);
+
+ PrepareAffinityFunctions(reader, outStream);
}
catch (Exception e)
{
@@ -282,7 +286,7 @@ namespace Apache.Ignite.Core
int cnt = reader.ReadInt();
for (int i = 0; i < cnt; i++)
- beans.Add(new LifecycleBeanHolder(CreateLifecycleBean(reader)));
+ beans.Add(new LifecycleBeanHolder(CreateObject<ILifecycleBean>(reader)));
// 2. Append beans definied in local configuration.
ICollection<ILifecycleBean> nativeBeans = _startup.Configuration.LifecycleBeans;
@@ -306,21 +310,33 @@ namespace Apache.Ignite.Core
}
/// <summary>
- /// Create lifecycle bean.
+ /// Prepares the affinity functions.
/// </summary>
- /// <param name="reader">Reader.</param>
- /// <returns>Lifecycle bean.</returns>
- private static ILifecycleBean CreateLifecycleBean(BinaryReader reader)
+ private static void PrepareAffinityFunctions(BinaryReader reader, PlatformMemoryStream outStream)
{
- // 1. Instantiate.
- var bean = IgniteUtils.CreateInstance<ILifecycleBean>(reader.ReadString());
+ var cnt = reader.ReadInt();
+
+ var writer = reader.Marshaller.StartMarshal(outStream);
- // 2. Set properties.
- var props = reader.ReadDictionaryAsGeneric<string, object>();
+ for (var i = 0; i < cnt; i++)
+ {
+ var objHolder = new ObjectInfoHolder(reader);
+ AffinityFunctionSerializer.Write(writer, objHolder.CreateInstance<IAffinityFunction>(), objHolder);
+ }
+ }
+
+ /// <summary>
+ /// Creates an object and sets the properties.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <returns>Resulting object.</returns>
+ private static T CreateObject<T>(IBinaryRawReader reader)
+ {
+ var res = IgniteUtils.CreateInstance<T>(reader.ReadString());
- IgniteUtils.SetProperties(bean, props);
+ IgniteUtils.SetProperties(res, reader.ReadDictionaryAsGeneric<string, object>());
- return bean;
+ return res;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index c3dcc3a..a5446ac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Reader extensions.
@@ -48,5 +49,18 @@ namespace Apache.Ignite.Core.Impl.Binary
{
return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
}
+
+ /// <summary>
+ /// Reads the object either as a normal object or as a [typeName+props] wrapper.
+ /// </summary>
+ public static T ReadObjectEx<T>(this IBinaryRawReader reader)
+ {
+ var obj = reader.ReadObject<object>();
+
+ if (obj == null)
+ return default(T);
+
+ return obj is T ? (T)obj : ((ObjectInfoHolder)obj).CreateInstance<T>();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 81fc195..a63e8f4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -506,12 +506,15 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <summary>
/// Adds a predefined system type.
/// </summary>
- private void AddSystemType<T>(byte typeId, Func<BinaryReader, T> ctor) where T : IBinaryWriteAware
+ private void AddSystemType<T>(int typeId, Func<BinaryReader, T> ctor) where T : IBinaryWriteAware
{
var type = typeof(T);
var serializer = new BinarySystemTypeSerializer<T>(ctor);
+ if (typeId == 0)
+ typeId = BinaryUtils.TypeId(type.Name, null, null);
+
AddType(type, typeId, BinaryUtils.GetTypeName(type), false, false, null, null, serializer, null, false);
}
@@ -536,6 +539,7 @@ namespace Apache.Ignite.Core.Impl.Binary
AddSystemType(BinaryUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
AddSystemType(BinaryUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, w => new PlatformJavaObjectFactoryProxy());
+ AddSystemType(0, w => new ObjectInfoHolder(w));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
new file mode 100644
index 0000000..888445a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
@@ -0,0 +1,277 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Cache.Affinity.Fair;
+ using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+ using Apache.Ignite.Core.Impl.Memory;
+
+ /// <summary>
+ /// Affinity function read/write methods.
+ /// </summary>
+ internal static class AffinityFunctionSerializer
+ {
+ /** */
+ private const byte TypeCodeNull = 0;
+
+ /** */
+ private const byte TypeCodeFair = 1;
+
+ /** */
+ private const byte TypeCodeRendezvous = 2;
+
+ /** */
+ private const byte TypeCodeUser = 3;
+
+ /// <summary>
+ /// Writes the instance.
+ /// </summary>
+ internal static void Write(IBinaryRawWriter writer, IAffinityFunction fun, object userFuncOverride = null)
+ {
+ Debug.Assert(writer != null);
+
+ if (fun == null)
+ {
+ writer.WriteByte(TypeCodeNull);
+ return;
+ }
+
+ // 1) Type code
+ // 2) Partitions
+ // 3) ExcludeNeighbors
+ // 4) Override flags
+ // 5) User object
+
+ var p = fun as AffinityFunctionBase;
+
+ if (p != null)
+ {
+ writer.WriteByte(p is FairAffinityFunction ? TypeCodeFair : TypeCodeRendezvous);
+ writer.WriteInt(p.Partitions);
+ writer.WriteBoolean(p.ExcludeNeighbors);
+
+ var overrideFlags = GetOverrideFlags(p.GetType());
+ writer.WriteByte((byte) overrideFlags);
+
+ // Do not write user func if there is nothing overridden
+ WriteUserFunc(writer, overrideFlags != UserOverrides.None ? fun : null, userFuncOverride);
+ }
+ else
+ {
+ writer.WriteByte(TypeCodeUser);
+ writer.WriteInt(fun.Partitions);
+ writer.WriteBoolean(false); // Exclude neighbors
+ writer.WriteByte((byte) UserOverrides.All);
+ WriteUserFunc(writer, fun, userFuncOverride);
+ }
+ }
+
+ /// <summary>
+ /// Reads the instance.
+ /// </summary>
+ internal static IAffinityFunction Read(IBinaryRawReader reader)
+ {
+ Debug.Assert(reader != null);
+
+ var typeCode = reader.ReadByte();
+
+ if (typeCode == TypeCodeNull)
+ return null;
+
+ var partitions = reader.ReadInt();
+ var exclNeighbors = reader.ReadBoolean();
+ var overrideFlags = (UserOverrides)reader.ReadByte();
+ var userFunc = reader.ReadObjectEx<IAffinityFunction>();
+
+ if (userFunc != null)
+ {
+ Debug.Assert(overrideFlags != UserOverrides.None);
+
+ var fair = userFunc as FairAffinityFunction;
+ if (fair != null)
+ {
+ fair.Partitions = partitions;
+ fair.ExcludeNeighbors = exclNeighbors;
+ }
+
+ var rendezvous = userFunc as RendezvousAffinityFunction;
+ if (rendezvous != null)
+ {
+ rendezvous.Partitions = partitions;
+ rendezvous.ExcludeNeighbors = exclNeighbors;
+ }
+
+ return userFunc;
+ }
+
+ Debug.Assert(overrideFlags == UserOverrides.None);
+ AffinityFunctionBase fun;
+
+ switch (typeCode)
+ {
+ case TypeCodeFair:
+ fun = new FairAffinityFunction();
+ break;
+ case TypeCodeRendezvous:
+ fun = new RendezvousAffinityFunction();
+ break;
+ default:
+ throw new InvalidOperationException("Invalid AffinityFunction type code: " + typeCode);
+ }
+
+ fun.Partitions = partitions;
+ fun.ExcludeNeighbors = exclNeighbors;
+
+ return fun;
+ }
+
+
+ /// <summary>
+ /// Writes the partitions assignment to a stream.
+ /// </summary>
+ /// <param name="parts">The parts.</param>
+ /// <param name="stream">The stream.</param>
+ /// <param name="marsh">The marshaller.</param>
+ internal static void WritePartitions(IEnumerable<IEnumerable<IClusterNode>> parts,
+ PlatformMemoryStream stream, Marshaller marsh)
+ {
+ Debug.Assert(parts != null);
+ Debug.Assert(stream != null);
+ Debug.Assert(marsh != null);
+
+ IBinaryRawWriter writer = marsh.StartMarshal(stream);
+
+ var partCnt = 0;
+ writer.WriteInt(partCnt); // reserve size
+
+ foreach (var part in parts)
+ {
+ if (part == null)
+ throw new IgniteException("IAffinityFunction.AssignPartitions() returned invalid partition: null");
+
+ partCnt++;
+
+ var nodeCnt = 0;
+ var cntPos = stream.Position;
+ writer.WriteInt(nodeCnt); // reserve size
+
+ foreach (var node in part)
+ {
+ nodeCnt++;
+ writer.WriteGuid(node.Id);
+ }
+
+ var endPos = stream.Position;
+ stream.Seek(cntPos, SeekOrigin.Begin);
+ stream.WriteInt(nodeCnt);
+ stream.Seek(endPos, SeekOrigin.Begin);
+ }
+
+ stream.SynchronizeOutput();
+ stream.Seek(0, SeekOrigin.Begin);
+ writer.WriteInt(partCnt);
+ }
+
+ /// <summary>
+ /// Reads the partitions assignment from a stream.
+ /// </summary>
+ /// <param name="stream">The stream.</param>
+ /// <param name="marsh">The marshaller.</param>
+ /// <returns>Partitions assignment.</returns>
+ internal static IEnumerable<IEnumerable<IClusterNode>> ReadPartitions(IBinaryStream stream, Marshaller marsh)
+ {
+ Debug.Assert(stream != null);
+ Debug.Assert(marsh != null);
+
+ IBinaryRawReader reader = marsh.StartUnmarshal(stream);
+
+ var partCnt = reader.ReadInt();
+
+ var res = new List<IEnumerable<IClusterNode>>(partCnt);
+
+ for (var i = 0; i < partCnt; i++)
+ res.Add(IgniteUtils.ReadNodes(reader));
+
+ return res;
+ }
+
+ /// <summary>
+ /// Gets the override flags.
+ /// </summary>
+ private static UserOverrides GetOverrideFlags(Type funcType)
+ {
+ var res = UserOverrides.None;
+
+ var methods = new[] {UserOverrides.GetPartition, UserOverrides.AssignPartitions, UserOverrides.RemoveNode};
+
+ var map = funcType.GetInterfaceMap(typeof(IAffinityFunction));
+
+ foreach (var method in methods)
+ {
+ // Find whether user type overrides IAffinityFunction method from AffinityFunctionBase.
+ var methodName = method.ToString();
+
+ if (map.TargetMethods.Single(x => x.Name == methodName).DeclaringType != typeof(AffinityFunctionBase))
+ res |= method;
+ }
+
+ return res;
+ }
+
+ /// <summary>
+ /// Writes the user function.
+ /// </summary>
+ private static void WriteUserFunc(IBinaryRawWriter writer, IAffinityFunction func, object funcOverride)
+ {
+ if (funcOverride != null)
+ {
+ writer.WriteObject(funcOverride);
+ return;
+ }
+
+ if (func != null && !func.GetType().IsSerializable)
+ throw new IgniteException("AffinityFunction should be serializable.");
+
+ writer.WriteObject(func);
+ }
+
+ /// <summary>
+ /// Overridden function flags.
+ /// </summary>
+ [Flags]
+ private enum UserOverrides : byte
+ {
+ None = 0,
+ GetPartition = 1,
+ RemoveNode = 1 << 1,
+ AssignPartitions = 1 << 2,
+ All = GetPartition | RemoveNode | AssignPartitions
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/PlatformAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/PlatformAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/PlatformAffinityFunction.cs
new file mode 100644
index 0000000..d335804
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/PlatformAffinityFunction.cs
@@ -0,0 +1,74 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Unmanaged;
+
+ /// <summary>
+ /// Affinity function that delegates to Java.
+ /// </summary>
+ internal class PlatformAffinityFunction : PlatformTarget, IAffinityFunction
+ {
+ /** Opcodes. */
+ private enum Op
+ {
+ Partition = 1,
+ RemoveNode = 2,
+ AssignPartitions = 3
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PlatformAffinityFunction"/> class.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <param name="marsh">Marshaller.</param>
+ public PlatformAffinityFunction(IUnmanagedTarget target, Marshaller marsh) : base(target, marsh)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public int Partitions
+ {
+ get { throw new NotSupportedException("PlatformAffinityFunction.Partitions is not supported."); }
+ }
+
+ /** <inheritdoc /> */
+ public int GetPartition(object key)
+ {
+ return (int) DoOutOp((int) Op.Partition, w => w.WriteObject(key));
+ }
+
+ /** <inheritdoc /> */
+ public void RemoveNode(Guid nodeId)
+ {
+ DoOutOp((int) Op.RemoveNode, w => w.WriteGuid(nodeId));
+ }
+
+ /** <inheritdoc /> */
+ public IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
+ {
+ return DoInOp((int) Op.AssignPartitions, s => AffinityFunctionSerializer.ReadPartitions(s, Marshaller));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ObjectInfoHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ObjectInfoHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ObjectInfoHolder.cs
new file mode 100644
index 0000000..407fe0c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ObjectInfoHolder.cs
@@ -0,0 +1,86 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Holds the information to instantiate an object and set its properties.
+ /// Typically used for .NET objects defined in Spring XML.
+ /// </summary>
+ internal class ObjectInfoHolder : IBinaryWriteAware
+ {
+ /** Type name. */
+ private readonly string _typeName;
+
+ /** Properties. */
+ private readonly Dictionary<string, object> _properties;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ObjectInfoHolder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ public ObjectInfoHolder(IBinaryRawReader reader)
+ {
+ Debug.Assert(reader != null);
+
+ _typeName = reader.ReadString();
+ _properties = reader.ReadDictionaryAsGeneric<string, object>();
+
+ Debug.Assert(!string.IsNullOrEmpty(_typeName));
+ }
+
+ /// <summary>
+ /// Gets the name of the type.
+ /// </summary>
+ public string TypeName
+ {
+ get { return _typeName; }
+ }
+
+ /// <summary>
+ /// Gets the properties.
+ /// </summary>
+ public Dictionary<string, object> Properties
+ {
+ get { return _properties; }
+ }
+
+ /// <summary>
+ /// Creates an instance according to type name and properties.
+ /// </summary>
+ public T CreateInstance<T>()
+ {
+ return IgniteUtils.CreateInstance<T>(TypeName, Properties);
+ }
+
+ /** <inheritdoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ Debug.Assert(writer != null);
+
+ var w = writer.GetRawWriter();
+
+ w.WriteString(_typeName);
+ w.WriteDictionary(_properties);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 7929a5d..5d0d989 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -128,8 +128,9 @@ namespace Apache.Ignite.Core.Impl
/// Create new instance of specified class.
/// </summary>
/// <param name="typeName">Class name</param>
+ /// <param name="props">Properties to set.</param>
/// <returns>New Instance.</returns>
- public static T CreateInstance<T>(string typeName)
+ public static T CreateInstance<T>(string typeName, IEnumerable<KeyValuePair<string, object>> props = null)
{
IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
@@ -138,7 +139,12 @@ namespace Apache.Ignite.Core.Impl
if (type == null)
throw new IgniteException("Failed to create class instance [className=" + typeName + ']');
- return (T) Activator.CreateInstance(type);
+ var res = (T)Activator.CreateInstance(type);
+
+ if (props != null)
+ SetProperties(res, props);
+
+ return res;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
index 8147e9d..dd16d03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
@@ -95,5 +95,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
internal void* extensionCbInLongOutLong;
internal void* extensionCbInLongLongOutLong;
+
+ internal void* affinityFunctionInit;
+ internal void* affinityFunctionPartition;
+ internal void* affinityFunctionAssignPartitions;
+ internal void* affinityFunctionRemoveNode;
+ internal void* affinityFunctionDestroy;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5f57cc8d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index e554cfc..f4b3db9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -21,14 +21,16 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+ using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
-
+ using Apache.Ignite.Core.Cache.Affinity;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
using Apache.Ignite.Core.Impl.Cache;
+ using Apache.Ignite.Core.Impl.Cache.Affinity;
using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
using Apache.Ignite.Core.Impl.Cache.Store;
using Apache.Ignite.Core.Impl.Common;
@@ -161,6 +163,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
private delegate long ExtensionCallbackInLongOutLongDelegate(void* target, int typ, long arg1);
private delegate long ExtensionCallbackInLongLongOutLongDelegate(void* target, int typ, long arg1, long arg2);
+ private delegate long AffinityFunctionInitDelegate(void* target, long memPtr, void* baseFunc);
+ private delegate int AffinityFunctionPartitionDelegate(void* target, long ptr, long memPtr);
+ private delegate void AffinityFunctionAssignPartitionsDelegate(void* target, long ptr, long inMemPtr, long outMemPtr);
+ private delegate void AffinityFunctionRemoveNodeDelegate(void* target, long ptr, long memPtr);
+ private delegate void AffinityFunctionDestroyDelegate(void* target, long ptr);
+
/// <summary>
/// constructor.
/// </summary>
@@ -240,7 +248,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
error = CreateFunctionPointer((ErrorCallbackDelegate)Error),
extensionCbInLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongOutLongDelegate)ExtensionCallbackInLongOutLong),
- extensionCbInLongLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongLongOutLongDelegate)ExtensionCallbackInLongLongOutLong)
+ extensionCbInLongLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongLongOutLongDelegate)ExtensionCallbackInLongLongOutLong),
+
+ affinityFunctionInit = CreateFunctionPointer((AffinityFunctionInitDelegate)AffinityFunctionInit),
+ affinityFunctionPartition = CreateFunctionPointer((AffinityFunctionPartitionDelegate)AffinityFunctionPartition),
+ affinityFunctionAssignPartitions = CreateFunctionPointer((AffinityFunctionAssignPartitionsDelegate)AffinityFunctionAssignPartitions),
+ affinityFunctionRemoveNode = CreateFunctionPointer((AffinityFunctionRemoveNodeDelegate)AffinityFunctionRemoveNode),
+ affinityFunctionDestroy = CreateFunctionPointer((AffinityFunctionDestroyDelegate)AffinityFunctionDestroy)
};
_cbsPtr = Marshal.AllocHGlobal(UU.HandlersSize());
@@ -1057,7 +1071,120 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
#endregion
-
+
+ #region AffinityFunction
+
+ private long AffinityFunctionInit(void* target, long memPtr, void* baseFunc)
+ {
+ return SafeCall(() =>
+ {
+ using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
+ {
+ var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+ var func = reader.ReadObjectEx<IAffinityFunction>();
+
+ ResourceProcessor.Inject(func, _ignite);
+
+ var affBase = func as AffinityFunctionBase;
+
+ if (affBase != null)
+ affBase.SetBaseFunction(new PlatformAffinityFunction(
+ _ignite.InteropProcessor.ChangeTarget(baseFunc), _ignite.Marshaller));
+
+ return _handleRegistry.Allocate(func);
+ }
+ });
+ }
+
+ private int AffinityFunctionPartition(void* target, long ptr, long memPtr)
+ {
+ return SafeCall(() =>
+ {
+ using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
+ {
+ var key = _ignite.Marshaller.Unmarshal<object>(stream);
+
+ return _handleRegistry.Get<IAffinityFunction>(ptr, true).GetPartition(key);
+ }
+ });
+ }
+
+ private void AffinityFunctionAssignPartitions(void* target, long ptr, long inMemPtr, long outMemPtr)
+ {
+ SafeCall(() =>
+ {
+ using (var inStream = IgniteManager.Memory.Get(inMemPtr).GetStream())
+ {
+ var ctx = new AffinityFunctionContext(_ignite.Marshaller.StartUnmarshal(inStream));
+ var func = _handleRegistry.Get<IAffinityFunction>(ptr, true);
+ var parts = func.AssignPartitions(ctx);
+
+ if (parts == null)
+ throw new IgniteException(func.GetType() + ".AssignPartitions() returned invalid result: null");
+
+ using (var outStream = IgniteManager.Memory.Get(outMemPtr).GetStream())
+ {
+ var writer = _ignite.Marshaller.StartMarshal(outStream);
+
+ var partCnt = 0;
+ writer.WriteInt(partCnt); // reserve size
+
+ foreach (var part in parts)
+ {
+ if (part == null)
+ throw new IgniteException(func.GetType() +
+ ".AssignPartitions() returned invalid partition: null");
+
+ partCnt++;
+
+ var nodeCnt = 0;
+ var cntPos = outStream.Position;
+ writer.WriteInt(nodeCnt); // reserve size
+
+ foreach (var node in part)
+ {
+ nodeCnt++;
+ writer.WriteGuid(node.Id);
+ }
+
+ var endPos = outStream.Position;
+ outStream.Seek(cntPos, SeekOrigin.Begin);
+ outStream.WriteInt(nodeCnt);
+ outStream.Seek(endPos, SeekOrigin.Begin);
+ }
+
+ outStream.SynchronizeOutput();
+ outStream.Seek(0, SeekOrigin.Begin);
+ writer.WriteInt(partCnt);
+ }
+ }
+ });
+ }
+
+ private void AffinityFunctionRemoveNode(void* target, long ptr, long memPtr)
+ {
+ SafeCall(() =>
+ {
+ using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
+ {
+ var nodeId = _ignite.Marshaller.Unmarshal<Guid>(stream);
+
+ _handleRegistry.Get<IAffinityFunction>(ptr, true).RemoveNode(nodeId);
+ }
+ });
+ }
+
+ private void AffinityFunctionDestroy(void* target, long ptr)
+ {
+ SafeCall(() =>
+ {
+ _handleRegistry.Release(ptr);
+ });
+ }
+
+ #endregion
+
#region HELPERS
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
[46/50] [abbrv] ignite git commit: Cleanup (2).
Posted by vo...@apache.org.
Cleanup (2).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/61f8b708
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/61f8b708
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/61f8b708
Branch: refs/heads/ignite-2649
Commit: 61f8b708e6b20513bb0f05e5d6b20eab6a8a0437
Parents: c451d87
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:32:38 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:32:38 2016 +0300
----------------------------------------------------------------------
.../ignite/marshaller/MarshallerUtils.java | 27 ++++++++------------
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 ++---
.../ignite/spi/discovery/tcp/ServerImpl.java | 3 +--
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 13 ++++++++++
.../spi/discovery/tcp/TcpDiscoverySpi.java | 4 +--
5 files changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index a73e8a5..c302351 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -100,22 +100,17 @@ public class MarshallerUtils {
-
-
-
-
-
/**
- * Unmarshal object from stream and set grid name thread local.
+ * Unmarshal object and set grid name thread local.
*
- * @param name Grid name.
* @param marsh Marshaller.
- * @param in Input stream.
+ * @param arr Binary data.
* @param ldr Class loader.
+ * @param name Grid name.
* @return Deserialized object.
* @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable ClassLoader ldr)
+ public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr, String name)
throws IgniteCheckedException {
LocalGridName gridNameTl = gridName();
@@ -125,7 +120,7 @@ public class MarshallerUtils {
try {
gridNameTl.setGridName(true, name);
- return marsh.unmarshal(in, ldr);
+ return marsh.unmarshal(arr, ldr);
}
finally {
gridNameTl.setGridName(init, gridNameStr);
@@ -133,17 +128,17 @@ public class MarshallerUtils {
}
/**
- * Unmarshal object and set grid name thread local.
+ * Unmarshal object from stream and set grid name thread local.
*
+ * @param name Grid name.
* @param marsh Marshaller.
- * @param arr Binary data.
+ * @param in Input stream.
* @param ldr Class loader.
- * @param name Grid name.
* @return Deserialized object.
* @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr,
- String name) throws IgniteCheckedException {
+ public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable ClassLoader ldr)
+ throws IgniteCheckedException {
LocalGridName gridNameTl = gridName();
String gridNameStr = gridNameTl.getGridName();
@@ -152,7 +147,7 @@ public class MarshallerUtils {
try {
gridNameTl.setGridName(true, name);
- return marsh.unmarshal(arr, ldr);
+ return marsh.unmarshal(in, ldr);
}
finally {
gridNameTl.setGridName(init, gridNameStr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 60d4131..78a1911 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -887,8 +887,7 @@ class ClientImpl extends TcpDiscoveryImpl {
TcpDiscoveryAbstractMessage msg;
try {
- msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()));
+ msg = unmarshal(in);
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
@@ -1213,8 +1212,7 @@ class ClientImpl extends TcpDiscoveryImpl {
List<TcpDiscoveryAbstractMessage> msgs = null;
while (!isInterrupted()) {
- TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()));
+ TcpDiscoveryAbstractMessage msg = unmarshal(in);
if (msg instanceof TcpDiscoveryClientReconnectMessage) {
TcpDiscoveryClientReconnectMessage res = (TcpDiscoveryClientReconnectMessage)msg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 00657db..61bdc2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -5437,8 +5437,7 @@ class ServerImpl extends TcpDiscoveryImpl {
while (!isInterrupted()) {
try {
- TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()));
+ TcpDiscoveryAbstractMessage msg = unmarshal(in);
msg.senderNodeId(nodeId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index 7eb915e..d049314 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -17,6 +17,7 @@
package org.apache.ignite.spi.discovery.tcp;
+import java.io.InputStream;
import java.net.InetSocketAddress;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -340,4 +341,16 @@ abstract class TcpDiscoveryImpl {
protected byte[] marshal(Object obj) throws IgniteCheckedException {
return MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, obj);
}
+
+ /**
+ * Unmarshal object.
+ *
+ * @param in Input stream.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected <T> T unmarshal(InputStream in) throws IgniteCheckedException {
+ return MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()));
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 368480f..39dc9dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1462,8 +1462,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
try {
sock.setSoTimeout((int)timeout);
- return MarshallerUtils.unmarshal(ignite.configuration().getGridName(), marsh, in == null ? sock.getInputStream() : in,
- U.resolveClassLoader(ignite.configuration()));
+ return MarshallerUtils.unmarshal(ignite.configuration().getGridName(), marsh,
+ in == null ? sock.getInputStream() : in, U.resolveClassLoader(ignite.configuration()));
}
catch (IOException | IgniteCheckedException e) {
if (X.hasCause(e, SocketTimeoutException.class))
[27/50] [abbrv] ignite git commit: Cherry-picked latest Visor fixes
for UI and compatibility.
Posted by vo...@apache.org.
Cherry-picked latest Visor fixes for UI and compatibility.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2b1c82cc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2b1c82cc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2b1c82cc
Branch: refs/heads/ignite-2649
Commit: 2b1c82cceee3f522f7d3ce50e8d74d0c9df066a0
Parents: 7cf26d9
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Jul 29 17:54:35 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Jul 29 17:54:35 2016 +0700
----------------------------------------------------------------------
.../internal/visor/cache/VisorCacheV4.java | 2 +-
.../visor/node/VisorNodeDataCollectorJob.java | 29 ++++++++++++++++----
2 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2b1c82cc/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV4.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV4.java
index 81dbacb..a5f66be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV4.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV4.java
@@ -86,7 +86,7 @@ public class VisorCacheV4 extends VisorCacheV2 {
/** {@inheritDoc} */
@Override public VisorCache history() {
- return initHistory(new VisorCacheV3());
+ return initHistory(new VisorCacheV4());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2b1c82cc/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
index 9a9b1cd..611dcde 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
@@ -21,8 +21,9 @@ import java.util.Collection;
import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -56,7 +57,7 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
private static final IgniteProductVersion VER_1_4_1 = IgniteProductVersion.fromString("1.4.1");
/** */
- private static final IgniteProductVersion VER_1_5_9 = IgniteProductVersion.fromString("1.5.9");
+ private static final IgniteProductVersion VER_1_5_10 = IgniteProductVersion.fromString("1.5.10");
/** */
private static final IgniteProductVersion VER_1_5_26 = IgniteProductVersion.fromString("1.5.26");
@@ -146,7 +147,7 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
if (compatibleWith(VER_1_4_1))
return new VisorCache();
- if (compatibleWith(VER_1_5_9))
+ if (compatibleWith(VER_1_5_10))
return new VisorCacheV2();
if (compatibleWith(VER_1_5_26))
@@ -156,6 +157,18 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
}
/**
+ * @param cacheName Cache name to check.
+ * @return {@code true} if cache on local node is not a data cache or near cache disabled.
+ */
+ private boolean proxyCache(String cacheName) {
+ GridDiscoveryManager discovery = ignite.context().discovery();
+
+ ClusterNode locNode = ignite.localNode();
+
+ return !(discovery.cacheAffinityNode(locNode, cacheName) || discovery.cacheNearNode(locNode, cacheName));
+ }
+
+ /**
* Collect caches.
*
* @param res Job result.
@@ -165,9 +178,10 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
try {
IgniteConfiguration cfg = ignite.configuration();
- GridCacheProcessor cacheProc = ignite.context().cache();
+ for (String cacheName : ignite.context().cache().cacheNames()) {
+ if (proxyCache(cacheName))
+ continue;
- for (String cacheName : cacheProc.cacheNames()) {
if (arg.systemCaches() || !(isSystemCache(cacheName) || isIgfsCache(cfg, cacheName))) {
long start0 = U.currentTimeMillis();
@@ -205,6 +219,11 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
for (IgniteFileSystem igfs : igfsProc.igfss()) {
long start0 = U.currentTimeMillis();
+ FileSystemConfiguration igfsCfg = igfs.configuration();
+
+ if (proxyCache(igfsCfg.getDataCacheName()) || proxyCache(igfsCfg.getMetaCacheName()))
+ continue;
+
try {
Collection<IpcServerEndpoint> endPoints = igfsProc.endpoints(igfs.name());
[47/50] [abbrv] ignite git commit: Cleanup (3).
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index e75e8ca..897a4ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -19,7 +19,6 @@ package org.apache.ignite.spi.discovery.tcp.messages;
import java.util.UUID;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.Marshaller;
@@ -92,7 +91,7 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
@Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr,
final String gridName) throws Throwable {
if (msg == null) {
- msg = MarshallerUtils.unmarshal(marsh, msgBytes, ldr, gridName);
+ msg = MarshallerUtils.unmarshal(gridName, marsh, msgBytes, ldr);
assert msg != null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
index 7378bd2..818ae6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
@@ -24,7 +24,6 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.nio.GridBufferedParser;
import org.apache.ignite.internal.util.nio.GridDelimitedParser;
import org.apache.ignite.internal.util.nio.GridNioCodecFilter;
@@ -222,7 +221,7 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
/** {@inheritDoc} */
@Override public T convert(byte[] msg, final String gridName) {
try {
- return MarshallerUtils.unmarshal(MARSH, msg, null, gridName);
+ return MarshallerUtils.unmarshal(gridName, MARSH, msg, null);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
index 35120cb..2c5c122 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
@@ -68,7 +68,7 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
assert msg instanceof byte[];
// Always unmarshal with system classloader.
- proceedMessageReceived(ses, MarshallerUtils.unmarshal(marshaller, (byte[])msg, null, ses.gridName()));
+ proceedMessageReceived(ses, MarshallerUtils.unmarshal(ses.gridName(), marshaller, (byte[])msg, null));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index a3d3249..0066368 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1544,8 +1544,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
@Override public Object deserialize(byte[] bytes) throws Exception {
if (ctx != null) {
- return MarshallerUtils.unmarshal(marshaller, bytes,
- U.resolveClassLoader(ctx.config()), ctx.gridName());
+ return MarshallerUtils.unmarshal(ctx.gridName(), marshaller, bytes,
+ U.resolveClassLoader(ctx.config()));
}
else
return marshaller.unmarshal(bytes, null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f459866/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index d635825..2e2531d 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -338,7 +338,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private <T> T unmarshal(final byte[] bytes) throws IOException {
if (marshaller != null) {
try {
- return MarshallerUtils.unmarshal(marshaller, bytes, getClass().getClassLoader(), gridName);
+ return MarshallerUtils.unmarshal(gridName, marshaller, bytes, getClass().getClassLoader());
}
catch (IgniteCheckedException e) {
throw new IOException(e);
[39/50] [abbrv] ignite git commit: Review (WIP).
Posted by vo...@apache.org.
Review (WIP).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1a3b0ea9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1a3b0ea9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1a3b0ea9
Branch: refs/heads/ignite-2649
Commit: 1a3b0ea98b25a868beebddcd9b96584ba640268d
Parents: 6b8231f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 15:35:36 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 15:35:36 2016 +0300
----------------------------------------------------------------------
.../rendezvous/RendezvousAffinityFunction.java | 2 +-
.../cache/store/jdbc/CacheJdbcBlobStore.java | 2 +-
.../internal/GridEventConsumeHandler.java | 5 +-
.../internal/GridMessageListenHandler.java | 4 +-
.../internal/binary/BinaryEnumObjectImpl.java | 2 +-
.../internal/binary/BinaryWriterExImpl.java | 2 +-
.../checkpoint/GridCheckpointManager.java | 4 +-
.../managers/communication/GridIoManager.java | 6 +-
.../deployment/GridDeploymentCommunication.java | 2 +-
.../eventstorage/GridEventStorageManager.java | 8 +--
.../swapspace/GridSwapSpaceManager.java | 2 +-
.../processors/affinity/GridAffinityUtils.java | 2 +-
.../cache/CacheEntrySerializablePredicate.java | 2 +-
.../cache/CacheInvokeDirectResult.java | 2 +-
.../processors/cache/GridCacheUtils.java | 3 +-
.../GridDistributedLockResponse.java | 2 +-
.../GridDistributedTxPrepareRequest.java | 2 +-
.../GridDistributedTxPrepareResponse.java | 2 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 2 +-
.../dht/GridDhtTxFinishResponse.java | 2 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 2 +-
.../atomic/GridNearAtomicUpdateResponse.java | 2 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 2 +-
.../GridDhtPartitionDemandMessage.java | 2 +-
.../preloader/GridDhtPartitionsFullMessage.java | 4 +-
.../GridDhtPartitionsSingleMessage.java | 4 +-
.../distributed/near/GridNearGetResponse.java | 2 +-
.../near/GridNearSingleGetResponse.java | 2 +-
.../near/GridNearTxFinishResponse.java | 2 +-
.../cache/query/GridCacheQueryResponse.java | 2 +-
.../cache/query/GridCacheSqlQuery.java | 2 +-
.../continuous/CacheContinuousQueryHandler.java | 2 +-
.../jdbc/GridCacheQueryJdbcMetadataTask.java | 4 +-
.../query/jdbc/GridCacheQueryJdbcTask.java | 6 +-
.../version/GridCacheRawVersionedEntry.java | 4 +-
.../closure/GridClosureProcessor.java | 2 +-
.../continuous/GridContinuousProcessor.java | 2 +-
.../processors/continuous/StartRequestData.java | 2 +-
.../datastreamer/DataStreamProcessor.java | 6 +-
.../datastreamer/DataStreamerImpl.java | 4 +-
.../processors/igfs/IgfsAckMessage.java | 2 +-
.../processors/igfs/IgfsDeleteMessage.java | 2 +-
.../processors/job/GridJobProcessor.java | 10 +--
.../internal/processors/job/GridJobWorker.java | 6 +-
.../offheap/GridOffHeapProcessor.java | 2 +-
.../handlers/task/GridTaskCommandHandler.java | 4 +-
.../service/GridServiceProcessor.java | 4 +-
.../processors/task/GridTaskProcessor.java | 4 +-
.../processors/task/GridTaskWorker.java | 8 +--
.../ignite/marshaller/MarshallerUtils.java | 70 +++++++++++---------
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 18 ++---
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +-
.../TcpDiscoveryMulticastIpFinder.java | 3 +-
.../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +-
.../communication/HadoopMarshallerFilter.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../ignite/cache/websession/WebSessionV2.java | 2 +-
58 files changed, 133 insertions(+), 132 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 2dd646f..6c1fec3 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -338,7 +338,7 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] nodeHashBytes = MarshallerUtils.marshal(
- ignite.configuration().getMarshaller(), nodeHash, ignite.name());
+ ignite.name(), ignite.configuration().getMarshaller(), nodeHash);
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
out.write(nodeHashBytes, 0, nodeHashBytes.length); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
index e641736..8d5227c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -561,7 +561,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
* @throws IgniteCheckedException If failed to convert.
*/
protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return MarshallerUtils.marshal(marsh, obj, ignite.name());
+ return MarshallerUtils.marshal(ignite.name(), marsh, obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index e99c2af..a180965 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -50,7 +50,6 @@ import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
@@ -371,7 +370,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
depInfo = new GridDeploymentInfoBean(dep);
- filterBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), filter, ctx.gridName());
+ filterBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), filter);
}
}
@@ -492,7 +491,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
void p2pMarshal(final GridKernalContext ctx) throws IgniteCheckedException {
assert ctx.config().getMarshaller() != null;
- bytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), evt, ctx.gridName());
+ bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), evt);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 8984313..373244f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -160,9 +160,9 @@ public class GridMessageListenHandler implements GridContinuousHandler {
assert ctx.config().isPeerClassLoadingEnabled();
if (topic != null)
- topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
+ topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
- predBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), pred, ctx.gridName());
+ predBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), pred);
// Deploy only listener, as it is very likely to be of some user class.
GridPeerDeployAware pda = U.peerDeployAware(pred);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index aa415eb..0f9e2e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -244,7 +244,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectContext cacheCtx) throws IgniteCheckedException {
- return MarshallerUtils.marshal(ctx.marshaller(), this, ctx.configuration().getGridName());
+ return MarshallerUtils.marshal(ctx.configuration().getGridName(), ctx.marshaller(), this);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index de89f76..675b2d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -181,7 +181,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
out.writeByte(GridBinaryMarshaller.OPTM_MARSH);
try {
- byte[] arr = MarshallerUtils.marshal(ctx.optimizedMarsh(), obj, ctx.configuration().getGridName());
+ byte[] arr = MarshallerUtils.marshal(ctx.configuration().getGridName(), ctx.optimizedMarsh(), obj);
writeInt(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
index a2db860..e14b74a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
@@ -174,7 +174,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
try {
switch (scope) {
case GLOBAL_SCOPE: {
- byte[] data = state == null ? null : MarshallerUtils.marshal(marsh, state, ctx.gridName());
+ byte[] data = state == null ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, state);
saved = getSpi(ses.getCheckpointSpi()).saveCheckpoint(key, data, timeout, override);
@@ -205,7 +205,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
timeout = ses.getEndTime() - now;
// Save it first to avoid getting null value on another node.
- byte[] data = state == null ? null : MarshallerUtils.marshal(marsh, state, ctx.gridName());
+ byte[] data = state == null ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, state);
Set<String> keys = keyMap.get(ses.getId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index ff5b780..3c33ee0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -1118,7 +1118,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
}
else {
if (topicOrd < 0)
- ioMsg.topicBytes(MarshallerUtils.marshal(marsh, topic, ctx.gridName()));
+ ioMsg.topicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, topic));
try {
if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi)
@@ -1378,10 +1378,10 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
byte[] serTopic = null;
if (!loc) {
- serMsg = MarshallerUtils.marshal(marsh, msg, ctx.gridName());
+ serMsg = MarshallerUtils.marshal(ctx.gridName(), marsh, msg);
if (topic != null)
- serTopic = MarshallerUtils.marshal(marsh, topic, ctx.gridName());
+ serTopic = MarshallerUtils.marshal(ctx.gridName(), marsh, topic);
}
GridDeployment dep = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index ba3b829..78c1c3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -446,7 +446,7 @@ class GridDeploymentCommunication {
long start = U.currentTimeMillis();
if (req.responseTopic() != null && !ctx.localNodeId().equals(dstNode.id()))
- req.responseTopicBytes(MarshallerUtils.marshal(marsh, req.responseTopic(), ctx.gridName()));
+ req.responseTopicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, req.responseTopic()));
ctx.io().send(dstNode, TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 233110b..6ec5d3c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -933,7 +933,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ioMgr.addMessageListener(resTopic, resLsnr);
- byte[] serFilter = MarshallerUtils.marshal(marsh, p, ctx.gridName());
+ byte[] serFilter = MarshallerUtils.marshal(ctx.gridName(), marsh, p);
GridDeployment dep = ctx.deploy().deploy(p.getClass(), U.detectClassLoader(p.getClass()));
@@ -1024,7 +1024,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ctx.io().send(locNode, topic, msg, plc);
if (!rmtNodes.isEmpty()) {
- msg.responseTopicBytes(MarshallerUtils.marshal(marsh, msg.responseTopic(), ctx.gridName()));
+ msg.responseTopicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, msg.responseTopic()));
ctx.io().send(rmtNodes, topic, msg, plc);
}
@@ -1144,8 +1144,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
log.debug("Sending event query response to node [nodeId=" + nodeId + "res=" + res + ']');
if (!ctx.localNodeId().equals(nodeId)) {
- res.eventsBytes(MarshallerUtils.marshal(marsh, res.events(), ctx.gridName()));
- res.exceptionBytes(MarshallerUtils.marshal(marsh, res.exception(), ctx.gridName()));
+ res.eventsBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, res.events()));
+ res.exceptionBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, res.exception()));
}
ctx.io().send(node, req.responseTopic(), res, PUBLIC_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index b5e18d1..972fe80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -412,7 +412,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
* @throws IgniteCheckedException If failed.
*/
private byte[] marshal(Object obj) throws IgniteCheckedException {
- return MarshallerUtils.marshal(marsh, obj, ctx.gridName());
+ return MarshallerUtils.marshal(ctx.gridName(), marsh, obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index e5d2085..939c14f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -78,7 +78,7 @@ class GridAffinityUtils {
throw new IgniteDeploymentCheckedException("Failed to deploy affinity object with class: " + cls.getName());
return new GridAffinityMessage(
- MarshallerUtils.marshal(ctx.config().getMarshaller(), o, ctx.gridName()),
+ MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), o),
cls.getName(),
dep.classLoaderId(),
dep.deployMode(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index d0837bd..c59d9a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -94,7 +94,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
p.prepareMarshal(ctx);
- bytes = MarshallerUtils.marshal(ctx.marshaller(), p, ctx.gridName());
+ bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), p);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index a8d9caa..e8c4ebc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -107,7 +107,7 @@ public class CacheInvokeDirectResult implements Message {
key.prepareMarshal(ctx.cacheObjectContext());
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
if (res != null)
res.prepareMarshal(ctx.cacheObjectContext());
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index fc51e84..a0913ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -55,7 +55,6 @@ import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.internal.GridKernalContext;
@@ -992,7 +991,7 @@ public class GridCacheUtils {
}
}
- return MarshallerUtils.marshal(ctx.marshaller(), obj, ctx.gridName());
+ return MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index 31cc588..d805660 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -203,7 +203,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index ae394d7..f208658 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -333,7 +333,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
// Marshal txNodes only if there is a node in topology with an older version.
if (ctx.exchange().minimumNodeVersion(topologyVersion()).compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
if (txNodes != null && txNodesBytes == null)
- txNodesBytes = MarshallerUtils.marshal(ctx.marshaller(), txNodes, ctx.gridName());
+ txNodesBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), txNodes);
}
else {
if (txNodesMsg == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index 7c47b2b..180e446 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -101,7 +101,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index f3ac402..1952730 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -107,7 +107,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
super.prepareMarshal(ctx);
if (affAssignment != null)
- affAssignmentBytes = MarshallerUtils.marshal(ctx.marshaller(), affAssignment, ctx.gridName());
+ affAssignmentBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), affAssignment);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index 7beb1d3..d60bb51 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -112,7 +112,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (checkCommittedErr != null)
- checkCommittedErrBytes = MarshallerUtils.marshal(ctx.marshaller(), checkCommittedErr, ctx.gridName());
+ checkCommittedErrBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), checkCommittedErr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index 688c439..159deee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -168,7 +168,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
prepareMarshalCacheObjects(nearEvicted, cctx);
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index ed923b8..e1d0b84 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -398,7 +398,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
GridCacheContext cctx = ctx.cacheContext(cacheId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index 4b49730..723c41a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -172,7 +172,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
info.marshal(cctx);
}
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index cbc01be..9c12962 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -184,7 +184,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
super.prepareMarshal(ctx);
if (topic != null)
- topicBytes = MarshallerUtils.marshal(ctx.marshaller(), topic, ctx.gridName());
+ topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), topic);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index a1f6700..c455ca4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -134,10 +134,10 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
super.prepareMarshal(ctx);
if (parts != null && partsBytes == null)
- partsBytes = MarshallerUtils.marshal(ctx.marshaller(), parts, ctx.gridName());
+ partsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), parts);
if (partCntrs != null)
- partCntrsBytes = MarshallerUtils.marshal(ctx.marshaller(), partCntrs, ctx.gridName());
+ partCntrsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), partCntrs);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 3be312b..b3ee57b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -138,10 +138,10 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
super.prepareMarshal(ctx);
if (partsBytes == null && parts != null)
- partsBytes = MarshallerUtils.marshal(ctx.marshaller(), parts, ctx.gridName());
+ partsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), parts);
if (partCntrs != null)
- partCntrsBytes = MarshallerUtils.marshal(ctx.marshaller(), partCntrs, ctx.gridName());
+ partCntrsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), partCntrs);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index ff1a373..d530d06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -191,7 +191,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
}
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
index e290310..37af50a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
@@ -170,7 +170,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
}
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 809e11c..753f5e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -102,7 +102,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 28ae466..b1615f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -125,7 +125,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
+ errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
metaDataBytes = marshalCollection(metadata, cctx);
dataBytes = marshalCollection(data, cctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index df6621f..aae96a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -142,7 +142,7 @@ public class GridCacheSqlQuery implements Message {
assert params != null;
- paramsBytes = MarshallerUtils.marshal(m, params, kernalCtx.gridName());
+ paramsBytes = MarshallerUtils.marshal(kernalCtx.gridName(), m, params);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index a9cf668..8ad4249 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -1542,7 +1542,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
depInfo = new GridDeploymentInfoBean(dep);
- bytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), obj, ctx.gridName());
+ bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
index 9d4fb7d..d659f10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
@@ -154,7 +154,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 0;
- data = MarshallerUtils.marshal(MARSHALLER, F.asList(schemasMap, indexesInfo), ignite.name());
+ data = MarshallerUtils.marshal(ignite.name(), MARSHALLER, F.asList(schemasMap, indexesInfo));
}
catch (Throwable t) {
U.error(log, "Failed to get metadata for JDBC.", t);
@@ -164,7 +164,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 1;
try {
- data = MarshallerUtils.marshal(MARSHALLER, err, ignite.name());
+ data = MarshallerUtils.marshal(ignite.name(), MARSHALLER, err);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index d078f38..b98dcbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -131,13 +131,13 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
if (res.getException() == null) {
status = 0;
- bytes = MarshallerUtils.marshal(MARSHALLER, res.getData(), ignite.name());
+ bytes = MarshallerUtils.marshal(ignite.name(), MARSHALLER, res.getData());
}
else {
status = 1;
- bytes = MarshallerUtils.marshal(MARSHALLER, new SQLException(res.getException().getMessage()),
- ignite.name());
+ bytes = MarshallerUtils.marshal(ignite.name(), MARSHALLER, new SQLException(res.getException().getMessage())
+ );
}
byte[] packet = new byte[bytes.length + 1];
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
index 2c64209..0b87652 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
@@ -242,13 +242,13 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
if (keyBytes == null) {
key.prepareMarshal(ctx);
- keyBytes = MarshallerUtils.marshal(marsh, key, ctx.kernalContext().gridName());
+ keyBytes = MarshallerUtils.marshal(ctx.kernalContext().gridName(), marsh, key);
}
if (valBytes == null && val != null) {
val.prepareMarshal(ctx);
- valBytes = MarshallerUtils.marshal(marsh, val, ctx.kernalContext().gridName());
+ valBytes = MarshallerUtils.marshal(ctx.kernalContext().gridName(), marsh, val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/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 e17c3fe..8c756c1 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
@@ -1145,7 +1145,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
if (closureBytes == null) {
closure = c.job;
- closureBytes = MarshallerUtils.marshal(marsh, c.job, ctx.gridName());
+ closureBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, c.job);
}
if (c.job == closure)
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index 388487f..ef4e729 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -1324,7 +1324,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (!msg.messages() &&
msg.data() != null &&
(nodes.size() > 1 || !ctx.localNodeId().equals(F.first(nodes).id())))
- msg.dataBytes(MarshallerUtils.marshal(marsh, msg.data(), ctx.gridName()));
+ msg.dataBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, msg.data()));
for (ClusterNode node : nodes) {
int cnt = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
index be4562a..4167c62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
@@ -98,7 +98,7 @@ class StartRequestData implements Externalizable {
void p2pMarshal(Marshaller marsh, final GridKernalContext kernalCtx) throws IgniteCheckedException {
assert marsh != null;
- prjPredBytes = MarshallerUtils.marshal(marsh, prjPred, kernalCtx.gridName());
+ prjPredBytes = MarshallerUtils.marshal(kernalCtx.gridName(), marsh, prjPred);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index 146a864..e1f8d6b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -91,8 +91,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
if (ctx.config().isDaemon())
return;
- marshErrBytes = MarshallerUtils.marshal(marsh, new IgniteCheckedException("Failed to marshal response error, " +
- "see node log for details."), ctx.gridName());
+ marshErrBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, new IgniteCheckedException("Failed to marshal response error, " +
+ "see node log for details."));
flusher = new IgniteThread(new GridWorker(ctx.gridName(), "grid-data-loader-flusher", log) {
@Override protected void body() throws InterruptedException {
@@ -332,7 +332,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
byte[] errBytes;
try {
- errBytes = err != null ? MarshallerUtils.marshal(marsh, err, ctx.gridName()) : null;
+ errBytes = err != null ? MarshallerUtils.marshal(ctx.gridName(), marsh, err) : null;
}
catch (Exception e) {
U.error(log, "Failed to marshal error [err=" + err + ", marshErr=" + e + ']', e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 066c789..10f266e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -1360,11 +1360,11 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
if (updaterBytes == null) {
assert rcvr != null;
- updaterBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), rcvr, ctx.gridName());
+ updaterBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), rcvr);
}
if (topicBytes == null)
- topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
+ topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal (request will not be sent).", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index 646d492..c123201 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -98,7 +98,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
super.prepareMarshal(marsh, kernalCtx);
if (err != null)
- errBytes = MarshallerUtils.marshal(marsh, err, kernalCtx.gridName());
+ errBytes = MarshallerUtils.marshal(kernalCtx.gridName(), marsh, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index 7e206e3..c971dc6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -98,7 +98,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
super.prepareMarshal(marsh, kernalCtx);
if (err != null)
- errBytes = MarshallerUtils.marshal(marsh, err, kernalCtx.gridName());
+ errBytes = MarshallerUtils.marshal(kernalCtx.gridName(), marsh, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index baf80e8..92bef35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -404,7 +404,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(taskNode.id()) && !ctx.config().isMarshalLocalJobs();
GridTaskSessionRequest req = new GridTaskSessionRequest(ses.getId(), ses.getJobId(),
- loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()), attrs);
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs), attrs);
Object topic = TOPIC_TASK.topic(ses.getJobId(), ctx.discovery().localNode().id());
@@ -517,7 +517,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
ctx.io().send(taskNode, TOPIC_JOB_SIBLINGS,
new GridJobSiblingsRequest(ses.getId(),
loc ? topic : null,
- loc ? null : MarshallerUtils.marshal(marsh, topic, ctx.gridName())),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, topic)),
SYSTEM_POOL);
// 4. Listen to discovery events.
@@ -1334,11 +1334,11 @@ public class GridJobProcessor extends GridProcessorAdapter {
locNodeId,
req.getSessionId(),
req.getJobId(),
- loc ? null : MarshallerUtils.marshal(marsh, ex, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ex),
ex,
- loc ? null : MarshallerUtils.marshal(marsh, null, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, null),
null,
- loc ? null : MarshallerUtils.marshal(marsh, null, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, null),
null,
false);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index 3d17c62..d9e256c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -746,11 +746,11 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
ctx.localNodeId(),
ses.getId(),
ses.getJobId(),
- loc ? null : MarshallerUtils.marshal(marsh, ex, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ex),
loc ? ex : null,
- loc ? null: MarshallerUtils.marshal(marsh, res, ctx.gridName()),
+ loc ? null: MarshallerUtils.marshal(ctx.gridName(), marsh, res),
loc ? res : null,
- loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs),
loc ? attrs : null,
isCancelled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
index 8d4e75e..bbcfbe5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
@@ -109,7 +109,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
private byte[] keyBytes(KeyCacheObject key, @Nullable byte[] keyBytes) throws IgniteCheckedException {
assert key != null;
- return keyBytes != null ? keyBytes : MarshallerUtils.marshal(marsh, key, ctx.gridName());
+ return keyBytes != null ? keyBytes : MarshallerUtils.marshal(ctx.gridName(), marsh, key);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index b6adfca..484dca0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -136,7 +136,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
res.error(err.getMessage());
else {
res.result(desc.result());
- res.resultBytes(MarshallerUtils.marshal(ctx.config().getMarshaller(), desc.result(), ctx.gridName()));
+ res.resultBytes(MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), desc.result()));
}
}
else
@@ -495,7 +495,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
// 2. Send message.
try {
- byte[] topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
+ byte[] topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
ctx.io().send(taskNode, TOPIC_REST, new GridTaskResultRequest(taskId, topic, topicBytes), SYSTEM_POOL);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index c17c9fc..c90350f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -453,7 +453,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
LazyServiceConfiguration cfg0;
try {
- byte[] srvcBytes = MarshallerUtils.marshal(marsh, cfg.getService(), ctx.gridName());
+ byte[] srvcBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, cfg.getService());
cfg0 = new LazyServiceConfiguration(cfg, srvcBytes);
}
@@ -1134,7 +1134,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
Service svc = cfg.getService();
try {
- byte[] bytes = MarshallerUtils.marshal(m, svc, ctx.gridName());
+ byte[] bytes = MarshallerUtils.marshal(ctx.gridName(), m, svc);
Service cp = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(),
ctx.config()), ctx.gridName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index b8ab83c..57b915f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -914,7 +914,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
GridTaskSessionRequest req = new GridTaskSessionRequest(
ses.getId(),
null,
- loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs),
attrs);
// Make sure to go through IO manager always, since order
@@ -1315,7 +1315,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
ctx.io().send(nodeId, topic,
new GridJobSiblingsResponse(
loc ? siblings : null,
- loc ? null : MarshallerUtils.marshal(marsh, siblings, ctx.gridName())),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, siblings)),
SYSTEM_POOL);
}
catch (IgniteCheckedException e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index fd0881d..a4656f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -1254,16 +1254,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
ses.getTaskName(),
ses.getUserVersion(),
ses.getTaskClassName(),
- loc ? null : MarshallerUtils.marshal(marsh, res.getJob(), ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, res.getJob()),
loc ? res.getJob() : null,
ses.getStartTime(),
timeout,
ses.getTopology(),
- loc ? null : MarshallerUtils.marshal(marsh, ses.getJobSiblings(), ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ses.getJobSiblings()),
loc ? ses.getJobSiblings() : null,
- loc ? null : MarshallerUtils.marshal(marsh, sesAttrs, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, sesAttrs),
loc ? sesAttrs : null,
- loc ? null : MarshallerUtils.marshal(marsh, jobAttrs, ctx.gridName()),
+ loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, jobAttrs),
loc ? jobAttrs : null,
ses.getCheckpointSpi(),
dep.classLoaderId(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 94ca30b..2f8eb08 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -29,27 +29,33 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
/**
- * Util class that sets and discards thread local
- * ignite grid name in {@link IgnitionEx} class.
+ * Utility marshaller methods.
*/
public final class MarshallerUtils {
/**
+ * Marshal object. Used when grid name is not available, f.e. in tests.
*
+ * @param marsh Marshaller.
+ * @param obj Object to marshal.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
*/
- private MarshallerUtils() {
+ public static byte[] marshal(final Marshaller marsh, final @Nullable Object obj) throws IgniteCheckedException {
+ // This method used to keep marshaller usages in one place.
+ return marsh.marshal(obj);
}
/**
- * Marshal object to stream and set grid name thread local.
+ * Marshal object setting provided node name.
*
- * @param marshaller Marshaller.
+ * @param gridName Node name.
+ * @param marsh Marshaller.
* @param obj Object to marshal.
- * @param out Output stream.
- * @param gridName Grid name.
- * @throws IgniteCheckedException If fail.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
*/
- public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
- final OutputStream out, final String gridName) throws IgniteCheckedException {
+ public static byte[] marshal(final String gridName, final Marshaller marsh, @Nullable Object obj)
+ throws IgniteCheckedException {
final LocalGridName gridNameTl = gridName();
final String gridNameStr = gridNameTl.getGridName();
@@ -58,23 +64,29 @@ public final class MarshallerUtils {
try {
gridNameTl.setGridName(true, gridName);
- marshaller.marshal(obj, out);
- } finally {
+ return marsh.marshal(obj);
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
+
+
+
+
+
/**
- * Marshal object and set grid name thread local.
+ * Marshal object to stream and set grid name thread local.
*
* @param marshaller Marshaller.
* @param obj Object to marshal.
+ * @param out Output stream.
* @param gridName Grid name.
- * @return Binary data.
* @throws IgniteCheckedException If fail.
*/
- public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
- final String gridName) throws IgniteCheckedException {
+ public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
+ final OutputStream out, final String gridName) throws IgniteCheckedException {
final LocalGridName gridNameTl = gridName();
final String gridNameStr = gridNameTl.getGridName();
@@ -83,28 +95,13 @@ public final class MarshallerUtils {
try {
gridNameTl.setGridName(true, gridName);
- return marshaller.marshal(obj);
- }
- finally {
+ marshaller.marshal(obj, out);
+ } finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
/**
- * Marshal object.
- * <p>Use only when grid name is not available, f.e. in tests.</p>
- *
- * @param marshaller Marshaller.
- * @param obj Object to marshal.
- * @return Binary data.
- * @throws IgniteCheckedException If fail.
- */
- public static byte[] marshal(final Marshaller marshaller, final @Nullable Object obj) throws IgniteCheckedException {
- // This method used to keep marshaller usages in one place.
- return marshaller.marshal(obj);
- }
-
- /**
* Unmarshal object from stream and set grid name thread local.
*
* @param marshaller Marshaller.
@@ -260,4 +257,11 @@ public final class MarshallerUtils {
private static LocalGridName gridName() {
return IgnitionEx.gridNameThreadLocal();
}
+
+ /**
+ * Private constructor.
+ */
+ private MarshallerUtils() {
+ // No-op.
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 0a0b42d..b53a81e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -431,7 +431,7 @@ class ClientImpl extends TcpDiscoveryImpl {
try {
sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().name())));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, evt)));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -685,8 +685,8 @@ class ClientImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- MarshallerUtils.marshal(spi.marsh, attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS),
- spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)
+ ));
node.setAttributes(attrs);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index d8dcca4..be108f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -743,7 +743,7 @@ class ServerImpl extends TcpDiscoveryImpl {
@Override public void sendCustomEvent(DiscoverySpiCustomMessage evt) {
try {
msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().name())));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, evt)));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -827,7 +827,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(locNode.attributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, subj));
attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
locNode.setAttributes(attrs);
@@ -1243,8 +1243,8 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- MarshallerUtils.marshal(spi.marsh,
- attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS), spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh,
+ attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
node.setAttributes(attrs);
}
@@ -2361,7 +2361,7 @@ class ServerImpl extends TcpDiscoveryImpl {
for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
if (msgBytes == null) {
try {
- msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().name());
+ msgBytes = MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msg);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal message: " + msg, e);
@@ -3140,7 +3140,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, subj));
node.setAttributes(attrs);
}
@@ -4860,7 +4860,7 @@ class ServerImpl extends TcpDiscoveryImpl {
try {
TcpDiscoveryCustomEventMessage ackMsg = new TcpDiscoveryCustomEventMessage(
getLocalNodeId(), nextMsg,
- MarshallerUtils.marshal(spi.marsh, nextMsg, spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, nextMsg));
ackMsg.topologyVersion(msg.topologyVersion());
@@ -5005,7 +5005,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (msgObj.isMutable())
msg.message(msgObj,
- MarshallerUtils.marshal(spi.marsh, msgObj, spi.ignite().name()));
+ MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msgObj));
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -5932,7 +5932,7 @@ class ServerImpl extends TcpDiscoveryImpl {
byte[] msgBytes = msgT.get2();
if (msgBytes == null)
- msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().name());
+ msgBytes = MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msg);
if (msg instanceof TcpDiscoveryClientAckResponse) {
if (clientVer == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 61186d7..de9877c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1678,7 +1678,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, Serializable> entry : data.entrySet()) {
try {
- byte[] bytes = MarshallerUtils.marshal(marsh, entry.getValue(), ignite.name());
+ byte[] bytes = MarshallerUtils.marshal(ignite.name(), marsh, entry.getValue());
data0.put(entry.getKey(), bytes);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 24f4803..3c9c20f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -32,7 +32,6 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
@@ -702,7 +701,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
private AddressResponse(Collection<InetSocketAddress> addrs, final String gridName) throws IgniteCheckedException {
this.addrs = addrs;
- byte[] addrsData = MarshallerUtils.marshal(marsh, addrs, gridName);
+ byte[] addrsData = MarshallerUtils.marshal(gridName, marsh, addrs);
data = new byte[U.IGNITE_HEADER.length + addrsData.length];
if (data.length > MAX_DATA_LENGTH)
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index b8365c5..052a422 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -595,7 +595,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
if (keyBytes == null) {
try {
- keyBytes = MarshallerUtils.marshal(ignite.configuration().getMarshaller(), key.key(), ignite.name());
+ keyBytes = MarshallerUtils.marshal(ignite.name(), ignite.configuration().getMarshaller(), key.key());
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal key: " + key.key(), e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
index a2e3902..35120cb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
@@ -60,7 +60,7 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
@Override public GridNioFuture<?> onSessionWrite(GridNioSession ses, Object msg) throws IgniteCheckedException {
assert msg instanceof HadoopMessage : "Invalid message type: " + msg;
- return proceedSessionWrite(ses, MarshallerUtils.marshal(marshaller, msg, ses.gridName()));
+ return proceedSessionWrite(ses, MarshallerUtils.marshal(ses.gridName(), marshaller, msg));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a3b0ea9/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index c3700ab..51fa52d 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1537,7 +1537,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
return new JavaObjectSerializer() {
@Override public byte[] serialize(Object obj) throws Exception {
if (ctx != null)
- return MarshallerUtils.marshal(marshaller, obj, ctx.gridName());
+ return MarshallerUtils.marshal(ctx.gridName(), marshaller, obj);
else
return MarshallerUtils.marshal(marshaller, obj);
}
[44/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
Cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2cc423b2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2cc423b2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2cc423b2
Branch: refs/heads/ignite-2649
Commit: 2cc423b2de360901960ef616062da9f386e09562
Parents: 28c4d93
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:26:22 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:26:22 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryUtils.java | 4 +-
.../ignite/marshaller/MarshallerUtils.java | 97 ++++++++++----------
.../spi/checkpoint/sharedfs/SharedFsUtils.java | 2 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 8 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 4 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 4 +-
6 files changed, 60 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 0ce4916..5b048cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -1590,8 +1590,8 @@ public class BinaryUtils {
ByteArrayInputStream input = new ByteArrayInputStream(in.array(), in.position(), len);
try {
- return MarshallerUtils.unmarshal(ctx.optimizedMarsh(), input,
- U.resolveClassLoader(clsLdr, ctx.configuration()), ctx.configuration().getGridName());
+ return MarshallerUtils.unmarshal(ctx.configuration().getGridName(), ctx.optimizedMarsh(), input,
+ U.resolveClassLoader(clsLdr, ctx.configuration()));
}
catch (IgniteCheckedException e) {
throw new BinaryObjectException("Failed to unmarshal object with optimized marshaller", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 5651766..fd13937 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -29,7 +29,7 @@ import java.io.OutputStream;
/**
* Utility marshaller methods.
*/
-public final class MarshallerUtils {
+public class MarshallerUtils {
/**
* Marshal object with provided node name.
*
@@ -40,10 +40,10 @@ public final class MarshallerUtils {
* @throws IgniteCheckedException If failed.
*/
public static byte[] marshal(String name, Marshaller marsh, @Nullable Object obj) throws IgniteCheckedException {
- final LocalGridName gridNameTl = gridName();
+ LocalGridName gridNameTl = gridName();
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
+ String gridNameStr = gridNameTl.getGridName();
+ boolean init = gridNameTl.isSet();
try {
gridNameTl.setGridName(true, name);
@@ -64,18 +64,19 @@ public final class MarshallerUtils {
* @param out Output stream.
* @throws IgniteCheckedException If fail.
*/
- public static void marshal(final String name, final Marshaller marshaller, final @Nullable Object obj,
- final OutputStream out) throws IgniteCheckedException {
- final LocalGridName gridNameTl = gridName();
+ public static void marshal(String name, Marshaller marshaller, @Nullable Object obj, OutputStream out)
+ throws IgniteCheckedException {
+ LocalGridName gridNameTl = gridName();
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
+ String gridNameStr = gridNameTl.getGridName();
+ boolean init = gridNameTl.isSet();
try {
gridNameTl.setGridName(true, name);
marshaller.marshal(obj, out);
- } finally {
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -107,26 +108,26 @@ public final class MarshallerUtils {
/**
* Unmarshal object from stream and set grid name thread local.
*
- * @param marshaller Marshaller.
+ * @param name Grid name.
+ * @param marsh Marshaller.
* @param in Input stream.
- * @param clsLdr Class loader.
- * @param gridName Grid name.
- * @param <T> Target type.
+ * @param ldr Class loader.
* @return Deserialized object.
* @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal(final Marshaller marshaller, InputStream in, @Nullable ClassLoader clsLdr,
- final String gridName) throws IgniteCheckedException {
- final LocalGridName gridNameTl = gridName();
+ public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable ClassLoader ldr)
+ throws IgniteCheckedException {
+ LocalGridName gridNameTl = gridName();
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
+ String gridNameStr = gridNameTl.getGridName();
+ boolean init = gridNameTl.isSet();
try {
- gridNameTl.setGridName(true, gridName);
+ gridNameTl.setGridName(true, name);
- return marshaller.unmarshal(in, clsLdr);
- } finally {
+ return marsh.unmarshal(in, ldr);
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -134,26 +135,26 @@ public final class MarshallerUtils {
/**
* Unmarshal object and set grid name thread local.
*
- * @param marshaller Marshaller.
- * @param arr Bianry data.
- * @param clsLdr Class loader.
- * @param gridName Grid name.
- * @param <T> Target type
+ * @param marsh Marshaller.
+ * @param arr Binary data.
+ * @param ldr Class loader.
+ * @param name Grid name.
* @return Deserialized object.
- * @throws IgniteCheckedException If fail.
+ * @throws IgniteCheckedException If failed.
*/
- public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
- final String gridName) throws IgniteCheckedException {
- final LocalGridName gridNameTl = gridName();
+ public static <T> T unmarshal( Marshaller marsh, byte[] arr, @Nullable ClassLoader ldr,
+ String name) throws IgniteCheckedException {
+ LocalGridName gridNameTl = gridName();
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
+ String gridNameStr = gridNameTl.getGridName();
+ boolean init = gridNameTl.isSet();
try {
- gridNameTl.setGridName(true, gridName);
+ gridNameTl.setGridName(true, name);
- return marshaller.unmarshal(arr, clsLdr);
- } finally {
+ return marsh.unmarshal(arr, ldr);
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
@@ -161,26 +162,26 @@ public final class MarshallerUtils {
/**
* Marshal and unmarshal object.
*
- * @param <T> Target type.
- * @param gridName Grid name.
- * @param marshaller Marshaller.
+ * @param name Grid name.
+ * @param marsh Marshaller.
* @param obj Object to clone.
* @param clsLdr Class loader.
* @return Deserialized value.
- * @throws IgniteCheckedException If fail.
+ * @throws IgniteCheckedException If failed.
*/
- public static <T> T marshalUnmarshal(final String gridName, final Marshaller marshaller, T obj,
- @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
- final LocalGridName gridNameTl = gridName();
+ public static <T> T marshalUnmarshal(String name, Marshaller marsh, T obj, @Nullable ClassLoader clsLdr)
+ throws IgniteCheckedException {
+ LocalGridName gridNameTl = gridName();
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
+ String gridNameStr = gridNameTl.getGridName();
+ boolean init = gridNameTl.isSet();
try {
- gridNameTl.setGridName(true, gridName);
+ gridNameTl.setGridName(true, name);
- return marshaller.unmarshal(marshaller.marshal(obj), clsLdr);
- } finally {
+ return marsh.unmarshal(marsh.marshal(obj), clsLdr);
+ }
+ finally {
gridNameTl.setGridName(init, gridNameStr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
index f25bad3..29a6a36 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
@@ -63,7 +63,7 @@ final class SharedFsUtils {
InputStream in = new FileInputStream(file);
try {
- return (SharedFsCheckpointData) MarshallerUtils.unmarshal(m, in, U.gridClassLoader(), igniteCfg.getGridName());
+ return (SharedFsCheckpointData) MarshallerUtils.unmarshal(igniteCfg.getGridName(), m, in, U.gridClassLoader());
}
finally {
U.close(in, log);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 67e7798..60d4131 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -887,8 +887,8 @@ class ClientImpl extends TcpDiscoveryImpl {
TcpDiscoveryAbstractMessage msg;
try {
- msg = MarshallerUtils.unmarshal(spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
+ msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()));
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
@@ -1213,8 +1213,8 @@ class ClientImpl extends TcpDiscoveryImpl {
List<TcpDiscoveryAbstractMessage> msgs = null;
while (!isInterrupted()) {
- TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
+ TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()));
if (msg instanceof TcpDiscoveryClientReconnectMessage) {
TcpDiscoveryClientReconnectMessage res = (TcpDiscoveryClientReconnectMessage)msg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 97696cb..00657db 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -5437,8 +5437,8 @@ class ServerImpl extends TcpDiscoveryImpl {
while (!isInterrupted()) {
try {
- TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.marsh, in,
- U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
+ TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()));
msg.senderNodeId(nodeId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cc423b2/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 9e4669a..368480f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1462,8 +1462,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
try {
sock.setSoTimeout((int)timeout);
- return MarshallerUtils.unmarshal(marsh, in == null ? sock.getInputStream() : in,
- U.resolveClassLoader(ignite.configuration()), ignite.configuration().getGridName());
+ return MarshallerUtils.unmarshal(ignite.configuration().getGridName(), marsh, in == null ? sock.getInputStream() : in,
+ U.resolveClassLoader(ignite.configuration()));
}
catch (IOException | IgniteCheckedException e) {
if (X.hasCause(e, SocketTimeoutException.class))
[12/50] [abbrv] ignite git commit: IGNITE-3446 Visor CMD: improve
usability for batch mode.
Posted by vo...@apache.org.
IGNITE-3446 Visor CMD: improve usability for batch mode.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4897315b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4897315b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4897315b
Branch: refs/heads/ignite-2649
Commit: 4897315b33a59e8566ffd026e99445279f27c53a
Parents: 6389400
Author: Andrey Novikov <an...@apache.org>
Authored: Fri Jul 15 16:54:21 2016 +0700
Committer: Andrey Novikov <an...@apache.org>
Committed: Fri Jul 15 16:54:21 2016 +0700
----------------------------------------------------------------------
.../ignite/visor/commands/VisorConsole.scala | 5 +-
.../commands/alert/VisorAlertCommand.scala | 2 +-
.../commands/cache/VisorCacheCommand.scala | 40 ++--
.../commands/cache/VisorCacheStopCommand.scala | 2 +-
.../config/VisorConfigurationCommand.scala | 23 ++-
.../commands/events/VisorEventsCommand.scala | 29 +--
.../visor/commands/gc/VisorGcCommand.scala | 11 +-
.../visor/commands/kill/VisorKillCommand.scala | 184 ++++++++++++++-----
.../visor/commands/node/VisorNodeCommand.scala | 13 +-
.../visor/commands/vvm/VisorVvmCommand.scala | 11 +-
.../scala/org/apache/ignite/visor/visor.scala | 76 +++++---
11 files changed, 276 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
index 6d91b05..b4d78b5 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
@@ -146,7 +146,10 @@ class VisorConsole {
batchCommand.foreach(commands => batchStream = Some(commands.replaceAll(";", "\n")))
val inputStream = batchStream match {
- case Some(cmd) => new ByteArrayInputStream((cmd + "\nquit\n").getBytes("UTF-8"))
+ case Some(cmd) =>
+ visor.batchMode = true
+
+ new ByteArrayInputStream((cmd + "\nquit\n").getBytes("UTF-8"))
case None => new FileInputStream(FileDescriptor.in)
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala
index db60443..401a3f2 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala
@@ -751,7 +751,7 @@ private case class VisorSentAlert(
assert(spec != null)
def idVar: String = {
- val v = mfind(id)
+ val v = mfindHead(id)
if (v.isDefined) id + "(@" + v.get._1 + ")" else id
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index b4ed6b8..a9f9137 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -73,12 +73,15 @@ import scala.language.{implicitConversions, reflectiveCalls}
*
* ====Arguments====
* {{{
- * -id=<node-id>
- * Full ID of the node to get cache statistics from.
- * Either '-id8' or '-id' can be specified.
- * If neither is specified statistics will be gathered from all nodes.
* -id8=<node-id>
* ID8 of the node to get cache statistics from.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
+ * If neither is specified statistics will be gathered from all nodes.
+ * -id=<node-id>
+ * Full ID of the node to get cache statistics from.
* Either '-id8' or '-id' can be specified.
* If neither is specified statistics will be gathered from all nodes.
* -c=<cache-name>
@@ -278,7 +281,7 @@ class VisorCacheCommand {
else if (hasArgFlag("swap", argLst))
VisorCacheSwapCommand().swap(argLst, node)
else if (hasArgFlag("stop", argLst))
- VisorCacheStopCommand().scan(argLst, node)
+ VisorCacheStopCommand().stop(argLst, node)
}
else {
if (hasArgFlag("clear", argLst))
@@ -311,7 +314,12 @@ class VisorCacheCommand {
return
}
- println("Time of the snapshot: " + formatDateTime(System.currentTimeMillis))
+ node match {
+ case Some(n) =>
+ println("ID8=" + nid8(n) + ", time of the snapshot: " + formatDateTime(System.currentTimeMillis))
+ case None =>
+ println("Time of the snapshot: " + formatDateTime(System.currentTimeMillis))
+ }
val sumT = VisorTextTable()
@@ -459,12 +467,12 @@ class VisorCacheCommand {
*/
private def mkCacheName(@Nullable s: String): String = {
if (s == null) {
- val v = mfind(DFLT_CACHE_KEY)
+ val v = mfindHead(DFLT_CACHE_KEY)
DFLT_CACHE_NAME + (if (v.isDefined) "(@" + v.get._1 + ')' else "")
}
else {
- val v = mfind(s)
+ val v = mfindHead(s)
s + (if (v.isDefined) "(@" + v.get._1 + ')' else "")
}
@@ -649,7 +657,7 @@ class VisorCacheCommand {
sumT.render()
- val a = ask("\nChoose cache number ('c' to cancel) [c]: ", "c")
+ val a = ask("\nChoose cache number ('c' to cancel) [c]: ", "0")
if (a.toLowerCase == "c")
None
@@ -703,17 +711,19 @@ object VisorCacheCommand {
"cache -stop -c=<cache-name>"
),
args = Seq(
+ "-id8=<node-id>" -> Seq(
+ "ID8 of the node to get cache statistics from.",
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'.",
+ "If neither is specified statistics will be gathered from all nodes."
+ ),
"-id=<node-id>" -> Seq(
"Full ID of the node to get cache statistics from.",
"Either '-id8' or '-id' can be specified.",
"If neither is specified statistics will be gathered from all nodes."
),
- "-id8=<node-id>" -> Seq(
- "ID8 of the node to get cache statistics from.",
- "Either '-id8' or '-id' can be specified.",
- "If neither is specified statistics will be gathered from all nodes.",
- "Note you can also use '@n0' ... '@nn' variables as shortcut to <node-id>."
- ),
"-c=<cache-name>" -> Seq(
"Name of the cache.",
"Note you can also use '@c0' ... '@cn' variables as shortcut to <cache-name>."
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
index bf81f73..1b55505 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
@@ -76,7 +76,7 @@ class VisorCacheStopCommand {
*
* @param argLst Command arguments.
*/
- def scan(argLst: ArgList, node: Option[ClusterNode]) {
+ def stop(argLst: ArgList, node: Option[ClusterNode]) {
val cacheArg = argValue("c", argLst)
val cacheName = cacheArg match {
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala
index 3f0f52f..1b8bbd5 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala
@@ -54,12 +54,16 @@ import scala.language.implicitConversions
*
* ====Arguments====
* {{{
+ * -id8=<node-id8>
+ * Node ID8.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
+ * If neither is specified - command starts in interactive mode.
* -id=<node-id>
* Full node ID. Either '-id8' or '-id' can be specified.
* If neither is specified - command starts in interactive mode.
- * -id8=<node-id8>
- * Node ID8. Either '-id8' or '-id' can be specified.
- * If neither is specified - command starts in interactive mode.
* }}}
*
* ====Examples====
@@ -388,14 +392,17 @@ object VisorConfigurationCommand {
s"${cmd.name} {-id=<node-id>|id8=<node-id8>}"
),
args = List(
+ "-id8=<node-id8>" -> List(
+ "Node ID8.",
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'.",
+ "If neither is specified - command starts in interactive mode."
+ ),
"-id=<node-id>" -> List(
"Full node ID. Either '-id8' or '-id' can be specified.",
"If neither is specified - command starts in interactive mode."
- ),
- "-id8=<node-id8>" -> List(
- "Node ID8. Either '-id8' or '-id' can be specified.",
- "If neither is specified - command starts in interactive mode.",
- "Note you can also use '@n0' ... '@nn' variables as shortcut to <node-id>."
)
),
examples = List(
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/events/VisorEventsCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/events/VisorEventsCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/events/VisorEventsCommand.scala
index f7ea625..e3e73c7 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/events/VisorEventsCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/events/VisorEventsCommand.scala
@@ -65,12 +65,15 @@ import scala.language.implicitConversions
*
* ====Arguments====
* {{{
- * -id=<node-id>
- * Full node ID.
- * Either '-id' or '-id8' can be specified.
- * If called without the arguments - starts in interactive mode.
* -id8
* Node ID8.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
+ * If called without the arguments - starts in interactive mode.
+ * -id=<node-id>
+ * Full node ID.
* Either '-id' or '-id8' can be specified.
* If called without the arguments - starts in interactive mode.
* -e=<ch,de,di,jo,ta,ca,cr,sw>
@@ -146,7 +149,7 @@ class VisorEventsCommand extends VisorConsoleCommand {
*/
@throws[IllegalArgumentException]("In case unknown event mnemonic.")
protected def typeFilter(typeArg: Option[String]) = {
- typeArg.map(_.split(",").map(typeIds).flatten).orNull
+ typeArg.map(_.split(",").flatMap(typeIds)).orNull
}
/**
@@ -229,6 +232,8 @@ class VisorEventsCommand extends VisorConsoleCommand {
return
}
+ println("ID8=" + nid8(node))
+
if (evts == null || evts.isEmpty) {
println("No events found.")
@@ -402,17 +407,19 @@ object VisorEventsCommand {
" {-t=<num>s|m|h|d} {-s=e|t} {-r} {-c=<n>}"
),
args = List(
+ "-id8=<node-id8>" -> List(
+ "Node ID8.",
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'.",
+ "If called without the arguments - starts in interactive mode."
+ ),
"-id=<node-id>" -> List(
"Full node ID.",
"Either '-id' or '-id8' can be specified.",
"If called without the arguments - starts in interactive mode."
),
- "-id8=<node-id8>" -> List(
- "Node ID8.",
- "Note that either '-id8' or '-id' can be specified and " +
- "you can also use '@n0' ... '@nn' variables as shortcut to <node-id8>.",
- "If called without the arguments - starts in interactive mode."
- ),
"-e=<ch,de,di,jo,ta,ca,cr,sw>" -> List(
"Comma separated list of event types that should be queried:",
" ch Checkpoint events.",
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/gc/VisorGcCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/gc/VisorGcCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/gc/VisorGcCommand.scala
index a9bf39f..990fd00 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/gc/VisorGcCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/gc/VisorGcCommand.scala
@@ -52,7 +52,10 @@ import scala.language.{implicitConversions, reflectiveCalls}
* {{{
* -id8=<node-id8>
* ID8 of the node.
- * Note that either '-id8' or '-id' can be specified.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
* -id=<node-id>
* ID of the node.
* Note that either '-id8' or '-id' can be specified.
@@ -159,8 +162,10 @@ object VisorGcCommand {
args = List(
"-id8=<node-id8>" -> List(
"ID8 of the node.",
- "Note that either '-id8' or '-id' can be specified and " +
- "you can also use '@n0' ... '@nn' variables as shortcut to <node-id8>."
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'."
),
"-id=<node-id>" -> List(
"ID of the node.",
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
index dffd5f1..c705e21 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
@@ -46,7 +46,7 @@ import scala.util.control.Breaks._
* {{{
* kill
* kill "-in|-ih"
- * kill "{-r|-k} {-id8=<node-id8>|-id=<node-id>}"
+ * kill "{-r|-k} {-sc} {-al|-ar|-id8=<node-id8>|-id=<node-id>}"
* }}}
*
* ====Arguments====
@@ -61,17 +61,28 @@ import scala.util.control.Breaks._
* Run command in interactive mode with ability to
* choose a host where to kill or restart nodes.
* Note that either '-in' or '-ih' can be specified.
+ * -al
+ * Kill or restart all nodes on this host.
+ * Note that either '-al' or '-ar' can be specified.
+ * -ar
+ * Kill or restart all nodes on other hosts.
+ * Note that either '-al', '-ar' can be specified.
+ * -sc
+ * Skip kill or restart of client nodes for group nodes command.
* -r
* Restart node mode.
* Note that either '-r' or '-k' can be specified.
- * If no parameters provided - command starts in interactive mode.
+ * If no other parameters provided - command executes on all nodes.
* -k
* Kill (stop) node mode.
* Note that either '-r' or '-k' can be specified.
- * If no parameters provided - command starts in interactive mode.
+ * If no other parameters provided - command executes on all nodes.
* -id8=<node-id8>
* ID8 of the node to kill or restart.
- * Note that either '-id8' or '-id' can be specified.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
* If no parameters provided - command starts in interactive mode.
* -id=<node-id>
* ID of the node to kill or restart.
@@ -85,6 +96,16 @@ import scala.util.control.Breaks._
* Starts command in interactive mode.
* kill "-id8=12345678 -r"
* Restart node with '12345678' ID8.
+ * kill -id8=@n0 -r" ->
+ * Restart specified node with id8 taken from 'n0' memory variable.
+ * kill -id8=@nl -r" ->
+ * Restart oldest local node with id8 taken from 'nl' memory variable.
+ * kill -id8=@nl -k" ->
+ * Kill (stop) oldest remote node with id8 taken from 'nr' memory variable.
+ * kill -r -ar" ->
+ * Restart all remote nodes.
+ * kill -k -sc -al" ->
+ * Kill (stop) all local server nodes.
* kill "-k"
* Kill (stop) all nodes.
* }}}
@@ -114,8 +135,12 @@ class VisorKillCommand extends VisorConsoleCommand {
val iNodes = hasArgFlag("in", argLst)
val iHosts = hasArgFlag("ih", argLst)
+ val skipClient = hasArgFlag("sc", argLst)
+
if (iNodes && iHosts)
scold("Only one of '-in' or '-ih' can be specified.").^^
+ else if ((iNodes || iHosts) && skipClient)
+ scold("Skip client flag is not allowed in interactive mode.").^^
else if (iNodes)
interactiveNodes().^^
else if (iHosts)
@@ -126,52 +151,94 @@ class VisorKillCommand extends VisorConsoleCommand {
val restart = hasArgFlag("r", argLst)
val kill = hasArgFlag("k", argLst)
- var node: ClusterNode = null
+ val allLocal = hasArgFlag("al", argLst)
+ val allRemote = hasArgFlag("ar", argLst)
if (kill && restart)
scold("Only one of '-k' or '-r' can be specified.")
else if (!kill && !restart)
scold("Missing '-k' or '-r' option in command: " + args)
- else if (id8.isDefined && id.isDefined)
- scold("Only one of -id8 or -id is allowed.")
+ else if (Seq(allLocal, allRemote, id8.isDefined, id.isDefined).count((v) => v) > 1)
+ scold("Only one of -al, -ar, -id8 or -id is allowed.")
+ else if ((id8.isDefined || id.isDefined) && skipClient)
+ scold("Skip client flag is allowed only for group command.")
else {
- if (id8.isDefined) {
+ val localGroup = ignite.cluster.forHost(ignite.localNode)
+
+ var nodes = if (id8.isDefined) {
val ns = nodeById8(id8.get)
if (ns.isEmpty)
scold("Unknown 'id8' value: " + id8.get).^^
- else if (ns.size != 1) {
+
+ if (ns.size != 1)
scold("'id8' resolves to more than one node (use full 'id' instead) : " + args).^^
- }
- else
- node = ns.head
+
+ ns.toSeq
}
- else if (id.isDefined)
- try {
- node = ignite.cluster.node(java.util.UUID.fromString(id.get))
+ else if (id.isDefined) {
+ var nid: UUID = null
- if (node == null)
- scold("'id' does not match any node : " + args).^^
+ try {
+ nid = UUID.fromString(id.get)
}
catch {
case e: IllegalArgumentException => scold("Invalid node 'id' in args: " + args).^^
}
- if (node == null && (id.isDefined || id8.isDefined))
- scold("Node with given ID cannot be found.").^^
+ val nodes = ignite.cluster.forNodeId(nid).nodes()
+
+ if (nodes.isEmpty)
+ scold("'id' does not match any node : " + args).^^
+
+ nodes.toSeq
+ } else if (allLocal) {
+ if (skipClient)
+ localGroup.forServers().nodes().toSeq
+ else
+ localGroup.nodes().toSeq
+ }
+ else if (allRemote) {
+ val remoteGroup = ignite.cluster.forOthers(localGroup)
+
+ if (skipClient)
+ remoteGroup.forServers().nodes().toSeq
+ else
+ remoteGroup.nodes().toSeq
+ }
+ else {
+ if (skipClient)
+ ignite.cluster.forServers().nodes().toSeq
+ else
+ ignite.cluster.nodes().toSeq
+ }
+
+ if (nodes.isEmpty) {
+ if (id.isDefined || id8.isDefined)
+ scold("Node with given ID cannot be found.").^^
+ else if (allLocal)
+ scold("Local nodes cannot be found.").^^
+ else if (allRemote)
+ scold("Remote nodes cannot be found.").^^
+ }
+
+ if (restart) {
+ val excludeNodes = nodes.filter(_.attribute[String](ATTR_RESTART_ENABLED) == "false")
+
+ nodes = nodes.filter(_.attribute[String](ATTR_RESTART_ENABLED) == "true")
- try
// In case of the restart - check that target node supports it.
- if (restart && node != null && node.attribute[String](ATTR_RESTART_ENABLED) != "true")
- scold("Node doesn't support restart: " + nid8(node)).^^
- catch {
- case e: IgniteException => scold("Failed to restart the node. " + e.getMessage).^^
+ if (excludeNodes.nonEmpty)
+ scold("Node(s) doesn't support restart: " + excludeNodes.map(nid8).mkString("[", ", ", "]")).^^
+
+ if (nodes.isEmpty)
+ break
}
val op = if (restart) "restart" else "kill"
try
- killOrRestart(if (node == null) ignite.cluster.nodes().map(_.id()) else Collections.singleton(node.id()), restart)
+ killOrRestart(nodes.map(_.id()), restart)
catch {
case _: IgniteException => scold("Failed to " + op + " due to system error.").^^
}
@@ -205,29 +272,31 @@ class VisorKillCommand extends VisorConsoleCommand {
val op = if (restart) "restart" else "kill"
- if (nodes.size == ignite.cluster.nodes().size())
- ask("Are you sure you want to " + op + " ALL nodes? (y/n) [n]: ", "n") match {
- case "y" | "Y" => ask("You are about to " + op + " ALL nodes. " +
- "Are you 100% sure? (y/n) [n]: ", "n") match {
+ if (!batchMode) {
+ if (nodes.size == ignite.cluster.nodes().size())
+ ask("Are you sure you want to " + op + " ALL nodes? (y/n) [n]: ", "n") match {
+ case "y" | "Y" => ask("You are about to " + op + " ALL nodes. " +
+ "Are you 100% sure? (y/n) [n]: ", "n") match {
case "y" | "Y" => ()
case "n" | "N" => break()
case x => nl(); warn("Invalid answer: " + x); break()
}
- case "n" | "N" => break()
- case x => nl(); warn("Invalid answer: " + x); break()
- }
- else if (nodes.size > 1)
- ask("Are you sure you want to " + op + " several nodes? (y/n) [n]: ", "n") match {
- case "y" | "Y" => ()
- case "n" | "N" => break()
- case x => nl(); warn("Invalid answer: " + x); break()
- }
- else
- ask("Are you sure you want to " + op + " this node? (y/n) [n]: ", "n") match {
- case "y" | "Y" => ()
- case "n" | "N" => break()
- case x => nl(); warn("Invalid answer: " + x); break()
- }
+ case "n" | "N" => break()
+ case x => nl(); warn("Invalid answer: " + x); break()
+ }
+ else if (nodes.size > 1)
+ ask("Are you sure you want to " + op + " several nodes? (y/n) [n]: ", "n") match {
+ case "y" | "Y" => ()
+ case "n" | "N" => break()
+ case x => nl(); warn("Invalid answer: " + x); break()
+ }
+ else
+ ask("Are you sure you want to " + op + " " + nid8(nodes.head) + " node? (y/n) [n]: ", "n") match {
+ case "y" | "Y" => ()
+ case "n" | "N" => break()
+ case x => nl(); warn("Invalid answer: " + x); break()
+ }
+ }
if (restart)
ignite.cluster.restartNodes(nodes)
@@ -278,7 +347,7 @@ object VisorKillCommand {
spec = List(
cmd.name,
s"${cmd.name} -in|-ih",
- s"${cmd.name} {-r|-k} {-id8=<node-id8>|-id=<node-id>}"
+ s"${cmd.name} {-r|-k} {-sc} {-al|-ar|-id8=<node-id8>|-id=<node-id>}"
),
args = List(
"-in" -> List(
@@ -293,6 +362,17 @@ object VisorKillCommand {
"choose a host where to kill or restart nodes.",
"Note that either '-in' or '-ih' can be specified."
),
+ "-al" -> List(
+ "Kill (stop) all local nodes.",
+ "Note that either '-al' or '-ar' can be specified."
+ ),
+ "-ar" -> List(
+ "Kill (stop) all remote nodes.",
+ "Note that either '-al' or '-ar' can be specified."
+ ),
+ "-sc" -> List(
+ "Skip kill or restart of client nodes for group nodes command."
+ ),
"-r" -> List(
"Restart node mode.",
"Note that either '-r' or '-k' can be specified.",
@@ -305,8 +385,10 @@ object VisorKillCommand {
),
"-id8=<node-id8>" -> List(
"ID8 of the node to kill or restart.",
- "Note that either '-id8' or '-id' can be specified and " +
- "you can also use '@n0' ... '@nn' variables as shortcut to <node-id8>.",
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'.",
"If no parameters provided - command starts in interactive mode."
),
"-id=<node-id>" -> List(
@@ -322,6 +404,14 @@ object VisorKillCommand {
"Restart node with id8.",
s"${cmd.name} -id8=@n0 -r" ->
"Restart specified node with id8 taken from 'n0' memory variable.",
+ s"${cmd.name} -id8=@nl -r" ->
+ "Restart oldest local node with id8 taken from 'nl' memory variable.",
+ s"${cmd.name} -id8=@nl -k" ->
+ "Kill (stop) oldest remote node with id8 taken from 'nr' memory variable.",
+ s"${cmd.name} -r -ar" ->
+ "Restart all remote nodes.",
+ s"${cmd.name} -k -sc -al" ->
+ "Kill (stop) all local server nodes.",
s"${cmd.name} -k" ->
"Kill (stop) all nodes."
),
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
index 9ba0129..899e495 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
@@ -57,7 +57,11 @@ import scala.util.control.Breaks._
* ====Arguments====
* {{{
* -id8=<node-id8>
- * ID8 of node. Either '-id8' or '-id' can be specified.
+ * ID8 of node.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
* If neither specified - command starts in interactive mode.
* -id=<node-id>
* Full ID of node. Either '-id8' or '-id' can be specified.
@@ -295,8 +299,11 @@ object VisorNodeCommand {
),
args = List(
"-id8=<node-id8>" -> List(
- "Note that either '-id8' or '-id' can be specified and " +
- "you can also use '@n0' ... '@nn' variables as shortcut to <node-id8>.",
+ "ID8 of node.",
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'.",
"If neither specified - command starts in interactive mode."
),
"-id=<node-id>" -> List(
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommand.scala
index ff5cf82..e935256 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommand.scala
@@ -60,7 +60,10 @@ import scala.util.control.Breaks._
* If not specified, PATH and JAVA_HOME will be searched.
* -id8=<node-id8>
* ID8 of node.
- * Either '-id8' or '-id' can be specified.
+ * Note that either '-id8' or '-id' should be specified.
+ * You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.
+ * To specify oldest node on the same host as visor use variable '@nl'.
+ * To specify oldest node on other hosts that are not running visor use variable '@nr'.
* -id=<node-id>
* Full ID of node.
* Either '-id8' or '-id' can be specified.
@@ -260,8 +263,10 @@ object VisorVvmCommand {
),
"-id8=<node-id8>" -> List(
"ID8 of node.",
- "Note that either '-id8' or '-id' can be specified and " +
- "you can also use '@n0' ... '@nn' variables as shortcut to <node-id8>."
+ "Note that either '-id8' or '-id' should be specified.",
+ "You can also use '@n0' ... '@nn' variables as a shortcut for <node-id8>.",
+ "To specify oldest node on the same host as visor use variable '@nl'.",
+ "To specify oldest node on other hosts that are not running visor use variable '@nr'."
),
"-id=<node-id>" -> List(
"Full ID of node.",
http://git-wip-us.apache.org/repos/asf/ignite/blob/4897315b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 7f7d1f9..1e8b634 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -234,6 +234,8 @@ object visor extends VisorTag {
private var reader: ConsoleReader = null
+ var batchMode: Boolean = false
+
def reader(reader: ConsoleReader) {
assert(reader != null)
@@ -661,12 +663,18 @@ object visor extends VisorTag {
}
/**
- * Finds variable by its value.
+ * Finds variables by its value.
*
* @param v Value to find by.
*/
- def mfind(@Nullable v: String): Option[(String, String)] =
- mem find(t => t._2 == v)
+ def mfind(@Nullable v: String) = mem.filter(t => t._2 == v).toSeq
+
+ /**
+ * Finds variable by its value.
+ *
+ * @param v Value to find by.
+ */
+ def mfindHead(@Nullable v: String) = mfind(v).filterNot(entry => Seq("nl", "nr").contains(entry._1)).headOption
/**
* Sets Visor console memory variable. Note that this method '''does not'''
@@ -872,7 +880,7 @@ object visor extends VisorTag {
case _ => Left("'id8' resolves to more than one node (use full 'id' instead): " + id8.get)
}
}
- else if (id.isDefined)
+ else if (id.isDefined) {
try {
val node = Option(ignite.cluster.node(java.util.UUID.fromString(id.get)))
@@ -884,6 +892,7 @@ object visor extends VisorTag {
catch {
case e: IllegalArgumentException => Left("Invalid node 'id': " + id.get)
}
+ }
else
Right(None)
}
@@ -1522,15 +1531,27 @@ object visor extends VisorTag {
setVarIfAbsent(ip.get, "h")
})
+ val onHost = ignite.cluster.forHost(ignite.localNode())
+
+ Option(onHost.forServers().forOldest().node()).foreach(n => msetOpt("nl", nid8(n)))
+ Option(ignite.cluster.forOthers(onHost).forServers.forOldest().node()).foreach(n => msetOpt("nr", nid8(n)))
+
nodeJoinLsnr = new IgnitePredicate[Event]() {
override def apply(e: Event): Boolean = {
e match {
case de: DiscoveryEvent =>
- setVarIfAbsent(nid8(de.eventNode()), "n")
+ val n = nid8(de.eventNode())
+
+ setVarIfAbsent(n, "n")
val node = ignite.cluster.node(de.eventNode().id())
if (node != null) {
+ val alias = if (U.sameMacs(ignite.localNode(), node)) "nl" else "nr"
+
+ if (mgetOpt(alias).isEmpty)
+ msetOpt(alias, n)
+
val ip = sortAddresses(node.addresses).headOption
if (ip.isDefined)
@@ -1551,29 +1572,25 @@ object visor extends VisorTag {
ignite.events().localListen(nodeJoinLsnr, EVT_NODE_JOINED)
- nodeLeftLsnr = new IgnitePredicate[Event]() {
- override def apply(e: Event): Boolean = {
- e match {
- case (de: DiscoveryEvent) =>
- val nv = mfind(nid8(de.eventNode()))
+ val mclear = (node: ClusterNode) => {
+ mfind(nid8(node)).foreach(nv => mem.remove(nv._1))
- if (nv.isDefined)
- mem.remove(nv.get._1)
+ val onHost = ignite.cluster.forHost(ignite.localNode())
- val ip = sortAddresses(de.eventNode().addresses).headOption
+ if (mgetOpt("nl").isEmpty)
+ Option(onHost.forServers().forOldest().node()).foreach(n => msetOpt("nl", nid8(n)))
- if (ip.isDefined) {
- val last = !ignite.cluster.nodes().exists(n =>
- n.addresses.size > 0 && sortAddresses(n.addresses).head == ip.get
- )
+ if (mgetOpt("nr").isEmpty)
+ Option(ignite.cluster.forOthers(onHost).forServers.forOldest().node()).foreach(n => msetOpt("nr", nid8(n)))
- if (last) {
- val hv = mfind(ip.get)
+ if (onHost.nodes().isEmpty)
+ sortAddresses(node.addresses).headOption.foreach((ip) => mfind(ip).foreach(hv => mem.remove(hv._1)))
+ }
- if (hv.isDefined)
- mem.remove(hv.get._1)
- }
- }
+ nodeLeftLsnr = new IgnitePredicate[Event]() {
+ override def apply(e: Event): Boolean = {
+ e match {
+ case (de: DiscoveryEvent) => mclear(de.eventNode())
}
true
@@ -1594,6 +1611,8 @@ object visor extends VisorTag {
close()
}
+ else
+ mclear(de.eventNode())
}
true
@@ -1658,7 +1677,7 @@ object visor extends VisorTag {
val n = ignite.cluster.node(id)
val id8 = nid8(id)
- val v = mfind(id8)
+ val v = mfindHead(id8)
id8 +
(if (v.isDefined) "(@" + v.get._1 + ")" else "") +
@@ -1678,7 +1697,7 @@ object visor extends VisorTag {
assert(isCon)
val id8 = nid8(id)
- val v = mfind(id8)
+ val v = mfindHead(id8)
id8 + (if (v.isDefined) "(@" + v.get._1 + ")" else "")
}
@@ -1846,7 +1865,7 @@ object visor extends VisorTag {
t.render()
- val a = ask("\nChoose node number ('c' to cancel) [c]: ", "c")
+ val a = ask("\nChoose node number ('c' to cancel) [0]: ", "0")
if (a.toLowerCase == "c")
None
@@ -1929,7 +1948,7 @@ object visor extends VisorTag {
t.render()
- val a = ask("\nChoose host number ('c' to cancel) [c]: ", "c")
+ val a = ask("\nChoose host number ('c' to cancel) [0]: ", "0")
if (a.toLowerCase == "c")
None
@@ -2000,6 +2019,9 @@ object visor extends VisorTag {
assert(prompt != null)
assert(dflt != null)
+ if (batchMode)
+ return dflt
+
readLineOpt(prompt, if (passwd) Some('*') else None) match {
case None => dflt
case Some(s) if s.length == 0 => dflt
[24/50] [abbrv] ignite git commit: IGNITE-3446 Visor CMD: improve
usability for batch mode.
Posted by vo...@apache.org.
IGNITE-3446 Visor CMD: improve usability for batch mode.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/71ef6527
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/71ef6527
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/71ef6527
Branch: refs/heads/ignite-2649
Commit: 71ef6527f1b90cf795072174378d9c401714df96
Parents: aedfde6
Author: Andrey Novikov <an...@apache.org>
Authored: Fri Jul 22 18:03:50 2016 +0700
Committer: Andrey Novikov <an...@apache.org>
Committed: Fri Jul 22 18:03:50 2016 +0700
----------------------------------------------------------------------
.../ignite/visor/commands/cache/VisorCacheStopCommand.scala | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/71ef6527/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
index 1b55505..22fb89d 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
@@ -19,7 +19,6 @@ package org.apache.ignite.visor.commands.cache
import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode}
import org.apache.ignite.visor.visor._
-
import org.apache.ignite.internal.visor.cache.VisorCacheStopTask
import org.apache.ignite.internal.visor.util.VisorTaskUtils._
@@ -102,7 +101,9 @@ class VisorCacheStopCommand {
return
}
- ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [n]: ", "n") match {
+ val dflt = if (batchMode) "y" else "n"
+
+ ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [$dflt]: ", dflt) match {
case "y" | "Y" =>
try {
executeRandom(grp, classOf[VisorCacheStopTask], cacheName)
[13/50] [abbrv] ignite git commit: Merge branch 'gridgain-7.5.30'
into ignite-1849
Posted by vo...@apache.org.
Merge branch 'gridgain-7.5.30' into ignite-1849
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6f7df5eb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6f7df5eb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6f7df5eb
Branch: refs/heads/ignite-2649
Commit: 6f7df5ebf77d338f524c4d055fcf21c717f93e1f
Parents: a33dd1c 4897315
Author: Alexander Paschenko <al...@gmail.com>
Authored: Mon Jul 18 13:58:32 2016 +0300
Committer: Alexander Paschenko <al...@gmail.com>
Committed: Mon Jul 18 13:58:32 2016 +0300
----------------------------------------------------------------------
.../examples/IndexingBridgeMethodTest.java | 93 +++++++
.../IgniteExamplesJ8SelfTestSuite.java | 2 +
.../org/apache/ignite/IgniteDataStreamer.java | 52 +++-
.../IgniteDataStreamerTimeoutException.java | 45 +++
.../configuration/CacheConfiguration.java | 3 +
.../processors/cache/GridCacheProcessor.java | 2 +
.../continuous/CacheContinuousQueryManager.java | 4 +-
.../datastreamer/DataStreamerImpl.java | 71 ++++-
.../service/GridServiceProcessor.java | 70 ++++-
.../processors/service/GridServiceProxy.java | 54 ++--
.../ignite/internal/util/IgniteUtils.java | 21 ++
.../OptimizedObjectStreamRegistry.java | 145 +++++-----
...eContinuousQueryMultiNodesFilteringTest.java | 278 +++++++++++++++++++
...dCacheContinuousQueryNodesFilteringTest.java | 168 +++++++++++
.../datastreamer/DataStreamerTimeoutTest.java | 163 +++++++++++
...rviceDeploymentExceptionPropagationTest.java | 80 ++++++
.../OptimizedMarshallerPooledSelfTest.java | 44 +++
.../testsuites/IgniteBinaryBasicTestSuite.java | 2 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../IgniteMarshallerSelfTestSuite.java | 2 +
.../IgniteCacheQuerySelfTestSuite3.java | 4 +
.../ignite/visor/commands/VisorConsole.scala | 5 +-
.../commands/alert/VisorAlertCommand.scala | 2 +-
.../commands/cache/VisorCacheCommand.scala | 40 ++-
.../commands/cache/VisorCacheStopCommand.scala | 2 +-
.../config/VisorConfigurationCommand.scala | 23 +-
.../commands/events/VisorEventsCommand.scala | 29 +-
.../visor/commands/gc/VisorGcCommand.scala | 11 +-
.../visor/commands/kill/VisorKillCommand.scala | 184 ++++++++----
.../visor/commands/node/VisorNodeCommand.scala | 13 +-
.../visor/commands/vvm/VisorVvmCommand.scala | 11 +-
.../scala/org/apache/ignite/visor/visor.scala | 76 +++--
32 files changed, 1470 insertions(+), 231 deletions(-)
----------------------------------------------------------------------
[04/50] [abbrv] ignite git commit: ignite-3392 Added test.
Posted by vo...@apache.org.
ignite-3392 Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a056954b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a056954b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a056954b
Branch: refs/heads/ignite-2649
Commit: a056954bbb179300716961c116b51492889db356
Parents: 762c43d
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jul 13 12:29:33 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jul 13 12:29:33 2016 +0300
----------------------------------------------------------------------
.../processors/service/GridServiceProxy.java | 54 ++++++-------
...rviceDeploymentExceptionPropagationTest.java | 80 ++++++++++++++++++++
2 files changed, 107 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a056954b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
index 25b2915..ba140f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
@@ -169,38 +169,38 @@ class GridServiceProxy<T> implements Serializable {
// If service is deployed locally, then execute locally.
if (node.isLocal()) {
- ServiceContextImpl svcCtx = ctx.service().serviceContext(name);
+ ServiceContextImpl svcCtx = ctx.service().serviceContext(name);
- if (svcCtx != null) {
- Service svc = svcCtx.service();
+ if (svcCtx != null) {
+ Service svc = svcCtx.service();
- if (svc != null)
- return mtd.invoke(svc, args);
+ if (svc != null)
+ return mtd.invoke(svc, args);
+ }
+ }
+ else {
+ // Execute service remotely.
+ return ctx.closure().callAsyncNoFailover(
+ BALANCE,
+ new ServiceProxyCallable(mtd.getName(), name, mtd.getParameterTypes(), args),
+ Collections.singleton(node),
+ false
+ ).get();
}
}
- else {
- // Execute service remotely.
- return ctx.closure().callAsyncNoFailover(
- BALANCE,
- new ServiceProxyCallable(mtd.getName(), name, mtd.getParameterTypes(), args),
- Collections.singleton(node),
- false
- ).get();
+ catch (GridServiceNotFoundException | ClusterTopologyCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Service was not found or topology changed (will retry): " + e.getMessage());
+ }
+ catch (RuntimeException | Error e) {
+ throw e;
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteException(e);
}
- }
- catch (GridServiceNotFoundException | ClusterTopologyCheckedException e) {
- if (log.isDebugEnabled())
- log.debug("Service was not found or topology changed (will retry): " + e.getMessage());
- }
- catch (RuntimeException | Error e) {
- throw e;
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
- }
- catch (Exception e) {
- throw new IgniteException(e);
- }
// If we are here, that means that service was not found
// or topology was changed. In this case, we erase the
http://git-wip-us.apache.org/repos/asf/ignite/blob/a056954b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
new file mode 100644
index 0000000..811594f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.processors.service;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.GridStringLogger;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/** */
+public class GridServiceDeploymentExceptionPropagationTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /** */
+ @SuppressWarnings("unused")
+ public void testExceptionPropagation() throws Exception {
+ try (Ignite srv = startGrid("server")) {
+
+ GridStringLogger log = new GridStringLogger();
+
+ try (Ignite client = startGrid("client", getConfiguration("client").setGridLogger(log).setClientMode(true))) {
+
+ try {
+ client.services().deployClusterSingleton("my-service", new ServiceImpl());
+ }
+ catch (IgniteException e) {
+ assertTrue(log.toString().contains("ServiceImpl init exception"));
+
+ return; // Exception is what we expect.
+ }
+
+ // Fail explicitly if we've managed to get here though we shouldn't have.
+ fail("https://issues.apache.org/jira/browse/IGNITE-3392");
+ }
+ }
+ }
+
+ /**
+ * Simple service implementation throwing an exception on init.
+ * Doesn't even try to do anything useful because what we're testing here is failure.
+ */
+ private static class ServiceImpl implements Service {
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ throw new RuntimeException("ServiceImpl init exception");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+ }
+}
[50/50] [abbrv] ignite git commit: Minors.
Posted by vo...@apache.org.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/acb42031
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/acb42031
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/acb42031
Branch: refs/heads/ignite-2649
Commit: acb4203189d35d2c8bb14ae29b3e1825473d7019
Parents: 739c69d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 17:02:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 17:02:11 2016 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/internal/IgnitionEx.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/acb42031/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 05cbd45..5e55706 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1285,10 +1285,10 @@ public class IgnitionEx {
* @throws IllegalArgumentException Thrown to indicate, that current thread is not an {@link IgniteThread}.
*/
public static IgniteKernal localIgnite() throws IllegalArgumentException {
- String gridName = U.getCurrentIgniteName();
+ String name = U.getCurrentIgniteName();
- if (U.isCurrentIgniteNameSet(gridName))
- return gridx(gridName);
+ if (U.isCurrentIgniteNameSet(name))
+ return gridx(name);
else if (Thread.currentThread() instanceof IgniteThread)
return gridx(((IgniteThread)Thread.currentThread()).getGridName());
else
[34/50] [abbrv] ignite git commit: IGNITE-2649 - Fix NPE.
Posted by vo...@apache.org.
IGNITE-2649 - Fix NPE.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b5a3f9e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b5a3f9e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b5a3f9e3
Branch: refs/heads/ignite-2649
Commit: b5a3f9e3c60483448bb1181952dbb96fc0f432c8
Parents: 087f84f
Author: dkarachentsev <dk...@gridgain.com>
Authored: Thu Aug 4 11:26:00 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Thu Aug 4 11:26:00 2016 +0300
----------------------------------------------------------------------
.../ignite/marshaller/MarshallerUtils.java | 114 ++++--
.../GridBinaryCacheSerializationTest.java | 373 -------------------
.../processors/query/h2/IgniteH2Indexing.java | 14 +-
3 files changed, 86 insertions(+), 415 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5a3f9e3/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index cfb45ad..629ce6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -30,7 +30,7 @@ import java.nio.ByteBuffer;
/**
* Util class that sets and discards thread local
- * ignite configuration in {@link IgnitionEx} class.
+ * ignite grid name in {@link IgnitionEx} class.
*/
public final class MarshallerUtils {
/**
@@ -40,12 +40,13 @@ public final class MarshallerUtils {
}
/**
+ * Marshal object to stream and set grid name thread local.
*
- * @param marshaller marshaller.
- * @param obj object.
- * @param out output stream.
+ * @param marshaller Marshaller.
+ * @param obj Object to marshal.
+ * @param out Output stream.
* @param gridName Grid name.
- * @throws IgniteCheckedException
+ * @throws IgniteCheckedException If fail.
*/
public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
final OutputStream out, final String gridName) throws IgniteCheckedException {
@@ -64,12 +65,13 @@ public final class MarshallerUtils {
}
/**
+ * Marshal object and set grid name thread local.
*
- * @param marshaller marshaller.
- * @param obj object.
+ * @param marshaller Marshaller.
+ * @param obj Object to marshal.
* @param gridName Grid name.
- * @return serialized.
- * @throws IgniteCheckedException
+ * @return Binary data.
+ * @throws IgniteCheckedException If fail.
*/
public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
final String gridName) throws IgniteCheckedException {
@@ -88,13 +90,28 @@ public final class MarshallerUtils {
}
/**
+ * Marshal object.
+ * <p>Use only when grid name is not available, f.e. in tests.</p>
+ *
+ * @param marshaller Marshaller.
+ * @param obj Object to marshal.
+ * @return Binary data.
+ * @throws IgniteCheckedException If fail.
+ */
+ public static byte[] marshal(final Marshaller marshaller, final @Nullable Object obj) throws IgniteCheckedException {
+ // This method used to keep marshaller usages in one place.
+ return marshaller.marshal(obj);
+ }
+
+ /**
+ * Unmarshal object from stream and set grid name thread local.
*
- * @param marshaller marshaller.
- * @param in input stream.
- * @param clsLdr class loader.
+ * @param marshaller Marshaller.
+ * @param in Input stream.
+ * @param clsLdr Class loader.
* @param gridName Grid name.
- * @param <T> target type.
- * @return deserialized object.
+ * @param <T> Target type.
+ * @return Deserialized object.
* @throws IgniteCheckedException
*/
public static <T> T unmarshal(final Marshaller marshaller, InputStream in, @Nullable ClassLoader clsLdr,
@@ -114,14 +131,32 @@ public final class MarshallerUtils {
}
/**
+ * Unmarshal object.
+ * <p>Use only when grid name is not available, f.e. in tests.</p>
+ *
+ * @param marshaller Marshaller.
+ * @param arr Bianry data.
+ * @param clsLdr Class loader.
+ * @param <T> Target type.
+ * @return Unmarshalled object.
+ * @throws IgniteCheckedException If fail.
+ */
+ public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr)
+ throws IgniteCheckedException {
+ // This method used to keep marshaller usages in one place.
+ return marshaller.unmarshal(arr, clsLdr);
+ }
+
+ /**
+ * Unmarshal object and set grid name thread local.
*
- * @param marshaller marshaller.
- * @param arr byte array.
- * @param clsLdr class loader.
+ * @param marshaller Marshaller.
+ * @param arr Bianry data.
+ * @param clsLdr Class loader.
* @param gridName Grid name.
- * @param <T> target type
- * @return deserialized object.
- * @throws IgniteCheckedException
+ * @param <T> Target type
+ * @return Deserialized object.
+ * @throws IgniteCheckedException If fail.
*/
public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
@@ -140,14 +175,15 @@ public final class MarshallerUtils {
}
/**
+ * Marshal and unmarshal object.
*
- * @param marshaller marshaller.
- * @param obj object
- * @param clsLdr class loader.
+ * @param marshaller Marshaller.
+ * @param obj Object to clone.
+ * @param clsLdr Class loader.
* @param gridName Grid name.
- * @param <T> target type.
- * @return deserialized value.
- * @throws IgniteCheckedException
+ * @param <T> Target type.
+ * @return Deserialized value.
+ * @throws IgniteCheckedException If fail.
*/
public static <T> T clone(final Marshaller marshaller, T obj, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
@@ -166,13 +202,14 @@ public final class MarshallerUtils {
}
/**
+ * Marshal object and set grid name thread local.
*
- * @param gridMarshaller grid marshaller.
- * @param obj object.
- * @param off offset.
- * @param gridName ignite config.
- * @return serialized data.
- * @throws IOException
+ * @param gridMarshaller Grid marshaller.
+ * @param obj Object to marshal.
+ * @param off Offset.
+ * @param gridName Grid name.
+ * @return Serialized data.
+ * @throws IOException If fail.
*/
public static ByteBuffer marshal(GridClientMarshaller gridMarshaller, Object obj, int off,
String gridName) throws IOException {
@@ -191,13 +228,14 @@ public final class MarshallerUtils {
}
/**
+ * Unmarshal object and set grid name thread local.
*
- * @param gridMarshaller grid marshaller.
- * @param bytes byte array.
- * @param gridName ignite config.
- * @param <T> target type.
- * @return deserialized value.
- * @throws IOException
+ * @param gridMarshaller Grid marshaller.
+ * @param bytes Binary data.
+ * @param gridName Grid name.
+ * @param <T> Target type.
+ * @return Deserialized value.
+ * @throws IOException If fail.
*/
public static <T> T unmarshal(GridClientMarshaller gridMarshaller, byte[] bytes,
String gridName) throws IOException {
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5a3f9e3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
deleted file mode 100644
index 31a7258..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * 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.processors.cache.binary;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.concurrent.Callable;
-
-/**
- *
- */
-public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
- /** */
- private static final String CACHE_NAME = "cache_name";
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
- final IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- if (gridName != null && gridName.startsWith("binary"))
- cfg.setMarshaller(new BinaryMarshaller());
-
- return cfg;
- }
-
- /**
- * Test that calling {@link Ignition#localIgnite()}
- * is safe for binary marshaller.
- *
- * @throws Exception
- */
- public void testPutGetSimple() throws Exception {
- testPutGet(new SimpleTestObject("one"), null);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPutGetSerializable() throws Exception {
- testPutGet(new SerializableTestObject("test"), null);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPutGetExternalizable() throws Exception {
- testPutGet(new ExternalizableTestObject("test"), null);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPutGetBinarylizable() throws Exception {
- testPutGet(new BinarylizableTestObject("test"), "binaryIgnite");
- }
-
- /**
- * @throws Exception If failed.
- */
- private void testPutGet(final TestObject obj, final String gridName) throws Exception {
- // Run async to emulate user thread.
- GridTestUtils.runAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- try (final Ignite ignite = startGrid(gridName)) {
- final IgniteCache<Integer, TestObject> cache = ignite.getOrCreateCache(CACHE_NAME);
-
- assertNull(obj.ignite());
-
- cache.put(1, obj);
-
- assertNotNull(obj.ignite());
-
- final TestObject loadedObj = cache.get(1);
-
- assertNotNull(loadedObj.ignite());
-
- assertEquals(obj, loadedObj);
- }
-
- return null;
- }
- }).get();
- }
-
- /**
- *
- */
- private interface TestObject {
- /**
- * @return Ignite instance.
- */
- Ignite ignite();
- }
-
- /**
- * Test object.
- */
- private static class SimpleTestObject implements TestObject {
- /** */
- private final String val;
-
- /** */
- private transient Ignite ignite;
-
- /** */
- private SimpleTestObject(final String val) {
- this.val = val;
- }
-
- /**
- * @return Object.
- */
- @SuppressWarnings("unused")
- private Object readResolve() {
- ignite = Ignition.localIgnite();
-
- return this;
- }
-
- /**
- * @return Object.
- */
- @SuppressWarnings("unused")
- private Object writeReplace() {
- ignite = Ignition.localIgnite();
-
- return this;
- }
-
- /** */
- @Override public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final SimpleTestObject simpleTestObj = (SimpleTestObject) o;
-
- return val != null ? val.equals(simpleTestObj.val) : simpleTestObj.val == null;
-
- }
-
- /** */
- @Override public int hashCode() {
- return val != null ? val.hashCode() : 0;
- }
-
- /** {@inheritDoc} */
- @Override public Ignite ignite() {
- return ignite;
- }
- }
-
- /**
- *
- */
- private static class SerializableTestObject implements Serializable, TestObject {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private String val;
-
- /** */
- private transient Ignite ignite;
-
- /**
- *
- */
- public SerializableTestObject() {
- }
-
- /**
- * @param val Value
- */
- public SerializableTestObject(final String val) {
- this.val = val;
- }
-
- /**
- * @param out Object output.
- * @throws IOException If fail.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- U.writeString(out, val);
-
- ignite = Ignition.localIgnite();
- }
-
- /**
- * @param in Object input.
- * @throws IOException If fail.
- */
- private void readObject(ObjectInputStream in) throws IOException {
- val = U.readString(in);
-
- ignite = Ignition.localIgnite();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final SerializableTestObject that = (SerializableTestObject) o;
-
- return val != null ? val.equals(that.val) : that.val == null;
-
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return val != null ? val.hashCode() : 0;
- }
-
- /** {@inheritDoc} */
- @Override public Ignite ignite() {
- return ignite;
- }
- }
-
- /**
- *
- */
- private static class ExternalizableTestObject implements Externalizable, TestObject {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private String val;
-
- /** */
- private transient Ignite ignite;
-
- /**
- *
- */
- public ExternalizableTestObject() {
- }
-
- /**
- * @param val Value.
- */
- public ExternalizableTestObject(final String val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(final ObjectOutput out) throws IOException {
- U.writeString(out, val);
-
- ignite = Ignition.localIgnite();
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
- val = U.readString(in);
-
- ignite = Ignition.localIgnite();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final ExternalizableTestObject that = (ExternalizableTestObject) o;
-
- return val != null ? val.equals(that.val) : that.val == null;
-
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return val != null ? val.hashCode() : 0;
- }
-
- /** {@inheritDoc} */
- @Override public Ignite ignite() {
- return ignite;
- }
- }
-
- /**
- *
- */
- private static class BinarylizableTestObject implements Binarylizable, TestObject {
- /** */
- private String val;
-
- /** */
- private transient Ignite ignite;
-
- /**
- *
- */
- public BinarylizableTestObject() {
- }
-
- /**
- * @param val Value.
- */
- public BinarylizableTestObject(final String val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
- writer.rawWriter().writeString(val);
-
- ignite = Ignition.localIgnite();
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
- val = reader.rawReader().readString();
-
- ignite = Ignition.localIgnite();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final BinarylizableTestObject that = (BinarylizableTestObject) o;
-
- return val != null ? val.equals(that.val) : that.val == null;
-
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return val != null ? val.hashCode() : 0;
- }
-
- /** {@inheritDoc} */
- @Override public Ignite ignite() {
- return ignite;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5a3f9e3/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index a00795f..c3700ab 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1536,13 +1536,19 @@ public class IgniteH2Indexing implements GridQueryIndexing {
protected JavaObjectSerializer h2Serializer() {
return new JavaObjectSerializer() {
@Override public byte[] serialize(Object obj) throws Exception {
- return MarshallerUtils.marshal(marshaller, obj, ctx.gridName());
+ if (ctx != null)
+ return MarshallerUtils.marshal(marshaller, obj, ctx.gridName());
+ else
+ return MarshallerUtils.marshal(marshaller, obj);
}
@Override public Object deserialize(byte[] bytes) throws Exception {
- ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
-
- return MarshallerUtils.unmarshal(marshaller, bytes, clsLdr, ctx.gridName());
+ if (ctx != null) {
+ return MarshallerUtils.unmarshal(marshaller, bytes,
+ U.resolveClassLoader(ctx.config()), ctx.gridName());
+ }
+ else
+ return MarshallerUtils.unmarshal(marshaller, bytes, null);
}
};
}
[43/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
Cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28c4d930
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28c4d930
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28c4d930
Branch: refs/heads/ignite-2649
Commit: 28c4d93012ef46a740f5d71d237d9089f59e1655
Parents: acf0705
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:23:47 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:23:47 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/marshaller/MarshallerUtils.java | 17 -----------------
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
2 files changed, 1 insertion(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28c4d930/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index c1dc373..5651766 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -132,23 +132,6 @@ public final class MarshallerUtils {
}
/**
- * Unmarshal object.
- * <p>Use only when grid name is not available, f.e. in tests.</p>
- *
- * @param marshaller Marshaller.
- * @param arr Bianry data.
- * @param clsLdr Class loader.
- * @param <T> Target type.
- * @return Unmarshalled object.
- * @throws IgniteCheckedException If fail.
- */
- public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr)
- throws IgniteCheckedException {
- // This method used to keep marshaller usages in one place.
- return marshaller.unmarshal(arr, clsLdr);
- }
-
- /**
* Unmarshal object and set grid name thread local.
*
* @param marshaller Marshaller.
http://git-wip-us.apache.org/repos/asf/ignite/blob/28c4d930/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 0b4e086..a3d3249 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1548,7 +1548,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
U.resolveClassLoader(ctx.config()), ctx.gridName());
}
else
- return MarshallerUtils.unmarshal(marshaller, bytes, null);
+ return marshaller.unmarshal(bytes, null);
}
};
}
[15/50] [abbrv] ignite git commit: IGNITE-3455: Entry placed on C++
side is not found on Java side
Posted by vo...@apache.org.
IGNITE-3455: Entry placed on C++ side is not found on Java side
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/84e83c96
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/84e83c96
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/84e83c96
Branch: refs/heads/ignite-2649
Commit: 84e83c96127a06f9d6b2ccc68d23db8f6dc089b1
Parents: 4897315
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Jul 18 15:21:46 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Jul 18 15:21:46 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 6 ++-
.../binary/BinaryMarshallerSelfTest.java | 41 ++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/84e83c96/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 27e9440..d78c126 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -1127,13 +1127,17 @@ public class BinaryContext {
mapper,
serializer,
true,
- false
+ true
);
fieldsMeta = desc.fieldsMeta();
schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
descByCls.put(cls, desc);
+
+ // Registering in order to support the interoperability between Java, C++ and .Net.
+ // https://issues.apache.org/jira/browse/IGNITE-3455
+ predefinedTypes.put(id, desc);
}
metaHnd.addMeta(id, new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName, schemas, isEnum).wrap(this));
http://git-wip-us.apache.org/repos/asf/ignite/blob/84e83c96/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index a504650..b3058de 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -1798,6 +1798,47 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testCustomTypeRegistration() throws Exception {
+ BinaryTypeConfiguration customType = new BinaryTypeConfiguration(Value.class.getName());
+
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(customType));
+
+ BinaryContext ctx = binaryContext(marsh);
+
+ int typeId = ctx.typeId(Value.class.getName());
+
+ BinaryClassDescriptor descriptor = ctx.descriptorForTypeId(true, typeId, null, false);
+
+ assertEquals(Value.class, descriptor.describedClass());
+ assertEquals(true, descriptor.registered());
+ assertEquals(true, descriptor.userType());
+
+ // Custom explicit types must be registered in 'predefinedTypes' in order not to break the interoperability.
+ Field field = ctx.getClass().getDeclaredField("predefinedTypes");
+
+ field.setAccessible(true);
+
+ Map<Integer, BinaryClassDescriptor> map = (Map<Integer, BinaryClassDescriptor>)field.get(ctx);
+
+ assertTrue(map.size() > 0);
+
+ assertNotNull(map.get(typeId));
+
+ // Custom explicit types must NOT be registered in 'predefinedTypeNames'.
+ field = ctx.getClass().getDeclaredField("predefinedTypeNames");
+
+ field.setAccessible(true);
+
+ Map<String, Integer> map2 = (Map<String, Integer>)field.get(ctx);
+
+ assertTrue(map2.size() > 0);
+
+ assertNull(map2.get(ctx.userTypeName(Value.class.getName())));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testFieldIdMapping() throws Exception {
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
[35/50] [abbrv] ignite git commit: IGNITE-2649 - Fix Assertion.
Posted by vo...@apache.org.
IGNITE-2649 - Fix Assertion.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d25e321d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d25e321d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d25e321d
Branch: refs/heads/ignite-2649
Commit: d25e321d204031562c23fb7835c3de968940b1ca
Parents: b5a3f9e
Author: dkarachentsev <dk...@gridgain.com>
Authored: Thu Aug 4 11:37:16 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Thu Aug 4 11:37:16 2016 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/cache/websession/WebSessionV2.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d25e321d/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index fd420d9..74e2be0 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -102,7 +102,6 @@ class WebSessionV2 implements HttpSession {
assert marshaller != null;
assert ctx != null;
assert ses != null || entity != null;
- assert gridName != null;
this.marshaller = marshaller;
this.ctx = ctx;
[02/50] [abbrv] ignite git commit: ignite-3239 Fix of
java.io.IOException: Resource deadlock avoided
Posted by vo...@apache.org.
ignite-3239 Fix of java.io.IOException: Resource deadlock avoided
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/762c43d6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/762c43d6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/762c43d6
Branch: refs/heads/ignite-2649
Commit: 762c43d67c2e500de1be2ae030a55658ad291574
Parents: 7aa609a
Author: agura <ag...@gridgain.com>
Authored: Thu Jun 16 13:03:03 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Jul 12 17:15:34 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/MarshallerContextImpl.java | 29 ++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/762c43d6/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index b4c9607..504ea6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -25,9 +25,11 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.locks.Lock;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryListenerException;
@@ -201,7 +203,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
File file = new File(workDir, fileName);
try (FileInputStream in = new FileInputStream(file)) {
- FileLock fileLock = in.getChannel().lock(0L, Long.MAX_VALUE, true);
+ FileLock fileLock = fileLock(in.getChannel(), true);
assert fileLock != null : fileName;
@@ -235,6 +237,26 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
}
/**
+ * @param ch File channel.
+ * @param shared Shared.
+ */
+ private static FileLock fileLock(
+ FileChannel ch,
+ boolean shared
+ ) throws IOException, IgniteInterruptedCheckedException {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (true) {
+ FileLock fileLock = ch.tryLock(0L, Long.MAX_VALUE, shared);
+
+ if (fileLock == null)
+ U.sleep(rnd.nextLong(50));
+ else
+ return fileLock;
+ }
+ }
+
+ /**
*/
private static class ContinuousQueryListener implements CacheEntryUpdatedListener<Integer, String> {
/** */
@@ -270,7 +292,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
File file = new File(workDir, fileName);
try (FileOutputStream out = new FileOutputStream(file)) {
- FileLock fileLock = out.getChannel().lock(0L, Long.MAX_VALUE, false);
+ FileLock fileLock = fileLock(out.getChannel(), false);
assert fileLock != null : fileName;
@@ -284,6 +306,9 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
U.error(log, "Failed to write class name to file [id=" + evt.getKey() +
", clsName=" + evt.getValue() + ", file=" + file.getAbsolutePath() + ']', e);
}
+ catch (IgniteInterruptedCheckedException e) {
+ U.error(log, "Interrupted while waiting for acquiring file lock: " + file, e);
+ }
}
finally {
lock.unlock();
[07/50] [abbrv] ignite git commit: IGNITE-3055: IgniteDataStreamer
can't be timed out
Posted by vo...@apache.org.
IGNITE-3055: IgniteDataStreamer can't be timed out
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10224dfe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10224dfe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10224dfe
Branch: refs/heads/ignite-2649
Commit: 10224dfee22b497bc671f878028881f99465a4c8
Parents: 06b24a9
Author: Vladislav Pyatkov <vl...@gmail.com>
Authored: Wed Jul 13 15:24:53 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Jul 13 15:24:53 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteDataStreamer.java | 52 +++++-
.../IgniteDataStreamerTimeoutException.java | 45 +++++
.../datastreamer/DataStreamerImpl.java | 71 ++++++--
.../ignite/internal/util/IgniteUtils.java | 21 +++
.../datastreamer/DataStreamerTimeoutTest.java | 163 +++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
6 files changed, 335 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
index 20d0057..887443f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
@@ -96,6 +96,9 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
/** Default per node buffer size. */
public static final int DFLT_PER_NODE_BUFFER_SIZE = 1024;
+ /** Default timeout for streamer's operations. */
+ public static final long DFLT_UNLIMIT_TIMEOUT = -1;
+
/**
* Name of cache to stream data to.
*
@@ -198,6 +201,29 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
public void perNodeParallelOperations(int parallelOps);
/**
+ * Sets the timeout that is used in the following cases:
+ * <ul>
+ * <li>any data addition method can be blocked when all per node parallel operations are exhausted.
+ * The timeout defines the max time you will be blocked waiting for a permit to add a chunk of data
+ * into the streamer;</li>
+ * <li>Total timeout time for {@link #flush()} operation;</li>
+ * <li>Total timeout time for {@link #close()} operation.</li>
+ * </ul>
+ * By default the timeout is disabled.
+ *
+ * @param timeout Timeout in milliseconds.
+ * @throws IllegalArgumentException If {@param timeout} is zero or less than {@code -1}.
+ */
+ public void timeout(long timeout);
+
+ /**
+ * Gets timeout set by {@link #timeout(long)}.
+ *
+ * @return Timeout in milliseconds.
+ */
+ public long timeout();
+
+ /**
* Gets automatic flush frequency. Essentially, this is the time after which the
* streamer will make an attempt to submit all data added so far to remote nodes.
* Note that there is no guarantee that data will be delivered after this concrete
@@ -287,10 +313,11 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @throws IgniteInterruptedException If thread has been interrupted.
* @throws IllegalStateException If grid has been concurrently stopped or
* {@link #close(boolean)} has already been called on streamer.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
* @see #allowOverwrite()
*/
public IgniteFuture<?> addData(K key, @Nullable V val) throws CacheException, IgniteInterruptedException,
- IllegalStateException;
+ IllegalStateException, IgniteDataStreamerTimeoutException;
/**
* Adds data for streaming on remote node. This method can be called from multiple
@@ -310,10 +337,11 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @throws IgniteInterruptedException If thread has been interrupted.
* @throws IllegalStateException If grid has been concurrently stopped or
* {@link #close(boolean)} has already been called on streamer.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
* @see #allowOverwrite()
*/
public IgniteFuture<?> addData(Map.Entry<K, V> entry) throws CacheException, IgniteInterruptedException,
- IllegalStateException;
+ IllegalStateException, IgniteDataStreamerTimeoutException;
/**
* Adds data for streaming on remote node. This method can be called from multiple
@@ -330,10 +358,12 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @param entries Collection of entries to be streamed.
* @throws IllegalStateException If grid has been concurrently stopped or
* {@link #close(boolean)} has already been called on streamer.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
* @return Future for this stream operation.
* @see #allowOverwrite()
*/
- public IgniteFuture<?> addData(Collection<? extends Map.Entry<K, V>> entries) throws IllegalStateException;
+ public IgniteFuture<?> addData(Collection<? extends Map.Entry<K, V>> entries) throws IllegalStateException,
+ IgniteDataStreamerTimeoutException;
/**
* Adds data for streaming on remote node. This method can be called from multiple
@@ -350,10 +380,12 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @param entries Map to be streamed.
* @throws IllegalStateException If grid has been concurrently stopped or
* {@link #close(boolean)} has already been called on streamer.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
* @return Future for this stream operation.
* @see #allowOverwrite()
*/
- public IgniteFuture<?> addData(Map<K, V> entries) throws IllegalStateException;
+ public IgniteFuture<?> addData(Map<K, V> entries) throws IllegalStateException,
+ IgniteDataStreamerTimeoutException;
/**
* Streams any remaining data, but doesn't close the streamer. Data can be still added after
@@ -368,9 +400,11 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @throws IgniteInterruptedException If thread has been interrupted.
* @throws IllegalStateException If grid has been concurrently stopped or
* {@link #close(boolean)} has already been called on streamer.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
* @see #tryFlush()
*/
- public void flush() throws CacheException, IgniteInterruptedException, IllegalStateException;
+ public void flush() throws CacheException, IgniteInterruptedException, IllegalStateException,
+ IgniteDataStreamerTimeoutException;
/**
* Makes an attempt to stream remaining data. This method is mostly similar to {@link #flush},
@@ -390,8 +424,10 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @param cancel {@code True} to cancel ongoing streaming operations.
* @throws CacheException If failed to map key to node.
* @throws IgniteInterruptedException If thread has been interrupted.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded, only if {@param cancel} is {@code false}.
*/
- public void close(boolean cancel) throws CacheException, IgniteInterruptedException;
+ public void close(boolean cancel) throws CacheException, IgniteInterruptedException,
+ IgniteDataStreamerTimeoutException;
/**
* Closes data streamer. This method is identical to calling {@link #close(boolean) close(false)} method.
@@ -401,7 +437,9 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
*
* @throws CacheException If failed to close data streamer.
* @throws IgniteInterruptedException If thread has been interrupted.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded.
*/
- @Override public void close() throws CacheException, IgniteInterruptedException;
+ @Override public void close() throws CacheException, IgniteInterruptedException,
+ IgniteDataStreamerTimeoutException;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamerTimeoutException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamerTimeoutException.java b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamerTimeoutException.java
new file mode 100644
index 0000000..c6c7367
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamerTimeoutException.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ * Exception is thrown when timeout of some {@link IgniteDataStreamer} operations occurs.
+ */
+public class IgniteDataStreamerTimeoutException extends IgniteException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Creates new timeout exception with given error message.
+ *
+ * @param msg Error message.
+ */
+ public IgniteDataStreamerTimeoutException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates new timeout exception with given error message and optional nested exception.
+ *
+ * @param msg Error message.
+ * @param cause Optional nested exception (can be {@code null}).
+ */
+ public IgniteDataStreamerTimeoutException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 9dc6a7f..21df559 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -46,6 +46,7 @@ import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteDataStreamerTimeoutException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -53,6 +54,7 @@ import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
@@ -147,6 +149,9 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
private int parallelOps = DFLT_MAX_PARALLEL_OPS;
/** */
+ private long timeout = DFLT_UNLIMIT_TIMEOUT;
+
+ /** */
private long autoFlushFreq;
/** Mapping. */
@@ -453,6 +458,19 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
}
/** {@inheritDoc} */
+ @Override public void timeout(long timeout) {
+ if (timeout < -1 || timeout == 0)
+ throw new IllegalArgumentException();
+
+ this.timeout = timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout() {
+ return this.timeout;
+ }
+
+ /** {@inheritDoc} */
@Override public long autoFlushFrequency() {
return autoFlushFreq;
}
@@ -517,6 +535,9 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
return new IgniteCacheFutureImpl<>(resFut);
}
+ catch (IgniteDataStreamerTimeoutException e) {
+ throw e;
+ }
catch (IgniteException e) {
return new IgniteFinishedFutureImpl<>(e);
}
@@ -572,7 +593,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
catch (Throwable e) {
resFut.onDone(e);
- if (e instanceof Error)
+ if (e instanceof Error || e instanceof IgniteDataStreamerTimeoutException)
throw e;
return new IgniteFinishedFutureImpl<>(e);
@@ -854,9 +875,20 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
boolean err = false;
+ long startTimeMillis = U.currentTimeMillis();
+
for (IgniteInternalFuture fut = q.poll(); fut != null; fut = q.poll()) {
try {
- fut.get();
+ if (timeout == DFLT_UNLIMIT_TIMEOUT)
+ fut.get();
+ else {
+ long timeRemain = timeout - U.currentTimeMillis() + startTimeMillis;
+
+ if (timeRemain <= 0)
+ throw new IgniteDataStreamerTimeoutException("Data streamer exceeded timeout on flush.");
+
+ fut.get(timeRemain);
+ }
}
catch (IgniteClientDisconnectedCheckedException e) {
if (log.isDebugEnabled())
@@ -864,6 +896,12 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
throw CU.convertToCacheException(e);
}
+ catch (IgniteFutureTimeoutCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to flush buffer: " + e);
+
+ throw new IgniteDataStreamerTimeoutException("Data streamer exceeded timeout on flush.", e);
+ }
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to flush buffer: " + e);
@@ -976,8 +1014,6 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
if (log.isDebugEnabled())
log.debug("Closing data streamer [ldr=" + this + ", cancel=" + cancel + ']');
- IgniteCheckedException e = null;
-
try {
// Assuming that no methods are called on this loader after this method is called.
if (cancel) {
@@ -993,14 +1029,12 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
ctx.io().removeMessageListener(topic);
}
- catch (IgniteCheckedException e0) {
- e = e0;
+ catch (IgniteCheckedException | IgniteDataStreamerTimeoutException e) {
+ fut.onDone(e);
+ throw e;
}
- fut.onDone(null, e != null ? e : err);
-
- if (e != null)
- throw e;
+ fut.onDone(err);
}
/**
@@ -1242,7 +1276,15 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
* @throws IgniteInterruptedCheckedException If thread has been interrupted.
*/
private void incrementActiveTasks() throws IgniteInterruptedCheckedException {
- U.acquire(sem);
+ if (timeout == DFLT_UNLIMIT_TIMEOUT)
+ U.acquire(sem);
+ else
+ if (!U.tryAcquire(sem, timeout, TimeUnit.MILLISECONDS)) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to add parallel operation.");
+
+ throw new IgniteDataStreamerTimeoutException("Data streamer exceeded timeout when starts parallel operation.");
+ }
}
/**
@@ -1268,7 +1310,12 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
assert !entries.isEmpty();
assert curFut != null;
- incrementActiveTasks();
+ try {
+ incrementActiveTasks();
+ } catch (IgniteDataStreamerTimeoutException e) {
+ curFut.onDone(e);
+ throw e;
+ }
IgniteInternalFuture<Object> fut;
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index fa18923..08c9219 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -7447,6 +7447,27 @@ public abstract class IgniteUtils {
}
/**
+ * Tries to acquire a permit from provided semaphore during {@code timeout}.
+ *
+ * @param sem Semaphore.
+ * @param timeout The maximum time to wait.
+ * @param unit The unit of the {@code time} argument.
+ * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException Wrapped {@link InterruptedException}.
+ * @return {@code True} if acquires a permit, {@code false} another.
+ */
+ public static boolean tryAcquire(Semaphore sem, long timeout, TimeUnit unit)
+ throws IgniteInterruptedCheckedException {
+ try {
+ return sem.tryAcquire(timeout, unit);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+
+ throw new IgniteInterruptedCheckedException(e);
+ }
+ }
+
+ /**
* Gets cache attributes for the node.
*
* @param n Node to get cache attributes for.
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
new file mode 100644
index 0000000..4e981b7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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.processors.datastreamer;
+
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteDataStreamerTimeoutException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.stream.StreamReceiver;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Test timeout for Data streamer.
+ */
+public class DataStreamerTimeoutTest extends GridCommonAbstractTest {
+
+ /** Cache name. */
+ public static final String CACHE_NAME = "cacheName";
+
+ /** Timeout. */
+ public static final int TIMEOUT = 1_000;
+
+ /** Amount of entries. */
+ public static final int ENTRY_AMOUNT = 100;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setCacheConfiguration(cacheConfiguration());
+
+ return cfg;
+ }
+
+ /**
+ * Gets cache configuration.
+ *
+ * @return Cache configuration.
+ */
+ private CacheConfiguration cacheConfiguration() {
+ CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+ cacheCfg.setCacheMode(PARTITIONED);
+ cacheCfg.setBackups(1);
+ cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+ cacheCfg.setName(CACHE_NAME);
+
+ return cacheCfg;
+ }
+
+ /**
+ * Test timeout on {@code DataStreamer.addData()} method
+ * @throws Exception If fail.
+ */
+ public void testTimeoutOnCloseMethod() throws Exception {
+ Ignite ignite = startGrid(1);
+
+ boolean thrown = false;
+
+ try (IgniteDataStreamer ldr = ignite.dataStreamer(CACHE_NAME)) {
+ ldr.timeout(TIMEOUT);
+ ldr.receiver(new TestDataReceiver());
+ ldr.perNodeBufferSize(ENTRY_AMOUNT);
+
+ for (int i=0; i < ENTRY_AMOUNT; i++)
+ ldr.addData(i, i);
+
+ }
+ catch (IgniteDataStreamerTimeoutException e) {
+ assertEquals(e.getMessage(), "Data streamer exceeded timeout on flush.");
+ thrown = true;
+ }
+ finally {
+ stopAllGrids();
+ }
+
+ assertTrue(thrown);
+ }
+
+ /**
+ * Test timeout on {@code DataStreamer.close()} method
+ * @throws Exception If fail.
+ */
+ public void testTimeoutOnAddDataMethod() throws Exception {
+ Ignite ignite = startGrid(1);
+
+ boolean thrown = false;
+
+ IgniteDataStreamer ldr = ignite.dataStreamer(CACHE_NAME);
+
+ try {
+ ldr.timeout(TIMEOUT);
+ ldr.receiver(new TestDataReceiver());
+ ldr.perNodeBufferSize(ENTRY_AMOUNT/2);
+ ldr.perNodeParallelOperations(1);
+
+ try {
+ for (int i=0; i < ENTRY_AMOUNT; i++)
+ ldr.addData(i, i);
+ }
+ catch (IgniteDataStreamerTimeoutException e) {
+ assertEquals(e.getMessage(), "Data streamer exceeded timeout when starts parallel operation.");
+
+ thrown = true;
+ }
+
+ }
+ finally {
+ if (thrown)
+ ldr.close(true);
+
+ stopAllGrids();
+ }
+
+ assertTrue(thrown);
+ }
+
+ /**
+ * Test receiver for timeout expiration emulation.
+ */
+ private static class TestDataReceiver implements StreamReceiver {
+
+ /** Is first. */
+ boolean isFirst = true;
+
+ /** {@inheritDoc} */
+ @Override public void receive(IgniteCache cache, Collection collection) throws IgniteException {
+ try {
+ if (isFirst)
+ U.sleep(2 * TIMEOUT);
+
+ isFirst = false;
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new IgniteException(e);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10224dfe/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 33aae9a..0b9345d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -138,6 +138,7 @@ import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSel
import org.apache.ignite.internal.processors.datastreamer.DataStreamerImplSelfTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerMultiThreadedSelfTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerMultinodeCreateCacheTest;
+import org.apache.ignite.internal.processors.datastreamer.DataStreamerTimeoutTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerUpdateAfterLoadTest;
import org.apache.ignite.testframework.GridTestUtils;
@@ -244,6 +245,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(DataStreamerMultiThreadedSelfTest.class);
suite.addTestSuite(DataStreamerMultinodeCreateCacheTest.class);
suite.addTestSuite(DataStreamerImplSelfTest.class);
+ suite.addTestSuite(DataStreamerTimeoutTest.class);
GridTestUtils.addTestIfNeeded(suite, GridCacheEntryMemorySizeSelfTest.class, ignoredTests);
suite.addTestSuite(GridCacheClearAllSelfTest.class);
suite.addTestSuite(GridCacheObjectToStringSelfTest.class);
[28/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 0c3cf0e..b8ab83c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -71,6 +71,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.jetbrains.annotations.Nullable;
import org.jsr166.LongAdder8;
@@ -913,7 +914,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
GridTaskSessionRequest req = new GridTaskSessionRequest(
ses.getId(),
null,
- loc ? null : marsh.marshal(attrs),
+ loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()),
attrs);
// Make sure to go through IO manager always, since order
@@ -1029,8 +1030,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
Map<?, ?> attrs = loc ? msg.getAttributes() :
- marsh.<Map<?, ?>>unmarshal(msg.getAttributesBytes(),
- U.resolveClassLoader(task.getTask().getClass().getClassLoader(), ctx.config()));
+ MarshallerUtils.<Map<?, ?>>unmarshal(marsh, msg.getAttributesBytes(),
+ U.resolveClassLoader(task.getTask().getClass().getClassLoader(), ctx.config()), ctx.gridName());
GridTaskSessionImpl ses = task.getSession();
@@ -1305,7 +1306,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
if (topic == null) {
assert req.topicBytes() != null;
- topic = marsh.unmarshal(req.topicBytes(), U.resolveClassLoader(ctx.config()));
+ topic = MarshallerUtils.unmarshal(marsh, req.topicBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName());
}
boolean loc = ctx.localNodeId().equals(nodeId);
@@ -1313,7 +1315,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
ctx.io().send(nodeId, topic,
new GridJobSiblingsResponse(
loc ? siblings : null,
- loc ? null : marsh.marshal(siblings)),
+ loc ? null : MarshallerUtils.marshal(marsh, siblings, ctx.gridName())),
SYSTEM_POOL);
}
catch (IgniteCheckedException e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 8ce005a..fd0881d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -81,6 +81,7 @@ import org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.TaskContinuousMapperResource;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentLinkedDeque8;
@@ -774,16 +775,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
try {
boolean loc = ctx.localNodeId().equals(res.getNodeId()) && !ctx.config().isMarshalLocalJobs();
- Object res0 = loc ? res.getJobResult() : marsh.unmarshal(res.getJobResultBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()));
+ Object res0 = loc ? res.getJobResult() : MarshallerUtils.unmarshal(marsh,
+ res.getJobResultBytes(), U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
IgniteException ex = loc ? res.getException() :
- marsh.<IgniteException>unmarshal(res.getExceptionBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()));
+ MarshallerUtils.<IgniteException>unmarshal(marsh, res.getExceptionBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
Map<Object, Object> attrs = loc ? res.getJobAttributes() :
- marsh.<Map<Object, Object>>unmarshal(res.getJobAttributesBytes(),
- U.resolveClassLoader(clsLdr, ctx.config()));
+ MarshallerUtils.<Map<Object, Object>>unmarshal(marsh, res.getJobAttributesBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
jobRes.onResponse(res0, ex, attrs, res.isCancelled());
@@ -1253,16 +1254,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
ses.getTaskName(),
ses.getUserVersion(),
ses.getTaskClassName(),
- loc ? null : marsh.marshal(res.getJob()),
+ loc ? null : MarshallerUtils.marshal(marsh, res.getJob(), ctx.gridName()),
loc ? res.getJob() : null,
ses.getStartTime(),
timeout,
ses.getTopology(),
- loc ? null : marsh.marshal(ses.getJobSiblings()),
+ loc ? null : MarshallerUtils.marshal(marsh, ses.getJobSiblings(), ctx.gridName()),
loc ? ses.getJobSiblings() : null,
- loc ? null : marsh.marshal(sesAttrs),
+ loc ? null : MarshallerUtils.marshal(marsh, sesAttrs, ctx.gridName()),
loc ? sesAttrs : null,
- loc ? null : marsh.marshal(jobAttrs),
+ loc ? null : MarshallerUtils.marshal(marsh, jobAttrs, ctx.gridName()),
loc ? jobAttrs : null,
ses.getCheckpointSpi(),
dep.classLoaderId(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
index 6820dc7..56d0c30 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.nio.GridNioFilter;
import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
import org.apache.ignite.internal.util.nio.GridNioFilterChain;
@@ -73,10 +74,12 @@ public class IpcToNioAdapter<T> {
* @param endp Endpoint.
* @param lsnr Listener.
* @param writerFactory Writer factory.
+ * @param igniteCfg Ignite config.
* @param filters Filters.
*/
public IpcToNioAdapter(GridNioMetricsListener metricsLsnr, IgniteLogger log, IpcEndpoint endp,
- GridNioServerListener<T> lsnr, GridNioMessageWriterFactory writerFactory, GridNioFilter... filters) {
+ GridNioServerListener<T> lsnr, GridNioMessageWriterFactory writerFactory,
+ IgniteConfiguration igniteCfg, GridNioFilter... filters) {
assert metricsLsnr != null;
this.metricsLsnr = metricsLsnr;
@@ -84,7 +87,7 @@ public class IpcToNioAdapter<T> {
this.writerFactory = writerFactory;
chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
- ses = new GridNioSessionImpl(chain, null, null, true);
+ ses = new GridNioSessionImpl(chain, null, null, true, igniteCfg);
writeBuf = ByteBuffer.allocate(8 << 10);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index ac55a14..3a2a98f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -47,6 +47,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
@@ -196,6 +197,9 @@ public class GridNioServer<T> {
}
}
+ /** Grid name */
+ private String gridName;
+
/**
* @param addr Address.
* @param port Port.
@@ -260,6 +264,7 @@ public class GridNioServer<T> {
this.sockSndBuf = sockSndBuf;
this.sndQueueLimit = sndQueueLimit;
this.msgQueueLsnr = msgQueueLsnr;
+ this.gridName = gridName;
filterChain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
@@ -1630,6 +1635,10 @@ public class GridNioServer<T> {
readBuf.order(order);
}
+ final IgniteConfiguration cfg = new IgniteConfiguration(); // TODO provide real config
+
+ cfg.setGridName(gridName);
+
final GridSelectorNioSessionImpl ses = new GridSelectorNioSessionImpl(
log,
idx,
@@ -1639,7 +1648,8 @@ public class GridNioServer<T> {
req.accepted(),
sndQueueLimit,
writeBuf,
- readBuf);
+ readBuf,
+ cfg);
Map<Integer, ?> meta = req.meta();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
index e4a7225..edc9aa6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
@@ -18,6 +18,8 @@
package org.apache.ignite.internal.util.nio;
import java.net.InetSocketAddress;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.jetbrains.annotations.Nullable;
/**
@@ -164,4 +166,9 @@ public interface GridNioSession {
* @return Recovery descriptor if recovery is supported, {@code null otherwise.}
*/
@Nullable public GridNioRecoveryDescriptor recoveryDescriptor();
+
+ /**
+ * @return Ignite configuration.
+ */
+ public IgniteConfiguration igniteConfiguration();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
index 0bcfe64..b1465c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.util.nio;
import java.net.InetSocketAddress;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
@@ -69,22 +70,28 @@ public class GridNioSessionImpl implements GridNioSession {
/** Accepted flag. */
private final boolean accepted;
+ /** Ignite configuration. */
+ private IgniteConfiguration igniteCfg;
+
/**
* @param filterChain Chain.
* @param locAddr Local address.
* @param rmtAddr Remote address.
+ * @param igniteCfg Ignite config.
* @param accepted {@code True} if this session was initiated from remote host.
*/
public GridNioSessionImpl(
GridNioFilterChain filterChain,
@Nullable InetSocketAddress locAddr,
@Nullable InetSocketAddress rmtAddr,
- boolean accepted
+ boolean accepted,
+ IgniteConfiguration igniteCfg
) {
this.filterChain = filterChain;
this.locAddr = locAddr;
this.rmtAddr = rmtAddr;
this.accepted = accepted;
+ this.igniteCfg = igniteCfg;
long now = U.currentTimeMillis();
@@ -309,4 +316,9 @@ public class GridNioSessionImpl implements GridNioSession {
@Override public String toString() {
return S.toString(GridNioSessionImpl.class, this);
}
+
+ /** {@inheritDoc} */
+ @Override public IgniteConfiguration igniteConfiguration() {
+ return igniteCfg;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
index 360b3d4..042eaee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -77,6 +78,7 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl {
* @param sndQueueLimit Send queue limit.
* @param writeBuf Write buffer.
* @param readBuf Read buffer.
+ * @param igniteCfg Ignite config.
*/
GridSelectorNioSessionImpl(
IgniteLogger log,
@@ -87,9 +89,10 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl {
boolean accepted,
int sndQueueLimit,
@Nullable ByteBuffer writeBuf,
- @Nullable ByteBuffer readBuf
+ @Nullable ByteBuffer readBuf,
+ IgniteConfiguration igniteCfg
) {
- super(filterChain, locAddr, rmtAddr, accepted);
+ super(filterChain, locAddr, rmtAddr, accepted, igniteCfg);
assert selectorIdx >= 0;
assert sndQueueLimit >= 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
new file mode 100644
index 0000000..b6808e9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -0,0 +1,241 @@
+/*
+ * 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.marshaller;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+
+/**
+ * Util class that sets and discards thread local
+ * ignite configuration in {@link IgnitionEx} class.
+ */
+public final class MarshallerUtils {
+ /**
+ *
+ */
+ private MarshallerUtils() {
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param obj object.
+ * @param out output stream.
+ * @param gridName Grid name.
+ * @throws IgniteCheckedException
+ */
+ public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
+ final OutputStream out, final String gridName) throws IgniteCheckedException {
+ final String name = setGridName(gridName);
+
+ try {
+ marshaller.marshal(obj, out);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param obj object.
+ * @param igniteCfg ignite config.
+ * @return serialized.
+ * @throws IgniteCheckedException
+ */
+ public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
+ final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ return marshal(marshaller, obj, igniteCfg.getGridName());
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param obj object.
+ * @param gridName Grid name.
+ * @return serialized.
+ * @throws IgniteCheckedException
+ */
+ public static byte[] marshal(final Marshaller marshaller, @Nullable Object obj,
+ final String gridName) throws IgniteCheckedException {
+ final String name = setGridName(gridName);
+
+ try {
+ return marshaller.marshal(obj);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param in input stream.
+ * @param clsLdr class loader.
+ * @param gridName Grid name.
+ * @param <T> target type.
+ * @return deserialized object.
+ * @throws IgniteCheckedException
+ */
+ public static <T> T unmarshal(final Marshaller marshaller, InputStream in, @Nullable ClassLoader clsLdr,
+ final String gridName) throws IgniteCheckedException {
+ final String name = setGridName(gridName);
+
+ try {
+ return marshaller.unmarshal(in, clsLdr);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param arr byte array.
+ * @param clsLdr class loader.
+ * @param gridName Grid name.
+ * @param <T> target type
+ * @return deserialized object.
+ * @throws IgniteCheckedException
+ */
+ public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
+ final String gridName) throws IgniteCheckedException {
+ final String name = setGridName(gridName);
+
+ try {
+ return marshaller.unmarshal(arr, clsLdr);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param arr byte array.
+ * @param clsLdr class loader.
+ * @param igniteCfg ignite config.
+ * @param <T> target type
+ * @return deserialized object.
+ * @throws IgniteCheckedException
+ */
+ public static <T> T unmarshal(final Marshaller marshaller, byte[] arr, @Nullable ClassLoader clsLdr,
+ final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
+ return unmarshal(marshaller, arr, clsLdr, igniteCfg.getGridName());
+ }
+
+ /**
+ *
+ * @param marshaller marshaller.
+ * @param obj object
+ * @param clsLdr class loader.
+ * @param gridName Grid name.
+ * @param <T> target type.
+ * @return deserialized value.
+ * @throws IgniteCheckedException
+ */
+ public static <T> T clone(final Marshaller marshaller, T obj, @Nullable ClassLoader clsLdr,
+ final String gridName) throws IgniteCheckedException {
+ final String name = setGridName(gridName);
+
+ try {
+ return marshaller.unmarshal(marshaller.marshal(obj), clsLdr);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param gridMarshaller grid marshaller.
+ * @param obj object.
+ * @param off offset.
+ * @param gridName ignite config.
+ * @return serialized data.
+ * @throws IOException
+ */
+ public static ByteBuffer marshal(GridClientMarshaller gridMarshaller, Object obj, int off,
+ String gridName) throws IOException {
+ final String name = setGridName(gridName);
+
+ try {
+ return gridMarshaller.marshal(obj, off);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ *
+ * @param gridMarshaller grid marshaller.
+ * @param bytes byte array.
+ * @param gridName ignite config.
+ * @param <T> target type.
+ * @return deserialized value.
+ * @throws IOException
+ */
+ public static <T> T unmarshal(GridClientMarshaller gridMarshaller, byte[] bytes,
+ String gridName) throws IOException {
+ final String name = setGridName(gridName);
+
+ try {
+ return gridMarshaller.unmarshal(bytes);
+ } finally {
+ restoreGridName(name);
+ }
+ }
+
+ /**
+ * @param name Grid name.
+ * @return Old grid name.
+ */
+ private static String setGridName(final String name) {
+ final String gridName = IgnitionEx.getGridNameThreadLocal();
+
+ if (!F.eq(name, gridName))
+ IgnitionEx.setGridNameThreadLocal(name);
+
+ return gridName;
+ }
+
+ /**
+ * @param name Grid name.
+ */
+ private static void restoreGridName(final String name) {
+ IgnitionEx.setGridNameThreadLocal(name);
+ }
+
+ /**
+ *
+ * @param kernalCtx kernal context.
+ * @return ignite config or null.
+ */
+ private static IgniteConfiguration getConfig(final @Nullable GridKernalContext kernalCtx) {
+ return kernalCtx == null ? null : kernalCtx.config();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
index 36a4ea6..7a12582 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
@@ -323,7 +323,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin
log.debug("Checking checkpoint file: " + file.getAbsolutePath());
try {
- SharedFsCheckpointData data = SharedFsUtils.read(file, marsh, log);
+ SharedFsCheckpointData data = SharedFsUtils.read(file, marsh, log, ignite.configuration());
if (data.getHost().equals(host)) {
files.put(file, new SharedFsTimeData(data.getExpireTime(), file.lastModified(),
@@ -386,7 +386,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin
if (file.exists())
try {
- SharedFsCheckpointData data = SharedFsUtils.read(file, marsh, log);
+ SharedFsCheckpointData data = SharedFsUtils.read(file, marsh, log, ignite.configuration());
return data != null ?
data.getExpireTime() == 0 || data.getExpireTime() > U.currentTimeMillis() ?
@@ -434,7 +434,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin
try {
SharedFsUtils.write(file, new SharedFsCheckpointData(state, expireTime, host, key),
- marsh, log);
+ marsh, log, ignite.configuration());
}
catch (IOException e) {
// Select next shared directory if exists, otherwise throw exception
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsTimeoutTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsTimeoutTask.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsTimeoutTask.java
index 3cf11f8..07619c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsTimeoutTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsTimeoutTask.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
@@ -116,8 +117,13 @@ class SharedFsTimeoutTask extends IgniteSpiThread {
SharedFsTimeData timeData = entry.getValue();
try {
- if (timeData.getLastAccessTime() != file.lastModified())
- timeData.setExpireTime(SharedFsUtils.read(file, marshaller, log).getExpireTime());
+ if (timeData.getLastAccessTime() != file.lastModified()) {
+ final IgniteConfiguration igniteCfg = new IgniteConfiguration();
+
+ igniteCfg.setGridName(getGridName());
+
+ timeData.setExpireTime(SharedFsUtils.read(file, marshaller, log, igniteCfg).getExpireTime());
+ }
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal/unmarshal in checkpoint file: " + file.getAbsolutePath(), e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
index b1698fa..da55499 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
@@ -25,8 +25,10 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
/**
* Utility class that helps to manage files. It provides read/write
@@ -52,7 +54,7 @@ final class SharedFsUtils {
* to {@link SharedFsCheckpointData} object.
* @throws IOException Thrown if file read error occurred.
*/
- static SharedFsCheckpointData read(File file, Marshaller m, IgniteLogger log)
+ static SharedFsCheckpointData read(File file, Marshaller m, IgniteLogger log, final IgniteConfiguration igniteCfg)
throws IOException, IgniteCheckedException {
assert file != null;
assert m != null;
@@ -61,7 +63,7 @@ final class SharedFsUtils {
InputStream in = new FileInputStream(file);
try {
- return (SharedFsCheckpointData)m.unmarshal(in, U.gridClassLoader());
+ return (SharedFsCheckpointData) MarshallerUtils.unmarshal(m, in, U.gridClassLoader(), igniteCfg.getGridName());
}
finally {
U.close(in, log);
@@ -76,11 +78,12 @@ final class SharedFsUtils {
* @param data Checkpoint data.
* @param m Grid marshaller.
* @param log Messages logger.
+ * @param igniteCfg Ignite config.
* @throws IgniteCheckedException Thrown if data could not be marshalled.
* @throws IOException Thrown if file write operation failed.
*/
- static void write(File file, SharedFsCheckpointData data, Marshaller m, IgniteLogger log)
- throws IOException, IgniteCheckedException {
+ static void write(File file, SharedFsCheckpointData data, Marshaller m, IgniteLogger log,
+ final IgniteConfiguration igniteCfg) throws IOException, IgniteCheckedException {
assert file != null;
assert m != null;
assert data != null;
@@ -91,7 +94,7 @@ final class SharedFsUtils {
try {
out = new FileOutputStream(file);
- m.marshal(data, out);
+ MarshallerUtils.marshal(m, data, out, igniteCfg.getGridName());
}
finally {
U.close(out, log);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index ed29b59..8e78352 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -3013,6 +3013,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
endpoint,
srvLsnr,
writerFactory,
+ ignite.configuration(),
new GridNioCodecFilter(new GridDirectParser(msgFactory, readerFactory), log, true),
new GridConnectionBytesVerifyFilter(log)
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 79e58b1..f383fe7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -64,6 +64,7 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.spi.IgniteSpiContext;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.IgniteSpiOperationTimeoutHelper;
@@ -430,7 +431,7 @@ class ClientImpl extends TcpDiscoveryImpl {
try {
sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- spi.marsh.marshal(evt)));
+ MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().configuration())));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -684,7 +685,8 @@ class ClientImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- spi.marsh.marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
+ MarshallerUtils.marshal(spi.marsh, attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS),
+ spi.ignite().configuration()));
node.setAttributes(attrs);
}
@@ -885,7 +887,8 @@ class ClientImpl extends TcpDiscoveryImpl {
TcpDiscoveryAbstractMessage msg;
try {
- msg = spi.marsh.unmarshal(in, U.resolveClassLoader(spi.ignite().configuration()));
+ msg = MarshallerUtils.unmarshal(spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
@@ -1210,8 +1213,8 @@ class ClientImpl extends TcpDiscoveryImpl {
List<TcpDiscoveryAbstractMessage> msgs = null;
while (!isInterrupted()) {
- TcpDiscoveryAbstractMessage msg = spi.marsh.unmarshal(in,
- U.resolveClassLoader(spi.ignite().configuration()));
+ TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
if (msg instanceof TcpDiscoveryClientReconnectMessage) {
TcpDiscoveryClientReconnectMessage res = (TcpDiscoveryClientReconnectMessage)msg;
@@ -1965,7 +1968,7 @@ class ClientImpl extends TcpDiscoveryImpl {
if (node != null && node.visible()) {
try {
DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
- U.resolveClassLoader(spi.ignite().configuration()));
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration());
notifyDiscovery(EVT_DISCOVERY_CUSTOM_EVT, topVer, node, allVisibleNodes(), msgObj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 7f689c5..3244182 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -65,6 +65,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgniteNodeAttributes;
@@ -90,6 +91,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.security.SecurityCredentials;
import org.apache.ignite.plugin.security.SecurityPermissionSet;
import org.apache.ignite.spi.IgniteNodeValidationResult;
@@ -740,7 +742,8 @@ class ServerImpl extends TcpDiscoveryImpl {
/** {@inheritDoc} */
@Override public void sendCustomEvent(DiscoverySpiCustomMessage evt) {
try {
- msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt, spi.marsh.marshal(evt)));
+ msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
+ MarshallerUtils.marshal(spi.marsh, evt, spi.ignite().configuration())));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -823,7 +826,8 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(locNode.attributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marsh.marshal(subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
+ MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().configuration()));
attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
locNode.setAttributes(attrs);
@@ -1239,7 +1243,8 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- spi.marsh.marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
+ MarshallerUtils.marshal(spi.marsh,
+ attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS), spi.ignite().configuration()));
node.setAttributes(attrs);
}
@@ -1262,7 +1267,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (credBytes == null)
return null;
- return spi.marsh.unmarshal(credBytes, null);
+ return MarshallerUtils.unmarshal(spi.marsh, credBytes, null, spi.ignite().configuration());
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to unmarshal node security credentials: " + node.id(), e);
@@ -2356,7 +2361,7 @@ class ServerImpl extends TcpDiscoveryImpl {
for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
if (msgBytes == null) {
try {
- msgBytes = spi.marsh.marshal(msg);
+ msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().configuration());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal message: " + msg, e);
@@ -2375,8 +2380,8 @@ class ServerImpl extends TcpDiscoveryImpl {
if (clientMsgWorker.clientNodeId.equals(node.id())) {
try {
- msg0 = spi.marsh.unmarshal(msgBytes,
- U.resolveClassLoader(spi.ignite().configuration()));
+ msg0 = MarshallerUtils.unmarshal(spi.marsh, msgBytes,
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration());
prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId, null, null, null);
@@ -3134,7 +3139,8 @@ class ServerImpl extends TcpDiscoveryImpl {
// Stick in authentication subject to node (use security-safe attributes for copy).
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marsh.marshal(subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
+ MarshallerUtils.marshal(spi.marsh, subj, spi.ignite().configuration()));
node.setAttributes(attrs);
}
@@ -3785,9 +3791,11 @@ class ServerImpl extends TcpDiscoveryImpl {
else {
SecurityContext subj = spi.nodeAuth.authenticateNode(node, cred);
- SecurityContext coordSubj = spi.marsh.unmarshal(
+ final IgniteConfiguration cfg = spi.ignite().configuration();
+
+ SecurityContext coordSubj = MarshallerUtils.unmarshal(spi.marsh,
node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
- U.resolveClassLoader(spi.ignite().configuration()));
+ U.resolveClassLoader(cfg), cfg);
if (!permissionsEqual(coordSubj.subject().permissions(), subj.subject().permissions())) {
// Node has not pass authentication.
@@ -4838,7 +4846,8 @@ class ServerImpl extends TcpDiscoveryImpl {
DiscoverySpiCustomMessage msgObj = null;
try {
- msgObj = msg.message(spi.marsh, U.resolveClassLoader(spi.ignite().configuration()));
+ msgObj = msg.message(spi.marsh, U.resolveClassLoader(spi.ignite().configuration()),
+ spi.ignite().configuration());
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -4850,7 +4859,8 @@ class ServerImpl extends TcpDiscoveryImpl {
if (nextMsg != null) {
try {
TcpDiscoveryCustomEventMessage ackMsg = new TcpDiscoveryCustomEventMessage(
- getLocalNodeId(), nextMsg, spi.marsh.marshal(nextMsg));
+ getLocalNodeId(), nextMsg,
+ MarshallerUtils.marshal(spi.marsh, nextMsg, spi.ignite().configuration()));
ackMsg.topologyVersion(msg.topologyVersion());
@@ -4981,8 +4991,10 @@ class ServerImpl extends TcpDiscoveryImpl {
if (node != null) {
try {
+ final IgniteConfiguration cfg = spi.ignite().configuration();
+
DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
- U.resolveClassLoader(spi.ignite().configuration()));
+ U.resolveClassLoader(cfg), cfg);
lsnr.onDiscovery(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT,
msg.topologyVersion(),
@@ -4992,7 +5004,8 @@ class ServerImpl extends TcpDiscoveryImpl {
msgObj);
if (msgObj.isMutable())
- msg.message(msgObj, spi.marsh.marshal(msgObj));
+ msg.message(msgObj,
+ MarshallerUtils.marshal(spi.marsh, msgObj, spi.ignite().configuration()));
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -5428,8 +5441,8 @@ class ServerImpl extends TcpDiscoveryImpl {
while (!isInterrupted()) {
try {
- TcpDiscoveryAbstractMessage msg = spi.marsh.unmarshal(in,
- U.resolveClassLoader(spi.ignite().configuration()));
+ TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.marsh, in,
+ U.resolveClassLoader(spi.ignite().configuration()), spi.ignite().configuration().getGridName());
msg.senderNodeId(nodeId);
@@ -5919,7 +5932,7 @@ class ServerImpl extends TcpDiscoveryImpl {
byte[] msgBytes = msgT.get2();
if (msgBytes == null)
- msgBytes = spi.marsh.marshal(msg);
+ msgBytes = MarshallerUtils.marshal(spi.marsh, msg, spi.ignite().configuration());
if (msg instanceof TcpDiscoveryClientAckResponse) {
if (clientVer == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 308830e..bb01f74 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -64,6 +64,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
@@ -1377,7 +1378,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
IgniteCheckedException err = null;
try {
- marsh.marshal(msg, out);
+ MarshallerUtils.marshal(marsh, msg, out, ignite.configuration().getGridName());
}
catch (IgniteCheckedException e) {
err = e;
@@ -1461,10 +1462,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
try {
sock.setSoTimeout((int)timeout);
- T res = marsh.unmarshal(in == null ? sock.getInputStream() : in,
- U.resolveClassLoader(ignite.configuration()));
-
- return res;
+ return MarshallerUtils.unmarshal(marsh, in == null ? sock.getInputStream() : in,
+ U.resolveClassLoader(ignite.configuration()), ignite.configuration().getGridName());
}
catch (IOException | IgniteCheckedException e) {
if (X.hasCause(e, SocketTimeoutException.class))
@@ -1679,7 +1678,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, Serializable> entry : data.entrySet()) {
try {
- byte[] bytes = marsh.marshal(entry.getValue());
+ byte[] bytes = MarshallerUtils.marshal(marsh, entry.getValue(), ignite.configuration());
data0.put(entry.getKey(), bytes);
}
@@ -1709,7 +1708,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
for (Map.Entry<Integer, byte[]> entry : data.entrySet()) {
try {
- Serializable compData = marsh.unmarshal(entry.getValue(), clsLdr);
+ Serializable compData = MarshallerUtils.unmarshal(marsh, entry.getValue(), clsLdr,
+ ignite.configuration());
data0.put(entry.getKey(), compData);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 8b29efd..d213eaa 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -32,6 +32,7 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
@@ -40,6 +41,7 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiConfiguration;
@@ -359,7 +361,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (!addr.isLoopbackAddress()) {
try {
if (!clientMode)
- addrSnds.add(new AddressSender(mcastAddr, addr, addrs));
+ addrSnds.add(new AddressSender(mcastAddr, addr, addrs, getIgniteConfiguration()));
reqItfs.add(addr);
}
@@ -379,7 +381,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
try {
// Create non-bound socket if local host is loopback or failed to create sockets explicitly
// bound to interfaces.
- addrSnds.add(new AddressSender(mcastAddr, null, addrs));
+ addrSnds.add(new AddressSender(mcastAddr, null, addrs, getIgniteConfiguration()));
}
catch (IOException e) {
if (log.isDebugEnabled())
@@ -389,7 +391,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (addrSnds.isEmpty()) {
try {
- addrSnds.add(new AddressSender(mcastAddr, mcastAddr, addrs));
+ addrSnds.add(new AddressSender(mcastAddr, mcastAddr, addrs, getIgniteConfiguration()));
reqItfs.add(mcastAddr);
}
@@ -593,7 +595,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
AddressResponse addrRes;
try {
- addrRes = new AddressResponse(data);
+ addrRes = new AddressResponse(data, getIgniteConfiguration());
}
catch (IgniteCheckedException e) {
LT.warn(log, e, "Failed to deserialize multicast response.");
@@ -640,6 +642,15 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
}
}
+ /**
+ * get Ignite configuration if possible.
+ *
+ * @return Ignite config or {@code null}.
+ */
+ @Nullable private IgniteConfiguration getIgniteConfiguration() {
+ return ignite == null ? null : ignite.configuration();
+ }
+
/** {@inheritDoc} */
@Override public void close() {
if (addrSnds != null) {
@@ -688,10 +699,10 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
* @param addrs Addresses discovery SPI binds to.
* @throws IgniteCheckedException If marshalling failed.
*/
- private AddressResponse(Collection<InetSocketAddress> addrs) throws IgniteCheckedException {
+ private AddressResponse(Collection<InetSocketAddress> addrs, final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
this.addrs = addrs;
- byte[] addrsData = marsh.marshal(addrs);
+ byte[] addrsData = MarshallerUtils.marshal(marsh, addrs, igniteCfg);
data = new byte[U.IGNITE_HEADER.length + addrsData.length];
if (data.length > MAX_DATA_LENGTH)
@@ -705,12 +716,13 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
* @param data Message data.
* @throws IgniteCheckedException If unmarshalling failed.
*/
- private AddressResponse(byte[] data) throws IgniteCheckedException {
+ private AddressResponse(byte[] data, final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
assert U.bytesEqual(U.IGNITE_HEADER, 0, data, 0, U.IGNITE_HEADER.length);
this.data = data;
- addrs = marsh.unmarshal(Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null);
+ addrs = MarshallerUtils.unmarshal(marsh,
+ Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null, igniteCfg);
}
/**
@@ -782,18 +794,24 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
/** */
private final InetAddress sockItf;
+ /** */
+ private final IgniteConfiguration igniteCfg;
+
/**
* @param mcastGrp Multicast address.
* @param sockItf Optional interface multicast socket should be bound to.
* @param addrs Local node addresses.
+ * @param igniteCfg Ignite configuration.
* @throws IOException If fails to create multicast socket.
*/
- private AddressSender(InetAddress mcastGrp, @Nullable InetAddress sockItf, Collection<InetSocketAddress> addrs)
+ private AddressSender(InetAddress mcastGrp, @Nullable InetAddress sockItf, Collection<InetSocketAddress> addrs,
+ final IgniteConfiguration igniteCfg)
throws IOException {
super(ignite == null ? null : ignite.name(), "tcp-disco-multicast-addr-sender", log);
this.mcastGrp = mcastGrp;
this.addrs = addrs;
this.sockItf = sockItf;
+ this.igniteCfg = igniteCfg;
sock = createSocket();
}
@@ -829,7 +847,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
AddressResponse res;
try {
- res = new AddressResponse(addrs);
+ res = new AddressResponse(addrs, igniteCfg);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to prepare multicast message.", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index ca5dd56..1555718 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -18,9 +18,12 @@
package org.apache.ignite.spi.discovery.tcp.messages;
import java.util.UUID;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -70,20 +73,26 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
}
/**
- * @return Deserialized message,
+ * @param marsh Marshaller.
+ * @param igniteCfg Ignite configuration.
+ * @return Deserialized message.
* @throws java.lang.Throwable if unmarshal failed.
*/
- @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh) throws Throwable {
- return message(marsh, null);
+ @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, IgniteConfiguration igniteCfg) throws Throwable {
+ return message(marsh, null, igniteCfg);
}
/**
- * @return Deserialized message,
+ * @param marsh Marshaller.
+ * @param ldr Class loader.
+ * @param igniteCfg Ignite configuration.
+ * @return Deserialized message.
* @throws java.lang.Throwable if unmarshal failed.
*/
- @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr) throws Throwable {
+ @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr,
+ final IgniteConfiguration igniteCfg) throws Throwable {
if (msg == null) {
- msg = marsh.unmarshal(msgBytes, ldr);
+ msg = MarshallerUtils.unmarshal(marsh, msgBytes, ldr, igniteCfg);
assert msg != null;
}
@@ -104,4 +113,4 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
@Override public String toString() {
return S.toString(TcpDiscoveryCustomEventMessage.class, this, "super", super.toString());
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index df35ed3..a9e19b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -57,6 +57,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiAdapter;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
@@ -594,7 +595,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
if (keyBytes == null) {
try {
- keyBytes = ignite.configuration().getMarshaller().marshal(key.key());
+ keyBytes = MarshallerUtils.marshal(ignite.configuration().getMarshaller(), key.key(), ignite.configuration());
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal key: " + key.key(), e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
index 03e82e3..d1372ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
@@ -17,6 +17,8 @@
package org.apache.ignite.stream.socket;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
/**
* Socket message converter.
*/
@@ -25,7 +27,8 @@ public interface SocketMessageConverter<T> {
* Converter message represented by array of bytes to object.
*
* @param msg Message.
+ * @param igniteCfg Ignite config.
* @return Converted object.
*/
- public T convert(byte[] msg);
+ public T convert(byte[] msg, IgniteConfiguration igniteCfg);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
index 066a5fd..24580e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
@@ -24,6 +24,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.nio.GridBufferedParser;
import org.apache.ignite.internal.util.nio.GridDelimitedParser;
import org.apache.ignite.internal.util.nio.GridNioCodecFilter;
@@ -35,6 +36,7 @@ import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
import org.apache.ignite.internal.util.nio.GridNioSession;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.stream.StreamAdapter;
import org.apache.ignite.stream.StreamTupleExtractor;
@@ -163,7 +165,7 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
}
@Override public void onMessage(GridNioSession ses, byte[] msg) {
- addMessage(converter.convert(msg));
+ addMessage(converter.convert(msg, ses.igniteConfiguration()));
}
};
@@ -218,9 +220,9 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
private static final JdkMarshaller MARSH = new JdkMarshaller();
/** {@inheritDoc} */
- @Override public T convert(byte[] msg) {
+ @Override public T convert(byte[] msg, final IgniteConfiguration igniteCfg) {
try {
- return MARSH.unmarshal(msg, null);
+ return MarshallerUtils.unmarshal(MARSH, msg, null, igniteCfg);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
new file mode 100644
index 0000000..0308ab6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryCacheSerializationTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.processors.cache.binary;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.testframework.junits.GridAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.lang.reflect.Method;
+
+/**
+ *
+ */
+public class GridBinaryCacheSerializationTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "cache_name";
+
+ /**
+ * Emulate user thread.
+ *
+ * @throws Throwable
+ */
+ @Override protected void runTest() throws Throwable {
+ Class<?> cls = getClass();
+
+ while (!cls.equals(GridAbstractTest.class))
+ cls = cls.getSuperclass();
+
+ final Method runTest = cls.getDeclaredMethod("runTestInternal");
+
+ runTest.setAccessible(true);
+
+ runTest.invoke(this);
+ }
+
+ /**
+ * Test that calling {@link Ignition#localIgnite()}
+ * is safe for binary marshaller.
+ *
+ * @throws Exception
+ */
+ public void testPutGet() throws Exception {
+ final IgniteCache<Integer, MyObj> cache = startGrid().getOrCreateCache(CACHE_NAME);
+
+ final MyObj one = new MyObj("one");
+ final MyObj two = new MyObj("two");
+ final MyObj three = new MyObj("three");
+
+ cache.put(1, one);
+ cache.put(2, two);
+ cache.put(3, three);
+
+ final MyObj loadedOne = cache.get(1);
+ final MyObj loadedTwo = cache.get(2);
+ final MyObj loadedThree = cache.get(3);
+
+ assert one.equals(loadedOne);
+ assert two.equals(loadedTwo);
+ assert three.equals(loadedThree);
+
+ }
+
+ /**
+ * Test obj.
+ */
+ private static class MyObj {
+
+ /** */
+ final String val;
+
+ /** */
+ private MyObj(final String val) {
+ this.val = val;
+ }
+
+ private Object readResolve() {
+ Ignition.localIgnite();
+ return this;
+ }
+
+ /** */
+ @Override public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final MyObj myObj = (MyObj) o;
+
+ return val != null ? val.equals(myObj.val) : myObj.val == null;
+
+ }
+
+ /** */
+ @Override public int hashCode() {
+ return val != null ? val.hashCode() : 0;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
index 201fd27..043ec02 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
import org.apache.ignite.internal.util.nio.GridNioFilterChain;
@@ -377,5 +378,10 @@ public class GridNioFilterChainSelfTest extends GridCommonAbstractTest {
@Nullable @Override public GridNioRecoveryDescriptor recoveryDescriptor() {
return null;
}
+
+ /** {@inheritDoc} */
+ @Override public IgniteConfiguration igniteConfiguration() {
+ return null;
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 32d9072..7014608 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -1964,7 +1964,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
if (msg instanceof TcpDiscoveryCustomEventMessage) {
try {
DiscoveryCustomMessage custMsg = GridTestUtils.getFieldValue(
- ((TcpDiscoveryCustomEventMessage)msg).message(marsh), "delegate");
+ ((TcpDiscoveryCustomEventMessage)msg).message(marsh, null), "delegate");
if (custMsg instanceof StartRoutineAckDiscoveryMessage) {
log.info("Skip message send and stop node: " + msg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
index 1056990..a76a1fa 100644
--- a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
@@ -169,7 +169,7 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest {
*/
public void testSizeBasedCustomConverter() throws Exception {
SocketMessageConverter<Message> converter = new SocketMessageConverter<Message>() {
- @Override public Message convert(byte[] msg) {
+ @Override public Message convert(byte[] msg, IgniteConfiguration cfg) {
int i = (msg[0] & 0xFF) << 24;
i |= (msg[1] & 0xFF) << 16;
i |= (msg[2] & 0xFF) << 8;
@@ -233,7 +233,7 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest {
*/
public void testDelimiterBasedCustomConverter() throws Exception {
SocketMessageConverter<Message> converter = new SocketMessageConverter<Message>() {
- @Override public Message convert(byte[] msg) {
+ @Override public Message convert(byte[] msg, IgniteConfiguration cfg) {
int i = (msg[0] & 0xFF) << 24;
i |= (msg[1] & 0xFF) << 16;
i |= (msg[2] & 0xFF) << 8;
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
index 1d59a95..736c69f 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
@@ -35,6 +35,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage;
import org.apache.ignite.internal.processors.hadoop.taskexecutor.external.HadoopProcessDescriptor;
@@ -1174,11 +1175,15 @@ public class HadoopExternalCommunication {
this.endpoint = endpoint;
+ final IgniteConfiguration cfg = new IgniteConfiguration(); // TODO provide real config
+ cfg.setGridName(gridName);
+
adapter = new HadoopIpcToNioAdapter<>(
HadoopExternalCommunication.this.log,
endpoint,
accepted,
srvLsnr,
+ cfg,
filters());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
index a8de999..1000b8a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopIpcToNioAdapter.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.ipc.IpcEndpoint;
import org.apache.ignite.internal.util.nio.GridNioFilter;
import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
@@ -62,14 +63,15 @@ public class HadoopIpcToNioAdapter<T> {
* @param log Log.
* @param endp Endpoint.
* @param lsnr Listener.
+ * @param igniteCfg Ignite config.
* @param filters Filters.
*/
public HadoopIpcToNioAdapter(IgniteLogger log, IpcEndpoint endp, boolean accepted,
- GridNioServerListener<T> lsnr, GridNioFilter... filters) {
+ GridNioServerListener<T> lsnr, IgniteConfiguration igniteCfg, GridNioFilter... filters) {
this.endp = endp;
chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
- ses = new GridNioSessionImpl(chain, null, null, accepted);
+ ses = new GridNioSessionImpl(chain, null, null, accepted, igniteCfg);
writeBuf = ByteBuffer.allocate(8 << 10);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
index 3f79469..d0cbecc 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
import org.apache.ignite.internal.util.nio.GridNioFuture;
import org.apache.ignite.internal.util.nio.GridNioSession;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
/**
* Serialization filter.
@@ -59,14 +60,15 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
@Override public GridNioFuture<?> onSessionWrite(GridNioSession ses, Object msg) throws IgniteCheckedException {
assert msg instanceof HadoopMessage : "Invalid message type: " + msg;
- return proceedSessionWrite(ses, marshaller.marshal(msg));
+ return proceedSessionWrite(ses, MarshallerUtils.marshal(marshaller, msg, ses.igniteConfiguration()));
}
+ /** {@inheritDoc} */
@Override public void onMessageReceived(GridNioSession ses, Object msg) throws IgniteCheckedException {
assert msg instanceof byte[];
// Always unmarshal with system classloader.
- proceedMessageReceived(ses, marshaller.unmarshal((byte[])msg, null));
+ proceedMessageReceived(ses, MarshallerUtils.unmarshal(marshaller, (byte[])msg, null, ses.igniteConfiguration()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 7f0e230..a00795f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -76,6 +76,7 @@ import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
@@ -1535,13 +1536,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
protected JavaObjectSerializer h2Serializer() {
return new JavaObjectSerializer() {
@Override public byte[] serialize(Object obj) throws Exception {
- return marshaller.marshal(obj);
+ return MarshallerUtils.marshal(marshaller, obj, ctx.gridName());
}
@Override public Object deserialize(byte[] bytes) throws Exception {
ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
- return marshaller.unmarshal(bytes, clsLdr);
+ return MarshallerUtils.unmarshal(marshaller, bytes, clsLdr, ctx.gridName());
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 47ab083..1fa3368 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -564,7 +564,7 @@ public class GridReduceQueryExecutor {
Marshaller m = ctx.config().getMarshaller();
for (GridCacheSqlQuery mapQry : mapQrys)
- mapQry.marshallParams(m);
+ mapQry.marshallParams(m, ctx);
}
boolean retry = false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
index 2b7442f..414fef1 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
@@ -514,8 +514,10 @@ public class WebSessionFilter implements Filter {
try {
final WebSessionEntity entity = binaryCache.get(sesId);
- if (entity != null)
- cached = new WebSessionV2(sesId, httpReq.getSession(false), false, ctx, entity, marshaller);
+ if (entity != null) {
+ cached = new WebSessionV2(sesId, httpReq.getSession(false), false, ctx, entity, marshaller,
+ webSesIgnite.configuration());
+ }
break;
}
@@ -698,7 +700,7 @@ public class WebSessionFilter implements Filter {
if (log.isDebugEnabled())
log.debug("Session created: " + sesId);
- WebSessionV2 cached = new WebSessionV2(sesId, ses, true, ctx, null, marshaller);
+ WebSessionV2 cached = new WebSessionV2(sesId, ses, true, ctx, null, marshaller, webSesIgnite.configuration());
final WebSessionEntity marshaledEntity = cached.marshalAttributes();
@@ -710,9 +712,9 @@ public class WebSessionFilter implements Filter {
final WebSessionEntity old = cache0.getAndPutIfAbsent(sesId, marshaledEntity);
if (old != null)
- cached = new WebSessionV2(sesId, ses, false, ctx, old, marshaller);
+ cached = new WebSessionV2(sesId, ses, false, ctx, old, marshaller, webSesIgnite.configuration());
else
- cached = new WebSessionV2(sesId, ses, false, ctx, marshaledEntity, marshaller);
+ cached = new WebSessionV2(sesId, ses, false, ctx, marshaledEntity, marshaller, webSesIgnite.configuration());
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index b6540b2..28d16b1 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -19,10 +19,12 @@ package org.apache.ignite.cache.websession;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.websession.WebSessionEntity;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import javax.servlet.ServletContext;
@@ -87,22 +89,27 @@ class WebSessionV2 implements HttpSession {
/** Original session to delegate invalidation. */
private final HttpSession genuineSes;
+ /** Ignite config. */
+ private final IgniteConfiguration cfg;
+
/**
* @param id Session ID.
* @param ses Session.
* @param isNew Is new flag.
*/
WebSessionV2(final String id, final @Nullable HttpSession ses, final boolean isNew, final ServletContext ctx,
- @Nullable WebSessionEntity entity, final Marshaller marshaller) {
+ @Nullable WebSessionEntity entity, final Marshaller marshaller, final IgniteConfiguration cfg) {
assert id != null;
assert marshaller != null;
assert ctx != null;
assert ses != null || entity != null;
+ assert cfg != null;
this.marshaller = marshaller;
this.ctx = ctx;
this.isNew = isNew;
this.genuineSes = ses;
+ this.cfg = cfg;
accessTime = System.currentTimeMillis();
@@ -333,7 +340,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private <T> T unmarshal(final byte[] bytes) throws IOException {
if (marshaller != null) {
try {
- return marshaller.unmarshal(bytes, getClass().getClassLoader());
+ return MarshallerUtils.unmarshal(marshaller, bytes, getClass().getClassLoader(), cfg);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
@@ -353,7 +360,7 @@ class WebSessionV2 implements HttpSession {
@Nullable private byte[] marshal(final Object obj) throws IOException {
if (marshaller != null) {
try {
- return marshaller.marshal(obj);
+ return MarshallerUtils.marshal(marshaller, obj, cfg);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
[40/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 3c9c20f..aa28118 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -702,10 +702,12 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
this.addrs = addrs;
byte[] addrsData = MarshallerUtils.marshal(gridName, marsh, addrs);
+
data = new byte[U.IGNITE_HEADER.length + addrsData.length];
if (data.length > MAX_DATA_LENGTH)
- throw new IgniteCheckedException("Too long data packet [size=" + data.length + ", max=" + MAX_DATA_LENGTH + "]");
+ throw new IgniteCheckedException("Too long data packet [size=" + data.length +
+ ", max=" + MAX_DATA_LENGTH + "]");
System.arraycopy(U.IGNITE_HEADER, 0, data, 0, U.IGNITE_HEADER.length);
System.arraycopy(addrsData, 0, data, 4, addrsData.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 51fa52d..0b4e086 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1537,9 +1537,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
return new JavaObjectSerializer() {
@Override public byte[] serialize(Object obj) throws Exception {
if (ctx != null)
- return MarshallerUtils.marshal(ctx.gridName(), marshaller, obj);
+ return MarshallerUtils.marshal(ctx, obj);
else
- return MarshallerUtils.marshal(marshaller, obj);
+ return marshaller.marshal(obj);
}
@Override public Object deserialize(byte[] bytes) throws Exception {
[03/50] [abbrv] ignite git commit: IGNITE-1849 GridCacheAdapter -
made size tasks @GridInternal
Posted by vo...@apache.org.
IGNITE-1849 GridCacheAdapter - made size tasks @GridInternal
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a33dd1c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a33dd1c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a33dd1c5
Branch: refs/heads/ignite-2649
Commit: a33dd1c5d680c6a3d9dd266f135f139cacd7772f
Parents: 762c43d
Author: Alexander Paschenko <al...@gmail.com>
Authored: Wed Jul 13 05:01:02 2016 +0300
Committer: Alexander Paschenko <al...@gmail.com>
Committed: Wed Jul 13 05:01:02 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 2 +
.../IgniteCacheInternalEventsIgnoreTest.java | 53 ++++++++++++++++++++
.../testsuites/IgniteCacheTestSuite5.java | 2 +
3 files changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a33dd1c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 55bd81d..05fd7d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -6656,6 +6656,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* Size task.
*/
+ @GridInternal
private static class SizeTask extends ComputeTaskAdapter<Object, Integer> {
/** */
private static final long serialVersionUID = 0L;
@@ -6721,6 +6722,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* Size task.
*/
+ @GridInternal
private static class SizeLongTask extends ComputeTaskAdapter<Object, Long> {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a33dd1c5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
new file mode 100644
index 0000000..e87206d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.processors.cache;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/** */
+public class IgniteCacheInternalEventsIgnoreTest extends GridCommonAbstractTest {
+ /** */
+ private static final AtomicBoolean evtFlag = new AtomicBoolean();
+
+ /** */
+ public void testInternalEventsIgnore() throws Exception {
+ Ignite ignite = startGrid(1);
+ ignite.events().localListen(new EvtLsnr(), EventType.EVT_TASK_STARTED, EventType.EVT_TASK_REDUCED,
+ EventType.EVT_TASK_FINISHED);
+ IgniteCache cache = ignite.createCache(defaultCacheConfiguration().setName("myTestCache"));
+ cache.size(CachePeekMode.ALL);
+ cache.sizeLong(CachePeekMode.ALL);
+ assertFalse(evtFlag.get());
+ }
+
+ /** */
+ private static final class EvtLsnr implements IgnitePredicate<Event> {
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event e) {
+ evtFlag.set(true);
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a33dd1c5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 98a3c44..af54f91 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
import org.apache.ignite.internal.processors.cache.EntryVersionConsistencyReadThroughTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheInternalEventsIgnoreTest;
import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest;
@@ -44,6 +45,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
suite.addTestSuite(IgniteCachePutStackOverflowSelfTest.class);
suite.addTestSuite(EntryVersionConsistencyReadThroughTest.class);
suite.addTestSuite(IgniteCacheTxIteratorSelfTest.class);
+ suite.addTestSuite(IgniteCacheInternalEventsIgnoreTest.class);
return suite;
}
[42/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
Cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/acf0705e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/acf0705e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/acf0705e
Branch: refs/heads/ignite-2649
Commit: acf0705e1cf656cdfddffe1e8ddecbcf4f44ed35
Parents: a7f99d9
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:23:10 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:23:10 2016 +0300
----------------------------------------------------------------------
.../connection/GridClientNioTcpConnection.java | 3 +-
.../processors/cache/GridCacheProcessor.java | 8 ++---
.../cache/query/GridCacheLocalQueryFuture.java | 12 +++----
.../cache/query/GridCacheQueryRequest.java | 9 ++---
.../closure/GridClosureProcessor.java | 6 ++--
.../rest/protocols/tcp/GridTcpRestParser.java | 3 +-
.../ignite/marshaller/MarshallerUtils.java | 36 +++-----------------
7 files changed, 25 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
index 579d185..093cf1f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
@@ -540,8 +540,7 @@ public class GridClientNioTcpConnection extends GridClientConnection {
GridClientMessage res0 = res;
if (res instanceof GridRouterResponse) {
- res0 = MarshallerUtils.unmarshal(marsh, ((GridRouterResponse)res).body(),
- ses.gridName());
+ res0 = marsh.unmarshal(((GridRouterResponse)res).body());
res0.requestId(res.requestId());
res0.clientId(res.clientId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index e6ba3ef..3cc33b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -106,7 +106,6 @@ import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -3398,8 +3397,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (ldr == null)
ldr = val.getCacheStoreFactory().getClass().getClassLoader();
- MarshallerUtils.clone(marshaller, val.getCacheStoreFactory(),
- U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
+ MarshallerUtils.marshalUnmarshal(ctx.gridName(), marshaller, val.getCacheStoreFactory(),
+ U.resolveClassLoader(ldr, ctx.config()));
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration. " +
@@ -3408,7 +3407,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
try {
- return MarshallerUtils.clone(marshaller, val, U.resolveClassLoader(ctx.config()), ctx.gridName());
+ return MarshallerUtils.marshalUnmarshal(ctx.gridName(), marshaller, val,
+ U.resolveClassLoader(ctx.config()));
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
index d524d70..7f33220 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
@@ -113,13 +113,13 @@ public class GridCacheLocalQueryFuture<K, V, R> extends GridCacheQueryFutureAdap
Marshaller marsh = cctx.marshaller();
- IgniteReducer<Object, Object> rdc = qry.reducer() != null
- ? MarshallerUtils.clone(marsh, qry.reducer(), U.resolveClassLoader(cctx.gridConfig()), cctx.gridName())
- : null;
+ IgniteReducer<Object, Object> rdc = qry.reducer() != null ?
+ MarshallerUtils.marshalUnmarshal(cctx.gridName(), marsh, qry.reducer(),
+ U.resolveClassLoader(cctx.gridConfig())) : null;
- IgniteClosure<Object, Object> trans = qry.transform() != null
- ? MarshallerUtils.clone(marsh, qry.transform(), U.resolveClassLoader(cctx.gridConfig()), cctx.gridName())
- : null;
+ IgniteClosure<Object, Object> trans = qry.transform() != null ?
+ MarshallerUtils.marshalUnmarshal(cctx.gridName(), marsh, qry.transform(),
+ U.resolveClassLoader(cctx.gridConfig())) : null;
return new GridCacheQueryInfo(
true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index b5a6fe2..d4de268 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -350,10 +350,11 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
void beforeLocalExecution(GridCacheContext ctx) throws IgniteCheckedException {
Marshaller marsh = ctx.marshaller();
- rdc = rdc != null ? MarshallerUtils.clone(marsh, rdc,
- U.resolveClassLoader(ctx.gridConfig()), ctx.gridName()) : null;
- trans = trans != null ? MarshallerUtils.clone(marsh, trans,
- U.resolveClassLoader(ctx.gridConfig()), ctx.gridName()) : null;
+ rdc = rdc != null ? MarshallerUtils.marshalUnmarshal(ctx.gridName(), marsh, rdc,
+ U.resolveClassLoader(ctx.gridConfig())) : null;
+
+ trans = trans != null ? MarshallerUtils.marshalUnmarshal(ctx.gridName(), marsh, trans,
+ U.resolveClassLoader(ctx.gridConfig())) : null;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/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 30f99a5..a330986 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
@@ -1151,10 +1151,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
if (c.job == closure)
c.job = MarshallerUtils.unmarshal(marsh, closureBytes, U.resolveClassLoader(ctx.config()), ctx.gridName());
else
- c.job = MarshallerUtils.clone(marsh, c.job, U.resolveClassLoader(ctx.config()), ctx.gridName());
+ c.job = MarshallerUtils.marshalUnmarshal(ctx.gridName(), marsh, c.job,
+ U.resolveClassLoader(ctx.config()));
}
else
- job = MarshallerUtils.clone(marsh, job, U.resolveClassLoader(ctx.config()), ctx.gridName());
+ job = MarshallerUtils.marshalUnmarshal(ctx.gridName(), marsh, job,
+ U.resolveClassLoader(ctx.config()));
}
else
hadLocNode = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index d7873a2..8c14305 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -520,8 +520,7 @@ public class GridTcpRestParser implements GridNioParser {
else {
GridClientMarshaller marsh = marshaller(ses);
- msg = MarshallerUtils.unmarshal(marsh, state.buffer().toByteArray(),
- ses.gridName());
+ msg = marsh.unmarshal(state.buffer().toByteArray());
msg.requestId(state.header().reqId());
msg.clientId(state.header().clientId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/acf0705e/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index ce143ff..c1dc373 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -21,10 +21,8 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.LocalGridName;
-import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
import org.jetbrains.annotations.Nullable;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -180,16 +178,16 @@ public final class MarshallerUtils {
/**
* Marshal and unmarshal object.
*
+ * @param <T> Target type.
+ * @param gridName Grid name.
* @param marshaller Marshaller.
* @param obj Object to clone.
* @param clsLdr Class loader.
- * @param gridName Grid name.
- * @param <T> Target type.
* @return Deserialized value.
* @throws IgniteCheckedException If fail.
*/
- public static <T> T clone(final Marshaller marshaller, T obj, @Nullable ClassLoader clsLdr,
- final String gridName) throws IgniteCheckedException {
+ public static <T> T marshalUnmarshal(final String gridName, final Marshaller marshaller, T obj,
+ @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
final LocalGridName gridNameTl = gridName();
final String gridNameStr = gridNameTl.getGridName();
@@ -205,32 +203,6 @@ public final class MarshallerUtils {
}
/**
- * Unmarshal object and set grid name thread local.
- *
- * @param gridMarshaller Grid marshaller.
- * @param bytes Binary data.
- * @param gridName Grid name.
- * @param <T> Target type.
- * @return Deserialized value.
- * @throws IOException If fail.
- */
- public static <T> T unmarshal(GridClientMarshaller gridMarshaller, byte[] bytes,
- String gridName) throws IOException {
- final LocalGridName gridNameTl = gridName();
-
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
-
- try {
- gridNameTl.setGridName(true, gridName);
-
- return gridMarshaller.unmarshal(bytes);
- } finally {
- gridNameTl.setGridName(init, gridNameStr);
- }
- }
-
- /**
* @return Grid name thread local.
*/
private static LocalGridName gridName() {
[30/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
IGNITE-2649 - Ignition.localIgnite() unreliable under Gateways and cause wrong components deserialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/97ce8fbb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/97ce8fbb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/97ce8fbb
Branch: refs/heads/ignite-2649
Commit: 97ce8fbbce3ccdf99d05d5e36899fe0a54deb5e7
Parents: 71ef652
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Aug 3 13:26:39 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Aug 3 13:26:40 2016 +0300
----------------------------------------------------------------------
.../socket/WordsSocketStreamerServer.java | 3 +-
.../rest/protocols/tcp/MockNioSession.java | 7 +
.../rendezvous/RendezvousAffinityFunction.java | 5 +-
.../cache/store/jdbc/CacheJdbcBlobStore.java | 5 +-
.../internal/GridEventConsumeHandler.java | 30 +--
.../internal/GridJobSiblingsResponse.java | 6 +-
.../internal/GridMessageListenHandler.java | 14 +-
.../org/apache/ignite/internal/IgnitionEx.java | 30 ++-
.../internal/binary/BinaryEnumObjectImpl.java | 3 +-
.../internal/binary/BinaryObjectImpl.java | 18 +-
.../ignite/internal/binary/BinaryUtils.java | 4 +-
.../internal/binary/BinaryWriterExImpl.java | 3 +-
.../client/GridClientConfiguration.java | 1 -
.../connection/GridClientNioTcpConnection.java | 4 +-
.../router/impl/GridTcpRouterNioParser.java | 3 +-
.../checkpoint/GridCheckpointManager.java | 11 +-
.../managers/communication/GridIoManager.java | 17 +-
.../deployment/GridDeploymentCommunication.java | 6 +-
.../eventstorage/GridEventStorageManager.java | 26 +-
.../swapspace/GridSwapSpaceManager.java | 5 +-
.../processors/affinity/GridAffinityUtils.java | 7 +-
.../cache/CacheEntrySerializablePredicate.java | 6 +-
.../cache/CacheInvokeDirectResult.java | 9 +-
.../processors/cache/GridCacheMessage.java | 13 +-
.../processors/cache/GridCacheProcessor.java | 7 +-
.../processors/cache/GridCacheUtils.java | 3 +-
.../GridDistributedLockResponse.java | 9 +-
.../GridDistributedTxPrepareRequest.java | 6 +-
.../GridDistributedTxPrepareResponse.java | 9 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 6 +-
.../dht/GridDhtTxFinishResponse.java | 9 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 6 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 9 +-
.../atomic/GridNearAtomicUpdateResponse.java | 9 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 9 +-
.../GridDhtPartitionDemandMessage.java | 9 +-
.../preloader/GridDhtPartitionsFullMessage.java | 17 +-
.../GridDhtPartitionsSingleMessage.java | 17 +-
.../distributed/near/GridNearGetResponse.java | 9 +-
.../near/GridNearSingleGetResponse.java | 9 +-
.../near/GridNearTxFinishResponse.java | 9 +-
.../cache/query/GridCacheLocalQueryFuture.java | 13 +-
.../cache/query/GridCacheQueryRequest.java | 31 ++-
.../cache/query/GridCacheQueryResponse.java | 9 +-
.../cache/query/GridCacheSqlQuery.java | 9 +-
.../continuous/CacheContinuousQueryHandler.java | 6 +-
.../jdbc/GridCacheQueryJdbcMetadataTask.java | 5 +-
.../query/jdbc/GridCacheQueryJdbcTask.java | 8 +-
.../cache/transactions/IgniteTxEntry.java | 11 +-
.../version/GridCacheRawVersionedEntry.java | 11 +-
.../IgniteCacheObjectProcessorImpl.java | 5 +-
.../closure/GridClosureProcessor.java | 9 +-
.../continuous/GridContinuousProcessor.java | 13 +-
.../processors/continuous/StartRequestData.java | 13 +-
.../datastreamer/DataStreamProcessor.java | 13 +-
.../datastreamer/DataStreamerImpl.java | 10 +-
.../processors/igfs/IgfsAckMessage.java | 15 +-
.../igfs/IgfsCommunicationMessage.java | 8 +-
.../internal/processors/igfs/IgfsContext.java | 4 +-
.../processors/igfs/IgfsDataManager.java | 2 +-
.../processors/igfs/IgfsDeleteMessage.java | 16 +-
.../igfs/IgfsFragmentizerManager.java | 2 +-
.../internal/processors/igfs/IgfsImpl.java | 2 +-
.../internal/processors/igfs/IgfsPaths.java | 7 +-
.../processors/job/GridJobProcessor.java | 34 +--
.../internal/processors/job/GridJobWorker.java | 10 +-
.../offheap/GridOffHeapProcessor.java | 5 +-
.../handlers/task/GridTaskCommandHandler.java | 13 +-
.../rest/protocols/tcp/GridTcpRestParser.java | 33 ++-
.../service/GridServiceProcessor.java | 11 +-
.../processors/task/GridTaskProcessor.java | 12 +-
.../processors/task/GridTaskWorker.java | 21 +-
.../internal/util/ipc/IpcToNioAdapter.java | 7 +-
.../ignite/internal/util/nio/GridNioServer.java | 12 +-
.../internal/util/nio/GridNioSession.java | 7 +
.../internal/util/nio/GridNioSessionImpl.java | 14 +-
.../util/nio/GridSelectorNioSessionImpl.java | 7 +-
.../ignite/marshaller/MarshallerUtils.java | 241 +++++++++++++++++++
.../sharedfs/SharedFsCheckpointSpi.java | 6 +-
.../sharedfs/SharedFsTimeoutTask.java | 10 +-
.../spi/checkpoint/sharedfs/SharedFsUtils.java | 13 +-
.../communication/tcp/TcpCommunicationSpi.java | 1 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 15 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 47 ++--
.../spi/discovery/tcp/TcpDiscoverySpi.java | 14 +-
.../TcpDiscoveryMulticastIpFinder.java | 38 ++-
.../TcpDiscoveryCustomEventMessage.java | 23 +-
.../spi/swapspace/file/FileSwapSpaceSpi.java | 3 +-
.../stream/socket/SocketMessageConverter.java | 5 +-
.../ignite/stream/socket/SocketStreamer.java | 8 +-
.../GridBinaryCacheSerializationTest.java | 113 +++++++++
.../nio/impl/GridNioFilterChainSelfTest.java | 6 +
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 2 +-
.../stream/socket/SocketStreamerSelfTest.java | 4 +-
.../HadoopExternalCommunication.java | 5 +
.../communication/HadoopIpcToNioAdapter.java | 6 +-
.../communication/HadoopMarshallerFilter.java | 6 +-
.../processors/query/h2/IgniteH2Indexing.java | 5 +-
.../h2/twostep/GridReduceQueryExecutor.java | 2 +-
.../cache/websession/WebSessionFilter.java | 12 +-
.../ignite/cache/websession/WebSessionV2.java | 13 +-
101 files changed, 1038 insertions(+), 356 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
index 814d235..c1727a55 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
@@ -35,6 +35,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.stream.StreamSingleTupleExtractor;
import org.apache.ignite.stream.socket.SocketMessageConverter;
import org.apache.ignite.stream.socket.SocketStreamer;
+import org.apache.ignite.configuration.IgniteConfiguration;
/**
* Example demonstrates streaming of data from external components into Ignite cache.
@@ -99,7 +100,7 @@ public class WordsSocketStreamerServer {
// Converter from zero-terminated string to Java strings.
sockStmr.setConverter(new SocketMessageConverter<String>() {
- @Override public String convert(byte[] msg) {
+ @Override public String convert(byte[] msg, IgniteConfiguration cfg) {
try {
return new String(msg, "ASCII");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
index c82c73e..e4efc78 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/MockNioSession.java
@@ -18,6 +18,8 @@
package org.apache.ignite.internal.processors.rest.protocols.tcp;
import java.net.InetSocketAddress;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
import org.apache.ignite.internal.util.nio.GridNioFinishedFuture;
import org.apache.ignite.internal.util.nio.GridNioFuture;
@@ -139,4 +141,9 @@ public class MockNioSession extends GridMetadataAwareAdapter implements GridNioS
@Nullable @Override public GridNioRecoveryDescriptor recoveryDescriptor() {
return null;
}
+
+ /** {@inheritDoc} */
+ @Override public IgniteConfiguration igniteConfiguration() {
+ return null;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 37258d4..8a84e9f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -42,6 +42,7 @@ import org.apache.ignite.cache.affinity.AffinityNodeHashResolver;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.GridKernalContextImpl;
import org.apache.ignite.internal.processors.cache.GridCacheUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -49,6 +50,7 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
import org.jetbrains.annotations.Nullable;
@@ -335,7 +337,8 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] nodeHashBytes = ignite.configuration().getMarshaller().marshal(nodeHash);
+ byte[] nodeHashBytes = MarshallerUtils.marshal(
+ ignite.configuration().getMarshaller(), nodeHash, ignite.configuration());
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
out.write(nodeHashBytes, 0, nodeHashBytes.length); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
index 147f6c9..d34adda 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.CacheStoreSessionResource;
import org.apache.ignite.resources.IgniteInstanceResource;
@@ -560,7 +561,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
* @throws IgniteCheckedException If failed to convert.
*/
protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return marsh.marshal(obj);
+ return MarshallerUtils.marshal(marsh, obj, ignite.configuration());
}
/**
@@ -575,7 +576,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
if (bytes == null || bytes.length == 0)
return null;
- return marsh.unmarshal(bytes, getClass().getClassLoader());
+ return MarshallerUtils.unmarshal(marsh, bytes, getClass().getClassLoader(), ignite.configuration());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index 19bf1a7..e99c2af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -51,6 +51,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVTS_ALL;
@@ -219,7 +220,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (cctx.deploymentEnabled() &&
ctx.discovery().cacheNode(node, cacheName)) {
- wrapper.p2pMarshal(ctx.config().getMarshaller());
+ wrapper.p2pMarshal(ctx);
wrapper.cacheName = cacheName;
@@ -338,7 +339,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
}
try {
- wrapper.p2pUnmarshal(ctx.config().getMarshaller(), U.resolveClassLoader(ldr, ctx.config()));
+ wrapper.p2pUnmarshal(ctx, U.resolveClassLoader(ldr, ctx.config()));
}
catch (IgniteCheckedException e) {
U.error(ctx.log(getClass()), "Failed to unmarshal event.", e);
@@ -370,7 +371,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
depInfo = new GridDeploymentInfoBean(dep);
- filterBytes = ctx.config().getMarshaller().marshal(filter);
+ filterBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), filter, ctx.gridName());
}
}
@@ -387,7 +388,8 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
- filter = ctx.config().getMarshaller().unmarshal(filterBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ filter = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), filterBytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
}
}
@@ -484,27 +486,27 @@ class GridEventConsumeHandler implements GridContinuousHandler {
}
/**
- * @param marsh Marshaller.
- * @throws IgniteCheckedException In case of error.
+ * @param ctx Kernal context.
+ * @throws IgniteCheckedException
*/
- void p2pMarshal(Marshaller marsh) throws IgniteCheckedException {
- assert marsh != null;
+ void p2pMarshal(final GridKernalContext ctx) throws IgniteCheckedException {
+ assert ctx.config().getMarshaller() != null;
- bytes = marsh.marshal(evt);
+ bytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), evt, ctx.gridName());
}
/**
- * @param marsh Marshaller.
+ * @param ctx Kernal context.
* @param ldr Class loader.
- * @throws IgniteCheckedException In case of error.
+ * @throws IgniteCheckedException
*/
- void p2pUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
- assert marsh != null;
+ void p2pUnmarshal(final GridKernalContext ctx, @Nullable ClassLoader ldr) throws IgniteCheckedException {
+ assert ctx.config().getMarshaller() != null;
assert evt == null;
assert bytes != null;
- evt = marsh.unmarshal(bytes, ldr);
+ evt = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), bytes, ldr, ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
index aa81cc5..714fb13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
@@ -24,6 +24,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.compute.ComputeJobSibling;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -68,13 +69,14 @@ public class GridJobSiblingsResponse implements Message {
/**
* @param marsh Marshaller.
+ * @param ctx kernal context.
* @throws IgniteCheckedException In case of error.
*/
- public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException {
+ public void unmarshalSiblings(Marshaller marsh, final GridKernalContext ctx) throws IgniteCheckedException {
assert marsh != null;
if (siblingsBytes != null)
- siblings = marsh.unmarshal(siblingsBytes, null);
+ siblings = MarshallerUtils.unmarshal(marsh, siblingsBytes, null, ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 0ac6877..8984313 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.util.lang.GridPeerDeployAware;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
/**
@@ -159,9 +160,9 @@ public class GridMessageListenHandler implements GridContinuousHandler {
assert ctx.config().isPeerClassLoadingEnabled();
if (topic != null)
- topicBytes = ctx.config().getMarshaller().marshal(topic);
+ topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
- predBytes = ctx.config().getMarshaller().marshal(pred);
+ predBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), pred, ctx.gridName());
// Deploy only listener, as it is very likely to be of some user class.
GridPeerDeployAware pda = U.peerDeployAware(pred);
@@ -192,10 +193,13 @@ public class GridMessageListenHandler implements GridContinuousHandler {
ClassLoader ldr = dep.classLoader();
- if (topicBytes != null)
- topic = ctx.config().getMarshaller().unmarshal(topicBytes, U.resolveClassLoader(ldr, ctx.config()));
+ if (topicBytes != null) {
+ topic = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), topicBytes,
+ U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
+ }
- pred = ctx.config().getMarshaller().unmarshal(predBytes, U.resolveClassLoader(ldr, ctx.config()));
+ pred = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), predBytes,
+ U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 6f5b9a6..8f882ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -166,6 +166,9 @@ public class IgnitionEx {
private static final Collection<IgnitionListener> lsnrs = new GridConcurrentHashSet<>(4);
/** */
+ private static final ThreadLocal<String> GRID_NAME_THREAD_LOC = new ThreadLocal<>();
+
+ /** */
private static ThreadLocal<Boolean> daemon = new ThreadLocal<Boolean>() {
@Override protected Boolean initialValue() {
return false;
@@ -1279,17 +1282,20 @@ public class IgnitionEx {
}
/**
- * Gets the grid, which is owner of current thread. An Exception is thrown if
+ * Gets a name of the grid from thread local config, which is owner of current thread. An Exception is thrown if
* current thread is not an {@link IgniteThread}.
*
* @return Grid instance related to current thread
* @throws IllegalArgumentException Thrown to indicate, that current thread is not an {@link IgniteThread}.
*/
public static IgniteKernal localIgnite() throws IllegalArgumentException {
- if (Thread.currentThread() instanceof IgniteThread)
+ if (GRID_NAME_THREAD_LOC.get() != null)
+ return gridx(GRID_NAME_THREAD_LOC.get());
+ else if (Thread.currentThread() instanceof IgniteThread)
return gridx(((IgniteThread)Thread.currentThread()).getGridName());
else
- throw new IllegalArgumentException("This method should be accessed under " + IgniteThread.class.getName());
+ throw new IllegalArgumentException("Ignite conf thread local must be set or" +
+ " this method should be accessed under " + IgniteThread.class.getName());
}
/**
@@ -1355,6 +1361,24 @@ public class IgnitionEx {
}
/**
+ * Set ignite config to thread local.
+ *
+ * @param name Grid name.
+ */
+ public static void setGridNameThreadLocal(final String name) {
+ GRID_NAME_THREAD_LOC.set(name);
+ }
+
+ /**
+ * Get ignite config from thread local.
+ *
+ * @return Grid name.
+ */
+ public static String getGridNameThreadLocal() {
+ return GRID_NAME_THREAD_LOC.get();
+ }
+
+ /**
* Start context encapsulates all starting parameters.
*/
private static final class GridStartContext {
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index afd0bdc..489220e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -243,7 +244,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectContext cacheCtx) throws IgniteCheckedException {
- return ctx.marshaller().marshal(this);
+ return MarshallerUtils.marshal(ctx.marshaller(), this, ctx.configuration());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index 3563fba..2296a3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -21,8 +21,10 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
+import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
@@ -538,8 +540,18 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
* @return Object.
*/
private Object deserializeValue(@Nullable CacheObjectContext coCtx) {
- BinaryReaderExImpl reader = reader(null,
- coCtx != null ? coCtx.kernalContext().config().getClassLoader() : ctx.configuration().getClassLoader());
+ final String gridName = IgnitionEx.getGridNameThreadLocal();
+
+ final ClassLoader cl;
+
+ if (coCtx != null) {
+ IgnitionEx.setGridNameThreadLocal(coCtx.kernalContext().config().getGridName());
+
+ cl = coCtx.kernalContext().config().getClassLoader();
+ } else
+ cl = ctx.configuration().getClassLoader();
+
+ final BinaryReaderExImpl reader = reader(null, cl);
Object obj0 = reader.deserialize();
@@ -550,6 +562,8 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
if (coCtx != null && coCtx.storeValue())
obj = obj0;
+ IgnitionEx.setGridNameThreadLocal(gridName);
+
return obj0;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index b6a95fb..0ce4916 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -61,6 +61,7 @@ import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -1589,7 +1590,8 @@ public class BinaryUtils {
ByteArrayInputStream input = new ByteArrayInputStream(in.array(), in.position(), len);
try {
- return ctx.optimizedMarsh().unmarshal(input, U.resolveClassLoader(clsLdr, ctx.configuration()));
+ return MarshallerUtils.unmarshal(ctx.optimizedMarsh(), input,
+ U.resolveClassLoader(clsLdr, ctx.configuration()), ctx.configuration().getGridName());
}
catch (IgniteCheckedException e) {
throw new BinaryObjectException("Failed to unmarshal object with optimized marshaller", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 30710f4..fab379a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -157,7 +158,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
out.writeByte(GridBinaryMarshaller.OPTM_MARSH);
try {
- byte[] arr = ctx.optimizedMarsh().marshal(obj);
+ byte[] arr = MarshallerUtils.marshal(ctx.optimizedMarsh(), obj, ctx.configuration());
writeInt(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
index e9d2958..cac1bb3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
@@ -157,7 +157,6 @@ public class GridClientConfiguration {
tcpNoDelay = cfg.isTcpNoDelay();
topRefreshFreq = cfg.getTopologyRefreshFrequency();
daemon = cfg.isDaemon();
- marshaller = cfg.getMarshaller();
setDataConfigurations(cfg.getDataConfigurations());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
index 8937504..c91f085 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java
@@ -78,6 +78,7 @@ import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -539,7 +540,8 @@ public class GridClientNioTcpConnection extends GridClientConnection {
GridClientMessage res0 = res;
if (res instanceof GridRouterResponse) {
- res0 = marsh.unmarshal(((GridRouterResponse)res).body());
+ res0 = MarshallerUtils.unmarshal(marsh, ((GridRouterResponse)res).body(),
+ ses.igniteConfiguration().getGridName());
res0.requestId(res.requestId());
res0.clientId(res.clientId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
index 83a6869..77b9f82 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.processors.rest.client.message.GridRouterRespo
import org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestParser;
import org.apache.ignite.internal.util.nio.GridNioSession;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerUtils;
import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.IGNITE_REQ_FLAG;
@@ -85,7 +86,7 @@ class GridTcpRouterNioParser extends GridTcpRestParser {
GridClientMessage clientMsg = (GridClientMessage)msg;
- ByteBuffer res = marsh.marshal(msg, 45);
+ ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.igniteConfiguration().getGridName());
ByteBuffer slice = res.slice();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
index 6b95dad..a2db860 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.checkpoint.CheckpointListener;
import org.apache.ignite.spi.checkpoint.CheckpointSpi;
@@ -173,7 +174,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
try {
switch (scope) {
case GLOBAL_SCOPE: {
- byte[] data = state == null ? null : marsh.marshal(state);
+ byte[] data = state == null ? null : MarshallerUtils.marshal(marsh, state, ctx.gridName());
saved = getSpi(ses.getCheckpointSpi()).saveCheckpoint(key, data, timeout, override);
@@ -204,7 +205,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
timeout = ses.getEndTime() - now;
// Save it first to avoid getting null value on another node.
- byte[] data = state == null ? null : marsh.marshal(state);
+ byte[] data = state == null ? null : MarshallerUtils.marshal(marsh, state, ctx.gridName());
Set<String> keys = keyMap.get(ses.getId());
@@ -337,8 +338,10 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
Serializable state = null;
// Always deserialize with task/session class loader.
- if (data != null)
- state = marsh.unmarshal(data, U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
+ if (data != null) {
+ state = MarshallerUtils.unmarshal(marsh, data,
+ U.resolveClassLoader(ses.getClassLoader(), ctx.config()), ctx.gridName());
+ }
record(EVT_CHECKPOINT_LOADED, key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 8ba6a1c..ff5b780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -67,6 +67,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.IoPool;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
@@ -594,7 +595,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
int topicOrd = msg.topicOrdinal();
msg.topic(topicOrd >= 0 ? GridTopic.fromOrdinal(topicOrd) :
- marsh.unmarshal(msg.topicBytes(), U.resolveClassLoader(ctx.config())));
+ MarshallerUtils.unmarshal(marsh, msg.topicBytes(), U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
if (!started) {
@@ -1117,7 +1118,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
}
else {
if (topicOrd < 0)
- ioMsg.topicBytes(marsh.marshal(topic));
+ ioMsg.topicBytes(MarshallerUtils.marshal(marsh, topic, ctx.gridName()));
try {
if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi)
@@ -1377,10 +1378,10 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
byte[] serTopic = null;
if (!loc) {
- serMsg = marsh.marshal(msg);
+ serMsg = MarshallerUtils.marshal(marsh, msg, ctx.gridName());
if (topic != null)
- serTopic = marsh.marshal(topic);
+ serTopic = MarshallerUtils.marshal(marsh, topic, ctx.gridName());
}
GridDeployment dep = null;
@@ -2037,8 +2038,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
// Unmarshall message topic if needed.
if (msgTopic == null && msgTopicBytes != null) {
- msgTopic = marsh.unmarshal(msgTopicBytes,
- U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
+ msgTopic = MarshallerUtils.unmarshal(marsh, msgTopicBytes,
+ U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()), ctx.gridName());
ioMsg.topic(msgTopic); // Save topic to avoid future unmarshallings.
}
@@ -2047,8 +2048,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
return;
if (msgBody == null) {
- msgBody = marsh.unmarshal(ioMsg.bodyBytes(),
- U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
+ msgBody = MarshallerUtils.unmarshal(marsh, ioMsg.bodyBytes(),
+ U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()), ctx.gridName());
ioMsg.body(msgBody); // Save body to avoid future unmarshallings.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index 76bd6e3..ba3b829 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteNotPeerDeployable;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -183,7 +184,8 @@ class GridDeploymentCommunication {
if (req.responseTopic() == null) {
try {
- req.responseTopic(marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
+ req.responseTopic(MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process deployment request (will ignore): " + req, e);
@@ -444,7 +446,7 @@ class GridDeploymentCommunication {
long start = U.currentTimeMillis();
if (req.responseTopic() != null && !ctx.localNodeId().equals(dstNode.id()))
- req.responseTopicBytes(marsh.marshal(req.responseTopic()));
+ req.responseTopicBytes(MarshallerUtils.marshal(marsh, req.responseTopic(), ctx.gridName()));
ctx.io().send(dstNode, TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 0095707..233110b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -58,6 +58,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.eventstorage.EventStorageSpi;
@@ -891,12 +892,12 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
try {
if (res.eventsBytes() != null)
- res.events(marsh.<Collection<Event>>unmarshal(res.eventsBytes(),
- U.resolveClassLoader(ctx.config())));
+ res.events(MarshallerUtils.<Collection<Event>>unmarshal(marsh, res.eventsBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
if (res.exceptionBytes() != null)
- res.exception(marsh.<Throwable>unmarshal(res.exceptionBytes(),
- U.resolveClassLoader(ctx.config())));
+ res.exception(MarshallerUtils.<Throwable>unmarshal(marsh, res.exceptionBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal events query response: " + msg, e);
@@ -932,7 +933,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ioMgr.addMessageListener(resTopic, resLsnr);
- byte[] serFilter = marsh.marshal(p);
+ byte[] serFilter = MarshallerUtils.marshal(marsh, p, ctx.gridName());
GridDeployment dep = ctx.deploy().deploy(p.getClass(), U.detectClassLoader(p.getClass()));
@@ -1023,7 +1024,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ctx.io().send(locNode, topic, msg, plc);
if (!rmtNodes.isEmpty()) {
- msg.responseTopicBytes(marsh.marshal(msg.responseTopic()));
+ msg.responseTopicBytes(MarshallerUtils.marshal(marsh, msg.responseTopic(), ctx.gridName()));
ctx.io().send(rmtNodes, topic, msg, plc);
}
@@ -1088,8 +1089,10 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
Collection<Event> evts;
try {
- if (req.responseTopicBytes() != null)
- req.responseTopic(marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
+ if (req.responseTopicBytes() != null) {
+ req.responseTopic(MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
+ }
GridDeployment dep = ctx.deploy().getGlobalDeployment(
req.deploymentMode(),
@@ -1105,7 +1108,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for event filter " +
"(is peer class loading turned on?): " + req);
- filter = marsh.unmarshal(req.filter(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ filter = MarshallerUtils.unmarshal(marsh, req.filter(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
// Resource injection.
ctx.resource().inject(dep, dep.deployedClass(req.filterClassName()), filter);
@@ -1140,8 +1144,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
log.debug("Sending event query response to node [nodeId=" + nodeId + "res=" + res + ']');
if (!ctx.localNodeId().equals(nodeId)) {
- res.eventsBytes(marsh.marshal(res.events()));
- res.exceptionBytes(marsh.marshal(res.exception()));
+ res.eventsBytes(MarshallerUtils.marshal(marsh, res.events(), ctx.gridName()));
+ res.exceptionBytes(MarshallerUtils.marshal(marsh, res.exception(), ctx.gridName()));
}
ctx.io().send(node, req.responseTopic(), res, PUBLIC_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index 437603a..b5e18d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.swapspace.SwapContext;
@@ -400,7 +401,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
if (swapBytes == null)
return null;
- return marsh.unmarshal(swapBytes, ldr != null ? ldr : U.gridClassLoader());
+ return MarshallerUtils.unmarshal(marsh, swapBytes, ldr != null ? ldr : U.gridClassLoader(), ctx.gridName());
}
/**
@@ -411,7 +412,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
* @throws IgniteCheckedException If failed.
*/
private byte[] marshal(Object obj) throws IgniteCheckedException {
- return ctx.config().getMarshaller().marshal(obj);
+ return MarshallerUtils.marshal(marsh, obj, ctx.gridName());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index f670960..e5d2085 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.lang.GridTuple3;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
import org.jetbrains.annotations.NotNull;
@@ -77,7 +78,7 @@ class GridAffinityUtils {
throw new IgniteDeploymentCheckedException("Failed to deploy affinity object with class: " + cls.getName());
return new GridAffinityMessage(
- ctx.config().getMarshaller().marshal(o),
+ MarshallerUtils.marshal(ctx.config().getMarshaller(), o, ctx.gridName()),
cls.getName(),
dep.classLoaderId(),
dep.deployMode(),
@@ -110,8 +111,8 @@ class GridAffinityUtils {
throw new IgniteDeploymentCheckedException("Failed to obtain affinity object (is peer class loading turned on?): " +
msg);
- Object src = ctx.config().getMarshaller().unmarshal(msg.source(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ Object src = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), msg.source(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
// Resource injection.
ctx.resource().inject(dep, dep.deployedClass(msg.sourceClassName()), src);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index 61b6db3..d0837bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -80,7 +81,8 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
assert p != null || bytes != null;
if (p == null) {
- p = ctx.marshaller().unmarshal(bytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ p = MarshallerUtils.unmarshal(ctx.marshaller(), bytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
p.finishUnmarshal(ctx, ldr);
}
@@ -92,7 +94,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
p.prepareMarshal(ctx);
- bytes = ctx.marshaller().marshal(p);
+ bytes = MarshallerUtils.marshal(ctx.marshaller(), p, ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index c6e8bee..a8d9caa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -24,6 +24,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -106,7 +107,7 @@ public class CacheInvokeDirectResult implements Message {
key.prepareMarshal(ctx.cacheObjectContext());
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
if (res != null)
res.prepareMarshal(ctx.cacheObjectContext());
@@ -120,8 +121,10 @@ public class CacheInvokeDirectResult implements Message {
public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
key.finishUnmarshal(ctx.cacheObjectContext(), ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
if (res != null)
res.finishUnmarshal(ctx.cacheObjectContext(), ldr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index f99d2cd..a0f4b06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -457,8 +458,10 @@ public abstract class GridCacheMessage implements Message {
Marshaller marsh = ctx.marshaller();
- for (int i = 0; i < byteCol.length; i++)
- args[i] = byteCol[i] == null ? null : marsh.unmarshal(byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
+ for (int i = 0; i < byteCol.length; i++) {
+ args[i] = byteCol[i] == null ? null : MarshallerUtils.unmarshal(marsh, byteCol[i],
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
return args;
}
@@ -608,8 +611,10 @@ public abstract class GridCacheMessage implements Message {
Marshaller marsh = ctx.marshaller();
- for (byte[] bytes : byteCol)
- col.add(bytes == null ? null : marsh.<T>unmarshal(bytes, U.resolveClassLoader(ldr, ctx.gridConfig())));
+ for (byte[] bytes : byteCol) {
+ col.add(bytes == null ? null : MarshallerUtils.<T>unmarshal(marsh, bytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName()));
+ }
return col;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 6761fac..e6ba3ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -118,6 +118,7 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.spi.IgniteNodeValidationResult;
import org.jetbrains.annotations.Nullable;
@@ -3397,8 +3398,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (ldr == null)
ldr = val.getCacheStoreFactory().getClass().getClassLoader();
- marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
- U.resolveClassLoader(ldr, ctx.config()));
+ MarshallerUtils.clone(marshaller, val.getCacheStoreFactory(),
+ U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration. " +
@@ -3407,7 +3408,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
try {
- return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config()));
+ return MarshallerUtils.clone(marshaller, val, U.resolveClassLoader(ctx.config()), ctx.gridName());
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index ba563e6..fc51e84 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -92,6 +92,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.CachePluginConfiguration;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -991,7 +992,7 @@ public class GridCacheUtils {
}
}
- return ctx.marshaller().marshal(obj);
+ return MarshallerUtils.marshal(ctx.marshaller(), obj, ctx.gridName());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index f56ba8f..31cc588 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -202,7 +203,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@@ -211,8 +212,10 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
finishUnmarshalCacheObjects(vals, ctx.cacheContext(cacheId), ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index 871a599..ae394d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -332,7 +333,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
// Marshal txNodes only if there is a node in topology with an older version.
if (ctx.exchange().minimumNodeVersion(topologyVersion()).compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
if (txNodes != null && txNodesBytes == null)
- txNodesBytes = ctx.marshaller().marshal(txNodes);
+ txNodesBytes = MarshallerUtils.marshal(ctx.marshaller(), txNodes, ctx.gridName());
}
else {
if (txNodesMsg == null)
@@ -372,7 +373,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
txNodes = F.viewReadOnly(txNodesMsg, MSG_TO_COL);
if (txNodesBytes != null && txNodes == null)
- txNodes = ctx.marshaller().unmarshal(txNodesBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ txNodes = MarshallerUtils.unmarshal(ctx.marshaller(), txNodesBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index 7011e80..7c47b2b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -100,15 +101,17 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
super.prepareMarshal(ctx);
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index c1be30b..f3ac402 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -106,7 +107,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
super.prepareMarshal(ctx);
if (affAssignment != null)
- affAssignmentBytes = ctx.marshaller().marshal(affAssignment);
+ affAssignmentBytes = MarshallerUtils.marshal(ctx.marshaller(), affAssignment, ctx.gridName());
}
/** {@inheritDoc} */
@@ -115,7 +116,8 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
super.finishUnmarshal(ctx, ldr);
if (affAssignmentBytes != null) {
- affAssignment = ctx.marshaller().unmarshal(affAssignmentBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ affAssignment = MarshallerUtils.unmarshal(ctx.marshaller(), affAssignmentBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
// TODO IGNITE-2110: setting 'local' for nodes not needed when IGNITE-2110 is implemented.
int assignments = affAssignment.size();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index 65c9024..7beb1d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -111,7 +112,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (checkCommittedErr != null)
- checkCommittedErrBytes = ctx.marshaller().marshal(checkCommittedErr);
+ checkCommittedErrBytes = MarshallerUtils.marshal(ctx.marshaller(), checkCommittedErr, ctx.gridName());
}
/** {@inheritDoc} */
@@ -119,8 +120,10 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (checkCommittedErrBytes != null)
- checkCommittedErr = ctx.marshaller().unmarshal(checkCommittedErrBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (checkCommittedErrBytes != null) {
+ checkCommittedErr = MarshallerUtils.unmarshal(ctx.marshaller(), checkCommittedErrBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index 742b39c..688c439 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -167,7 +168,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
prepareMarshalCacheObjects(nearEvicted, cctx);
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@@ -180,7 +181,8 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
finishUnmarshalCacheObjects(nearEvicted, cctx, ldr);
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index 1d03dd2..8edf383 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -1,3 +1,5 @@
+// if (expiryPlcBytes != null && expiryPlc == null)
+// expiryPlc = MarshallerUtils.unmarshal(ctx.marshaller(), expiryPlcBytes, ldr, ctx.kernalContext());
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -45,6 +47,7 @@ import org.apache.ignite.internal.util.GridLongList;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -633,8 +636,10 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
- if (expiryPlcBytes != null)
- expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (expiryPlcBytes != null) {
+ expiryPlc = MarshallerUtils.unmarshal(ctx.marshaller(), expiryPlcBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index dd52aae..ed923b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.GridLongList;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -397,7 +398,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
super.prepareMarshal(ctx);
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
GridCacheContext cctx = ctx.cacheContext(cacheId);
@@ -415,8 +416,10 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
GridCacheContext cctx = ctx.cacheContext(cacheId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index 12bf160..4b49730 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -171,7 +172,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
info.marshal(cctx);
}
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@@ -188,8 +189,10 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
info.unmarshal(cctx, ldr);
}
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 4426c44..cbc01be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -183,15 +184,17 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
super.prepareMarshal(ctx);
if (topic != null)
- topicBytes = ctx.marshaller().marshal(topic);
+ topicBytes = MarshallerUtils.marshal(ctx.marshaller(), topic, ctx.gridName());
}
/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (topicBytes != null)
- topic = ctx.marshaller().unmarshal(topicBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (topicBytes != null) {
+ topic = MarshallerUtils.unmarshal(ctx.marshaller(), topicBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
[29/50] [abbrv] ignite git commit: IGNITE-2649 -
Ignition.localIgnite() unreliable under Gateways and cause wrong components
deserialization.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 6194552..a1f6700 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -133,10 +134,10 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
super.prepareMarshal(ctx);
if (parts != null && partsBytes == null)
- partsBytes = ctx.marshaller().marshal(parts);
+ partsBytes = MarshallerUtils.marshal(ctx.marshaller(), parts, ctx.gridName());
if (partCntrs != null)
- partCntrsBytes = ctx.marshaller().marshal(partCntrs);
+ partCntrsBytes = MarshallerUtils.marshal(ctx.marshaller(), partCntrs, ctx.gridName());
}
/**
@@ -157,14 +158,18 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (partsBytes != null && parts == null)
- parts = ctx.marshaller().unmarshal(partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (partsBytes != null && parts == null) {
+ parts = MarshallerUtils.unmarshal(ctx.marshaller(), partsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
if (parts == null)
parts = new HashMap<>();
- if (partCntrsBytes != null && partCntrs == null)
- partCntrs = ctx.marshaller().unmarshal(partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (partCntrsBytes != null && partCntrs == null) {
+ partCntrs = MarshallerUtils.unmarshal(ctx.marshaller(), partCntrsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
if (partCntrs == null)
partCntrs = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 0fe4259..3be312b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -137,21 +138,25 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
super.prepareMarshal(ctx);
if (partsBytes == null && parts != null)
- partsBytes = ctx.marshaller().marshal(parts);
+ partsBytes = MarshallerUtils.marshal(ctx.marshaller(), parts, ctx.gridName());
if (partCntrs != null)
- partCntrsBytes = ctx.marshaller().marshal(partCntrs);
+ partCntrsBytes = MarshallerUtils.marshal(ctx.marshaller(), partCntrs, ctx.gridName());
}
/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (partsBytes != null && parts == null)
- parts = ctx.marshaller().unmarshal(partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (partsBytes != null && parts == null) {
+ parts = MarshallerUtils.unmarshal(ctx.marshaller(), partsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
- if (partCntrsBytes != null)
- partCntrs = ctx.marshaller().unmarshal(partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (partCntrsBytes != null) {
+ partCntrs = MarshallerUtils.unmarshal(ctx.marshaller(), partCntrsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index be92551..ff1a373 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -190,7 +191,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
}
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@@ -204,8 +205,10 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
info.unmarshal(cctx, ldr);
}
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
index e8d164f..e290310 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -169,7 +170,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
}
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@@ -187,8 +188,10 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
((GridCacheEntryInfo)res).unmarshal(cctx, ldr);
}
- if (errBytes != null && err == null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null && err == null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 4055b2a..809e11c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -101,15 +102,17 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
}
/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
index 91ae12c..d524d70 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
/**
* Local query future.
@@ -112,13 +113,13 @@ public class GridCacheLocalQueryFuture<K, V, R> extends GridCacheQueryFutureAdap
Marshaller marsh = cctx.marshaller();
- IgniteReducer<Object, Object> rdc = qry.reducer() != null ?
- marsh.<IgniteReducer<Object, Object>>unmarshal(marsh.marshal(qry.reducer()),
- U.resolveClassLoader(cctx.gridConfig())) : null;
+ IgniteReducer<Object, Object> rdc = qry.reducer() != null
+ ? MarshallerUtils.clone(marsh, qry.reducer(), U.resolveClassLoader(cctx.gridConfig()), cctx.gridName())
+ : null;
- IgniteClosure<Object, Object> trans = qry.transform() != null ?
- marsh.<IgniteClosure<Object, Object>>unmarshal(marsh.marshal(qry.transform()),
- U.resolveClassLoader(cctx.gridConfig())) : null;
+ IgniteClosure<Object, Object> trans = qry.transform() != null
+ ? MarshallerUtils.clone(marsh, qry.transform(), U.resolveClassLoader(cctx.gridConfig()), cctx.gridName())
+ : null;
return new GridCacheQueryInfo(
true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index 88ebe99..b5a6fe2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -316,19 +317,25 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- Marshaller mrsh = ctx.marshaller();
+ Marshaller marsh = ctx.marshaller();
- if (keyValFilterBytes != null)
- keyValFilter = mrsh.unmarshal(keyValFilterBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (keyValFilterBytes != null) {
+ keyValFilter = MarshallerUtils.unmarshal(marsh, keyValFilterBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
if (rdcBytes != null)
- rdc = mrsh.unmarshal(rdcBytes, ldr);
+ rdc = MarshallerUtils.unmarshal(marsh, rdcBytes, ldr, ctx.gridName());
- if (transBytes != null)
- trans = mrsh.unmarshal(transBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (transBytes != null) {
+ trans = MarshallerUtils.unmarshal(marsh, transBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
- if (argsBytes != null)
- args = mrsh.unmarshal(argsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (argsBytes != null) {
+ args = MarshallerUtils.unmarshal(marsh, argsBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
}
/** {@inheritDoc} */
@@ -343,10 +350,10 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
void beforeLocalExecution(GridCacheContext ctx) throws IgniteCheckedException {
Marshaller marsh = ctx.marshaller();
- rdc = rdc != null ? marsh.<IgniteReducer<Object, Object>>unmarshal(marsh.marshal(rdc),
- U.resolveClassLoader(ctx.gridConfig())) : null;
- trans = trans != null ? marsh.<IgniteClosure<Object, Object>>unmarshal(marsh.marshal(trans),
- U.resolveClassLoader(ctx.gridConfig())) : null;
+ rdc = rdc != null ? MarshallerUtils.clone(marsh, rdc,
+ U.resolveClassLoader(ctx.gridConfig()), ctx.gridName()) : null;
+ trans = trans != null ? MarshallerUtils.clone(marsh, trans,
+ U.resolveClassLoader(ctx.gridConfig()), ctx.gridName()) : null;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 2cde8f4..28ae466 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -124,7 +125,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (err != null)
- errBytes = ctx.marshaller().marshal(err);
+ errBytes = MarshallerUtils.marshal(ctx.marshaller(), err, ctx.gridName());
metaDataBytes = marshalCollection(metadata, cctx);
dataBytes = marshalCollection(data, cctx);
@@ -145,8 +146,10 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (errBytes != null)
- err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ if (errBytes != null) {
+ err = MarshallerUtils.unmarshal(ctx.marshaller(), errBytes,
+ U.resolveClassLoader(ldr, ctx.gridConfig()), ctx.gridName());
+ }
metadata = unmarshalCollection(metaDataBytes, ctx, ldr);
data = unmarshalCollection(dataBytes, ctx, ldr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index 0733827..df6621f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -132,19 +133,21 @@ public class GridCacheSqlQuery implements Message {
/**
* @param m Marshaller.
+ * @param kernalCtx kernal context.
* @throws IgniteCheckedException If failed.
*/
- public void marshallParams(Marshaller m) throws IgniteCheckedException {
+ public void marshallParams(Marshaller m, final GridKernalContext kernalCtx) throws IgniteCheckedException {
if (paramsBytes != null)
return;
assert params != null;
- paramsBytes = m.marshal(params);
+ paramsBytes = MarshallerUtils.marshal(m, params, kernalCtx.gridName());
}
/**
* @param m Marshaller.
+ * @param ctx kernal context.
* @throws IgniteCheckedException If failed.
*/
public void unmarshallParams(Marshaller m, GridKernalContext ctx) throws IgniteCheckedException {
@@ -153,7 +156,7 @@ public class GridCacheSqlQuery implements Message {
assert paramsBytes != null;
- params = m.unmarshal(paramsBytes, U.resolveClassLoader(ctx.config()));
+ params = MarshallerUtils.unmarshal(m, paramsBytes, U.resolveClassLoader(ctx.config()), ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index fc38eba..a9cf668 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -77,6 +77,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteAsyncCallback;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.thread.IgniteStripedThreadPoolExecutor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1541,7 +1542,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
depInfo = new GridDeploymentInfoBean(dep);
- bytes = ctx.config().getMarshaller().marshal(obj);
+ bytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), obj, ctx.gridName());
}
/**
@@ -1559,7 +1560,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
- return ctx.config().getMarshaller().unmarshal(bytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ return MarshallerUtils.unmarshal(ctx.config().getMarshaller(), bytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
index a8b2da4..ec242f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
@@ -153,7 +154,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 0;
- data = MARSHALLER.marshal(F.asList(schemasMap, indexesInfo));
+ data = MarshallerUtils.marshal(MARSHALLER, F.asList(schemasMap, indexesInfo), ignite.configuration());
}
catch (Throwable t) {
U.error(log, "Failed to get metadata for JDBC.", t);
@@ -163,7 +164,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
status = 1;
try {
- data = MARSHALLER.marshal(err);
+ data = MarshallerUtils.marshal(MARSHALLER, err, ignite.configuration());
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index 5c60762..3faca1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -52,6 +52,7 @@ import org.apache.ignite.internal.util.typedef.CAX;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
@@ -82,7 +83,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
try {
assert arg != null;
- Map<String, Object> args = MARSHALLER.unmarshal(arg, null);
+ Map<String, Object> args = MarshallerUtils.unmarshal(MARSHALLER, arg, null, ignite.configuration());
boolean first = true;
@@ -130,12 +131,13 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
if (res.getException() == null) {
status = 0;
- bytes = MARSHALLER.marshal(res.getData());
+ bytes = MarshallerUtils.marshal(MARSHALLER, res.getData(), ignite.configuration());
}
else {
status = 1;
- bytes = MARSHALLER.marshal(new SQLException(res.getException().getMessage()));
+ bytes = MarshallerUtils.marshal(MARSHALLER, new SQLException(res.getException().getMessage()),
+ ignite.configuration());
}
byte[] packet = new byte[bytes.length + 1];
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 3258ce9..8bbe151 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -48,6 +48,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
@@ -878,8 +879,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
// Unmarshal transform closure anyway if it exists.
if (transformClosBytes != null && entryProcessorsCol == null)
- entryProcessorsCol = ctx.marshaller().unmarshal(transformClosBytes,
- U.resolveClassLoader(clsLdr, ctx.gridConfig()));
+ entryProcessorsCol = MarshallerUtils.unmarshal(ctx.marshaller(),
+ transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()), ctx.gridName());
if (filters == null)
filters = CU.empty0();
@@ -894,8 +895,10 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
val.unmarshal(this.ctx, clsLdr);
- if (expiryPlcBytes != null)
- expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()));
+ if (expiryPlcBytes != null) {
+ expiryPlc = MarshallerUtils.unmarshal(ctx.marshaller(), expiryPlcBytes,
+ U.resolveClassLoader(clsLdr, ctx.gridConfig()), ctx.gridName());
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
index 4c5a704..2c64209 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -191,7 +192,8 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
unmarshalKey(ctx, marsh);
if (val == null && valBytes != null) {
- val = marsh.unmarshal(valBytes, U.resolveClassLoader(ctx.kernalContext().config()));
+ val = MarshallerUtils.unmarshal(marsh, valBytes,
+ U.resolveClassLoader(ctx.kernalContext().config()), ctx.kernalContext().gridName());
val.finishUnmarshal(ctx, null);
}
@@ -222,7 +224,8 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
if (key == null) {
assert keyBytes != null;
- key = marsh.unmarshal(keyBytes, U.resolveClassLoader(ctx.kernalContext().config()));
+ key = MarshallerUtils.unmarshal(marsh, keyBytes,
+ U.resolveClassLoader(ctx.kernalContext().config()), ctx.kernalContext().gridName());
key.finishUnmarshal(ctx, null);
}
@@ -239,13 +242,13 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
if (keyBytes == null) {
key.prepareMarshal(ctx);
- keyBytes = marsh.marshal(key);
+ keyBytes = MarshallerUtils.marshal(marsh, key, ctx.kernalContext().gridName());
}
if (valBytes == null && val != null) {
val.prepareMarshal(ctx);
- valBytes = marsh.marshal(val);
+ valBytes = MarshallerUtils.marshal(marsh, val, ctx.kernalContext().gridName());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 6630c7a..d46fdbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
@@ -107,8 +108,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
@Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
throws IgniteCheckedException
{
- return ctx.kernalContext().cache().context().marshaller().unmarshal(bytes, U.resolveClassLoader(clsLdr,
- ctx.kernalContext().config()));
+ return MarshallerUtils.unmarshal(ctx.kernalContext().cache().context().marshaller(),
+ bytes, U.resolveClassLoader(clsLdr, ctx.kernalContext().config()), ctx.kernalContext().gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/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 1a96954..e17c3fe 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
@@ -70,6 +70,7 @@ import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.LoadBalancerResource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1144,16 +1145,16 @@ public class GridClosureProcessor extends GridProcessorAdapter {
if (closureBytes == null) {
closure = c.job;
- closureBytes = marsh.marshal(c.job);
+ closureBytes = MarshallerUtils.marshal(marsh, c.job, ctx.gridName());
}
if (c.job == closure)
- c.job = marsh.unmarshal(closureBytes, U.resolveClassLoader(ctx.config()));
+ c.job = MarshallerUtils.unmarshal(marsh, closureBytes, U.resolveClassLoader(ctx.config()), ctx.gridName());
else
- c.job = marsh.unmarshal(marsh.marshal(c.job), U.resolveClassLoader(ctx.config()));
+ c.job = MarshallerUtils.clone(marsh, c.job, U.resolveClassLoader(ctx.config()), ctx.gridName());
}
else
- job = marsh.unmarshal(marsh.marshal(job), U.resolveClassLoader(ctx.config()));
+ job = MarshallerUtils.clone(marsh, job, U.resolveClassLoader(ctx.config()), ctx.gridName());
}
else
hadLocNode = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index e96e646..388487f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -77,6 +77,7 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
@@ -288,7 +289,8 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (msg.data() == null && msg.dataBytes() != null) {
try {
- msg.data(marsh.unmarshal(msg.dataBytes(), U.resolveClassLoader(ctx.config())));
+ msg.data(MarshallerUtils.unmarshal(marsh, msg.dataBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
@@ -676,7 +678,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
reqData.className(clsName);
reqData.deploymentInfo(new GridDeploymentInfoBean(dep));
- reqData.p2pMarshal(marsh);
+ reqData.p2pMarshal(marsh, ctx);
}
// Handle peer deployment for other handler-specific objects.
@@ -733,7 +735,8 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (msg.data() == null && msg.dataBytes() != null) {
try {
- msg.data(marsh.unmarshal(msg.dataBytes(), U.resolveClassLoader(ctx.config())));
+ msg.data(MarshallerUtils.unmarshal(marsh, msg.dataBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
@@ -976,7 +979,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
- data.p2pUnmarshal(marsh, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ data.p2pUnmarshal(marsh, U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx);
}
hnd.p2pUnmarshal(node.id(), ctx);
@@ -1321,7 +1324,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (!msg.messages() &&
msg.data() != null &&
(nodes.size() > 1 || !ctx.localNodeId().equals(F.first(nodes).id())))
- msg.dataBytes(marsh.marshal(msg.data()));
+ msg.dataBytes(MarshallerUtils.marshal(marsh, msg.data(), ctx.gridName()));
for (ClusterNode node : nodes) {
int cnt = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
index cdfe0e1..be4562a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
@@ -23,11 +23,13 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
/**
@@ -90,26 +92,29 @@ class StartRequestData implements Externalizable {
/**
* @param marsh Marshaller.
+ * @param kernalCtx Kernal context.
* @throws org.apache.ignite.IgniteCheckedException In case of error.
*/
- void p2pMarshal(Marshaller marsh) throws IgniteCheckedException {
+ void p2pMarshal(Marshaller marsh, final GridKernalContext kernalCtx) throws IgniteCheckedException {
assert marsh != null;
- prjPredBytes = marsh.marshal(prjPred);
+ prjPredBytes = MarshallerUtils.marshal(marsh, prjPred, kernalCtx.gridName());
}
/**
* @param marsh Marshaller.
* @param ldr Class loader.
+ * @param kernalCtx Kernal context.
* @throws org.apache.ignite.IgniteCheckedException In case of error.
*/
- void p2pUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
+ void p2pUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr,
+ final GridKernalContext kernalCtx) throws IgniteCheckedException {
assert marsh != null;
assert prjPred == null;
assert prjPredBytes != null;
- prjPred = marsh.unmarshal(prjPredBytes, ldr);
+ prjPred = MarshallerUtils.unmarshal(marsh, prjPredBytes, ldr, kernalCtx.gridName());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index c7c1f5e..146a864 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.stream.StreamReceiver;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
@@ -90,8 +91,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
if (ctx.config().isDaemon())
return;
- marshErrBytes = marsh.marshal(new IgniteCheckedException("Failed to marshal response error, " +
- "see node log for details."));
+ marshErrBytes = MarshallerUtils.marshal(marsh, new IgniteCheckedException("Failed to marshal response error, " +
+ "see node log for details."), ctx.gridName());
flusher = new IgniteThread(new GridWorker(ctx.gridName(), "grid-data-loader-flusher", log) {
@Override protected void body() throws InterruptedException {
@@ -235,7 +236,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
Object topic;
try {
- topic = marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(null, ctx.config()));
+ topic = MarshallerUtils.unmarshal(marsh, req.responseTopicBytes(),
+ U.resolveClassLoader(null, ctx.config()), ctx.gridName());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal topic from request: " + req, e);
@@ -275,7 +277,8 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
StreamReceiver<K, V> updater;
try {
- updater = marsh.unmarshal(req.updaterBytes(), U.resolveClassLoader(clsLdr, ctx.config()));
+ updater = MarshallerUtils.unmarshal(marsh, req.updaterBytes(),
+ U.resolveClassLoader(clsLdr, ctx.config()), ctx.gridName());
if (updater != null)
ctx.resource().injectGeneric(updater);
@@ -329,7 +332,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
byte[] errBytes;
try {
- errBytes = err != null ? marsh.marshal(err) : null;
+ errBytes = err != null ? MarshallerUtils.marshal(marsh, err, ctx.gridName()) : null;
}
catch (Exception e) {
U.error(log, "Failed to marshal error [err=" + err + ", marshErr=" + e + ']', e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 21df559..066c789 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -98,6 +98,7 @@ import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.stream.StreamReceiver;
import org.jetbrains.annotations.Nullable;
@@ -1359,11 +1360,11 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
if (updaterBytes == null) {
assert rcvr != null;
- updaterBytes = ctx.config().getMarshaller().marshal(rcvr);
+ updaterBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), rcvr, ctx.gridName());
}
if (topicBytes == null)
- topicBytes = ctx.config().getMarshaller().marshal(topic);
+ topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal (request will not be sent).", e);
@@ -1494,9 +1495,8 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
try {
GridPeerDeployAware jobPda0 = jobPda;
- err = ctx.config().getMarshaller().unmarshal(
- errBytes,
- U.resolveClassLoader(jobPda0 != null ? jobPda0.classLoader() : null, ctx.config()));
+ err = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), errBytes,
+ U.resolveClassLoader(jobPda0 != null ? jobPda0.classLoader() : null, ctx.config()), ctx.gridName());
}
catch (IgniteCheckedException e) {
f.onDone(null, new IgniteCheckedException("Failed to unmarshal response.", e));
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index 0bf3dde..646d492 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -21,8 +21,10 @@ import java.io.Externalizable;
import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -92,19 +94,20 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
- super.prepareMarshal(marsh);
+ @Override public void prepareMarshal(Marshaller marsh, final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ super.prepareMarshal(marsh, kernalCtx);
if (err != null)
- errBytes = marsh.marshal(err);
+ errBytes = MarshallerUtils.marshal(marsh, err, kernalCtx.gridName());
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
- super.finishUnmarshal(marsh, ldr);
+ @Override public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr,
+ final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ super.finishUnmarshal(marsh, ldr, kernalCtx);
if (errBytes != null)
- err = marsh.unmarshal(errBytes, ldr);
+ err = MarshallerUtils.unmarshal(marsh, errBytes, ldr, kernalCtx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
index 412c45b..d1d40e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.igfs;
import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -34,18 +35,21 @@ public abstract class IgfsCommunicationMessage implements Message {
/**
* @param marsh Marshaller.
+ * @param kernalCtx Kernal ctx.
* @throws IgniteCheckedException In case of error.
*/
- public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
+ public void prepareMarshal(Marshaller marsh, final GridKernalContext kernalCtx) throws IgniteCheckedException {
// No-op.
}
/**
* @param marsh Marshaller.
* @param ldr Class loader.
+ * @param kernalCtx Kernal ctx.
* @throws IgniteCheckedException In case of error.
*/
- public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
+ public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr,
+ final GridKernalContext kernalCtx) throws IgniteCheckedException {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
index a638bf3..76290e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
@@ -148,7 +148,7 @@ public class IgfsContext {
public void send(UUID nodeId, Object topic, IgfsCommunicationMessage msg, byte plc)
throws IgniteCheckedException {
if (!kernalContext().localNodeId().equals(nodeId))
- msg.prepareMarshal(kernalContext().config().getMarshaller());
+ msg.prepareMarshal(kernalContext().config().getMarshaller(), kernalContext());
kernalContext().io().send(nodeId, topic, msg, plc);
}
@@ -163,7 +163,7 @@ public class IgfsContext {
public void send(ClusterNode node, Object topic, IgfsCommunicationMessage msg, byte plc)
throws IgniteCheckedException {
if (!kernalContext().localNodeId().equals(node.id()))
- msg.prepareMarshal(kernalContext().config().getMarshaller());
+ msg.prepareMarshal(kernalContext().config().getMarshaller(), kernalContext());
kernalContext().io().send(node, topic, msg, plc);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index bdf3b08..ed1f525 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -1149,7 +1149,7 @@ public class IgfsDataManager extends IgfsManager {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void processAckMessage(UUID nodeId, IgfsAckMessage ackMsg) {
try {
- ackMsg.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null);
+ ackMsg.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null, igfsCtx.kernalContext());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal message (will ignore): " + ackMsg, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index e59b257..7e206e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -21,9 +21,11 @@ import java.io.Externalizable;
import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -91,19 +93,21 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
- super.prepareMarshal(marsh);
+ @Override public void prepareMarshal(Marshaller marsh,
+ final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ super.prepareMarshal(marsh, kernalCtx);
if (err != null)
- errBytes = marsh.marshal(err);
+ errBytes = MarshallerUtils.marshal(marsh, err, kernalCtx.gridName());
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
- super.finishUnmarshal(marsh, ldr);
+ @Override public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr,
+ final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ super.finishUnmarshal(marsh, ldr, kernalCtx);
if (errBytes != null)
- err = marsh.unmarshal(errBytes, ldr);
+ err = MarshallerUtils.unmarshal(marsh, errBytes, ldr, kernalCtx.gridName());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index d64c64a..e04445f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -263,7 +263,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
*/
@SuppressWarnings("fallthrough")
private void processFragmentizerRequest(IgfsFragmentizerRequest req) throws IgniteCheckedException {
- req.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null);
+ req.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null, igfsCtx.kernalContext());
Collection<IgfsFileAffinityRange> ranges = req.fragmentRanges();
IgniteUuid fileId = req.fileId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index 7234e52..a25d082 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -256,7 +256,7 @@ public final class IgfsImpl implements IgfsEx {
if (secondaryFs instanceof HadoopPayloadAware)
secondaryFsPayload = ((HadoopPayloadAware) secondaryFs).getPayload();
- secondaryPaths = new IgfsPaths(secondaryFsPayload, dfltMode, modeRslvr.modesOrdered());
+ secondaryPaths = new IgfsPaths(secondaryFsPayload, dfltMode, modeRslvr.modesOrdered(), igfsCtx);
// Check whether IGFS LRU eviction policy is set on data cache.
String dataCacheName = igfsCtx.configuration().getDataCacheName();
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
index 4a79259..7571797 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
@@ -31,6 +31,7 @@ import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.jetbrains.annotations.Nullable;
@@ -63,9 +64,11 @@ public class IgfsPaths implements Externalizable {
* @param payload Payload.
* @param dfltMode Default IGFS mode.
* @param pathModes Path modes.
+ * @param igfsCtx Ignite FS context.
* @throws IgniteCheckedException If failed.
*/
- public IgfsPaths(Object payload, IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> pathModes)
+ public IgfsPaths(Object payload, IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> pathModes,
+ final IgfsContext igfsCtx)
throws IgniteCheckedException {
this.dfltMode = dfltMode;
this.pathModes = pathModes;
@@ -75,7 +78,7 @@ public class IgfsPaths implements Externalizable {
else {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- new JdkMarshaller().marshal(payload, out);
+ MarshallerUtils.marshal(new JdkMarshaller(), payload, out, igfsCtx.kernalContext().config().getGridName());
payloadBytes = out.toByteArray();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 906d298..baf80e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -76,6 +76,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -403,7 +404,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(taskNode.id()) && !ctx.config().isMarshalLocalJobs();
GridTaskSessionRequest req = new GridTaskSessionRequest(ses.getId(), ses.getJobId(),
- loc ? null : marsh.marshal(attrs), attrs);
+ loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()), attrs);
Object topic = TOPIC_TASK.topic(ses.getJobId(), ctx.discovery().localNode().id());
@@ -454,7 +455,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (res.jobSiblings() == null) {
try {
- res.unmarshalSiblings(marsh);
+ res.unmarshalSiblings(marsh, ctx);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal job siblings.", e);
@@ -516,7 +517,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
ctx.io().send(taskNode, TOPIC_JOB_SIBLINGS,
new GridJobSiblingsRequest(ses.getId(),
loc ? topic : null,
- loc ? null : marsh.marshal(topic)),
+ loc ? null : MarshallerUtils.marshal(marsh, topic, ctx.gridName())),
SYSTEM_POOL);
// 4. Listen to discovery events.
@@ -1018,7 +1019,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (siblings0 == null) {
assert req.getSiblingsBytes() != null;
- siblings0 = marsh.unmarshal(req.getSiblingsBytes(), U.resolveClassLoader(ctx.config()));
+ siblings0 = MarshallerUtils.unmarshal(marsh, req.getSiblingsBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName());
}
siblings = new ArrayList<>(siblings0);
@@ -1029,9 +1031,10 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (req.isSessionFullSupport()) {
sesAttrs = req.getSessionAttributes();
- if (sesAttrs == null)
- sesAttrs = marsh.unmarshal(req.getSessionAttributesBytes(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ if (sesAttrs == null) {
+ sesAttrs = MarshallerUtils.unmarshal(marsh, req.getSessionAttributesBytes(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ }
}
// Note that we unmarshal session/job attributes here with proper class loader.
@@ -1056,9 +1059,10 @@ public class GridJobProcessor extends GridProcessorAdapter {
Map<? extends Serializable, ? extends Serializable> jobAttrs = req.getJobAttributes();
- if (jobAttrs == null)
- jobAttrs = marsh.unmarshal(req.getJobAttributesBytes(),
- U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ if (jobAttrs == null) {
+ jobAttrs = MarshallerUtils.unmarshal(marsh, req.getJobAttributesBytes(),
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
+ }
jobCtx = new GridJobContextImpl(ctx, req.getJobId(), jobAttrs);
}
@@ -1330,11 +1334,11 @@ public class GridJobProcessor extends GridProcessorAdapter {
locNodeId,
req.getSessionId(),
req.getJobId(),
- loc ? null : marsh.marshal(ex),
+ loc ? null : MarshallerUtils.marshal(marsh, ex, ctx.gridName()),
ex,
- loc ? null : marsh.marshal(null),
+ loc ? null : MarshallerUtils.marshal(marsh, null, ctx.gridName()),
null,
- loc ? null : marsh.marshal(null),
+ loc ? null : MarshallerUtils.marshal(marsh, null, ctx.gridName()),
null,
false);
@@ -1425,8 +1429,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
Map<?, ?> attrs = loc ? req.getAttributes() :
- (Map<?, ?>)marsh.unmarshal(req.getAttributesBytes(),
- U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
+ (Map<?, ?>)MarshallerUtils.unmarshal(marsh, req.getAttributesBytes(),
+ U.resolveClassLoader(ses.getClassLoader(), ctx.config()), ctx.gridName());
if (ctx.event().isRecordable(EVT_TASK_SESSION_ATTR_SET)) {
Event evt = new TaskEvent(
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index 164c9e7..3d17c62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -54,6 +54,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVT_JOB_CANCELLED;
@@ -406,7 +407,8 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
try {
if (job == null) {
- job = marsh.unmarshal(jobBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+ job = MarshallerUtils.unmarshal(marsh, jobBytes,
+ U.resolveClassLoader(dep.classLoader(), ctx.config()), ctx.gridName());
// No need to hold reference any more.
jobBytes = null;
@@ -744,11 +746,11 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
ctx.localNodeId(),
ses.getId(),
ses.getJobId(),
- loc ? null : marsh.marshal(ex),
+ loc ? null : MarshallerUtils.marshal(marsh, ex, ctx.gridName()),
loc ? ex : null,
- loc ? null: marsh.marshal(res),
+ loc ? null: MarshallerUtils.marshal(marsh, res, ctx.gridName()),
loc ? res : null,
- loc ? null : marsh.marshal(attrs),
+ loc ? null : MarshallerUtils.marshal(marsh, attrs, ctx.gridName()),
loc ? attrs : null,
isCancelled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
index d9d4421..8d4e75e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -108,7 +109,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
private byte[] keyBytes(KeyCacheObject key, @Nullable byte[] keyBytes) throws IgniteCheckedException {
assert key != null;
- return keyBytes != null ? keyBytes : marsh.marshal(key);
+ return keyBytes != null ? keyBytes : MarshallerUtils.marshal(marsh, key, ctx.gridName());
}
/**
@@ -212,7 +213,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
if (valBytes == null)
return null;
- return marsh.unmarshal(valBytes, U.resolveClassLoader(ldr, ctx.config()));
+ return MarshallerUtils.unmarshal(marsh, valBytes, U.resolveClassLoader(ldr, ctx.config()), ctx.gridName());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index 6937196..b6adfca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -63,6 +63,7 @@ import org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
@@ -135,14 +136,14 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
res.error(err.getMessage());
else {
res.result(desc.result());
- res.resultBytes(ctx.config().getMarshaller().marshal(desc.result()));
+ res.resultBytes(MarshallerUtils.marshal(ctx.config().getMarshaller(), desc.result(), ctx.gridName()));
}
}
else
res.found(false);
- Object topic = ctx.config().getMarshaller().unmarshal(req.topicBytes(),
- U.resolveClassLoader(ctx.config()));
+ Object topic = MarshallerUtils.unmarshal(ctx.config().getMarshaller(), req.topicBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName());
ctx.io().send(nodeId, topic, res, SYSTEM_POOL);
}
@@ -440,8 +441,8 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
res = (GridTaskResultResponse)msg;
try {
- res.result(ctx.config().getMarshaller().unmarshal(res.resultBytes(),
- U.resolveClassLoader(ctx.config())));
+ res.result(MarshallerUtils.unmarshal(ctx.config().getMarshaller(), res.resultBytes(),
+ U.resolveClassLoader(ctx.config()), ctx.gridName()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal task result: " + res, e);
@@ -494,7 +495,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
// 2. Send message.
try {
- byte[] topicBytes = ctx.config().getMarshaller().marshal(topic);
+ byte[] topicBytes = MarshallerUtils.marshal(ctx.config().getMarshaller(), topic, ctx.gridName());
ctx.io().send(taskNode, TOPIC_REST, new GridTaskResultRequest(taskId, topic, topicBytes), SYSTEM_POOL);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 5beff75..21f105d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -25,6 +25,7 @@ import java.nio.charset.Charset;
import java.util.Date;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
import org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponse;
@@ -39,6 +40,7 @@ import org.apache.ignite.internal.util.nio.GridNioSession;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.jetbrains.annotations.Nullable;
@@ -169,7 +171,7 @@ public class GridTcpRestParser implements GridNioParser {
GridClientMessage msg = (GridClientMessage)msg0;
if (msg instanceof GridMemcachedMessage)
- return encodeMemcache((GridMemcachedMessage)msg);
+ return encodeMemcache((GridMemcachedMessage)msg, ses.igniteConfiguration());
else if (msg instanceof GridClientPingPacket)
return ByteBuffer.wrap(GridClientPingPacket.PING_PACKET);
else if (msg instanceof GridClientHandshakeRequest) {
@@ -208,7 +210,7 @@ public class GridTcpRestParser implements GridNioParser {
else {
GridClientMarshaller marsh = marshaller(ses);
- ByteBuffer res = marsh.marshal(msg, 45);
+ ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.igniteConfiguration().getGridName());
ByteBuffer slice = res.slice();
@@ -519,7 +521,8 @@ public class GridTcpRestParser implements GridNioParser {
else {
GridClientMarshaller marsh = marshaller(ses);
- msg = marsh.unmarshal(state.buffer().toByteArray());
+ msg = MarshallerUtils.unmarshal(marsh, state.buffer().toByteArray(),
+ ses.igniteConfiguration().getGridName());
msg.requestId(state.header().reqId());
msg.clientId(state.header().clientId());
@@ -533,10 +536,12 @@ public class GridTcpRestParser implements GridNioParser {
* Encodes memcache message to a raw byte array.
*
* @param msg Message being serialized.
+ * @param igniteCfg Ignite config.
* @return Serialized message.
* @throws IgniteCheckedException If serialization failed.
*/
- private ByteBuffer encodeMemcache(GridMemcachedMessage msg) throws IgniteCheckedException {
+ private ByteBuffer encodeMemcache(GridMemcachedMessage msg,
+ final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
GridByteArrayList res = new GridByteArrayList(HDR_LEN);
int keyLen = 0;
@@ -546,7 +551,7 @@ public class GridTcpRestParser implements GridNioParser {
if (msg.key() != null) {
ByteArrayOutputStream rawKey = new ByteArrayOutputStream();
- keyFlags = encodeObj(msg.key(), rawKey);
+ keyFlags = encodeObj(msg.key(), rawKey, igniteCfg);
msg.key(rawKey.toByteArray());
@@ -560,7 +565,7 @@ public class GridTcpRestParser implements GridNioParser {
if (msg.value() != null) {
ByteArrayOutputStream rawVal = new ByteArrayOutputStream();
- valFlags = encodeObj(msg.value(), rawVal);
+ valFlags = encodeObj(msg.value(), rawVal, igniteCfg);
msg.value(rawVal.toByteArray());
@@ -645,7 +650,7 @@ public class GridTcpRestParser implements GridNioParser {
byte[] rawKey = (byte[])req.key();
// Only values can be hessian-encoded.
- req.key(decodeObj(keyFlags, rawKey));
+ req.key(decodeObj(keyFlags, rawKey, ses.igniteConfiguration()));
}
if (req.value() != null) {
@@ -653,7 +658,7 @@ public class GridTcpRestParser implements GridNioParser {
byte[] rawVal = (byte[])req.value();
- req.value(decodeObj(valFlags, rawVal));
+ req.value(decodeObj(valFlags, rawVal, ses.igniteConfiguration()));
}
}
@@ -711,14 +716,16 @@ public class GridTcpRestParser implements GridNioParser {
*
* @param flags Flags.
* @param bytes Byte array to decode.
+ * @param igniteCfg Ignite config.
* @return Decoded value.
* @throws IgniteCheckedException If deserialization failed.
*/
- private Object decodeObj(short flags, byte[] bytes) throws IgniteCheckedException {
+ private Object decodeObj(short flags, byte[] bytes,
+ final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
assert bytes != null;
if ((flags & SERIALIZED_FLAG) != 0)
- return jdkMarshaller.unmarshal(bytes, null);
+ return MarshallerUtils.unmarshal(jdkMarshaller, bytes, null, igniteCfg);
int masked = flags & 0xff00;
@@ -749,10 +756,12 @@ public class GridTcpRestParser implements GridNioParser {
*
* @param obj Object to serialize.
* @param out Output stream to which object should be written.
+ * @param igniteCfg Ignite config.
* @return Serialization flags.
* @throws IgniteCheckedException If JDK serialization failed.
*/
- private int encodeObj(Object obj, ByteArrayOutputStream out) throws IgniteCheckedException {
+ private int encodeObj(Object obj, ByteArrayOutputStream out,
+ final IgniteConfiguration igniteCfg) throws IgniteCheckedException {
int flags = 0;
byte[] data = null;
@@ -800,7 +809,7 @@ public class GridTcpRestParser implements GridNioParser {
flags |= BYTE_ARR_FLAG;
}
else {
- jdkMarshaller.marshal(obj, out);
+ MarshallerUtils.marshal(jdkMarshaller, obj, out, igniteCfg.getGridName());
flags |= SERIALIZED_FLAG;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/97ce8fbb/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index b418ba2..c17c9fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -83,6 +83,7 @@ import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.resources.JobContextResource;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.services.Service;
@@ -452,7 +453,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
LazyServiceConfiguration cfg0;
try {
- byte[] srvcBytes = marsh.marshal(cfg.getService());
+ byte[] srvcBytes = MarshallerUtils.marshal(marsh, cfg.getService(), ctx.gridName());
cfg0 = new LazyServiceConfiguration(cfg, srvcBytes);
}
@@ -1123,7 +1124,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
if (cfg instanceof LazyServiceConfiguration) {
byte[] bytes = ((LazyServiceConfiguration)cfg).serviceBytes();
- Service srvc = m.unmarshal(bytes, U.resolveClassLoader(null, ctx.config()));
+ Service srvc = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(null, ctx.config()), ctx.gridName());
ctx.resource().inject(srvc);
@@ -1133,10 +1134,10 @@ public class GridServiceProcessor extends GridProcessorAdapter {
Service svc = cfg.getService();
try {
- byte[] bytes = m.marshal(svc);
+ byte[] bytes = MarshallerUtils.marshal(m, svc, ctx.gridName());
- Service cp = m.unmarshal(bytes,
- U.resolveClassLoader(svc.getClass().getClassLoader(), ctx.config()));
+ Service cp = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(),
+ ctx.config()), ctx.gridName());
ctx.resource().inject(cp);
[21/50] [abbrv] ignite git commit: IGNITE-3511: .NET: Fixed
AffinityFunctionBase.cs placement, added missing Package-Info.cs files.
Posted by vo...@apache.org.
IGNITE-3511: .NET: Fixed AffinityFunctionBase.cs placement, added missing Package-Info.cs files.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/448571ba
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/448571ba
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/448571ba
Branch: refs/heads/ignite-2649
Commit: 448571ba2ca1b05197b17a38d157babf4cb4f203
Parents: 7364938
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 19 16:11:23 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 19 16:11:23 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.csproj | 5 +-
.../Cache/Affinity/AffinityFunctionBase.cs | 139 ------------------
.../Cache/Affinity/Fair/FairAffinityFunction.cs | 1 +
.../Cache/Affinity/Fair/Package-Info.cs | 26 ++++
.../Cache/Affinity/Package-Info.cs | 26 ++++
.../Cache/Affinity/Rendezvous/Package-Info.cs | 26 ++++
.../Rendezvous/RendezvousAffinityFunction.cs | 1 +
.../Impl/Cache/Affinity/AffinityFunctionBase.cs | 140 +++++++++++++++++++
8 files changed, 224 insertions(+), 140 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 6793873..3736988 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -55,11 +55,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Binary\Package-Info.cs" />
- <Compile Include="Cache\Affinity\AffinityFunctionBase.cs" />
<Compile Include="Cache\Affinity\AffinityFunctionContext.cs" />
<Compile Include="Cache\Affinity\AffinityTopologyVersion.cs" />
<Compile Include="Cache\Affinity\Fair\FairAffinityFunction.cs" />
+ <Compile Include="Cache\Affinity\Fair\Package-Info.cs" />
+ <Compile Include="Cache\Affinity\Rendezvous\Package-Info.cs" />
<Compile Include="Cache\Affinity\IAffinityFunction.cs" />
+ <Compile Include="Cache\Affinity\Package-Info.cs" />
<Compile Include="Cache\Affinity\Rendezvous\RendezvousAffinityFunction.cs" />
<Compile Include="Cache\CacheAtomicUpdateTimeoutException.cs" />
<Compile Include="Cache\CacheEntryProcessorException.cs" />
@@ -114,6 +116,7 @@
<Compile Include="Common\IgniteFutureCancelledException.cs" />
<Compile Include="Common\IgniteGuid.cs" />
<Compile Include="Common\Package-Info.cs" />
+ <Compile Include="Impl\Cache\Affinity\AffinityFunctionBase.cs" />
<Compile Include="Impl\Cache\Affinity\AffinityFunctionSerializer.cs" />
<Compile Include="Impl\Cache\Affinity\PlatformAffinityFunction.cs" />
<Compile Include="Impl\Cache\Event\JavaCacheEntryEventFilter.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
deleted file mode 100644
index ce2e5e1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionBase.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-\ufeff/*
- * 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.
- */
-
-namespace Apache.Ignite.Core.Cache.Affinity
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
-
- /// <summary>
- /// Base class for predefined affinity functions.
- /// </summary>
- [Serializable]
- public abstract class AffinityFunctionBase : IAffinityFunction
- {
- /// <summary> The default value for <see cref="Partitions"/> property. </summary>
- public const int DefaultPartitions = 1024;
-
- /** */
- private int _partitions = DefaultPartitions;
-
- /** */
- private IAffinityFunction _baseFunction;
-
-
- /// <summary>
- /// Gets or sets the total number of partitions.
- /// </summary>
- [DefaultValue(DefaultPartitions)]
- public virtual int Partitions
- {
- get { return _partitions; }
- set { _partitions = value; }
- }
-
- /// <summary>
- /// Gets partition number for a given key starting from 0. Partitioned caches
- /// should make sure that keys are about evenly distributed across all partitions
- /// from 0 to <see cref="Partitions" /> for best performance.
- /// <para />
- /// Note that for fully replicated caches it is possible to segment key sets among different
- /// grid node groups. In that case each node group should return a unique partition
- /// number. However, unlike partitioned cache, mappings of keys to nodes in
- /// replicated caches are constant and a node cannot migrate from one partition
- /// to another.
- /// </summary>
- /// <param name="key">Key to get partition for.</param>
- /// <returns>
- /// Partition number for a given key.
- /// </returns>
- public virtual int GetPartition(object key)
- {
- ThrowIfUninitialized();
-
- return _baseFunction.GetPartition(key);
- }
-
- /// <summary>
- /// Removes node from affinity. This method is called when it is safe to remove
- /// disconnected node from affinity mapping.
- /// </summary>
- /// <param name="nodeId">The node identifier.</param>
- public virtual void RemoveNode(Guid nodeId)
- {
- ThrowIfUninitialized();
-
- _baseFunction.RemoveNode(nodeId);
- }
-
- /// <summary>
- /// Gets affinity nodes for a partition. In case of replicated cache, all returned
- /// nodes are updated in the same manner. In case of partitioned cache, the returned
- /// list should contain only the primary and back up nodes with primary node being
- /// always first.
- /// <pare />
- /// Note that partitioned affinity must obey the following contract: given that node
- /// <code>N</code> is primary for some key <code>K</code>, if any other node(s) leave
- /// grid and no node joins grid, node <code>N</code> will remain primary for key <code>K</code>.
- /// </summary>
- /// <param name="context">The affinity function context.</param>
- /// <returns>
- /// A collection of partitions, where each partition is a collection of nodes,
- /// where first node is a primary node, and other nodes are backup nodes.
- /// </returns>
- public virtual IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
- {
- ThrowIfUninitialized();
-
- return _baseFunction.AssignPartitions(context);
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether to exclude same-host-neighbors from being backups of each other.
- /// </summary>
- public virtual bool ExcludeNeighbors { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AffinityFunctionBase"/> class.
- /// </summary>
- internal AffinityFunctionBase()
- {
- // No-op.
- }
-
- /// <summary>
- /// Sets the base function.
- /// </summary>
- /// <param name="baseFunc">The base function.</param>
- internal void SetBaseFunction(IAffinityFunction baseFunc)
- {
- _baseFunction = baseFunc;
- }
-
- /// <summary>
- /// Gets the direct usage error.
- /// </summary>
- private void ThrowIfUninitialized()
- {
- if (_baseFunction == null)
- throw new IgniteException(GetType() + " has not yet been initialized.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
index 4a3885f..f06937d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/FairAffinityFunction.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Cache.Affinity.Fair
{
using System;
+ using Apache.Ignite.Core.Impl.Cache.Affinity;
/// <summary>
/// Fair affinity function which tries to ensure that all nodes get equal number of partitions with
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/Package-Info.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/Package-Info.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/Package-Info.cs
new file mode 100644
index 0000000..3bcaa59
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Fair/Package-Info.cs
@@ -0,0 +1,26 @@
+\ufeff/*
+* 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.
+*/
+
+#pragma warning disable 1587 // invalid XML comment
+
+/// <summary>
+/// Fair affinity functionality.
+/// </summary>
+namespace Apache.Ignite.Core.Cache.Affinity.Fair
+{
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Package-Info.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Package-Info.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Package-Info.cs
new file mode 100644
index 0000000..dfbdf08
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Package-Info.cs
@@ -0,0 +1,26 @@
+\ufeff/*
+* 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.
+*/
+
+#pragma warning disable 1587 // invalid XML comment
+
+/// <summary>
+/// Cache affinity API.
+/// </summary>
+namespace Apache.Ignite.Core.Cache.Affinity
+{
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/Package-Info.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/Package-Info.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/Package-Info.cs
new file mode 100644
index 0000000..d3f5ef0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/Package-Info.cs
@@ -0,0 +1,26 @@
+\ufeff/*
+* 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.
+*/
+
+#pragma warning disable 1587 // invalid XML comment
+
+/// <summary>
+/// Rendezvous affinity functionality.
+/// </summary>
+namespace Apache.Ignite.Core.Cache.Affinity.Rendezvous
+{
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
index 98ec364..928324c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/Rendezvous/RendezvousAffinityFunction.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Cache.Affinity.Rendezvous
{
using System;
+ using Apache.Ignite.Core.Impl.Cache.Affinity;
/// <summary>
/// Affinity function for partitioned cache based on Highest Random Weight algorithm.
http://git-wip-us.apache.org/repos/asf/ignite/blob/448571ba/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionBase.cs
new file mode 100644
index 0000000..8536e4c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionBase.cs
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache.Affinity
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Base class for predefined affinity functions.
+ /// </summary>
+ [Serializable]
+ public abstract class AffinityFunctionBase : IAffinityFunction
+ {
+ /// <summary> The default value for <see cref="Partitions"/> property. </summary>
+ public const int DefaultPartitions = 1024;
+
+ /** */
+ private int _partitions = DefaultPartitions;
+
+ /** */
+ private IAffinityFunction _baseFunction;
+
+
+ /// <summary>
+ /// Gets or sets the total number of partitions.
+ /// </summary>
+ [DefaultValue(DefaultPartitions)]
+ public virtual int Partitions
+ {
+ get { return _partitions; }
+ set { _partitions = value; }
+ }
+
+ /// <summary>
+ /// Gets partition number for a given key starting from 0. Partitioned caches
+ /// should make sure that keys are about evenly distributed across all partitions
+ /// from 0 to <see cref="Partitions" /> for best performance.
+ /// <para />
+ /// Note that for fully replicated caches it is possible to segment key sets among different
+ /// grid node groups. In that case each node group should return a unique partition
+ /// number. However, unlike partitioned cache, mappings of keys to nodes in
+ /// replicated caches are constant and a node cannot migrate from one partition
+ /// to another.
+ /// </summary>
+ /// <param name="key">Key to get partition for.</param>
+ /// <returns>
+ /// Partition number for a given key.
+ /// </returns>
+ public virtual int GetPartition(object key)
+ {
+ ThrowIfUninitialized();
+
+ return _baseFunction.GetPartition(key);
+ }
+
+ /// <summary>
+ /// Removes node from affinity. This method is called when it is safe to remove
+ /// disconnected node from affinity mapping.
+ /// </summary>
+ /// <param name="nodeId">The node identifier.</param>
+ public virtual void RemoveNode(Guid nodeId)
+ {
+ ThrowIfUninitialized();
+
+ _baseFunction.RemoveNode(nodeId);
+ }
+
+ /// <summary>
+ /// Gets affinity nodes for a partition. In case of replicated cache, all returned
+ /// nodes are updated in the same manner. In case of partitioned cache, the returned
+ /// list should contain only the primary and back up nodes with primary node being
+ /// always first.
+ /// <pare />
+ /// Note that partitioned affinity must obey the following contract: given that node
+ /// <code>N</code> is primary for some key <code>K</code>, if any other node(s) leave
+ /// grid and no node joins grid, node <code>N</code> will remain primary for key <code>K</code>.
+ /// </summary>
+ /// <param name="context">The affinity function context.</param>
+ /// <returns>
+ /// A collection of partitions, where each partition is a collection of nodes,
+ /// where first node is a primary node, and other nodes are backup nodes.
+ /// </returns>
+ public virtual IEnumerable<IEnumerable<IClusterNode>> AssignPartitions(AffinityFunctionContext context)
+ {
+ ThrowIfUninitialized();
+
+ return _baseFunction.AssignPartitions(context);
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to exclude same-host-neighbors from being backups of each other.
+ /// </summary>
+ public virtual bool ExcludeNeighbors { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AffinityFunctionBase"/> class.
+ /// </summary>
+ internal AffinityFunctionBase()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Sets the base function.
+ /// </summary>
+ /// <param name="baseFunc">The base function.</param>
+ internal void SetBaseFunction(IAffinityFunction baseFunc)
+ {
+ _baseFunction = baseFunc;
+ }
+
+ /// <summary>
+ /// Gets the direct usage error.
+ /// </summary>
+ private void ThrowIfUninitialized()
+ {
+ if (_baseFunction == null)
+ throw new IgniteException(GetType() + " has not yet been initialized.");
+ }
+ }
+}
[22/50] [abbrv] ignite git commit: Merge branch 'gridgain-7.5.30'
into ignite-1849
Posted by vo...@apache.org.
Merge branch 'gridgain-7.5.30' into ignite-1849
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b81dbbf2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b81dbbf2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b81dbbf2
Branch: refs/heads/ignite-2649
Commit: b81dbbf23b7941bfbaac18ce9004ef06b0f1f4f8
Parents: 5ae31fa 448571b
Author: Alexander Paschenko <al...@gmail.com>
Authored: Tue Jul 19 19:55:11 2016 +0300
Committer: Alexander Paschenko <al...@gmail.com>
Committed: Tue Jul 19 19:55:11 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 6 +-
.../internal/binary/BinaryObjectImpl.java | 8 +
.../internal/binary/GridBinaryMarshaller.java | 11 +-
.../GridAffinityFunctionContextImpl.java | 9 +
.../processors/cache/GridCacheProcessor.java | 65 +-
.../affinity/PlatformAffinityFunction.java | 277 ++++++
.../PlatformAffinityFunctionTarget.java | 113 +++
.../cache/affinity/PlatformAffinityUtils.java | 116 +++
.../callback/PlatformCallbackGateway.java | 89 ++
.../callback/PlatformCallbackUtils.java | 49 ++
.../PlatformDotNetConfigurationClosure.java | 115 ++-
.../dotnet/PlatformDotNetAffinityFunction.java | 171 ++++
.../binary/BinaryMarshallerSelfTest.java | 41 +
.../processors/igfs/IgfsIgniteMock.java | 492 +++++++++++
.../internal/processors/igfs/IgfsMock.java | 397 +++++++++
.../mapreduce/IgniteHadoopMapReducePlanner.java | 48 +-
.../IgniteHadoopWeightedMapReducePlanner.java | 846 +++++++++++++++++++
.../internal/processors/hadoop/HadoopUtils.java | 81 ++
.../planner/HadoopAbstractMapReducePlanner.java | 116 +++
.../planner/HadoopMapReducePlanGroup.java | 150 ++++
.../planner/HadoopMapReducePlanTopology.java | 89 ++
.../HadoopDefaultMapReducePlannerSelfTest.java | 451 +---------
.../processors/hadoop/HadoopMapReduceTest.java | 16 +-
.../processors/hadoop/HadoopPlannerMockJob.java | 168 ++++
.../HadoopWeightedMapReducePlannerTest.java | 599 +++++++++++++
.../HadoopWeightedPlannerMapReduceTest.java | 38 +
.../testsuites/IgniteHadoopTestSuite.java | 8 +-
.../cpp/common/include/ignite/common/java.h | 18 +
modules/platforms/cpp/common/src/java.cpp | 36 +-
.../Apache.Ignite.Core.Tests.csproj | 9 +-
.../Affinity/AffinityFunctionSpringTest.cs | 184 ++++
.../Config/Cache/Affinity/affinity-function.xml | 129 +++
.../Cache/Affinity/affinity-function2.xml | 49 ++
.../Apache.Ignite.Core.Tests/TestRunner.cs | 3 +-
.../Apache.Ignite.Core.csproj | 14 +-
.../Cache/Affinity/AffinityFunctionContext.cs | 120 +++
.../Cache/Affinity/AffinityTopologyVersion.cs | 138 +++
.../Cache/Affinity/Fair/FairAffinityFunction.cs | 33 +
.../Cache/Affinity/Fair/Package-Info.cs | 26 +
.../Cache/Affinity/IAffinityFunction.cs | 82 ++
.../Cache/Affinity/Package-Info.cs | 26 +
.../Cache/Affinity/Rendezvous/Package-Info.cs | 26 +
.../Rendezvous/RendezvousAffinityFunction.cs | 32 +
.../Apache.Ignite.Core/Events/EventReader.cs | 8 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 38 +-
.../Impl/Binary/BinaryReaderExtensions.cs | 14 +
.../Impl/Binary/Marshaller.cs | 6 +-
.../Impl/Cache/Affinity/AffinityFunctionBase.cs | 140 +++
.../Affinity/AffinityFunctionSerializer.cs | 277 ++++++
.../Cache/Affinity/PlatformAffinityFunction.cs | 74 ++
.../Impl/Common/ObjectInfoHolder.cs | 86 ++
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 10 +-
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 6 +
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 133 ++-
54 files changed, 5756 insertions(+), 530 deletions(-)
----------------------------------------------------------------------
[14/50] [abbrv] ignite git commit: IGNITE-1849 minor fixes
Posted by vo...@apache.org.
IGNITE-1849 minor fixes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5ae31fa3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5ae31fa3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5ae31fa3
Branch: refs/heads/ignite-2649
Commit: 5ae31fa39758780ac279d4c1b0179b84405c11ac
Parents: 6f7df5e
Author: Alexander Paschenko <al...@gmail.com>
Authored: Mon Jul 18 14:09:46 2016 +0300
Committer: Alexander Paschenko <al...@gmail.com>
Committed: Mon Jul 18 14:09:46 2016 +0300
----------------------------------------------------------------------
...IgniteCacheInternalEventsIgnoreSelfTest.java | 61 ++++++++++++++++++++
.../IgniteCacheInternalEventsIgnoreTest.java | 53 -----------------
.../testsuites/IgniteCacheTestSuite5.java | 4 +-
3 files changed, 63 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ae31fa3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreSelfTest.java
new file mode 100644
index 0000000..e14a600
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreSelfTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.processors.cache;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class IgniteCacheInternalEventsIgnoreSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final AtomicBoolean evtFlag = new AtomicBoolean();
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInternalEventsIgnore() throws Exception {
+ Ignite ignite = startGrid(1);
+ ignite.events().localListen(new EventListener(), EventType.EVT_TASK_STARTED, EventType.EVT_TASK_REDUCED,
+ EventType.EVT_TASK_FINISHED);
+ IgniteCache cache = ignite.createCache(defaultCacheConfiguration().setName("myTestCache"));
+ cache.size(CachePeekMode.ALL);
+ cache.sizeLong(CachePeekMode.ALL);
+
+ assertFalse(evtFlag.get());
+ }
+
+ /**
+ *
+ */
+ private static final class EventListener implements IgnitePredicate<Event> {
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event e) {
+ evtFlag.set(true);
+
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ae31fa3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
deleted file mode 100644
index e87206d..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInternalEventsIgnoreTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.processors.cache;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.events.Event;
-import org.apache.ignite.events.EventType;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/** */
-public class IgniteCacheInternalEventsIgnoreTest extends GridCommonAbstractTest {
- /** */
- private static final AtomicBoolean evtFlag = new AtomicBoolean();
-
- /** */
- public void testInternalEventsIgnore() throws Exception {
- Ignite ignite = startGrid(1);
- ignite.events().localListen(new EvtLsnr(), EventType.EVT_TASK_STARTED, EventType.EVT_TASK_REDUCED,
- EventType.EVT_TASK_FINISHED);
- IgniteCache cache = ignite.createCache(defaultCacheConfiguration().setName("myTestCache"));
- cache.size(CachePeekMode.ALL);
- cache.sizeLong(CachePeekMode.ALL);
- assertFalse(evtFlag.get());
- }
-
- /** */
- private static final class EvtLsnr implements IgnitePredicate<Event> {
- /** {@inheritDoc} */
- @Override public boolean apply(Event e) {
- evtFlag.set(true);
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ae31fa3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index af54f91..0341502 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -21,7 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
import org.apache.ignite.internal.processors.cache.EntryVersionConsistencyReadThroughTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheInternalEventsIgnoreTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheInternalEventsIgnoreSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest;
@@ -45,7 +45,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
suite.addTestSuite(IgniteCachePutStackOverflowSelfTest.class);
suite.addTestSuite(EntryVersionConsistencyReadThroughTest.class);
suite.addTestSuite(IgniteCacheTxIteratorSelfTest.class);
- suite.addTestSuite(IgniteCacheInternalEventsIgnoreTest.class);
+ suite.addTestSuite(IgniteCacheInternalEventsIgnoreSelfTest.class);
return suite;
}
[05/50] [abbrv] ignite git commit: ignite-3413 Use cache node filter
for continuous query registration
Posted by vo...@apache.org.
ignite-3413 Use cache node filter for continuous query registration
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/89d64e74
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/89d64e74
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/89d64e74
Branch: refs/heads/ignite-2649
Commit: 89d64e74b697054a88c3a91433aaaf4f7fdd0284
Parents: a056954
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jul 13 12:41:18 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jul 13 12:41:18 2016 +0300
----------------------------------------------------------------------
.../continuous/CacheContinuousQueryManager.java | 4 +-
...eContinuousQueryMultiNodesFilteringTest.java | 278 +++++++++++++++++++
...dCacheContinuousQueryNodesFilteringTest.java | 168 +++++++++++
.../IgniteCacheQuerySelfTestSuite3.java | 4 +
4 files changed, 453 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/89d64e74/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index c966527..195f3ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -642,7 +642,9 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
hnd.localCache(cctx.isLocal());
IgnitePredicate<ClusterNode> pred = (loc || cctx.config().getCacheMode() == CacheMode.LOCAL) ?
- F.nodeForNodeId(cctx.localNodeId()) : F.<ClusterNode>alwaysTrue();
+ F.nodeForNodeId(cctx.localNodeId()) : cctx.config().getNodeFilter();
+
+ assert pred != null : cctx.config();
UUID id = cctx.kernalContext().continuous().startRoutine(
hnd,
http://git-wip-us.apache.org/repos/asf/ignite/blob/89d64e74/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
new file mode 100644
index 0000000..7000446
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
@@ -0,0 +1,278 @@
+/*
+ * 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.processors.cache.query.continuous;
+
+import java.util.Collections;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryCreatedListener;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListener;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryRemovedListener;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jsr166.ConcurrentHashMap8;
+
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+
+/** */
+@SuppressWarnings("unchecked")
+public class GridCacheContinuousQueryMultiNodesFilteringTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int SERVER_GRIDS_COUNT = 6;
+
+ /** Cache entry operations' counts. */
+ private static final ConcurrentMap<String, AtomicInteger> opCounts = new ConcurrentHashMap8<>();
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /** */
+ public void testFiltersAndListeners() throws Exception {
+ for (int i = 1; i <= SERVER_GRIDS_COUNT; i++)
+ startGrid(i, false);
+
+ startGrid(SERVER_GRIDS_COUNT + 1, true);
+
+ for (int i = 1; i <= SERVER_GRIDS_COUNT + 1; i++) {
+ for (int j = 0; j < i; j++) {
+ jcache(i, "part" + i).put("k" + j, "v0");
+ jcache(i, "repl" + i).put("k" + j, "v0");
+
+ // Should trigger updates
+ jcache(i, "part" + i).put("k" + j, "v1");
+ jcache(i, "repl" + i).put("k" + j, "v1");
+
+ jcache(i, "part" + i).remove("k" + j);
+ jcache(i, "repl" + i).remove("k" + j);
+ }
+ }
+
+ for (int i = 1; i <= SERVER_GRIDS_COUNT + 1; i++) {
+ // For each i, we did 3 ops on 2 caches on i keys, hence expected number.
+ final int expTotal = i * 3 * 2;
+ final int i0 = i;
+
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return opCounts.get("qry" + i0 + "_total").get() == expTotal;
+ }
+ }, 5000);
+
+ int partInserts = opCounts.get("part" + i + "_ins").get();
+ int replInserts = opCounts.get("repl" + i + "_ins").get();
+ int partUpdates = opCounts.get("part" + i + "_upd").get();
+ int replUpdates = opCounts.get("repl" + i + "_upd").get();
+ int partRemoves = opCounts.get("part" + i + "_rmv").get();
+ int replRemoves = opCounts.get("repl" + i + "_rmv").get();
+ int totalQryOps = opCounts.get("qry" + i + "_total").get();
+
+ assertEquals(i, partInserts);
+ assertEquals(i, replInserts);
+
+ assertEquals(i, partUpdates);
+ assertEquals(i, replUpdates);
+
+ assertEquals(i, partRemoves);
+ assertEquals(i, replRemoves);
+
+ assertEquals(expTotal, totalQryOps);
+
+ assertEquals(totalQryOps, partInserts + replInserts + partUpdates + replUpdates + partRemoves + replRemoves);
+ }
+ }
+
+ /** */
+ private Ignite startGrid(final int idx, boolean isClientMode) throws Exception {
+ String gridName = getTestGridName(idx);
+
+ IgniteConfiguration cfg = optimize(getConfiguration(gridName)).setClientMode(isClientMode);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ cfg.setUserAttributes(Collections.singletonMap("idx", idx));
+
+ Ignite node = startGrid(gridName, cfg);
+
+ IgnitePredicate<ClusterNode> nodeFilter = new NodeFilter(idx);
+
+ String partCacheName = "part" + idx;
+
+ IgniteCache partCache = node.createCache(defaultCacheConfiguration().setName("part" + idx)
+ .setCacheMode(PARTITIONED).setBackups(1).setNodeFilter(nodeFilter));
+
+ opCounts.put(partCacheName + "_ins", new AtomicInteger());
+ opCounts.put(partCacheName + "_upd", new AtomicInteger());
+ opCounts.put(partCacheName + "_rmv", new AtomicInteger());
+
+ partCache.registerCacheEntryListener(new ListenerConfiguration(partCacheName, ListenerConfiguration.Op.INSERT));
+ partCache.registerCacheEntryListener(new ListenerConfiguration(partCacheName, ListenerConfiguration.Op.UPDATE));
+ partCache.registerCacheEntryListener(new ListenerConfiguration(partCacheName, ListenerConfiguration.Op.REMOVE));
+
+ String replCacheName = "repl" + idx;
+
+ IgniteCache replCache = node.createCache(defaultCacheConfiguration().setName("repl" + idx)
+ .setCacheMode(REPLICATED).setNodeFilter(nodeFilter));
+
+ opCounts.put(replCacheName + "_ins", new AtomicInteger());
+ opCounts.put(replCacheName + "_upd", new AtomicInteger());
+ opCounts.put(replCacheName + "_rmv", new AtomicInteger());
+
+ replCache.registerCacheEntryListener(new ListenerConfiguration(replCacheName, ListenerConfiguration.Op.INSERT));
+ replCache.registerCacheEntryListener(new ListenerConfiguration(replCacheName, ListenerConfiguration.Op.UPDATE));
+ replCache.registerCacheEntryListener(new ListenerConfiguration(replCacheName, ListenerConfiguration.Op.REMOVE));
+
+ opCounts.put("qry" + idx + "_total", new AtomicInteger());
+
+ ContinuousQuery qry = new ContinuousQuery();
+ qry.setRemoteFilterFactory(new EntryEventFilterFactory(idx));
+ qry.setLocalListener(new CacheEntryUpdatedListener() {
+ /** {@inheritDoc} */
+ @Override public void onUpdated(Iterable evts) {
+ opCounts.get("qry" + idx + "_total").incrementAndGet();
+ }
+ });
+
+ partCache.query(qry);
+ replCache.query(qry);
+
+ return node;
+ }
+
+ /** */
+ private final static class ListenerConfiguration extends MutableCacheEntryListenerConfiguration {
+ /** Operation. */
+ enum Op {
+ /** Insert. */
+ INSERT,
+
+ /** Update. */
+ UPDATE,
+
+ /** Remove. */
+ REMOVE
+ }
+
+ /** */
+ ListenerConfiguration(final String cacheName, final Op op) {
+ super(new Factory<CacheEntryListener>() {
+ /** {@inheritDoc} */
+ @Override public CacheEntryListener create() {
+ switch (op) {
+ case INSERT:
+ return new CacheEntryCreatedListener() {
+ /** {@inheritDoc} */
+ @Override public void onCreated(Iterable iterable) {
+ for (Object evt : iterable)
+ opCounts.get(cacheName + "_ins").getAndIncrement();
+ }
+ };
+ case UPDATE:
+ return new CacheEntryUpdatedListener() {
+ /** {@inheritDoc} */
+ @Override public void onUpdated(Iterable iterable) {
+ for (Object evt : iterable)
+ opCounts.get(cacheName + "_upd").getAndIncrement();
+ }
+ };
+ case REMOVE:
+ return new CacheEntryRemovedListener() {
+ /** {@inheritDoc} */
+ @Override public void onRemoved(Iterable iterable) {
+ for (Object evt : iterable)
+ opCounts.get(cacheName + "_rmv").getAndIncrement();
+ }
+ };
+ default:
+ throw new IgniteException(new IllegalArgumentException());
+ }
+ }
+ }, null, true, false);
+ }
+ }
+
+ /** */
+ private final static class EntryEventFilterFactory implements Factory<CacheEntryEventFilter> {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Grid index to determine whether node filter has been invoked. */
+ private final int idx;
+
+ /** */
+ private EntryEventFilterFactory(int idx) {
+ this.idx = idx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheEntryEventFilter create() {
+ return new CacheEntryEventFilter() {
+ /** {@inheritDoc} */
+ @Override public boolean evaluate(CacheEntryEvent evt) throws CacheEntryListenerException {
+ int evtNodeIdx = (Integer)(ignite.cluster().localNode().attributes().get("idx"));
+
+ assertTrue(evtNodeIdx % 2 == idx % 2);
+
+ return true;
+ }
+ };
+ }
+ }
+
+ /** */
+ private final static class NodeFilter implements IgnitePredicate<ClusterNode> {
+ /** */
+ private final int idx;
+
+ /** */
+ private NodeFilter(int idx) {
+ this.idx = idx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(ClusterNode clusterNode) {
+ return ((Integer)clusterNode.attributes().get("idx") % 2) == idx % 2;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89d64e74/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
new file mode 100644
index 0000000..dccde65
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.processors.cache.query.continuous;
+
+import java.io.Serializable;
+import java.util.Collections;
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridStringLogger;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/** */
+@SuppressWarnings("unused")
+public class GridCacheContinuousQueryNodesFilteringTest extends GridCommonAbstractTest implements Serializable {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final String ENTRY_FILTER_CLS_NAME = "org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilter";
+
+ /**
+ * Tests that node not matched by filter really does not try to participate in the query.
+ *
+ * @throws Exception if failed.
+ */
+ @SuppressWarnings("EmptyTryBlock")
+ public void testNodeWithoutAttributeExclusion() throws Exception {
+ try (Ignite node1 = startNodeWithCache()) {
+ try (Ignite node2 = startGrid("node2", getConfiguration("node2", false, null))) {
+ assertEquals(2, node2.cluster().nodes().size());
+ }
+ }
+ }
+
+ /**
+ * Test that node matched by filter and having filter instantiation problems fails for sure.
+ *
+ * @throws Exception if failed.
+ */
+ public void testNodeWithAttributeFailure() throws Exception {
+ try (Ignite node1 = startNodeWithCache()) {
+ GridStringLogger log = new GridStringLogger();
+
+ try (Ignite node2 = startGrid("node2", getConfiguration("node2", true, log))) {
+ fail();
+ }
+ catch (IgniteException e) {
+ assertTrue(log.toString().contains("Class not found for continuous query remote filter " +
+ "[name=org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilter]"));
+ }
+ }
+ }
+
+ /**
+ * Start first, attribute-bearing, node, create new cache and launch continuous query on it.
+ *
+ * @return Node.
+ * @throws Exception if failed.
+ */
+ private Ignite startNodeWithCache() throws Exception {
+ Ignite node1 = startGrid("node1", getConfiguration("node1", true, null));
+
+ CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
+ ccfg.setName("attrsTestCache");
+ ccfg.setNodeFilter(new IgnitePredicate<ClusterNode>() {
+ /** {@inheritDoc} */
+ @Override public boolean apply(ClusterNode node) {
+ return "data".equals(node.attribute("node-type"));
+ }
+ });
+
+ IgniteCache<Integer, Integer> cache = node1.createCache(ccfg);
+
+ ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
+
+ qry.setRemoteFilterFactory(new RemoteFilterFactory());
+ qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() {
+ /** {@inheritDoc} */
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ // No-op.
+ }
+ });
+
+ RemoteFilterFactory.clsLdr = getExternalClassLoader();
+
+ cache.query(qry);
+
+ // Switch class loader before starting the second node.
+ RemoteFilterFactory.clsLdr = getClass().getClassLoader();
+
+ return node1;
+ }
+
+ /**
+ * @param name Node name.
+ * @param setAttr Flag indicating whether node user attribute should be set.
+ * @param log Logger.
+ * @return Node configuration w/specified name.
+ * @throws Exception If failed.
+ */
+ private IgniteConfiguration getConfiguration(String name, boolean setAttr, GridStringLogger log) throws Exception {
+ IgniteConfiguration cfg = optimize(getConfiguration(name));
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ if (setAttr)
+ cfg.setUserAttributes(Collections.singletonMap("node-type", "data"));
+
+ cfg.setGridLogger(log);
+
+ return cfg;
+ }
+
+ /**
+ *
+ */
+ private static class RemoteFilterFactory implements Factory<CacheEntryEventFilter<Integer, Integer>> {
+ /** */
+ private static ClassLoader clsLdr;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public CacheEntryEventFilter<Integer, Integer> create() {
+ try {
+ Class<?> filterCls = clsLdr.loadClass(ENTRY_FILTER_CLS_NAME);
+
+ assert CacheEntryEventFilter.class.isAssignableFrom(filterCls);
+
+ return ((Class<CacheEntryEventFilter>)filterCls).newInstance();
+ }
+ catch (ClassNotFoundException e) {
+ throw new IgniteException("Class not found for continuous query remote filter [name=" +
+ e.getMessage() + "]");
+ }
+ catch (Exception e) { // We really don't expect anything else fancy here.
+ throw new AssertionError("Unexpected exception", e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89d64e74/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
index a1a32a1..abf4ac3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
@@ -43,6 +43,8 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryConcurrentTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryMultiNodesFilteringTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryNodesFilteringTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionTxOneNodeTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest;
@@ -115,6 +117,8 @@ public class IgniteCacheQuerySelfTestSuite3 extends TestSuite {
suite.addTestSuite(CacheContinuousQueryExecuteInPrimaryTest.class);
suite.addTestSuite(CacheContinuousQueryLostPartitionTest.class);
suite.addTestSuite(ContinuousQueryRemoteFilterMissingInClassPathSelfTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryNodesFilteringTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryMultiNodesFilteringTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryImmutableEntryTest.class);
suite.addTestSuite(CacheKeepBinaryIterationTest.class);
suite.addTestSuite(CacheKeepBinaryIterationStoreEnabledTest.class);
[41/50] [abbrv] ignite git commit: Cleanup.
Posted by vo...@apache.org.
Cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7f99d92
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7f99d92
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7f99d92
Branch: refs/heads/ignite-2649
Commit: a7f99d92d64b3235aedf58ab262fcfa1f633a905
Parents: 1a3b0ea
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 16:19:40 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 16:19:40 2016 +0300
----------------------------------------------------------------------
.../rendezvous/RendezvousAffinityFunction.java | 4 +-
.../internal/GridEventConsumeHandler.java | 4 +-
.../internal/GridMessageListenHandler.java | 4 +-
.../router/impl/GridTcpRouterNioParser.java | 2 +-
.../checkpoint/GridCheckpointManager.java | 4 +-
.../managers/communication/GridIoManager.java | 6 +-
.../deployment/GridDeploymentCommunication.java | 2 +-
.../eventstorage/GridEventStorageManager.java | 8 +-
.../swapspace/GridSwapSpaceManager.java | 2 +-
.../processors/affinity/GridAffinityUtils.java | 2 +-
.../cache/CacheEntrySerializablePredicate.java | 3 +-
.../cache/CacheInvokeDirectResult.java | 3 +-
.../processors/cache/GridCacheUtils.java | 12 +++
.../GridDistributedLockResponse.java | 3 +-
.../GridDistributedTxPrepareRequest.java | 3 +-
.../GridDistributedTxPrepareResponse.java | 3 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 3 +-
.../dht/GridDhtTxFinishResponse.java | 3 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 3 +-
.../atomic/GridNearAtomicUpdateResponse.java | 3 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 3 +-
.../GridDhtPartitionDemandMessage.java | 3 +-
.../preloader/GridDhtPartitionsFullMessage.java | 5 +-
.../GridDhtPartitionsSingleMessage.java | 5 +-
.../distributed/near/GridNearGetResponse.java | 3 +-
.../near/GridNearSingleGetResponse.java | 3 +-
.../near/GridNearTxFinishResponse.java | 3 +-
.../cache/query/GridCacheQueryResponse.java | 3 +-
.../continuous/CacheContinuousQueryHandler.java | 2 +-
.../closure/GridClosureProcessor.java | 2 +-
.../continuous/GridContinuousProcessor.java | 2 +-
.../datastreamer/DataStreamProcessor.java | 4 +-
.../datastreamer/DataStreamerImpl.java | 4 +-
.../processors/igfs/IgfsAckMessage.java | 2 +-
.../processors/igfs/IgfsDeleteMessage.java | 3 +-
.../internal/processors/igfs/IgfsPaths.java | 2 +-
.../processors/job/GridJobProcessor.java | 10 +--
.../internal/processors/job/GridJobWorker.java | 6 +-
.../offheap/GridOffHeapProcessor.java | 2 +-
.../handlers/task/GridTaskCommandHandler.java | 4 +-
.../rest/protocols/tcp/GridTcpRestParser.java | 8 +-
.../service/GridServiceProcessor.java | 8 +-
.../processors/task/GridTaskProcessor.java | 4 +-
.../processors/task/GridTaskWorker.java | 8 +-
.../ignite/marshaller/MarshallerUtils.java | 91 ++++++++------------
.../spi/checkpoint/sharedfs/SharedFsUtils.java | 2 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 10 +--
.../ignite/spi/discovery/tcp/ServerImpl.java | 28 +++---
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 14 +++
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +-
.../TcpDiscoveryMulticastIpFinder.java | 4 +-
.../processors/query/h2/IgniteH2Indexing.java | 4 +-
52 files changed, 173 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 6c1fec3..1b90581 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -337,8 +337,8 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] nodeHashBytes = MarshallerUtils.marshal(
- ignite.name(), ignite.configuration().getMarshaller(), nodeHash);
+ byte[] nodeHashBytes =
+ MarshallerUtils.marshal(ignite.name(), ignite.configuration().getMarshaller(), nodeHash);
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
out.write(nodeHashBytes, 0, nodeHashBytes.length); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index a180965..5cb3f6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -370,7 +370,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
depInfo = new GridDeploymentInfoBean(dep);
- filterBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), filter);
+ filterBytes = MarshallerUtils.marshal(ctx, filter);
}
}
@@ -491,7 +491,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
void p2pMarshal(final GridKernalContext ctx) throws IgniteCheckedException {
assert ctx.config().getMarshaller() != null;
- bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), evt);
+ bytes = MarshallerUtils.marshal(ctx, evt);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 373244f..1d2dda9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -160,9 +160,9 @@ public class GridMessageListenHandler implements GridContinuousHandler {
assert ctx.config().isPeerClassLoadingEnabled();
if (topic != null)
- topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
+ topicBytes = MarshallerUtils.marshal(ctx, topic);
- predBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), pred);
+ predBytes = MarshallerUtils.marshal(ctx, pred);
// Deploy only listener, as it is very likely to be of some user class.
GridPeerDeployAware pda = U.peerDeployAware(pred);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
index 0b3a042..a4893aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridTcpRouterNioParser.java
@@ -86,7 +86,7 @@ class GridTcpRouterNioParser extends GridTcpRestParser {
GridClientMessage clientMsg = (GridClientMessage)msg;
- ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.gridName());
+ ByteBuffer res = marsh.marshal(msg, 45);
ByteBuffer slice = res.slice();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
index e14b74a..483922f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
@@ -174,7 +174,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
try {
switch (scope) {
case GLOBAL_SCOPE: {
- byte[] data = state == null ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, state);
+ byte[] data = state == null ? null : MarshallerUtils.marshal(ctx, state);
saved = getSpi(ses.getCheckpointSpi()).saveCheckpoint(key, data, timeout, override);
@@ -205,7 +205,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
timeout = ses.getEndTime() - now;
// Save it first to avoid getting null value on another node.
- byte[] data = state == null ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, state);
+ byte[] data = state == null ? null : MarshallerUtils.marshal(ctx, state);
Set<String> keys = keyMap.get(ses.getId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 3c33ee0..855fd8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -1118,7 +1118,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
}
else {
if (topicOrd < 0)
- ioMsg.topicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, topic));
+ ioMsg.topicBytes(MarshallerUtils.marshal(ctx, topic));
try {
if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi)
@@ -1378,10 +1378,10 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
byte[] serTopic = null;
if (!loc) {
- serMsg = MarshallerUtils.marshal(ctx.gridName(), marsh, msg);
+ serMsg = MarshallerUtils.marshal(ctx, msg);
if (topic != null)
- serTopic = MarshallerUtils.marshal(ctx.gridName(), marsh, topic);
+ serTopic = MarshallerUtils.marshal(ctx, topic);
}
GridDeployment dep = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index 78c1c3e..86ab22e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -446,7 +446,7 @@ class GridDeploymentCommunication {
long start = U.currentTimeMillis();
if (req.responseTopic() != null && !ctx.localNodeId().equals(dstNode.id()))
- req.responseTopicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, req.responseTopic()));
+ req.responseTopicBytes(MarshallerUtils.marshal(ctx, req.responseTopic()));
ctx.io().send(dstNode, TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 6ec5d3c..7dabd81 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -933,7 +933,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ioMgr.addMessageListener(resTopic, resLsnr);
- byte[] serFilter = MarshallerUtils.marshal(ctx.gridName(), marsh, p);
+ byte[] serFilter = MarshallerUtils.marshal(ctx, p);
GridDeployment dep = ctx.deploy().deploy(p.getClass(), U.detectClassLoader(p.getClass()));
@@ -1024,7 +1024,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
ctx.io().send(locNode, topic, msg, plc);
if (!rmtNodes.isEmpty()) {
- msg.responseTopicBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, msg.responseTopic()));
+ msg.responseTopicBytes(MarshallerUtils.marshal(ctx, msg.responseTopic()));
ctx.io().send(rmtNodes, topic, msg, plc);
}
@@ -1144,8 +1144,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
log.debug("Sending event query response to node [nodeId=" + nodeId + "res=" + res + ']');
if (!ctx.localNodeId().equals(nodeId)) {
- res.eventsBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, res.events()));
- res.exceptionBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, res.exception()));
+ res.eventsBytes(MarshallerUtils.marshal(ctx, res.events()));
+ res.exceptionBytes(MarshallerUtils.marshal(ctx, res.exception()));
}
ctx.io().send(node, req.responseTopic(), res, PUBLIC_POOL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index 972fe80..1d205ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -412,7 +412,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
* @throws IgniteCheckedException If failed.
*/
private byte[] marshal(Object obj) throws IgniteCheckedException {
- return MarshallerUtils.marshal(ctx.gridName(), marsh, obj);
+ return MarshallerUtils.marshal(ctx, obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index 939c14f..599a6bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -78,7 +78,7 @@ class GridAffinityUtils {
throw new IgniteDeploymentCheckedException("Failed to deploy affinity object with class: " + cls.getName());
return new GridAffinityMessage(
- MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), o),
+ MarshallerUtils.marshal(ctx, o),
cls.getName(),
dep.classLoaderId(),
dep.deployMode(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index c59d9a6..8d0d99b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -94,7 +95,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
p.prepareMarshal(ctx);
- bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), p);
+ bytes = CU.marshal(ctx, p);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index e8c4ebc..096c2a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -23,6 +23,7 @@ import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -107,7 +108,7 @@ public class CacheInvokeDirectResult implements Message {
key.prepareMarshal(ctx.cacheObjectContext());
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
if (res != null)
res.prepareMarshal(ctx.cacheObjectContext());
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index a0913ea..6264648 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1891,4 +1891,16 @@ public class GridCacheUtils {
? DEFAULT_TX_CFG
: cfg.getTransactionConfiguration();
}
+
+ /**
+ * Marshal object.
+ *
+ * @param ctx Shared context.
+ * @param obj Object.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
+ */
+ public static byte[] marshal(GridCacheSharedContext ctx, Object obj) throws IgniteCheckedException {
+ return MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), obj);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index d805660..260672a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -203,7 +204,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index f208658..8b71d23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.marshaller.MarshallerUtils;
@@ -333,7 +334,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
// Marshal txNodes only if there is a node in topology with an older version.
if (ctx.exchange().minimumNodeVersion(topologyVersion()).compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
if (txNodes != null && txNodesBytes == null)
- txNodesBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), txNodes);
+ txNodesBytes = CU.marshal(ctx, txNodes);
}
else {
if (txNodesMsg == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index 180e446..84a5bc9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -101,7 +102,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index 1952730..fb8ca7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -107,7 +108,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
super.prepareMarshal(ctx);
if (affAssignment != null)
- affAssignmentBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), affAssignment);
+ affAssignmentBytes = CU.marshal(ctx, affAssignment);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index d60bb51..0c871e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -112,7 +113,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (checkCommittedErr != null)
- checkCommittedErrBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), checkCommittedErr);
+ checkCommittedErrBytes = CU.marshal(ctx, checkCommittedErr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index 159deee..097b316 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -168,7 +169,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
prepareMarshalCacheObjects(nearEvicted, cctx);
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index e1d0b84..0ec7ba3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -38,6 +38,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.GridLongList;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -398,7 +399,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
GridCacheContext cctx = ctx.cacheContext(cacheId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index 723c41a..2f9b4de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -172,7 +173,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
info.marshal(cctx);
}
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 9c12962..3aadf93 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -184,7 +185,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
super.prepareMarshal(ctx);
if (topic != null)
- topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), topic);
+ topicBytes = CU.marshal(ctx, topic);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index c455ca4..ad8de3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -134,10 +135,10 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
super.prepareMarshal(ctx);
if (parts != null && partsBytes == null)
- partsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), parts);
+ partsBytes = CU.marshal(ctx, parts);
if (partCntrs != null)
- partCntrsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), partCntrs);
+ partCntrsBytes = CU.marshal(ctx, partCntrs);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index b3ee57b..2daeb21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -138,10 +139,10 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
super.prepareMarshal(ctx);
if (partsBytes == null && parts != null)
- partsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), parts);
+ partsBytes = CU.marshal(ctx, parts);
if (partCntrs != null)
- partCntrsBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), partCntrs);
+ partCntrsBytes = CU.marshal(ctx, partCntrs);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index d530d06..7060463 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionable;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -191,7 +192,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
}
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
index 37af50a..fc1f442 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheDeployable;
import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -170,7 +171,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
}
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 753f5e3..b06aca5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -102,7 +103,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
super.prepareMarshal(ctx);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index b1615f1..28d8aef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -125,7 +126,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (err != null)
- errBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.marshaller(), err);
+ errBytes = CU.marshal(ctx, err);
metaDataBytes = marshalCollection(metadata, cctx);
dataBytes = marshalCollection(data, cctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 8ad4249..461d31b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -1542,7 +1542,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
depInfo = new GridDeploymentInfoBean(dep);
- bytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), obj);
+ bytes = MarshallerUtils.marshal(ctx, obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/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 8c756c1..30f99a5 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
@@ -1145,7 +1145,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
if (closureBytes == null) {
closure = c.job;
- closureBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, c.job);
+ closureBytes = MarshallerUtils.marshal(ctx, c.job);
}
if (c.job == closure)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index ef4e729..a205c2c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -1324,7 +1324,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (!msg.messages() &&
msg.data() != null &&
(nodes.size() > 1 || !ctx.localNodeId().equals(F.first(nodes).id())))
- msg.dataBytes(MarshallerUtils.marshal(ctx.gridName(), marsh, msg.data()));
+ msg.dataBytes(MarshallerUtils.marshal(ctx, msg.data()));
for (ClusterNode node : nodes) {
int cnt = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index e1f8d6b..065f5ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -91,7 +91,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
if (ctx.config().isDaemon())
return;
- marshErrBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, new IgniteCheckedException("Failed to marshal response error, " +
+ marshErrBytes = MarshallerUtils.marshal(ctx, new IgniteCheckedException("Failed to marshal response error, " +
"see node log for details."));
flusher = new IgniteThread(new GridWorker(ctx.gridName(), "grid-data-loader-flusher", log) {
@@ -332,7 +332,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
byte[] errBytes;
try {
- errBytes = err != null ? MarshallerUtils.marshal(ctx.gridName(), marsh, err) : null;
+ errBytes = err != null ? MarshallerUtils.marshal(ctx, err) : null;
}
catch (Exception e) {
U.error(log, "Failed to marshal error [err=" + err + ", marshErr=" + e + ']', e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 10f266e..01d17d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -1360,11 +1360,11 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
if (updaterBytes == null) {
assert rcvr != null;
- updaterBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), rcvr);
+ updaterBytes = MarshallerUtils.marshal(ctx, rcvr);
}
if (topicBytes == null)
- topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
+ topicBytes = MarshallerUtils.marshal(ctx, topic);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal (request will not be sent).", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index c123201..87d145b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -94,7 +94,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh, final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ @Override public void prepareMarshal(Marshaller marsh, GridKernalContext kernalCtx) throws IgniteCheckedException {
super.prepareMarshal(marsh, kernalCtx);
if (err != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index c971dc6..a3e84e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -93,8 +93,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh,
- final GridKernalContext kernalCtx) throws IgniteCheckedException {
+ @Override public void prepareMarshal(Marshaller marsh, GridKernalContext kernalCtx) throws IgniteCheckedException {
super.prepareMarshal(marsh, kernalCtx);
if (err != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
index 7571797..9892bc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
@@ -78,7 +78,7 @@ public class IgfsPaths implements Externalizable {
else {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- MarshallerUtils.marshal(new JdkMarshaller(), payload, out, igfsCtx.kernalContext().config().getGridName());
+ MarshallerUtils.marshal(igfsCtx.kernalContext().gridName(), new JdkMarshaller(), payload, out);
payloadBytes = out.toByteArray();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 92bef35..f3907c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -404,7 +404,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
boolean loc = ctx.localNodeId().equals(taskNode.id()) && !ctx.config().isMarshalLocalJobs();
GridTaskSessionRequest req = new GridTaskSessionRequest(ses.getId(), ses.getJobId(),
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs), attrs);
+ loc ? null : MarshallerUtils.marshal(ctx, attrs), attrs);
Object topic = TOPIC_TASK.topic(ses.getJobId(), ctx.discovery().localNode().id());
@@ -517,7 +517,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
ctx.io().send(taskNode, TOPIC_JOB_SIBLINGS,
new GridJobSiblingsRequest(ses.getId(),
loc ? topic : null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, topic)),
+ loc ? null : MarshallerUtils.marshal(ctx, topic)),
SYSTEM_POOL);
// 4. Listen to discovery events.
@@ -1334,11 +1334,11 @@ public class GridJobProcessor extends GridProcessorAdapter {
locNodeId,
req.getSessionId(),
req.getJobId(),
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ex),
+ loc ? null : MarshallerUtils.marshal(ctx, ex),
ex,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, null),
+ loc ? null : MarshallerUtils.marshal(ctx, null),
null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, null),
+ loc ? null : MarshallerUtils.marshal(ctx, null),
null,
false);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index d9e256c..7af32ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -746,11 +746,11 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
ctx.localNodeId(),
ses.getId(),
ses.getJobId(),
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ex),
+ loc ? null : MarshallerUtils.marshal(ctx, ex),
loc ? ex : null,
- loc ? null: MarshallerUtils.marshal(ctx.gridName(), marsh, res),
+ loc ? null: MarshallerUtils.marshal(ctx, res),
loc ? res : null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs),
+ loc ? null : MarshallerUtils.marshal(ctx, attrs),
loc ? attrs : null,
isCancelled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
index bbcfbe5..2e9e957 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
@@ -109,7 +109,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
private byte[] keyBytes(KeyCacheObject key, @Nullable byte[] keyBytes) throws IgniteCheckedException {
assert key != null;
- return keyBytes != null ? keyBytes : MarshallerUtils.marshal(ctx.gridName(), marsh, key);
+ return keyBytes != null ? keyBytes : MarshallerUtils.marshal(ctx, key);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index 484dca0..1badaf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -136,7 +136,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
res.error(err.getMessage());
else {
res.result(desc.result());
- res.resultBytes(MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), desc.result()));
+ res.resultBytes(MarshallerUtils.marshal(ctx, desc.result()));
}
}
else
@@ -495,7 +495,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
// 2. Send message.
try {
- byte[] topicBytes = MarshallerUtils.marshal(ctx.gridName(), ctx.config().getMarshaller(), topic);
+ byte[] topicBytes = MarshallerUtils.marshal(ctx, topic);
ctx.io().send(taskNode, TOPIC_REST, new GridTaskResultRequest(taskId, topic, topicBytes), SYSTEM_POOL);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 4e44abe..d7873a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -25,7 +25,6 @@ import java.nio.charset.Charset;
import java.util.Date;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
import org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponse;
@@ -210,7 +209,7 @@ public class GridTcpRestParser implements GridNioParser {
else {
GridClientMarshaller marsh = marshaller(ses);
- ByteBuffer res = MarshallerUtils.marshal(marsh, msg, 45, ses.gridName());
+ ByteBuffer res = marsh.marshal(msg, 45);
ByteBuffer slice = res.slice();
@@ -760,8 +759,7 @@ public class GridTcpRestParser implements GridNioParser {
* @return Serialization flags.
* @throws IgniteCheckedException If JDK serialization failed.
*/
- private int encodeObj(Object obj, ByteArrayOutputStream out,
- final String gridName) throws IgniteCheckedException {
+ private int encodeObj(Object obj, ByteArrayOutputStream out, final String gridName) throws IgniteCheckedException {
int flags = 0;
byte[] data = null;
@@ -809,7 +807,7 @@ public class GridTcpRestParser implements GridNioParser {
flags |= BYTE_ARR_FLAG;
}
else {
- MarshallerUtils.marshal(jdkMarshaller, obj, out, gridName);
+ MarshallerUtils.marshal(gridName, jdkMarshaller, obj, out);
flags |= SERIALIZED_FLAG;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index c90350f..3c2317e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -448,18 +448,16 @@ public class GridServiceProcessor extends GridProcessorAdapter {
validate(cfg);
if (!state.srvcCompatibility) {
- Marshaller marsh = ctx.config().getMarshaller();
-
LazyServiceConfiguration cfg0;
try {
- byte[] srvcBytes = MarshallerUtils.marshal(ctx.gridName(), marsh, cfg.getService());
+ byte[] srvcBytes = MarshallerUtils.marshal(ctx, cfg.getService());
cfg0 = new LazyServiceConfiguration(cfg, srvcBytes);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal service with configured marshaller [srvc=" + cfg.getService()
- + ", marsh=" + marsh + "]", e);
+ + ", marsh=" + ctx.config().getMarshaller() + "]", e);
return new GridFinishedFuture<>(e);
}
@@ -1134,7 +1132,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
Service svc = cfg.getService();
try {
- byte[] bytes = MarshallerUtils.marshal(ctx.gridName(), m, svc);
+ byte[] bytes = MarshallerUtils.marshal(ctx, svc);
Service cp = MarshallerUtils.unmarshal(m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(),
ctx.config()), ctx.gridName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 57b915f..7cb097f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -914,7 +914,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
GridTaskSessionRequest req = new GridTaskSessionRequest(
ses.getId(),
null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, attrs),
+ loc ? null : MarshallerUtils.marshal(ctx, attrs),
attrs);
// Make sure to go through IO manager always, since order
@@ -1315,7 +1315,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
ctx.io().send(nodeId, topic,
new GridJobSiblingsResponse(
loc ? siblings : null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, siblings)),
+ loc ? null : MarshallerUtils.marshal(ctx, siblings)),
SYSTEM_POOL);
}
catch (IgniteCheckedException e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index a4656f4..3089cc7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -1254,16 +1254,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
ses.getTaskName(),
ses.getUserVersion(),
ses.getTaskClassName(),
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, res.getJob()),
+ loc ? null : MarshallerUtils.marshal(ctx, res.getJob()),
loc ? res.getJob() : null,
ses.getStartTime(),
timeout,
ses.getTopology(),
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, ses.getJobSiblings()),
+ loc ? null : MarshallerUtils.marshal(ctx, ses.getJobSiblings()),
loc ? ses.getJobSiblings() : null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, sesAttrs),
+ loc ? null : MarshallerUtils.marshal(ctx, sesAttrs),
loc ? sesAttrs : null,
- loc ? null : MarshallerUtils.marshal(ctx.gridName(), marsh, jobAttrs),
+ loc ? null : MarshallerUtils.marshal(ctx, jobAttrs),
loc ? jobAttrs : null,
ses.getCheckpointSpi(),
dep.classLoaderId(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 2f8eb08..ce143ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -18,51 +18,37 @@
package org.apache.ignite.marshaller;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.LocalGridName;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.LocalGridName;
import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.ByteBuffer;
/**
* Utility marshaller methods.
*/
public final class MarshallerUtils {
/**
- * Marshal object. Used when grid name is not available, f.e. in tests.
- *
- * @param marsh Marshaller.
- * @param obj Object to marshal.
- * @return Result.
- * @throws IgniteCheckedException If failed.
- */
- public static byte[] marshal(final Marshaller marsh, final @Nullable Object obj) throws IgniteCheckedException {
- // This method used to keep marshaller usages in one place.
- return marsh.marshal(obj);
- }
-
- /**
- * Marshal object setting provided node name.
+ * Marshal object with provided node name.
*
- * @param gridName Node name.
+ * @param name Grid name.
* @param marsh Marshaller.
* @param obj Object to marshal.
* @return Result.
* @throws IgniteCheckedException If failed.
*/
- public static byte[] marshal(final String gridName, final Marshaller marsh, @Nullable Object obj)
- throws IgniteCheckedException {
+ public static byte[] marshal(String name, Marshaller marsh, @Nullable Object obj) throws IgniteCheckedException {
final LocalGridName gridNameTl = gridName();
final String gridNameStr = gridNameTl.getGridName();
final boolean init = gridNameTl.isSet();
try {
- gridNameTl.setGridName(true, gridName);
+ gridNameTl.setGridName(true, name);
return marsh.marshal(obj);
}
@@ -71,29 +57,24 @@ public final class MarshallerUtils {
}
}
-
-
-
-
-
/**
* Marshal object to stream and set grid name thread local.
*
+ * @param name Grid name.
* @param marshaller Marshaller.
* @param obj Object to marshal.
* @param out Output stream.
- * @param gridName Grid name.
* @throws IgniteCheckedException If fail.
*/
- public static void marshal(final Marshaller marshaller, final @Nullable Object obj,
- final OutputStream out, final String gridName) throws IgniteCheckedException {
+ public static void marshal(final String name, final Marshaller marshaller, final @Nullable Object obj,
+ final OutputStream out) throws IgniteCheckedException {
final LocalGridName gridNameTl = gridName();
final String gridNameStr = gridNameTl.getGridName();
final boolean init = gridNameTl.isSet();
try {
- gridNameTl.setGridName(true, gridName);
+ gridNameTl.setGridName(true, name);
marshaller.marshal(obj, out);
} finally {
@@ -102,6 +83,30 @@ public final class MarshallerUtils {
}
/**
+ * Marshal object with node name taken from provided kernal context.
+ *
+ * @param ctx Kernal context.
+ * @param obj Object to marshal.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
+ */
+ public static byte[] marshal(GridKernalContext ctx, @Nullable Object obj) throws IgniteCheckedException {
+ return marshal(ctx.gridName(), ctx.config().getMarshaller(), obj);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /**
* Unmarshal object from stream and set grid name thread local.
*
* @param marshaller Marshaller.
@@ -110,7 +115,7 @@ public final class MarshallerUtils {
* @param gridName Grid name.
* @param <T> Target type.
* @return Deserialized object.
- * @throws IgniteCheckedException
+ * @throws IgniteCheckedException If failed.
*/
public static <T> T unmarshal(final Marshaller marshaller, InputStream in, @Nullable ClassLoader clsLdr,
final String gridName) throws IgniteCheckedException {
@@ -200,32 +205,6 @@ public final class MarshallerUtils {
}
/**
- * Marshal object and set grid name thread local.
- *
- * @param gridMarshaller Grid marshaller.
- * @param obj Object to marshal.
- * @param off Offset.
- * @param gridName Grid name.
- * @return Serialized data.
- * @throws IOException If fail.
- */
- public static ByteBuffer marshal(GridClientMarshaller gridMarshaller, Object obj, int off,
- String gridName) throws IOException {
- final LocalGridName gridNameTl = gridName();
-
- final String gridNameStr = gridNameTl.getGridName();
- final boolean init = gridNameTl.isSet();
-
- try {
- gridNameTl.setGridName(true, gridName);
-
- return gridMarshaller.marshal(obj, off);
- } finally {
- gridNameTl.setGridName(init, gridNameStr);
- }
- }
-
- /**
* Unmarshal object and set grid name thread local.
*
* @param gridMarshaller Grid marshaller.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
index da55499..f25bad3 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
@@ -94,7 +94,7 @@ final class SharedFsUtils {
try {
out = new FileOutputStream(file);
- MarshallerUtils.marshal(m, data, out, igniteCfg.getGridName());
+ MarshallerUtils.marshal(igniteCfg.getGridName(), m, data, out);
}
finally {
U.close(out, log);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index b53a81e..67e7798 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -430,8 +430,7 @@ class ClientImpl extends TcpDiscoveryImpl {
throw new IgniteClientDisconnectedException(null, "Failed to send custom message: client is disconnected.");
try {
- sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, evt)));
+ sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt, marshal(evt)));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -684,9 +683,10 @@ class ClientImpl extends TcpDiscoveryImpl {
// Use security-unsafe getter.
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)
- ));
+ attrs.put(
+ IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
+ marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS))
+ );
node.setAttributes(attrs);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index be108f8..97696cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -742,8 +742,7 @@ class ServerImpl extends TcpDiscoveryImpl {
/** {@inheritDoc} */
@Override public void sendCustomEvent(DiscoverySpiCustomMessage evt) {
try {
- msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, evt)));
+ msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt, marshal(evt)));
}
catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -826,8 +825,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(locNode.attributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, marshal(subj));
attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
locNode.setAttributes(attrs);
@@ -1242,9 +1240,10 @@ class ServerImpl extends TcpDiscoveryImpl {
// Use security-unsafe getter.
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh,
- attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
+ attrs.put(
+ IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
+ marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS))
+ );
node.setAttributes(attrs);
}
@@ -2361,7 +2360,7 @@ class ServerImpl extends TcpDiscoveryImpl {
for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
if (msgBytes == null) {
try {
- msgBytes = MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msg);
+ msgBytes = marshal(msg);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to marshal message: " + msg, e);
@@ -3139,8 +3138,7 @@ class ServerImpl extends TcpDiscoveryImpl {
// Stick in authentication subject to node (use security-safe attributes for copy).
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, marshal(subj));
node.setAttributes(attrs);
}
@@ -4858,9 +4856,8 @@ class ServerImpl extends TcpDiscoveryImpl {
if (nextMsg != null) {
try {
- TcpDiscoveryCustomEventMessage ackMsg = new TcpDiscoveryCustomEventMessage(
- getLocalNodeId(), nextMsg,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, nextMsg));
+ TcpDiscoveryCustomEventMessage ackMsg =
+ new TcpDiscoveryCustomEventMessage(getLocalNodeId(), nextMsg, marshal(nextMsg));
ackMsg.topologyVersion(msg.topologyVersion());
@@ -5004,8 +5001,7 @@ class ServerImpl extends TcpDiscoveryImpl {
msgObj);
if (msgObj.isMutable())
- msg.message(msgObj,
- MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msgObj));
+ msg.message(msgObj, marshal(msgObj));
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -5932,7 +5928,7 @@ class ServerImpl extends TcpDiscoveryImpl {
byte[] msgBytes = msgT.get2();
if (msgBytes == null)
- msgBytes = MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, msg);
+ msgBytes = marshal(msg);
if (msg instanceof TcpDiscoveryClientAckResponse) {
if (clientVer == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index 30b83e5..7eb915e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -26,12 +26,15 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedDeque;
+
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.spi.IgniteSpiContext;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.IgniteSpiThread;
@@ -326,4 +329,15 @@ abstract class TcpDiscoveryImpl {
return res;
}
+
+ /**
+ * Marshal object.
+ *
+ * @param obj Object.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected byte[] marshal(Object obj) throws IgniteCheckedException {
+ return MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, obj);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7f99d92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index de9877c..9e4669a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1378,7 +1378,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
IgniteCheckedException err = null;
try {
- MarshallerUtils.marshal(marsh, msg, out, ignite.configuration().getGridName());
+ MarshallerUtils.marshal(ignite.name(), marsh, msg, out);
}
catch (IgniteCheckedException e) {
err = e;
[11/50] [abbrv] ignite git commit: Merge branch 'gridgain-7.5.30' of
https://github.com/gridgain/apache-ignite into gridgain-7.5.30
Posted by vo...@apache.org.
Merge branch 'gridgain-7.5.30' of https://github.com/gridgain/apache-ignite into gridgain-7.5.30
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6389400a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6389400a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6389400a
Branch: refs/heads/ignite-2649
Commit: 6389400a91f1fc95c9b55e78ab8eef55f99b1093
Parents: 2537e0f 27f6c58
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Jul 15 09:35:57 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Jul 15 09:35:57 2016 +0300
----------------------------------------------------------------------
.../examples/IndexingBridgeMethodTest.java | 93 ++++++++++++
.../IgniteExamplesJ8SelfTestSuite.java | 2 +
.../configuration/CacheConfiguration.java | 3 +
.../OptimizedObjectStreamRegistry.java | 145 +++++++++++--------
.../OptimizedMarshallerPooledSelfTest.java | 44 ++++++
.../testsuites/IgniteBinaryBasicTestSuite.java | 2 +
.../IgniteMarshallerSelfTestSuite.java | 2 +
7 files changed, 228 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
[10/50] [abbrv] ignite git commit: IgniteDataStreamer: fixed JavaDoc
Posted by vo...@apache.org.
IgniteDataStreamer: fixed JavaDoc
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2537e0f6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2537e0f6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2537e0f6
Branch: refs/heads/ignite-2649
Commit: 2537e0f62a1a1ecba315b18f4ed9bf38ff99d5df
Parents: 10224df
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Jul 15 09:35:41 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Jul 15 09:35:41 2016 +0300
----------------------------------------------------------------------
.../core/src/main/java/org/apache/ignite/IgniteDataStreamer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2537e0f6/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
index 887443f..472c5e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
@@ -212,7 +212,7 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* By default the timeout is disabled.
*
* @param timeout Timeout in milliseconds.
- * @throws IllegalArgumentException If {@param timeout} is zero or less than {@code -1}.
+ * @throws IllegalArgumentException If timeout is zero or less than {@code -1}.
*/
public void timeout(long timeout);
@@ -424,7 +424,7 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable {
* @param cancel {@code True} to cancel ongoing streaming operations.
* @throws CacheException If failed to map key to node.
* @throws IgniteInterruptedException If thread has been interrupted.
- * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded, only if {@param cancel} is {@code false}.
+ * @throws IgniteDataStreamerTimeoutException If {@code timeout} is exceeded, only if cancel is {@code false}.
*/
public void close(boolean cancel) throws CacheException, IgniteInterruptedException,
IgniteDataStreamerTimeoutException;
[09/50] [abbrv] ignite git commit: Fixed NPE in OptimizedMarshaller
when streams pool is used
Posted by vo...@apache.org.
Fixed NPE in OptimizedMarshaller when streams pool is used
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/27f6c586
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/27f6c586
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/27f6c586
Branch: refs/heads/ignite-2649
Commit: 27f6c5862940948669b6445a6839501327dacbb2
Parents: 4d2be72
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Jul 13 14:37:23 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Jul 13 14:37:23 2016 -0700
----------------------------------------------------------------------
.../OptimizedObjectStreamRegistry.java | 145 +++++++++++--------
.../OptimizedMarshallerPooledSelfTest.java | 44 ++++++
.../testsuites/IgniteBinaryBasicTestSuite.java | 2 +
.../IgniteMarshallerSelfTestSuite.java | 2 +
4 files changed, 130 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/27f6c586/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
index e0e4872..fd1b917 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
@@ -33,8 +33,11 @@ class OptimizedObjectStreamRegistry {
/** Holders. */
private static final ThreadLocal<StreamHolder> holders = new ThreadLocal<>();
- /** Holders pool. */
- private static BlockingQueue<StreamHolder> pool;
+ /** Output streams pool. */
+ private static BlockingQueue<OptimizedObjectOutputStream> outPool;
+
+ /** Input streams pool. */
+ private static BlockingQueue<OptimizedObjectInputStream> inPool;
/**
* Ensures singleton.
@@ -50,16 +53,18 @@ class OptimizedObjectStreamRegistry {
*/
static void poolSize(int size) {
if (size > 0) {
- pool = new LinkedBlockingQueue<>(size);
+ outPool = new LinkedBlockingQueue<>(size);
+ inPool = new LinkedBlockingQueue<>(size);
for (int i = 0; i < size; i++) {
- boolean b = pool.offer(new StreamHolder());
-
- assert b;
+ outPool.offer(createOut());
+ inPool.offer(createIn());
}
}
- else
- pool = null;
+ else {
+ outPool = null;
+ inPool = null;
+ }
}
/**
@@ -69,7 +74,17 @@ class OptimizedObjectStreamRegistry {
* @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If thread is interrupted while trying to take holder from pool.
*/
static OptimizedObjectOutputStream out() throws IgniteInterruptedCheckedException {
- return holder().acquireOut();
+ if (outPool != null) {
+ try {
+ return outPool.take();
+ }
+ catch (InterruptedException e) {
+ throw new IgniteInterruptedCheckedException(
+ "Failed to take output object stream from pool (thread interrupted).", e);
+ }
+ }
+ else
+ return holder().acquireOut();
}
/**
@@ -79,7 +94,17 @@ class OptimizedObjectStreamRegistry {
* @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If thread is interrupted while trying to take holder from pool.
*/
static OptimizedObjectInputStream in() throws IgniteInterruptedCheckedException {
- return holder().acquireIn();
+ if (inPool != null) {
+ try {
+ return inPool.take();
+ }
+ catch (InterruptedException e) {
+ throw new IgniteInterruptedCheckedException(
+ "Failed to take input object stream from pool (thread interrupted).", e);
+ }
+ }
+ else
+ return holder().acquireIn();
}
/**
@@ -90,17 +115,17 @@ class OptimizedObjectStreamRegistry {
static void closeOut(OptimizedObjectOutputStream out) {
U.close(out, null);
- StreamHolder holder = holders.get();
-
- holder.releaseOut();
-
- if (pool != null) {
- holders.remove();
-
- boolean b = pool.offer(holder);
+ if (outPool != null) {
+ boolean b = outPool.offer(out);
assert b;
}
+ else {
+ StreamHolder holder = holders.get();
+
+ if (holder != null)
+ holder.releaseOut();
+ }
}
/**
@@ -112,17 +137,17 @@ class OptimizedObjectStreamRegistry {
static void closeIn(OptimizedObjectInputStream in) {
U.close(in, null);
- StreamHolder holder = holders.get();
-
- holder.releaseIn();
-
- if (pool != null) {
- holders.remove();
-
- boolean b = pool.offer(holder);
+ if (inPool != null) {
+ boolean b = inPool.offer(in);
assert b;
}
+ else {
+ StreamHolder holder = holders.get();
+
+ if (holder != null)
+ holder.releaseIn();
+ }
}
/**
@@ -134,19 +159,41 @@ class OptimizedObjectStreamRegistry {
private static StreamHolder holder() throws IgniteInterruptedCheckedException {
StreamHolder holder = holders.get();
- if (holder == null) {
- try {
- holders.set(holder = pool != null ? pool.take() : new StreamHolder());
- }
- catch (InterruptedException e) {
- throw new IgniteInterruptedCheckedException("Failed to take object stream from pool (thread interrupted).", e);
- }
- }
+ if (holder == null)
+ holders.set(holder = new StreamHolder());
return holder;
}
/**
+ * Creates output stream.
+ *
+ * @return Object output stream.
+ */
+ private static OptimizedObjectOutputStream createOut() {
+ try {
+ return new OptimizedObjectOutputStream(new GridUnsafeDataOutput(4 * 1024));
+ }
+ catch (IOException e) {
+ throw new IgniteException("Failed to create object output stream.", e);
+ }
+ }
+
+ /**
+ * Creates input stream.
+ *
+ * @return Object input stream.
+ */
+ private static OptimizedObjectInputStream createIn() {
+ try {
+ return new OptimizedObjectInputStream(new GridUnsafeDataInput());
+ }
+ catch (IOException e) {
+ throw new IgniteException("Failed to create object input stream.", e);
+ }
+ }
+
+ /**
* Streams holder.
*/
private static class StreamHolder {
@@ -193,33 +240,5 @@ class OptimizedObjectStreamRegistry {
void releaseIn() {
inAcquireCnt--;
}
-
- /**
- * Creates output stream.
- *
- * @return Object output stream.
- */
- private OptimizedObjectOutputStream createOut() {
- try {
- return new OptimizedObjectOutputStream(new GridUnsafeDataOutput(4 * 1024));
- }
- catch (IOException e) {
- throw new IgniteException("Failed to create object output stream.", e);
- }
- }
-
- /**
- * Creates input stream.
- *
- * @return Object input stream.
- */
- private OptimizedObjectInputStream createIn() {
- try {
- return new OptimizedObjectInputStream(new GridUnsafeDataInput());
- }
- catch (IOException e) {
- throw new IgniteException("Failed to create object input stream.", e);
- }
- }
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/27f6c586/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
new file mode 100644
index 0000000..a883270
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.marshaller.optimized;
+
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Optimized marshaller self test.
+ */
+@GridCommonTest(group = "Marshaller")
+public class OptimizedMarshallerPooledSelfTest extends OptimizedMarshallerSelfTest {
+ /** {@inheritDoc} */
+ @Override protected Marshaller marshaller() {
+ OptimizedMarshaller m = new OptimizedMarshaller(false);
+
+ m.setPoolSize(8);
+
+ return m;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ // Reset static registry.
+ new OptimizedMarshaller().setPoolSize(0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/27f6c586/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
index 2aabf4f..734e199 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -40,6 +40,7 @@ import org.apache.ignite.marshaller.DynamicProxySerializationMultiJvmSelfTest;
import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerNodeFailoverTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerPooledSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSerialPersistentFieldsSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerTest;
@@ -88,6 +89,7 @@ public class IgniteBinaryBasicTestSuite extends TestSuite {
ignoredTests.add(GridDeploymentMessageCountSelfTest.class);
ignoredTests.add(DynamicProxySerializationMultiJvmSelfTest.class);
ignoredTests.add(GridHandleTableSelfTest.class);
+ ignoredTests.add(OptimizedMarshallerPooledSelfTest.class);
// TODO: check and delete if pass.
ignoredTests.add(IgniteDaemonNodeMarshallerCacheTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/27f6c586/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
index ec0ec23..99cbf60 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTes
import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerNodeFailoverTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerPooledSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSerialPersistentFieldsSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerTest;
@@ -59,6 +60,7 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerNodeFailoverTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerSerialPersistentFieldsSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, GridHandleTableSelfTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerPooledSelfTest.class, ignoredTests);
return suite;
}