@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,
ExecutorService executor,
com.google.common.base.Optional<ImageExtension> imageExtension) |
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<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.
|
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<ComputeMetadata> |
listNodes()
all nodes available to the current user by id.
|
Set<? extends NodeMetadata> |
listNodesDetailsMatching(com.google.common.base.Predicate<ComputeMetadata> 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.
|
void |
rebootNodesMatching(com.google.common.base.Predicate<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. |
void |
resumeNodesMatching(com.google.common.base.Predicate<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<NodeMetadata> filter,
Statement runScript) |
Map<NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<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<NodeMetadata> filter,
String runScript) |
Map<? extends NodeMetadata,ExecResponse> |
runScriptOnNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter,
String runScript,
RunScriptOptions options) |
com.google.common.util.concurrent.ListenableFuture<ExecResponse> |
submitScriptOnNode(String id,
Statement 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.
|
void |
suspendNodesMatching(com.google.common.base.Predicate<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") ExecutorService executor, com.google.common.base.Optional<ImageExtension> imageExtension)
public ComputeServiceContext getContext()
getContext
in interface ComputeService
public 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 ComputeService
group
- - 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
ComputeService
ComputeService.createNodesInGroup(String,int,Template)
, except that the template
is default, equivalent to templateBuilder().any().options(templateOptions)
.createNodesInGroup
in interface ComputeService
RunNodesException
public Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException
ComputeService
ComputeService.createNodesInGroup(String,int,TemplateOptions)
, except that the
options are default, as specified in ComputeService.templateOptions()
.createNodesInGroup
in interface ComputeService
RunNodesException
public void destroyNode(String id)
destroyNode
in interface ComputeService
public Set<? extends NodeMetadata> destroyNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter)
destroyNodesMatching
in interface ComputeService
@Nullable protected NodeMetadata doDestroyNode(String id)
id
- protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes)
public Set<ComputeMetadata> listNodes()
NodeMetadata
objects.listNodes
in interface ComputeService
public Set<? extends NodeMetadata> listNodesDetailsMatching(com.google.common.base.Predicate<ComputeMetadata> filter)
listNodesDetailsMatching
in interface ComputeService
filter
- how to select the nodes you are interested in details on.public Set<? extends Hardware> listHardwareProfiles()
listHardwareProfiles
in interface ComputeService
public Set<? extends Image> listImages()
listImages
in interface ComputeService
public Set<? extends Location> listAssignableLocations()
listAssignableLocations
in interface ComputeService
public TemplateBuilder templateBuilder()
templateBuilder
in interface ComputeService
public NodeMetadata getNodeMetadata(String id)
getNodeMetadata
in interface ComputeService
public Image getImage(String id)
getImage
in interface ComputeService
public void rebootNode(String id)
rebootNode
in interface ComputeService
public void rebootNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter)
rebootNodesMatching
in interface ComputeService
public void resumeNode(String id)
suspended
state,
given its id.
resumeNode
in interface ComputeService
public void resumeNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter)
resumeNodesMatching
in interface ComputeService
public void suspendNode(String id)
suspended
state.
suspendNode
in interface ComputeService
public void suspendNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter)
suspendNodesMatching
in interface ComputeService
public Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter, String runScript) throws RunScriptOnNodesException
runScriptOnNodesMatching
in interface ComputeService
RunScriptOnNodesException
ComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
public Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter, Statement runScript) throws RunScriptOnNodesException
runScriptOnNodesMatching
in interface ComputeService
RunScriptOnNodesException
ComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
public Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter, String runScript, RunScriptOptions options) throws RunScriptOnNodesException
runScriptOnNodesMatching
in interface ComputeService
RunScriptOnNodesException
ComputeService.runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
public Map<NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<NodeMetadata> filter, Statement runScript, RunScriptOptions options) throws RunScriptOnNodesException
runScriptOnNodesMatching
in interface ComputeService
filter
- 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)
,
Statements
public ExecResponse runScriptOnNode(String id, String runScript)
runScriptOnNode
in interface ComputeService
ComputeService.runScriptOnNode(String, String, RunScriptOptions)
public ExecResponse runScriptOnNode(String id, String runScript, RunScriptOptions options)
runScriptOnNode
in interface ComputeService
ComputeService.runScriptOnNode(String, Statement, RunScriptOptions)
,
Statements.exec(java.lang.String)
public ExecResponse runScriptOnNode(String id, Statement runScript)
runScriptOnNode
in interface ComputeService
ComputeService.runScriptOnNode(String, Statement, RunScriptOptions)
public ExecResponse runScriptOnNode(String id, Statement runScript, RunScriptOptions options)
runScriptOnNode
in interface ComputeService
id
- 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)
,
Statements
public com.google.common.util.concurrent.ListenableFuture<ExecResponse> submitScriptOnNode(String id, Statement runScript, RunScriptOptions options)
nohup
submitScriptOnNode
in interface ComputeService
id
- 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)
,
Statements
public TemplateOptions templateOptions()
ComputeService
templateOptions
in interface ComputeService
protected 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 ComputeService
ImageExtension
or Optional.absent()
if not
implementedCopyright © 2009-2013 jclouds. All Rights Reserved.