Repository: ignite Updated Branches: refs/heads/ignite-324 [created] cc1ba72d5
ignite-324 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cc1ba72d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cc1ba72d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cc1ba72d Branch: refs/heads/ignite-324 Commit: cc1ba72d5734424a31218856e01ca8d247000b23 Parents: bcaa0a8 Author: sboikov <[email protected]> Authored: Fri Feb 19 17:01:05 2016 +0300 Committer: sboikov <[email protected]> Committed: Fri Feb 19 17:01:05 2016 +0300 ---------------------------------------------------------------------- .../processors/cache/CacheTopologyManager.java | 49 ++++++++++++++++++++ .../cache/GridCacheSharedContext.java | 17 ++++++- 2 files changed, 65 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1ba72d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheTopologyManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheTopologyManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheTopologyManager.java new file mode 100644 index 0000000..9c4382e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheTopologyManager.java @@ -0,0 +1,49 @@ +/* + * 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.cache; + +import java.util.List; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2; + +/** + * + */ +public class CacheTopologyManager<K, V> extends GridCacheSharedManagerAdapter<K, V> { + /** + * @param affAssignment Affinity assignment. + * @param partMap Partition map. + * @return {@code True} if partition primary nodes own partitions. + */ + public boolean primaryOwnPartitions(List<List<ClusterNode>> affAssignment, GridDhtPartitionFullMap partMap) { + for (int i = 0; i < affAssignment.size(); i++) { + ClusterNode primary = affAssignment.get(i).get(0); + + GridDhtPartitionMap2 stateMap = partMap.get(primary.id()); + + GridDhtPartitionState state = stateMap.get(i); + + if (state != GridDhtPartitionState.OWNING) + return false; + } + + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1ba72d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java index 2221d3b..c9a769f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java @@ -85,6 +85,9 @@ public class GridCacheSharedContext<K, V> { /** Deployment manager. */ private GridCacheDeploymentManager<K, V> depMgr; + /** */ + private CacheTopologyManager topMgr; + /** Cache contexts map. */ private ConcurrentMap<Integer, GridCacheContext<K, V>> ctxMap; @@ -101,6 +104,7 @@ public class GridCacheSharedContext<K, V> { * @param mvccMgr MVCC manager. * @param depMgr Deployment manager. * @param exchMgr Exchange manager. + * @param topMgr Topology manager. * @param ioMgr IO manager. * @param jtaMgr JTA manager. * @param storeSesLsnrs Store session listeners. @@ -112,13 +116,14 @@ public class GridCacheSharedContext<K, V> { GridCacheMvccManager mvccMgr, GridCacheDeploymentManager<K, V> depMgr, GridCachePartitionExchangeManager<K, V> exchMgr, + CacheTopologyManager<K, V> topMgr, GridCacheIoManager ioMgr, CacheJtaManagerAdapter jtaMgr, Collection<CacheStoreSessionListener> storeSesLsnrs ) { this.kernalCtx = kernalCtx; - setManagers(mgrs, txMgr, jtaMgr, verMgr, mvccMgr, depMgr, exchMgr, ioMgr); + setManagers(mgrs, txMgr, jtaMgr, verMgr, mvccMgr, depMgr, exchMgr, topMgr, ioMgr); this.storeSesLsnrs = storeSesLsnrs; @@ -162,6 +167,7 @@ public class GridCacheSharedContext<K, V> { mvccMgr, new GridCacheDeploymentManager<K, V>(), new GridCachePartitionExchangeManager<K, V>(), + topMgr, ioMgr); this.mgrs = mgrs; @@ -200,6 +206,7 @@ public class GridCacheSharedContext<K, V> { GridCacheMvccManager mvccMgr, GridCacheDeploymentManager<K, V> depMgr, GridCachePartitionExchangeManager<K, V> exchMgr, + CacheTopologyManager topMgr, GridCacheIoManager ioMgr) { this.mvccMgr = add(mgrs, mvccMgr); this.verMgr = add(mgrs, verMgr); @@ -207,6 +214,7 @@ public class GridCacheSharedContext<K, V> { this.jtaMgr = add(mgrs, jtaMgr); this.depMgr = add(mgrs, depMgr); this.exchMgr = add(mgrs, exchMgr); + this.topMgr = add(mgrs, topMgr); this.ioMgr = add(mgrs, ioMgr); } @@ -366,6 +374,13 @@ public class GridCacheSharedContext<K, V> { } /** + * @return Topology manager. + */ + public CacheTopologyManager topology() { + return topMgr; + } + + /** * @return Lock order manager. */ public GridCacheVersionManager versions() {
