use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class vmListenerToCheckHARegionQueue method afterCreate.
public void afterCreate(EntryEvent event) {
if (HAGIIBugDUnitTest.isHARegionQueueUp) {
Cache cache = event.getRegion().getCache();
HARegion regionForQueue = (HARegion) cache.getRegion(Region.SEPARATOR + HARegionQueue.createRegionName(HAGIIBugDUnitTest.regionQueueName));
HARegionQueue regionqueue = regionForQueue.getOwner();
try {
regionqueue.put(new ConflatableObject(event.getKey(), event.getNewValue(), ((EntryEventImpl) event).getEventId(), false, "region1"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class vmListenerToCheckHARegionQueue method testGIIBug.
@Ignore("TODO")
@Test
public void testGIIBug() throws Exception {
vm0.invoke(putFromVmBeforeGII("vm0_1"));
populateKeySet("vm0_1");
Thread t1 = new Thread() {
public void run() {
try {
createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
CacheListener regionListener = new vmListenerToCheckHARegionQueue();
factory.setCacheListener(regionListener);
RegionAttributes attrs = factory.create();
Region region = cache.createRegion(REGION_NAME, attrs);
LogWriterUtils.getLogWriter().info("Name of the region is : " + region.getFullPath());
HARegionQueueAttributes hattr = new HARegionQueueAttributes();
// setting expiry time for the regionqueue.
hattr.setExpiryTime(12000000);
RegionQueue regionqueue = null;
regionqueue = HARegionQueue.getHARegionQueueInstance(regionQueueName, cache, hattr, HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
isHARegionQueueUp = true;
vm0.invoke(setStopFlag());
assertNotNull(regionqueue);
} catch (Exception e) {
isTestFailed = true;
e.printStackTrace();
}
}
};
AsyncInvocation[] async = new AsyncInvocation[4];
async[0] = vm0.invokeAsync(putFrmVm("vm0_2"));
t1.start();
ThreadUtils.join(t1, 30 * 1000);
if (isTestFailed)
fail("HARegionQueue can not be created");
for (int count = 0; count < 1; count++) {
ThreadUtils.join(async[count], 30 * 1000);
if (async[count].exceptionOccurred()) {
Assert.fail("Got exception on " + count, async[count].getException());
}
}
total_no_puts[0] = vm0.invoke(() -> HAGIIBugDUnitTest.getTotalNoPuts());
populate_keys_after_gii();
boolean validationFlag = false;
validateResults(validationFlag);
if (keys_set_before_gii.size() != 0)
fail("Data in the HARegion Queue is inconsistent for the keys that are put before GII");
validationFlag = true;
validateResults(validationFlag);
LogWriterUtils.getLogWriter().info("No. of keys that are missed by HARegion Queue during GII " + keys_set_after_gii.size());
if (keys_set_after_gii.size() != 0)
fail("Set of the keys are missed by HARegion Queue during GII");
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class HABug36738DUnitTest method checkRegionQueueSize.
private void checkRegionQueueSize() {
final HARegion region = (HARegion) cache.getRegion(Region.SEPARATOR + HAHelper.getRegionQueueName(HAREGION_NAME));
assertNotNull(region);
assertEquals(COUNT, region.size());
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class GemFireMemberStatus method initializeRegionSizes.
protected void initializeRegionSizes() {
Iterator rootRegions = cache.rootRegions().iterator();
while (rootRegions.hasNext()) {
LocalRegion rootRegion = (LocalRegion) rootRegions.next();
if (!(rootRegion instanceof HARegion)) {
RegionStatus rootRegionStatus = rootRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) rootRegion) : new RegionStatus(rootRegion);
putRegionStatus(rootRegion.getFullPath(), rootRegionStatus);
Iterator subRegions = rootRegion.subregions(true).iterator();
while (subRegions.hasNext()) {
LocalRegion subRegion = (LocalRegion) subRegions.next();
RegionStatus subRegionStatus = subRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) subRegion) : new RegionStatus(subRegion);
putRegionStatus(subRegion.getFullPath(), subRegionStatus);
}
}
}
}
use of org.apache.geode.internal.cache.HARegion in project geode by apache.
the class HARegionQueue method putGIIDataInRegion.
/**
* Repopulates the HARegion after the GII is over so as to reset the counters and populate the
* DACE objects for the thread identifiers . This method should be invoked as the last method in
* the constructor . Thus while creating BlockingQueue this method should be invoked lastly in the
* derived class constructor , after the HARegionQueue contructor is complete. Otherwise, the
* ReentrantLock will be null.
*/
void putGIIDataInRegion() throws CacheException, InterruptedException {
Set entrySet = this.region.entrySet(false);
// be populated
if (!entrySet.isEmpty()) {
this.puttingGIIDataInQueue = true;
final boolean isDebugEnabled = logger.isDebugEnabled();
try {
Region.Entry entry = null;
Map orderedMap = new TreeMap();
Iterator iterator = entrySet.iterator();
Object key = null;
while (iterator.hasNext()) {
entry = (Region.Entry) iterator.next();
key = entry.getKey();
if (isDebugEnabled) {
logger.debug("processing queue key {} and value {}", key, entry.getValue());
}
if (key instanceof Long) {
if (!(entry.getValue() instanceof ClientMarkerMessageImpl)) {
orderedMap.put(key, entry.getValue());
}
}
this.region.localDestroy(key);
}
long max = 0;
long counterInRegion = 0;
entrySet = orderedMap.entrySet();
if (!entrySet.isEmpty()) {
Map.Entry mapEntry = null;
iterator = entrySet.iterator();
while (iterator.hasNext()) {
mapEntry = (Map.Entry) iterator.next();
Conflatable val = (Conflatable) mapEntry.getValue();
if (val != null && val.getEventId() != null) {
counterInRegion = ((Long) mapEntry.getKey()).intValue();
// TODO: remove this assertion
Assert.assertTrue(counterInRegion > max);
max = counterInRegion;
// putInQueue(val);
// logger.info(LocalizedStrings.DEBUG, this + " putting GII entry #" + counterInRegion
// + " into queue: " + val);
this.put(val);
} else if (isDebugEnabled) {
logger.debug("bug 44959 encountered: HARegion.putGIIDataInRegion found null eventId in {}", val);
}
}
}
this.tailKey.set(max);
} finally {
this.puttingGIIDataInQueue = false;
if (isDebugEnabled) {
logger.debug("{} done putting GII data into queue", this);
}
}
}
// TODO:Asif: Avoid invocation of this method
startHAServices(this.region.getCache());
}
Aggregations