Skip to content

Commit

Permalink
IGNITE-20085 GridNearTxRemote initial cleanup (#10861)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-vinogradov authored Aug 1, 2023
1 parent 5eab58f commit 5596342
Showing 1 changed file with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
*/
public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
/** Evicted keys. */
private Collection<IgniteTxKey> evicted = new LinkedList<>();
private final Collection<IgniteTxKey> evicted = new LinkedList<>();

/** Near node ID. */
private UUID nearNodeId;
private final UUID nearNodeId;

/** Near transaction ID. */
private GridCacheVersion nearXidVer;
Expand Down Expand Up @@ -125,8 +125,7 @@ public GridNearTxRemote(

int writeSize = writeEntries != null ? Math.max(txSize, writeEntries.size()) : txSize;

txState = new IgniteTxRemoteStateImpl(Collections.<IgniteTxKey, IgniteTxEntry>emptyMap(),
U.<IgniteTxKey, IgniteTxEntry>newLinkedHashMap(writeSize));
txState = new IgniteTxRemoteStateImpl(Collections.emptyMap(), U.newLinkedHashMap(writeSize));

if (writeEntries != null) {
for (IgniteTxEntry entry : writeEntries) {
Expand Down Expand Up @@ -203,8 +202,7 @@ public GridNearTxRemote(
this.nearXidVer = nearXidVer;
this.nearNodeId = nearNodeId;

txState = new IgniteTxRemoteStateImpl(U.<IgniteTxKey, IgniteTxEntry>newLinkedHashMap(1),
U.<IgniteTxKey, IgniteTxEntry>newLinkedHashMap(txSize));
txState = new IgniteTxRemoteStateImpl(U.newLinkedHashMap(1), U.newLinkedHashMap(txSize));

assert topVer != null && topVer.topologyVersion() > 0 : topVer;

Expand Down Expand Up @@ -239,7 +237,7 @@ public GridNearTxRemote(
}

/** {@inheritDoc} */
@Override public void addActiveCache(GridCacheContext cacheCtx, boolean recovery) throws IgniteCheckedException {
@Override public void addActiveCache(GridCacheContext cacheCtx, boolean recovery) {
throw new UnsupportedOperationException("Near tx doesn't track active caches.");
}

Expand All @@ -258,13 +256,6 @@ public void ownedVersions(Map<IgniteTxKey, GridCacheVersion> vers) {
owned.putAll(vers);
}

/**
* @return Near node ID.
*/
public UUID nearNodeId() {
return nearNodeId;
}

/** {@inheritDoc} */
@Override public Collection<UUID> masterNodeIds() {
Collection<UUID> res = new ArrayList<>(2);
Expand Down Expand Up @@ -309,51 +300,39 @@ public void addEntries(ClassLoader ldr, Iterable<IgniteTxEntry> entries) throws
/**
* @param entry Entry to enlist.
* @throws IgniteCheckedException If failed.
* @return {@code True} if entry was enlisted.
*/
private boolean addEntry(IgniteTxEntry entry) throws IgniteCheckedException {
private void addEntry(IgniteTxEntry entry) throws IgniteCheckedException {
checkInternal(entry.txKey());

GridCacheContext cacheCtx = entry.context();
GridCacheContext<?, ?> cacheCtx = entry.context();

assert cacheCtx.isNear() : entry;

GridNearCacheEntry cached = cacheCtx.near().peekExx(entry.key());

if (cached == null) {
if (cached == null)
evicted.add(entry.txKey());

return false;
}
else {
try {
// Unswap is no-op for near cache.

CacheObject val = cached.peek();

if (val == null && cached.evictInternal(xidVer, null, false)) {
if (val == null && cached.evictInternal(xidVer, null, false))
evicted.add(entry.txKey());

return false;
}
else {
// Initialize cache entry.
entry.cached(cached);

txState.addWriteEntry(entry.txKey(), entry);

addExplicit(entry);

return true;
}
}
catch (GridCacheEntryRemovedException ignore) {
evicted.add(entry.txKey());

if (log.isDebugEnabled())
log.debug("Got removed entry when adding to remote transaction (will ignore): " + cached);

return false;
}
}
}
Expand Down

0 comments on commit 5596342

Please sign in to comment.