Search in sources :

Example 1 with DiskStoreAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.DiskStoreAttributesCreation 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)

Example 2 with DiskStoreAttributesCreation

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

the class CacheXml80DUnitTest method testDiskUsage.

@Test
public void testDiskUsage() throws Exception {
    CacheCreation cache = new CacheCreation();
    DiskStoreAttributesCreation disk = new DiskStoreAttributesCreation();
    disk.setDiskUsageWarningPercentage(97);
    disk.setDiskUsageCriticalPercentage(98);
    disk.setName("mydisk");
    cache.addDiskStore(disk);
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
    attrs.setDiskStoreName("mydisk");
    cache.createVMRegion("whatever", attrs);
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) DiskStoreAttributesCreation(org.apache.geode.internal.cache.xmlcache.DiskStoreAttributesCreation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)2 DiskStoreAttributesCreation (org.apache.geode.internal.cache.xmlcache.DiskStoreAttributesCreation)2 DiskStore (org.apache.geode.cache.DiskStore)1 BackupManager (org.apache.geode.internal.cache.persistence.BackupManager)1 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)1 TypeRegistry (org.apache.geode.pdx.internal.TypeRegistry)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1