use of org.apache.geode.admin.internal.PrepareBackupRequest 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());
}
Aggregations