Search in sources :

Example 1 with GatewaySenderEventRemoteDispatcher

use of org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher 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)

Example 2 with GatewaySenderEventRemoteDispatcher

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

the class RemoteParallelGatewaySenderEventProcessor method rebalance.

@Override
protected void rebalance() {
    GatewaySenderStats statistics = this.sender.getStatistics();
    long startTime = statistics.startLoadBalance();
    try {
        if (this.dispatcher.isRemoteDispatcher()) {
            GatewaySenderEventRemoteDispatcher remoteDispatcher = (GatewaySenderEventRemoteDispatcher) this.dispatcher;
            if (remoteDispatcher.isConnectedToRemote()) {
                remoteDispatcher.stopAckReaderThread();
                remoteDispatcher.destroyConnection();
            }
        }
    } finally {
        statistics.endLoadBalance(startTime);
    }
}
Also used : GatewaySenderStats(org.apache.geode.internal.cache.wan.GatewaySenderStats) GatewaySenderEventRemoteDispatcher(org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher)

Example 3 with GatewaySenderEventRemoteDispatcher

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

the class RemoteConcurrentParallelGatewaySenderEventProcessor method rebalance.

@Override
protected void rebalance() {
    GatewaySenderStats statistics = this.sender.getStatistics();
    long startTime = statistics.startLoadBalance();
    try {
        for (ParallelGatewaySenderEventProcessor parallelProcessor : this.processors) {
            GatewaySenderEventRemoteDispatcher remoteDispatcher = (GatewaySenderEventRemoteDispatcher) parallelProcessor.getDispatcher();
            if (remoteDispatcher.isConnectedToRemote()) {
                remoteDispatcher.stopAckReaderThread();
                remoteDispatcher.destroyConnection();
            }
        }
    } finally {
        statistics.endLoadBalance(startTime);
    }
}
Also used : GatewaySenderStats(org.apache.geode.internal.cache.wan.GatewaySenderStats) GatewaySenderEventRemoteDispatcher(org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher) ParallelGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderEventProcessor)

Aggregations

GatewaySenderEventRemoteDispatcher (org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher)3 GatewaySenderStats (org.apache.geode.internal.cache.wan.GatewaySenderStats)2 IOException (java.io.IOException)1 Connection (org.apache.geode.cache.client.internal.Connection)1 ConnectionDestroyedException (org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException)1 GatewaySenderConfigurationException (org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException)1 GatewaySenderException (org.apache.geode.internal.cache.wan.GatewaySenderException)1 ParallelGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderEventProcessor)1