Search in sources :

Example 6 with DiskStoreImpl

use of org.apache.geode.internal.cache.DiskStoreImpl in project geode by apache.

the class MemberMBeanBridge method compactAllDiskStores.

/**
   * An instruction to members with cache that they should compact their disk stores.
   * 
   * @return a list of compacted Disk stores
   */
public String[] compactAllDiskStores() {
    List<String> compactedStores = new ArrayList<String>();
    if (cache != null && !cache.isClosed()) {
        for (DiskStore store : this.cache.listDiskStoresIncludingRegionOwned()) {
            if (store.forceCompaction()) {
                compactedStores.add(((DiskStoreImpl) store).getPersistentID().getDirectory());
            }
        }
    }
    String[] compactedStoresAr = new String[compactedStores.size()];
    return compactedStores.toArray(compactedStoresAr);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) ArrayList(java.util.ArrayList) DiskStoreImpl(org.apache.geode.internal.cache.DiskStoreImpl)

Example 7 with DiskStoreImpl

use of org.apache.geode.internal.cache.DiskStoreImpl in project geode by apache.

the class CompactRequest method compactDiskStore.

public static PersistentID compactDiskStore(String diskStoreName) {
    PersistentID persistentID = null;
    InternalCache cache = GemFireCacheImpl.getInstance();
    if (cache != null && !cache.isClosed()) {
        DiskStoreImpl diskStore = (DiskStoreImpl) cache.findDiskStore(diskStoreName);
        if (diskStore != null && diskStore.forceCompaction()) {
            persistentID = diskStore.getPersistentID();
        }
    }
    return persistentID;
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) DiskStoreImpl(org.apache.geode.internal.cache.DiskStoreImpl) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Example 8 with DiskStoreImpl

use of org.apache.geode.internal.cache.DiskStoreImpl in project geode by apache.

the class BackupManager method finishBackup.

public HashSet<PersistentID> finishBackup(File targetDir, File baselineDir, boolean abort) throws IOException {
    try {
        if (abort) {
            return new HashSet<PersistentID>();
        }
        File backupDir = getBackupDir(targetDir);
        // Make sure our baseline is okay for this member
        baselineDir = checkBaseline(baselineDir);
        // Create an inspector for the baseline backup
        BackupInspector inspector = (baselineDir == null ? null : BackupInspector.createInspector(baselineDir));
        File storesDir = new File(backupDir, DATA_STORES);
        RestoreScript restoreScript = new RestoreScript();
        HashSet<PersistentID> persistentIds = new HashSet<PersistentID>();
        Collection<DiskStore> diskStores = new ArrayList<DiskStore>(cache.listDiskStoresIncludingRegionOwned());
        boolean foundPersistentData = false;
        for (Iterator<DiskStore> itr = diskStores.iterator(); itr.hasNext(); ) {
            DiskStoreImpl store = (DiskStoreImpl) itr.next();
            if (store.hasPersistedData()) {
                if (!foundPersistentData) {
                    createBackupDir(backupDir);
                    foundPersistentData = true;
                }
                File diskStoreDir = new File(storesDir, store.getBackupDirName());
                diskStoreDir.mkdir();
                store.startBackup(diskStoreDir, inspector, restoreScript);
            } else {
                itr.remove();
            }
            store.releaseBackupLock();
        }
        allowDestroys.countDown();
        for (DiskStore store : diskStores) {
            DiskStoreImpl storeImpl = (DiskStoreImpl) store;
            storeImpl.finishBackup(this);
            storeImpl.getStats().endBackup();
            persistentIds.add(storeImpl.getPersistentID());
        }
        if (foundPersistentData) {
            backupConfigFiles(restoreScript, backupDir);
            backupUserFiles(restoreScript, backupDir);
            backupDeployedJars(restoreScript, backupDir);
            restoreScript.generate(backupDir);
            File incompleteFile = new File(backupDir, INCOMPLETE_BACKUP);
            if (!incompleteFile.delete()) {
                throw new IOException("Could not delete file " + INCOMPLETE_BACKUP);
            }
        }
        return persistentIds;
    } finally {
        cleanup();
    }
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) DiskStore(org.apache.geode.cache.DiskStore) DiskStoreImpl(org.apache.geode.internal.cache.DiskStoreImpl) File(java.io.File) HashSet(java.util.HashSet) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Example 9 with DiskStoreImpl

use of org.apache.geode.internal.cache.DiskStoreImpl in project geode by apache.

the class BackupManager method prepareBackup.

public HashSet<PersistentID> prepareBackup() {
    HashSet<PersistentID> persistentIds = new HashSet<PersistentID>();
    Collection<DiskStore> diskStores = cache.listDiskStoresIncludingRegionOwned();
    for (DiskStore store : diskStores) {
        DiskStoreImpl storeImpl = (DiskStoreImpl) store;
        storeImpl.lockStoreBeforeBackup();
        if (storeImpl.hasPersistedData()) {
            persistentIds.add(storeImpl.getPersistentID());
            storeImpl.getStats().startBackup();
        }
    }
    return persistentIds;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) DiskStoreImpl(org.apache.geode.internal.cache.DiskStoreImpl) HashSet(java.util.HashSet) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Aggregations

DiskStoreImpl (org.apache.geode.internal.cache.DiskStoreImpl)9 DiskStore (org.apache.geode.cache.DiskStore)4 ArrayList (java.util.ArrayList)3 PersistentID (org.apache.geode.cache.persistence.PersistentID)3 HashSet (java.util.HashSet)2 InternalCache (org.apache.geode.internal.cache.InternalCache)2 File (java.io.File)1 IOException (java.io.IOException)1 Set (java.util.Set)1 UUID (java.util.UUID)1 FunctionContext (org.apache.geode.cache.execute.FunctionContext)1 DM (org.apache.geode.distributed.internal.DM)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 DirectoryHolder (org.apache.geode.internal.cache.DirectoryHolder)1 DiskRegionStats (org.apache.geode.internal.cache.DiskRegionStats)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 DiskStoreDetails (org.apache.geode.management.internal.cli.domain.DiskStoreDetails)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1 Expectations (org.jmock.Expectations)1