Search in sources :

Example 16 with RegionQueue

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");
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) Properties(java.util.Properties) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) CacheListener(org.apache.geode.cache.CacheListener) RegionQueue(org.apache.geode.internal.cache.RegionQueue) CacheException(org.apache.geode.cache.CacheException) AttributesFactory(org.apache.geode.cache.AttributesFactory) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) Ignore(org.junit.Ignore) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 17 with RegionQueue

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);
}
Also used : SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) CancelException(org.apache.geode.CancelException) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 18 with RegionQueue

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();
    }
}
Also used : ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) Iterator(java.util.Iterator) LocalRegion(org.apache.geode.internal.cache.LocalRegion) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 19 with RegionQueue

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);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Properties(java.util.Properties) RegionQueue(org.apache.geode.internal.cache.RegionQueue) CacheListener(org.apache.geode.cache.CacheListener)

Example 20 with RegionQueue

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);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Properties(java.util.Properties) RegionQueue(org.apache.geode.internal.cache.RegionQueue) CacheListener(org.apache.geode.cache.CacheListener)

Aggregations

RegionQueue (org.apache.geode.internal.cache.RegionQueue)39 GatewaySender (org.apache.geode.cache.wan.GatewaySender)28 IgnoredException (org.apache.geode.test.dunit.IgnoredException)8 Properties (java.util.Properties)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 Test (org.junit.Test)7 Region (org.apache.geode.cache.Region)6 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)6 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 CacheListener (org.apache.geode.cache.CacheListener)4 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)4 AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)4 BucketRegion (org.apache.geode.internal.cache.BucketRegion)4 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)4 RegionAttributes (org.apache.geode.cache.RegionAttributes)3 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)3 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)3