Search in sources :

Example 16 with ClientMetadataService

use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.

the class FixedPRSinglehopDUnitTest method verifyMetadata.

private void verifyMetadata(final int totalBuckets, int currentRedundancy) {
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
    WaitCriterion wc = new WaitCriterion() {

        public boolean done() {
            return (regionMetaData.size() == 1);
        }

        public String description() {
            return "expected no metadata to be refreshed";
        }
    };
    Wait.waitForCriterion(wc, 60000, 1000, true);
    assertTrue(regionMetaData.containsKey(region.getFullPath()));
    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
    wc = new WaitCriterion() {

        public boolean done() {
            return (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == totalBuckets);
        }

        public String description() {
            return "expected no metadata to be refreshed.  Expected " + totalBuckets + " entries but found " + prMetaData.getBucketServerLocationsMap_TEST_ONLY();
        }
    };
    Wait.waitForCriterion(wc, 60000, 1000, true);
    System.out.println("metadata is " + prMetaData);
    System.out.println("metadata bucket locations map is " + prMetaData.getBucketServerLocationsMap_TEST_ONLY());
    for (Map.Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
        assertEquals("list has wrong contents: " + entry.getValue(), currentRedundancy, ((List) entry.getValue()).size());
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) ClientPartitionAdvisor(org.apache.geode.cache.client.internal.ClientPartitionAdvisor) Map(java.util.Map)

Example 17 with ClientMetadataService

use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.

the class FixedPRSinglehopDUnitTest method updateIntoSinglePR.

public static void updateIntoSinglePR(boolean assertNoMetadataRefreshes) {
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(q1dateJan1, "update0");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q1dateFeb1, "update00");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q1dateMar1, "update000");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q2dateApr1, "update1");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q2dateMay1, "update11");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q2dateJun1, "update111");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q3dateJuly1, "update2");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q3dateAug1, "update22");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q3dateSep1, "update2222");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q4dateOct1, "update3");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q4dateNov1, "update33");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
    region.put(q4dateDec1, "update3333");
    if (assertNoMetadataRefreshes) {
        assertFalse(cms.isRefreshMetadataTestOnly());
    }
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService)

Example 18 with ClientMetadataService

use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.

the class FixedPRSinglehopDUnitTest method updateIntoSinglePRFor3Qs.

public static void updateIntoSinglePRFor3Qs() {
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(q1dateJan1, "update0");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q1dateFeb1, "update00");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q1dateMar1, "update000");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q2dateApr1, "update1");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q2dateMay1, "update11");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q2dateJun1, "update111");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q3dateJuly1, "update2");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q3dateAug1, "update22");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
    region.put(q3dateSep1, "update2222");
    assertEquals(false, cms.isRefreshMetadataTestOnly());
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService)

Example 19 with ClientMetadataService

use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.

the class SingleHopStatsDUnitTest method createdColocatedPRData.

private void createdColocatedPRData(GemFireCacheImpl cache) {
    Region customerRegion = cache.getRegion(CUSTOMER_REGION_NAME);
    Region orderRegion = cache.getRegion(ORDER_REGION_NAME);
    Region shipmentRegion = cache.getRegion(SHIPMENT_REGION_NAME);
    for (int i = 0; i <= 20; i++) {
        CustId custid = new CustId(i);
        Customer customer = new Customer("name" + i, "Address" + i);
        customerRegion.put(custid, customer);
        for (int j = 1; j <= 10; j++) {
            int oid = (i * 10) + j;
            OrderId orderId = new OrderId(oid, custid);
            Order order = new Order(ORDER_REGION_NAME + oid);
            orderRegion.put(orderId, order);
            for (int k = 1; k <= 10; k++) {
                int sid = (oid * 10) + k;
                ShipmentId shipmentId = new ShipmentId(sid, orderId);
                Shipment shipment = new Shipment("Shipment" + sid);
                shipmentRegion.put(shipmentId, shipment);
            }
        }
    }
    ClientMetadataService cms = cache.getClientMetadataService();
    Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
    assertEquals(3, regionMetaData.size());
    assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
    regionMetaData.get(customerRegion.getFullPath());
    metaDataRefreshCount_Customer = ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount();
    // hops are not predictable
    assertTrue(metaDataRefreshCount_Customer != 0);
    regionMetaData.get(orderRegion.getFullPath());
    metaDataRefreshCount_Order = ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount();
    assertTrue(metaDataRefreshCount_Order == 0);
    regionMetaData.get(shipmentRegion.getFullPath());
    metaDataRefreshCount_Shipment = ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount();
    assertTrue(metaDataRefreshCount_Shipment == 0);
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) CustId(org.apache.geode.internal.cache.execute.data.CustId) Region(org.apache.geode.cache.Region) ClientPartitionAdvisor(org.apache.geode.cache.client.internal.ClientPartitionAdvisor)

Example 20 with ClientMetadataService

use of org.apache.geode.cache.client.internal.ClientMetadataService in project geode by apache.

the class SingleHopGetAllPutAllDUnitTest method verifyMetadata.

private static void verifyMetadata() {
    Region region = cache.getRegion(PartitionedRegionName);
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    cms.getClientPRMetadata((LocalRegion) region);
    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
    WaitCriterion wc = new WaitCriterion() {

        public boolean done() {
            return (regionMetaData.size() == 1);
        }

        public String description() {
            return "Region metadat size is not 1. Exisitng size of regionMetaData is " + regionMetaData.size();
        }
    };
    Wait.waitForCriterion(wc, 5000, 200, true);
    assertTrue(regionMetaData.containsKey(region.getFullPath()));
    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
    wc = new WaitCriterion() {

        public boolean done() {
            return (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 13);
        }

        public String description() {
            return "Bucket server location map size is not 13. Exisitng size is :" + prMetaData.getBucketServerLocationsMap_TEST_ONLY().size();
        }
    };
    Wait.waitForCriterion(wc, 5000, 200, true);
    for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
        assertEquals(2, ((List) entry.getValue()).size());
    }
}
Also used : Entry(java.util.Map.Entry) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) ClientPartitionAdvisor(org.apache.geode.cache.client.internal.ClientPartitionAdvisor)

Aggregations

ClientMetadataService (org.apache.geode.cache.client.internal.ClientMetadataService)37 ClientPartitionAdvisor (org.apache.geode.cache.client.internal.ClientPartitionAdvisor)15 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)13 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)13 Test (org.junit.Test)13 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)12 Entry (java.util.Map.Entry)8 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)6 Region (org.apache.geode.cache.Region)5 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Cache (org.apache.geode.cache.Cache)2 CacheException (org.apache.geode.cache.CacheException)2 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)2 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)2 ServerBucketProfile (org.apache.geode.internal.cache.BucketAdvisor.ServerBucketProfile)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2