Search in sources :

Example 1 with ClientServerObserverAdapter

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

the class HAInterestTestCase method setClientServerObserverForBeforeRegistration.

public static void setClientServerObserverForBeforeRegistration(final VM vm) {
    PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = true;
    ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

        public void beforeInterestRegistration() {
            synchronized (HAInterestTestCase.class) {
                vm.invoke(() -> HAInterestTestCase.startServer());
                HAInterestTestCase.isBeforeRegistrationCallbackCalled = true;
                HAInterestTestCase.class.notify();
                PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
            }
        }
    });
}
Also used : ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter)

Example 2 with ClientServerObserverAdapter

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

the class HAStartupAndFailoverDUnitTest method setClientServerObserver.

public static void setClientServerObserver() {
    PoolImpl.AFTER_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = true;
    ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

        public void afterPrimaryIdentificationFromBackup(ServerLocation primaryEndpoint) {
            synchronized (HAStartupAndFailoverDUnitTest.class) {
                HAStartupAndFailoverDUnitTest.identifiedPrimary = true;
                HAStartupAndFailoverDUnitTest.class.notify();
            }
        }
    });
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter)

Example 3 with ClientServerObserverAdapter

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

the class HAInterestTestCase method setClientServerObserverForBeforeInterestRecovery.

public static void setClientServerObserverForBeforeInterestRecovery() {
    PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
    ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

        public void beforeInterestRecovery() {
            synchronized (HAInterestTestCase.class) {
                Thread t = new Thread() {

                    public void run() {
                        Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
                        assertNotNull(r1);
                        r1.put(k1, server_k1_updated);
                    }
                };
                t.start();
                HAInterestTestCase.isBeforeInterestRecoveryCallbackCalled = true;
                HAInterestTestCase.class.notify();
                PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
            }
        }
    });
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter)

Example 4 with ClientServerObserverAdapter

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

the class HAInterestTestCase method setClientServerObserverForBeforeInterestRecoveryFailure.

public static void setClientServerObserverForBeforeInterestRecoveryFailure() {
    PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
    ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

        public void beforeInterestRecovery() {
            synchronized (HAInterestTestCase.class) {
                Thread t = new Thread() {

                    public void run() {
                        getBackupVM().invoke(() -> HAInterestTestCase.startServer());
                        getPrimaryVM().invoke(() -> HAInterestTestCase.stopServer());
                    }
                };
                t.start();
                try {
                    ThreadUtils.join(t, 30 * 1000);
                } catch (Exception ignore) {
                    exceptionOccurred = true;
                }
                HAInterestTestCase.isBeforeInterestRecoveryCallbackCalled = true;
                HAInterestTestCase.class.notify();
                PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
            }
        }
    });
}
Also used : ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter) IOException(java.io.IOException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 5 with ClientServerObserverAdapter

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

the class ConflationDUnitTest method setClientServerObserverForBeforeInterestRecovery.

/**
   * reset all counters to zero before interest recovery
   *
   */
public static void setClientServerObserverForBeforeInterestRecovery() {
    PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
    ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {

        public void beforeInterestRecovery() {
            setAllCountersZero();
        }
    });
}
Also used : ClientServerObserverAdapter(org.apache.geode.internal.cache.ClientServerObserverAdapter)

Aggregations

ClientServerObserverAdapter (org.apache.geode.internal.cache.ClientServerObserverAdapter)22 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)5 EventID (org.apache.geode.internal.cache.EventID)4 Region (org.apache.geode.cache.Region)2 ClientServerObserver (org.apache.geode.internal.cache.ClientServerObserver)2 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Properties (java.util.Properties)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 PoolImpl (org.apache.geode.cache.client.internal.PoolImpl)1 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1