Search in sources :

Example 16 with DiscoCache

use of org.apache.ignite.internal.managers.discovery.DiscoCache in project ignite by apache.

the class CacheAffinitySharedManager method processClientCacheStartRequests.

/**
 * @param crd Coordinator flag.
 * @param msg Change request.
 * @param topVer Current topology version.
 * @param discoCache Discovery data cache.
 * @return Map of started caches (cache ID to near enabled flag).
 */
@Nullable
private Map<Integer, Boolean> processClientCacheStartRequests(boolean crd, ClientCacheChangeDummyDiscoveryMessage msg, AffinityTopologyVersion topVer, DiscoCache discoCache) {
    Map<String, DynamicCacheChangeRequest> startReqs = msg.startRequests();
    List<DynamicCacheDescriptor> startDescs = clientCachesToStart(msg.requestId(), startReqs);
    if (startDescs == null || startDescs.isEmpty()) {
        cctx.cache().completeClientCacheChangeFuture(msg.requestId(), null);
        return null;
    }
    Map<Integer, GridDhtAssignmentFetchFuture> fetchFuts = U.newHashMap(startDescs.size());
    Map<Integer, Boolean> startedInfos = U.newHashMap(startDescs.size());
    List<StartCacheInfo> startCacheInfos = startDescs.stream().map(desc -> {
        DynamicCacheChangeRequest changeReq = startReqs.get(desc.cacheName());
        startedInfos.put(desc.cacheId(), changeReq.nearCacheConfiguration() != null);
        return new StartCacheInfo(desc.cacheConfiguration(), desc, changeReq.nearCacheConfiguration(), topVer, changeReq.disabledAfterStart(), true);
    }).collect(Collectors.toList());
    Set<String> startedCaches = startCacheInfos.stream().map(info -> info.getCacheDescriptor().cacheName()).collect(Collectors.toSet());
    try {
        cctx.cache().prepareStartCaches(startCacheInfos);
    } catch (IgniteCheckedException e) {
        cctx.cache().closeCaches(startedCaches, false);
        cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
        return null;
    }
    Set<CacheGroupDescriptor> groupDescs = startDescs.stream().map(DynamicCacheDescriptor::groupDescriptor).collect(Collectors.toSet());
    for (CacheGroupDescriptor grpDesc : groupDescs) {
        try {
            CacheGroupContext grp = cctx.cache().cacheGroup(grpDesc.groupId());
            assert grp != null : grpDesc.groupId();
            assert !grp.affinityNode() || grp.isLocal() : grp.cacheOrGroupName();
            // Skip for local caches.
            if (grp.isLocal())
                continue;
            CacheGroupHolder grpHolder = grpHolders.get(grp.groupId());
            assert !crd || (grpHolder != null && grpHolder.affinity().idealAssignmentRaw() != null);
            if (grpHolder == null)
                grpHolder = getOrCreateGroupHolder(topVer, grpDesc);
            // If current node is not client and current node have no aff holder.
            if (grpHolder.nonAffNode() && !cctx.localNode().isClient()) {
                GridDhtPartitionsExchangeFuture excFut = context().exchange().lastFinishedFuture();
                grp.topology().updateTopologyVersion(excFut, discoCache, -1, false);
                // Exchange free cache creation, just replacing client topology with dht.
                // Topology should be initialized before the use.
                grp.topology().beforeExchange(excFut, true, false);
                grpHolder = new CacheGroupAffNodeHolder(grp, grpHolder.affinity());
                grpHolders.put(grp.groupId(), grpHolder);
                GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId());
                if (clientTop != null) {
                    grp.topology().update(grpHolder.affinity().lastVersion(), clientTop.partitionMap(true), clientTop.fullUpdateCounters(), Collections.<Integer>emptySet(), null, null, null, clientTop.lostPartitions());
                    excFut.validate(grp);
                }
                assert grpHolder.affinity().lastVersion().equals(grp.affinity().lastVersion());
            } else if (!crd && !fetchFuts.containsKey(grp.groupId())) {
                boolean topVerLessOrNotInitialized = !grp.topology().initialized() || grp.topology().readyTopologyVersion().compareTo(topVer) < 0;
                if (grp.affinity().lastVersion().compareTo(topVer) < 0 || topVerLessOrNotInitialized) {
                    GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture(cctx, grp.groupId(), topVer, discoCache);
                    fetchFut.init(true);
                    fetchFuts.put(grp.groupId(), fetchFut);
                }
            }
        } catch (IgniteCheckedException e) {
            cctx.cache().closeCaches(startedCaches, false);
            cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
            return null;
        }
    }
    for (GridDhtAssignmentFetchFuture fetchFut : fetchFuts.values()) {
        try {
            CacheGroupContext grp = cctx.cache().cacheGroup(fetchFut.groupId());
            assert grp != null;
            GridDhtAffinityAssignmentResponse res = fetchAffinity(topVer, null, discoCache, grp.affinity(), fetchFut);
            GridDhtPartitionFullMap partMap;
            if (res != null) {
                partMap = res.partitionMap();
                assert partMap != null : res;
            } else
                partMap = new GridDhtPartitionFullMap(cctx.localNodeId(), cctx.localNode().order(), 1);
            GridDhtPartitionsExchangeFuture exchFut = context().exchange().lastFinishedFuture();
            grp.topology().updateTopologyVersion(exchFut, discoCache, -1, false);
            GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId());
            Set<Integer> lostParts = clientTop == null ? null : clientTop.lostPartitions();
            grp.topology().update(topVer, partMap, null, Collections.emptySet(), null, null, null, lostParts);
            if (clientTop == null)
                grp.topology().detectLostPartitions(topVer, exchFut);
            exchFut.validate(grp);
        } catch (IgniteCheckedException e) {
            cctx.cache().closeCaches(startedCaches, false);
            cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
            return null;
        }
    }
    for (DynamicCacheDescriptor desc : startDescs) {
        if (desc.cacheConfiguration().getCacheMode() != LOCAL) {
            CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId());
            assert grp != null;
            grp.topology().onExchangeDone(null, grp.affinity().cachedAffinity(topVer), true);
        }
    }
    cctx.cache().initCacheProxies(topVer, null);
    startReqs.keySet().forEach(req -> cctx.cache().completeProxyInitialize(req));
    cctx.cache().completeClientCacheChangeFuture(msg.requestId(), null);
    return startedInfos;
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) Arrays(java.util.Arrays) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridPartitionStateMap(org.apache.ignite.internal.util.GridPartitionStateMap) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) GridLongList(org.apache.ignite.internal.util.GridLongList) AFFINITY_CALCULATION(org.apache.ignite.internal.processors.tracing.SpanType.AFFINITY_CALCULATION) Map(java.util.Map) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) CacheGroupAffinityMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CacheGroupAffinityMessage) GridDhtAssignmentFetchFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAssignmentFetchFuture) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) IgniteFuture(org.apache.ignite.lang.IgniteFuture) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) LOCAL(org.apache.ignite.cache.CacheMode.LOCAL) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) IgniteInClosureX(org.apache.ignite.internal.util.lang.IgniteInClosureX) OWNING(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) NONE(org.apache.ignite.cache.CacheRebalanceMode.NONE) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) CU(org.apache.ignite.internal.util.typedef.internal.CU) Optional(java.util.Optional) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridDhtAffinityAssignmentResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse) Span(org.apache.ignite.internal.processors.tracing.Span) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) ClusterNode(org.apache.ignite.cluster.ClusterNode) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteClosure(org.apache.ignite.lang.IgniteClosure) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) CacheException(javax.cache.CacheException) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) Iterator(java.util.Iterator) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridDhtAssignmentFetchFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAssignmentFetchFuture) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) GridDhtAffinityAssignmentResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with DiscoCache

