Skip to content

Commit

Permalink
sprint-2 fix for ignite-301
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakov Zhdanov committed Mar 2, 2015
1 parent c9f46c1 commit ea6a1c0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 15 deletions.
Expand Up @@ -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.*;
Expand Down Expand Up @@ -508,4 +509,11 @@ public interface GridKernalContext extends Iterable<GridComponent> {
* @return Exception registry.
*/
public IgniteExceptionRegistry exceptionRegistry();

/**
* Gets Cluster processor.
*
* @return Cluster processor.
*/
public ClusterProcessor cluster();
}
Expand Up @@ -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.*;
Expand Down Expand Up @@ -243,6 +244,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
@GridToStringExclude
private IgniteSpringProcessor spring;

/** */
@GridToStringExclude
private ClusterProcessor cluster;

/** */
@GridToStringExclude
private DataStructuresProcessor dataStructuresProc;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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} */
Expand Down Expand Up @@ -678,7 +675,7 @@ public void start(final IgniteConfiguration cfg,
igfsExecSvc,
restExecSvc);

cluster = new IgniteClusterImpl(ctx);
startProcessor(ctx, new ClusterProcessor(ctx), attrs);

U.onGridStart();

Expand Down Expand Up @@ -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.");
Expand Down
@@ -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;
}
}

0 comments on commit ea6a1c0

Please sign in to comment.