use of org.apache.curator.framework.imps.FailedDeleteManager.FailedDeleteManagerListener in project xian by happyyangyuan.
the class TestFailedDeleteManager method testGuaranteedDeleteOnNonExistentNodeInForeground.
@Test
public void testGuaranteedDeleteOnNonExistentNodeInForeground() throws Exception {
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
client.start();
final AtomicBoolean pathAdded = new AtomicBoolean(false);
((CuratorFrameworkImpl) client).getFailedDeleteManager().debugListener = new FailedDeleteManagerListener() {
@Override
public void pathAddedForDelete(String path) {
pathAdded.set(true);
}
};
try {
client.delete().guaranteed().forPath("/nonexistent");
Assert.fail();
} catch (NoNodeException e) {
// Exception is expected, the delete should not be retried
Assert.assertFalse(pathAdded.get());
} finally {
client.close();
}
}
use of org.apache.curator.framework.imps.FailedDeleteManager.FailedDeleteManagerListener in project xian by happyyangyuan.
the class TestFailedDeleteManager method testGuaranteedDeleteOnNonExistentNodeInBackground.
@Test
public void testGuaranteedDeleteOnNonExistentNodeInBackground() throws Exception {
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
client.start();
final AtomicBoolean pathAdded = new AtomicBoolean(false);
((CuratorFrameworkImpl) client).getFailedDeleteManager().debugListener = new FailedDeleteManagerListener() {
@Override
public void pathAddedForDelete(String path) {
pathAdded.set(true);
}
};
final CountDownLatch backgroundLatch = new CountDownLatch(1);
BackgroundCallback background = new BackgroundCallback() {
@Override
public void processResult(CuratorFramework client, CuratorEvent event) throws Exception {
backgroundLatch.countDown();
}
};
try {
client.delete().guaranteed().inBackground(background).forPath("/nonexistent");
backgroundLatch.await();
// Exception is expected, the delete should not be retried
Assert.assertFalse(pathAdded.get());
} finally {
client.close();
}
}
Aggregations