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"));
}
}
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;
}
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() }));
}
}
}
}
}
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"));
}
}
Aggregations