public class StackModule extends BaseModule<StackModule,StackInfo> implements Validable
Each stack node is identified by name and version, contains service and configuration child nodes and may extend a single parent stack.
Resolution of a stack is a depth first traversal up the inheritance chain where each stack node calls resolve on its parent before resolving itself. After the parent resolve call returns, all ancestors in the inheritance tree are fully resolved. The act of resolving the stack includes resolution of the configuration and services children of the stack as well as merging of other stack state with the fully resolved parent.
Configuration child node resolution involves merging configuration types, properties and attributes with the fully resolved parent.
Because a service may explicitly extend another service in a stack outside of the inheritance tree, service child node resolution involves a depth first resolution of the stack associated with the services explicit parent, if any. This follows the same steps defined above fore stack node resolution. After the services explicit parent is fully resolved, the services state is merged with it's parent.
If a cycle in a stack definition is detected, an exception is thrown from the resolve call.
Modifier and Type | Field and Description |
---|---|
protected boolean |
valid
validity flag
|
moduleState
Constructor and Description |
---|
StackModule(StackDirectory stackDirectory,
StackContext stackContext)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addError(String error) |
void |
addErrors(Collection<String> errors) |
void |
finalizeModule()
Lifecycle even which is called when the associated stack has been fully resolved.
|
Collection<String> |
getErrors() |
Map<String,ExtensionModule> |
getExtensionModules() |
String |
getId()
Obtain the id of the module.
|
StackInfo |
getModuleInfo()
Obtain the associated module information.
|
Map<String,ServiceModule> |
getServiceModules() |
StackDirectory |
getStackDirectory()
Get the associated stack directory.
|
static URI |
getURI(StackModule module,
String uriString) |
boolean |
isDeleted()
Determine whether the module has been marked for deletion.
|
boolean |
isValid() |
void |
resolve(StackModule parentModule,
Map<String,StackModule> allStacks,
Map<String,ServiceModule> commonServices,
Map<String,ExtensionModule> extensions)
Fully resolve the stack.
|
void |
setValid(boolean valid) |
finalizeChildModules, getModuleState, mergeChildModules
public StackModule(StackDirectory stackDirectory, StackContext stackContext)
stackDirectory
- represents stack directorystackContext
- general stack contextpublic Map<String,ServiceModule> getServiceModules()
public Map<String,ExtensionModule> getExtensionModules()
public void resolve(StackModule parentModule, Map<String,StackModule> allStacks, Map<String,ServiceModule> commonServices, Map<String,ExtensionModule> extensions) throws org.apache.ambari.server.AmbariException
resolve
in interface StackDefinitionModule<StackModule,StackInfo>
parentModule
- not used. Each stack determines its own parent since stacks don't
have containing modulesallStacks
- all stacks modules contained in the stack definitioncommonServices
- all common services specified in the stack definitionextensions
- all extension modules contained in the stack definitionorg.apache.ambari.server.AmbariException
- if an exception occurs during stack resolutionpublic StackInfo getModuleInfo()
StackDefinitionModule
getModuleInfo
in interface StackDefinitionModule<StackModule,StackInfo>
public boolean isDeleted()
StackDefinitionModule
isDeleted
in interface StackDefinitionModule<StackModule,StackInfo>
public String getId()
StackDefinitionModule
getId
in interface StackDefinitionModule<StackModule,StackInfo>
public void finalizeModule()
StackDefinitionModule
finalizeModule
in interface StackDefinitionModule<StackModule,StackInfo>
finalizeModule
in class BaseModule<StackModule,StackInfo>
public StackDirectory getStackDirectory()
public static URI getURI(StackModule module, String uriString)
module
- the stack moduleuriString
- the uri stringpublic boolean isValid()
isValid
in interface StackDefinitionModule<StackModule,StackInfo>
isValid
in interface Validable
public void setValid(boolean valid)
setValid
in interface StackDefinitionModule<StackModule,StackInfo>
setValid
in interface Validable
valid
- set validity flagpublic Collection<String> getErrors()
public void addErrors(Collection<String> errors)
Copyright © 2022 Apache Software Foundation. All rights reserved.