Search in sources :

Example 66 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testDiskDirs.

/**
   * Tests disk directories
   */
@Test
public void testDiskDirs() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    File[] dirs = new File[] { new File(this.getUniqueName() + "-dir1"), new File(this.getUniqueName() + "-dir2") };
    for (int i = 0; i < dirs.length; i++) {
        dirs[i].mkdirs();
        dirs[i].deleteOnExit();
    }
    int[] diskSizes = { DiskWriteAttributesImpl.DEFAULT_DISK_DIR_SIZE, DiskWriteAttributesImpl.DEFAULT_DISK_DIR_SIZE };
    attrs.setDiskDirsAndSize(dirs, diskSizes);
    cache.createRegion("root", attrs);
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) File(java.io.File) Test(org.junit.Test)

Example 67 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testEntriesInRootRegion.

/**
   * Tests creating a cache with entries defined in the root region
   */
@Test
public void testEntriesInRootRegion() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionCreation root = (RegionCreation) cache.createRegion("root", new RegionAttributesCreation(cache));
    root.put("KEY1", "VALUE1");
    root.put("KEY2", "VALUE2");
    root.put("KEY3", "VALUE3");
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 68 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testBridgeLoadProbe.

@Test
public void testBridgeLoadProbe() throws Exception {
    CacheCreation cache = new CacheCreation();
    CacheServer server = cache.addCacheServer();
    server.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    server.setLoadProbe(new MyLoadProbe());
    testXml(cache);
    Cache c = getCache();
    server = c.getCacheServers().get(0);
    assertEquals(MyLoadProbe.class, server.getLoadProbe().getClass());
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 69 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testLOCAL_PERSISTENT.

@Test
public void testLOCAL_PERSISTENT() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionCreation root = (RegionCreation) cache.createRegion("plocal", "LOCAL_PERSISTENT");
    testXml(cache);
    GemFireCacheImpl c = (GemFireCacheImpl) getCache();
    Region r = c.getRegion("plocal");
    assertNotNull(r);
    RegionAttributes ra = r.getAttributes();
    assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
    assertEquals(Scope.LOCAL, ra.getScope());
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 70 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class DiskStoreFactoryImpl method create.

public DiskStore create(String name) {
    this.attrs.name = name;
    // As a simple fix for 41290, only allow one DiskStore to be created
    // at a time per cache by syncing on the cache.
    DiskStore result;
    synchronized (this.cache) {
        result = findExisting(name);
        if (result == null) {
            if (this.cache instanceof GemFireCacheImpl) {
                TypeRegistry registry = this.cache.getPdxRegistry();
                DiskStoreImpl dsi = new DiskStoreImpl(this.cache, this.attrs);
                result = dsi;
                // Added for M&M
                this.cache.getInternalDistributedSystem().handleResourceEvent(ResourceEvent.DISKSTORE_CREATE, dsi);
                dsi.doInitialRecovery();
                this.cache.addDiskStore(dsi);
                if (registry != null) {
                    registry.creatingDiskStore(dsi);
                }
            } else if (this.cache instanceof CacheCreation) {
                CacheCreation creation = (CacheCreation) this.cache;
                result = new DiskStoreAttributesCreation(this.attrs);
                creation.addDiskStore(result);
            }
        }
    }
    // that isn't backed up.
    if (this.cache instanceof GemFireCacheImpl) {
        BackupManager backup = this.cache.getBackupManager();
        if (backup != null) {
            backup.waitForBackup();
        }
    }
    return result;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) TypeRegistry(org.apache.geode.pdx.internal.TypeRegistry) BackupManager(org.apache.geode.internal.cache.persistence.BackupManager) DiskStoreAttributesCreation(org.apache.geode.internal.cache.xmlcache.DiskStoreAttributesCreation)

Aggregations

CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)153 Test (org.junit.Test)143 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)114 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)86 Region (org.apache.geode.cache.Region)62 LocalRegion (org.apache.geode.internal.cache.LocalRegion)57 Cache (org.apache.geode.cache.Cache)53 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)53 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)53 ClientCache (org.apache.geode.cache.client.ClientCache)42 RegionAttributes (org.apache.geode.cache.RegionAttributes)35 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)35 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)35 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)25 CacheServer (org.apache.geode.cache.server.CacheServer)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)16 File (java.io.File)15 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)12 AttributesFactory (org.apache.geode.cache.AttributesFactory)9 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9