Search in sources :

Example 1 with SerialGatewaySenderImpl

use of org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl 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;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) SerialGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation) SerialGatewaySenderImpl(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl) ParallelGatewaySenderImpl(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderImpl) ParallelGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

Example 2 with SerialGatewaySenderImpl

use of org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl 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;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) SerialGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation) SerialGatewaySenderImpl(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl) ParallelGatewaySenderImpl(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderImpl) ParallelGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

Aggregations

GatewaySender (org.apache.geode.cache.wan.GatewaySender)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2 ParallelGatewaySenderImpl (org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderImpl)2 SerialGatewaySenderImpl (org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl)2 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)2 ParallelGatewaySenderCreation (org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation)2 SerialGatewaySenderCreation (org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation)2