use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDhtCacheEntry method mappings.
/**
* Sets mappings into entry.
*
* @param ver Version.
* @return Candidate, if one existed for the version, or {@code null} if candidate was not found.
* @throws GridCacheEntryRemovedException If removed.
*/
@Nullable
public GridCacheMvccCandidate mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds) throws GridCacheEntryRemovedException {
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
if (cand != null)
cand.mappedNodeIds(dhtNodeIds, nearNodeIds);
return cand;
} finally {
unlockEntry();
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDhtCacheEntry method localCandidateByNearVersion.
/**
* @param nearVer Near version.
* @param rmv If {@code true}, then add to removed list if not found.
* @return Local candidate by near version.
* @throws GridCacheEntryRemovedException If removed.
*/
@Nullable
GridCacheMvccCandidate localCandidateByNearVersion(GridCacheVersion nearVer, boolean rmv) throws GridCacheEntryRemovedException {
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
for (GridCacheMvccCandidate c : mvcc.localCandidatesNoCopy(false)) {
GridCacheVersion ver = c.otherVersion();
if (ver != null && ver.equals(nearVer))
return c;
}
}
if (rmv)
addRemoved(nearVer);
return null;
} finally {
unlockEntry();
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDhtCacheEntry method removeLock.
/**
* {@inheritDoc}
*/
@Override
public GridCacheMvccCandidate removeLock() {
GridCacheMvccCandidate ret = super.removeLock();
locPart.onUnlock();
return ret;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDhtCacheEntry method removeMapping.
/**
* @param ver Version.
* @param mappedNode Mapped node to remove.
*/
public void removeMapping(GridCacheVersion ver, ClusterNode mappedNode) {
lockEntry();
try {
GridCacheMvcc mvcc = mvccExtras();
GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
if (cand != null)
cand.removeMappedNode(mappedNode);
} finally {
unlockEntry();
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class VisorTxTask method fetchTxEntriesAndFillUsedCaches.
/**
* Retrieves detailed information about used keys and locks ownership.
*
* @param ignite Ignite.
* @param locTx Local tx.
* @param usedCaches Used caches.
* @param usedCacheGroups Used cache groups.
* @param locEntries Local entries.
* @param skipLocksCheck Skip locks check.
*/
private static List<TxVerboseKey> fetchTxEntriesAndFillUsedCaches(IgniteEx ignite, IgniteInternalTx locTx, Map<Integer, String> usedCaches, Map<Integer, String> usedCacheGroups, Collection<IgniteTxEntry> locEntries, boolean skipLocksCheck) {
List<TxVerboseKey> locTxKeys = new ArrayList<>();
for (IgniteTxEntry txEntry : locEntries) {
GridCacheContext cacheCtx = ignite.context().cache().context().cacheContext(txEntry.cacheId());
usedCaches.put(cacheCtx.cacheId(), cacheCtx.name());
usedCacheGroups.put(cacheCtx.groupId(), cacheCtx.group().cacheOrGroupName());
TxKeyLockType keyLockType = TxKeyLockType.NO_LOCK;
GridCacheVersion ownerVer = null;
if (!skipLocksCheck) {
GridCacheEntryEx entryEx = cacheCtx.cache().entryEx(txEntry.key(), locTx.topologyVersion());
Collection<GridCacheMvccCandidate> locCandidates;
try {
locCandidates = entryEx.localCandidates();
} catch (GridCacheEntryRemovedException ignored) {
U.warn(ignite.log(), "Failed to process TX key: entry was already removed: " + txEntry.txKey());
continue;
}
boolean owner = false;
boolean present = false;
for (GridCacheMvccCandidate mvccCandidate : locCandidates) {
if (mvccCandidate.owner())
ownerVer = mvccCandidate.version();
if (locTx.xidVersion().equals(mvccCandidate.version())) {
present = true;
if (mvccCandidate.owner())
owner = true;
}
}
keyLockType = present ? (owner ? TxKeyLockType.OWNS_LOCK : TxKeyLockType.AWAITS_LOCK) : TxKeyLockType.NO_LOCK;
}
TxVerboseKey txVerboseKey = new TxVerboseKey(txEntry.txKey().toString(), keyLockType, ownerVer, txEntry.isRead());
locTxKeys.add(txVerboseKey);
}
return locTxKeys;
}
Aggregations