Search in sources :

Example 1 with IracTombstoneCleanupCommand

use of org.infinispan.commands.irac.IracTombstoneCleanupCommand in project infinispan by infinispan.

the class DefaultIracTombstoneManager method checkStaleTombstone.

@Override
public void checkStaleTombstone(Collection<? extends IracTombstoneInfo> tombstones) {
    LocalizedCacheTopology topology = distributionManager.getCacheTopology();
    for (IracTombstoneInfo tombstone : tombstones) {
        IracTombstoneInfo data = tombstoneMap.get(tombstone.getKey());
        if (!topology.getSegmentDistribution(tombstone.getSegment()).isPrimary() || (tombstone.equals(data))) {
            // not a primary owner or the data is the same (i.e. it is valid)
            continue;
        }
        IracTombstoneCleanupCommand cmd = commandsFactory.buildIracTombstoneCleanupCommand(tombstone);
        rpcManager.sendToMany(topology.getSegmentDistribution(tombstone.getSegment()).writeOwners(), cmd, DeliverOrder.NONE);
    }
}
Also used : IracTombstoneCleanupCommand(org.infinispan.commands.irac.IracTombstoneCleanupCommand) LocalizedCacheTopology(org.infinispan.distribution.LocalizedCacheTopology)

Example 2 with IracTombstoneCleanupCommand

use of org.infinispan.commands.irac.IracTombstoneCleanupCommand in project infinispan by infinispan.

the class IracTombstoneCleanupTest method testPrimaryOwnerRoundCleanupsBackup.

public void testPrimaryOwnerRoundCleanupsBackup(Method method) {
    String key = k(method);
    int segment = getSegment(key);
    Cache<String, String> pCache = findPrimaryOwner(segment);
    Cache<String, String> bCache = findBackupOwner(segment);
    IracMetadata metadata = dummyMetadata(1);
    tombstoneManager(pCache).storeTombstone(segment, key, metadata);
    tombstoneManager(bCache).storeTombstone(segment, key, metadata);
    assertEquals(1, tombstoneManager(pCache).size());
    assertEquals(1, tombstoneManager(bCache).size());
    RecordingRpcManager pRpcManager = recordingRpcManager(pCache);
    pRpcManager.startRecording();
    tombstoneManager(pCache).runCleanupAndWait();
    eventuallyEquals(0, () -> tombstoneManager(pCache).size());
    eventuallyEquals(0, () -> tombstoneManager(bCache).size());
    IracTombstoneCleanupCommand cmd = pRpcManager.findSingleCommand(IracTombstoneCleanupCommand.class);
    assertNotNull(cmd);
    assertEquals(segment, cmd.getTombstone().getSegment());
    assertEquals(key, cmd.getTombstone().getKey());
    assertEquals(metadata, cmd.getTombstone().getMetadata());
}
Also used : IracTombstoneCleanupCommand(org.infinispan.commands.irac.IracTombstoneCleanupCommand) IracMetadata(org.infinispan.metadata.impl.IracMetadata) ByteString(org.infinispan.util.ByteString)

Aggregations

IracTombstoneCleanupCommand (org.infinispan.commands.irac.IracTombstoneCleanupCommand)2 LocalizedCacheTopology (org.infinispan.distribution.LocalizedCacheTopology)1 IracMetadata (org.infinispan.metadata.impl.IracMetadata)1 ByteString (org.infinispan.util.ByteString)1