Repository: ignite Updated Branches: refs/heads/master cc0dbd161 -> 18077e073
IGNITE-1566: IGFS: Improved error message when IGFS name is not specified in URL. This closes #216. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/18077e07 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/18077e07 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/18077e07 Branch: refs/heads/master Commit: 18077e073c130966e61b221a35527f8217377ebe Parents: cc0dbd1 Author: iveselovskiy <[email protected]> Authored: Tue Apr 12 16:00:36 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Tue Apr 12 16:00:36 2016 +0300 ---------------------------------------------------------------------- .../processors/igfs/IgfsIpcHandler.java | 12 +- .../hadoop/igfs/HadoopIgfsWrapper.java | 11 +- .../ignite/igfs/Hadoop1DualAbstractTest.java | 2 +- ...IgniteHadoopFileSystemHandshakeSelfTest.java | 121 +++++++++++++++---- 4 files changed, 113 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/18077e07/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java index bf87384..a888aff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java @@ -257,13 +257,13 @@ class IgfsIpcHandler implements IgfsServerHandler { * @throws IgniteCheckedException In case of handshake failure. */ private IgfsMessage processHandshakeRequest(IgfsHandshakeRequest req) throws IgniteCheckedException { - if (!F.eq(ctx.gridName(), req.gridName())) - throw new IgniteCheckedException("Failed to perform handshake because actual Grid name differs from expected " + - "[expected=" + req.gridName() + ", actual=" + ctx.gridName() + ']'); + if (req.gridName() != null && !F.eq(ctx.gridName(), req.gridName())) + throw new IgniteCheckedException("Failed to perform handshake because existing Grid name " + + "differs from requested [requested=" + req.gridName() + ", existing=" + ctx.gridName() + ']'); - if (!F.eq(igfs.name(), req.igfsName())) - throw new IgniteCheckedException("Failed to perform handshake because actual IGFS name differs from expected " + - "[expected=" + req.igfsName() + ", actual=" + igfs.name() + ']'); + if (req.igfsName() != null && !F.eq(igfs.name(), req.igfsName())) + throw new IgniteCheckedException("Failed to perform handshake because existing IGFS name " + + "differs from requested [requested=" + req.igfsName() + ", existing=" + igfs.name() + ']'); IgfsControlResponse res = new IgfsControlResponse(); http://git-wip-us.apache.org/repos/asf/ignite/blob/18077e07/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java index 69df381..f4ee97f 100644 --- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java +++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java @@ -19,16 +19,15 @@ package org.apache.ignite.internal.processors.hadoop.igfs; import java.io.IOException; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.hadoop.conf.Configuration; -import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.IgniteIllegalStateException; -import org.apache.ignite.IgniteState; import org.apache.ignite.Ignition; import org.apache.ignite.igfs.IgfsBlockLocation; import org.apache.ignite.igfs.IgfsFile; @@ -38,6 +37,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsEx; import org.apache.ignite.internal.processors.igfs.IgfsHandshakeResponse; import org.apache.ignite.internal.processors.igfs.IgfsStatus; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; @@ -335,7 +335,12 @@ public class HadoopIgfsWrapper implements HadoopIgfs { } } - throw new IOException("Failed to communicate with IGFS.", err); + List<Throwable> list = X.getThrowableList(err); + + Throwable cause = list.get(list.size() - 1); + + throw new IOException("Failed to communicate with IGFS: " + + (cause.getMessage() == null ? cause.toString() : cause.getMessage()), err); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/18077e07/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java index f4c1cb7..d1d7c10 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java @@ -25,7 +25,7 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem; import org.apache.ignite.internal.processors.igfs.IgfsDualAbstractSelfTest; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import static org.apache.ignite.igfs.HadoopSecondaryFileSystemConfigurationTest.IGFS_SCHEME; +import static org.apache.ignite.IgniteFileSystem.IGFS_SCHEME; import static org.apache.ignite.igfs.HadoopSecondaryFileSystemConfigurationTest.SECONDARY_CFG_PATH; import static org.apache.ignite.igfs.HadoopSecondaryFileSystemConfigurationTest.configuration; import static org.apache.ignite.igfs.HadoopSecondaryFileSystemConfigurationTest.mkUri; http://git-wip-us.apache.org/repos/asf/ignite/blob/18077e07/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java index e4e1c85..fdb0d77 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java @@ -44,6 +44,7 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.igfs.IgfsMode.PRIMARY; import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.PARAM_IGFS_ENDPOINT_NO_EMBED; import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.PARAM_IGFS_ENDPOINT_NO_LOCAL_SHMEM; +import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.PARAM_IGFS_ENDPOINT_NO_LOCAL_TCP; import static org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT; /** @@ -62,6 +63,12 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT /** IGFS path. */ private static final IgfsPath PATH = new IgfsPath("/path"); + /** A host-port pair used for URI in embedded mode. */ + private static final String HOST_PORT_UNUSED = "somehost:65333"; + + /** Flag defines if to use TCP or embedded connection mode: */ + private boolean tcp = false; + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(true); @@ -75,21 +82,37 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT public void testHandshake() throws Exception { startUp(false, false); + tcp = true; + checkValid(IGFS_NAME + ":" + GRID_NAME + "@"); checkValid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1"); checkValid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); - checkInvalid(IGFS_NAME + "@"); - checkInvalid(IGFS_NAME + "@127.0.0.1"); - checkInvalid(IGFS_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); + checkValid(IGFS_NAME + "@"); + checkValid(IGFS_NAME + "@127.0.0.1"); + checkValid(IGFS_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); - checkInvalid(":" + GRID_NAME + "@"); - checkInvalid(":" + GRID_NAME + "@127.0.0.1"); - checkInvalid(":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); + checkValid(":" + GRID_NAME + "@"); + checkValid(":" + GRID_NAME + "@127.0.0.1"); + checkValid(":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); - checkInvalid(""); - checkInvalid("127.0.0.1"); - checkInvalid("127.0.0.1:" + DFLT_IPC_PORT); + checkValid(""); + checkValid("127.0.0.1"); + checkValid("127.0.0.1:" + DFLT_IPC_PORT); + + tcp = false; // Embedded mode: + + checkValid(IGFS_NAME + ":" + GRID_NAME + "@"); + checkValid(IGFS_NAME + ":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid(IGFS_NAME + "@"); // Embedded mode fails, but remote tcp succeeds. + checkInvalid(IGFS_NAME + "@" + HOST_PORT_UNUSED); + + checkValid(":" + GRID_NAME + "@"); // Embedded mode fails, but remote tcp succeeds. + checkInvalid(":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid("@"); // Embedded mode fails, but remote tcp succeeds. + checkInvalid("@" + HOST_PORT_UNUSED); } /** @@ -100,6 +123,8 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT public void testHandshakeDefaultGrid() throws Exception { startUp(true, false); + tcp = true; + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1"); checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); @@ -112,9 +137,23 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT checkInvalid(":" + GRID_NAME + "@127.0.0.1"); checkInvalid(":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); - checkInvalid(""); - checkInvalid("127.0.0.1"); - checkInvalid("127.0.0.1:" + DFLT_IPC_PORT); + checkValid(""); + checkValid("127.0.0.1"); + checkValid("127.0.0.1:" + DFLT_IPC_PORT); + + tcp = false; // Embedded mode: + + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid(IGFS_NAME + "@"); + checkValid(IGFS_NAME + "@" + HOST_PORT_UNUSED); + + checkInvalid(":" + GRID_NAME + "@"); + checkInvalid(":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid("@"); // Embedded mode fails, but remote tcp succeeds. + checkInvalid("@" + HOST_PORT_UNUSED); } /** @@ -123,7 +162,9 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT * @throws Exception If failed. */ public void testHandshakeDefaultIgfs() throws Exception { - startUp(false, true); + startUp(false/*grid name*/, true/*default igfs*/); + + tcp = true; checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1"); @@ -137,9 +178,23 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT checkValid(":" + GRID_NAME + "@127.0.0.1"); checkValid(":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); - checkInvalid(""); - checkInvalid("127.0.0.1"); - checkInvalid("127.0.0.1:" + DFLT_IPC_PORT); + checkValid(""); + checkValid("127.0.0.1"); + checkValid("127.0.0.1:" + DFLT_IPC_PORT); + + tcp = false; // Embedded mode: + + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkInvalid(IGFS_NAME + "@"); + checkInvalid(IGFS_NAME + "@" + HOST_PORT_UNUSED); + + checkValid(":" + GRID_NAME + "@"); + checkValid(":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid("@"); // NB: in embedded mode this fails, but remote TCP still succeeds. + checkInvalid("@" + HOST_PORT_UNUSED); } /** @@ -150,6 +205,8 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT public void testHandshakeDefaultGridDefaultIgfs() throws Exception { startUp(true, true); + tcp = true; + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1"); checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1:" + DFLT_IPC_PORT); @@ -165,6 +222,20 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT checkValid(""); checkValid("127.0.0.1"); checkValid("127.0.0.1:" + DFLT_IPC_PORT); + + tcp = false; // Embedded mode: + + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@"); + checkInvalid(IGFS_NAME + ":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkInvalid(IGFS_NAME + "@"); + checkInvalid(IGFS_NAME + "@" + HOST_PORT_UNUSED); + + checkInvalid(":" + GRID_NAME + "@"); + checkInvalid(":" + GRID_NAME + "@" + HOST_PORT_UNUSED); + + checkValid("@"); + checkValid("@" + HOST_PORT_UNUSED); } /** @@ -257,7 +328,7 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT * @throws Exception If failed. */ private void checkValid(String authority) throws Exception { - FileSystem fs = fileSystem(authority); + FileSystem fs = fileSystem(authority, tcp); assert fs.exists(new Path(PATH.toString())); } @@ -272,7 +343,7 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT private void checkInvalid(final String authority) throws Exception { GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { - fileSystem(authority); + fileSystem(authority, tcp); return null; } @@ -280,14 +351,14 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT } /** - * + * Gets the file system using authority and tcp flag. * * @param authority Authority. * @return File system. * @throws Exception If failed. */ - private static FileSystem fileSystem(String authority) throws Exception { - return FileSystem.get(new URI("igfs://" + authority + "/"), configuration(authority)); + private static FileSystem fileSystem(String authority, boolean tcp) throws Exception { + return FileSystem.get(new URI("igfs://" + authority + "/"), configuration(authority, tcp)); } /** @@ -296,7 +367,7 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT * @param authority Authority. * @return Configuration. */ - private static Configuration configuration(String authority) { + private static Configuration configuration(String authority, boolean tcp) { Configuration cfg = new Configuration(); cfg.set("fs.defaultFS", "igfs://" + authority + "/"); @@ -306,7 +377,11 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT cfg.setBoolean("fs.igfs.impl.disable.cache", true); - cfg.setBoolean(String.format(PARAM_IGFS_ENDPOINT_NO_EMBED, authority), true); + if (tcp) + cfg.setBoolean(String.format(PARAM_IGFS_ENDPOINT_NO_EMBED, authority), true); + else + cfg.setBoolean(String.format(PARAM_IGFS_ENDPOINT_NO_LOCAL_TCP, authority), true); + cfg.setBoolean(String.format(PARAM_IGFS_ENDPOINT_NO_LOCAL_SHMEM, authority), true); return cfg;
