@Singleton public class BaseComputeService extends Object implements ComputeService
| Modifier and Type | Field and Description |
|---|---|
protected ComputeServiceContext |
context |
protected Map<String,Credentials> |
credentialStore |
protected Logger |
logger |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseComputeService(ComputeServiceContext context,
Map<String,Credentials> credentialStore,
com.google.common.base.Supplier<Set<? extends Image>> images,
com.google.common.base.Supplier<Set<? extends Hardware>> hardwareProfiles,
com.google.common.base.Supplier<Set<? extends Location>> locations,
ListNodesStrategy listNodesStrategy,
GetImageStrategy getImageStrategy,
GetNodeMetadataStrategy getNodeMetadataStrategy,
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy,
ResumeNodeStrategy resumeNodeStrategy,
SuspendNodeStrategy suspendNodeStrategy,
javax.inject.Provider<TemplateBuilder> templateBuilderProvider,
javax.inject.Provider<TemplateOptions> templateOptionsProvider,
com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeRunning,
com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
InitAdminAccess initAdminAccess,
RunScriptOnNode.Factory runScriptOnNodeFactory,
PersistNodeCredentials persistNodeCredentials,
ComputeServiceConstants.Timeouts timeouts,
com.google.common.util.concurrent.ListeningExecutorService userExecutor,
com.google.common.base.Optional<ImageExtension> imageExtension,
com.google.common.base.Optional<SecurityGroupExtension> securityGroupExtension) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) |
Set<? extends NodeMetadata> |
createNodesInGroup(String group,
int count)
Like
ComputeService.createNodesInGroup(String,int,TemplateOptions), except that the
options are default, as specified in ComputeService.templateOptions(). |
Set<? extends NodeMetadata> |
createNodesInGroup(String group,
int count,
Template template)
The compute api treats nodes as a group based on the name you specify.
|
Set<? extends NodeMetadata> |
createNodesInGroup(String group,
int count,
TemplateOptions templateOptions)
Like
ComputeService.createNodesInGroup(String,int,Template), except that the template
is default, equivalent to templateBuilder().any().options(templateOptions). |
void |
destroyNode(String id)
destroy the node, given its id.
|
Set<? extends NodeMetadata> |
destroyNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
nodes matching the filter are treated as a logical set.
|
protected NodeMetadata |
doDestroyNode(String id) |
ComputeServiceContext |
getContext() |
Image |
getImage(String id)
Find an image by its id.
|
com.google.common.base.Optional<ImageExtension> |
getImageExtension()
Returns the
ImageExtension for this provider if it implements it. |
NodeMetadata |
getNodeMetadata(String id)
Find a node by its id.
|
com.google.common.base.Optional<SecurityGroupExtension> |
getSecurityGroupExtension()
Returns the
SecurityGroupExtension for this provider if it implements it. |
Set<? extends Location> |
listAssignableLocations()
The list locations command returns all the valid locations for nodes.
|
Set<? extends Hardware> |
listHardwareProfiles()
The list hardware profiles command shows you the options including virtual cpu count, memory,
and disks.
|
Set<? extends Image> |
listImages()
Images define the operating system and metadata related to a node.
|
Set<? extends ComputeMetadata> |
listNodes() |
Set<? extends NodeMetadata> |
listNodesByIds(Iterable<String> ids) |
Set<? extends NodeMetadata> |
listNodesDetailsMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
get all nodes including details such as image and ip addresses even if it incurs extra
requests to the service.
|
void |
rebootNode(String id)
reboot the node, given its id.
|
Set<? extends NodeMetadata> |
rebootNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
nodes matching the filter are treated as a logical set.
|
void |
resumeNode(String id)
resume the node from
suspended state,
given its id. |
Set<? extends NodeMetadata> |
resumeNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
nodes matching the filter are treated as a logical set.
|
ExecResponse |
runScriptOnNode(String id,
Statement runScript) |
ExecResponse |
runScriptOnNode(String id,
Statement runScript,
RunScriptOptions options)
Run the script on a specific node
|
ExecResponse |
runScriptOnNode(String id,
String runScript) |
ExecResponse |
runScriptOnNode(String id,
String runScript,
RunScriptOptions options) |
Map<NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter,
Statement runScript) |
Map<NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter,
Statement runScript,
RunScriptOptions options)
Run the script on all nodes with the specific predicate.
|
Map<NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter,
String runScript) |
Map<? extends NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter,
String runScript,
RunScriptOptions options) |
com.google.common.util.concurrent.ListenableFuture<ExecResponse> |
submitScriptOnNode(String id,
Statement runScript,
RunScriptOptions options) |
com.google.common.util.concurrent.ListenableFuture<ExecResponse> |
submitScriptOnNode(String id,
String runScript,
RunScriptOptions options)
Run the script on a specific node in the background, typically as
nohup |
void |
suspendNode(String id)
suspend the node, given its id.
|
Set<? extends NodeMetadata> |
suspendNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
nodes matching the filter are treated as a logical set.
|
TemplateBuilder |
templateBuilder()
Makes a new template builder for this service
|
TemplateOptions |
templateOptions()
Makes a new set of options for running nodes
|
protected NodeMetadata |
updateNodeWithCredentialsIfPresent(NodeMetadata node,
RunScriptOptions options) |
@Named(value="jclouds.compute") protected Logger logger
protected final ComputeServiceContext context
protected final Map<String,Credentials> credentialStore
@Inject protected BaseComputeService(ComputeServiceContext context, Map<String,Credentials> credentialStore, com.google.common.base.Supplier<Set<? extends Image>> images, com.google.common.base.Supplier<Set<? extends Hardware>> hardwareProfiles, com.google.common.base.Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy, GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy, javax.inject.Provider<TemplateBuilder> templateBuilderProvider, @Named(value="DEFAULT") javax.inject.Provider<TemplateOptions> templateOptionsProvider, @Named(value="jclouds.compute.timeout.node-running") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeRunning, @Named(value="jclouds.compute.timeout.node-terminated") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeTerminated, @Named(value="jclouds.compute.timeout.node-suspended") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeSuspended, InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, InitAdminAccess initAdminAccess, RunScriptOnNode.Factory runScriptOnNodeFactory, PersistNodeCredentials persistNodeCredentials, ComputeServiceConstants.Timeouts timeouts, @Named(value="jclouds.user-threads") com.google.common.util.concurrent.ListeningExecutorService userExecutor, com.google.common.base.Optional<ImageExtension> imageExtension, com.google.common.base.Optional<SecurityGroupExtension> securityGroupExtension)
public ComputeServiceContext getContext()
getContext in interface ComputeServicepublic Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template) throws RunNodesException
ComputeService
if (node.getCredentials().key.startsWith("-----BEGIN RSA PRIVATE KEY-----"))
// it is a private key, not a password.
Note. if all you want to do is execute a script at bootup, you should consider use of the
runscript option.
If resources such as security groups are needed, they will be reused or created for you.
Inbound port 22 will always be opened up.
createNodesInGroup in interface ComputeServicegroup - - common identifier to group nodes bycount - - how many to fire up.template - - how to configure the nodesRunNodesException - when there's a problem applying options to nodes. Note that successful and failed
nodes are a part of this exception, so be sure to inspect this carefully.public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, TemplateOptions templateOptions) throws RunNodesException
ComputeServiceComputeService.createNodesInGroup(String,int,Template), except that the template
is default, equivalent to templateBuilder().any().options(templateOptions).createNodesInGroup in interface ComputeServiceRunNodesExceptionpublic Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException
ComputeServiceComputeService.createNodesInGroup(String,int,TemplateOptions), except that the
options are default, as specified in ComputeService.templateOptions().createNodesInGroup in interface ComputeServiceRunNodesExceptionpublic void destroyNode(String id)
destroyNode in interface ComputeServicepublic Set<? extends NodeMetadata> destroyNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
destroyNodesMatching in interface ComputeService@Nullable protected NodeMetadata doDestroyNode(String id)
id - protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes)
public Set<? extends ComputeMetadata> listNodes()
listNodes in interface ComputeServiceNodeMetadata objects.public Set<? extends NodeMetadata> listNodesByIds(Iterable<String> ids)
listNodesByIds in interface ComputeServicepublic Set<? extends NodeMetadata> listNodesDetailsMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
listNodesDetailsMatching in interface ComputeServicefilter - how to select the nodes you are interested in details on.public Set<? extends Hardware> listHardwareProfiles()
listHardwareProfiles in interface ComputeServicepublic Set<? extends Image> listImages()
listImages in interface ComputeServicepublic Set<? extends Location> listAssignableLocations()
listAssignableLocations in interface ComputeServicepublic TemplateBuilder templateBuilder()
templateBuilder in interface ComputeServicepublic NodeMetadata getNodeMetadata(String id)
getNodeMetadata in interface ComputeServicepublic Image getImage(String id)
getImage in interface ComputeServicepublic void rebootNode(String id)
rebootNode in interface ComputeServicepublic Set<? extends NodeMetadata> rebootNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
rebootNodesMatching in interface ComputeServicepublic void resumeNode(String id)
suspended state,
given its id.
resumeNode in interface ComputeServicepublic Set<? extends NodeMetadata> resumeNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
resumeNodesMatching in interface ComputeServicepublic void suspendNode(String id)
suspended state.
suspendNode in interface ComputeServicepublic Set<? extends NodeMetadata> suspendNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter)
suspendNodesMatching in interface ComputeServicepublic Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript) throws RunScriptOnNodesException
runScriptOnNodesMatching in interface ComputeServiceRunScriptOnNodesExceptionComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)public Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript) throws RunScriptOnNodesException
runScriptOnNodesMatching in interface ComputeServiceRunScriptOnNodesExceptionComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)public Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript, RunScriptOptions options) throws RunScriptOnNodesException
runScriptOnNodesMatching in interface ComputeServiceRunScriptOnNodesExceptionComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)public Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript, RunScriptOptions options) throws RunScriptOnNodesException
runScriptOnNodesMatching in interface ComputeServicefilter - Predicate-based filter to define on which nodes the script is to be executedrunScript - statement containing the script to runoptions - nullable options to how to run the script, whether to override credentialsRunScriptOnNodesException - if anything goes wrong during script executionNodePredicates.runningInGroup(String),
Statementspublic ExecResponse runScriptOnNode(String id, String runScript)
runScriptOnNode in interface ComputeServiceComputeService.runScriptOnNode(String, String, RunScriptOptions)public ExecResponse runScriptOnNode(String id, String runScript, RunScriptOptions options)
runScriptOnNode in interface ComputeServiceComputeService.runScriptOnNode(String, Statement, RunScriptOptions),
Statements.exec(java.lang.String)public ExecResponse runScriptOnNode(String id, Statement runScript)
runScriptOnNode in interface ComputeServiceComputeService.runScriptOnNode(String, Statement, RunScriptOptions)public ExecResponse runScriptOnNode(String id, Statement runScript, RunScriptOptions options)
runScriptOnNode in interface ComputeServiceid - node the script is to be executed onrunScript - statement containing the script to runoptions - nullable options to how to run the script, whether to override credentialsNodePredicates.runningInGroup(String),
Statementspublic com.google.common.util.concurrent.ListenableFuture<ExecResponse> submitScriptOnNode(String id, String runScript, RunScriptOptions options)
nohupsubmitScriptOnNode in interface ComputeServiceid - node the script is to be executed onrunScript - statement containing the script to runoptions - nullable options to how to run the script, whether to override credentialsNodePredicates.runningInGroup(String),
Statementspublic com.google.common.util.concurrent.ListenableFuture<ExecResponse> submitScriptOnNode(String id, Statement runScript, RunScriptOptions options)
submitScriptOnNode in interface ComputeServicepublic TemplateOptions templateOptions()
ComputeServicetemplateOptions in interface ComputeServiceprotected NodeMetadata updateNodeWithCredentialsIfPresent(NodeMetadata node, RunScriptOptions options)
public com.google.common.base.Optional<ImageExtension> getImageExtension()
ImageExtension for this provider if it implements it.getImageExtension in interface ComputeServiceImageExtension or Optional.absent() if not
implementedpublic com.google.common.base.Optional<SecurityGroupExtension> getSecurityGroupExtension()
SecurityGroupExtension for this provider if it implements it.getSecurityGroupExtension in interface ComputeServiceSecurityGroupExtension or Optional.absent() if not
implementedCopyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.