use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class PersistentRVVRecoveryDUnitTest method testLotsOfTombstonesExpiration.
/**
* Test that we correctly recover and expire recovered tombstones, with compaction enabled.
*
* This test differs from above test in that we need to make sure tombstones start expiring based
* on their original time-stamp, NOT the time-stamp assigned during scheduling for expiration
* after recovery.
*/
@Ignore
@Test
public void testLotsOfTombstonesExpiration() throws Throwable {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
vm0.invoke(new CacheSerializableRunnable("") {
@Override
public void run2() throws CacheException {
long replicatedTombstoneTomeout = TombstoneService.REPLICATE_TOMBSTONE_TIMEOUT;
int expiriredTombstoneLimit = TombstoneService.EXPIRED_TOMBSTONE_LIMIT;
try {
LocalRegion region = createRegion(vm0);
int initialCount = getTombstoneCount(region);
assertEquals(0, initialCount);
final int entryCount = 20;
for (int i = 0; i < entryCount; i++) {
region.put(i, new byte[100]);
// destroy each entry.
region.destroy(i);
}
assertEquals(entryCount, getTombstoneCount(region));
// roll to a new oplog
region.getDiskStore().forceRoll();
// Force a compaction. This should do nothing, because
// The tombstones are not garbage, so only 50% of the oplog
// is garbage (the creates).
region.getDiskStore().forceCompaction();
assertEquals(0, region.getDiskStore().numCompactableOplogs());
assertEquals(entryCount, getTombstoneCount(region));
getCache().close();
// We should wait for timeout time so that tomstones are expired
// right away when they are gIId based on their original timestamp.
Wait.pause((int) TEST_REPLICATED_TOMBSTONE_TIMEOUT);
TombstoneService.REPLICATE_TOMBSTONE_TIMEOUT = TEST_REPLICATED_TOMBSTONE_TIMEOUT;
TombstoneService.EXPIRED_TOMBSTONE_LIMIT = entryCount;
// Do region GII
region = createRegion(vm0);
assertEquals(entryCount, getTombstoneCount(region));
getCache().getLogger().fine("Waiting for maximumSleepTime ms");
// maximumSleepTime+500 in TombstoneSweeper GC thread
Wait.pause(10000);
// Tombstones should have been expired and garbage collected by now by
// TombstoneService.
assertEquals(0, getTombstoneCount(region));
// This should compact some oplogs
region.getDiskStore().forceCompaction();
assertEquals(0, region.getDiskStore().numCompactableOplogs());
// Test after restart the tombstones are still missing
getCache().close();
region = createRegion(vm0);
assertEquals(0, getTombstoneCount(region));
// We should have an oplog available for compaction, because the
// tombstones
// were garbage collected
assertEquals(0, region.getDiskStore().numCompactableOplogs());
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
cache.close();
} finally {
TombstoneService.REPLICATE_TOMBSTONE_TIMEOUT = replicatedTombstoneTomeout;
TombstoneService.EXPIRED_TOMBSTONE_LIMIT = expiriredTombstoneLimit;
}
}
});
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAInterestTestCase method stopSecondaryAndRegisterK1AndK2AndVerifyResponse.
/**
* returns the secondary that was stopped
*/
public static VM stopSecondaryAndRegisterK1AndK2AndVerifyResponse() {
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return pool.getConnectedServerCount() == 3;
}
@Override
public String description() {
return "Never got three connected servers";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
// close secondary EP
VM result = getBackupVM();
result.invoke(() -> HAInterestTestCase.stopServer());
List list = new ArrayList();
list.add(k1);
list.add(k2);
List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
assertNotNull(serverKeys);
List resultKeys = (List) serverKeys.get(0);
assertEquals(2, resultKeys.size());
assertTrue(resultKeys.contains(k1));
assertTrue(resultKeys.contains(k2));
return result;
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAInterestTestCase method registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse.
public static void registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse() {
ServerLocation primary = pool.getPrimary();
ServerLocation secondary = (ServerLocation) pool.getRedundants().get(0);
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
List list = new ArrayList();
list.add(k1);
list.add(k2);
// Primary server
List serverKeys1 = srp.registerInterestOn(primary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
assertNotNull(serverKeys1);
// expect serverKeys in response from primary
List resultKeys = (List) serverKeys1.get(0);
assertEquals(2, resultKeys.size());
assertTrue(resultKeys.contains(k1));
assertTrue(resultKeys.contains(k2));
// Secondary server
List serverKeys2 = srp.registerInterestOn(secondary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
// if the list is null then it is empty
if (serverKeys2 != null) {
// no serverKeys in response from secondary
assertTrue(serverKeys2.isEmpty());
}
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAInterestTestCase method stopPrimaryAndUnregisterRegisterK1.
public static void stopPrimaryAndUnregisterRegisterK1() {
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return pool.getConnectedServerCount() == 3;
}
@Override
public String description() {
return "connected server count never became 3";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
// close primaryEP
getPrimaryVM().invoke(() -> HAInterestTestCase.stopServer());
List list = new ArrayList();
list.add(k1);
srp.unregisterInterest(list, InterestType.KEY, false, false);
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class FilterProfileIntegrationJUnitTest method testFilterProfile.
@Test
public void testFilterProfile() throws Exception {
Cache cache = CacheUtils.getCache();
try {
createLocalRegion();
LocalRegion region = (LocalRegion) cache.getRegion(regionName);
final FilterProfile filterProfile = new FilterProfile(region);
filterProfile.registerClientInterest("clientId", ".*", InterestType.REGULAR_EXPRESSION, false);
final FilterProfileTestHook hook = new FilterProfileTestHook();
FilterProfile.testHook = hook;
new Thread(new Runnable() {
public void run() {
while (hook.getCount() != 1) {
}
filterProfile.unregisterClientInterest("clientId", ".*", InterestType.REGULAR_EXPRESSION);
}
}).start();
filterProfile.hasAllKeysInterestFor("clientId");
} finally {
cache.getDistributedSystem().disconnect();
cache.close();
}
}
Aggregations