mirror of https://github.com/apache/jclouds.git
utility for eventual consistency testing
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2036 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
483c144d38
commit
cc0a346289
|
@ -39,6 +39,7 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ComputationException;
|
||||
|
||||
/**
|
||||
|
@ -49,6 +50,19 @@ import com.google.common.collect.ComputationException;
|
|||
public class Utils {
|
||||
public static final String UTF8_ENCODING = "UTF-8";
|
||||
|
||||
public static boolean enventuallyTrue(Supplier<Boolean> assertion, long inconsistencyMillis) throws InterruptedException {
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
if (!assertion.get()) {
|
||||
Thread.sleep(inconsistencyMillis / 30);
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Resource
|
||||
protected static Logger logger = Logger.NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue