ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject [4/5] 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 Fri, 27 May 2016 11:37:46 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/9d937ca3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9d937ca3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9d937ca3

Branch: refs/heads/master
Commit: 9d937ca34775f39b46568eb3fca4585ce00a0fb1
Parents: d05786d
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri May 13 12:54:01 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Fri May 27 14:35:42 2016 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/9d937ca3/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 1a0d60f..4fe8ca8 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
@@ -20,6 +20,7 @@ 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 +85,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 +216,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 +284,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