ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [10/40] ignite git commit: IGNITE-3597: Removed static work directory.
Date Mon, 17 Oct 2016 17:59:07 GMT
IGNITE-3597: Removed static work directory.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: a92f20b5cc75e6b80b2731da0192723526b0c1dc
Parents: bba019f
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Oct 4 14:10:26 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Oct 4 14:10:26 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContextImpl.java  |   4 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  15 +-
 .../ignite/internal/MarshallerContextImpl.java  |   5 +-
 .../processors/hadoop/HadoopHelper.java         |   7 +
 .../internal/processors/hadoop/HadoopJob.java   |   5 +
 .../processors/hadoop/HadoopNoopHelper.java     |   5 +
 .../internal/processors/igfs/IgfsServer.java    |   5 +-
 .../cpp/PlatformCppConfigurationClosure.java    |  13 +-
 .../PlatformDotNetConfigurationClosure.java     |  13 +-
 .../platform/utils/PlatformUtils.java           |   8 +-
 .../ignite/internal/util/IgniteUtils.java       |  92 +++++-----
 .../shmem/IpcSharedMemoryServerEndpoint.java    |  15 +-
 .../apache/ignite/logger/java/JavaLogger.java   |  14 +-
 .../logger/java/JavaLoggerFileHandler.java      |  10 +-
 .../sharedfs/SharedFsCheckpointSpi.java         |   3 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   4 +-
 .../sharedfs/TcpDiscoverySharedFsIpFinder.java  |   2 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   2 +-
 .../MarshallerContextLockingSelfTest.java       |   2 +-
 .../MarshallerCacheJobRunNodeRestartTest.java   |   2 +-
 .../handlers/log/GridLogCommandHandlerTest.java |   5 +-
 ...artupWithSpecifiedWorkDirectorySelfTest.java | 166 -------------------
 .../ipc/shmem/IgfsSharedMemoryTestServer.java   |   4 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   9 +-
 .../IpcSharedMemoryBenchmarkReader.java         |   2 +-
 .../ignite/logger/java/JavaLoggerTest.java      |   3 +-
 .../OptimizedMarshallerNodeFailoverTest.java    |   4 -
 ...heckpointSpiMultipleDirectoriesSelfTest.java |   6 +-
 .../GridAbstractCommunicationSelfTest.java      |   2 -
 ...cpCommunicationSpiMultithreadedSelfTest.java |   2 -
 .../GridSwapSpaceSpiAbstractSelfTest.java       |   2 -
 .../testframework/junits/GridAbstractTest.java  |   2 +-
 .../ignite/testframework/junits/IgniteMock.java |  10 ++
 .../junits/IgniteTestResources.java             |   2 -
 .../junits/spi/GridSpiAbstractTest.java         |   2 -
 .../testsuites/IgniteBinaryBasicTestSuite.java  |   2 -
 .../testsuites/IgniteKernalSelfTestSuite.java   |   2 -
 .../CacheNoValueClassOnServerTestClient.java    |   2 -
 .../CacheConfigurationP2PTestClient.java        |   2 -
 .../processors/hadoop/HadoopHelperImpl.java     |  13 ++
 .../processors/hadoop/impl/HadoopUtils.java     |  11 +-
 .../processors/hadoop/impl/v2/HadoopV2Job.java  |  13 +-
 .../hadoop/impl/v2/HadoopV2TaskContext.java     |   4 +-
 .../external/HadoopExternalTaskExecutor.java    |  13 +-
 .../child/HadoopExternalProcessStarter.java     |  10 +-
 .../HadoopExternalCommunication.java            |  10 +-
 .../hadoop/impl/HadoopPlannerMockJob.java       |   7 +
 .../HadoopExternalCommunicationSelfTest.java    |   2 +-
 .../cache/CacheConfigurationP2PTestServer.java  |   2 -
 .../IgniteConfigurationTest.cs                  |   2 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |   2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |   2 +-
 52 files changed, 209 insertions(+), 337 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index eb214e8..c7e26e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -408,7 +408,9 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.restExecSvc = restExecSvc;
         this.callbackExecSvc = callbackExecSvc;
 
