ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [3/4] ignite git commit: IGNITE-5392 - Joining node must accept cluster active status
Date Sun, 11 Jun 2017 18:54:22 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
index 3c500a4..643480d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
@@ -33,6 +34,7 @@ import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.GridKernalContext;
@@ -44,6 +46,11 @@ import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData;
+import org.apache.ignite.internal.processors.cache.CacheData;
+import org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData;
+import org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData.CacheInfo;
+import org.apache.ignite.internal.processors.cache.CacheNodeCommonDiscoveryData;
 import org.apache.ignite.internal.processors.cache.ChangeGlobalStateMessage;
 import org.apache.ignite.internal.processors.cache.ClusterState;
 import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch;
@@ -53,6 +60,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse;
 import org.apache.ignite.internal.processors.cache.StoredCacheData;
+import org.apache.ignite.internal.processors.query.QuerySchema;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -60,21 +68,25 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag;
+import org.apache.ignite.spi.discovery.DiscoveryDataBag.JoiningNodeDiscoveryData;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.CACHE_PROC;
+import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.STATE_PROC;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
 import static org.apache.ignite.internal.processors.cache.ClusterState.ACTIVE;
 import static org.apache.ignite.internal.processors.cache.ClusterState.INACTIVE;
 import static org.apache.ignite.internal.processors.cache.ClusterState.TRANSITION;
