Search in sources :

Example 1 with AsyncEventQueueConfigurationException

use of org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException in project geode by apache.

the class AsyncEventQueueValidationsJUnitTest method testConcurrentParallelAsyncEventQueueAttributesWrongDispatcherThreads.

@Test
public void testConcurrentParallelAsyncEventQueueAttributesWrongDispatcherThreads() {
    cache = new CacheFactory().set(MCAST_PORT, "0").create();
    try {
        AsyncEventQueueFactory fact = cache.createAsyncEventQueueFactory();
        fact.setParallel(true);
        fact.setDispatcherThreads(-5);
        fact.setOrderPolicy(OrderPolicy.KEY);
        fact.create("id", new org.apache.geode.internal.cache.wan.MyAsyncEventListener());
        fail("Expected AsyncEventQueueConfigurationException.");
    } catch (AsyncEventQueueConfigurationException e) {
        assertTrue(e.getMessage().contains(" can not be created with dispatcher threads less than 1"));
    }
}
Also used : AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) CacheFactory(org.apache.geode.cache.CacheFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with AsyncEventQueueConfigurationException

use of org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException in project geode by apache.

the class AsyncEventQueueFactoryImpl method create.

private GatewaySender create(String id) {
    this.attrs.id = id;
    GatewaySender sender = null;
    if (this.attrs.getDispatcherThreads() <= 0) {
        throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
    }
    if (this.attrs.isParallel()) {
        if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
            throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new ParallelAsyncEventQueueImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new ParallelAsyncEventQueueCreation(this.cache, this.attrs);
            ((CacheCreation) this.cache).addGatewaySender(sender);
        }
    } else {
        if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
            this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new SerialAsyncEventQueueImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new SerialAsyncEventQueueCreation(this.cache, this.attrs);
            ((CacheCreation) this.cache).addGatewaySender(sender);
        }
    }
    return sender;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) ParallelAsyncEventQueueCreation(org.apache.geode.internal.cache.xmlcache.ParallelAsyncEventQueueCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) SerialAsyncEventQueueCreation(org.apache.geode.internal.cache.xmlcache.SerialAsyncEventQueueCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

Example 3 with AsyncEventQueueConfigurationException

use of org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException in project geode by apache.

the class DistributedRegion method postCreateRegion.

/**
   * In addition to inherited code this method also invokes RegionMembershipListeners
   */
@Override
protected void postCreateRegion() {
    super.postCreateRegion();
    // should we sync on this.distAdvisor first to prevent bug 44369?
    synchronized (this.advisorListener) {
        Set others = this.advisorListener.getInitialMembers();
        CacheListener[] listeners = fetchCacheListenersField();
        if (listeners != null) {
            for (CacheListener listener : listeners) {
                if (listener instanceof RegionMembershipListener) {
                    RegionMembershipListener regionMembershipListener = (RegionMembershipListener) listener;
                    try {
                        DistributedMember[] otherDms = new DistributedMember[others.size()];
                        others.toArray(otherDms);
                        regionMembershipListener.initialMembers(this, otherDms);
                    } catch (VirtualMachineError err) {
                        SystemFailure.initiateFailure(err);
                        // now, so don't let this thread continue.
                        throw err;
                    } catch (Throwable t) {
                        // Whenever you catch Error or Throwable, you must also
                        // catch VirtualMachineError (see above). However, there is
                        // _still_ a possibility that you are dealing with a cascading
                        // error condition, so you also need to check to see if the JVM
                        // is still usable:
                        SystemFailure.checkFailure();
                        logger.error(LocalizedMessage.create(LocalizedStrings.DistributedRegion_EXCEPTION_OCCURRED_IN_REGIONMEMBERSHIPLISTENER), t);
                    }
                }
            }
        }
        Set<String> allGatewaySenderIds = getAllGatewaySenderIds();
        if (!allGatewaySenderIds.isEmpty()) {
            for (GatewaySender sender : this.cache.getAllGatewaySenders()) {
                if (sender.isParallel() && allGatewaySenderIds.contains(sender.getId())) {
                    // addShadowPartitionedRegionForUserRR
                    if (sender.getId().contains(AsyncEventQueueImpl.ASYNC_EVENT_QUEUE_PREFIX)) {
                        throw new AsyncEventQueueConfigurationException(LocalizedStrings.ParallelAsyncEventQueue_0_CAN_NOT_BE_USED_WITH_REPLICATED_REGION_1.toLocalizedString(new Object[] { AsyncEventQueueImpl.getAsyncEventQueueIdFromSenderId(sender.getId()), this.getFullPath() }));
                    }
                    throw new GatewaySenderConfigurationException(LocalizedStrings.ParallelGatewaySender_0_CAN_NOT_BE_USED_WITH_REPLICATED_REGION_1.toLocalizedString(new Object[] { sender.getId(), this.getFullPath() }));
                }
            }
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) RegionMembershipListener(org.apache.geode.cache.RegionMembershipListener) CacheListener(org.apache.geode.cache.CacheListener) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 4 with AsyncEventQueueConfigurationException

use of org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException in project geode by apache.

the class AsyncEventQueueValidationsJUnitTest method testConcurrentParallelAsyncEventQueueAttributesOrderPolicyThread.

@Test
public void testConcurrentParallelAsyncEventQueueAttributesOrderPolicyThread() {
    cache = new CacheFactory().set(MCAST_PORT, "0").create();
    try {
        AsyncEventQueueFactory fact = cache.createAsyncEventQueueFactory();
        fact.setParallel(true);
        fact.setDispatcherThreads(5);
        fact.setOrderPolicy(OrderPolicy.THREAD);
        fact.create("id", new org.apache.geode.internal.cache.wan.MyAsyncEventListener());
        fail("Expected AsyncEventQueueConfigurationException.");
    } catch (AsyncEventQueueConfigurationException e) {
        assertTrue(e.getMessage().contains("can not be created with OrderPolicy"));
    }
}
Also used : AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) CacheFactory(org.apache.geode.cache.CacheFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

AsyncEventQueueConfigurationException (org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException)4 CacheFactory (org.apache.geode.cache.CacheFactory)2 AsyncEventQueueFactory (org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory)2 GatewaySender (org.apache.geode.cache.wan.GatewaySender)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 CacheListener (org.apache.geode.cache.CacheListener)1 RegionMembershipListener (org.apache.geode.cache.RegionMembershipListener)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)1 GatewaySenderConfigurationException (org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException)1 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)1 ParallelAsyncEventQueueCreation (org.apache.geode.internal.cache.xmlcache.ParallelAsyncEventQueueCreation)1 SerialAsyncEventQueueCreation (org.apache.geode.internal.cache.xmlcache.SerialAsyncEventQueueCreation)1