use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class CacheAffinitySharedManager method onChangeAffinityMessage.
/**
* Called on exchange initiated by {@link CacheAffinityChangeMessage} which sent after rebalance finished.
*
* @param exchFut Exchange future.
* @param crd Coordinator flag.
* @param msg Message.
* @throws IgniteCheckedException If failed.
*/
public void onChangeAffinityMessage(final GridDhtPartitionsExchangeFuture exchFut, boolean crd, final CacheAffinityChangeMessage msg) throws IgniteCheckedException {
assert affCalcVer != null || cctx.kernalContext().clientNode();
assert msg.topologyVersion() != null && msg.exchangeId() == null : msg;
assert affCalcVer == null || affCalcVer.equals(msg.topologyVersion());
final AffinityTopologyVersion topVer = exchFut.topologyVersion();
if (log.isDebugEnabled()) {
log.debug("Process affinity change message [exchVer=" + exchFut.topologyVersion() + ", affCalcVer=" + affCalcVer + ", msgVer=" + msg.topologyVersion() + ']');
}
final Map<Integer, Map<Integer, List<UUID>>> affChange = msg.assignmentChange();
assert !F.isEmpty(affChange) : msg;
final Map<Integer, IgniteUuid> deploymentIds = msg.cacheDeploymentIds();
final Map<Object, List<List<ClusterNode>>> affCache = new HashMap<>();
forAllCaches(crd, new IgniteInClosureX<GridAffinityAssignmentCache>() {
@Override
public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException {
AffinityTopologyVersion affTopVer = aff.lastVersion();
assert affTopVer.topologyVersion() > 0 : affTopVer;
DynamicCacheDescriptor desc = registeredCaches.get(aff.cacheId());
assert desc != null : aff.cacheName();
IgniteUuid deploymentId = desc.deploymentId();
if (!deploymentId.equals(deploymentIds.get(aff.cacheId()))) {
aff.clientEventTopologyChange(exchFut.discoveryEvent(), topVer);
return;
}
Map<Integer, List<UUID>> change = affChange.get(aff.cacheId());
if (change != null) {
assert !change.isEmpty() : msg;
List<List<ClusterNode>> curAff = aff.assignments(affTopVer);
List<List<ClusterNode>> assignment = new ArrayList<>(curAff);
for (Map.Entry<Integer, List<UUID>> e : change.entrySet()) {
Integer part = e.getKey();
List<ClusterNode> nodes = toNodes(topVer, e.getValue());
assert !nodes.equals(assignment.get(part)) : "Assignment did not change " + "[cache=" + aff.cacheName() + ", part=" + part + ", cur=" + F.nodeIds(assignment.get(part)) + ", new=" + F.nodeIds(nodes) + ", exchVer=" + exchFut.topologyVersion() + ", msgVer=" + msg.topologyVersion() + ']';
assignment.set(part, nodes);
}
aff.initialize(topVer, cachedAssignment(aff, assignment, affCache));
} else
aff.clientEventTopologyChange(exchFut.discoveryEvent(), topVer);
}
});
synchronized (mux) {
if (affCalcVer == null)
affCalcVer = msg.topologyVersion();
}
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class GridCacheDeploymentManager method addGlobalParticipants.
/**
* @param sndNodeId Sender node ID.
* @param sndLdrId Sender loader ID.
* @param participants Participants.
* @param locDepOwner {@code True} if local deployment owner.
* @return Added participants.
*/
@Nullable
private Map<UUID, IgniteUuid> addGlobalParticipants(UUID sndNodeId, IgniteUuid sndLdrId, Map<UUID, IgniteUuid> participants, boolean locDepOwner) {
Map<UUID, IgniteUuid> added = null;
if (participants != null) {
for (Map.Entry<UUID, IgniteUuid> entry : participants.entrySet()) {
UUID nodeId = entry.getKey();
IgniteUuid ldrVer = entry.getValue();
if (!ldrVer.equals(allParticipants.get(nodeId))) {
allParticipants.put(nodeId, ldrVer);
if (added == null)
added = IgniteUtils.newHashMap(participants.size());
added.put(nodeId, ldrVer);
}
}
}
if (locDepOwner) {
assert sndNodeId != null;
assert sndLdrId != null;
if (!sndLdrId.equals(allParticipants.get(sndNodeId))) {
allParticipants.put(sndNodeId, sndLdrId);
if (added == null)
added = U.newHashMap(1);
added.put(sndNodeId, sndLdrId);
}
}
return added;
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class GridCacheDeploymentManager method addDeploymentContext.
/**
* Adds deployment info to deployment contexts queue.
*
* @param info Info to add.
*/
public void addDeploymentContext(GridDeploymentInfo info) {
IgniteUuid ldrId = info.classLoaderId();
while (true) {
CachedDeploymentInfo<K, V> depInfo = deps.get(ldrId);
if (depInfo == null) {
depInfo = new CachedDeploymentInfo<>(ldrId.globalId(), ldrId, info.userVersion(), info.deployMode(), info.participants());
CachedDeploymentInfo<K, V> old = deps.putIfAbsent(ldrId, depInfo);
if (old != null)
depInfo = old;
else
break;
}
Map<UUID, IgniteUuid> participants = info.participants();
if (participants != null) {
if (!depInfo.addParticipants(participants, cctx)) {
deps.remove(ldrId, depInfo);
continue;
}
}
break;
}
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class CacheDataStructuresManager method onReconnected.
/**
* @param clusterRestarted Cluster restarted flag.
* @throws IgniteCheckedException If failed.
*/
public void onReconnected(boolean clusterRestarted) throws IgniteCheckedException {
for (Map.Entry<IgniteUuid, GridCacheSetProxy> e : setsMap.entrySet()) {
GridCacheSetProxy set = e.getValue();
if (clusterRestarted) {
set.blockOnRemove();
setsMap.remove(e.getKey(), set);
} else
set.needCheckNotRemoved();
}
for (Map.Entry<IgniteUuid, GridCacheQueueProxy> e : queuesMap.entrySet()) {
GridCacheQueueProxy queue = e.getValue();
if (clusterRestarted) {
queue.delegate().onRemoved(false);
queuesMap.remove(e.getKey(), queue);
}
}
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class GridDhtCacheAdapter method beginMultiUpdate.
/**
* Starts multi-update lock. Will wait for topology future is ready.
*
* @return Topology version.
* @throws IgniteCheckedException If failed.
*/
public AffinityTopologyVersion beginMultiUpdate() throws IgniteCheckedException {
IgniteBiTuple<IgniteUuid, GridDhtTopologyFuture> tup = multiTxHolder.get();
if (tup != null)
throw new IgniteCheckedException("Nested multi-update locks are not supported");
top.readLock();
GridDhtTopologyFuture topFut;
AffinityTopologyVersion topVer;
try {
// While we are holding read lock, register lock future for partition release future.
IgniteUuid lockId = IgniteUuid.fromUuid(ctx.localNodeId());
topVer = top.topologyVersion();
MultiUpdateFuture fut = new MultiUpdateFuture(topVer);
MultiUpdateFuture old = multiTxFuts.putIfAbsent(lockId, fut);
assert old == null;
topFut = top.topologyVersionFuture();
multiTxHolder.set(F.t(lockId, topFut));
} finally {
top.readUnlock();
}
topFut.get();
return topVer;
}
Aggregations