+import static org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest.stopRequest;
 
 /**
  *
@@ -127,20 +139,10 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
-        super.start(activeOnStart);
-
-        globalState = activeOnStart ? ACTIVE : INACTIVE;
-        cacheProc = ctx.cache();
-        sharedCtx = cacheProc.context();
-
-        sharedCtx.io().addCacheHandler(0,
-            GridChangeGlobalStateMessageResponse.class,
-            new CI2<UUID, GridChangeGlobalStateMessageResponse>() {
-                @Override public void apply(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
-                    processChangeGlobalStateResponse(nodeId, msg);
-                }
-            });
+    @Override public void start() throws IgniteCheckedException {
+        // Start first node as inactive if persistent enable.
+        globalState = ctx.config().isPersistentStoreEnabled() ? INACTIVE :
+            ctx.config().isActiveOnStart() ? ACTIVE : INACTIVE;
 
         ctx.discovery().setCustomEventListener(
             ChangeGlobalStateMessage.class, new CustomEventListener<ChangeGlobalStateMessage>() {
@@ -190,6 +192,23 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         ctx.event().addLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
     }
 
+    public void cacheProcessorStarted(CacheJoinNodeDiscoveryData data) {
+        assert data != null;
+
+        localCacheData = data;
+
+        cacheProc = ctx.cache();
+        sharedCtx = cacheProc.context();
+
+        sharedCtx.io().addCacheHandler(
+            0, GridChangeGlobalStateMessageResponse.class,
+            new CI2<UUID, GridChangeGlobalStateMessageResponse>() {
+                @Override public void apply(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
+                    processChangeGlobalStateResponse(nodeId, msg);
+                }
+            });
+    }
+
     /** {@inheritDoc} */
     @Override public void stop(boolean cancel) throws IgniteCheckedException {
         super.stop(cancel);
@@ -215,7 +234,8 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
     /** {@inheritDoc} */
     @Override public void collectGridNodeData(DiscoveryDataBag dataBag) {
-        dataBag.addGridCommonData(DiscoveryDataExchangeType.STATE_PROC.ordinal(), globalState);
+        if (!dataBag.commonDataCollectedFor(STATE_PROC.ordinal()))
+            dataBag.addGridCommonData(STATE_PROC.ordinal(), globalState);
     }
 
     /** {@inheritDoc} */
@@ -224,6 +244,25 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
         if (state != null)
             globalState = state;
+
+        // TODO warning, processing in discovery thread!!!
+        if (globalState == INACTIVE) {
+            // Clean up.
+            try {
+                if (sharedCtx.pageStore() != null)
+                    sharedCtx.pageStore().onDeActivate(ctx);
+
+                if (sharedCtx.wal() != null)
+                    sharedCtx.wal().onDeActivate(ctx);
+
+                // Todo check after join
+                sharedCtx.database().onDeActivate(ctx);
+            }
+            catch (IgniteCheckedException e) {
+                // Todo Need handler correct .
+                e.printStackTrace();
+            }
+        }
     }
 
     /**
@@ -250,33 +289,32 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
                     "fail " + prettyStr(activate) + ", because now in progress" + prettyStr(locF.activate)));
         }
 
-        try {
-            if (ctx.clientNode()) {
-                AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
+        if (ctx.clientNode()) {
+            AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
 
-                IgniteCompute comp = ((ClusterGroupAdapter)ctx.cluster().get().forServers())
-                    .compute().withAsync();
+            IgniteCompute comp = ((ClusterGroupAdapter)ctx.cluster().get().forServers()).compute();
 
-                if (log.isInfoEnabled())
-                    log.info("Send " + prettyStr(activate) + " request from client node [id=" +
-                        ctx.localNodeId() + " topVer=" + topVer + " ]");
+            if (log.isInfoEnabled())
+                log.info("Send " + prettyStr(activate) + " request from client node [id=" +
+                    ctx.localNodeId() + " topVer=" + topVer + " ]");
 
-                comp.run(new ClientChangeGlobalStateComputeRequest(activate));
+            IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate));
 
-                comp.future().listen(new CI1<IgniteFuture>() {
-                    @Override public void apply(IgniteFuture fut) {
-                        try {
-                            fut.get();
+            fut.listen(new CI1<IgniteFuture>() {
+                @Override public void apply(IgniteFuture fut) {
+                    try {
+                        fut.get();
 
-                            cgsFut.onDone();
-                        }
-                        catch (Exception e) {
-                            cgsFut.onDone(e);
-                        }
+                        cgsFut.onDone();
                     }
-                });
-            }
-            else {
+                    catch (Exception e) {
+                        cgsFut.onDone(e);
+                    }
+                }
+            });
+        }
+        else {
+            try {
                 List<DynamicCacheChangeRequest> reqs = new ArrayList<>();
 
                 DynamicCacheChangeRequest changeGlobalStateReq = new DynamicCacheChangeRequest(
@@ -284,7 +322,11 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
                 reqs.add(changeGlobalStateReq);
 
-                reqs.addAll(activate ? cacheProc.startAllCachesRequests() : cacheProc.stopAllCachesRequests());
+                List<DynamicCacheChangeRequest> cacheReqs = activate ? startAllCachesRequests() : stopAllCachesRequests();
+
+                reqs.addAll(cacheReqs);
+
+                printCacheInfo(cacheReqs, activate);
 
                 ChangeGlobalStateMessage changeGlobalStateMsg = new ChangeGlobalStateMessage(
                     requestId, ctx.localNodeId(), activate, new DynamicCacheChangeBatch(reqs));
@@ -302,14 +344,123 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
                     cgsFut.onDone(e);
                 }
             }
+            catch (IgniteCheckedException e) {
+                cgsFut.onDone(e);
+            }
         }
-        catch (IgniteCheckedException e) {
-            log.error("Fail create or send change global state request." + cgsFut, e);
 
-            cgsFut.onDone(e);
+        return cgsFut;
+    }
+
+    private void printCacheInfo(List<DynamicCacheChangeRequest> reqs, boolean active) {
+        assert reqs != null;
+
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("[");
+
+        for (int i = 0; i < reqs.size() - 1; i++)
+            sb.append(reqs.get(i).cacheName()).append(", ");
+
+        sb.append(reqs.get(reqs.size() - 1).cacheName());
+
+        sb.append("]");
+
+        sb.append(" ").append(reqs.size())
+            .append(" caches will be ")
+            .append(active ? "started" : "stopped");
+
+        if (log.isInfoEnabled())
+            log.info(sb.toString());
+    }
+
+    public void onCacheStart(DynamicCacheChangeRequest req) {
+        CacheInfo cacheInfo = cacheData.get(req.cacheName());
+
+        if (cacheInfo == null)
+            cacheData.put(req.cacheName(),
+                new CacheInfo(
+                    new StoredCacheData(req.startCacheConfiguration()),
+                    req.cacheType(), req.sql(),
+                    0L)
+            );
+    }
+
+    public void onCacheStop(DynamicCacheChangeRequest req) {
+        CacheInfo cacheInfo = cacheData.get(req.cacheName());
+
+        if (cacheInfo != null)
+            cacheData.remove(req.cacheName());
+    }
+
+    private Map<String, CacheConfiguration> allCaches() {
+        Map<String, CacheConfiguration> cfgs = new HashMap<>();
+
+        for (Map.Entry<String, CacheInfo> entry : cacheData.entrySet())
+            if (cfgs.get(entry.getKey()) == null)
+                cfgs.put(entry.getKey(), entry.getValue().cacheData().config());
+
+        return cfgs;
+    }
+
+    private List<DynamicCacheChangeRequest> startAllCachesRequests() throws IgniteCheckedException {
+        assert !ctx.config().isDaemon();
+
+        Collection<CacheConfiguration> cacheCfgs = allCaches().values();
+
+        final List<DynamicCacheChangeRequest> reqs = new ArrayList<>();
+
+        if (sharedCtx.pageStore() != null && sharedCtx.database().persistenceEnabled()) {
+            Map<String, StoredCacheData> ccfgs = sharedCtx.pageStore().readCacheConfigurations();
+
+            for (Map.Entry<String, StoredCacheData> entry : ccfgs.entrySet())
+                reqs.add(createRequest(entry.getValue().config()));
+
+            for (CacheConfiguration cfg : cacheCfgs)
+                if (!ccfgs.keySet().contains(cfg.getName()))
+                    reqs.add(createRequest(cfg));
+
+            return reqs;
         }
+        else {
+            for (CacheConfiguration cfg : cacheCfgs)
+                reqs.add(createRequest(cfg));
 
-        return cgsFut;
+            return reqs;
+        }
+    }
+
+    private DynamicCacheChangeRequest createRequest(CacheConfiguration cfg) {
+        assert cfg != null;
+        assert cfg.getName() != null;
+
+        String cacheName = cfg.getName();
+
+        DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(
+            UUID.randomUUID(), cacheName, ctx.localNodeId());
+
+        req.startCacheConfiguration(cfg);
+        req.template(cfg.getName().endsWith("*"));
+        req.nearCacheConfiguration(cfg.getNearConfiguration());
+        req.deploymentId(IgniteUuid.randomUuid());
+        req.schema(new QuerySchema(cfg.getQueryEntities()));
+        req.cacheType(cacheProc.cacheType(cacheName));
+
+        return req;
+    }
+
+    private List<DynamicCacheChangeRequest> stopAllCachesRequests() {
+        Collection<CacheConfiguration> cacheCfgs = allCaches().values();
+
+        List<DynamicCacheChangeRequest> reqs = new ArrayList<>(cacheCfgs.size());
+
+        for (CacheConfiguration cfg : cacheCfgs) {
+            DynamicCacheChangeRequest req = stopRequest(ctx, cfg.getName(), false, false);
+
+            reqs.add(req);
+        }
+
+        return reqs;
     }
 
     /**
@@ -327,6 +478,79 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         return globalState == ACTIVE;
     }
 
+    @Override public void onKernalStart() throws IgniteCheckedException {
+        super.onKernalStart();
+
+        // First node started (coordinator).
+        if (ctx.discovery().serverNodes(AffinityTopologyVersion.NONE).get(0).isLocal())
+            cacheData.putAll(localCacheData.caches());
+    }
+
+    private final ConcurrentHashMap<String, CacheInfo> cacheData = new ConcurrentHashMap<>();
+
+    private volatile CacheJoinNodeDiscoveryData localCacheData;
+
+    public boolean isLocalConfigure(String cacheName){
+        assert localCacheData != null;
+
+        return localCacheData.caches().containsKey(cacheName) || localCacheData.templates().containsKey(cacheName);
+    }
+
+    // Invoke if cluster inactive.
+    public void collectGridNodeData0(DiscoveryDataBag dataBag) {
+        if (!dataBag.commonDataCollectedFor(CACHE_PROC.ordinal()))
+            dataBag.addGridCommonData(CACHE_PROC.ordinal(), cacheData);
+    }
+
+    public void onJoiningNodeDataReceived0(JoiningNodeDiscoveryData data) {
+        if (data.hasJoiningNodeData()) {
+            if (data.joiningNodeData() instanceof CacheJoinNodeDiscoveryData) {
+                CacheJoinNodeDiscoveryData data0 = (CacheJoinNodeDiscoveryData)data.joiningNodeData();
+
+                cacheData.putAll(data0.caches());
+            }
+            else if (data.joiningNodeData() instanceof CacheClientReconnectDiscoveryData) {
+                CacheClientReconnectDiscoveryData data0 = (CacheClientReconnectDiscoveryData)data.joiningNodeData();
+
+                //Todo think how handler?
+            }
+        }
+    }
+
+    public void onGridDataReceived0(DiscoveryDataBag.GridDiscoveryData data) {
+        // Receive data from active cluster.
+        if (data.commonData() instanceof CacheNodeCommonDiscoveryData) {
+            CacheNodeCommonDiscoveryData data0 = (CacheNodeCommonDiscoveryData)data.commonData();
+
+            Map<String, CacheData> caches = data0.caches();
+
+            Map<String, CacheInfo> cacheInfos = new HashMap<>();
+
+            for (Map.Entry<String, CacheData> entry : caches.entrySet()) {
+                CacheData val = entry.getValue();
+
+                CacheInfo info = new CacheInfo(
+                    new StoredCacheData(val.cacheConfiguration()),
+                    val.cacheType(),
+                    val.sql(),
+                    val.flags()
+                );
+
+                cacheInfos.put(entry.getKey(), info);
+            }
+
+            cacheData.putAll(cacheInfos);
+
+        } // Receive data from inactive cluster.
+        else if (data.commonData() instanceof Map) {
+            Map<String, CacheInfo> data0 = (Map<String, CacheInfo>)data.commonData();
+
+            cacheData.putAll(data0);
+        }
+
+        cacheData.putAll(localCacheData.caches());
+    }
+
     /**
      * @param exchActions Requests.
      * @param topVer Exchange topology version.
@@ -341,7 +565,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         if (exchActions.newClusterState() != null) {
             ChangeGlobalStateContext cgsCtx = lastCgsCtx;
 
-            assert cgsCtx != null : exchActions;
+            assert cgsCtx != null : topVer;
 
             cgsCtx.topologyVersion(topVer);
 
@@ -412,7 +636,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         GridChangeGlobalStateFuture af = cgsLocFut.get();
 
         if (af != null && af.requestId.equals(actx.requestId)) {
-            IgniteCheckedException e = new IgniteCheckedException("see suppressed");
+            IgniteCheckedException e = new IgniteCheckedException("Fail " + prettyStr(actx.activate), null, false);
 
             for (Map.Entry<UUID, Exception> entry : exs.entrySet())
                 e.addSuppressed(entry.getValue());
@@ -439,34 +663,18 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         }
 
         try {
-            if (!client) {
+            if (!client)
                 sharedCtx.database().lock();
 
-                IgnitePageStoreManager pageStore = sharedCtx.pageStore();
+            IgnitePageStoreManager pageStore = sharedCtx.pageStore();
 
-                if (pageStore != null)
-                    pageStore.onActivate(ctx);
+            if (pageStore != null)
+                pageStore.onActivate(ctx);
 
-                if (sharedCtx.wal() != null)
-                    sharedCtx.wal().onActivate(ctx);
+            if (sharedCtx.wal() != null)
+                sharedCtx.wal().onActivate(ctx);
 
-                sharedCtx.database().initDataBase();
-
-                // TODO IGNITE-5075 group descriptors.
-                for (StoredCacheData cacheData : cfgs) {
-                    if (CU.isSystemCache(cacheData.config().getName()))
-                        if (pageStore != null)
-                            pageStore.initializeForCache(ctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor(), cacheData);
-                }
-
-                for (StoredCacheData cacheData : cfgs) {
-                    if (!CU.isSystemCache(cacheData.config().getName()))
-                        if (pageStore != null)
-                            pageStore.initializeForCache(ctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor(), cacheData);
-                }
-
-                sharedCtx.database().onActivate(ctx);
-            }
+            sharedCtx.database().onActivate(ctx);
 
             if (log.isInfoEnabled())
                 log.info("Success activate wal, dataBase, pageStore [nodeId="
@@ -478,7 +686,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
             log.error("Fail activate wal, dataBase, pageStore [nodeId=" + ctx.localNodeId() + ", client=" + client +
                 ", topVer=" + cgsCtx.topVer + "]", e);
 
-            if (!ctx.clientNode())
+            if (!client)
                 sharedCtx.database().unLock();
 
             return e;
@@ -512,10 +720,6 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
             return e;
         }
-        finally {
-            if (!client)
-                sharedCtx.database().unLock();
-        }
     }
 
     /**
@@ -574,17 +778,15 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         Exception ex = null;
 
         try {
-            if (!client) {
-                sharedCtx.database().onDeActivate(ctx);
+            sharedCtx.database().onDeActivate(ctx);
 
-                if (sharedCtx.pageStore() != null)
-                    sharedCtx.pageStore().onDeActivate(ctx);
+            if (sharedCtx.pageStore() != null)
+                sharedCtx.pageStore().onDeActivate(ctx);
 
-                if (sharedCtx.wal() != null)
-                    sharedCtx.wal().onDeActivate(ctx);
+            if (sharedCtx.wal() != null)
+                sharedCtx.wal().onDeActivate(ctx);
 
-                sharedCtx.affinity().removeAllCacheInfo();
-            }
+            sharedCtx.affinity().removeAllCacheInfo();
         }
         catch (Exception e) {
             ex = e;

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index a72dcd6..9b04af9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -152,7 +152,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (ctx.config().isDaemon())
             return;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index c52f7ac..70b3103 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -94,7 +94,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (ctx.config().isDaemon())
             return;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 961fe46..369a909 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -202,31 +202,23 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
-        super.start(activeOnStart);
-
-        if (!activeOnStart)
-            return;
-
+    @Override public void start() throws IgniteCheckedException {
         ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
     }
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void onKernalStart() throws IgniteCheckedException {
         if (ctx.config().isDaemon() || !ctx.state().active())
             return;
 
-        onKernalStart0(activeOnStart);
+        onKernalStart0();
     }
 
     /**
      *
      */
