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:
adrian.f.cole 2009-11-02 09:11:13 +00:00
parent 483c144d38
commit cc0a346289
1 changed files with 14 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import org.apache.commons.io.IOUtils;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Supplier;
import com.google.common.collect.ComputationException; import com.google.common.collect.ComputationException;
/** /**
@ -49,6 +50,19 @@ import com.google.common.collect.ComputationException;
public class Utils { public class Utils {
public static final String UTF8_ENCODING = "UTF-8"; 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 @Resource
protected static Logger logger = Logger.NULL; protected static Logger logger = Logger.NULL;