use of org.apache.ignite.internal.managers.discovery.DiscoCache in project ignite by apache.

the class GridClusterStateProcessor method autoAdjustInMemoryClusterState.

/**
 * Update baseline locally if cluster is not persistent and baseline autoadjustment is enabled with zero timeout.
 *
 * @param nodeId Id of the node that initiated the operation (joined/left/failed).
 * @param topSnapshot Topology snapshot from the discovery message.
 * @param discoCache Discovery cache from the discovery manager.
 * @param topVer Topology version.
 * @param minorTopVer Minor topology version.
 * @return {@code true} if baseline was changed and discovery cache recalculation is required.
 */
public boolean autoAdjustInMemoryClusterState(UUID nodeId, Collection<ClusterNode> topSnapshot, DiscoCache discoCache, long topVer, int minorTopVer) {
    IgniteClusterImpl cluster = ctx.cluster().get();
    DiscoveryDataClusterState oldState = globalState;
    boolean isInMemoryCluster = CU.isInMemoryCluster(ctx.discovery().allNodes(), ctx.marshallerContext().jdkMarshaller(), U.resolveClassLoader(ctx.config()));
    boolean autoAdjustBaseline = isInMemoryCluster && oldState.state().active() && !oldState.transition() && cluster.isBaselineAutoAdjustEnabled() && cluster.baselineAutoAdjustTimeout() == 0L;
    if (autoAdjustBaseline) {
        BaselineTopology oldBlt = oldState.baselineTopology();
        Collection<ClusterNode> bltNodes = topSnapshot.stream().filter(n -> !n.isClient() && !n.isDaemon()).collect(Collectors.toList());
        if (!bltNodes.isEmpty()) {
            int newBltId = oldBlt == null ? 0 : oldBlt.id();
            BaselineTopology newBlt = BaselineTopology.build(bltNodes, newBltId);
            ChangeGlobalStateMessage changeGlobalStateMsg = new ChangeGlobalStateMessage(nodeId, nodeId, null, oldState.state(), true, newBlt, true, System.currentTimeMillis());
            AffinityTopologyVersion ver = new AffinityTopologyVersion(topVer, minorTopVer);
            onStateChangeMessage(ver, changeGlobalStateMsg, discoCache);
            ChangeGlobalStateFinishMessage finishMsg = new ChangeGlobalStateFinishMessage(nodeId, oldState.state(), true);
            onStateFinishMessage(finishMsg);
            globalState.localBaselineAutoAdjustment(true);
            return true;
        }
    }
    return false;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) BaselineConfigurationChangedEvent(org.apache.ignite.events.BaselineConfigurationChangedEvent) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) DistributedBaselineConfiguration(org.apache.ignite.internal.cluster.DistributedBaselineConfiguration) ReadOnlyMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage) Map(java.util.Map) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) BaselineNodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeAttributeViewWalker) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) GridCacheUtils.extractDataStorage(org.apache.ignite.internal.processors.cache.GridCacheUtils.extractDataStorage) Serializable(java.io.Serializable) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BaselineNodeAttributeView(org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView) BaselineAutoAdjustStatus(org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineAutoAdjustStatus) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) CLUSTER_READ_ONLY_MODE(org.apache.ignite.internal.IgniteFeatures.CLUSTER_READ_ONLY_MODE) IgniteCompute(org.apache.ignite.IgniteCompute) ClusterStateChangeStartedEvent(org.apache.ignite.events.ClusterStateChangeStartedEvent) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) DFLT_STATE_ON_START(org.apache.ignite.configuration.IgniteConfiguration.DFLT_STATE_ON_START) IgniteLogger(org.apache.ignite.IgniteLogger) ClusterGroupAdapter(org.apache.ignite.internal.cluster.ClusterGroupAdapter) IgniteDiscoverySpi(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) ReadWriteMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage) S(org.apache.ignite.internal.util.typedef.internal.S) C1(org.apache.ignite.internal.util.typedef.C1) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED(org.apache.ignite.events.EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED) A(org.apache.ignite.internal.util.typedef.internal.A) Field(java.lang.reflect.Field) BaselineNode(org.apache.ignite.cluster.BaselineNode) STATE_PROC(org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.STATE_PROC) IgniteClusterImpl(org.apache.ignite.internal.cluster.IgniteClusterImpl) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryDataBag(org.apache.ignite.spi.discovery.DiscoveryDataBag) StateChangeRequest(org.apache.ignite.internal.processors.cache.StateChangeRequest) StoredCacheData(org.apache.ignite.internal.processors.cache.StoredCacheData) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) GridChangeGlobalStateMessageResponse(org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse) SAFE_CLUSTER_DEACTIVATION(org.apache.ignite.internal.IgniteFeatures.SAFE_CLUSTER_DEACTIVATION) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) IgniteFuture(org.apache.ignite.lang.IgniteFuture) DistributePropertyListener(org.apache.ignite.internal.processors.configuration.distributed.DistributePropertyListener) EventType(org.apache.ignite.events.EventType) IgniteFeatures.allNodesSupports(org.apache.ignite.internal.IgniteFeatures.allNodesSupports) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ExchangeActions(org.apache.ignite.internal.processors.cache.ExchangeActions) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) CU(org.apache.ignite.internal.util.typedef.internal.CU) BaselineTopologyUpdater(org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineTopologyUpdater) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) BaselineNodeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeViewWalker) EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED(org.apache.ignite.events.EventType.EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED) HashMap(java.util.HashMap) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) IgniteNodeValidationResult(org.apache.ignite.spi.IgniteNodeValidationResult) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteClusterImpl(org.apache.ignite.internal.cluster.IgniteClusterImpl)

