use of org.apache.geode.admin.BackupStatus in project geode by apache.
the class BackupDUnitTest method testBackupStatusCleanedUpAfterFailureOnOneMember.
@Test
public void testBackupStatusCleanedUpAfterFailureOnOneMember() throws Throwable {
IgnoredException.addIgnoredException("Uncaught exception");
IgnoredException.addIgnoredException("Stop processing");
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final VM vm2 = host.getVM(2);
// Create an observer that will fail a backup
// When this member receives a prepare
DistributionMessageObserver observer = new SerializableDistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof PrepareBackupRequest) {
DistributionMessageObserver.setInstance(null);
IOException exception = new IOException("Backup in progess");
AdminFailureResponse response = AdminFailureResponse.create(dm, message.getSender(), exception);
response.setMsgId(((PrepareBackupRequest) message).getMsgId());
dm.putOutgoing(response);
throw new RuntimeException("Stop processing");
}
}
};
vm0.invoke(() -> {
disconnectFromDS();
DistributionMessageObserver.setInstance(observer);
});
createPersistentRegion(vm0);
createPersistentRegion(vm1);
createData(vm0, 0, 5, "A", "region1");
createData(vm0, 0, 5, "B", "region2");
try {
backup(vm2);
fail("Backup should have failed with in progress exception");
} catch (Exception expected) {
// that's ok, hte backup should have failed
}
// A second backup should succeed because the observer
// has been cleared and the backup state should be cleared.
BackupStatus status = backup(vm2);
assertEquals(2, status.getBackedUpDiskStores().size());
assertEquals(Collections.emptySet(), status.getOfflineDiskStores());
}
use of org.apache.geode.admin.BackupStatus in project geode by apache.
the class IncrementalBackupDUnitTest method baseline.
/**
* Invokes {@link AdminDistributedSystem#backupAllMembers(File)} on a member.
*
* @param vm a member of the distributed system
* @return the status of the backup.
*/
private BackupStatus baseline(VM vm) {
return (BackupStatus) vm.invoke(new SerializableCallable("Backup all members.") {
@Override
public Object call() {
DistributedSystemConfig config;
AdminDistributedSystem adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
return adminDS.backupAllMembers(getBaselineDir());
} catch (AdminException e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
}
use of org.apache.geode.admin.BackupStatus in project geode by apache.
the class IncrementalBackupDUnitTest method incremental.
/**
* Invokes {@link AdminDistributedSystem#backupAllMembers(File, File)} on a member.
*
* @param vm a member of the distributed system.
* @return a status of the backup operation.
*/
private BackupStatus incremental(VM vm) {
return (BackupStatus) vm.invoke(new SerializableCallable("Backup all members.") {
@Override
public Object call() {
DistributedSystemConfig config;
AdminDistributedSystem adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
return adminDS.backupAllMembers(getIncrementalDir(), getBaselineBackupDir());
} catch (AdminException e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
}
Aggregations