Search in sources :

Example 6 with ClientMetadataService

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

the class Shipment method test_MetadataServiceCallAccuracy_FromGetOp.

@Test
public void test_MetadataServiceCallAccuracy_FromGetOp() {
    Integer port0 = (Integer) member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(0, 4));
    Integer port1 = (Integer) member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(0, 4));
    member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.createClient(port0));
    createClient(port1);
    member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.putIntoSinglePR());
    member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
    member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
    final ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.get(new Integer(0));
    region.get(new Integer(1));
    region.get(new Integer(2));
    region.get(new Integer(3));
    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == true);
    printMetadata();
    Wait.pause(5000);
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.get(new Integer(0));
    region.get(new Integer(1));
    region.get(new Integer(2));
    region.get(new Integer(3));
    Wait.pause(5000);
    assertFalse(cms.isRefreshMetadataTestOnly());
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test)

Example 7 with ClientMetadataService

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

the class Shipment method verifyEmptyMetadata.

public static void verifyEmptyMetadata() {
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    assertTrue(cms.getClientPRMetadata_TEST_ONLY().isEmpty());
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService)

Example 8 with ClientMetadataService

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

the class Shipment method fetchAndValidateMetadata.

private boolean fetchAndValidateMetadata() {
    ClientMetadataService service = ((GemFireCacheImpl) this.cache).getClientMetadataService();
    service.getClientPRMetadata((LocalRegion) this.region);
    HashMap<ServerLocation, HashSet<Integer>> servers = service.groupByServerToAllBuckets(this.region, true);
    if (servers == null) {
        // + this.region.getFullPath());
        return false;
    } else if (servers.size() == 4) {
        region.getCache().getLogger().fine("The client metadata contains the following " + servers.size() + " servers for region " + this.region.getFullPath() + ":");
        for (Map.Entry entry : servers.entrySet()) {
            region.getCache().getLogger().fine(entry.getKey() + "->" + entry.getValue());
        }
        if (servers.size() < 4) {
            region.getCache().getLogger().info("Servers size is " + servers.size() + " less than expected 4.");
            return false;
        }
    }
    return true;
}
Also used : Entry(java.util.Map.Entry) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) HashSet(java.util.HashSet)

Example 9 with ClientMetadataService

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

the class Shipment method test_NoMetadataServiceCall.

@Test
public void test_NoMetadataServiceCall() {
    Integer port0 = (Integer) member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(1, 4));
    Integer port1 = (Integer) member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(1, 4));
    member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.createClientWithoutPRSingleHopEnabled(port0));
    createClientWithoutPRSingleHopEnabled(port1);
    member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.putIntoSinglePR());
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
    member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
    region.put(new Integer(0), "create0");
    final boolean metadataRefreshed_get1 = cms.isRefreshMetadataTestOnly();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(new Integer(1), "create1");
    final boolean metadataRefreshed_get2 = cms.isRefreshMetadataTestOnly();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(new Integer(2), "create2");
    final boolean metadataRefreshed_get3 = cms.isRefreshMetadataTestOnly();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(new Integer(3), "create3");
    final boolean metadataRefreshed_get4 = cms.isRefreshMetadataTestOnly();
    Wait.pause(5000);
    assertFalse(metadataRefreshed_get1 || metadataRefreshed_get2 || metadataRefreshed_get3 || metadataRefreshed_get4);
    printMetadata();
    cms.satisfyRefreshMetadata_TEST_ONLY(false);
    region.put(new Integer(0), "create0");
    region.put(new Integer(1), "create1");
    region.put(new Integer(2), "create2");
    region.put(new Integer(3), "create3");
    Wait.pause(5000);
    assertFalse(cms.isRefreshMetadataTestOnly());
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test)

Example 10 with ClientMetadataService

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

the class Shipment method verifyEmptyStaticData.

public static void verifyEmptyStaticData() {
    ClientMetadataService cms = ((GemFireCacheImpl) cache).getClientMetadataService();
    assertTrue(cms.getClientPartitionAttributesMap().isEmpty());
}
Also used : ClientMetadataService(org.apache.geode.cache.client.internal.ClientMetadataService)

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