ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [08/17] ignite git commit: review IGNITE-2708 Need to validate that SPIs are started only once (added logic to protect properly started grids) (cherry picked from commit b8d624a)
Date Wed, 01 Jun 2016 11:27:54 GMT
review IGNITE-2708 Need to validate that SPIs are started only once (added logic to protect
properly started grids)
(cherry picked from commit b8d624a)


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

Branch: refs/heads/ignite-3038
Commit: 52e2f71a6d57cd4f60582e59ad1660b2baec6f74
Parents: c5019c6
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri May 13 12:54:01 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Tue May 31 09:32:49 2016 +0300

----------------------------------------------------------------------
 .../internal/managers/GridManagerAdapter.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/52e2f71a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
index 58d64f6..a09047b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.managers;
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.IdentityHashMap;
 import java.util.Map;
 import java.util.UUID;
 import javax.cache.expiry.Duration;
@@ -84,6 +86,9 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements
GridMan
     /** Checks is SPI implementation is {@code NO-OP} or not. */
     private final boolean enabled;
 
+    /** */
+    private final Map<IgniteSpi, Boolean> spiMap = new IdentityHashMap<>();
+
     /**
      * @param ctx Kernal context.
      * @param spis Specific SPI instance.
@@ -212,6 +217,11 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements
GridMan
             if (spi instanceof IgniteSpiAdapter)
                 ((IgniteSpiAdapter)spi).onBeforeStart();
 
+            // Save SPI to map to make sure to stop it properly.
+            Boolean res = spiMap.put(spi, Boolean.TRUE);
+
+            assert res == null;
+
             // Inject all spi resources.
             ctx.resource().inject(spi);
 
@@ -275,6 +285,13 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements
GridMan
      */
     protected final void stopSpi() throws IgniteCheckedException {
         for (T spi : spis) {
+            if (spiMap.remove(spi) == null) {
+                if (log.isDebugEnabled())
+                    log.debug("Will not stop SPI since it has not been started by this manager:
" + spi);
+
+                continue;
+            }
+
             if (log.isDebugEnabled())
                 log.debug("Stopping SPI: " + spi);
 


Mime
View raw message