Search in sources :

Example 1 with LocatorMembershipListener

use of org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener in project geode by apache.

the class WANTestBase method checkAllSiteMetaDataFor3Sites.

public static Long checkAllSiteMetaDataFor3Sites(final Map<Integer, Set<String>> dsVsPort) {
    Awaitility.await().atMost(50, TimeUnit.SECONDS).until(() -> assertEquals("System is not initialized", true, (getSystemStatic() != null)));
    List<Locator> locatorsConfigured = Locator.getLocators();
    Locator locator = locatorsConfigured.get(0);
    LocatorMembershipListener listener = ((InternalLocator) locator).getlocatorMembershipListener();
    if (listener == null) {
        fail("No locator membership listener available. WAN is likely not enabled. Is this test in the WAN project?");
    }
    final Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = listener.getAllLocatorsInfo();
    System.out.println("allSiteMetaData : " + allSiteMetaData);
    Awaitility.await().atMost(300, TimeUnit.SECONDS).until(() -> {
        assertEquals(true, (dsVsPort.size() == allSiteMetaData.size()));
        boolean completeFlag = true;
        for (Map.Entry<Integer, Set<String>> entry : dsVsPort.entrySet()) {
            Set<DistributionLocatorId> locators = allSiteMetaData.get(entry.getKey());
            for (String locatorInMetaData : entry.getValue()) {
                DistributionLocatorId locatorId = new DistributionLocatorId(locatorInMetaData);
                if (!locators.contains(locatorId)) {
                    completeFlag = false;
                    break;
                }
            }
            if (false == completeFlag) {
                break;
            }
        }
        assertEquals("Expected site Metadata: " + dsVsPort + " but actual meta data: " + allSiteMetaData, true, completeFlag);
    });
    return System.currentTimeMillis();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) LocatorMembershipListener(org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentSkipListSet (java.util.concurrent.ConcurrentSkipListSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 LocatorMembershipListener (org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener)1 Locator (org.apache.geode.distributed.Locator)1 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)1 DistributionLocatorId (org.apache.geode.internal.admin.remote.DistributionLocatorId)1