use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class PartitionedRegionSingleHopWithServerGroupDUnitTest method verifyMetadata.
public static void verifyMetadata(final int numRegions, final int numBucketLocations) {
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
if (regionMetaData.size() == numRegions) {
return true;
}
return false;
}
public String description() {
return "expected metadata for each region to be" + numRegions + " but it is " + regionMetaData.size() + "Metadata is " + regionMetaData.keySet();
}
};
Wait.waitForCriterion(wc, 60000, 1000, true);
if (numRegions != 0) {
assertTrue(regionMetaData.containsKey(region.getFullPath()));
ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
if (cache.getLogger().fineEnabled()) {
for (Entry e : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
cache.getLogger().fine("For bucket id " + e.getKey() + " the locations are " + e.getValue());
}
}
for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
assertEquals(numBucketLocations, ((List) entry.getValue()).size());
}
}
}
use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class Shipment method verifyDeadServer.
private void verifyDeadServer(Map<String, ClientPartitionAdvisor> regionMetaData, Region region, int port0, int port1) {
ServerLocation sl0 = new ServerLocation("localhost", port0);
ServerLocation sl1 = new ServerLocation("localhost", port1);
final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
List servers = (List) entry.getValue();
assertFalse(servers.contains(sl0));
assertFalse(servers.contains(sl1));
}
}
use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class Shipment method testServerLocationRemovalThroughPing.
// GEODE-853: random ports, pause sleeps, time sensitive, 5 second
@Category(FlakyTest.class)
// thread sleeps
@Test
public void testServerLocationRemovalThroughPing() {
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);
putIntoPartitionedRegions();
getFromPartitionedRegions();
Wait.pause(5000);
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
assertEquals(4, regionMetaData.size());
assertTrue(regionMetaData.containsKey(region.getFullPath()));
assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
assertTrue(regionMetaData.containsKey(orderRegion.getFullPath()));
assertTrue(regionMetaData.containsKey(shipmentRegion.getFullPath()));
ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
assertEquals(4, /* numBuckets */
prMetaData.getBucketServerLocationsMap_TEST_ONLY().size());
for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
assertEquals(4, ((List) entry.getValue()).size());
}
member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
// make sure that ping detects the dead servers
Wait.pause(5000);
getFromPartitionedRegions();
verifyDeadServer(regionMetaData, customerRegion, port0, port1);
verifyDeadServer(regionMetaData, region, port0, port1);
}
use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class Shipment method testMetadataIsSameOnAllServersAndClientsHA.
@Test
public void testMetadataIsSameOnAllServersAndClientsHA() {
Integer port0 = (Integer) member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(2, 4));
Integer port1 = (Integer) member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(2, 4));
createClient(port0, port1, port0, port1);
put();
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
cms.getClientPRMetadata((LocalRegion) region);
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()));
member0.invoke(new CacheSerializableRunnable("aba") {
@Override
public void run2() throws CacheException {
final PartitionedRegion pr = (PartitionedRegion) region;
ConcurrentHashMap<Integer, Set<ServerBucketProfile>> serverMap = pr.getRegionAdvisor().getAllClientBucketProfilesTest();
}
});
member1.invoke(new CacheSerializableRunnable("aba") {
@Override
public void run2() throws CacheException {
final PartitionedRegion pr = (PartitionedRegion) region;
ConcurrentHashMap<Integer, Set<ServerBucketProfile>> serverMap = pr.getRegionAdvisor().getAllClientBucketProfilesTest();
}
});
ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
final Map<Integer, List<BucketServerLocation66>> clientMap = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (clientMap.size() == 4));
for (Entry entry : clientMap.entrySet()) {
assertEquals(2, ((List) entry.getValue()).size());
}
member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
put();
cms = ((GemFireCacheImpl) cache).getClientMetadataService();
cms.getClientPRMetadata((LocalRegion) region);
// member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
assertEquals(4, /* numBuckets */
clientMap.size());
for (Entry entry : clientMap.entrySet()) {
assertEquals(1, ((List) entry.getValue()).size());
}
assertEquals(1, regionMetaData.size());
assertTrue(regionMetaData.containsKey(region.getFullPath()));
assertEquals(4, /* numBuckets */
clientMap.size());
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> {
int bucketId = -1;
int size = -1;
List globalList = new ArrayList();
boolean finished = true;
for (Entry entry : clientMap.entrySet()) {
List list = (List) entry.getValue();
if (list.size() != 1) {
size = list.size();
globalList = list;
bucketId = (Integer) entry.getKey();
finished = false;
System.out.println("bucket copies are not created, the locations size for bucket id : " + bucketId + " size : " + size + " the list is " + globalList);
}
}
return finished;
});
}
use of org.apache.geode.cache.client.internal.ClientPartitionAdvisor in project geode by apache.
the class Shipment method testMetadataFetchOnlyThroughputAll.
@Test
public void testMetadataFetchOnlyThroughputAll() {
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);
putAll();
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() == 1));
assertTrue(regionMetaData.containsKey(region.getFullPath()));
final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4));
}
Aggregations