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());
}
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;
}
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();
}
}
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);
}
}));
}
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);
}
}
}
Aggregations