use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.
the class SystemAdmin method compactAllDiskStores.
public static void compactAllDiskStores(List args) throws AdminException {
InternalDistributedSystem ads = getAdminCnx();
Map<DistributedMember, Set<PersistentID>> status = AdminDistributedSystemImpl.compactAllDiskStores(ads.getDistributionManager());
System.out.println("Compaction complete.");
System.out.println("The following disk stores compacted some files:");
for (Set<PersistentID> memberStores : status.values()) {
for (PersistentID store : memberStores) {
System.out.println("\t" + store);
}
}
}
use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.
the class SystemAdmin method backup.
public static void backup(String targetDir) throws AdminException {
InternalDistributedSystem ads = getAdminCnx();
// Baseline directory should be null if it was not provided on the command line
BackupStatus status = AdminDistributedSystemImpl.backupAllMembers(ads.getDistributionManager(), new File(targetDir), (SystemAdmin.baselineDir == null ? null : new File(SystemAdmin.baselineDir)));
boolean incomplete = !status.getOfflineDiskStores().isEmpty();
System.out.println("The following disk stores were backed up:");
for (Set<PersistentID> memberStores : status.getBackedUpDiskStores().values()) {
for (PersistentID store : memberStores) {
System.out.println("\t" + store);
}
}
if (incomplete) {
System.err.println("The backup may be incomplete. The following disk stores are not online:");
for (PersistentID store : status.getOfflineDiskStores()) {
System.err.println("\t" + store);
}
} else {
System.out.println("Backup successful.");
}
}
use of org.apache.geode.cache.persistence.PersistentID 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;
}
use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.
the class DistributedSystemBridge method backupAllMembers.
/**
*
* @param targetDirPath path of the directory where the back up files should be placed.
* @param baselineDirPath path of the directory for baseline backup.
* @return open type DiskBackupStatus containing each member wise disk back up status
*/
public DiskBackupStatus backupAllMembers(String targetDirPath, String baselineDirPath) throws Exception {
if (BackupDataStoreHelper.obtainLock(dm)) {
try {
if (targetDirPath == null || targetDirPath.isEmpty()) {
throw new Exception(ManagementStrings.TARGET_DIR_CANT_BE_NULL_OR_EMPTY.toLocalizedString());
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
File targetDir = new File(targetDirPath);
targetDir = new File(targetDir, format.format(new Date()));
File baselineDir = null;
if (baselineDirPath != null) {
baselineDir = new File(baselineDirPath);
}
DM dm = cache.getDistributionManager();
Set<PersistentID> missingMembers = MissingPersistentIDsRequest.send(dm);
Set recipients = dm.getOtherDistributionManagerIds();
BackupDataStoreResult result = BackupDataStoreHelper.backupAllMembers(dm, recipients, targetDir, baselineDir);
Iterator<DistributedMember> it = result.getSuccessfulMembers().keySet().iterator();
Map<String, String[]> backedUpDiskStores = new HashMap<>();
while (it.hasNext()) {
DistributedMember member = it.next();
Set<PersistentID> setOfDisk = result.getSuccessfulMembers().get(member);
String[] setOfDiskStr = new String[setOfDisk.size()];
int j = 0;
for (PersistentID id : setOfDisk) {
setOfDiskStr[j] = id.getDirectory();
j++;
}
backedUpDiskStores.put(member.getId(), setOfDiskStr);
}
// should override the previous missingMembers
for (Set<PersistentID> onlineMembersIds : result.getSuccessfulMembers().values()) {
missingMembers.removeAll(onlineMembersIds);
}
result.getExistingDataStores().keySet().removeAll(result.getSuccessfulMembers().keySet());
String[] setOfMissingDiskStr = null;
if (result.getExistingDataStores().size() > 0) {
setOfMissingDiskStr = new String[result.getExistingDataStores().size()];
int j = 0;
for (Set<PersistentID> lostMembersIds : result.getExistingDataStores().values()) {
for (PersistentID id : lostMembersIds) {
setOfMissingDiskStr[j] = id.getDirectory();
j++;
}
}
}
DiskBackupStatus diskBackupStatus = new DiskBackupStatus();
diskBackupStatus.setBackedUpDiskStores(backedUpDiskStores);
diskBackupStatus.setOfflineDiskStores(setOfMissingDiskStr);
return diskBackupStatus;
} finally {
BackupDataStoreHelper.releaseLock(dm);
}
} else {
throw new Exception(LocalizedStrings.DistributedSystem_BACKUP_ALREADY_IN_PROGRESS.toLocalizedString());
}
}
use of org.apache.geode.cache.persistence.PersistentID in project geode by apache.
the class MissingPersistentIDsRequest method createResponse.
@Override
protected AdminResponse createResponse(DistributionManager dm) {
Set<PersistentID> missingIds = new HashSet<>();
Set<PersistentID> localPatterns = new HashSet<>();
InternalCache cache = GemFireCacheImpl.getInstance();
if (cache != null && !cache.isClosed()) {
PersistentMemberManager mm = cache.getPersistentMemberManager();
Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
for (Map.Entry<String, Set<PersistentMemberID>> entry : waitingRegions.entrySet()) {
for (PersistentMemberID id : entry.getValue()) {
missingIds.add(new PersistentMemberPattern(id));
}
}
Set<PersistentMemberID> localIds = mm.getPersistentIDs();
for (PersistentMemberID id : localIds) {
localPatterns.add(new PersistentMemberPattern(id));
}
}
return new MissingPersistentIDsResponse(missingIds, localPatterns, this.getSender());
}
Aggregations