Search in sources :

Example 1 with DiskBackupResult

use of org.apache.geode.management.DiskBackupResult in project geode by apache.

the class MemberMBeanBridge method backupMember.

/**
   * backs up all the disk to the targeted directory
   * 
   * @param targetDirPath path of the directory where back up is to be taken
   * @return array of DiskBackup results which might get aggregated at Managing node Check the
   *         validity of this mbean call. When does it make sense to backup a single member of a
   *         gemfire system in isolation of the other members?
   */
public DiskBackupResult[] backupMember(String targetDirPath) {
    if (cache != null) {
        Collection<DiskStore> diskStores = cache.listDiskStoresIncludingRegionOwned();
        for (DiskStore store : diskStores) {
            store.flush();
        }
    }
    DiskBackupResult[] diskBackUpResult = null;
    File targetDir = new File(targetDirPath);
    if (cache == null) {
        return null;
    } else {
        try {
            BackupManager manager = cache.startBackup(cache.getInternalDistributedSystem().getDistributedMember());
            boolean abort = true;
            Set<PersistentID> existingDataStores;
            Set<PersistentID> successfulDataStores;
            try {
                existingDataStores = manager.prepareBackup();
                abort = false;
            } finally {
                successfulDataStores = manager.finishBackup(targetDir, null, /* TODO rishi */
                abort);
            }
            diskBackUpResult = new DiskBackupResult[existingDataStores.size()];
            int j = 0;
            for (PersistentID id : existingDataStores) {
                if (successfulDataStores.contains(id)) {
                    diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(), false);
                } else {
                    diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(), true);
                }
                j++;
            }
        } catch (IOException e) {
            throw new ManagementException(e);
        }
    }
    return diskBackUpResult;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) DiskBackupResult(org.apache.geode.management.DiskBackupResult) ManagementException(org.apache.geode.management.ManagementException) IOException(java.io.IOException) File(java.io.File) BackupManager(org.apache.geode.internal.cache.persistence.BackupManager) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 DiskStore (org.apache.geode.cache.DiskStore)1 PersistentID (org.apache.geode.cache.persistence.PersistentID)1 BackupManager (org.apache.geode.internal.cache.persistence.BackupManager)1 DiskBackupResult (org.apache.geode.management.DiskBackupResult)1 ManagementException (org.apache.geode.management.ManagementException)1