use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class HAExpiryDUnitTest method checkSizeAfterExpiration.
/**
* This function checks the regionqueue size After expiration. size should be = 0.
*
* @throws Exception
*/
public static void checkSizeAfterExpiration() throws Exception {
HARegion regionForQueue = (HARegion) cache.getRegion(Region.SEPARATOR + HARegionQueue.createRegionName(regionQueueName));
final HARegionQueue regionqueue = regionForQueue.getOwner();
cache.getLogger().info("Size of the regionqueue After expiration is " + regionqueue.size());
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return regionqueue.size() <= regionQueueSize;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 60 * 1000, 200, true);
/*
* if (regionqueue.size() > regionQueueSize) fail("RegionQueue size should be 0 after
* expiration");
*/
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class HAExpiryDUnitTest method checkSizeBeforeExpiration.
/**
* This function checks the regionqueue size before expiration. size should be > 0.
*
* @throws Exception
*/
public static void checkSizeBeforeExpiration() throws Exception {
HARegion regionForQueue = (HARegion) cache.getRegion(Region.SEPARATOR + HARegionQueue.createRegionName(regionQueueName));
final HARegionQueue regionqueue = regionForQueue.getOwner();
regionQueueSize = regionqueue.size();
cache.getLogger().info("Size of the regionqueue before expiration is " + regionQueueSize);
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return regionqueue.size() >= 1;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 60 * 1000, 200, true);
/*
* if (regionqueue.size() < 1) fail("RegionQueue size canot be less than 1 before expiration");
*/
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class vmListenerToCheckHARegionQueue method validateResults.
private void validateResults(boolean isSecond) {
HARegion regionForQueue = (HARegion) cache.getRegion(Region.SEPARATOR + HARegionQueue.createRegionName(HAExpiryDUnitTest.regionQueueName));
LogWriterUtils.getLogWriter().info("Region Queue size : " + regionForQueue.keys().size());
Iterator itr = regionForQueue.entrySet(false).iterator();
while (itr.hasNext()) {
Entry entry = (Entry) itr.next();
if (entry.getKey() instanceof Long) {
String strValue = (String) ((ConflatableObject) entry.getValue()).getKey();
if (isSecond) {
if (strValue.indexOf("_2") != -1) {
if (keys_set_after_gii.contains(((ConflatableObject) entry.getValue()).getKey())) {
keys_set_after_gii.remove(strValue);
}
}
} else {
if (strValue.indexOf("_1") != -1) {
if (!keys_set_before_gii.contains(strValue)) {
fail("Key " + ((ConflatableObject) entry.getValue()).getKey() + " not present in the region queue before GII");
} else {
keys_set_before_gii.remove(strValue);
}
}
}
}
}
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class HARegionJUnitTest method testPut.
/**
* test no exception being thrown while put is being done on an HARegion
*/
@Test
public void testPut() throws Exception {
Region region = createHARegion();
region.put("key1", "value1");
assertEquals(region.get("key1"), "value1");
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class QueueRemovalMessage method process.
/**
* Extracts the region from the message list and hands over the message removal task to the
* executor
*/
@Override
protected void process(DistributionManager dm) {
final InternalCache cache;
// use GemFireCache.getInstance to avoid blocking during cache.xml processing.
cache = GemFireCacheImpl.getInstance();
if (cache != null) {
Iterator iterator = this.messagesList.iterator();
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE);
try {
while (iterator.hasNext()) {
final String regionName = (String) iterator.next();
final int size = (Integer) iterator.next();
final LocalRegion region = (LocalRegion) cache.getRegion(regionName);
final HARegionQueue hrq;
if (region == null || !region.isInitialized()) {
hrq = null;
} else {
HARegionQueue tmp = ((HARegion) region).getOwner();
if (tmp != null && tmp.isQueueInitialized()) {
hrq = tmp;
} else {
hrq = null;
}
}
// a bunch of event IDs to go through
for (int i = 0; i < size; i++) {
final EventID id = (EventID) iterator.next();
boolean interrupted = Thread.interrupted();
if (hrq == null || !hrq.isQueueInitialized()) {
continue;
}
try {
// {
try {
if (logger.isTraceEnabled()) {
logger.trace("QueueRemovalMessage: removing dispatched events on queue {} for {}", regionName, id);
}
hrq.removeDispatchedEvents(id);
} catch (RegionDestroyedException ignore) {
logger.info(LocalizedMessage.create(LocalizedStrings.QueueRemovalMessage_QUEUE_FOUND_DESTROYED_WHILE_PROCESSING_THE_LAST_DISPTACHED_SEQUENCE_ID_FOR_A_HAREGIONQUEUES_DACE_THE_EVENT_ID_IS_0_FOR_HAREGION_WITH_NAME_1, new Object[] { id, regionName }));
} catch (CancelException ignore) {
// cache or DS is closing
return;
} catch (CacheException e) {
logger.error(LocalizedMessage.create(LocalizedStrings.QueueRemovalMessage_QUEUEREMOVALMESSAGEPROCESSEXCEPTION_IN_PROCESSING_THE_LAST_DISPTACHED_SEQUENCE_ID_FOR_A_HAREGIONQUEUES_DACE_THE_PROBLEM_IS_WITH_EVENT_ID__0_FOR_HAREGION_WITH_NAME_1, new Object[] { regionName, id }), e);
} catch (InterruptedException ignore) {
// interrupt occurs during shutdown. this runs in an executor, so just stop
return;
// processing
}
} catch (RejectedExecutionException ignore) {
interrupted = true;
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
// if
}
// for
} finally {
LocalRegion.setThreadInitLevelRequirement(oldLevel);
}
}
// cache != null
}
Aggregations