Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-vinogradov committed Sep 19, 2023
1 parent 771c735 commit 6f77083
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUpdateVersionAware;
import org.apache.ignite.internal.processors.cache.mvcc.MvccVersionAware;
import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanSet;
Expand Down Expand Up @@ -536,10 +534,10 @@ void onResult(GridDhtForceKeysResponse res) {
if (entry.initialValue(
info.value(),
info.version(),
cctx.mvccEnabled() ? ((MvccVersionAware)info).mvccVersion() : null,
cctx.mvccEnabled() ? ((MvccUpdateVersionAware)info).newMvccVersion() : null,
cctx.mvccEnabled() ? ((MvccVersionAware)entry).mvccTxState() : TxState.NA,
cctx.mvccEnabled() ? ((MvccUpdateVersionAware)entry).newMvccTxState() : TxState.NA,
null,
null,
TxState.NA,
TxState.NA,
info.ttl(),
info.expireTime(),
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,6 @@ private <K, V> IgniteInternalFuture putAsync0(
) {
assert key != null;

if (cacheCtx.mvccEnabled())
return mvccPutAllAsync0(cacheCtx, Collections.singletonMap(key, val),
entryProc == null ? null : Collections.singletonMap(key, entryProc), invokeArgs, retval, filter);

try {
beforePut(cacheCtx, retval, false);

Expand Down Expand Up @@ -858,9 +854,6 @@ private <K, V> IgniteInternalFuture putAllAsync0(
@Nullable Map<KeyCacheObject, GridCacheDrInfo> drMap,
final boolean retval
) {
if (cacheCtx.mvccEnabled())
return mvccPutAllAsync0(cacheCtx, map, invokeMap, invokeArgs, retval, null);

try {
beforePut(cacheCtx, retval, false);
}
Expand Down Expand Up @@ -1703,9 +1696,6 @@ private <K, V> IgniteInternalFuture<GridCacheReturn> removeAllAsync0(
final boolean retval,
@Nullable final CacheEntryPredicate filter,
boolean singleRmv) {
if (cacheCtx.mvccEnabled())
return mvccRemoveAllAsync0(cacheCtx, keys, retval, filter);

try {
checkUpdatesAllowed(cacheCtx);
}
Expand Down Expand Up @@ -1929,87 +1919,6 @@ private <K, V> IgniteInternalFuture<GridCacheReturn> removeAllAsync0(
}
}

/**
* Internal method for remove operations in Mvcc mode.
*
* @param cacheCtx Cache context.
* @param keys Keys to remove.
* @param retval Flag indicating whether a value should be returned.
* @param filter Filter.
* @return Future for asynchronous remove.
*/
@SuppressWarnings("unchecked")
private <K, V> IgniteInternalFuture<GridCacheReturn> mvccRemoveAllAsync0(
final GridCacheContext cacheCtx,
@Nullable final Collection<? extends K> keys,
final boolean retval,
@Nullable final CacheEntryPredicate filter
) {
try {
MvccUtils.requestSnapshot(this);

beforeRemove(cacheCtx, retval);
}
catch (IgniteCheckedException e) {
return new GridFinishedFuture(e);
}

if (F.isEmpty(keys)) {
if (implicit()) {
try {
commit();
}
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
}
}

return new GridFinishedFuture<>(new GridCacheReturn(localResult(), true));
}

init();

Set<KeyCacheObject> enlisted = new HashSet<>(keys.size());

try {
for (Object key : keys) {
if (isRollbackOnly())
return new GridFinishedFuture<>(timedOut() ? timeoutException() : rollbackException());

if (key == null) {
rollback();

throw new NullPointerException("Null key.");
}

KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key);

enlisted.add(cacheKey);
}

}
catch (IgniteCheckedException e) {
return new GridFinishedFuture(e);
}

return updateAsync(cacheCtx, new UpdateSourceIterator<KeyCacheObject>() {

private final Iterator<KeyCacheObject> it = enlisted.iterator();

@Override public EnlistOperation operation() {
return EnlistOperation.DELETE;
}

@Override public boolean hasNextX() {
return it.hasNext();
}

@Override public KeyCacheObject nextX() {
return it.next();
}
}, retval, filter, remainingTime());
}

/**
* @param cacheCtx Cache context.
* @param cacheIds Involved cache ids.
Expand Down Expand Up @@ -2208,9 +2117,6 @@ public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.emptyMap());

if (cacheCtx.mvccEnabled() && !isOperationAllowed(true))
return txTypeMismatchFinishFuture();

init();

int keysCnt = keys.size();
Expand Down Expand Up @@ -4811,15 +4717,12 @@ private boolean isAll(GridCacheContext cctx,
* @throws IgniteCheckedException If failed.
*/
private void beforePut(GridCacheContext cacheCtx, boolean retval, boolean mvccOp) throws IgniteCheckedException {
assert !mvccOp || cacheCtx.mvccEnabled();
assert !mvccOp;

checkUpdatesAllowed(cacheCtx);

cacheCtx.checkSecurity(SecurityPermission.CACHE_PUT);

if (cacheCtx.mvccEnabled() && !isOperationAllowed(mvccOp))
throw new IgniteCheckedException(TX_TYPE_MISMATCH_ERR_MSG);

if (retval)
needReturnValue(true);

Expand All @@ -4828,27 +4731,6 @@ private void beforePut(GridCacheContext cacheCtx, boolean retval, boolean mvccOp
init();
}

/**
* @param cacheCtx Cache context.
* @param retval Return value flag.
* @throws IgniteCheckedException If failed.
*/
private void beforeRemove(GridCacheContext cacheCtx, boolean retval) throws IgniteCheckedException {
assert cacheCtx.mvccEnabled();

checkUpdatesAllowed(cacheCtx);

cacheCtx.checkSecurity(SecurityPermission.CACHE_REMOVE);

if (cacheCtx.mvccEnabled() && !isOperationAllowed(true))
throw new IgniteCheckedException(TX_TYPE_MISMATCH_ERR_MSG);

if (retval)
needReturnValue(true);

checkValid();
}

/**
* @param cacheCtx Cache context.
* @throws IgniteCheckedException If updates are not allowed.
Expand Down

0 comments on commit 6f77083

Please sign in to comment.