use of org.apache.geode.internal.cache.RegionQueue 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.RegionQueue in project geode by apache.
the class SerialAsyncEventQueueImpl method stop.
@Override
public void stop() {
if (logger.isDebugEnabled()) {
logger.debug("Stopping Gateway Sender : {}", this);
}
this.getLifeCycleLock().writeLock().lock();
try {
// Stop the dispatcher
AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
if (ev != null && !ev.isStopped()) {
ev.stopProcessing();
}
// Stop the proxy (after the dispatcher, so the socket is still
// alive until after the dispatcher has stopped)
stompProxyDead();
// Close the listeners
for (AsyncEventListener listener : this.listeners) {
listener.close();
}
logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
clearTempEventsAfterSenderStopped();
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
if (this.isPrimary()) {
try {
DistributedLockService.destroy(getSenderAdvisor().getDLockServiceName());
} catch (IllegalArgumentException e) {
// service not found... ignore
}
}
if (getQueues() != null && !getQueues().isEmpty()) {
for (RegionQueue q : getQueues()) {
((SerialGatewaySenderQueue) q).cleanUp();
}
}
this.setIsPrimary(false);
try {
new UpdateAttributesProcessor(this).distribute(false);
} catch (CancelException e) {
}
Thread lockObtainingThread = getSenderAdvisor().getLockObtainingThread();
if (lockObtainingThread != null && lockObtainingThread.isAlive()) {
// wait a while for thread to terminate
try {
lockObtainingThread.join(3000);
} catch (InterruptedException ex) {
// we allowed our join to be canceled
// reset interrupt bit so this thread knows it has been interrupted
Thread.currentThread().interrupt();
}
if (lockObtainingThread.isAlive()) {
logger.info(LocalizedMessage.create(LocalizedStrings.GatewaySender_COULD_NOT_STOP_LOCK_OBTAINING_THREAD_DURING_GATEWAY_SENDER_STOP));
}
}
InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class AbstractGatewaySender method destroy.
public void destroy(boolean initiator) {
try {
this.getLifeCycleLock().writeLock().lock();
// first, check if this sender is attached to any region. If so, throw
// GatewaySenderException
Set<LocalRegion> regions = this.cache.getApplicationRegions();
Iterator regionItr = regions.iterator();
while (regionItr.hasNext()) {
LocalRegion region = (LocalRegion) regionItr.next();
if (region.getAttributes().getGatewaySenderIds().contains(this.id)) {
throw new GatewaySenderException(LocalizedStrings.GatewaySender_COULD_NOT_DESTROY_SENDER_AS_IT_IS_STILL_IN_USE.toLocalizedString(this));
}
}
// close the GatewaySenderAdvisor
GatewaySenderAdvisor advisor = this.getSenderAdvisor();
if (advisor != null) {
if (logger.isDebugEnabled()) {
logger.debug("Stopping the GatewaySender advisor");
}
advisor.close();
}
// remove the sender from the cache
this.cache.removeGatewaySender(this);
// destroy the region underneath the sender's queue
if (initiator) {
Set<RegionQueue> regionQueues = getQueues();
if (regionQueues != null) {
for (RegionQueue regionQueue : regionQueues) {
try {
if (regionQueue instanceof ConcurrentParallelGatewaySenderQueue) {
Set<PartitionedRegion> queueRegions = ((ConcurrentParallelGatewaySenderQueue) regionQueue).getRegions();
for (PartitionedRegion queueRegion : queueRegions) {
queueRegion.destroyRegion();
}
} else {
// For SerialGatewaySenderQueue, do local destroy
regionQueue.getRegion().localDestroyRegion();
}
}// by several nodes simultaneously
catch (RegionDestroyedException e) {
// the region might have already been destroyed by other node. Just
// log
// the exception.
this.logger.info(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_REGION_0_UNDERLYING_GATEWAYSENDER_1_IS_ALREADY_DESTROYED, new Object[] { e.getRegionFullPath(), this }));
}
}
}
// END if (regionQueues != null)
}
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class HAExpiryDUnitTest method createRegionQueue.
public static void createRegionQueue(Boolean isDurable) throws Exception {
new HAExpiryDUnitTest().createCache(new Properties());
HARegionQueueAttributes hattr = new HARegionQueueAttributes();
// setting expiry time for the regionqueue.
hattr.setExpiryTime(4);
RegionQueue regionqueue = HARegionQueue.getHARegionQueueInstance(regionQueueName, cache, hattr, HARegionQueue.NON_BLOCKING_HA_QUEUE, isDurable.booleanValue());
assertNotNull(regionqueue);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
CacheListener serverListener = new VMListener();
factory.setCacheListener(serverListener);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class vmListenerToCheckHARegionQueue method createRegionQueue.
public static void createRegionQueue() throws Exception {
new HAGIIBugDUnitTest().createCache(new Properties());
HARegionQueueAttributes hattr = new HARegionQueueAttributes();
// setting expiry time for the regionqueue.
hattr.setExpiryTime(12000000);
RegionQueue regionqueue = HARegionQueue.getHARegionQueueInstance(regionQueueName, cache, hattr, HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
assertNotNull(regionqueue);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
CacheListener regionListener = new vmListenerToPutInHARegionQueue();
factory.setCacheListener(regionListener);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
}
Aggregations