diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 100ad281b211c..cb9ffa101e506 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -33,11 +33,12 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.closure.*; +import org.apache.ignite.internal.processors.cluster.*; import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; import org.apache.ignite.internal.processors.datastructures.*; -import org.apache.ignite.internal.processors.igfs.*; import org.apache.ignite.internal.processors.hadoop.*; +import org.apache.ignite.internal.processors.igfs.*; import org.apache.ignite.internal.processors.job.*; import org.apache.ignite.internal.processors.jobmetrics.*; import org.apache.ignite.internal.processors.offheap.*; @@ -508,4 +509,11 @@ public interface GridKernalContext extends Iterable { * @return Exception registry. */ public IgniteExceptionRegistry exceptionRegistry(); + + /** + * Gets Cluster processor. + * + * @return Cluster processor. + */ + public ClusterProcessor cluster(); } 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 395ad52c7f95c..756c16a0fbd9e 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 @@ -36,11 +36,12 @@ import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.closure.*; +import org.apache.ignite.internal.processors.cluster.*; import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; import org.apache.ignite.internal.processors.datastructures.*; -import org.apache.ignite.internal.processors.igfs.*; import org.apache.ignite.internal.processors.hadoop.*; +import org.apache.ignite.internal.processors.igfs.*; import org.apache.ignite.internal.processors.job.*; import org.apache.ignite.internal.processors.jobmetrics.*; import org.apache.ignite.internal.processors.offheap.*; @@ -243,6 +244,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable @GridToStringExclude private IgniteSpringProcessor spring; + /** */ + @GridToStringExclude + private ClusterProcessor cluster; + /** */ @GridToStringExclude private DataStructuresProcessor dataStructuresProc; @@ -461,6 +466,8 @@ else if (comp instanceof GridQueryProcessor) qryProc = (GridQueryProcessor)comp; else if (comp instanceof DataStructuresProcessor) dataStructuresProc = (DataStructuresProcessor)comp; + else if (comp instanceof ClusterProcessor) + cluster = (ClusterProcessor)comp; else assert (comp instanceof GridPluginComponent) : "Unknown manager class: " + comp.getClass(); @@ -853,6 +860,11 @@ protected Object readResolve() throws ObjectStreamException { return registry; } + /** {@inheritDoc} */ + @Override public ClusterProcessor cluster() { + return cluster; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridKernalContextImpl.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 9c92edd51f17a..f46d071b91c19 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.closure.*; +import org.apache.ignite.internal.processors.cluster.*; import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; import org.apache.ignite.internal.processors.datastructures.*; @@ -182,10 +183,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { @GridToStringExclude private boolean errOnStop; - /** Cluster. */ - @GridToStringExclude - private IgniteClusterImpl cluster; - /** Scheduler. */ @GridToStringExclude private IgniteScheduler scheduler; @@ -229,37 +226,37 @@ public IgniteKernal(@Nullable GridSpringResourceContext rsrcCtx) { /** {@inheritDoc} */ @Override public IgniteClusterEx cluster() { - return cluster; + return ctx.cluster().get(); } /** {@inheritDoc} */ @Override public ClusterNode localNode() { - return cluster.localNode(); + return ctx.cluster().get().localNode(); } /** {@inheritDoc} */ @Override public IgniteCompute compute() { - return cluster.compute(); + return ctx.cluster().get().compute(); } /** {@inheritDoc} */ @Override public IgniteMessaging message() { - return cluster.message(); + return ctx.cluster().get().message(); } /** {@inheritDoc} */ @Override public IgniteEvents events() { - return cluster.events(); + return ctx.cluster().get().events(); } /** {@inheritDoc} */ @Override public IgniteServices services() { - return cluster.services(); + return ctx.cluster().get().services(); } /** {@inheritDoc} */ @Override public ExecutorService executorService() { - return cluster.executorService(); + return ctx.cluster().get().executorService(); } /** {@inheritDoc} */ @@ -678,7 +675,7 @@ public void start(final IgniteConfiguration cfg, igfsExecSvc, restExecSvc); - cluster = new IgniteClusterImpl(ctx); + startProcessor(ctx, new ClusterProcessor(ctx), attrs); U.onGridStart(); @@ -1793,7 +1790,7 @@ else if (state == STARTING) // No more kernal calls from this point on. gw.setState(STOPPING); - cluster.clearNodeMap(); + ctx.cluster().get().clearNodeMap(); if (log.isDebugEnabled()) log.debug("Grid " + (gridName == null ? "" : '\'' + gridName + "' ") + "is stopping."); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java new file mode 100644 index 0000000000000..0ee00f1ec3e55 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cluster; + +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.cluster.*; +import org.apache.ignite.internal.processors.*; + +/** + * + */ +public class ClusterProcessor extends GridProcessorAdapter { + /** */ + private IgniteClusterImpl cluster; + + /** + * @param ctx Kernal context. + */ + public ClusterProcessor(GridKernalContext ctx) { + super(ctx); + + cluster = new IgniteClusterImpl(ctx); + } + + /** + * @return Cluster. + */ + public IgniteClusterImpl get() { + return cluster; + } +}