Search in sources :

Example 1 with ClientServerObserver

use of org.apache.geode.internal.cache.ClientServerObserver in project geode by apache.

the class ServerRegionProxy method registerInterestList.

/**
   * Does a region registerInterestList on a server
   * 
   * @param keys list of keys we are interested in
   * @param policy the interest result policy for this registration
   * @param isDurable true if this registration is durable
   * @param regionDataPolicy the data policy ordinal of the region
   * @return list of keys
   */
public List registerInterestList(List keys, InterestResultPolicy policy, boolean isDurable, boolean receiveUpdatesAsInvalidates, final byte regionDataPolicy) {
    final RegisterInterestTracker rit = this.pool.getRITracker();
    List result = null;
    boolean finished = false;
    try {
        // register with the tracker early
        rit.addInterestList(this.region, keys, policy, isDurable, receiveUpdatesAsInvalidates);
        result = RegisterInterestListOp.execute(this.pool, this.regionName, keys, policy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
        finished = true;
        //////// TEST PURPOSE ONLY ///////////
        if (PoolImpl.AFTER_REGISTER_CALLBACK_FLAG) {
            ClientServerObserver bo = ClientServerObserverHolder.getInstance();
            bo.afterInterestRegistration();
        }
        /////////////////////////////////////////
        return result;
    } finally {
        if (!finished) {
            rit.removeInterestList(this.region, keys, isDurable, receiveUpdatesAsInvalidates);
        }
    }
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List)

Example 2 with ClientServerObserver

use of org.apache.geode.internal.cache.ClientServerObserver in project geode by apache.

the class QueueManagerImpl method recoverAllInterestTypes.

protected void recoverAllInterestTypes(final Connection recoveredConnection, boolean isFirstNewConnection) {
    if (PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG) {
        ClientServerObserver bo = ClientServerObserverHolder.getInstance();
        bo.beforeInterestRecovery();
    }
    recoverInterestList(recoveredConnection, false, true, isFirstNewConnection);
    recoverInterestList(recoveredConnection, false, false, isFirstNewConnection);
    recoverCqs(recoveredConnection, false);
    if (getPool().isDurableClient()) {
        recoverInterestList(recoveredConnection, true, true, isFirstNewConnection);
        recoverInterestList(recoveredConnection, true, false, isFirstNewConnection);
        recoverCqs(recoveredConnection, true);
    }
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver)

Example 3 with ClientServerObserver

use of org.apache.geode.internal.cache.ClientServerObserver in project geode by apache.

the class QueueManagerImpl method recoverPrimary.

/**
   * Find a new primary, adding any failed servers we encounter to the excluded servers list
   * 
   * First we try to make a backup server the primary, but if run out of backup servers we will try
   * to find a new server.
   */
protected void recoverPrimary(Set excludedServers) {
    if (pool.getPoolOrCacheCancelInProgress() != null) {
        return;
    }
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (queueConnections.getPrimary() != null) {
        if (isDebugEnabled) {
            logger.debug("Primary recovery not needed");
        }
        return;
    }
    if (isDebugEnabled) {
        logger.debug("SubscriptionManager redundancy satisfier - primary endpoint has been lost. Attempting to recover");
    }
    if (printRecoveringPrimary) {
        logger.info(LocalizedMessage.create(LocalizedStrings.QueueManagerImpl_SUBSCRIPTION_MANAGER_REDUNDANCY_SATISFIER_PRIMARY_ENDPOINT_HAS_BEEN_LOST_ATTEMPTIMG_TO_RECOVER));
        printRecoveringPrimary = false;
    }
    QueueConnectionImpl newPrimary = null;
    while (newPrimary == null && pool.getPoolOrCacheCancelInProgress() == null) {
        List backups = queueConnections.getBackups();
        newPrimary = promoteBackupToPrimary(backups);
        // Hitesh now lets say that server crashed
        if (newPrimary == null) {
            // could not find a backup to promote
            break;
        }
        if (!addToConnectionList(newPrimary, true)) {
            synchronized (lock) {
                // make sure we don't retry the same backup server
                queueConnections = queueConnections.removeConnection(newPrimary);
            }
            newPrimary = null;
        }
    }
    if (newPrimary != null) {
        if (isDebugEnabled) {
            logger.debug("SubscriptionManager redundancy satisfier - Switched backup server to primary: {}", newPrimary.getEndpoint());
        }
        if (PoolImpl.AFTER_PRIMARY_RECOVERED_CALLBACK_FLAG) {
            ClientServerObserver bo = ClientServerObserverHolder.getInstance();
            bo.afterPrimaryRecovered(newPrimary.getServer());
        }
        // new primary from back up server was found, alert affected cqs if necessary
        cqsConnected();
        printPrimaryNotFoundError = true;
        printRecoveringPrimary = true;
        return;
    }
    while (newPrimary == null) {
        newPrimary = createNewPrimary(excludedServers);
        if (newPrimary == null) {
            // could not find a new primary to create
            break;
        }
        if (!addToConnectionList(newPrimary, true)) {
            excludedServers.add(newPrimary.getServer());
            newPrimary = null;
        }
        if (newPrimary != null) {
            if (isDebugEnabled) {
                logger.debug("SubscriptionManager redundancy satisfier - Non backup server was made primary. Recovering interest {}", newPrimary.getEndpoint());
            }
            if (!recoverInterest(newPrimary, true)) {
                excludedServers.add(newPrimary.getServer());
                newPrimary = null;
            }
            // New primary queue was found from a non backup, alert the affected cqs
            cqsConnected();
        }
        if (newPrimary != null && PoolImpl.AFTER_PRIMARY_RECOVERED_CALLBACK_FLAG) {
            ClientServerObserver bo = ClientServerObserverHolder.getInstance();
            bo.afterPrimaryRecovered(newPrimary.getServer());
        }
        printPrimaryNotFoundError = true;
        printRecoveringPrimary = true;
        return;
    }
    // No primary queue was found, alert the affected cqs
    cqsDisconnected();
    if (isDebugEnabled) {
        logger.debug("SubscriptionManager redundancy satisfier - Could not recover a new primary");
    }
    synchronized (lock) {
        queueConnections = queueConnections.setPrimaryDiscoveryFailed(null);
        lock.notifyAll();
    }
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Example 4 with ClientServerObserver

use of org.apache.geode.internal.cache.ClientServerObserver in project geode by apache.

the class DurableClientSimpleDUnitTest method setPeriodicACKObserver.

private void setPeriodicACKObserver(VM vm) {
    CacheSerializableRunnable cacheSerializableRunnable = new CacheSerializableRunnable("Set ClientServerObserver") {

        @Override
        public void run2() throws CacheException {
            PoolImpl.BEFORE_SENDING_CLIENT_ACK_CALLBACK_FLAG = true;
            ClientServerObserver origObserver = ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

                @Override
                public void beforeSendingClientAck() {
                    LogWriterUtils.getLogWriter().info("beforeSendingClientAck invoked");
                }
            });
        }
    };
    vm.invoke(cacheSerializableRunnable);
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter)