-        marshCtx = new MarshallerContextImpl(plugins);
+        String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
+
+        marshCtx = new MarshallerContextImpl(workDir, plugins);
 
         try {
             spring = SPRING.create(false);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 aad96fb..2914c7c 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
@@ -1823,7 +1823,10 @@ public class IgnitionEx {
                 // If user provided IGNITE_HOME - set it as a system property.
                 U.setIgniteHome(ggHome);
 
-            U.setWorkDirectory(cfg.getWorkDirectory(), ggHome);
+            // Correctly resolve work directory and set it back to configuration.
+            String workDir = U.workDirectory(cfg.getWorkDirectory(), ggHome);
+
+            myCfg.setWorkDirectory(workDir);
 
             // Ensure invariant.
             // It's a bit dirty - but this is a result of late refactoring
@@ -1834,7 +1837,7 @@ public class IgnitionEx {
 
             myCfg.setNodeId(nodeId);
 
-            IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId);
+            IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId, workDir);
 
             assert cfgLog != null;
 
@@ -2095,11 +2098,13 @@ public class IgnitionEx {
         /**
          * @param cfgLog Configured logger.
          * @param nodeId Local node ID.
+         * @param workDir Work directory.
          * @return Initialized logger.
          * @throws IgniteCheckedException If failed.
          */
         @SuppressWarnings("ErrorNotRethrown")
-        private IgniteLogger initLogger(@Nullable IgniteLogger cfgLog, UUID nodeId) throws IgniteCheckedException {
+        private IgniteLogger initLogger(@Nullable IgniteLogger cfgLog, UUID nodeId, String workDir)
+            throws IgniteCheckedException {
             try {
                 Exception log4jInitErr = null;
 
@@ -2157,6 +2162,10 @@ public class IgnitionEx {
                         cfgLog = new JavaLogger();
                 }
 
+                // Special handling for Java logger which requires work directory.
+                if (cfgLog instanceof JavaLogger)
+                    ((JavaLogger)cfgLog).setWorkDirectory(workDir);
+
                 // Set node IDs for all file appenders.
                 if (cfgLog instanceof LoggerNodeIdAware)
                     ((LoggerNodeIdAware)cfgLog).setNodeId(nodeId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 0420e18..e501d27 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
@@ -72,13 +72,14 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     private ContinuousQueryListener lsnr;
 
     /**
+     * @param igniteWorkDir Ignite work directory.
      * @param plugins Plugins.
      * @throws IgniteCheckedException In case of error.
      */
-    public MarshallerContextImpl(List<PluginProvider> plugins) throws IgniteCheckedException {
+    public MarshallerContextImpl(String igniteWorkDir, List<PluginProvider> plugins) throws IgniteCheckedException {
         super(plugins);
 
-        workDir = U.resolveWorkDirectory("marshaller", false);
+        workDir = U.resolveWorkDirectory(igniteWorkDir, "marshaller", false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
index a8fee79..7936fef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
@@ -52,4 +52,11 @@ public interface HadoopHelper {
      * @return Input stream.
      */
     @Nullable public InputStream loadClassBytes(ClassLoader ldr, String clsName);
+
+    /**
+     * Get work directory.
+     *
+     * @return Work directory.
+     */
+    public String workDirectory();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
index 2f6f6a7..a77c744 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
@@ -99,4 +99,9 @@ public interface HadoopJob {
      * Cleans up the job staging directory.
      */
     public void cleanupStagingDirectory();
+
+    /**
+     * @return Ignite work directory.
+     */
+    public String igniteWorkDirectory();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
index d3348ca..f8f870f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
@@ -57,6 +57,11 @@ public class HadoopNoopHelper implements HadoopHelper {
         throw unsupported();
     }
 
+    /** {@inheritDoc} */
+    @Override public String workDirectory() {
+        throw unsupported();
+    }
+
     /**
      * @return Exception.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
index aa4b115..b2c3c83 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
@@ -153,7 +153,7 @@ public class IgfsServer {
      * @return Server endpoint.
      * @throws IgniteCheckedException If failed.
      */
-    private static IpcServerEndpoint createEndpoint(IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt)
+    private IpcServerEndpoint createEndpoint(IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt)
         throws IgniteCheckedException {
         A.notNull(endpointCfg, "endpointCfg");
 
@@ -164,7 +164,8 @@ public class IgfsServer {
 
         switch (typ) {
             case SHMEM: {
-                IpcSharedMemoryServerEndpoint endpoint = new IpcSharedMemoryServerEndpoint();
+                IpcSharedMemoryServerEndpoint endpoint =
+                    new IpcSharedMemoryServerEndpoint(igfsCtx.kernalContext().config().getWorkDirectory());
 
                 endpoint.setPort(endpointCfg.getPort());
                 endpoint.setSize(endpointCfg.getMemorySize());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 2e60025..f6711d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.platform.cpp;
 
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
@@ -130,17 +129,7 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();
 
-        if (ggHome == null)
-            ggHome = U.getIgniteHome();
-        else
-            // If user provided IGNITE_HOME - set it as a system property.
+        if (ggHome != null)
             U.setIgniteHome(ggHome);
-
-        try {
-            U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 5a7d15d..ed40be5 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
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.platform.dotnet;
 
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
 import org.apache.ignite.binary.BinaryBasicNameMapper;
@@ -151,19 +150,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();
 
-        if (ggHome == null)
-            ggHome = U.getIgniteHome();
-        else
-            // If user provided IGNITE_HOME - set it as a system property.
+        if (ggHome != null)
             U.setIgniteHome(ggHome);
 
-        try {
-            U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-
         // 4. Callback to .Net.
         prepare(igniteCfg, dotNetCfg0);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index b31bbd3..ec025c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -786,12 +786,16 @@ public class PlatformUtils {
     @SuppressWarnings("deprecation")
     public static GridBinaryMarshaller marshaller() {
         try {
+            IgniteConfiguration cfg = new IgniteConfiguration();
+
             BinaryContext ctx =
-                new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
+                new BinaryContext(BinaryNoopMetadataHandler.instance(), cfg, new NullLogger());
 
             BinaryMarshaller marsh = new BinaryMarshaller();
 
-            marsh.setContext(new MarshallerContextImpl(null));
+            String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
+
+            marsh.setContext(new MarshallerContextImpl(workDir, null));
 
             ctx.configure(marsh, new IgniteConfiguration());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 501cdb2..f07266b 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
@@ -305,9 +305,6 @@ public abstract class IgniteUtils {
     /** Project home directory. */
     private static volatile GridTuple<String> ggHome;
 
-    /** Project work directory. */
-    private static volatile String igniteWork;
-
     /** OS JDK string. */
     private static String osJdkStr;
 
@@ -8826,54 +8823,56 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Get default work directory.
+     *
+     * @return Default work directory.
+     */
+    public static String defaultWorkDirectory() throws IgniteCheckedException {
+        return workDirectory(null, null);
+    }
+
+    /**
+     * Get work directory for the given user-provided work directory and Ignite home.
+     *
      * @param userWorkDir Ignite work folder provided by user.
      * @param userIgniteHome Ignite home folder provided by user.
      */
-    public static void setWorkDirectory(@Nullable String userWorkDir, @Nullable String userIgniteHome)
+    public static String workDirectory(@Nullable String userWorkDir, @Nullable String userIgniteHome)
         throws IgniteCheckedException {
-        String igniteWork0 = igniteWork;
-
-        if (igniteWork0 == null) {
-            synchronized (IgniteUtils.class) {
-                // Double check.
-                igniteWork0 = igniteWork;
-
-                if (igniteWork0 != null)
-                    return;
+        if (userIgniteHome == null)
+            userIgniteHome = getIgniteHome();
 
-                File workDir;
+        File workDir;
 
-                if (!F.isEmpty(userWorkDir))
-                    workDir = new File(userWorkDir);
-                else if (!F.isEmpty(IGNITE_WORK_DIR))
-                    workDir = new File(IGNITE_WORK_DIR);
-                else if (!F.isEmpty(userIgniteHome))
-                    workDir = new File(userIgniteHome, "work");
-                else {
-                    String tmpDirPath = System.getProperty("java.io.tmpdir");
+        if (!F.isEmpty(userWorkDir))
+            workDir = new File(userWorkDir);
+        else if (!F.isEmpty(IGNITE_WORK_DIR))
+            workDir = new File(IGNITE_WORK_DIR);
+        else if (!F.isEmpty(userIgniteHome))
+            workDir = new File(userIgniteHome, "work");
+        else {
+            String tmpDirPath = System.getProperty("java.io.tmpdir");
 
-                    if (tmpDirPath == null)
-                        throw new IgniteCheckedException("Failed to create work directory in OS temp " +
-                            "(property 'java.io.tmpdir' is null).");
+            if (tmpDirPath == null)
+                throw new IgniteCheckedException("Failed to create work directory in OS temp " +
+                    "(property 'java.io.tmpdir' is null).");
 
-                    workDir = new File(tmpDirPath, "ignite" + File.separator + "work");
-                }
+            workDir = new File(tmpDirPath, "ignite" + File.separator + "work");
+        }
 
-                if (!workDir.isAbsolute())
-                    throw new IgniteCheckedException("Work directory path must be absolute: " + workDir);
+        if (!workDir.isAbsolute())
+            throw new IgniteCheckedException("Work directory path must be absolute: " + workDir);
 
-                if (!mkdirs(workDir))
-                    throw new IgniteCheckedException("Work directory does not exist and cannot be created: " + workDir);
+        if (!mkdirs(workDir))
+            throw new IgniteCheckedException("Work directory does not exist and cannot be created: " + workDir);
 
-                if (!workDir.canRead())
-                    throw new IgniteCheckedException("Cannot read from work directory: " + workDir);
+        if (!workDir.canRead())
+            throw new IgniteCheckedException("Cannot read from work directory: " + workDir);
 
-                if (!workDir.canWrite())
-                    throw new IgniteCheckedException("Cannot write to work directory: " + workDir);
+        if (!workDir.canWrite())
+            throw new IgniteCheckedException("Cannot write to work directory: " + workDir);
 
-                igniteWork = workDir.getAbsolutePath();
-            }
-        }
+        return workDir.getAbsolutePath();
     }
 
     /**
@@ -8884,30 +8883,23 @@ public abstract class IgniteUtils {
     }
 
     /**
-     * Nullifies work directory. For test purposes only.
-     */
-    public static void nullifyWorkDirectory() {
-        igniteWork = null;
-    }
-
-    /**
      * Resolves work directory.
      *
+     * @param workDir Work directory.
      * @param path Path to resolve.
      * @param delIfExist Flag indicating whether to delete the specify directory or not.
      * @return Resolved work directory.
      * @throws IgniteCheckedException If failed.
      */
-    public static File resolveWorkDirectory(String path, boolean delIfExist) throws IgniteCheckedException {
+    public static File resolveWorkDirectory(String workDir, String path, boolean delIfExist)
+        throws IgniteCheckedException {
         File dir = new File(path);
 
         if (!dir.isAbsolute()) {
-            String ggWork0 = igniteWork;
-
-            if (F.isEmpty(ggWork0))
+            if (F.isEmpty(workDir))
                 throw new IgniteCheckedException("Failed to resolve path (work directory has not been set): " + path);
 
-            dir = new File(ggWork0, dir.getPath());
+            dir = new File(workDir, dir.getPath());
         }
 
         if (delIfExist && dir.exists()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
index 6fd6482..94c3820 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
@@ -120,6 +120,9 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
     /** Grid name. */
     private String gridName;
 
+    /** Work directory. */
+    private final String workDir;
+
     /** Flag allowing not to print out of resources warning. */
     private boolean omitOutOfResourcesWarn;
 
@@ -139,9 +142,11 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
     /**
      * Use this constructor when dependencies could be injected
      * with {@link GridResourceProcessor#injectGeneric(Object)}.
+     *
+     * @param workDir Work directory.
      */
-    public IpcSharedMemoryServerEndpoint() {
-        // No-op.
+    public IpcSharedMemoryServerEndpoint(String workDir) {
+        this.workDir = workDir;
     }
 
     /**
@@ -150,11 +155,13 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
      * @param log Log.
      * @param locNodeId Node id.
      * @param gridName Grid name.
+     * @param workDir Work directory.
      */
-    public IpcSharedMemoryServerEndpoint(IgniteLogger log, UUID locNodeId, String gridName) {
+    public IpcSharedMemoryServerEndpoint(IgniteLogger log, UUID locNodeId, String gridName, String workDir) {
         this.log = log;
         this.locNodeId = locNodeId;
         this.gridName = gridName;
+        this.workDir = workDir;
     }
 
     /** @param omitOutOfResourcesWarn If {@code true}, out of resources warning will not be printed by server. */
@@ -181,7 +188,7 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
 
         tokDirPath = tokDirPath + '/' + locNodeId.toString() + '-' + IpcSharedMemoryUtils.pid();
 
-        tokDir = U.resolveWorkDirectory(tokDirPath, false);
+        tokDir = U.resolveWorkDirectory(workDir, tokDirPath, false);
 
         if (port <= 0 || port >= 0xffff)
             throw new IpcEndpointBindException("Port value is illegal: " + port);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
index 4214b5b..d5ff5e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
+++ b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
@@ -113,6 +113,9 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
     /** Quiet flag. */
     private final boolean quiet;
 
+    /** Work directory. */
+    private volatile String workDir;
+
     /** Node ID. */
     private volatile UUID nodeId;
 
@@ -340,6 +343,15 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
         }
     }
 
+    /**
+     * Set work directory.
+     *
+     * @param workDir Work directory.
+     */
+    public void setWorkDirectory(String workDir) {
+        this.workDir = workDir;
+    }
+
     /** {@inheritDoc} */
     @Override public void setNodeId(UUID nodeId) {
         A.notNull(nodeId, "nodeId");
@@ -361,7 +373,7 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
             return;
 
         try {
-            fileHnd.nodeId(nodeId);
+            fileHnd.nodeId(nodeId, workDir);
         }
         catch (IgniteCheckedException | IOException e) {
             throw new RuntimeException("Failed to enable file handler.", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
index 5acdc08..7d1fa08 100644
--- a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
@@ -80,7 +80,7 @@ public final class JavaLoggerFileHandler extends StreamHandler {
      *
      * @param nodeId Node id.
      */
-    public void nodeId(UUID nodeId) throws IgniteCheckedException, IOException {
+    public void nodeId(UUID nodeId, String workDir) throws IgniteCheckedException, IOException {
         if (delegate != null)
             return;
 
@@ -91,7 +91,7 @@ public final class JavaLoggerFileHandler extends StreamHandler {
         if (ptrn == null)
             ptrn = "ignite-%{id8}.%g.log";
 
-        ptrn = new File(logDirectory(), ptrn.replace("%{id8}", U.id8(nodeId))).getAbsolutePath();
+        ptrn = new File(logDirectory(workDir), ptrn.replace("%{id8}", U.id8(nodeId))).getAbsolutePath();
 
         int limit = getIntProperty(clsName + ".limit", 0);
 
@@ -133,10 +133,12 @@ public final class JavaLoggerFileHandler extends StreamHandler {
     /**
      * Resolves logging directory.
      *
+     * @param workDir Work directory.
      * @return Logging directory.
      */
-    private static File logDirectory() throws IgniteCheckedException {
-        return !F.isEmpty(U.IGNITE_LOG_DIR) ? new File(U.IGNITE_LOG_DIR) : U.resolveWorkDirectory("log", false);
+    private static File logDirectory(String workDir) throws IgniteCheckedException {
+        return !F.isEmpty(U.IGNITE_LOG_DIR) ? new File(U.IGNITE_LOG_DIR) :
+            U.resolveWorkDirectory(workDir, "log", false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 092c864..21011a7 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
@@ -36,7 +36,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
 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;
 import org.apache.ignite.spi.IgniteSpiAdapter;
@@ -291,7 +290,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin
                 folder = new File(curDirPath);
             else {
                 try {
-                    folder = U.resolveWorkDirectory(curDirPath, false);
+                    folder = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), curDirPath, false);
                 }
                 catch (IgniteCheckedException e) {
                     if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 d81b9f3..d61cee6 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
@@ -1779,8 +1779,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         // If configured TCP port is busy, find first available in range.
         for (int port = shmemPort; port < shmemPort + locPortRange; port++) {
             try {
+                IgniteConfiguration cfg = ignite.configuration();
+
                 IpcSharedMemoryServerEndpoint srv =
-                    new IpcSharedMemoryServerEndpoint(log, ignite.configuration().getNodeId(), gridName);
+                    new IpcSharedMemoryServerEndpoint(log, cfg.getNodeId(), gridName, cfg.getWorkDirectory());
 
                 srv.setPort(port);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
index bcd9513..d4e93d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
@@ -140,7 +140,7 @@ public class TcpDiscoverySharedFsIpFinder extends TcpDiscoveryIpFinderAdapter {
                     tmp = new File(path);
                 else {
                     try {
-                        tmp = U.resolveWorkDirectory(path, false);
+                        tmp = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), path, false);
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteSpiException("Failed to resolve directory [path=" + path +

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 9be5b93..222f463 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
@@ -299,7 +299,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
         String path = baseDir + File.separator + gridName + File.separator + ignite.configuration().getNodeId();
 
         try {
-            dir = U.resolveWorkDirectory(path, true);
+            dir = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), path, true);
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
index e549336..bf0adf8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
@@ -90,7 +90,7 @@ public class MarshallerContextLockingSelfTest extends GridCommonAbstractTest {
         public void executeTest(GridTestLog4jLogger log) throws Exception {
             counter.incrementAndGet();
 
-            File workDir = U.resolveWorkDirectory("marshaller", false);
+            File workDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false);
 
             final MarshallerContextImpl.ContinuousQueryListener queryListener = new MarshallerContextImpl.ContinuousQueryListener(log, workDir);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
index c7aecb4..2b7922e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
@@ -57,7 +57,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest
      */
     public void testJobRun() throws Exception {
         for (int i = 0; i < 5; i++) {
-            U.resolveWorkDirectory("marshaller", true);
+            U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);
 
             log.info("Iteration: " + i);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
index 7b0e950..1fb093a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
@@ -61,12 +61,9 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
-        Path file = Paths.get(igniteHome + "/work/log/" + "test.log");
-        Files.delete(file);
-
+        Files.delete(Paths.get(igniteHome + "/work/log/" + "test.log"));
         Files.delete(Paths.get(igniteHome + "/work/log/" + "ignite.log"));
         Files.delete(Paths.get(igniteHome + "/work/log/"));
-        Files.delete(Paths.get(igniteHome + "/work/"));
 
         super.afterTestsStopped();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java
deleted file mode 100644
index 3eb0eba..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java
+++ /dev/null
@@ -1,166 +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.util;
-
-import java.io.File;
-import java.util.UUID;
-import junit.framework.TestCase;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.logger.java.JavaLogger;
-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 static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME;
-import static org.apache.ignite.internal.util.IgniteUtils.nullifyHomeDirectory;
-import static org.apache.ignite.internal.util.IgniteUtils.nullifyWorkDirectory;
-
-/**
- * Checks creation of work folder.
- */
-public class GridStartupWithSpecifiedWorkDirectorySelfTest extends TestCase {
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** */
-    private static final int GRID_COUNT = 2;
-
-    /** System temp directory. */
-    private static final String TMP_DIR = System.getProperty("java.io.tmpdir");
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        // Protection against previously cached values.
-        nullifyHomeDirectory();
-        nullifyWorkDirectory();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void tearDown() throws Exception {
-        // Next grid in the same VM shouldn't use cached values produced by these tests.
-        nullifyHomeDirectory();
-        nullifyWorkDirectory();
-
-        U.setWorkDirectory(null, U.getIgniteHome());
-    }
-
-    /**
-     * @param log Grid logger.
-     * @return Grid configuration.
-     */
-    private IgniteConfiguration getConfiguration(IgniteLogger log) {
-        // We can't use U.getIgniteHome() here because
-        // it will initialize cached value which is forbidden to override.
-        String ggHome = IgniteSystemProperties.getString(IGNITE_HOME);
-
-        assert ggHome != null;
-
-        U.setIgniteHome(null);
-
-        String ggHome0 = U.getIgniteHome();
-
-        assert ggHome0 == null;
-
-        TcpDiscoverySpi disc = new TcpDiscoverySpi();
-
-        disc.setIpFinder(IP_FINDER);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridLogger(log);
-        cfg.setDiscoverySpi(disc);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStartStopWithUndefinedHomeAndWorkDirs() throws Exception {
-        IgniteLogger log = new JavaLogger();
-
-        log.info(">>> Test started: " + getName());
-        log.info("Grid start-stop test count: " + GRID_COUNT);
-
-        File testWorkDir = null;
-
-        try {
-            for (int i = 0; i < GRID_COUNT; i++) {
-                try (Ignite g = G.start(getConfiguration(log))) {
-                    assert g != null;
-
-                    testWorkDir = U.resolveWorkDirectory(getName(), true);
-
-                    assertTrue("Work directory wasn't created", testWorkDir.exists());
-
-                    assertTrue("Work directory must be located in OS temp directory",
-                        testWorkDir.getAbsolutePath().startsWith(TMP_DIR));
-
-                    System.out.println(testWorkDir);
-
-                    X.println("Stopping grid " + g.cluster().localNode().id());
-                }
-            }
-        }
-        finally {
-            if (testWorkDir != null && testWorkDir.getAbsolutePath().startsWith(TMP_DIR))
-                U.delete(testWorkDir);
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStartStopWithUndefinedHomeAndConfiguredWorkDirs() throws Exception {
-        IgniteLogger log = new JavaLogger();
-
-        log.info(">>> Test started: " + getName());
-        log.info("Grid start-stop test count: " + GRID_COUNT);
-
-        String tmpWorkDir = new File(TMP_DIR, getName() + "_" + UUID.randomUUID()).getAbsolutePath();
-
-        try {
-            for (int i = 0; i < GRID_COUNT; i++) {
-                IgniteConfiguration cfg = getConfiguration(log);
-
-                cfg.setWorkDirectory(tmpWorkDir);
-
-                try (Ignite g = G.start(cfg)) {
-                    assert g != null;
-
-                    File testWorkDir = U.resolveWorkDirectory(getName(), true);
-
-                    assertTrue("Work directory wasn't created", testWorkDir.exists());
-
-                    assertTrue("Work directory must be located in configured directory",
-                        testWorkDir.getAbsolutePath().startsWith(tmpWorkDir));
-
-                    X.println("Stopping grid " + g.cluster().localNode().id());
-                }
-            }
-        } finally {
-            U.delete(new File(tmpWorkDir));
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
index 2873708..a983f82 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
@@ -35,15 +35,13 @@ public class IgfsSharedMemoryTestServer {
     public static void main(String[] args) throws IgniteCheckedException {
         System.out.println("Starting server ...");
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Tell our process PID to the wrapper.
         X.println(GridJavaProcess.PID_MSG_PREFIX + U.jvmPid());
 
         InputStream is = null;
 
         try {
-            IpcServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+            IpcServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
             new IgniteTestResources().inject(srv);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
index 1aae999..0c5f564 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
@@ -55,10 +55,7 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
     @Override protected void afterTestsStopped() throws Exception {
         // Start and stop server endpoint to let GC worker
         // make a run and cleanup resources.
-
-        U.setWorkDirectory(null, U.getIgniteHome());
-
-        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
         new IgniteTestResources().inject(srv);
 
@@ -74,10 +71,8 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
      * @throws Exception If failed.
      */
     public void testIgfsServerClientInteractionsUponClientKilling() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Run server endpoint.
-        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
         new IgniteTestResources().inject(srv);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
index 90c74f9..d86f127 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
@@ -76,7 +76,7 @@ public class IpcSharedMemoryBenchmarkReader implements IpcSharedMemoryBenchmarkP
             }
         });
 
-        try (IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint()) {
+        try (IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory())) {
             new IgniteTestResources().inject(srv);
 
             srv.start();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
index 5b0251d..5fd5b5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
@@ -37,10 +37,9 @@ public class JavaLoggerTest extends TestCase {
      * @throws Exception If failed.
      */
     public void testLogInitialize() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         log = new JavaLogger();
 
+        ((JavaLogger)log).setWorkDirectory(U.defaultWorkDirectory());
         ((LoggerNodeIdAware)log).setNodeId(UUID.fromString("00000000-1111-2222-3333-444444444444"));
 
         if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
index eddc4de..ebbd8ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
@@ -160,8 +160,6 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
             for (int i = 0; i < workDirs.length; i++) {
                 workDir = workDirs[i];
 
-                U.nullifyWorkDirectory();
-
                 startGrid(i);
             }
 
@@ -178,8 +176,6 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
             for (int i = 0; i < workDirs.length; i++) {
                 workDir = workDirs[i];
 
-                U.nullifyWorkDirectory();
-
                 startGrid(i);
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
index ce89302..2eea7c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
@@ -70,7 +70,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String curSpiPath1 = getSpi().getCurrentDirectoryPath();
 
-        File folder1 = U.resolveWorkDirectory(curSpiPath1, false);
+        File folder1 = U.resolveWorkDirectory(U.defaultWorkDirectory(), curSpiPath1, false);
 
         assert folder1.exists() : "Checkpoint folder doesn't exist.";
 
@@ -83,7 +83,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String curSpiPath2 = getSpi().getCurrentDirectoryPath();
 
-        File folder2 = U.resolveWorkDirectory(curSpiPath2, false);
+        File folder2 = U.resolveWorkDirectory(U.defaultWorkDirectory(), curSpiPath2, false);
 
         assert folder2.exists() : "Check point folder doesn't exist.";
 
@@ -97,7 +97,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String newCurSpiPath = getSpi().getCurrentDirectoryPath();
 
-        File changedFolder = U.resolveWorkDirectory(newCurSpiPath, false);
+        File changedFolder = U.resolveWorkDirectory(U.defaultWorkDirectory(), newCurSpiPath, false);
 
         assert changedFolder.exists() : "Check point folder doesn't exist.";
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
index fc9cf0f..93339ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
@@ -283,8 +283,6 @@ public abstract class GridAbstractCommunicationSelfTest<T extends CommunicationS
      * @throws Exception If failed.
      */
     private void startSpis() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spis.clear();
         nodes.clear();
         spiRsrcs.clear();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
index 7bbf531..a74a07a 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
@@ -468,8 +468,6 @@ public class GridTcpCommunicationSpiMultithreadedSelfTest extends GridSpiAbstrac
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spis.clear();
         nodes.clear();
         spiRsrcs.clear();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
index da1bc26..9e927dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
@@ -65,8 +65,6 @@ public abstract class GridSwapSpaceSpiAbstractSelfTest extends GridCommonAbstrac
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spi = spi();
 
         getTestResources().inject(spi);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index aa90af0..9f507e6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -497,7 +497,7 @@ public abstract class GridAbstractTest extends TestCase {
      */
     protected void beforeTestsStarted() throws Exception {
         // Will clean and re-create marshaller directory from scratch.
-        U.resolveWorkDirectory("marshaller", true);
+        U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index c9859fc..b559897 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -27,9 +27,11 @@ import org.apache.ignite.IgniteAtomicReference;
 import org.apache.ignite.IgniteAtomicSequence;
 import org.apache.ignite.IgniteAtomicStamped;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteCountDownLatch;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLock;
 import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.IgniteDataStreamer;
@@ -55,6 +57,7 @@ import org.apache.ignite.internal.binary.BinaryCachingMetadataHandler;
 import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
 import org.apache.ignite.internal.processors.cacheobject.NoOpBinary;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.marshaller.Marshaller;
@@ -136,6 +139,13 @@ public class IgniteMock implements Ignite {
         cfg.setIgniteHome(home);
         cfg.setLocalHost(locHost);
 
+        try {
+            cfg.setWorkDirectory(U.defaultWorkDirectory());
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException("Failed to get default work directory.", e);
+        }
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index 13d5fbd..4d861d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -83,8 +83,6 @@ public class IgniteTestResources {
         home = U.getIgniteHome();
         locHost = localHost();
 
-        U.setWorkDirectory(null, null);
-
         GridTestKernalContext ctx = new GridTestKernalContext(log);
 
         rsrcProc = new GridResourceProcessor(ctx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
index 591753b..20b3cf2 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
@@ -429,8 +429,6 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends GridAbstr
      * @throws Exception If failed.
      */
     protected void spiStart(IgniteSpi spi) throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Start SPI with unique grid name.
         spi.spiStart(getTestGridName());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 734e199..2e3d8b5 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
@@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRe
 import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest;
 import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
 import org.apache.ignite.internal.util.GridHandleTableSelfTest;
-import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
 import org.apache.ignite.internal.util.IgniteUtilsSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
 import org.apache.ignite.internal.util.nio.GridNioSelfTest;
@@ -80,7 +79,6 @@ public class IgniteBinaryBasicTestSuite extends TestSuite {
         ignoredTests.add(IgniteCacheP2pUnmarshallingNearErrorTest.class);
         ignoredTests.add(IgniteCacheP2pUnmarshallingRebalanceErrorTest.class);
         ignoredTests.add(GridReleaseTypeSelfTest.class);
-        ignoredTests.add(GridStartupWithSpecifiedWorkDirectorySelfTest.class);
         ignoredTests.add(IgniteUtilsSelfTest.class);
         ignoredTests.add(ClusterGroupSelfTest.class);
         ignoredTests.add(GridMessagingNoPeerClassLoadingSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index b91fff4..d9cc8c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -68,7 +68,6 @@ import org.apache.ignite.internal.processors.service.IgniteServiceDeploymentClas
 import org.apache.ignite.internal.processors.service.IgniteServiceDeploymentClassLoadingOptimizedMarshallerTest;
 import org.apache.ignite.internal.processors.service.IgniteServiceReassignmentTest;
 import org.apache.ignite.internal.processors.service.ServicePredicateAccessCacheTest;
-import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
 import org.apache.ignite.internal.util.GridStartupWithUndefinedIgniteHomeSelfTest;
 import org.apache.ignite.spi.communication.GridCacheMessageSelfTest;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -115,7 +114,6 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
         suite.addTestSuite(GridDiscoveryEventSelfTest.class);
         suite.addTestSuite(GridPortProcessorSelfTest.class);
         suite.addTestSuite(GridHomePathSelfTest.class);
-        GridTestUtils.addTestIfNeeded(suite, GridStartupWithSpecifiedWorkDirectorySelfTest.class, ignoredTests);
         suite.addTestSuite(GridStartupWithUndefinedIgniteHomeSelfTest.class);
         GridTestUtils.addTestIfNeeded(suite, GridVersionSelfTest.class, ignoredTests);
         suite.addTestSuite(GridListenActorSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
index c845593..5c82469 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
@@ -55,8 +55,6 @@ public class CacheNoValueClassOnServerTestClient {
 
         cfg.setDiscoverySpi(disco);
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println("Test external node started");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
index 1134ab3..e0406c2 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
@@ -55,8 +55,6 @@ public class CacheConfigurationP2PTestClient {
 
         cfg.setDiscoverySpi(disco);
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println("Test external node started");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
index 71bb8a4..0e86529 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
@@ -16,7 +16,10 @@
  */
 package org.apache.ignite.internal.processors.hadoop;
 
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
@@ -117,4 +120,14 @@ public class HadoopHelperImpl implements HadoopHelper {
     @Override @Nullable public InputStream loadClassBytes(ClassLoader ldr, String clsName) {
         return ldr.getResourceAsStream(clsName.replace('.', '/') + ".class");
     }
+
+    /** {@inheritDoc} */
+    @Override public String workDirectory() {
+        try {
+            return ctx != null ? ctx.config().getWorkDirectory() : U.defaultWorkDirectory();
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException("Failed to resolve Ignite work directory.", e);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
index 347bfae..a34388d 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
@@ -287,25 +287,28 @@ public class HadoopUtils {
     /**
      * Returns work directory for job execution.
      *
+     * @param workDir Work directory.
      * @param locNodeId Local node ID.
      * @param jobId Job ID.
      * @return Working directory for job.
      * @throws IgniteCheckedException If Failed.
      */
-    public static File jobLocalDir(UUID locNodeId, HadoopJobId jobId) throws IgniteCheckedException {
-        return new File(new File(U.resolveWorkDirectory("hadoop", false), "node-" + locNodeId), "job_" + jobId);
+    public static File jobLocalDir(String workDir, UUID locNodeId, HadoopJobId jobId) throws IgniteCheckedException {
+        return new File(new File(U.resolveWorkDirectory(workDir, "hadoop", false),
+            "node-" + locNodeId), "job_" + jobId);
     }
 
     /**
      * Returns subdirectory of job working directory for task execution.
      *
+     * @param workDir Work directory.
      * @param locNodeId Local node ID.
      * @param info Task info.
      * @return Working directory for task.
      * @throws IgniteCheckedException If Failed.
      */
-    public static File taskLocalDir(UUID locNodeId, HadoopTaskInfo info) throws IgniteCheckedException {
-        File jobLocDir = jobLocalDir(locNodeId, info.jobId());
+    public static File taskLocalDir(String workDir, UUID locNodeId, HadoopTaskInfo info) throws IgniteCheckedException {
+        File jobLocDir = jobLocalDir(workDir, locNodeId, info.jobId());
 
         return new File(jobLocDir, info.type() + "_" + info.taskNumber() + "_" + info.attempt());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
index 3731b2c..36da410 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
@@ -311,7 +311,7 @@ public class HadoopV2Job implements HadoopJob {
         ClassLoader oldLdr = HadoopCommonUtils.setContextClassLoader(getClass().getClassLoader());
 
         try {
-            rsrcMgr.prepareJobEnvironment(!external, jobLocalDir(locNodeId, jobId));
+            rsrcMgr.prepareJobEnvironment(!external, jobLocalDir(igniteWorkDirectory(), locNodeId, jobId));
         }
         finally {
             HadoopCommonUtils.restoreContextClassLoader(oldLdr);
@@ -323,7 +323,7 @@ public class HadoopV2Job implements HadoopJob {
     @Override public void dispose(boolean external) throws IgniteCheckedException {
         try {
             if (rsrcMgr != null && !external) {
-                File jobLocDir = jobLocalDir(locNodeId, jobId);
+                File jobLocDir = jobLocalDir(igniteWorkDirectory(), locNodeId, jobId);
 
                 if (jobLocDir.exists())
                     U.delete(jobLocDir);
@@ -411,7 +411,7 @@ public class HadoopV2Job implements HadoopJob {
 
     /** {@inheritDoc} */
     @Override public void prepareTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
-        rsrcMgr.prepareTaskWorkDir(taskLocalDir(locNodeId, info));
+        rsrcMgr.prepareTaskWorkDir(taskLocalDir(igniteWorkDirectory(), locNodeId, info));
     }
 
     /** {@inheritDoc} */
@@ -420,7 +420,7 @@ public class HadoopV2Job implements HadoopJob {
 
         taskCtxClsPool.add(ctx.getClass());
 
-        File locDir = taskLocalDir(locNodeId, info);
+        File locDir = taskLocalDir(igniteWorkDirectory(), locNodeId, info);
 
         if (locDir.exists())
             U.delete(locDir);
@@ -431,6 +431,11 @@ public class HadoopV2Job implements HadoopJob {
         rsrcMgr.cleanupStagingDirectory();
     }
 
+    /** {@inheritDoc} */
+    @Override public String igniteWorkDirectory() {
+        return helper.workDirectory();
+    }
+
     /**
      * Getter for job configuration.
      * @return The job configuration.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
index 96fa892..d444f2b 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
@@ -285,12 +285,12 @@ public class HadoopV2TaskContext extends HadoopTaskContext {
             case REDUCE:
                 job().prepareTaskEnvironment(taskInfo());
 
-                locDir = taskLocalDir(locNodeId, taskInfo());
+                locDir = taskLocalDir(job.igniteWorkDirectory(), locNodeId, taskInfo());
 
                 break;
 
             default:
-                locDir = jobLocalDir(locNodeId, taskInfo().jobId());
+                locDir = jobLocalDir(job.igniteWorkDirectory(), locNodeId, taskInfo().jobId());
         }
 
         ClassLoader oldLdr = HadoopCommonUtils.setContextClassLoader(jobConf().getClassLoader());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
index dc5874d..2c560bc 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
@@ -106,7 +106,7 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
 
         log = ctx.kernalContext().log(HadoopExternalTaskExecutor.class);
 
-        outputBase = U.resolveWorkDirectory("hadoop", false);
+        outputBase = U.resolveWorkDirectory(ctx.kernalContext().config().getWorkDirectory(), "hadoop", false);
 
         pathSep = System.getProperty("path.separator", U.isWindows() ? ";" : ":");
 
@@ -118,7 +118,8 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
             ctx.kernalContext().config().getMarshaller(),
             log,
             ctx.kernalContext().getSystemExecutorService(),
-            ctx.kernalContext().gridName());
+            ctx.kernalContext().gridName(),
+            ctx.kernalContext().config().getWorkDirectory());
 
         comm.setListener(new MessageListener());
 
@@ -380,7 +381,8 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
                         log.debug("Created hadoop child process metadata for job [job=" + job +
                             ", childProcId=" + childProcId + ", taskMeta=" + startMeta + ']');
 
-                    Process proc = startJavaProcess(childProcId, startMeta, job);
+                    Process proc = startJavaProcess(childProcId, startMeta, job,
+                        ctx.kernalContext().config().getWorkDirectory());
 
                     BufferedReader rdr = new BufferedReader(new InputStreamReader(proc.getInputStream()));
 
@@ -517,10 +519,11 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
      * @param childProcId Child process ID.
      * @param startMeta Metadata.
      * @param job Job.
+     * @param igniteWorkDir Work directory.
      * @return Started process.
      */
     private Process startJavaProcess(UUID childProcId, HadoopExternalTaskMetadata startMeta,
-        HadoopJob job) throws Exception {
+        HadoopJob job, String igniteWorkDir) throws Exception {
         String outFldr = jobWorkFolder(job.id()) + File.separator + childProcId;
 
         if (log.isDebugEnabled())
@@ -528,7 +531,7 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
 
         List<String> cmd = new ArrayList<>();
 
-        File workDir = U.resolveWorkDirectory("", false);
+        File workDir = U.resolveWorkDirectory(igniteWorkDir, "", false);
 
         cmd.add(javaCmd);
         cmd.addAll(startMeta.jvmOptions());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
index 32880e4..90012fb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
@@ -77,12 +77,11 @@ public class HadoopExternalProcessStarter {
     }
 
     /**
+     * Run the process.
      *
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void run() throws Exception {
-        U.setWorkDirectory(args.workDir, U.getIgniteHome());
-
         File outputDir = outputDirectory();
 
         initializeStreams(outputDir);
@@ -98,7 +97,8 @@ public class HadoopExternalProcessStarter {
             new JdkMarshaller(),
             log,
             msgExecSvc,
-            "external"
+            "external",
+            args.workDir
         );
 
         comm.start();
@@ -121,7 +121,7 @@ public class HadoopExternalProcessStarter {
 
     /**
      * @param outputDir Directory for process output.
-     * @throws Exception
+     * @throws Exception If failed.
      */
     private void initializeStreams(File outputDir) throws Exception {
         out = new FileOutputStream(new File(outputDir, args.childProcId + ".out"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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..6d903d8 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
@@ -177,6 +177,9 @@ public class HadoopExternalCommunication {
     /** Grid name. */
     private String gridName;
 
+    /** Work directory. */
+    private String workDir;
+
     /** Complex variable that represents this node IP address. */
     private volatile InetAddress locHost;
 
@@ -254,6 +257,7 @@ public class HadoopExternalCommunication {
      * @param log Logger.
      * @param execSvc Executor service for message notification.
      * @param gridName Grid name.
+     * @param workDir Work directory.
      */
     public HadoopExternalCommunication(
         UUID parentNodeId,
@@ -261,7 +265,8 @@ public class HadoopExternalCommunication {
         Marshaller marsh,
         IgniteLogger log,
         ExecutorService execSvc,
-        String gridName
+        String gridName,
+        String workDir
     ) {
         locProcDesc = new HadoopProcessDescriptor(parentNodeId, procId);
 
@@ -269,6 +274,7 @@ public class HadoopExternalCommunication {
         this.log = log.getLogger(HadoopExternalCommunication.class);
         this.execSvc = execSvc;
         this.gridName = gridName;
+        this.workDir = workDir;
     }
 
     /**
@@ -685,7 +691,7 @@ public class HadoopExternalCommunication {
             try {
                 IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(
                     log.getLogger(IpcSharedMemoryServerEndpoint.class),
-                    locProcDesc.processId(), gridName);
+                    locProcDesc.processId(), gridName, workDir);
 
                 srv.setPort(port);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
index 220614c..7e6fa9c 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
@@ -101,6 +101,13 @@ public class HadoopPlannerMockJob implements HadoopJob {
         throwUnsupported();
     }
 
+    /** {@inheritDoc} */
+    @Override public String igniteWorkDirectory() {
+        throwUnsupported();
+
+        return null;
+    }
+
     /**
      * Throw {@link UnsupportedOperationException}.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
index a40c531..38ff318 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
@@ -81,7 +81,7 @@ public class HadoopExternalCommunicationSelfTest extends GridCommonAbstractTest
 
             for (int i = 0; i < comms.length; i++) {
                 comms[i] = new HadoopExternalCommunication(parentNodeId, UUID.randomUUID(), marsh, log,
-                    Executors.newFixedThreadPool(1), name + i);
+                    Executors.newFixedThreadPool(1), name + i, U.defaultWorkDirectory());
 
                 if (useShmem)
                     comms[i].setSharedMemoryPort(14000);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
index 05a314b..500811f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
@@ -35,8 +35,6 @@ public class CacheConfigurationP2PTestServer {
 
         IgniteConfiguration cfg = CacheConfigurationP2PTest.createConfiguration();
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println(CacheConfigurationP2PTest.NODE_START_MSG);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 9d11ad3..47575e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -116,7 +116,7 @@ namespace Apache.Ignite.Core.Tests
                 Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
                 Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
                 Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
-                Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
+                Assert.AreEqual(cfg.WorkDirectory.Trim('\\'), resCfg.WorkDirectory.Trim('\\'));
                 Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
                 Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
                 Assert.IsTrue(File.Exists(resCfg.JvmDllPath));


Mime
View raw message