mirror of https://github.com/apache/jclouds.git
Use Futures.getUnchecked to get strategy results
This commit is contained in:
parent
2576362e98
commit
3db6ee4c27
|
@ -19,13 +19,12 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -59,10 +58,6 @@ public class DeleteAllClientsInListImpl implements DeleteAllClientsInList {
|
|||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
DeleteAllClientsInListImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecuor");
|
||||
|
@ -89,11 +84,7 @@ public class DeleteAllClientsInListImpl implements DeleteAllClientsInList {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("deleting clients: %s", Joiner.on(',').join(names)));
|
||||
futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("deleting clients: %s", Joiner.on(',').join(names)));
|
||||
getUnchecked(futures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -58,10 +57,6 @@ public class DeleteAllNodesInListImpl implements DeleteAllNodesInList {
|
|||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
DeleteAllNodesInListImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecuor");
|
||||
|
@ -87,11 +82,7 @@ public class DeleteAllNodesInListImpl implements DeleteAllNodesInList {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("deleting nodes: %s", Joiner.on(',').join(names)));
|
||||
futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("deleting nodes: %s", Joiner.on(',').join(names)));
|
||||
getUnchecked(futures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -60,10 +59,6 @@ public class ListClientsImpl implements ListClients {
|
|||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListClientsImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecuor");
|
||||
|
@ -110,12 +105,8 @@ public class ListClientsImpl implements ListClients {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("getting clients: %s", Joiner.on(',').join(toGet)));
|
||||
return futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("getting clients: %s", Joiner.on(',').join(toGet)));
|
||||
return getUnchecked(futures);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -61,10 +60,6 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListCookbookVersionsImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecuor");
|
||||
|
@ -119,12 +114,8 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("getting versions of cookbook: " + cookbook));
|
||||
return futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("getting versions of cookbook: " + cookbook));
|
||||
return getUnchecked(futures);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -54,9 +53,6 @@ public class ListEnvironmentsImpl implements ListEnvironments {
|
|||
@Resource
|
||||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListEnvironmentsImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
|
@ -105,11 +101,7 @@ public class ListEnvironmentsImpl implements ListEnvironments {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("deleting environments: %s", Joiner.on(',').join(toGet)));
|
||||
return futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("deleting environments: %s", Joiner.on(',').join(toGet)));
|
||||
return getUnchecked(futures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -60,10 +59,6 @@ public class ListNodesImpl implements ListNodes {
|
|||
@Named(ChefProperties.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListNodesImpl(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, ChefApi api) {
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecuor");
|
||||
|
@ -109,12 +104,8 @@ public class ListNodesImpl implements ListNodes {
|
|||
}
|
||||
}));
|
||||
|
||||
try {
|
||||
logger.trace(String.format("getting nodes: %s", Joiner.on(',').join(toGet)));
|
||||
return futures.get(maxTime, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
logger.trace(String.format("getting nodes: %s", Joiner.on(',').join(toGet)));
|
||||
return getUnchecked(futures);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue