Search in sources :

Example 31 with RegionFactory

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

the class PersistentReplicatedTestBase method createPersistentRegionWithoutCompaction.

protected SerializableRunnable createPersistentRegionWithoutCompaction(final VM vm0) {
    SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {

        public void run() {
            Cache cache = getCache();
            DiskStoreFactory dsf = cache.createDiskStoreFactory();
            File dir = getDiskDirForVM(vm0);
            dir.mkdirs();
            dsf.setDiskDirs(new File[] { dir });
            dsf.setMaxOplogSize(1);
            dsf.setAutoCompact(false);
            dsf.setAllowForceCompaction(true);
            dsf.setCompactionThreshold(20);
            DiskStore ds = dsf.create(REGION_NAME);
            RegionFactory rf = new RegionFactory();
            rf.setDiskStoreName(ds.getName());
            rf.setDiskSynchronous(true);
            rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
            rf.setScope(Scope.DISTRIBUTED_ACK);
            rf.create(REGION_NAME);
        }
    };
    vm0.invoke(createRegion);
    return createRegion;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) RegionFactory(org.apache.geode.cache.RegionFactory) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Cache(org.apache.geode.cache.Cache)

Example 32 with RegionFactory

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

the class RollingUpgrade2DUnitTest method createPersistentReplicateRegion.

public static void createPersistentReplicateRegion(GemFireCache cache, String regionName, File diskStore) throws Exception {
    DiskStore store = cache.findDiskStore("store");
    if (store == null) {
        DiskStoreFactory factory = cache.createDiskStoreFactory();
        factory.setMaxOplogSize(1L);
        factory.setDiskDirs(new File[] { diskStore.getAbsoluteFile() });
        factory.create("store");
    }
    RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory();
    rf.setDiskStoreName("store");
    rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
    rf.create(regionName);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) RegionFactory(org.apache.geode.cache.RegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Example 33 with RegionFactory

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

the class PersistentReplicatedTestBase method createNonPersistentRegion.

protected void createNonPersistentRegion(VM vm) throws Exception {
    SerializableRunnable createRegion = new SerializableRunnable("Create non persistent region") {

        public void run() {
            Cache cache = getCache();
            RegionFactory rf = new RegionFactory();
            rf.setDataPolicy(DataPolicy.REPLICATE);
            rf.setScope(Scope.DISTRIBUTED_ACK);
            rf.create(REGION_NAME);
        }
    };
    vm.invoke(createRegion);
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache)

Example 34 with RegionFactory

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

the class UnregisterInterestDUnitTest method createCacheAndStartServer.

public static Integer createCacheAndStartServer() throws Exception {
    DistributedSystem ds = new UnregisterInterestDUnitTest().getSystem();
    ds.disconnect();
    Properties props = new Properties();
    props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
    CacheFactory cf = new CacheFactory(props);
    cache = cf.create();
    RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory(RegionShortcut.REPLICATE);
    rf.create(regionname);
    CacheServer server = ((GemFireCacheImpl) cache).addCacheServer();
    server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
    server.start();
    return server.getPort();
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 35 with RegionFactory

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

the class QueryDataDUnitTest method testNormalRegions.

@Test
public void testNormalRegions() throws Exception {
    this.managerVM.invoke(this.testName.getMethodName(), () -> {
        DistributedSystemMXBean distributedSystemMXBean = this.managementTestRule.getSystemManagementService().getDistributedSystemMXBean();
        String normalRegionName1 = this.testName.getMethodName() + "_NORMAL_REGION_1";
        String tempRegionName1 = this.testName.getMethodName() + "_TEMP_REGION_1";
        // to Reverse order of regions while getting Random region in QueryDataFunction [?]
        String normalRegionName2 = this.testName.getMethodName() + "_NORMAL_REGION_2";
        String tempRegionName2 = this.testName.getMethodName() + "_TEMP_REGION_2";
        Cache cache = this.managementTestRule.getCache();
        RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
        regionFactory.create(normalRegionName1);
        regionFactory.create(normalRegionName2);
        Region region = cache.getRegion("/" + normalRegionName1);
        assertThat(region.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
        RegionFactory regionFactory1 = cache.createRegionFactory(RegionShortcut.REPLICATE);
        regionFactory1.create(tempRegionName1);
        regionFactory1.create(tempRegionName2);
        String query1 = "SELECT * FROM /" + tempRegionName1 + " r1, /" + normalRegionName1 + " r2 WHERE r1.ID = r2.ID";
        String query2 = "SELECT * FROM /" + normalRegionName2 + " r1, /" + tempRegionName2 + " r2 WHERE r1.ID = r2.ID";
        String query3 = "SELECT * FROM /" + normalRegionName2;
        distributedSystemMXBean.queryDataForCompressedResult(query1, null, 2);
        distributedSystemMXBean.queryDataForCompressedResult(query2, null, 2);
        distributedSystemMXBean.queryDataForCompressedResult(query3, null, 2);
    // TODO: assert results of queryDataForCompressedResult?
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

RegionFactory (org.apache.geode.cache.RegionFactory)124 Region (org.apache.geode.cache.Region)63 Cache (org.apache.geode.cache.Cache)57 Test (org.junit.Test)54 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)51 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)44 VM (org.apache.geode.test.dunit.VM)44 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)31 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)31 CacheException (org.apache.geode.cache.CacheException)30 Host (org.apache.geode.test.dunit.Host)28 Properties (java.util.Properties)25 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)22 File (java.io.File)21 DiskStore (org.apache.geode.cache.DiskStore)20 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)20 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)20 AttributesFactory (org.apache.geode.cache.AttributesFactory)18 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)17 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)17