Example 5 with ClientServerObserver

use of org.apache.geode.internal.cache.ClientServerObserver in project geode by apache.

the class ServerRegionProxy method registerInterest.

/**
   * Does a region registerInterest on a server
   * 
   * @param key describes what we are interested in
   * @param interestType the {@link InterestType} for this registration
   * @param policy the interest result policy for this registration
   * @param isDurable true if this registration is durable
   * @param receiveUpdatesAsInvalidates whether to act like notify-by-subscription is false.
   * @param regionDataPolicy the data policy ordinal of the region
   * @return list of keys
   */
public List registerInterest(final Object key, final int interestType, final InterestResultPolicy policy, final boolean isDurable, final boolean receiveUpdatesAsInvalidates, final byte regionDataPolicy) {
    if (interestType == InterestType.KEY && key instanceof List) {
        return registerInterestList((List) key, policy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
    } else {
        final RegisterInterestTracker rit = this.pool.getRITracker();
        List result = null;
        boolean finished = false;
        try {
            // register with the tracker early
            rit.addSingleInterest(this.region, key, interestType, policy, isDurable, receiveUpdatesAsInvalidates);
            result = RegisterInterestOp.execute(this.pool, this.regionName, key, interestType, policy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
            //////// TEST PURPOSE ONLY ///////////
            if (PoolImpl.AFTER_REGISTER_CALLBACK_FLAG) {
                ClientServerObserver bo = ClientServerObserverHolder.getInstance();
                bo.afterInterestRegistration();
            }
            /////////////////////////////////////////
            finished = true;
            return result;
        } finally {
            if (!finished) {
                rit.removeSingleInterest(this.region, key, interestType, isDurable, receiveUpdatesAsInvalidates);
            }
        }
    }
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List)

Aggregations

ClientServerObserver (org.apache.geode.internal.cache.ClientServerObserver)11 CancelException (org.apache.geode.CancelException)4 GemFireSecurityException (org.apache.geode.security.GemFireSecurityException)4 IOException (java.io.IOException)3 InterruptedIOException (java.io.InterruptedIOException)3 ConnectException (java.net.ConnectException)3 SocketException (java.net.SocketException)3 List (java.util.List)3 SSLException (javax.net.ssl.SSLException)3 InvalidDeltaException (org.apache.geode.InvalidDeltaException)3 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)3 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)3 ServerRefusedConnectionException (org.apache.geode.cache.client.ServerRefusedConnectionException)3 Endpoint (org.apache.geode.cache.client.internal.Endpoint)3 ConcurrentCacheModificationException (org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException)3 AuthenticationFailedException (org.apache.geode.security.AuthenticationFailedException)3 AuthenticationRequiredException (org.apache.geode.security.AuthenticationRequiredException)3 ClientServerObserverAdapter (org.apache.geode.internal.cache.ClientServerObserverAdapter)2 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)2 ArrayList (java.util.ArrayList)1