Example 18 with DiscoCache

use of org.apache.ignite.internal.managers.discovery.DiscoCache in project ignite by apache.

the class ClusterProcessor method processMetricsUpdateMessage.

/**
 * @param sndNodeId Sender node ID.
 * @param msg Message.
 */
private void processMetricsUpdateMessage(UUID sndNodeId, ClusterMetricsUpdateMessage msg) {
    byte[] nodeMetrics = msg.nodeMetrics();
    if (nodeMetrics != null) {
        assert msg.allNodesMetrics() == null;
        allNodesMetrics.put(sndNodeId, nodeMetrics);
        updateNodeMetrics(ctx.discovery().discoCache(), sndNodeId, nodeMetrics);
    } else {
        Map<UUID, byte[]> allNodesMetrics = msg.allNodesMetrics();
        assert allNodesMetrics != null;
        DiscoCache discoCache = ctx.discovery().discoCache();
        for (Map.Entry<UUID, byte[]> e : allNodesMetrics.entrySet()) {
            if (!ctx.localNodeId().equals(e.getKey()))
                updateNodeMetrics(discoCache, e.getKey(), e.getValue());
        }
    }
}
Also used : DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) UUID(java.util.UUID) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

DiscoCache (org.apache.ignite.internal.managers.discovery.DiscoCache)18 ClusterNode (org.apache.ignite.cluster.ClusterNode)12 UUID (java.util.UUID)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)11 HashMap (java.util.HashMap)9 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)9 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)9 ArrayList (java.util.ArrayList)8 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)8 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)8 Map (java.util.Map)7 IgniteException (org.apache.ignite.IgniteException)7 Collection (java.util.Collection)6 Collections (java.util.Collections)6 List (java.util.List)6 Set (java.util.Set)6 GridFinishedFuture (org.apache.ignite.internal.util.future.GridFinishedFuture)6 F (org.apache.ignite.internal.util.typedef.F)6 CU (org.apache.ignite.internal.util.typedef.internal.CU)6 U (org.apache.ignite.internal.util.typedef.internal.U)6