Search in sources :

Example 1 with SYSTEM_POOL

use of org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method sendAllPartitions.

/**
 * @param fullMsg Message to send.
 * @param nodes Target Nodes.
 * @param mergedJoinExchMsgs Messages received from merged 'join node' exchanges.
 * @param affinityForJoinedNodes Affinity if was requested by some nodes.
 */
private void sendAllPartitions(GridDhtPartitionsFullMessage fullMsg, Collection<ClusterNode> nodes, Map<UUID, GridDhtPartitionsSingleMessage> mergedJoinExchMsgs, Map<Integer, CacheGroupAffinityMessage> affinityForJoinedNodes) {
    assert !nodes.contains(cctx.localNode());
    if (log.isTraceEnabled()) {
        log.trace("Sending full partition map [nodeIds=" + F.viewReadOnly(nodes, F.node2id()) + ", exchId=" + exchId + ", msg=" + fullMsg + ']');
    }
    // Find any single message with affinity request. This request exists only for newly joined nodes.
    Optional<GridDhtPartitionsSingleMessage> singleMsgWithAffinityReq = nodes.stream().flatMap(node -> Optional.ofNullable(msgs.get(node.id())).filter(singleMsg -> singleMsg.cacheGroupsAffinityRequest() != null).map(Stream::of).orElse(Stream.empty())).findAny();
    // Prepare full message for newly joined nodes with affinity request.
    final GridDhtPartitionsFullMessage fullMsgWithAffinity = singleMsgWithAffinityReq.filter(singleMessage -> affinityForJoinedNodes != null).map(singleMessage -> fullMsg.copy().joinedNodeAffinity(affinityForJoinedNodes)).orElse(null);
    // Prepare and send full messages for given nodes.
    nodes.stream().map(node -> {
        // No joined nodes, just send a regular full message.
        if (fullMsgWithAffinity == null)
            return new T2<>(node, fullMsg);
        return new T2<>(node, // If single message contains affinity request, use special full message for such single messages.
        Optional.ofNullable(msgs.get(node.id())).filter(singleMsg -> singleMsg.cacheGroupsAffinityRequest() != null).map(singleMsg -> fullMsgWithAffinity).orElse(fullMsg));
    }).map(nodeAndMsg -> {
        ClusterNode node = nodeAndMsg.get1();
        GridDhtPartitionsFullMessage fullMsgToSend = nodeAndMsg.get2();
        // If exchange has merged, use merged version of exchange id.
        GridDhtPartitionExchangeId sndExchId = mergedJoinExchMsgs != null ? Optional.ofNullable(mergedJoinExchMsgs.get(node.id())).map(GridDhtPartitionsAbstractMessage::exchangeId).orElse(exchangeId()) : exchangeId();
        if (sndExchId != null && !sndExchId.equals(exchangeId())) {
            GridDhtPartitionsFullMessage fullMsgWithUpdatedExchangeId = fullMsgToSend.copy();
            fullMsgWithUpdatedExchangeId.exchangeId(sndExchId);
            return new T2<>(node, fullMsgWithUpdatedExchangeId);
        }
        return new T2<>(node, fullMsgToSend);
    }).forEach(nodeAndMsg -> {
        ClusterNode node = nodeAndMsg.get1();
        GridDhtPartitionsFullMessage fullMsgToSend = nodeAndMsg.get2();
        try {
            cctx.io().send(node, fullMsgToSend, SYSTEM_POOL);
        } catch (ClusterTopologyCheckedException e) {
            if (log.isDebugEnabled())
                log.debug("Failed to send partitions, node failed: " + node);
        } catch (IgniteCheckedException e) {
            U.error(log, "Failed to send partitions [node=" + node + ']', e);
        }
    });
}
Also used : GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) NoopSpan(org.apache.ignite.internal.processors.tracing.NoopSpan) Map(java.util.Map) GridIoPolicy(org.apache.ignite.internal.managers.communication.GridIoPolicy) ExchangeContext(org.apache.ignite.internal.processors.cache.ExchangeContext) BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) Latch(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.latch.Latch) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD) CountDownLatch(java.util.concurrent.CountDownLatch) SnapshotDiscoveryMessage(org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotDiscoveryMessage) EternalExpiryPolicy(javax.cache.expiry.EternalExpiryPolicy) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT) SecurityContext(org.apache.ignite.internal.processors.security.SecurityContext) ExchangeRecord(org.apache.ignite.internal.pagemem.wal.record.ExchangeRecord) SecurityUtils.remoteSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.remoteSecurityContext) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteLogger(org.apache.ignite.IgniteLogger) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) LinkedHashMap(java.util.LinkedHashMap) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteDiagnosticAware(org.apache.ignite.internal.IgniteDiagnosticAware) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) Stream.concat(java.util.stream.Stream.concat) LinkedHashSet(java.util.LinkedHashSet) DynamicCacheChangeFailureMessage(org.apache.ignite.internal.processors.cache.DynamicCacheChangeFailureMessage) IOException(java.io.IOException) T2(org.apache.ignite.internal.util.typedef.T2) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) Lock(java.util.concurrent.locks.Lock) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) DatabaseLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) ATTR_DYNAMIC_CACHE_START_ROLLBACK_SUPPORTED(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DYNAMIC_CACHE_START_ROLLBACK_SUPPORTED) CacheMode(org.apache.ignite.cache.CacheMode) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) DynamicCacheChangeRequest(org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest) ExchangeDiscoveryEvents.serverLeftEvent(org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents.serverLeftEvent) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) IgniteSystemProperties.getBoolean(org.apache.ignite.IgniteSystemProperties.getBoolean) TimeBag(org.apache.ignite.internal.util.TimeBag) StateChangeRequest(org.apache.ignite.internal.processors.cache.StateChangeRequest) GridDhtPartitionsStateValidator(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionsStateValidator) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) X(org.apache.ignite.internal.util.typedef.X) GridPlainCallable(org.apache.ignite.internal.util.lang.GridPlainCallable) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) FailureType(org.apache.ignite.failure.FailureType) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) SpanTags(org.apache.ignite.internal.processors.tracing.SpanTags) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IgniteSnapshotManager.isSnapshotOperation(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.isSnapshotOperation) NavigableSet(java.util.NavigableSet) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IgniteUtils.doInParallelUninterruptibly(org.apache.ignite.internal.util.IgniteUtils.doInParallelUninterruptibly) IgniteSystemProperties.getLong(org.apache.ignite.IgniteSystemProperties.getLong) 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) IgniteTxKey(org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey) CU(org.apache.ignite.internal.util.typedef.internal.CU) IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT_LIMIT(org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT_LIMIT) Optional(java.util.Optional) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) ExchangeDiscoveryEvents(org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) Span(org.apache.ignite.internal.processors.tracing.Span) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) HashMap(java.util.HashMap) WalStateAbstractMessage(org.apache.ignite.internal.processors.cache.WalStateAbstractMessage) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) FailureContext(org.apache.ignite.failure.FailureContext) IgniteUtils.doInParallel(org.apache.ignite.internal.util.IgniteUtils.doInParallel) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) CachePartitionExchangeWorkerTask(org.apache.ignite.internal.processors.cache.CachePartitionExchangeWorkerTask) GridDhtTopologyFutureAdapter(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) Collections.emptySet(java.util.Collections.emptySet) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) ExchangeDiscoveryEvents.serverJoinEvent(org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents.serverJoinEvent) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) PARTIAL_COUNTERS_MAP_SINCE(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap.PARTIAL_COUNTERS_MAP_SINCE) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) TimeUnit(java.util.concurrent.TimeUnit) ChangeGlobalStateMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) Collections(java.util.Collections) GridCacheUtils(org.apache.ignite.internal.processors.cache.GridCacheUtils) CacheAffinityChangeMessage(org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) T2(org.apache.ignite.internal.util.typedef.T2) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.emptySet (java.util.Collections.emptySet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 NavigableSet (java.util.NavigableSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1