use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class MyGatewayEventSubstitutionFilter method setRemoveFromQueueOnException.
public static void setRemoveFromQueueOnException(String senderId, boolean removeFromQueue) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
assertNotNull(sender);
((AbstractGatewaySender) sender).setRemoveFromQueueOnException(removeFromQueue);
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class CacheXml80GatewayDUnitTest method testGatewaySenderWithSubstitutionFilter.
@Test
public void testGatewaySenderWithSubstitutionFilter() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
// Create a GatewaySender with GatewayEventSubstitutionFilter.
// Don't start the sender to avoid 'Locators must be configured before starting gateway-sender'
// exception.
String id = getName();
GatewaySenderFactory factory = cache.createGatewaySenderFactory();
factory.setManualStart(true);
factory.setGatewayEventSubstitutionFilter(new MyGatewayEventSubstitutionFilter());
GatewaySender sender = factory.create(id, 2);
// Verify the GatewayEventSubstitutionFilter is set on the GatewaySender.
assertNotNull(sender.getGatewayEventSubstitutionFilter());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
// Get the GatewaySender. Verify the GatewayEventSubstitutionFilter is not null.
GatewaySender senderOnCache = c.getGatewaySender(id);
assertNotNull(senderOnCache);
assertNotNull(senderOnCache.getGatewayEventSubstitutionFilter());
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class GatewaySenderFactoryImpl method create.
public 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 ParallelGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new ParallelGatewaySenderCreation(this.cache, this.attrs);
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 SerialGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new SerialGatewaySenderCreation(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
}
}
return sender;
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class GatewaySenderFactoryImpl method create.
public GatewaySender create(String id, int remoteDSId) {
int myDSId = InternalDistributedSystem.getAnyInstance().getDistributionManager().getDistributedSystemId();
if (remoteDSId == myDSId) {
throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_0_CANNOT_BE_CREATED_WITH_REMOTE_SITE_ID_EQUAL_TO_THIS_SITE_ID.toLocalizedString(id));
}
if (remoteDSId < 0) {
throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_0_CANNOT_BE_CREATED_WITH_REMOTE_SITE_ID_LESS_THAN_ZERO.toLocalizedString(id));
}
this.attrs.id = id;
this.attrs.remoteDs = remoteDSId;
GatewaySender sender = null;
if (this.attrs.getDispatcherThreads() <= 0) {
throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_SENDER_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
}
// Verify socket read timeout if a proper logger is available
if (this.cache instanceof GemFireCacheImpl) {
// were failing, and we were running out of time to change them.
if (this.attrs.getSocketReadTimeout() != 0 && this.attrs.getSocketReadTimeout() < GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT) {
logger.warn(LocalizedMessage.create(LocalizedStrings.Gateway_CONFIGURED_SOCKET_READ_TIMEOUT_TOO_LOW, new Object[] { "GatewaySender " + id, this.attrs.getSocketReadTimeout(), GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT }));
this.attrs.socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT;
}
// Log a warning if the old system property is set.
if (GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY_CHECKED.compareAndSet(false, true)) {
if (System.getProperty(GatewaySender.GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY) != null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.Gateway_OBSOLETE_SYSTEM_POPERTY, new Object[] { GatewaySender.GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY, "GatewaySender socket read timeout" }));
}
}
}
if (this.attrs.isParallel()) {
if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_PARALLEL_GATEWAY_SENDER_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
}
if (this.cache instanceof GemFireCacheImpl) {
sender = new ParallelGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new ParallelGatewaySenderCreation(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
}
} else {
if (this.attrs.getAsyncEventListeners().size() > 0) {
throw new GatewaySenderException(LocalizedStrings.SerialGatewaySenderImpl_GATEWAY_0_CANNOT_DEFINE_A_REMOTE_SITE_BECAUSE_AT_LEAST_ONE_LISTENER_IS_ALREADY_ADDED.toLocalizedString(id));
}
if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
}
if (this.cache instanceof GemFireCacheImpl) {
sender = new SerialGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new SerialGatewaySenderCreation(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
}
}
return sender;
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class WANTestBase method validateQueueClosedForConcurrentSerialGatewaySender.
// Ensure that the sender's queue(s) have been closed.
public static void validateQueueClosedForConcurrentSerialGatewaySender(final String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
final Set<RegionQueue> regionQueue;
if (sender instanceof AbstractGatewaySender) {
regionQueue = ((AbstractGatewaySender) sender).getQueuesForConcurrentSerialGatewaySender();
} else {
regionQueue = null;
}
assertEquals(null, regionQueue);
}
Aggregations