use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.
the class SingleHopStatsDUnitTest method createPR.
private void createPR(String fromClient, boolean colocated) {
GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
Region region = cache.getRegion(Region_Name);
if (!colocated) {
if (fromClient.equals("FirstClient")) {
System.out.println("first pass...");
for (int i = 0; i < 113; i++) {
region.create(i, "create" + i);
}
ClientMetadataService cms = cache.getClientMetadataService();
final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
assertEquals(0, regionMetaData.size());
System.out.println("second pass...");
for (int i = 113; i < 226; i++) {
region.create(i, "create" + i);
}
cms = ((GemFireCacheImpl) cache).getClientMetadataService();
// since PR metadata is fetched in a background executor thread
// we need to wait for it to arrive for a bit
Awaitility.await().timeout(120, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).pollInterval(500, TimeUnit.MILLISECONDS).until(() -> regionMetaData.size() == 1);
assertTrue(regionMetaData.containsKey(region.getFullPath()));
regionMetaData.get(region.getFullPath());
metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
// hops are not predictable
assertTrue(metaDataRefreshCount != 0);
System.out.println("metadata refresh count after second pass is " + metaDataRefreshCount);
} else {
System.out.println("creating keys in second client");
for (int i = 0; i < 226; i++) {
region.create(i, "create" + i);
}
ClientMetadataService cms = cache.getClientMetadataService();
Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
assertEquals(1, regionMetaData.size());
assertTrue(regionMetaData.containsKey(region.getFullPath()));
regionMetaData.get(region.getFullPath());
metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
// hops are not predictable
assertTrue(metaDataRefreshCount != 0);
System.out.println("metadata refresh count in second client is " + metaDataRefreshCount);
}
} else {
createdColocatedPRData(cache);
}
}
use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.
the class SingleHopStatsDUnitTest method getPR.
private void getPR(String FromClient, boolean colocated) {
Cache cache = CacheFactory.getAnyInstance();
Region region = cache.getRegion(Region_Name);
Region customerRegion = cache.getRegion(CUSTOMER_REGION_NAME);
Region orderRegion = cache.getRegion(ORDER_REGION_NAME);
Region shipmentRegion = cache.getRegion("SHIPMENT");
if (!colocated) {
for (int i = 0; i < 226; i++) {
region.get(i);
}
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
assertEquals(1, regionMetaData.size());
regionMetaData.get(region.getFullPath());
assertEquals(metaDataRefreshCount, ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
} else {
for (int i = 0; i <= 20; i++) {
CustId custid = new CustId(i);
customerRegion.get(custid);
for (int j = 1; j <= 10; j++) {
int oid = (i * 10) + j;
OrderId orderId = new OrderId(oid, custid);
orderRegion.get(orderId);
for (int k = 1; k <= 10; k++) {
int sid = (oid * 10) + k;
ShipmentId shipmentId = new ShipmentId(sid, orderId);
shipmentRegion.get(shipmentId);
}
}
}
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
assertEquals(3, regionMetaData.size());
assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
regionMetaData.get(customerRegion.getFullPath());
assertEquals(metaDataRefreshCount_Customer, ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount());
regionMetaData.get(orderRegion.getFullPath());
assertEquals(metaDataRefreshCount_Order, ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount());
regionMetaData.get(shipmentRegion.getFullPath());
assertEquals(metaDataRefreshCount_Shipment, ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount());
}
}
use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.
the class FunctionServiceClientAccessorPRMultipleMembersDUnitTest method createRegions.
@Override
public void createRegions() {
super.createRegions();
// Make sure the client is consistently using singlehop by proactively getting
// the server location metadata.
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
ClientMetadataService clientMetadataService = cache.getClientMetadataService();
clientMetadataService.getClientPRMetadata((LocalRegion) region);
}
use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.
the class PartitionedRegionSingleHopWithServerGroupDUnitTest method verifyMetadataFor2ClientsInOneVM.
public static void verifyMetadataFor2ClientsInOneVM(final int numRegions, final int numBucketLocations, final int numBucketLocations2) {
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() + " they are " + regionMetaData.keySet();
}
};
Wait.waitForCriterion(wc, 120000, 1000, true);
if (numRegions != 0) {
assertTrue(regionMetaData.containsKey(region.getFullPath()));
ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
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());
}
assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
prMetaData = regionMetaData.get(customerRegion.getFullPath());
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());
}
assertTrue(regionMetaData.containsKey(customerRegion2.getFullPath()));
prMetaData = regionMetaData.get(customerRegion2.getFullPath());
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(numBucketLocations2, ((List) entry.getValue()).size());
}
}
}
use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.
the class Shipment method verifyMetadata.
private void verifyMetadata() {
ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
// make sure all fetch tasks are completed
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.getRefreshTaskCount() == 0);
// final Map<String, ClientPartitionAdvisor> regionMetaData = cms
// .getClientPRMetadata_TEST_ONLY();
// Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() == 4));
// assertEquals(4, regionMetaData.size());
// 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