Search in sources :

Example 51 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class PartitionedRegionBucketCreationDistributionDUnitTest method testEnforceUniqueHostForLonerDistributedSystem.

/**
   * Added for defect #47181. Use below combination to reproduce the issue: mcast-port = 0 Locators
   * should be empty enforce-unique-host = true redundancy-zone = "zone"
   */
@Test
public void testEnforceUniqueHostForLonerDistributedSystem() {
    Cache myCache = createLonerCacheWithEnforceUniqueHost();
    try {
        AttributesFactory attr = new AttributesFactory();
        PartitionAttributesFactory paf = new PartitionAttributesFactory();
        PartitionAttributes prAttr = paf.create();
        attr.setPartitionAttributes(prAttr);
        RegionAttributes regionAttribs = attr.create();
        Region region = myCache.createRegion("PR1", regionAttribs);
        for (int i = 0; i < 113; i++) {
            region.put("Key_" + i, new Integer(i));
        }
        // verify region size
        assertEquals(113, region.size());
    } finally {
        myCache.close();
        myCache.getDistributedSystem().disconnect();
    }
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 52 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class PartitionedRegionCreationDUnitTest method getCacheSerializableRunnableForPRInitialize.

/**
   * This function tests root, allpartition region and their scope and mirrortype attribute.
   */
public CacheSerializableRunnable getCacheSerializableRunnableForPRInitialize() {
    SerializableRunnable initializePrRegion;
    initializePrRegion = new CacheSerializableRunnable("initialize") {

        @Override
        public void run2() throws CacheException {
            Cache cache = getCache();
            Region root = cache.getRegion(PartitionedRegionHelper.PR_ROOT_REGION_NAME);
            if (root == null)
                fail("PartionedRegionInitializationDUnitTest() - the " + PartitionedRegionHelper.PR_ROOT_REGION_NAME + " do not exists");
            RegionAttributes regionAttribs = root.getAttributes();
            Scope scope = regionAttribs.getScope();
            if (!scope.isDistributedAck())
                fail("PartionedRegionInitializationDUnitTest() - the " + PartitionedRegionHelper.PR_ROOT_REGION_NAME + " scope is not distributedAck");
            assertEquals("PartionedRegionInitializationTest() - the " + PartitionedRegionHelper.PR_ROOT_REGION_NAME + " does not have the proper data policy" + DataPolicy.REPLICATE, DataPolicy.REPLICATE, regionAttribs.getDataPolicy());
        // Region allPartitionedRegions = root
        // .getSubregion(PartitionedRegionHelper.PARTITIONED_REGION_CONFIG_NAME);
        // if (allPartitionedRegions == null)
        // fail("PartionedRegionInitializationTest() - the "
        // + PartitionedRegionHelper.PARTITIONED_REGION_CONFIG_NAME
        // + " do not exists");
        // regionAttribs = allPartitionedRegions.getAttributes();
        // scope = regionAttribs.getScope();
        // if (!scope.isDistributedAck())
        // fail("PartionedRegionInitializationTest() - the "
        // + PartitionedRegionHelper.PARTITIONED_REGION_CONFIG_NAME
        // + " scope is not global");
        // DataPolicy datapolicy = regionAttribs.getDataPolicy();
        // if (! DataPolicy.REPLICATE.equals(datapolicy))
        // fail("PartionedRegionInitializationTest() - the "
        // + PartitionedRegionHelper.PARTITIONED_REGION_CONFIG_NAME
        // + " data policy is not " + DataPolicy.REPLICATE);
        }
    };
    return (CacheSerializableRunnable) initializePrRegion;
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Scope(org.apache.geode.cache.Scope) CacheException(org.apache.geode.cache.CacheException) RegionAttributes(org.apache.geode.cache.RegionAttributes) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache)

Example 53 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class RemoveDAckDUnitTest method createCacheVM1.

// end of create cache for VM0
public static void createCacheVM1() {
    try {
        ds = (new RemoveDAckDUnitTest()).getSystem(props);
        AttributesFactory factory = new AttributesFactory();
        cache = CacheFactory.create(ds);
        factory.setScope(Scope.DISTRIBUTED_ACK);
        RegionAttributes attr = factory.create();
        region = cache.createRegion("map", attr);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheException(org.apache.geode.cache.CacheException)

Example 54 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class RemoveDAckDUnitTest method createCacheVM0.

public static void createCacheVM0() {
    try {
        ds = (new RemoveDAckDUnitTest()).getSystem(props);
        cache = CacheFactory.create(ds);
        AttributesFactory factory = new AttributesFactory();
        factory.setScope(Scope.DISTRIBUTED_ACK);
        RegionAttributes attr = factory.create();
        region = cache.createRegion("map", attr);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheException(org.apache.geode.cache.CacheException)

Example 55 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class RemoveAllDAckDUnitTest method createCacheForVM1.

public static void createCacheForVM1() throws Exception {
    CacheWriter aWriter = new BeforeDestroyCallback();
    ds = (new RemoveAllDAckDUnitTest()).getSystem(props);
    cache = CacheFactory.create(ds);
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setCacheWriter(aWriter);
    RegionAttributes attr = factory.create();
    region = cache.createRegion("map", attr);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheWriter(org.apache.geode.cache.CacheWriter)

Aggregations

RegionAttributes (org.apache.geode.cache.RegionAttributes)590 AttributesFactory (org.apache.geode.cache.AttributesFactory)471 Region (org.apache.geode.cache.Region)256 Test (org.junit.Test)251 Properties (java.util.Properties)158 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)128 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)126 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)118 LocalRegion (org.apache.geode.internal.cache.LocalRegion)112 Cache (org.apache.geode.cache.Cache)99 VM (org.apache.geode.test.dunit.VM)93 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)89 HashSet (java.util.HashSet)80 CacheException (org.apache.geode.cache.CacheException)65 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)62 CacheServer (org.apache.geode.cache.server.CacheServer)60 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)59 ArrayList (java.util.ArrayList)57 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)56