-    private void onKernalStart0(boolean activeOnStart){
-        if (!activeOnStart && ctx.state().active())
-            ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
-
+    private void onKernalStart0(){
         utilityCache = (IgniteInternalCache)ctx.cache().utilityCache();
 
         utilityDataCache = (IgniteInternalCache)ctx.cache().utilityCache();
@@ -315,7 +307,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
 
         ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
 
-        onKernalStart0(true);
+        onKernalStart0();
 
         restoreStructuresState(ctx);
     }
@@ -324,7 +316,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
      * @param ctx Context.
      */
     public void restoreStructuresState(GridKernalContext ctx) {
-        onKernalStart0(true);
+        onKernalStart0();
 
         try {
             for (Map.Entry<GridCacheInternal, GridCacheRemovable> e : dsMap.entrySet()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index d848d2f..3c2f64d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -75,7 +75,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         IgniteConfiguration igniteCfg = ctx.config();
 
         if (igniteCfg.isDaemon())
@@ -177,7 +177,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void onKernalStart() throws IgniteCheckedException {
         if (ctx.config().isDaemon())
             return;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index e0bc4d2..9108967 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -235,7 +235,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (metricsUpdateFreq < -1)
             throw new IgniteCheckedException("Invalid value for 'metricsUpdateFrequency' configuration property " +
                 "(should be greater than or equals to -1): " + metricsUpdateFreq);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessor.java
index e7fe8ae..c40cfda 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessor.java
@@ -127,7 +127,7 @@ public class GridJobMetricsProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         assertParameter(histSize > 0, "metricsHistorySize > 0");
         assertParameter(expireTime > 0, "metricsExpireTime > 0");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/GridMarshallerMappingProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/GridMarshallerMappingProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/GridMarshallerMappingProcessor.java
index 9b65aa5..266c6f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/GridMarshallerMappingProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/GridMarshallerMappingProcessor.java
@@ -100,7 +100,7 @@ public class GridMarshallerMappingProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         GridDiscoveryManager discoMgr = ctx.discovery();
         GridIoManager ioMgr = ctx.io();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
index 9a30d54..a7061ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
@@ -67,7 +67,7 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         IgniteConfiguration cfg = ctx.config();
 
         SqlConnectorConfiguration sqlCfg = prepareConfiguration(cfg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index 792df86..1da3112 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -147,7 +147,7 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         try (PlatformMemory mem = platformCtx.memory().allocate()) {
             PlatformOutputStream out = mem.output();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
index 687700c..c1e542d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
@@ -148,7 +148,7 @@ public class IgnitePluginProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         ackPluginsInfo();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/port/GridPortProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/port/GridPortProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/port/GridPortProcessor.java
index 3d06a2a..5d75a4a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/port/GridPortProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/port/GridPortProcessor.java
@@ -57,7 +57,7 @@ public class GridPortProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (log.isDebugEnabled())
             log.debug("Started port processor.");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 2a71595..6079ae8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -223,8 +223,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
-        super.start(activeOnStart);
+    @Override public void start() throws IgniteCheckedException {
+        super.start();
 
         if (idx != null) {
             ctx.resource().injectGeneric(idx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
index 345bf34..6d508fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
@@ -77,7 +77,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (log.isDebugEnabled())
             log.debug("Started resource processor.");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index f2f2b34..716adf7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -451,7 +451,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (isRestEnabled()) {
             if (notStartOnClient()) {
                 U.quietAndInfo(log, "REST protocols do not start on client node. " +
@@ -503,7 +503,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void onKernalStart() throws IgniteCheckedException {
         if (isRestEnabled()) {
             for (GridRestProtocol proto : protos)
                 proto.onKernalStart();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index e3d365f..5c1872c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -194,10 +194,10 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         ctx.addNodeAttribute(ATTR_SERVICES_COMPATIBILITY_MODE, srvcCompatibilitySysProp);
 
-        if (ctx.isDaemon() || !activeOnStart)
+        if (ctx.isDaemon())
             return;
 
         IgniteConfiguration cfg = ctx.config();
@@ -211,7 +211,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void onKernalStart() throws IgniteCheckedException {
         if (ctx.isDaemon() || !ctx.state().active())
             return;
 
@@ -348,9 +348,9 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
 
         depExe = Executors.newSingleThreadExecutor(new IgniteThreadFactory(ctx.igniteInstanceName(), "srvc-deploy"));
 
-        start(true);
+        start();
 
-        onKernalStart(true);
+        onKernalStart();
     }
 
     /** {@inheritDoc} */
@@ -364,6 +364,8 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
         cancelFutures(undepFuts, new IgniteCheckedException("Failed to undeploy service, cluster in active."));
 
         onKernalStop(true);
+
+        busyLock.unblock();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
index f9937a6..91ccf4a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
@@ -49,7 +49,7 @@ public class GridTaskSessionProcessor extends GridProcessorAdapter {
     /**
      * Starts session processor.
      */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (log.isDebugEnabled())
             log.debug("Session processor started.");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index e73d292..683d3c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -140,7 +140,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) {
+    @Override public void start() {
         ctx.event().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
 
         ctx.io().addMessageListener(TOPIC_JOB_SIBLINGS, new JobSiblingsMessageListener());
@@ -152,7 +152,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void onKernalStart() throws IgniteCheckedException {
         tasksMetaCache = ctx.security().enabled() && !ctx.isDaemon() ?
             ctx.cache().<GridTaskNameHashKey, String>utilityCache() : null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessor.java
index 1651d17..9deca9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessor.java
@@ -67,7 +67,7 @@ public class GridTimeoutProcessor extends GridProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) {
+    @Override public void start() {
         timeoutWorker.start();
 
         if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c253a6d..184b6cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -3729,32 +3729,6 @@ class ServerImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                boolean locActiveOnStart = booleanAttribute(locNode, ATTR_ACTIVE_ON_START, true);
-                boolean rmtActiveOnStart = booleanAttribute(node, ATTR_ACTIVE_ON_START, true);
-
-                if (locActiveOnStart != rmtActiveOnStart) {
-                    String errMsg = "Local node's active on start flag differs from " +
-                        "the same property on remote node (make sure all nodes in topology have the same " +
-                        "active on start flag) [locActiveOnStart=" + locActiveOnStart +
-                        ", rmtActiveOnStart=" + rmtActiveOnStart +
-                        ", locNodeAddrs=" + U.addressesAsString(locNode) +
-                        ", rmtNodeAddrs=" + U.addressesAsString(node) +
-                        ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']';
-
-                    String sndMsg = "Local node's active on start flag differs from " +
-                        "the same property on remote node (make sure all nodes in topology have the same " +
-                        "active on start flag) [locActiveOnStart=" + rmtActiveOnStart +
-                        ", rmtActiveOnStart=" + locActiveOnStart +
-                        ", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() +
-                        ", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() +
-                        ", rmtNodeId=" + locNode.id() + ']';
-
-                    nodeCheckError(node, errMsg, sndMsg);
-
-                    // Ignore join request.
-                    return;
-                }
-
                 final Boolean locSrvcCompatibilityEnabled = locNode.attribute(ATTR_SERVICES_COMPATIBILITY_MODE);
 
                 final Boolean rmtSrvcCompatibilityEnabled = node.attribute(ATTR_SERVICES_COMPATIBILITY_MODE);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
index 48e617f..5e85b62 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
@@ -126,9 +126,9 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT
 
         Manager mgr = new Manager(grid().context(), new Spi());
 
-        mgr.start(true);
+        mgr.start();
 
-        mgr.onKernalStart(true);
+        mgr.onKernalStart();
 
         assertTrue(mgr.enabled());
     }
@@ -143,7 +143,7 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT
 
         assertTrue(mgr.enabled());
 
-        mgr.onKernalStart(true);
+        mgr.onKernalStart();
 
         mgr.onKernalStop(false);
 
@@ -163,7 +163,7 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT
         }
 
         /** {@inheritDoc} */
-        @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+        @Override public void start() throws IgniteCheckedException {
             // No-op.
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/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 cb7efc8..795bda4 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
@@ -57,7 +57,7 @@ public class GridNoopManagerSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+        @Override public void start() throws IgniteCheckedException {
             // No-op.
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/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 1df86f1..90af25e 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
@@ -477,9 +477,9 @@ public class GridTcpCommunicationSpiMultithreadedSelfTest extends GridSpiAbstrac
 
         timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));
 
-        timeoutProcessor.start(true);
+        timeoutProcessor.start();
 
-        timeoutProcessor.onKernalStart(true);
+        timeoutProcessor.onKernalStart();
 
         for (int i = 0; i < getSpiCount(); i++) {
             CommunicationSpi<Message> spi = newCommunicationSpi();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestReconnectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestReconnectProcessor.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestReconnectProcessor.java
index d15ddf9..2476bd3 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestReconnectProcessor.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestReconnectProcessor.java
@@ -50,7 +50,7 @@ public class TestReconnectProcessor extends GridProcessorAdapter implements Grid
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS, new SecurityCredentials());
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/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 5b7e4b2..93f691e 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
@@ -779,6 +779,17 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * Starts new grid with given configuration.
+     *
+     * @param cfg Ignite configuration.
+     * @return Started grid.
+     * @throws Exception If anything failed.
+     */
+    protected IgniteEx startGrid(IgniteConfiguration cfg) throws Exception {
+        return (IgniteEx)startGrid(cfg.getIgniteInstanceName(), cfg, null);
+    }
+
+    /**
      * Starts new grid with given index and Spring application context.
      *
      * @param idx Index of the grid to start.
@@ -1213,13 +1224,6 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
-     * @param cfg Config.
-     */
-    protected Ignite startGrid(IgniteConfiguration cfg) throws Exception {
-        return startGrid(cfg.getIgniteInstanceName(), cfg);
-    }
-
-    /**
      * Loads configuration from the given Spring XML file.
      *
      * @param springCfgPath Path to file.

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/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 b8d1ce9..bb92e25 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
@@ -83,7 +83,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
      */
     public void start() throws IgniteCheckedException {
         for (GridComponent comp : this)
-            comp.start(config().isActiveOnStart());
+            comp.start();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
index c7db48f..329d67f 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
@@ -64,7 +64,7 @@ public class HadoopProcessor extends HadoopProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void start(boolean activeOnStart) throws IgniteCheckedException {
+    @Override public void start() throws IgniteCheckedException {
         if (ctx.isDaemon())
             return;
 
@@ -95,8 +95,8 @@ public class HadoopProcessor extends HadoopProcessorAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
-        super.onKernalStart(activeOnStart);
+    @Override public void onKernalStart() throws IgniteCheckedException {
+        super.onKernalStart();
 
         if (hctx == null)
             return;

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/GridCacheDatabaseSharedManager.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/GridCacheDatabaseSharedManager.java
index 10b664d..cae59a4 100755
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/GridCacheDatabaseSharedManager.java
+++ b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/GridCacheDatabaseSharedManager.java
@@ -103,6 +103,7 @@ import org.apache.ignite.internal.processors.cache.CacheGroupContext;
 import org.apache.ignite.internal.processors.cache.ClusterState;
 import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.StoredCacheData;
 import org.apache.ignite.internal.processors.cache.database.file.FilePageStoreManager;
@@ -347,7 +348,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
     @Override protected void start0() throws IgniteCheckedException {
         snapshotMgr = cctx.snapshot();
 
-        initDataBase();
+        assert !cctx.kernalContext().state().active() : "Cluster with persistent must starting as inactive.";
 
         if (!cctx.kernalContext().clientNode()) {
             IgnitePageStoreManager store = cctx.pageStore();
@@ -447,56 +448,102 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
 
     /** {@inheritDoc} */
     @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
-        if (!reconnect && !cctx.kernalContext().clientNode() && cctx.kernalContext().state().active()) {
-            Collection<String> cacheNames = new HashSet<>();
+        if (reconnect || cctx.kernalContext().clientNode() || !cctx.kernalContext().state().active())
+            return;
 
-            // TODO IGNITE-5075 group descriptors.
-            for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration()) {
-                if (CU.isSystemCache(ccfg.getName())) {
-                    storeMgr.initializeForCache(cctx.cache().cacheDescriptors().get(ccfg.getName()).groupDescriptor(), new StoredCacheData(ccfg));
+        if (persistenceEnabled() && cctx.kernalContext().state().active())
+            initDataBase();
 
-                    cacheNames.add(ccfg.getName());
-                }
-            }
+        GridCacheProcessor cachePrc = cctx.kernalContext().cache();
 
-            for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration())
-                if (!CU.isSystemCache(ccfg.getName())) {
-                    DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptors().get(ccfg.getName());
+        // Todo before join local node.
 
-                    if (cacheDesc != null)
-                        storeMgr.initializeForCache(cacheDesc.groupDescriptor(), new StoredCacheData(ccfg));
+        Collection<String> cacheNames = new HashSet<>();
 
-                    cacheNames.add(ccfg.getName());
-                }
+        // TODO IGNITE-5075 group descriptors.
+        for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration()) {
+            if (CU.isSystemCache(ccfg.getName())) {
+                storeMgr.initializeForCache(
+                    cctx.cache().cacheDescriptors().get(ccfg.getName()).groupDescriptor(), new StoredCacheData(ccfg));
 
-            for (StoredCacheData cacheData : cctx.pageStore().readCacheConfigurations().values()) {
-                if (!cacheNames.contains(cacheData.config().getName()))
-                    storeMgr.initializeForCache(cctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor(), cacheData);
+                cacheNames.add(ccfg.getName());
             }
+        }
+
+        for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration())
+            if (!CU.isSystemCache(ccfg.getName())) {
+                DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptors().get(ccfg.getName());
 
-            readCheckpointAndRestoreMemory();
+                if (cacheDesc != null)
+                    storeMgr.initializeForCache(cacheDesc.groupDescriptor(), new StoredCacheData(ccfg));
+
+                cacheNames.add(ccfg.getName());
+            }
+
+        for (StoredCacheData cacheData : cctx.pageStore().readCacheConfigurations().values()) {
+            if (!cacheNames.contains(cacheData.config().getName()))
+                storeMgr.initializeForCache(
+                    cctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor(), cacheData);
         }
+
+        readCheckpointAndRestoreMemory();
     }
 
+
     /** {@inheritDoc} */
     @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        super.onActivate(kctx);
+        snapshotMgr = cctx.snapshot();
+
+        if (cctx.localNode().isClient())
+            return;
+
+        initDataBase();
 
         if (log.isDebugEnabled())
             log.debug("Activate database manager [id=" + cctx.localNodeId() +
                 " topVer=" + cctx.discovery().topologyVersionEx() + " ]");
 
-        if (!cctx.kernalContext().clientNode()) {
-            readCheckpointAndRestoreMemory();
+        GridCacheProcessor cachePrc = cctx.kernalContext().cache();
 
-            if (log.isDebugEnabled())
-                log.debug("Restore state after activation [nodeId=" + cctx.localNodeId() + " ]");
+        // Todo join local info.
+
+        Collection<String> cacheNames = new HashSet<>();
+
+        // TODO IGNITE-5075 group descriptors.
+        for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration()) {
+            if (CU.isSystemCache(ccfg.getName())) {
+                storeMgr.initializeForCache(
+                    cctx.cache().cacheDescriptors().get(ccfg.getName()).groupDescriptor(), new StoredCacheData(ccfg));
+
+                cacheNames.add(ccfg.getName());
+            }
+        }
+
+        for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration())
+            if (!CU.isSystemCache(ccfg.getName())) {
+                DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptors().get(ccfg.getName());
+
+                if (cacheDesc != null)
+                    storeMgr.initializeForCache(cacheDesc.groupDescriptor(), new StoredCacheData(ccfg));
+
+                cacheNames.add(ccfg.getName());
+            }
+
+        for (StoredCacheData cacheData : cctx.pageStore().readCacheConfigurations().values()) {
+            if (!cacheNames.contains(cacheData.config().getName()))
+                storeMgr.initializeForCache(
+                    cctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor(), cacheData);
         }
+
+        readCheckpointAndRestoreMemory();
+
+        if (log.isDebugEnabled())
+            log.debug("Restore state after activation [nodeId=" + cctx.localNodeId() + " ]");
     }
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        super.onDeActivate(kctx);
+        stop0(true);
 
         if (log.isDebugEnabled())
             log.debug("DeActivate database manager [id=" + cctx.localNodeId() +
@@ -1926,6 +1973,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
 
                 Checkpoint chp = markCheckpointBegin(tracker);
 
+                if (chp.cpPages == null)
+                    return;
+
                 snapshotMgr.onCheckPointBegin();
 
                 boolean interrupted = true;
@@ -2967,8 +3017,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
                         if (content == null)
                             content = readContent();
 
-                        log.warning("Failed to acquire file lock (already locked by " + content
-                            + "), will try again in 1s: " + file.getAbsolutePath());
+                        log.warning("Failed to acquire file lock (local nodeId:" + ctx.localNodeId()
+                            + ", already locked by " + content + "), will try again in 1s: "
+                            + file.getAbsolutePath());
                     }
 
                     U.sleep(1000);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
index f91c47f..8c096f1 100755
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
+++ b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
@@ -204,16 +204,19 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
 
             assert old == null : "Non-null old store holder for cache: " + cacheData.config().getName();
         }
-
-        storeCacheData(grpDesc, cacheData);
     }
 
     /** {@inheritDoc} */
-    @Override public void storeCacheData(CacheGroupDescriptor grpDesc, StoredCacheData cacheData)
-        throws IgniteCheckedException {
+    @Override public void storeCacheData(
+        CacheGroupDescriptor grpDesc,
+        StoredCacheData cacheData
+    ) throws IgniteCheckedException {
+
         File cacheWorkDir = cacheWorkDirectory(grpDesc, cacheData.config());
         File file;
 
+        checkAndInitCacheWorkDir(cacheWorkDir);
+
         assert cacheWorkDir.exists() : "Work directory does not exist: " + cacheWorkDir;
 
         if (grpDesc.sharedGroup())
@@ -356,6 +359,34 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
 
         File cacheWorkDir = cacheWorkDirectory(grpDesc, ccfg);
 
+        boolean dirExisted = checkAndInitCacheWorkDir(cacheWorkDir);
+
+        File idxFile = new File(cacheWorkDir, INDEX_FILE_NAME);
+
+        if (dirExisted && !idxFile.exists())
+            grpsWithoutIdx.add(grpDesc.groupId());
+
+        FilePageStore idxStore = new FilePageStore(
+            PageMemory.FLAG_IDX,
+            idxFile,
+            cctx.kernalContext().config().getMemoryConfiguration());
+
+        FilePageStore[] partStores = new FilePageStore[grpDesc.config().getAffinity().partitions()];
+
+        for (int partId = 0; partId < partStores.length; partId++) {
+            FilePageStore partStore = new FilePageStore(
+                PageMemory.FLAG_DATA,
+                new File(cacheWorkDir, String.format(PART_FILE_TEMPLATE, partId)),
+                cctx.kernalContext().config().getMemoryConfiguration()
+            );
+
+            partStores[partId] = partStore;
+        }
+
+        return new CacheStoreHolder(idxStore, partStores);
+    }
+
+    private boolean checkAndInitCacheWorkDir(File cacheWorkDir) throws IgniteCheckedException {
         boolean dirExisted = false;
 
         if (!cacheWorkDir.exists()) {
@@ -389,7 +420,8 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
                     catch (IOException e) {
                         throw new IgniteCheckedException(e);
                     }
-                } else {
+                }
+                else {
                     U.warn(log, "Ignite node crashed during the snapshot restore process " +
                         "(there is a snapshot restore lock file left for cache). Will remove both the lock file and " +
                         "incomplete cache directory [cacheDir=" + cacheWorkDir.getAbsolutePath() + ']');
@@ -411,29 +443,7 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
                 dirExisted = true;
         }
 
-        File idxFile = new File(cacheWorkDir, INDEX_FILE_NAME);
-
-        if (dirExisted && !idxFile.exists())
-            grpsWithoutIdx.add(grpDesc.groupId());
-
-        FilePageStore idxStore = new FilePageStore(
-            PageMemory.FLAG_IDX,
-            idxFile,
-            cctx.kernalContext().config().getMemoryConfiguration());
-
-        FilePageStore[] partStores = new FilePageStore[grpDesc.config().getAffinity().partitions()];
-
-        for (int partId = 0; partId < partStores.length; partId++) {
-            FilePageStore partStore = new FilePageStore(
-                PageMemory.FLAG_DATA,
-                new File(cacheWorkDir, String.format(PART_FILE_TEMPLATE, partId)),
-                cctx.kernalContext().config().getMemoryConfiguration()
-            );
-
-            partStores[partId] = partStore;
-        }
-
-        return new CacheStoreHolder(idxStore, partStores);
+        return dirExisted;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bdbba0ee/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java
index 997eef5..144bbef 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.pagemem.PageIdUtils;


Mime
View raw message