mirror of https://github.com/apache/jclouds.git
Merge pull request #718 from grkvlt/transform-parallel-timeout
Timeouts on FutureIterables.transformParallel
This commit is contained in:
commit
a979c31d8c
|
@ -31,7 +31,6 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -51,6 +50,7 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -58,10 +58,15 @@ import com.google.common.collect.ImmutableSet;
|
|||
*/
|
||||
@Singleton
|
||||
public class EC2ListNodesStrategy implements ListNodesStrategy {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected static Long maxTime;
|
||||
|
||||
protected final EC2AsyncClient client;
|
||||
protected final Supplier<Set<String>> regions;
|
||||
protected final Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata;
|
||||
|
@ -100,7 +105,7 @@ public class EC2ListNodesStrategy implements ListNodesStrategy {
|
|||
return castToSpecificTypedFuture(client.getInstanceServices().describeInstancesInRegion(from));
|
||||
}
|
||||
|
||||
}, executor, null, logger, "reservations");
|
||||
}, executor, maxTime, logger, "reservations");
|
||||
|
||||
return concat(concat(reservations));
|
||||
}
|
||||
|
|
|
@ -137,9 +137,10 @@ public class FutureIterables {
|
|||
errors.incrementAndGet();
|
||||
logException(logger, logPrefix, total, complete.get(), errors.get(), start, e);
|
||||
errorMap.put(future.getKey(), e);
|
||||
}
|
||||
} finally {
|
||||
doneSignal.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -148,10 +149,11 @@ public class FutureIterables {
|
|||
}, exec);
|
||||
}
|
||||
try {
|
||||
if (maxTime != null)
|
||||
if (maxTime != null) {
|
||||
doneSignal.await(maxTime, TimeUnit.MILLISECONDS);
|
||||
else
|
||||
} else {
|
||||
doneSignal.await();
|
||||
}
|
||||
if (errors.get() > 0) {
|
||||
String message = message(logPrefix, total, complete.get(), errors.get(), start);
|
||||
RuntimeException exception = new RuntimeException(message);
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.Set;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -45,6 +44,7 @@ import org.jclouds.location.Region;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
|
|||
.describeSpotInstanceRequestsInRegion(from);
|
||||
}
|
||||
|
||||
}, executor, null, logger, "reservations")), spotConverter), notNull());
|
||||
}, executor, maxTime, logger, "reservations")), spotConverter), notNull());
|
||||
|
||||
return concat(super.pollRunningInstances(), spots);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue