Search in sources :

Example 1 with GatewaySenderConfigurationException

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

the class SerialGatewaySenderImpl method start.

@Override
public void start() {
    if (logger.isDebugEnabled()) {
        logger.debug("Starting gatewaySender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        if (isRunning()) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_SENDER_0_IS_ALREADY_RUNNING, this.getId()));
            return;
        }
        if (this.remoteDSId != DEFAULT_DISTRIBUTED_SYSTEM_ID) {
            String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
            if (locators.length() == 0) {
                throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_LOCATOR_SHOULD_BE_CONFIGURED_BEFORE_STARTING_GATEWAY_SENDER.toLocalizedString());
            }
        }
        getSenderAdvisor().initDLockService();
        if (!isPrimary()) {
            if (getSenderAdvisor().volunteerForPrimary()) {
                getSenderAdvisor().makePrimary();
            } else {
                getSenderAdvisor().makeSecondary();
            }
        }
        if (getDispatcherThreads() > 1) {
            eventProcessor = new RemoteConcurrentSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this);
        } else {
            eventProcessor = new RemoteSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this, getId());
        }
        eventProcessor.start();
        waitForRunningStatus();
        this.startTime = System.currentTimeMillis();
        // Only notify the type registry if this is a WAN gateway queue
        if (!isAsyncEventQueue()) {
            getCache().getPdxRegistry().gatewaySenderStarted(this);
        }
        new UpdateAttributesProcessor(this).distribute(false);
        InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
        system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_START, this);
        logger.info(LocalizedMessage.create(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this));
        enqueueTempEvents();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
}
Also used : GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 2 with GatewaySenderConfigurationException

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

the class SerialAsyncEventQueueImpl method start.

@Override
public void start() {
    if (logger.isDebugEnabled()) {
        logger.debug("Starting gatewaySender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        if (isRunning()) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_SENDER_0_IS_ALREADY_RUNNING, this.getId()));
            return;
        }
        if (this.remoteDSId != DEFAULT_DISTRIBUTED_SYSTEM_ID) {
            String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
            if (locators.length() == 0) {
                throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_LOCATOR_SHOULD_BE_CONFIGURED_BEFORE_STARTING_GATEWAY_SENDER.toLocalizedString());
            }
        }
        getSenderAdvisor().initDLockService();
        if (!isPrimary()) {
            if (getSenderAdvisor().volunteerForPrimary()) {
                getSenderAdvisor().makePrimary();
            } else {
                getSenderAdvisor().makeSecondary();
            }
        }
        if (getDispatcherThreads() > 1) {
            eventProcessor = new ConcurrentSerialGatewaySenderEventProcessor(SerialAsyncEventQueueImpl.this);
        } else {
            eventProcessor = new SerialGatewaySenderEventProcessor(SerialAsyncEventQueueImpl.this, getId());
        }
        eventProcessor.start();
        waitForRunningStatus();
        this.startTime = System.currentTimeMillis();
        // Only notify the type registry if this is a WAN gateway queue
        if (!isAsyncEventQueue()) {
            getCache().getPdxRegistry().gatewaySenderStarted(this);
        }
        new UpdateAttributesProcessor(this).distribute(false);
        InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
        system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_START, this);
        logger.info(LocalizedMessage.create(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this));
        enqueueTempEvents();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
}
Also used : GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) SerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderEventProcessor)

Example 3 with GatewaySenderConfigurationException

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

the class PartitionedRegion method checkSameSenderIdsAvailableOnAllNodes.

public void checkSameSenderIdsAvailableOnAllNodes() {
    List senderIds = this.getCacheDistributionAdvisor().adviseSameGatewaySenderIds(getGatewaySenderIds());
    if (!senderIds.isEmpty()) {
        throw new GatewaySenderConfigurationException(LocalizedStrings.Region_REGION_0_HAS_1_GATEWAY_SENDER_IDS_ANOTHER_CACHE_HAS_THE_SAME_REGION_WITH_2_GATEWAY_SENDER_IDS_FOR_REGION_ACROSS_ALL_MEMBERS_IN_DS_GATEWAY_SENDER_IDS_SHOULD_BE_SAME.toLocalizedString(new Object[] { this.getName(), senderIds.get(0), senderIds.get(1) }));
    }
    List asycnQueueIds = this.getCacheDistributionAdvisor().adviseSameAsyncEventQueueIds(getVisibleAsyncEventQueueIds());
    if (!asycnQueueIds.isEmpty()) {
        throw new GatewaySenderConfigurationException(LocalizedStrings.Region_REGION_0_HAS_1_ASYNC_EVENT_QUEUE_IDS_ANOTHER_CACHE_HAS_THE_SAME_REGION_WITH_2_ASYNC_EVENT_QUEUE_IDS_FOR_REGION_ACROSS_ALL_MEMBERS_IN_DS_ASYNC_EVENT_QUEUE_IDS_SHOULD_BE_SAME.toLocalizedString(new Object[] { this.getName(), asycnQueueIds.get(0), asycnQueueIds.get(1) }));
    }
}
Also used : GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with GatewaySenderConfigurationException

use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException 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 5 with GatewaySenderConfigurationException

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

the class RemoteParallelGatewaySenderEventProcessor method shouldSendVersionEvents.

/**
   * Returns if corresponding receiver WAN site of this GatewaySender has GemfireVersion > 7.0.1
   * 
   * @param disp
   * @return true if remote site Gemfire Version is >= 7.0.1
   */
private boolean shouldSendVersionEvents(GatewaySenderEventDispatcher disp) throws GatewaySenderException {
    try {
        GatewaySenderEventRemoteDispatcher remoteDispatcher = (GatewaySenderEventRemoteDispatcher) disp;
        // This will create a new connection if no batch has been sent till
        // now.
        Connection conn = remoteDispatcher.getConnection(false);
        if (conn != null) {
            short remoteSiteVersion = conn.getWanSiteVersion();
            if (Version.GFE_701.compareTo(remoteSiteVersion) <= 0) {
                return true;
            }
        }
    } catch (GatewaySenderException e) {
        Throwable cause = e.getCause();
        if (cause instanceof IOException || e instanceof GatewaySenderConfigurationException || cause instanceof ConnectionDestroyedException) {
            try {
                int sleepInterval = GatewaySender.CONNECTION_RETRY_INTERVAL;
                if (logger.isDebugEnabled()) {
                    logger.debug("Sleeping for {} milliseconds", sleepInterval);
                }
                Thread.sleep(sleepInterval);
            } catch (InterruptedException ie) {
                // log the exception
                if (logger.isDebugEnabled()) {
                    logger.debug(ie.getMessage(), ie);
                }
            }
        }
        throw e;
    }
    return false;
}
Also used : GatewaySenderEventRemoteDispatcher(org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) Connection(org.apache.geode.cache.client.internal.Connection) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) IOException(java.io.IOException) ConnectionDestroyedException(org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException)

Aggregations

GatewaySenderConfigurationException (org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException)5 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2 UpdateAttributesProcessor (org.apache.geode.internal.cache.UpdateAttributesProcessor)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 CacheListener (org.apache.geode.cache.CacheListener)1 RegionMembershipListener (org.apache.geode.cache.RegionMembershipListener)1 Connection (org.apache.geode.cache.client.internal.Connection)1 ConnectionDestroyedException (org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException)1 GatewaySender (org.apache.geode.cache.wan.GatewaySender)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)1 AsyncEventQueueConfigurationException (org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException)1