ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [02/11] incubator-ignite git commit: IGNITE-651 - Persistance for marshaller cache
Date Wed, 01 Apr 2015 06:19:58 GMT
IGNITE-651 - Persistance for marshaller cache


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

Branch: refs/heads/ignite-598
Commit: ea7d2485622cc455be536dec3ecbb36dec3498db
Parents: c6b3380
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Tue Mar 31 13:29:08 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Tue Mar 31 13:29:08 2015 -0700

----------------------------------------------------------------------
 .../checkpoint/s3/S3CheckpointSpiSelfTest.java  | 12 +--
 .../ignite/internal/GridKernalContextImpl.java  |  3 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  6 +-
 .../internal/MarshallerContextAdapter.java      |  6 +-
 .../ignite/internal/MarshallerContextImpl.java  | 90 ++++++++++++++++++--
 .../processors/cache/GridCacheProcessor.java    |  8 +-
 .../CacheContinuousQueryListener.java           |  3 +
 .../continuous/CacheContinuousQueryManager.java |  2 +-
 .../ignite/internal/util/IgniteUtils.java       |  2 +-
 .../ignite/marshaller/MarshallerContext.java    |  3 +-
 .../optimized/OptimizedMarshallerUtils.java     |  9 +-
 .../managers/GridNoopManagerSelfTest.java       |  2 +-
 .../communication/GridIoManagerSelfTest.java    |  9 +-
 .../internal/util/IgniteUtilsSelfTest.java      |  2 +-
 .../OptimizedMarshallerNodeFailoverTest.java    | 71 ++++++++++++++-
 .../spi/GridSpiLocalHostInjectionTest.java      |  2 +-
 .../GridPriorityQueueCollisionSpiSelfTest.java  |  2 +-
 ...RobinLoadBalancingSpiNotPerTaskSelfTest.java |  2 +-
 .../testframework/junits/GridAbstractTest.java  | 28 +++---
 .../junits/GridTestKernalContext.java           |  2 +-
 .../junits/IgniteTestResources.java             |  8 +-
 .../junits/spi/GridSpiAbstractTest.java         | 13 +--
 22 files changed, 231 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java
