Search in sources :

Example 81 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class IgniteAuthenticationProcessor method authenticate.

/**
 * {@inheritDoc}
 */
@Override
public SecurityContext authenticate(AuthenticationContext authCtx) throws IgniteCheckedException {
    SecurityCredentials creds = authCtx.credentials();
    String login = (String) creds.getLogin();
    if (F.isEmpty(login))
        throw new IgniteAccessControlException("The user name or password is incorrect [userName=" + login + ']');
    String passwd = (String) creds.getPassword();
    UUID subjId;
    if (ctx.clientNode()) {
        if (ctx.discovery().aliveServerNodes().isEmpty()) {
            throw new IgniteAccessControlException("No alive server node was found to which the authentication" + " operation could be delegated. It is possible that the client node has been started with the" + " \"forceServerMode\" flag enabled and no server node had been started yet.");
        }
        AuthenticateFuture fut;
        do {
            synchronized (mux) {
                ClusterNode rndNode = U.randomServerNode(ctx);
                fut = new AuthenticateFuture(rndNode.id());
                UserAuthenticateRequestMessage msg = new UserAuthenticateRequestMessage(login, passwd);
                authFuts.put(msg.id(), fut);
                ctx.io().sendToGridTopic(rndNode, GridTopic.TOPIC_AUTH, msg, GridIoPolicy.SYSTEM_POOL);
            }
            fut.get();
        } while (fut.retry());
        subjId = toSubjectId(login);
    } else
        subjId = authenticateOnServer(login, passwd);
    return new SecurityContextImpl(subjId, login, authCtx.subjectType(), authCtx.address());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) SecurityCredentials(org.apache.ignite.plugin.security.SecurityCredentials) UUID(java.util.UUID)

Example 82 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class CacheGroupMetricsImpl method getAffinityPartitionsAssignmentMap.

/**
 */
public Map<Integer, List<String>> getAffinityPartitionsAssignmentMap() {
    if (ctx.affinity().lastVersion().topologyVersion() < 0)
        return Collections.emptyMap();
    AffinityAssignment assignment = ctx.affinity().cachedAffinity(AffinityTopologyVersion.NONE);
    int part = 0;
    Map<Integer, List<String>> assignmentMap = new LinkedHashMap<>();
    for (List<ClusterNode> partAssignment : assignment.assignment()) {
        List<String> partNodeIds = new ArrayList<>(partAssignment.size());
        for (ClusterNode node : partAssignment) partNodeIds.add(node.id().toString());
        assignmentMap.put(part, partNodeIds);
        part++;
    }
    return assignmentMap;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap)

Example 83 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method onAllServersLeft.

/**
 */
private void onAllServersLeft() {
    assert cctx.kernalContext().clientNode() : cctx.localNode();
    List<ClusterNode> empty = Collections.emptyList();
    for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
        List<List<ClusterNode>> affAssignment = new ArrayList<>(grp.affinity().partitions());
        for (int i = 0; i < grp.affinity().partitions(); i++) affAssignment.add(empty);
        grp.affinity().idealAssignment(initialVersion(), affAssignment);
        grp.affinity().initialize(initialVersion(), affAssignment);
        cctx.exchange().exchangerUpdateHeartbeat();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext)

Example 84 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method waitAndReplyToNode.

/**
 * @param nodeId Node ID.
 * @param msg Client's message.
 */
public void waitAndReplyToNode(final UUID nodeId, final GridDhtPartitionsSingleMessage msg) {
    if (log.isDebugEnabled())
        log.debug("Single message will be handled on completion of exchange future: " + this);
    listen(failureHandlerWrapper(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {

        @Override
        public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
            if (cctx.kernalContext().isStopping())
                return;
            // Thus, there is no need to create and send GridDhtPartitionsFullMessage.
            if (cacheChangeFailureMsgSent)
                return;
            FinishState finishState0;
            synchronized (mux) {
                finishState0 = finishState;
            }
            if (finishState0 == null) {
                assert (firstDiscoEvt.type() == EVT_NODE_JOINED && firstDiscoEvt.eventNode().isClient()) : GridDhtPartitionsExchangeFuture.this;
                ClusterNode node = cctx.node(nodeId);
                if (node == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("No node found for nodeId: " + nodeId + ", handling of single message will be stopped: " + msg);
                    }
                    return;
                }
                GridDhtPartitionsFullMessage msg = createPartitionsMessage(true, node.version().compareToIgnoreTimestamp(PARTIAL_COUNTERS_MAP_SINCE) >= 0);
                msg.rebalanced(rebalanced());
                finishState0 = new FinishState(cctx.localNodeId(), initialVersion(), msg);
            }
            sendAllPartitionsToNode(finishState0, msg, nodeId);
        }
    }));
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CI1(org.apache.ignite.internal.util.typedef.CI1) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Example 85 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class GridDhtPartitionsFullMessage method merge.

/**
 * Merges (replaces with newer) partitions map from given {@code other} full message.
 *
 * @param other Other full message.
 */
public void merge(GridDhtPartitionsFullMessage other, GridDiscoveryManager discovery) {
    assert other.exchangeId() == null && exchangeId() == null : "Both current and merge full message must have exchangeId == null" + other.exchangeId() + "," + exchangeId();
    for (Map.Entry<Integer, GridDhtPartitionFullMap> groupAndMap : other.partitions().entrySet()) {
        int grpId = groupAndMap.getKey();
        GridDhtPartitionFullMap updMap = groupAndMap.getValue();
        GridDhtPartitionFullMap currMap = partitions().get(grpId);
        if (currMap == null)
            partitions().put(grpId, updMap);
        else {
            ClusterNode currentMapSentBy = discovery.node(currMap.nodeId());
            ClusterNode newMapSentBy = discovery.node(updMap.nodeId());
            if (newMapSentBy == null)
                continue;
            if (currentMapSentBy == null || newMapSentBy.order() > currentMapSentBy.order() || updMap.compareTo(currMap) >= 0)
                partitions().put(grpId, updMap);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDirectMap(org.apache.ignite.internal.GridDirectMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ClusterNode (org.apache.ignite.cluster.ClusterNode)1104 UUID (java.util.UUID)281 ArrayList (java.util.ArrayList)280 Test (org.junit.Test)276 Ignite (org.apache.ignite.Ignite)239 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)239 HashMap (java.util.HashMap)184 Map (java.util.Map)182 List (java.util.List)165 IgniteException (org.apache.ignite.IgniteException)147 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)147 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)143 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)126 Collection (java.util.Collection)113 Message (org.apache.ignite.plugin.extensions.communication.Message)106 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)87 HashSet (java.util.HashSet)85 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)82 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)81 IgniteEx (org.apache.ignite.internal.IgniteEx)81