public abstract class ModuleRedeployer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ModuleRedeployer.ModuleDeployment
Holds information about a module that needs to be re-deployed.
|
| Modifier and Type | Field and Description |
|---|---|
protected JobFactory |
jobFactory
Job factory.
|
protected org.apache.curator.framework.recipes.cache.PathChildrenCache |
moduleDeploymentRequests
Cache of children under the module deployment requests path.
|
protected StreamFactory |
streamFactory
Stream factory.
|
| Constructor and Description |
|---|
ModuleRedeployer(ZooKeeperConnection zkConnection,
ContainerRepository containerRepository,
StreamFactory streamFactory,
JobFactory jobFactory,
org.apache.curator.framework.recipes.cache.PathChildrenCache moduleDeploymentRequests,
ContainerMatcher containerMatcher,
DeploymentUnitStateCalculator stateCalculator)
Constructs
ModuleRedeployer |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
deployModules(Container container)
Deploy unallocated/orphaned modules.
|
protected java.util.List<ModuleDeploymentRequestsPath> |
getAllModuleDeploymentRequests()
Get all the module deployment requests.
|
protected org.apache.curator.framework.CuratorFramework |
getClient()
Return the Curator framework client.
|
protected ContainerMatcher |
instantiateContainerMatcher(ModuleDescriptor moduleDescriptor)
Return a
ContainerMatcher that
will exclude containers that are already hosting the module. |
protected void |
logUnwantedRedeployment(java.lang.String criteria,
java.lang.String moduleLabel)
Log unwanted re-deployment of the module if the module count is less
than or equal to zero.
|
protected void |
redeployModule(ModuleRedeployer.ModuleDeployment moduleDeployment,
boolean arriving)
Redeploy a module to a container.
|
protected void |
updateDeploymentUnitState(ModuleRedeployer.ModuleDeployment moduleDeployment,
ModuleDeploymentStatus deploymentStatus)
Update the ZooKeeper ephemeral node that indicates the status for the
provided deployment unit.
|
protected final org.apache.curator.framework.recipes.cache.PathChildrenCache moduleDeploymentRequests
protected final StreamFactory streamFactory
protected final JobFactory jobFactory
public ModuleRedeployer(ZooKeeperConnection zkConnection, ContainerRepository containerRepository, StreamFactory streamFactory, JobFactory jobFactory, org.apache.curator.framework.recipes.cache.PathChildrenCache moduleDeploymentRequests, ContainerMatcher containerMatcher, DeploymentUnitStateCalculator stateCalculator)
ModuleRedeployerzkConnection - ZooKeeper connectioncontainerRepository - the repository to find the containersstreamFactory - factory to construct StreamjobFactory - factory to construct JobmoduleDeploymentRequests - cache of children for requested module deployments pathcontainerMatcher - matches modules to containersstateCalculator - calculator for stream/job stateprotected abstract void deployModules(Container container) throws java.lang.Exception
container - the container to deployjava.lang.Exceptionprotected org.apache.curator.framework.CuratorFramework getClient()
protected ContainerMatcher instantiateContainerMatcher(ModuleDescriptor moduleDescriptor) throws java.lang.Exception
ContainerMatcher that
will exclude containers that are already hosting the module.moduleDescriptor - containers that have deployed this module
will be excluded from the results returned
by the ContainerMatcher.java.lang.Exceptionprotected void logUnwantedRedeployment(java.lang.String criteria,
java.lang.String moduleLabel)
criteria - the criteria for the module deploymentmoduleLabel - the module labelprotected void redeployModule(ModuleRedeployer.ModuleDeployment moduleDeployment, boolean arriving) throws java.lang.Exception
moduleDeployment - contains module redeployment details such as
stream, module descriptor, and deployment propertiesarriving - if true, this module redeployment is being triggered
by an arriving container; if false this is being
triggered by a departing containerjava.lang.InterruptedExceptionjava.lang.Exceptionprotected void updateDeploymentUnitState(ModuleRedeployer.ModuleDeployment moduleDeployment, ModuleDeploymentStatus deploymentStatus) throws java.lang.Exception
moduleDeployment - module that a redeploy was attempted fordeploymentStatus - deployment status for the module; may be null
if a module deployment was not attempted
(for example if there were no containers
available for deployment)java.lang.Exceptionprotected java.util.List<ModuleDeploymentRequestsPath> getAllModuleDeploymentRequests()