Package org.craftercms.deployer.impl
Class TargetImpl
java.lang.Object
org.craftercms.deployer.impl.TargetImpl
- All Implemented Interfaces:
Target
Default implementation of
Target.- Author:
- avasquez
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classNested classes/interfaces inherited from interface org.craftercms.deployer.api.Target
Target.Status -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.springframework.context.ConfigurableApplicationContextprotected final org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> protected final Fileprotected Deploymentprotected final Lockprotected DeploymentPipelineprotected final DeploymentPipelineFactoryprotected final Stringprotected Map<String, List<TargetEventListener>> protected final ExecutorServiceprotected final ZonedDateTimeprotected final Stringprotected final Queue<Deployment> protected final longprotected ScheduledFuture<?> protected final org.springframework.scheduling.TaskSchedulerprotected final Stringprotected Target.Statusstatic final Stringprotected final TargetEventListenerResolverprotected final TargetLifecycleHooksResolverFields inherited from interface org.craftercms.deployer.api.Target
AUTHORING_ENV, INDEX_ID_FORMAT_CONFIG_KEY -
Constructor Summary
ConstructorsConstructorDescriptionTargetImpl(String env, String siteName, String localRepoPath, File configurationFile, long runtimeThresholdSeconds, TargetEventListenerResolver targetEventListenerResolver, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration, org.springframework.context.ConfigurableApplicationContext applicationContext, ExecutorService executor, org.springframework.scheduling.TaskScheduler scheduler, TargetLifecycleHooksResolver targetLifecycleHooksResolver, DeploymentPipelineFactory deploymentPipelineFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms a cleanup of the local repository.static voidclear()voidclose()Closes the target, releases any open resources and stops any running threads associated to the target.voiddelete()Deletes the target, executing any delete hooks.Starts a new deployment for the target (asynchronous operation ifwaitTillDoneis false).booleanReturns all deployments (pending and current).org.springframework.context.ConfigurableApplicationContextReturns this target's Spring application contextorg.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> Returns the configuration of the target.Returns the YAML configuration file of the target.protected Collection<TargetLifecycleHook> static TargetReturns the current deployment.protected Collection<TargetLifecycleHook> protected Collection<TargetLifecycleHook> getEnv()Returns the environment of the target.getId()Returns the ID of the target.static Stringprotected Collection<TargetLifecycleHook> intReturns the number of retry attempts left for the current deployment.Returns the load date of the target.Returns the pending deployments.longReturn the runtime warning threshold in seconds.Returns the site name of the target.Returns the status of the targetvoidhandleEvent(TargetEvent<?> event) Call the appropriate event listeners for the given event type.inthashCode()voidinit()Starts the initialization of the target (asynchronous operation).protected voidstatic voidsetCurrent(Target target) voidsetInitRetryAttempts(int initRetryAttempts) protected voidtoString()voidunlock()Deletes the git lock file is present in the local repository.
-
Field Details
-
TARGET_ID_FORMAT
- See Also:
-
loadDate
-
env
-
siteName
-
localRepoPath
-
configurationFile
-
runtimeThresholdSeconds
protected final long runtimeThresholdSeconds -
configuration
protected final org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration -
applicationContext
protected final org.springframework.context.ConfigurableApplicationContext applicationContext -
executor
-
scheduler
protected final org.springframework.scheduling.TaskScheduler scheduler -
targetLifecycleHooksResolver
-
deploymentPipelineFactory
-
targetEventListenerResolver
-
status
-
deploymentPipeline
-
scheduledDeploymentFuture
-
pendingDeployments
-
currentDeployment
-
deploymentLock
-
eventListeners
-
-
Constructor Details
-
TargetImpl
public TargetImpl(@Value("${target.env}") String env, @Value("${target.siteName}") String siteName, @Value("${target.localRepoPath}") String localRepoPath, @Value("${target.configFile}") File configurationFile, @Value("${target.runtimeWarningThreshold.seconds}") long runtimeThresholdSeconds, @Autowired TargetEventListenerResolver targetEventListenerResolver, @Autowired org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> configuration, @Autowired org.springframework.context.ConfigurableApplicationContext applicationContext, @Autowired ExecutorService executor, @Autowired org.springframework.scheduling.TaskScheduler scheduler, @Autowired TargetLifecycleHooksResolver targetLifecycleHooksResolver, @Autowired DeploymentPipelineFactory deploymentPipelineFactory)
-
-
Method Details
-
setCurrent
-
getCurrent
-
clear
public static void clear() -
getId
-
getEnv
Description copied from interface:TargetReturns the environment of the target. -
getSiteName
Description copied from interface:TargetReturns the site name of the target.- Specified by:
getSiteNamein interfaceTarget
-
getId
Description copied from interface:TargetReturns the ID of the target. -
getLoadDate
Description copied from interface:TargetReturns the load date of the target.- Specified by:
getLoadDatein interfaceTarget
-
getStatus
Description copied from interface:TargetReturns the status of the target -
getConfigurationFile
Description copied from interface:TargetReturns the YAML configuration file of the target.- Specified by:
getConfigurationFilein interfaceTarget
-
getRuntimeWarningThreshold
public long getRuntimeWarningThreshold()Description copied from interface:TargetReturn the runtime warning threshold in seconds. This is the maximum time a deployment can run before a warning is triggered.- Specified by:
getRuntimeWarningThresholdin interfaceTarget- Returns:
- the runtime threshold in seconds
-
getConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> getConfiguration()Description copied from interface:TargetReturns the configuration of the target.- Specified by:
getConfigurationin interfaceTarget
-
getApplicationContext
public org.springframework.context.ConfigurableApplicationContext getApplicationContext()Description copied from interface:TargetReturns this target's Spring application context- Specified by:
getApplicationContextin interfaceTarget
-
init
public void init()Description copied from interface:TargetStarts the initialization of the target (asynchronous operation). Called when the create target API is called or the target config is loaded. -
deploy
public Deployment deploy(boolean waitTillDone, Map<String, Object> params) throws TargetNotReadyExceptionDescription copied from interface:TargetStarts a new deployment for the target (asynchronous operation ifwaitTillDoneis false).- Specified by:
deployin interfaceTarget- Parameters:
waitTillDone- if the method should wait till the deployment is done or return immediatelyparams- miscellaneous parameters that can be used by the processors.- Returns:
- the deployment info
- Throws:
TargetNotReadyException- if the target is not inTarget.Status.INIT_COMPLETED
-
getPendingDeployments
Description copied from interface:TargetReturns the pending deployments.- Specified by:
getPendingDeploymentsin interfaceTarget
-
getCurrentDeployment
Description copied from interface:TargetReturns the current deployment.- Specified by:
getCurrentDeploymentin interfaceTarget
-
getAllDeployments
Description copied from interface:TargetReturns all deployments (pending and current).- Specified by:
getAllDeploymentsin interfaceTarget
-
getInitRetryAttempts
public int getInitRetryAttempts()Description copied from interface:TargetReturns the number of retry attempts left for the current deployment. This is used to retry deployments a maximum number of attempts if they fail to init after creation- Specified by:
getInitRetryAttemptsin interfaceTarget- Returns:
- the number of retry attempts left
-
cleanRepo
public void cleanRepo()Performs a cleanup of the local repository. -
close
public void close()Description copied from interface:TargetCloses the target, releases any open resources and stops any running threads associated to the target. -
delete
public void delete()Description copied from interface:TargetDeletes the target, executing any delete hooks. CallsTarget.close()too. -
unlock
public void unlock()Description copied from interface:TargetDeletes the git lock file is present in the local repository. -
handleEvent
Description copied from interface:TargetCall the appropriate event listeners for the given event type.- Specified by:
handleEventin interfaceTarget- Parameters:
event- the target event to handle
-
getCreateHooks
protected Collection<TargetLifecycleHook> getCreateHooks() throws org.craftercms.commons.config.ConfigurationException, DeployerException- Throws:
org.craftercms.commons.config.ConfigurationExceptionDeployerException
-
getDuplicateHooks
protected Collection<TargetLifecycleHook> getDuplicateHooks() throws org.craftercms.commons.config.ConfigurationException, DeployerException- Throws:
org.craftercms.commons.config.ConfigurationExceptionDeployerException
-
getInitHooks
protected Collection<TargetLifecycleHook> getInitHooks() throws DeployerException, org.craftercms.commons.config.ConfigurationException- Throws:
DeployerExceptionorg.craftercms.commons.config.ConfigurationException
-
getDeleteHooks
protected Collection<TargetLifecycleHook> getDeleteHooks() throws DeployerException, org.craftercms.commons.config.ConfigurationException- Throws:
DeployerExceptionorg.craftercms.commons.config.ConfigurationException
-
scheduleDeployments
protected void scheduleDeployments() throws org.craftercms.commons.config.ConfigurationException- Throws:
org.craftercms.commons.config.ConfigurationException
-
stopDeployments
protected void stopDeployments() -
setInitRetryAttempts
public void setInitRetryAttempts(int initRetryAttempts) -
equals
-
hashCode
public int hashCode() -
toString
-