removed unused class

This commit is contained in:
Adrian Cole 2010-07-28 19:37:38 -07:00
parent 4ed2f2ec8a
commit 798399dac4
1 changed files with 8 additions and 19 deletions

View File

@ -51,9 +51,8 @@ import com.google.common.util.concurrent.ListenableFuture;
@Singleton @Singleton
public class ConcurrentUtils { public class ConcurrentUtils {
public static <T> Map<T, Exception> awaitCompletion( public static <T> Map<T, Exception> awaitCompletion(Map<T, ? extends ListenableFuture<?>> responses,
Map<T, ? extends ListenableFuture<?>> responses, ExecutorService executor, ExecutorService executor, @Nullable Long maxTime, final Logger logger, final String logPrefix) {
@Nullable Long maxTime, final Logger logger, final String logPrefix) {
if (responses.size() == 0) if (responses.size() == 0)
return ImmutableMap.of(); return ImmutableMap.of();
final int total = responses.size(); final int total = responses.size();
@ -100,36 +99,27 @@ public class ConcurrentUtils {
return errorMap; return errorMap;
} }
private static void logException(Logger logger, String logPrefix, int total, int complete, private static void logException(Logger logger, String logPrefix, int total, int complete, int errors, long start,
int errors, long start, Exception e) { Exception e) {
String message = message(logPrefix, total, complete, errors, start); String message = message(logPrefix, total, complete, errors, start);
logger.error(e, message); logger.error(e, message);
} }
private static String message(String prefix, int size, int complete, int errors, long start) { private static String message(String prefix, int size, int complete, int errors, long start) {
return String.format("%s, completed: %d/%d, errors: %d, rate: %dms/op", prefix, complete, return String.format("%s, completed: %d/%d, errors: %d, rate: %dms/op", prefix, complete, size, errors,
size, errors, (long) ((System.currentTimeMillis() - start) / ((double) size))); (long) ((System.currentTimeMillis() - start) / ((double) size)));
} }
protected static boolean timeOut(long start, Long maxTime) { protected static boolean timeOut(long start, Long maxTime) {
return maxTime != null ? System.currentTimeMillis() < start + maxTime : false; return maxTime != null ? System.currentTimeMillis() < start + maxTime : false;
} }
/**
* Converts an exception into an object, which is useful for transforming to null or false.
*/
public static <T> ListenableFuture<T> convertExceptionToValue(ListenableFuture<T> future,
Class<? extends Exception> clazz, T toValue) {
return new ConvertFutureExceptionToValue<T>(future, clazz, toValue);
}
/** /**
* Just like {@code Futures#makeListenable} except that we pass in an executorService. * Just like {@code Futures#makeListenable} except that we pass in an executorService.
* <p/> * <p/>
* Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed. * Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed.
*/ */
public static <T> ListenableFuture<T> makeListenable(Future<T> future, public static <T> ListenableFuture<T> makeListenable(Future<T> future, ExecutorService executorService) {
ExecutorService executorService) {
if (future instanceof ListenableFuture<?>) { if (future instanceof ListenableFuture<?>) {
return (ListenableFuture<T>) future; return (ListenableFuture<T>) future;
} }
@ -141,8 +131,7 @@ public class ConcurrentUtils {
* <p/> * <p/>
* Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed. * Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed.
*/ */
private static class ListenableFutureAdapter<T> extends ForwardingFuture<T> implements private static class ListenableFutureAdapter<T> extends ForwardingFuture<T> implements ListenableFuture<T> {
ListenableFuture<T> {
private final Executor adapterExecutor; private final Executor adapterExecutor;