File System Deployment Target

From AlfrescoWiki

Jump to: navigation, search


The file system deployment target deploys WCM content to a local filesystem. By default there is a file system deployment target built into the standalone WCM_Deployment_Engine called "default" and also once included in the web delivery runtime subsystem called "filesystem".

In source code the class inplementing ths file system deployment target is org.alfresco.deployment.impl.fsr.FileSystemDeploymentTarget.


Contents

[edit] File System Deployment Target Metadata

The File System Deployment Target has a simple repository of metadata to track which files, directories and versions are on the target file system. This data is maintained automatically by the File System Deployment Target. It reduces the amount of files that need to be deployed.

In order to force a full redeploy you can safely delete the contents of the metadata directory, but please ensure that a deployment is not already in progress!

The location of the metadata is configured for each target through the metaDataDirectory property.

If there are multiple file system targets on the same deployment engine the configurer should consider whether any of the targets share metadata or have one set of metadata per target. Perhaps the simplest configuration is to use a separate folder for each target's metadata with a folder structure like <receieverRoot>/<metadata>/<targetName>

File System Deployment Targets have functionality to validate that the metadata and the target deployment are consistent. Validation occurs after the deployment engine starts and after detecting an inconsistency. For example trying to delete a file that does not exist or overwriting a file that was outside the control of the File System Deployment Target.

[edit] autofix

The File System Deployment Target can either issue an error upon detecting a problem or automatically fix the problem. There is an autoFix parameter in the definition of the Target which controls whether the File System Deployment Target will attempt to fix the metadata itself or just issue a warning. Set the value to true to fix or false to not fix.

[edit] Configuration

Here is an example target definition for the standalone deployment engine.

	<!--
		Define and register the deployment target called "sampleTarget which
		is used for unit tests"
	-->
	<bean
		class="org.alfresco.deployment.impl.server.DeploymentTargetRegistrationBean"
		init-method="register">

		<!-- What's the name of your target? -->
		<property name="name">
			<value>sampleTarget</value>
		</property>
		
		<!--  Register with the deploymentReceiverEngine -->
		<property name="registry">
			<ref bean="deploymentReceiverEngine" />
		</property>
		
		<property name="target">
		
			<!-- This is the definition of the target - you could also add a reference to a bean which already exists -->
			<bean
				class="org.alfresco.deployment.impl.fsr.FileSystemDeploymentTarget"
				init-method="init">
				
				<!--  Where to store the deployed content -->
				<property name="rootDirectory">
					<value>sampleTarget</value>
				</property>
				
				<!--  where to store meta data for sampleTarget-->
        		<property name="metaDataDirectory">
            		<value>${deployment.filesystem.metadatadir}/sampleTarget</value>
        		</property>
				<property name="autoFix">
					<value>${deployment.filesystem.autofix}</value>
				</property>
				<property name="postCommit">
					<list>
						<bean class="org.alfresco.deployment.SampleRunnable" />
					</list>
				</property>
				<property name="fileSystemReceiverService">
					<ref bean="fileSystemReceiverService" />
				</property>
				<property name="name"><value>sampleTarget</value></property>
				<property name="authenticator">
					<bean
						class="org.alfresco.deployment.impl.server.DeploymentReceiverAuthenticatorSimple">
						<property name="user">
							<value>Giles</value>
						</property>
						<property name="password">
							<value>Watcher</value>
						</property>
					</bean>
				</property>
			</bean>
		</property>
	</bean>	

[edit] Extending the File System Deployment Target

[edit] prepare callback

The prepare callbacks (which are also implementations of the same FSDeploymentRunnable interface used in postCommit callbacks) are called by the File System Deployment Targets immediately after the complete set of deployment files have been transferred to the File System Deployment Targets's temporary storage areas.

If exceptions are thrown by the callbacks then the deployment will fail and be rolled back. The exception will be propagated to the system calling the File System Deployment Targets and the exception should be logged on both File System Deployment Targets and calling system.

The callbacks occur within the deployment transaction so should minimise the time they take to run since there are resources waiting for deployment to complete.

To register a prepare callback add your bean to the "prepare" property of the target definition.

e.g.

<property name="prepare">
     <list>
	<bean class="org.alfresco.deployment.SampleRunnable" />
     </list>
</property>

[edit] postCommit callback

There is a postCommit callback available which is called after each successful deployment. For example some users of alfresco use ftp to transfer files or send emails when deployment is complete.

If exceptions are thrown by the callbacks then the exceptions will be logged. But it is too late to do anything else.

There is a sample adapter that will call an operating system command, such as a batch script, or the callback can call a custom java class.

The callback(s) are configured in the 'target' properties of the deployment configuration. They are called in sequence.

Diagram to show the FSDeploymentRunnable class

Image:FSDeployment runnable class.jpg

Users need to implement the 'FSDeploymentRunnable' interface.

Two implementations are provided.

SampleRunnable 
an example java class that demonstrates how to use this feature
ProgramRunnable 
execute a operating system command after deployment

To register a postCommit callback add your bean to the "postCommit" property of the target definition.

e.g.

<property name="postCommit"> 
    <list> 
        <bean class="org.alfresco.deployment.SampleRunnable"/> 
    </list>
</property>