b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java
index f48a754..bb92e09 100644
--- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java
+++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java
@@ -100,7 +100,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
             final String key = KEY_PREFIX + i;
 
             assertWithRetries(new GridAbsClosureX() {
-                @Override public void applyx() {
+                @Override public void applyx() throws IgniteCheckedException {
                     assertNotNull("Missing checkpoint: " + key,
                         getSpi().loadCheckpoint(key));
                 }
@@ -122,7 +122,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
             final String key = KEY_PREFIX + i;
 
             assertWithRetries(new GridAbsClosureX() {
-                @Override public void applyx() {
+                @Override public void applyx() throws IgniteCheckedException {
                     assertTrue(getSpi().removeCheckpoint(key));
                 }
             });
@@ -133,7 +133,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
             final String key = KEY_PREFIX + i;
 
             assertWithRetries(new GridAbsClosureX() {
-                @Override public void applyx() {
+                @Override public void applyx() throws IgniteCheckedException {
                     assertNull(getSpi().loadCheckpoint(key));
                 }
             });
@@ -159,7 +159,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
             final String key = KEY_PREFIX + i;
 
             assertWithRetries(new GridAbsClosureX() {
-                @Override public void applyx() {
+                @Override public void applyx() throws IgniteCheckedException {
                     assertNull("Checkpoint state should not be loaded with key: " + key,
                         getSpi().loadCheckpoint(key));
                 }
@@ -181,7 +181,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
         getSpi().saveCheckpoint(KEY_PREFIX, GridTestIoUtils.serializeJdk(state2), 0, true);
 
         assertWithRetries(new GridAbsClosureX() {
-            @Override public void applyx() {
+            @Override public void applyx() throws IgniteCheckedException {
                 assertNotNull(getSpi().loadCheckpoint(KEY_PREFIX));
             }
         });
@@ -197,7 +197,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest<S3CheckpointSpi
         getSpi().removeCheckpoint(KEY_PREFIX);
 
         assertWithRetries(new GridAbsClosureX() {
-            @Override public void applyx() {
+            @Override public void applyx() throws IgniteCheckedException {
                 assertNull(getSpi().loadCheckpoint(KEY_PREFIX));
             }
         });

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 6c953e7..4abf5e7 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
@@ -325,6 +325,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
      * @param mgmtExecSvc Management executor service.
      * @param igfsExecSvc IGFS executor service.
      * @param restExecSvc REST executor service.
+     * @throws IgniteCheckedException In case of error.
      */
     @SuppressWarnings("TypeMayBeWeakened")
     protected GridKernalContextImpl(
@@ -339,7 +340,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         ExecutorService p2pExecSvc,
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
-        ExecutorService restExecSvc) {
+        ExecutorService restExecSvc) throws IgniteCheckedException {
         assert grid != null;
         assert cfg != null;
         assert gw != null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 4c8a567..19fff08 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
@@ -19,11 +19,11 @@ package org.apache.ignite.internal;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.affinity.rendezvous.*;
-import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.resource.*;
-import org.apache.ignite.internal.util.spring.*;
 import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.spring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
@@ -34,7 +34,7 @@ import org.apache.ignite.marshaller.jdk.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.mxbean.*;
 import org.apache.ignite.plugin.segmentation.*;
-import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.apache.ignite.resources.*;
 import org.apache.ignite.spi.*;
 import org.apache.ignite.spi.checkpoint.noop.*;
 import org.apache.ignite.spi.collision.noop.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
index 08f2137..5dca2f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
@@ -95,7 +95,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
     }
 
     /** {@inheritDoc} */
-    @Override public Class getClass(int id, ClassLoader ldr) throws ClassNotFoundException
{
+    @Override public Class getClass(int id, ClassLoader ldr) throws ClassNotFoundException,
IgniteCheckedException {
         String clsName = map.get(id);
 
         if (clsName == null) {
@@ -118,6 +118,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
      * @param id Type ID.
      * @param clsName Class name.
      * @return Whether class name was registered.
+     * @throws IgniteCheckedException In case of error.
      */
     protected abstract boolean registerClassName(int id, String clsName) throws IgniteCheckedException;
 
@@ -126,6 +127,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
      *
      * @param id Type ID.
      * @return Class name.
+     * @throws IgniteCheckedException In case of error.
      */
-    protected abstract String className(int id);
+    protected abstract String className(int id) throws IgniteCheckedException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 17de465..4a27222 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
@@ -21,6 +21,8 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
+import javax.cache.event.*;
+import java.io.*;
 import java.util.concurrent.*;
 
 /**
@@ -31,6 +33,9 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     private final CountDownLatch latch = new CountDownLatch(1);
 
     /** */
+    private final File workDir;
+
+    /** */
     private IgniteLogger log;
 
     /** */
@@ -40,9 +45,30 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     private int failedCnt;
 
     /**
+     * @throws IgniteCheckedException In case of error.
+     */
+    public MarshallerContextImpl() throws IgniteCheckedException {
+        workDir = U.resolveWorkDirectory("marshaller", false);
+    }
+
+    /**
+     * @param ctx Kernal context.
+     * @throws IgniteCheckedException In case of error.
+     */
+    public void onMarshallerCacheStarted(GridKernalContext ctx) throws IgniteCheckedException
{
+        ctx.cache().marshallerCache().context().continuousQueries().executeInternalQuery(
+            new ContinuousQueryListener(log, workDir),
+            null,
+            true,
+            true
+        );
+    }
+
+    /**
      * @param ctx Kernal context.
+     * @throws IgniteCheckedException In case of error.
      */
-    public void onMarshallerCacheReady(GridKernalContext ctx) {
+    public void onMarshallerCachePreloaded(GridKernalContext ctx) throws IgniteCheckedException
{
         assert ctx != null;
 
         log = ctx.log(MarshallerContextImpl.class);
@@ -89,15 +115,63 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override protected String className(int id) {
-        try {
-            if (cache == null)
-                U.awaitQuiet(latch);
+    @Override protected String className(int id) throws IgniteCheckedException {
+        if (cache == null)
+            U.awaitQuiet(latch);
+
+        String clsName = cache.get(id);
+
+        if (clsName == null) {
+            File file = new File(workDir, id + ".classname");
 
-            return cache.get(id);
+            try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+                clsName = reader.readLine();
+            }
+            catch (IOException e) {
+                throw new IgniteCheckedException("Failed to read class name from file [id="
+ id +
+                    ", file=" + file.getAbsolutePath() + ']', e);
+            }
         }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
+
+        return clsName;
+    }
+
+    /**
+     */
+    private static class ContinuousQueryListener implements CacheEntryUpdatedListener<Integer,
String> {
+        /** */
+        private final IgniteLogger log;
+
+        /** */
+        private final File workDir;
+
+        /**
+         * @param log Logger.
+         * @param workDir Work directory.
+         */
+        private ContinuousQueryListener(IgniteLogger log, File workDir) {
+            this.log = log;
+            this.workDir = workDir;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer,
? extends String>> events)
+            throws CacheEntryListenerException {
+            for (CacheEntryEvent<? extends Integer, ? extends String> evt : events)
{
+                assert evt.getOldValue() == null;
+
+                File file = new File(workDir, evt.getKey() + ".classname");
+
+                try (Writer writer = new FileWriter(file)) {
+                    writer.write(evt.getValue());
+
+                    writer.flush();
+                }
+                catch (IOException e) {
+                    U.error(log, "Failed to write class name to file [id=" + evt.getKey()
+
+                        ", clsName=" + evt.getValue() + ", file=" + file.getAbsolutePath()
+ ']', e);
+                }
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index a04746a..0e96994 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -677,9 +677,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             }
         }
 
-        marshallerCache().context().preloader().syncFuture().listen(new CI1<IgniteInternalFuture<?>>()
{
-            @Override public void apply(IgniteInternalFuture<?> f) {
-                ctx.marshallerContext().onMarshallerCacheReady(ctx);
+        ctx.marshallerContext().onMarshallerCacheStarted(ctx);
+
+        marshallerCache().context().preloader().syncFuture().listen(new CIX1<IgniteInternalFuture<?>>()
{
+            @Override public void applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException
{
+                ctx.marshallerContext().onMarshallerCachePreloaded(ctx);
             }
         });
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
index b779c18..a21213f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
@@ -45,5 +45,8 @@ interface CacheContinuousQueryListener<K, V> {
      */
     public boolean oldValueRequired();
 
+    /**
+     * @return Whether to notify on existing entries.
+     */
     public boolean notifyExisting();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index eff845d..ed3bbea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -129,7 +129,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter
{
         assert e != null;
         assert key != null;
 
-        boolean internal = e.isInternal();
+        boolean internal = e.isInternal() || e.context().system();
 
         if (preload && !internal)
             return;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 5f6da0f..8aebac2 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
@@ -8347,7 +8347,7 @@ public abstract class IgniteUtils {
     /**
      * Nullifies work directory. For test purposes only.
      */
-    static void nullifyWorkDirectory() {
+    public static void nullifyWorkDirectory() {
         igniteWork = null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
index 393a35b..f0e248a 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
@@ -40,6 +40,7 @@ public interface MarshallerContext {
      * @param ldr Class loader.
      * @return Class.
      * @throws ClassNotFoundException If class was not found.
+     * @throws IgniteCheckedException In case of any other error.
      */
-    public Class getClass(int id, ClassLoader ldr) throws ClassNotFoundException;
+    public Class getClass(int id, ClassLoader ldr) throws ClassNotFoundException, IgniteCheckedException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index d5caa9d..fafdea1 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -246,7 +246,14 @@ class OptimizedMarshallerUtils {
         ClassLoader ldr,
         MarshallerContext ctx,
         OptimizedMarshallerIdMapper mapper) throws IOException, ClassNotFoundException {
-        Class cls = ctx.getClass(id, ldr);
+        Class cls;
+
+        try {
+            cls = ctx.getClass(id, ldr);
+        }
+        catch (IgniteCheckedException e) {
+            throw new IOException("Failed to resolve class for ID: " + id, e);
+        }
 
         OptimizedClassDescriptor desc = clsMap.get(cls);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java
index dab197c..e0a62e1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java
@@ -32,7 +32,7 @@ public class GridNoopManagerSelfTest extends GridCommonAbstractTest {
     /**
      *
      */
-    public void testEnabledManager() {
+    public void testEnabledManager() throws IgniteCheckedException {
         GridTestKernalContext ctx = new GridTestKernalContext(new GridStringLogger());
 
         assertTrue(new Manager(ctx, new Spi()).enabled());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
index c11156a..3890716 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
@@ -45,7 +45,7 @@ import static org.mockito.Mockito.*;
  */
 public class GridIoManagerSelfTest extends GridCommonAbstractTest {
     /** Grid test context. */
-    private GridTestKernalContext ctx = new GridTestKernalContext(log);
+    private GridTestKernalContext ctx;
 
     /** Test local node. */
     private GridTestNode locNode = new GridTestNode(UUID.randomUUID());
@@ -53,6 +53,13 @@ public class GridIoManagerSelfTest extends GridCommonAbstractTest {
     /** Test remote node. */
     private GridTestNode rmtNode = new GridTestNode(UUID.randomUUID());
 
+    /**
+     * @throws IgniteCheckedException In case of error.
+     */
+    public GridIoManagerSelfTest() throws IgniteCheckedException {
+        ctx = new GridTestKernalContext(log);
+    }
+
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
         ctx.config().setCommunicationSpi(new TcpCommunicationSpi());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
index 8f7796d..6e3e0e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
@@ -293,7 +293,7 @@ public class IgniteUtilsSelfTest extends GridCommonAbstractTest {
         /**
          * @param ignite Grid.
          */
-        private SelfReferencedJob(Ignite ignite) {
+        private SelfReferencedJob(Ignite ignite) throws IgniteCheckedException {
             node = ignite.cluster().localNode();
 
             ref = this;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 a28996d..07fd9e3 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
@@ -20,6 +20,8 @@ package org.apache.ignite.marshaller.optimized;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.marshaller.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -42,6 +44,9 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
     /** */
     private boolean cache;
 
+    /** */
+    private String workDir;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -54,6 +59,8 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
 
         cfg.setMarshaller(new OptimizedMarshaller());
 
+        cfg.setWorkDirectory(workDir);
+
         if (cache) {
             CacheConfiguration ccfg = new CacheConfiguration();
 
@@ -111,6 +118,66 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
         assertNotNull(ignite.cache(null));
     }
 
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRestartAllNodes() throws Exception {
+        cache = false;
+
+        String home = U.getIgniteHome();
+
+        String[] workDirs = new String[3];
+
+        for (int i = 0; i < 3; i++) {
+            workDirs[i] = home + "/work/marshallerTestNode_" + i;
+
+            File file = new File(workDirs[i]);
+
+            if (file.exists())
+                assert U.delete(file);
+        }
+
+        try {
+            for (int i = 0; i < workDirs.length; i++) {
+                workDir = workDirs[i];
+
+                U.nullifyWorkDirectory();
+
+                startGrid(i);
+            }
+
+            Marshaller marsh = ignite(0).configuration().getMarshaller();
+
+            TestClass1 obj = new TestClass1();
+
+            obj.val = 111;
+
+            byte[] bytes = marsh.marshal(obj);
+
+            stopAllGrids();
+
+            for (int i = 0; i < workDirs.length; i++) {
+                workDir = workDirs[i];
+
+                U.nullifyWorkDirectory();
+
+                startGrid(i);
+            }
+
+            for (int i = 0; i < 3; i++) {
+                marsh = ignite(i).configuration().getMarshaller();
+
+                TestClass1 obj0 = marsh.unmarshal(bytes, null);
+
+                assertEquals(111, obj0.val);
+            }
+        }
+        finally {
+            for (String dir : workDirs)
+                assert U.delete(new File(dir));
+        }
+    }
+
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         super.afterTest();
@@ -153,7 +220,9 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
     /**
      *
      */
-    static class TestClass1 implements Serializable {}
+    static class TestClass1 implements Serializable {
+        int val;
+    }
 
     /**
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/spi/GridSpiLocalHostInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/GridSpiLocalHostInjectionTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/GridSpiLocalHostInjectionTest.java
index 7925823..a0eb81f 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/GridSpiLocalHostInjectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/GridSpiLocalHostInjectionTest.java
@@ -141,7 +141,7 @@ public class GridSpiLocalHostInjectionTest extends GridCommonAbstractTest
{
      * @param cfgVal {@code true} if {@code localHost} property value should be set to configuration.
      * @return Resource processor.
      */
-    private GridResourceProcessor getResourceProcessor(boolean cfgVal) {
+    private GridResourceProcessor getResourceProcessor(boolean cfgVal) throws IgniteCheckedException
{
         GridTestKernalContext ctx = newContext();
 
         if (cfgVal)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java
index 40e5b28..0e993a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java
@@ -32,7 +32,7 @@ import static org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisi
 @GridSpiTest(spi = PriorityQueueCollisionSpi.class, group = "Collision SPI")
 public class GridPriorityQueueCollisionSpiSelfTest extends GridSpiAbstractTest<PriorityQueueCollisionSpi>
{
     /** {@inheritDoc} */
-    @Override protected void afterTest() {
+    @Override protected void afterTest() throws Exception {
         getSpi().setParallelJobsNumber(DFLT_PARALLEL_JOBS_NUM);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java
index 72c1014..55c3016 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java
@@ -112,7 +112,7 @@ public class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest
     }
 
     /** */
-    public void testNodeNotInTopology() {
+    public void testNodeNotInTopology() throws Exception {
         ComputeTaskSession ses = new GridTestTaskSession();
 
         ClusterNode node = new GridTestNode(UUID.randomUUID());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 93d1d74..da316fd 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
@@ -116,7 +116,7 @@ public abstract class GridAbstractTest extends TestCase {
     private static final ConcurrentMap<UUID, Object> serializedObj = new ConcurrentHashMap<>();
 
     /** */
-    protected GridAbstractTest() {
+    protected GridAbstractTest() throws IgniteCheckedException {
         this(false);
 
         log = getTestCounters().getTestResources().getLogger().getLogger(getClass());
@@ -172,7 +172,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return Test resources.
      */
-    protected IgniteTestResources getTestResources() {
+    protected IgniteTestResources getTestResources() throws IgniteCheckedException {
         return getTestCounters().getTestResources();
     }
 
@@ -215,7 +215,8 @@ public abstract class GridAbstractTest extends TestCase {
      * @param cats Additional categories.
      */
     @SuppressWarnings({"deprecation"})
-    protected void resetLog4j(Level log4jLevel, boolean logToFile, String cat, String...
cats) {
+    protected void resetLog4j(Level log4jLevel, boolean logToFile, String cat, String...
cats)
+        throws IgniteCheckedException {
         for (String c : F.concat(false, cat, F.asList(cats)))
             Logger.getLogger(c).setLevel(log4jLevel);
 
@@ -381,7 +382,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return Test kernal context.
      */
-    protected GridTestKernalContext newContext() {
+    protected GridTestKernalContext newContext() throws IgniteCheckedException {
         return new GridTestKernalContext(log());
     }
 
@@ -672,7 +673,7 @@ public abstract class GridAbstractTest extends TestCase {
      * @param cfg Configuration.
      * @return Optimized configuration (by modifying passed in one).
      */
-    protected IgniteConfiguration optimize(IgniteConfiguration cfg) {
+    protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException
{
         // TODO: GG-4048: propose another way to avoid network overhead in tests.
         if (cfg.getLocalHost() == null) {
             if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi)
@@ -1055,7 +1056,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return Ignite home.
      */
-    protected String home() {
+    protected String home() throws IgniteCheckedException {
         return getTestResources().getIgniteHome();
     }
 
@@ -1250,7 +1251,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return First test flag.
      */
-    protected boolean isFirstTest() {
+    protected boolean isFirstTest() throws IgniteCheckedException {
         TestCounters cntrs = getTestCounters();
 
         return cntrs.getStarted() == 1 && cntrs.getStopped() == 0;
@@ -1259,7 +1260,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return Last test flag.
      */
-    protected boolean isLastTest() {
+    protected boolean isLastTest() throws IgniteCheckedException {
         TestCounters cntrs = getTestCounters();
 
         return cntrs.getStopped() == cntrs.getNumberOfTests();
@@ -1268,7 +1269,7 @@ public abstract class GridAbstractTest extends TestCase {
     /**
      * @return Test counters.
      */
-    protected synchronized TestCounters getTestCounters() {
+    protected synchronized TestCounters getTestCounters() throws IgniteCheckedException {
         TestCounters tc = tests.get(getClass());
 
         if (tc == null)
@@ -1461,7 +1462,14 @@ public abstract class GridAbstractTest extends TestCase {
         private boolean reset;
 
         /** */
-        private IgniteTestResources rsrcs = new IgniteTestResources();
+        private IgniteTestResources rsrcs;
+
+        /**
+         * @throws IgniteCheckedException In case of error.
+         */
+        public TestCounters() throws IgniteCheckedException {
+            rsrcs = new IgniteTestResources();
+        }
 
         /**
          * @return Reset flag.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index b871a4a..6b7a7f9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -33,7 +33,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
     /**
      * @param log Logger to use in context config.
      */
-    public GridTestKernalContext(IgniteLogger log) {
+    public GridTestKernalContext(IgniteLogger log) throws IgniteCheckedException {
         super(new GridLoggerProxy(log, null, null, null),
             new IgniteKernal(null),
             new IgniteConfiguration(),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 583c082..61dddbe 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
@@ -63,13 +63,15 @@ public class IgniteTestResources {
     private GridResourceProcessor rsrcProc;
 
     /** */
-    public IgniteTestResources() {
+    public IgniteTestResources() throws IgniteCheckedException {
         log = rootLog.getLogger(getClass());
         nodeId = UUID.randomUUID();
         jmx = ManagementFactory.getPlatformMBeanServer();
         home = U.getIgniteHome();
         locHost = localHost();
 
+        U.setWorkDirectory(null, null);
+
         GridTestKernalContext ctx = new GridTestKernalContext(log);
 
         rsrcProc = new GridResourceProcessor(ctx);
@@ -78,7 +80,7 @@ public class IgniteTestResources {
     /**
      * @param jmx JMX server.
      */
-    public IgniteTestResources(MBeanServer jmx) {
+    public IgniteTestResources(MBeanServer jmx) throws IgniteCheckedException {
         assert jmx != null;
 
         this.jmx = jmx;
@@ -97,7 +99,7 @@ public class IgniteTestResources {
     /**
      * @param log Logger.
      */
-    public IgniteTestResources(IgniteLogger log) {
+    public IgniteTestResources(IgniteLogger log) throws IgniteCheckedException {
         assert log != null;
 
         this.log = log.getLogger(getClass());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ea7d2485/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 3df5283..7898c3d 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
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.testframework.junits.spi;
 
+import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -86,7 +87,7 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends
GridAbstr
      * @return Test data.
      */
     @SuppressWarnings({"unchecked"})
-    protected TestData<T> getTestData() {
+    protected TestData<T> getTestData() throws IgniteCheckedException {
         TestData<T> data = (TestData<T>)tests.get(getClass());
 
         if (data == null)
@@ -157,7 +158,7 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends
GridAbstr
     }
 
     /** {@inheritDoc} */
-    @Override protected final IgniteTestResources getTestResources() {
+    @Override protected final IgniteTestResources getTestResources() throws IgniteCheckedException
{
         return getTestData().getTestResources();
     }
 
@@ -429,7 +430,7 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends
GridAbstr
     /**
      * @return  Fully initialized and started SPI implementation.
      */
-    protected final T getSpi() {
+    protected final T getSpi() throws IgniteCheckedException {
         return getTestData().getSpi();
     }
 
@@ -584,13 +585,13 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi>
extends GridAbstr
         private Map<String, Object> allAttrs = new HashMap<>();
 
         /** */
-        private IgniteTestResources rsrcs = new IgniteTestResources();
+        private IgniteTestResources rsrcs;
 
         /**
          *
          */
-        TestData() {
-            // No-op.
+        TestData() throws IgniteCheckedException {
+            rsrcs = new IgniteTestResources();
         }
 
         /**


Mime
View raw message