mirror of https://github.com/apache/jclouds.git
renamed tag -> group
removed old language in exception about tag
This commit is contained in:
parent
7e32b0624d
commit
9d36c3e4b0
|
@ -35,26 +35,26 @@ public class RunNodesException extends Exception {
|
||||||
|
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = -2272965726680821281L;
|
private static final long serialVersionUID = -2272965726680821281L;
|
||||||
private final String tag;
|
private final String group;
|
||||||
private final int count;
|
private final int count;
|
||||||
private final Template template;
|
private final Template template;
|
||||||
private final Set<? extends NodeMetadata> successfulNodes;
|
private final Set<? extends NodeMetadata> successfulNodes;
|
||||||
private final Map<? extends NodeMetadata, ? extends Throwable> failedNodes;
|
private final Map<? extends NodeMetadata, ? extends Throwable> failedNodes;
|
||||||
private final Map<?, Exception> executionExceptions;
|
private final Map<?, Exception> executionExceptions;
|
||||||
|
|
||||||
public RunNodesException(String tag, int count, Template template,
|
public RunNodesException(String group, int count, Template template,
|
||||||
Set<? extends NodeMetadata> successfulNodes, Map<?, Exception> executionExceptions,
|
Set<? extends NodeMetadata> successfulNodes, Map<?, Exception> executionExceptions,
|
||||||
Map<? extends NodeMetadata, ? extends Throwable> failedNodes) {
|
Map<? extends NodeMetadata, ? extends Throwable> failedNodes) {
|
||||||
super(
|
super(
|
||||||
String
|
String
|
||||||
.format(
|
.format(
|
||||||
"error running %d node%s tag(%s) location(%s) image(%s) size(%s) options(%s)%n%s%n%s",
|
"error running %d node%s group(%s) location(%s) image(%s) size(%s) options(%s)%n%s%n%s",
|
||||||
count, count > 1 ? "s" : "", tag, template.getLocation().getId(),
|
count, count > 1 ? "s" : "", group, template.getLocation().getId(),
|
||||||
template.getImage().getProviderId(), template.getHardware()
|
template.getImage().getProviderId(), template.getHardware()
|
||||||
.getProviderId(), template.getOptions(),
|
.getProviderId(), template.getOptions(),
|
||||||
createExecutionErrorMessage(executionExceptions),
|
createExecutionErrorMessage(executionExceptions),
|
||||||
createNodeErrorMessage(failedNodes)));
|
createNodeErrorMessage(failedNodes)));
|
||||||
this.tag = tag;
|
this.group = group;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.template = template;
|
this.template = template;
|
||||||
this.successfulNodes = successfulNodes;
|
this.successfulNodes = successfulNodes;
|
||||||
|
@ -86,8 +86,8 @@ public class RunNodesException extends Exception {
|
||||||
return failedNodes;
|
return failedNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getGroup() {
|
||||||
return tag;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
|
|
|
@ -62,12 +62,12 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
|
|
||||||
private class AddNode implements Callable<NodeMetadata> {
|
private class AddNode implements Callable<NodeMetadata> {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String tag;
|
private final String group;
|
||||||
private final Template template;
|
private final Template template;
|
||||||
|
|
||||||
private AddNode(String name, String tag, Template template) {
|
private AddNode(String name, String group, Template template) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.tag = checkNotNull(tag, "tag");
|
this.group = checkNotNull(group, "group");
|
||||||
this.template = checkNotNull(template, "template");
|
this.template = checkNotNull(template, "template");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)",
|
logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)",
|
||||||
template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware()
|
template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware()
|
||||||
.getProviderId());
|
.getProviderId());
|
||||||
node = addNodeWithTagStrategy.createNodeWithGroupEncodedIntoName(tag, name, template);
|
node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template);
|
||||||
logger.debug("<< %s node(%s)", node.getState(), node.getId());
|
logger.debug("<< %s node(%s)", node.getState(), node.getId());
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper(this).add("name", name).add("tag", tag).add("template", template).toString();
|
return toStringHelper(this).add("name", name).add("group", group).add("template", template).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
protected final CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy;
|
protected final CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy;
|
||||||
protected final ListNodesStrategy listNodesStrategy;
|
protected final ListNodesStrategy listNodesStrategy;
|
||||||
protected final String nodeNamingConvention;
|
protected final String nodeNamingConvention;
|
||||||
protected final ExecutorService executor;
|
protected final ExecutorService executor;
|
||||||
|
@ -99,12 +99,12 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected CreateNodesWithGroupEncodedIntoNameThenAddToSet(
|
protected CreateNodesWithGroupEncodedIntoNameThenAddToSet(
|
||||||
CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy,
|
CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy,
|
||||||
ListNodesStrategy listNodesStrategy,
|
ListNodesStrategy listNodesStrategy,
|
||||||
@Named("NAMING_CONVENTION") String nodeNamingConvention,
|
@Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||||
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory) {
|
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory) {
|
||||||
this.addNodeWithTagStrategy = addNodeWithTagStrategy;
|
this.addNodeWithGroupStrategy = addNodeWithGroupStrategy;
|
||||||
this.listNodesStrategy = listNodesStrategy;
|
this.listNodesStrategy = listNodesStrategy;
|
||||||
this.nodeNamingConvention = nodeNamingConvention;
|
this.nodeNamingConvention = nodeNamingConvention;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
|
@ -112,15 +112,15 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation gets a list of acceptable node names to encode the tag into, then it
|
* This implementation gets a list of acceptable node names to encode the group into, then it
|
||||||
* simultaneously runs the nodes and applies options to them.
|
* simultaneously runs the nodes and applies options to them.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> goodNodes,
|
public Map<?, Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||||
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
|
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
|
||||||
Map<String, Future<Void>> responses = newLinkedHashMap();
|
Map<String, Future<Void>> responses = newLinkedHashMap();
|
||||||
for (String name : getNextNames(tag, template, count)) {
|
for (String name : getNextNames(group, template, count)) {
|
||||||
responses.put(name, compose(executor.submit(new AddNode(name, tag, template)),
|
responses.put(name, compose(executor.submit(new AddNode(name, group, template)),
|
||||||
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory.create(template.getOptions(),
|
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory.create(template.getOptions(),
|
||||||
goodNodes, badNodes, customizationResponses), executor));
|
goodNodes, badNodes, customizationResponses), executor));
|
||||||
}
|
}
|
||||||
|
@ -128,22 +128,22 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the next node names that can be used. These will be derived from the tag and the
|
* Find the next node names that can be used. These will be derived from the group and the
|
||||||
* template. We will pre-allocate a specified quantity, and attempt to verify that there is no
|
* template. We will pre-allocate a specified quantity, and attempt to verify that there is no
|
||||||
* name conflict with the current service.
|
* name conflict with the current service.
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param group
|
||||||
* @param count
|
* @param count
|
||||||
* @param template
|
* @param template
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected Set<String> getNextNames(final String tag, final Template template, int count) {
|
protected Set<String> getNextNames(final String group, final Template template, int count) {
|
||||||
Set<String> names = newLinkedHashSet();
|
Set<String> names = newLinkedHashSet();
|
||||||
Iterable<? extends ComputeMetadata> currentNodes = listNodesStrategy.listNodes();
|
Iterable<? extends ComputeMetadata> currentNodes = listNodesStrategy.listNodes();
|
||||||
int maxTries = 100;
|
int maxTries = 100;
|
||||||
int currentTries = 0;
|
int currentTries = 0;
|
||||||
while (names.size() < count && currentTries++ < maxTries) {
|
while (names.size() < count && currentTries++ < maxTries) {
|
||||||
final String name = getNextName(tag, template);
|
final String name = getNextName(group, template);
|
||||||
if (!any(currentNodes, new Predicate<ComputeMetadata>() {
|
if (!any(currentNodes, new Predicate<ComputeMetadata>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -159,14 +159,14 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a name using a random mechanism that still ties all nodes in a tag together.
|
* Get a name using a random mechanism that still ties all nodes in a group together.
|
||||||
*
|
*
|
||||||
* This implementation will pass the tag and a hex formatted random number to the configured
|
* This implementation will pass the group and a hex formatted random number to the configured
|
||||||
* naming convention.
|
* naming convention.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected String getNextName(final String tag, final Template template) {
|
protected String getNextName(final String group, final Template template) {
|
||||||
return String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
|
return String.format(nodeNamingConvention, group, Integer.toHexString(new SecureRandom().nextInt(4095)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue