use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class Shipment method testMetadataFetchOnlyThroughFunctions.
@Test
public void testMetadataFetchOnlyThroughFunctions() throws Exception {
// Workaround for 52004
IgnoredException.addIgnoredException("InternalFunctionInvocationTargetException");
Integer port0 = (Integer) member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(3, 4));
Integer port1 = (Integer) member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(3, 4));
Integer port2 = (Integer) member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(3, 4));
Integer port3 = (Integer) member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(3, 4));
createClient(port0, port1, port2, port3);
executeFunctions();
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> regionMetaData.size() == 1);
assertEquals(1, regionMetaData.size());
assertTrue(regionMetaData.containsKey(region.getFullPath()));
final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
// Fixes a race condition in GEODE-414 by retrying as
// region.clientMetaDataLock.tryLock() may prevent fetching the
// metadata through functional calls as only limited functions are executed in the test.
long start = System.currentTimeMillis();
do {
if ((prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() != 4)) {
// waiting if there is another thread holding the lock
Thread.sleep(1000);
cms.getClientPRMetadata((LocalRegion) region);
} else {
break;
}
} while (System.currentTimeMillis() - start < 60000);
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4));
// assertIndexDetailsEquals(4/*numBuckets*/,
// prMetaData.getBucketServerLocationsMap_TEST_ONLY().size());
}
Aggregations