use of org.apache.geode.distributed.Locator in project geode by apache.
the class WANTestBase method checkAllSiteMetaData.
public static void checkAllSiteMetaData(Map<Integer, Set<InetSocketAddress>> dsIdToLocatorAddresses) {
List<Locator> locatorsConfigured = Locator.getLocators();
Locator locator = locatorsConfigured.get(0);
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> {
Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator) locator).getlocatorMembershipListener().getAllLocatorsInfo();
for (Map.Entry<Integer, Set<InetSocketAddress>> entry : dsIdToLocatorAddresses.entrySet()) {
Set<DistributionLocatorId> foundLocatorIds = allSiteMetaData.get(entry.getKey());
Set<InetSocketAddress> expectedLocators = entry.getValue();
final Set<InetSocketAddress> foundLocators = foundLocatorIds.stream().map(distributionLocatorId -> new InetSocketAddress(distributionLocatorId.getHostnameForClients(), distributionLocatorId.getPort())).collect(Collectors.toSet());
assertEquals(expectedLocators, foundLocators);
}
});
}
use of org.apache.geode.distributed.Locator 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();
}
use of org.apache.geode.distributed.Locator in project geode by apache.
the class MemberCommandsDUnitTest method testListMemberWithNoCache.
/**
* Tests the execution of "list member" command, when no cache is created
*
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
public void testListMemberWithNoCache() throws IOException, ClassNotFoundException {
final Host host = Host.getHost(0);
final VM[] servers = { host.getVM(0), host.getVM(1) };
final int[] openPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1);
final File logFile = new File(getUniqueName() + "-locator" + openPorts[0] + ".log");
Locator locator = Locator.startLocator(openPorts[0], logFile);
try {
final Properties props = createProperties(host, openPorts[0]);
CommandProcessor commandProcessor = new CommandProcessor();
Result result = commandProcessor.createCommandStatement(CliStrings.LIST_MEMBER, EMPTY_ENV).process();
getLogWriter().info("#SB" + getResultAsString(result));
assertEquals(true, result.getStatus().equals(Status.ERROR));
} finally {
// fix for bug 46562
locator.stop();
}
}
Aggregations