lonBackupFailurePolicy = BackupFailurePolicy.FAIL;
}
public void testPutWithFailures() {
populateKeys(cache("LON", 0));
BackupSenderImpl bs = (BackupSenderImpl) cache("LON", 0).getAdvancedCache().getComponentRegistry().getComponent(BackupSender.class);
OfflineStatus nycStatus = bs.getOfflineStatus("NYC");
for (int i = 0; i < FAILURES / nrRpcPerPut; i++) {
try {
assertEquals(BackupSender.BringSiteOnlineResponse.ALREADY_ONLINE, bs.bringSiteOnline("NYC"));
cache("LON", 0).put(KEYS[i], "v" + i);
fail("This should have failed");
} catch (Exception e) {
assertEquals(i + 1, nycStatus.getFailureCount());
}
}
assert nycStatus.isOffline();
for (int i = 0; i < FAILURES; i++) {
cache("LON", 0).put(KEYS[i], "v" + i);
}
for (int i = 0; i < FAILURES; i++) {
assertEquals("v" + i, cache("LON", 0).get(KEYS[i]));
}
assertEquals(BackupSender.BringSiteOnlineResponse.NO_SUCH_SITE, bs.bringSiteOnline("NO_SITE"));
assertEquals(BackupSender.BringSiteOnlineResponse.BROUGHT_ONLINE, bs.bringSiteOnline("NYC"));
for (int i = 0; i < FAILURES / nrRpcPerPut; i++) {
try {
cache("LON", 0).put(KEYS[i], "v" + i);
fail("This should have failed");