use of org.apache.geode.cache.control.RebalanceOperation in project geode by apache.
the class BackupDUnitTest method backupWhileBucketIsMoved.
/**
* Test for bug 42420. Invoke a backup when a bucket is in the middle of being moved.
*
* @param observer - a message observer that triggers at the backup at the correct time.
*/
public void backupWhileBucketIsMoved(final DistributionMessageObserver observer) throws Throwable {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final VM vm2 = host.getVM(2);
vm0.invoke(new SerializableRunnable("Add listener to invoke backup") {
public void run() {
disconnectFromDS();
// This listener will wait for a response to the
// destroy region message, and then trigger a backup.
// That will backup before this member has finished destroying
// a bucket, but after the peer has removed the bucket.
DistributionMessageObserver.setInstance(observer);
}
});
try {
LogWriterUtils.getLogWriter().info("Creating region in VM0");
createPersistentRegion(vm0);
// create twos bucket on vm0
createData(vm0, 0, 2, "A", "region1");
// create the pr on vm1, which won't have any buckets
LogWriterUtils.getLogWriter().info("Creating region in VM1");
createPersistentRegion(vm1);
// Perform a rebalance. This will trigger the backup in the middle
// of the bucket move.
vm0.invoke(new SerializableRunnable("Do rebalance") {
public void run() {
Cache cache = getCache();
RebalanceOperation op = cache.getResourceManager().createRebalanceFactory().start();
RebalanceResults results;
try {
results = op.getResults();
assertEquals(1, results.getTotalBucketTransfersCompleted());
} catch (Exception e) {
Assert.fail("interupted", e);
}
}
});
validateBackupComplete();
createData(vm0, 0, 5, "C", "region1");
closeCache(vm0);
closeCache(vm1);
// Destroy the current data
Invoke.invokeInEveryVM(new SerializableRunnable("Clean disk dirs") {
public void run() {
try {
cleanDiskDirs();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
restoreBackup(2);
LogWriterUtils.getLogWriter().info("Creating region in VM0");
AsyncInvocation async0 = createPersistentRegionAsync(vm0);
LogWriterUtils.getLogWriter().info("Creating region in VM1");
AsyncInvocation async1 = createPersistentRegionAsync(vm1);
async0.getResult(MAX_WAIT);
async1.getResult(MAX_WAIT);
checkData(vm0, 0, 2, "A", "region1");
} finally {
// cleanup the distribution message observer
vm0.invoke(new SerializableRunnable() {
public void run() {
DistributionMessageObserver.setInstance(null);
disconnectFromDS();
}
});
}
}
Aggregations