Search in sources :

Example 16 with PersistentID

use of org.apache.geode.cache.persistence.PersistentID 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 17 with PersistentID

use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.

the class CacheAndRegionListenerImpl method getMissingPersistentMembersJMX.

public TabularData getMissingPersistentMembersJMX() throws AdminException {
    try {
        Set<PersistentID> members = super.getMissingPersistentMembers();
        TabularData results = new TabularDataSupport(PERSISTENT_ID_TABLE_TYPE);
        int index = 0;
        for (PersistentID id : members) {
            CompositeData idData = new CompositeDataSupport(PERSISTENT_ID_TYPE, PERSISTENT_ID_FIELDS, new Object[] { id.getHost().toString(), id.getDirectory(), id.getUUID().toString() });
            results.put(idData);
            index++;
        }
        return results;
    } catch (OpenDataException e) {
        logger.warn("Exception occurred while getting missing persistent members.", e);
        throw new AdminException(e);
    }
}
Also used : PersistentID(org.apache.geode.cache.persistence.PersistentID)

Example 18 with PersistentID

use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.

the class AdminDistributedSystemImpl method backupAllMembers.

public static BackupStatus backupAllMembers(DM dm, File targetDir, File baselineDir) throws AdminException {
    BackupStatus status = null;
    if (BackupDataStoreHelper.obtainLock(dm)) {
        try {
            Set<PersistentID> missingMembers = getMissingPersistentMembers(dm);
            Set recipients = dm.getOtherDistributionManagerIds();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
            targetDir = new File(targetDir, format.format(new Date()));
            BackupDataStoreResult result = BackupDataStoreHelper.backupAllMembers(dm, recipients, targetDir, baselineDir);
            // should override the previous missingMembers
            for (Set<PersistentID> onlineMembersIds : result.getSuccessfulMembers().values()) {
                missingMembers.removeAll(onlineMembersIds);
            }
            result.getExistingDataStores().keySet().removeAll(result.getSuccessfulMembers().keySet());
            for (Set<PersistentID> lostMembersIds : result.getExistingDataStores().values()) {
                missingMembers.addAll(lostMembersIds);
            }
            status = new BackupStatusImpl(result.getSuccessfulMembers(), missingMembers);
        } finally {
            BackupDataStoreHelper.releaseLock(dm);
        }
    } else {
        throw new AdminException(LocalizedStrings.DistributedSystem_BACKUP_ALREADY_IN_PROGRESS.toLocalizedString());
    }
    return status;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Example 19 with PersistentID

use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.

the class AdminDistributedSystemImpl method revokePersistentMember.

public static void revokePersistentMember(DM dm, UUID diskStoreID) {
    PersistentMemberPattern pattern = new PersistentMemberPattern(diskStoreID);
    boolean success = false;
    try {
        // make sure that the disk store we're revoking is actually missing
        boolean found = false;
        Set<PersistentID> details = getMissingPersistentMembers(dm);
        if (details != null) {
            for (PersistentID id : details) {
                if (id.getUUID().equals(diskStoreID)) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            return;
        }
        // Fix for 42607 - verify that the persistent id is not already
        // running before revoking it.
        PrepareRevokePersistentIDRequest.send(dm, pattern);
        success = true;
    } finally {
        if (success) {
            // revoke the persistent member if were able to prepare the revoke
            RevokePersistentIDRequest.send(dm, pattern);
        } else {
            // otherwise, cancel the revoke.
            PrepareRevokePersistentIDRequest.cancel(dm, pattern);
        }
    }
}
Also used : PersistentMemberPattern(org.apache.geode.internal.cache.persistence.PersistentMemberPattern) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Example 20 with PersistentID

use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.

the class PrepareBackupRequest method createResponse.

@Override
protected AdminResponse createResponse(DistributionManager dm) {
    InternalCache cache = GemFireCacheImpl.getInstance();
    HashSet<PersistentID> persistentIds;
    if (cache == null) {
        persistentIds = new HashSet<>();
    } else {
        try {
            BackupManager manager = cache.startBackup(getSender());
            persistentIds = manager.prepareBackup();
        } catch (IOException e) {
            logger.error(LocalizedMessage.create(LocalizedStrings.CliLegacyMessage_ERROR, this.getClass()), e);
            return AdminFailureResponse.create(dm, getSender(), e);
        }
    }
    return new PrepareBackupResponse(this.getSender(), persistentIds);
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) IOException(java.io.IOException) BackupManager(org.apache.geode.internal.cache.persistence.BackupManager) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Aggregations

PersistentID (org.apache.geode.cache.persistence.PersistentID)29 HashSet (java.util.HashSet)11 File (java.io.File)8 Set (java.util.Set)8 IOException (java.io.IOException)7 DiskStore (org.apache.geode.cache.DiskStore)7 InternalCache (org.apache.geode.internal.cache.InternalCache)6 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 DistributedMember (org.apache.geode.distributed.DistributedMember)5 Map (java.util.Map)4 AdminException (org.apache.geode.admin.AdminException)4 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 LinkedList (java.util.LinkedList)3 TreeSet (java.util.TreeSet)3 RegexFileFilter (org.apache.commons.io.filefilter.RegexFileFilter)3 AdminDistributedSystem (org.apache.geode.admin.AdminDistributedSystem)3 BackupStatus (org.apache.geode.admin.BackupStatus)3 DistributedSystemConfig (org.apache.geode.admin.DistributedSystemConfig)3