use of org.infinispan.commands.write.InvalidateVersionsCommand in project infinispan by infinispan.
the class ScatteredVersionManagerImpl method tryRegularInvalidations.
private void tryRegularInvalidations(boolean force) {
ConcurrentMap<K, InvalidationInfo> scheduledKeys;
long stamp = scheduledKeysLock.writeLock();
try {
scheduledKeys = this.scheduledKeys;
this.scheduledKeys = new ConcurrentHashMap<>(invalidationBatchSize);
} finally {
scheduledKeysLock.unlockWrite(stamp);
}
// we'll invalidate all keys in one run
// we don't have to keep any topology lock, because the versions increase monotonically
int numKeys = scheduledKeys.size();
Object[] keys = new Object[numKeys];
int[] topologyIds = new int[numKeys];
long[] versions = new long[numKeys];
boolean[] isRemoved = new boolean[numKeys];
int numRemoved = 0;
int i = 0;
for (Map.Entry<K, InvalidationInfo> entry : scheduledKeys.entrySet()) {
keys[i] = entry.getKey();
topologyIds[i] = entry.getValue().topologyId;
versions[i] = entry.getValue().version;
if (isRemoved[i] = entry.getValue().removal) {
// intentional assignment
numRemoved++;
}
++i;
}
InvalidateVersionsCommand command = commandsFactory.buildInvalidateVersionsCommand(-1, keys, topologyIds, versions, false);
sendRegularInvalidations(command, keys, topologyIds, versions, numRemoved, isRemoved, force);
}
use of org.infinispan.commands.write.InvalidateVersionsCommand in project infinispan by infinispan.
the class ScatteredVersionManagerImpl method tryRemovedInvalidations.
private void tryRemovedInvalidations() {
final ConcurrentMap<K, InvalidationInfo> removedKeys;
long stamp = removedKeysLock.writeLock();
try {
removedKeys = this.removedKeys;
this.removedKeys = new ConcurrentHashMap<>(invalidationBatchSize);
} finally {
removedKeysLock.unlockWrite(stamp);
}
int numKeys = removedKeys.size();
Object[] keys = new Object[numKeys];
int[] topologyIds = new int[numKeys];
long[] versions = new long[numKeys];
int i = 0;
for (Map.Entry<K, InvalidationInfo> entry : removedKeys.entrySet()) {
keys[i] = entry.getKey();
topologyIds[i] = entry.getValue().topologyId;
versions[i] = entry.getValue().version;
}
InvalidateVersionsCommand removeCommand = commandsFactory.buildInvalidateVersionsCommand(-1, keys, topologyIds, versions, true);
sendRemoveInvalidations(removeCommand);
}
use of org.infinispan.commands.write.InvalidateVersionsCommand in project infinispan by infinispan.
the class ScatteredStateConsumerImpl method invalidate.
private void invalidate(List<KeyAndVersion> list, Address member) {
Object[] keys = new Object[list.size()];
int[] topologyIds = new int[list.size()];
long[] versions = new long[list.size()];
int i = 0;
for (KeyAndVersion pair : list) {
keys[i] = pair.key;
SimpleClusteredVersion version = (SimpleClusteredVersion) pair.version;
topologyIds[i] = version.getTopologyId();
versions[i] = version.getVersion();
++i;
}
// Theoretically we can just send these invalidations asynchronously, but we'd prefer to have old copies
// removed when state transfer completes.
long incrementedCounter = chunkCounter.incrementAndGet();
if (log.isTraceEnabled())
log.tracef("Invalidating versions on %s, chunk counter incremented to %d", member, incrementedCounter);
InvalidateVersionsCommand ivc = commandsFactory.buildInvalidateVersionsCommand(cacheTopology.getTopologyId(), keys, topologyIds, versions, true);
rpcManager.invokeCommand(member, ivc, SingleResponseCollector.validOnly(), rpcManager.getSyncRpcOptions()).whenComplete((response, t) -> {
if (t != null) {
log.failedInvalidatingRemoteCache(t);
}
long decrementedCounter = chunkCounter.decrementAndGet();
if (log.isTraceEnabled())
log.tracef("Versions invalidated on %s, chunk counter decremented to %d", member, decrementedCounter);
if (decrementedCounter == 0) {
notifyEndOfStateTransferIfNeeded();
}
});
}
Aggregations